teavm icon indicating copy to clipboard operation
teavm copied to clipboard

is native but has no annotation

Open frankbauer opened this issue 6 years ago • 3 comments

Hi.

I was trying to use the SystemCompiler in a TeaVM Project with a WASM target:

JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
String[] compilerArgs = { "public class Foo { }" };
compiler.run(null, null, null, compilerArgs);

However building it gives me the following (among many other) errors:

Method org.teavm.jso.typedarrays.Int8Array.create(I)Lorg/teavm/jso/typedarrays/Int8Array; is native but has no org.teavm.interop.Import annotation on it Method org.teavm.jso.ajax.XMLHttpRequest.create()Lorg/teavm/jso/ajax/XMLHttpRequest; is native but has no org.teavm.interop.Import annotation on it

Did I miss an important setup step? I was trying a basic Hello World first to test the toolchain, and that did work.

frankbauer avatar Dec 03 '18 15:12 frankbauer

  1. TeaVM is not a JVM! It most likely won't run heavyweight applications like javac, Eclipse or Tomcat. It's usecase it close to GWT: you write code in subset of Java (mostly subset of Java libraries, with 100% syntax).
  2. WebAssembly backend is experimental, which means it does not support 100% of features available in JavaScript backend. What version of TeaVM are you using? You better use 0.6.0 versions published on bintray. Is there any reason you prefer to use WebAssembly instead of JavaScript target?
  3. There's successfull attempt to compile javac to JavaScript: teavm-javac. It does not work with WebAssembly yet. Also, it's a little bit outdated, I'll update it later.

konsoletyper avatar Dec 03 '18 15:12 konsoletyper

Thanks for the fast feedback.

  1. I am currently using 0.6.0-dev-623
  2. I thought WebAssembly would have performance advantages over plain JavaScript. But I do not have any preferences. Thanks for the link, this looks promising.

frankbauer avatar Dec 03 '18 15:12 frankbauer

I am not sure about what you mean. I suppose you can copy compiled result to tomcat,and visit the html in browser. Here is a blog(You can ignore chinese text, read command and image) https://blog.csdn.net/quantum7/article/details/113875769

quantum6 avatar Jun 03 '21 08:06 quantum6