I found the post about compiling javascript to java using Rhino compiler. I was able to get the simple case to work and invoke the methods in java. However, I have some questions, and hope I can get them answered here.
How do I compile the below code to TestObject.class with method (setTmpValue,getTmpValue,getType) and constructor of 1 arguments? Or it is not possible?
function TestObject(params) { this.type= params.type; var tmpValue = 0; this.setTmpValue = function ( val ) { tmpValue = val; }; this.getTmpValue = function () { return tmpValue; }; this.getType = function () { return type }; }
Is it possible to refer a class that will be compiled from other js file?
Example: Can I invoke B in A? or do new B() in A? A.js -> A.class B.js -> B.class
How does the scope work for these compiled classes?
- Is there other documentation than the one Here?
Thanks in advance for helping out!