在小程序或 Google AppEngine 中托管 Java 编译器?

在小程序或 Google AppEngine 中托管 Java 编译器?

问题描述:

在网上搜索我发现Javac 编译器是用Java 编写的,而且我还查看了Sun 站点上的源代码.来源相当大,我无法取得任何进展.Eclipse 项目也有一个内嵌的编译器,但谁能触及它的源代码;-)

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. Java 编译器可以托管在 Applet 中吗?
  2. 能否让 Java 编译器在 GAE 上工作,并从数据存储动态加载生成的类文件?

是的,这样的编译器实际上只是一个普通的 Java 应用程序(除了它通常带有自己的本地启动器,但这不是必需的).

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).

因此您可以轻松地在 Applet 或 GAE 中运行它.

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

然而这并没有太大帮助,因为如果您想实际运行生成的类,那么您需要使用 ClassLoader 实例,它是不允许在(未签名的)Applet 中并且可能不允许在 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.