简体   繁体   English

Eclipse:在项目的构建路径中编辑属于jar的任何.class文件,并自动生成与这些编辑相对应的新类文件

[英]Eclipse: Edit any .class file belonging to the jars in a project's build path and auto-generate a new class file corresponding to these edits

In Eclipse, I can browse through the jars( that my project depends on) and open any class file from these jars. 在Eclipse中,我可以浏览jar(我的项目所依赖的jar)并打开这些jar中的任何类文件。 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. 但是,我无法编辑这些文件,甚至更好,能够自动生成与我所做的编辑相对应的.class。

For eg., lets take the log4j library. 例如,让我们使用log4j库。 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. 一旦执行了该操作,在包管理器中就可以看到log4j jar文件,并且可以浏览该jar文件中的类文件,并能够读取jar文件中的任何类文件。 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. 我正在尝试做的是能够编辑任何类文件(例如org.apache.log4j.Appender)并自动生成与我对该类所做的编辑相对应的新类。

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. 拥有这样的功能将非常有帮助,尤其是在使用开源库(log4j,gwt等)并且对快速测试想要为这些开源社区做出贡献的任何新功能感兴趣时。

thanks 谢谢

No. 没有。

You can view the source code because Maven downloads and attaches the source JARs for you. 您可以查看源代码,因为Maven为您下载并附加了源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). 不。您正在查看的源代码不是来自类文件,而是来自jar中包含的单独源文件(较不常见),或者来自仅包含源代码的另一个jar(较常见)。 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. 要执行所需的操作,需要将源重新编译为类文件,然后重新构建jar文件以包含该类。 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. 然后让您的其他项目而不是jar版本依赖于此。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让Eclipse自动生成新Java类的main方法? - How do you get Eclipse to auto-generate a main method for a new Java class? 在Eclipse中自动生成类层次结构和代码结构 - Auto-generate class hierarchy and code structure in Eclipse Eclipse可以自动生成第三方库类的接口吗? - Can Eclipse auto-generate an interface of a 3rd party library class? Eclipse Java部署:如何将自动生成的文件添加到Jar文件 - Eclipse Java Deployment: how to add auto-generate file to Jar file 在eclipse中自动生成界面 - Auto-generate Interface in eclipse 有没有一种方法可以通过ANT或其他构建自动化系统自动生成JWG文件/编译Openscript文件? - Is there a way to auto-generate a JWG file/compile an Openscript file through ANT or some other build automation system? 如何在使用build.xml文件的Ant生成的jar文件中包含Eclipse项目的“Java Build Path”部分中引用的jar文件 - How to include the jars referenced in “Java Build Path” section of an Eclipse project in a jar file generated with Ant using a build.xml file 如何在 Eclipse 中重命名一个类及其对应的文件? - How to rename a class and its corresponding file in Eclipse? 如何在构建过程中自动生成pom文件以上传到maven2存储库? - How to auto-generate a pom file during build for upload to a maven2 repository? 自动生成委托/封装代码 class(在 Intellij 中) - auto-generate code for delegation/encapsulation class (in Intellij)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM