在小程序或 Google AppEngine 中托管 Java 编译器?
在网上搜索我发现Javac编译器是用Java编写的,并且我还查看了Sun网站上的源代码。来源相当大,我无法取得任何进展。此外,Eclipse 项目内部嵌入了一个编译器,但谁能接触它的源代码;-)。
所以我想我应该向您提出几个问题:
- Java 编译器可以托管在 Applet 中吗?
- 是否可以使 Java 编译器在 GAE 上工作,并从数据存储中动态加载生成的类文件?
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:
- Could the Java compiler be hosted in an Applet?
- Could the Java compiler be made to work on GAE, with dynamic loading of the resulting class files from the datastore?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这样的编译器实际上只是一个普通的 Java 应用程序(除了它通常带有自己的本机启动器,但这不是必需的)。
因此您可以在 Applet 或 GAE 中轻松运行它。
但是这并没有太大帮助,因为如果你想实际运行生成的类,那么你需要使用
ClassLoader
实例,这是不允许的(未签名)小程序,GAE 中可能不允许。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.仅当您将
tools.jar
添加到小程序的运行时类路径时。有关详细信息,请参阅 STBC 帮助中的将编译器添加到应用程序的运行时类路径。不确定,但请注意有人似乎已经注册了Google应用程序。名为“javacompiler”。 ;)
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.Not sure, though note that someone seems to have registered a Google app. by the name of 'javacompiler'. ;)