Skip to content
/ aplus-jvm Public

A simple Java Virtual Machine for aplus

License

Notifications You must be signed in to change notification settings

kwrx/aplus-jvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aplus-jvm

Build Status License: MIT

Simple Java Virtual Machine developed for aplus

How to run?

# Clone repository
$> git clone https://github.com/kwrx/aplus-jvm
$> cd aplus-jvm

# Configure & Build
$> ./configure --prefix=DESTDIR
$> make
$> make install

NOTE: Replace DESTDIR with your destionation path, default: /usr/local
NOTE: See ./configure --help for more infos

Example

//
// Calc.java
//                         
public class Calc {                            
 public static int Sum(int a, int b) {         
     return a + b;                             
 }                                             
}                                             
//
// main.c
//
int main(int argc, char** argv) {

    /* Initialize VM */
    avm_init();

    /* Open Calc.class */
    if(avm_open("Calc.class") == J_ERR) { 
        perror("Calc.class");
        abort(); 
    }
    

    /* Initialize context & resolve assemblies */
    avm_begin();


    j_value a, b;
    
    a.i32 = 10;
    b.i32 = 15;

    /* c = Calc.Sum(a, b); */
    j_value c = avm_call("Calc", "Sum", 2, a, b);
    
    
    /* Destroy context & all resources */
    avm_end();
    
    
    printf("The sum of %d + %d = %d\n", a.i32, b.i32, c.i32);

}

License

Copyright (c) Antonino Natale. All rights reserved.

Licensed under the MIT license.

About

A simple Java Virtual Machine for aplus

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published