Eclipse:编辑属于项目构建路径中 jar 的任何 .class 文件,并自动生成与这些编辑相对应的新类文件
在 Eclipse 中,我可以浏览 jar(我的项目所依赖的)并打开这些 jar 中的任何类文件。一旦我打开一个类文件,就会显示该类文件对应的源代码。
但是,我不能做的是编辑这些文件,甚至更好的是,能够自动生成与我所做的编辑相对应的 .class。
例如,让我们以 log4j 库为例。假设我将其添加到我的项目的构建路径中;一旦我这样做了,log4j jar 文件就会在我的 Package Explorer 中可见,我将能够浏览此 jar 文件中的类文件,并能够读取 jar 文件中的任何类文件。我想做的是能够编辑任何类文件(例如 org.apache.log4j.Appender)并自动生成与我对该类所做的编辑相对应的新类。
有没有一个插件可以让我做到这一点?
拥有这样的功能将非常有帮助,特别是当您使用开源库(log4j、gwt 等)并且有兴趣快速测试您想要为这些开源社区贡献的任何新功能时。
谢谢
In Eclipse, I can browse through the jars( that my project depends on) and open any class file from these jars. Once I open a class file, the source corresponding to this class file will be displayed.
But, what I can't do is edit these files and even better, be able to auto-generate the .class corresponding to the edits I have made.
For eg., lets take the log4j library. Lets say I add it to my Project's build path; once I do that the log4j jar file is visible in my Package Explorer and I would able to browse through the class files in this jar file and be able to read any class file within the jar file. What I am trying to do is be able to edit any class file (say for eg., org.apache.log4j.Appender) and auto-generate a new class corresponding to the edits I have made on this class.
Is there a plugin that would allow me to do this ??
It would be very helpful to have such a functionality especially when you are working with open-source libraries(log4j, gwt etc) and are interested in quickly testing any new functionality you would like to contribute to these open-source communities.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不需要。
您可以查看源代码,因为 Maven 会为您下载并附加源 JAR。
No.
You can view the source code because Maven downloads and attaches the source JARs for you.
不,您正在查看的源不是来自类文件,而是来自 jar 中包含的单独源文件(不太常见),或者来自另一个仅包含源的 jar(更常见)。要执行您想要的操作,需要将源代码重新编译为类文件,然后重建 jar 文件以包含该类。这将有效地重建整个项目。
如果您想编辑开源库项目,您应该在工作区中为其创建一个新项目,并从版本控制中检出该项目。然后让你的其他项目依赖于此而不是 jar 版本。
No. the source you are viewing is not from the class file, it's from separate source files included in the jar (less common) or it's from another jar that contains just the source (more common). To do what you want it would need to recompile the source to the class file, and then rebuild the jar file to contain that class. It would be effectively rebuilding the entire project.
If you want to edit an open source library project you should create a new project in your workspace for it, checking out the project from version control. Then have your other project depend on this instead of the jar release.