我只是想知道 java.lang.Object、java.lang.String 等类(在 Oracle 提供的 rt.jar 内)是如何从 .java 源文件生成的。我认为,他们的javac不可能编译它们。
我试图编译包含“class Dummy{}”的 Dummy.java
lab@labb:~/Documents$ 设置 PATH=.:$JAVA_HOME/bin
lab@labb:~/Documents$ 设置 CLASSPATH=。
lab@labb:~/Documents$ javac -verbose Dummy.java
[解析开始RegularFileObject[Dummy.java]]
【解析完成12ms】
[源文件的搜索路径:.]
【类文件的搜索路径:/usr/lib/jvm/java-7-oracle/jre/lib/resources.jar,/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar,/ usr/lib/jvm/java-7-oracle/jre/lib/sunrsasign.jar,/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar,/usr/lib/jvm/java- 7-oracle/jre/lib/jce.jar,/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar,/usr/lib/jvm/java-7-oracle/jre/classes, /usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar,/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar,/usr/lib /jvm/java-7-oracle/jre/lib/ext/zipfs.jar,/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar,/usr/lib/jvm/java -7-oracle/jre/lib/ext/sunec.jar,/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar,.]
[加载 ZipFileIndexFileObject[/usr/lib/jvm/java-7-oracle/lib/ct.sym(META-INF/sym/rt.jar/java/lang/ Object .class)]]
[检查假人]
[加载 ZipFileIndexFileObject[/usr/lib/jvm/java-7-oracle/lib/ct.sym(META-INF/sym/rt.jar/java/lang/ AutoCloseable .class)]]
[写了 RegularFileObject[Dummy.class]] [总共 131 毫秒]