Simple Java Virtual Machine developed for aplus
# 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
//
// 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);
}
Copyright (c) Antonino Natale. All rights reserved.
Licensed under the MIT license.