Bytecoder
Bytecoder copied to clipboard
Native constructors
This issue is a suggestion. At the moment it is not possible to instantiate JavaScript classes from Java without using static native methods, an annotation for this purpose would be nice to have.
public class ArrayBuffer implements OpaqueReferenceType {
@NativeConstructor("create")
public ArrayBuffer(int size) {}
}
bytecoder.imports.arraybuffer = {
create: function (...) { ... }
};
new ArrayBuffer(4);
This is a very useful feature request. Thank you for submitting this!
Now that I think about it, instantiating abstract classes directly isn't possible. However, if using @OpaqueMethod/Property works with native
methods then this shouldn't be a problem as one could use non-abstract classes instead.
Closed due to no further feedback.