简体   繁体   English

如何从源代码(JDK 中的 src.zip)构建 java JRE?

[英]How does one build the java JRE from source (src.zip in JDK)?

Surprisingly enough I couldn't find the answer to this question.令人惊讶的是,我找不到这个问题的答案。

I am trying to rebuild the java JRE from source.我正在尝试从源代码重建 java JRE。 I obtain the java JRE source by extracting the src.zip file in the JDK.我通过在 JDK 中提取 src.zip 文件来获取 java JRE 源代码。

After making any changes I need to make to the JRE, how do I compile the new source back into .java files (after which I can compress it into the rt.jar file).在对 JRE 进行任何需要进行的更改后,如何将新源编译回 .java 文件(之后我可以将其压缩到 rt.jar 文件中)。

Thanks.谢谢。

You have better chances using OpenJDK (the base of Oracle/ Sun's future JDKs).您有更好的机会使用 OpenJDK(Oracle/Sun 未来 JDK 的基础)。 http://openjdk.java.net/ http://openjdk.java.net/

But what do you want to change actually?但实际上你想改变什么? Maybe there is a better way...也许有更好的方法...

If you want to change a number of class, you only need to compile those classes.如果你想改变一些类,你只需要编译那些类。 You don't need to compile the whole JDK unless you intend to replace it.除非您打算替换它,否则您不需要编译整个 JDK。

If you just want to patch it, create a JAR of your changed classes and add this to the boot class path.如果您只想修补它,请为您更改的类创建一个 JAR,并将其添加到引导类路径中。

Some of the Java sources that make up rt.jar are generated during the build process, from scripts and other means.组成 rt.jar 的一些 Java 源代码是在构建过程中通过脚本和其他方式生成的。 Some of the properties files are also generated this way, and some of the properties files are turned into Java source that also contributes to rt.jar.一些属性文件也是通过这种方式生成的,并且一些属性文件被转化为Java源代码,也有助于rt.jar。 So without doing a complete build first and populating the 'gensrc' directory, you won't have all the sources that make up rt.jar.因此,如果不先进行完整的构建并填充“gensrc”目录,您将不会拥有组成 rt.jar 的所有源代码。

Taken from: http://www.java.net/forum/topic/jdk/java-se-snapshots-project-feedback/it-possible-just-build-rtjar摘自: http : //www.java.net/forum/topic/jdk/java-se-snapshots-project-feedback/it-possible-just-build-rtjar

So when you say javac on all the java files inside src.zip it won't compile as the dependency graph is broken (missing generated files)因此,当您对 src.zip 中的所有 java 文件说 javac 时,它不会编译,因为依赖关系图已损坏(缺少生成的文件)

Also have a look at this: Where to get full source code for rt.jar?也看看这个: 从哪里获得 rt.jar 的完整源代码?

After revisiting the question.重温这个问题后。 Javac on any of those files will allow you to rebuild them.任何这些文件上的 Javac 将允许您重建它们。 Also you don't compile .java files into .java files they become .class files.此外,您不会将 .java 文件编译为 .java 文件,它们会变成 .class 文件。 You can write an ANT build script to handle the heavy work for you.您可以编写一个 ANT 构建脚本来为您处理繁重的工作。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM