Hosting the Java compiler in an applet or in Googl

2019-05-23 04:21发布

Searching the web I've found that the Javac compiler is written in Java, and I also peeked at the source on Sun's site. The source is quite big and I couldn't make any headway on it. Also the Eclipse project has a compiler embedded inside, but who could touch its source code ;-).

So I thought I'd throw a couple of questions your way:

  1. Could the Java compiler be hosted in an Applet?
  2. Could the Java compiler be made to work on GAE, with dynamic loading of the resulting class files from the datastore?

2条回答
\"骚年 ilove
2楼-- · 2019-05-23 04:55

Yes, the compiler as such is really just a normal Java application (except that it usually brings its own native launcher, but that's not required).

So you can easily run it within an Applet or inside GAE.

However that won't really help too much, because if you want to actually run the produced classes, then you'd need to play with ClassLoader instances which is not allowed in (unsigned) Applets and probably not allowed in GAE.

查看更多
【Aperson】
3楼-- · 2019-05-23 04:59

..Could java compiler be hosted in an applet?

Only if you add the tools.jar to the runtime class-path of the applet. See Add the compiler to the application's runtime classpath in the STBC help for details.

..Could java compiler be made to work on GAE, ..

Not sure, though note that someone seems to have registered a Google app. by the name of 'javacompiler'. ;)

查看更多
登录 后发表回答