Closed
Issue #91 · created by Jim Sproch ·


Merge `Java` and `JavaPoly` globals

We should merge the Java (eg. Java.type()) and JavaPoly objects. J is just an alias for Java, so it would be merged too. JavaPoly should be the default JVM as well as a constructor for creating JVMs.

// Run using a "default" JVM
var JavaPoly = require('javapoly');
JavaPoly.addClass('/path/to/SomeClass.java');
JavaPoly.addClass('/path/to/SomeClass2.class');
JavaPoly.type('SomeClass').then(function(SomeClass){SomeClass.doSomething();});
// Run using an "explicit" JVM
var JavaPoly = require('javapoly');
var jvm = new JavaPoly({ /* options */ });
jvm.addClass('/path/to/SomeClass.java');
jvm.addClass('/path/to/SomeClass2.class');
jvm.type('SomeClass').then(function(SomeClass){SomeClass.doSomething();});

The "default" JVM should be started if/when someone invokes JavaPoly.type(...). An "explicit" JVM should be start if/when someone invokes (new JavaPoly()) to create a new JVM and then invokes .type(...) which lazily starts the JVM. So in a sense, the type of JavaPoly is a JVM (the default jvm) and the type of new JavaPoly() is also a JVM (an explicit jvm). JVMs are started lazily, upon first use.

Related to #89 and #90


4 participants
jimsproch/JavaPoly#91

Assignee: none

Milestone: none


Votes
0 up
0 down