我想知道是否已经有一个库可以以编程方式编写Java类或方法?
I was wondering if there is already a library to programmatically write a java class or method?
我正在寻找能够将新源代码写入现有文件的库或扩展已经存在的文件。
I am looking for libraries capable of writing new source code into existing files or extend files that already exist.
推荐答案查看 Eclipse JDT 。
Eclipse Java开发工具(JDT)提供用于访问和操作Java源代码的API。它允许访问工作空间中的现有项目,创建新项目以及修改和读取现有项目。
The Eclipse Java Development Tools (JDT) provide APIs to access and manipulate Java source code. It allows to access the existing projects in the workspace, create new projects and modify and read existing projects.
更具体地说,您可以创建新的Java元素,例如项目,程序包,类,然后使用Java模型API,然后您可以创建/修改类型为以下内容的内容:方法,通过AST的语句(抽象语法树)
More specifically, you can create new Java elements e.g. projects, packages, classes using the Java Model API and then you can then create/modify contents of a type e.g. methods, statements via the AST (Abstract Syntax Tree)
您应该看到此文章以及此教程。
You should see this article and also this tutorial.
更多推荐
以编程方式编写Java
发布评论