jtulach / bck2brwsr

Bck2Brwsr VM to transpile Java bytecode to JavaScript
http://bck2brwsr.apidesign.org
Other
114 stars 16 forks source link

Allow native methods to be implemented by javascript code #42

Closed johanvos closed 3 years ago

johanvos commented 3 years ago

A number of applications/libs use JNI with platform-specific implementations of native Java methods. This can currently be done with bck2brwsr already with a JavaScript implementation, but it requires the addition of an annotation to the Java code. By providing a simple mechanism in the bytecode2javascript generator, we can as a last resort, when there is on annotation on a native method, check if there is a javascript method that has the signature of the native method, and if so invoke it.

jtulach commented 3 years ago

I agree that having an ability to patch (native) methods of existing classes would be handy. fe5bdfa shows how to do that in current Bck2Brwsr.