本帖最后由 杨兴庭 于 2013-7-9 11:19 编辑
现在复习以前的东西,所以有些东西研究得细致一点,所以碰到下面的问题了, 下面是我在 windows 命令行编译一个 .java 程序,时能 verbose 选项时打印的东西:
D:\j2se 练习\others>javac -verbose RandomTest.java [语法分析开始时间 RegularFileObject[RandomTest.java]]
[语法分析已完成, 用时 15 毫秒]
[源文件的搜索路径: .]
[类文件的搜索路径: D:\Program Files (x86)\Java\jdk1.7.0_15\jre\lib\resources.jar
,D:\Program Files (x86)\Java\jdk1.7.0_15\jre\lib\rt.jar,D:\Program Files (x86)\J
ava\jdk1.7.0_15\jre\lib\sunrsasign.jar,D:\Program Files (x86)\Java\jdk1.7.0_15\j
re\lib\jsse.jar,D:\Program Files (x86)\Java\jdk1.7.0_15\jre\lib\jce.jar,D:\Progr
am Files (x86)\Java\jdk1.7.0_15\jre\lib\charsets.jar,D:\Program Files (x86)\Java
\jdk1.7.0_15\jre\lib\jfr.jar,D:\Program Files (x86)\Java\jdk1.7.0_15\jre\classes
,D:\Program Files (x86)\Java\jdk1.7.0_15\jre\lib\ext\access-bridge-32.jar,D:\Pro
gram Files (x86)\Java\jdk1.7.0_15\jre\lib\ext\dnsns.jar,D:\Program Files (x86)\J
ava\jdk1.7.0_15\jre\lib\ext\jaccess.jar,D:\Program Files (x86)\Java\jdk1.7.0_15\
jre\lib\ext\localedata.jar,D:\Program Files (x86)\Java\jdk1.7.0_15\jre\lib\ext\s
unec.jar,D:\Program Files (x86)\Java\jdk1.7.0_15\jre\lib\ext\sunjce_provider.jar
,D:\Program Files (x86)\Java\jdk1.7.0_15\jre\lib\ext\sunmscapi.jar,D:\Program Fi
les (x86)\Java\jdk1.7.0_15\jre\lib\ext\sunpkcs11.jar,D:\Program Files (x86)\Java
\jdk1.7.0_15\jre\lib\ext\zipfs.jar,.]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/Object.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/String.class)]]
[正在检查RandomTest]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/System.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/io/PrintStream.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/io/FilterOutputStream.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/io/OutputStream.class)]]
[已写入RegularFileObject[RandomTest$1.class]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/StringBuilder.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/CharSequence.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/io/Serializable.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/Comparable.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/AbstractStringBuilder.class)]]
[正在加载ZipFileIndexFileObject[D:\Program Files (x86)\Java\jdk1.7.0_15\lib\ct.s
ym(META-INF/sym/rt.jar/java/lang/StringBuffer.class)]]
[已写入RegularFileObject[RandomTest.class]]
[共 530 毫秒]
问题在这里 从这个结果可以看出, java compiler 至少做了 1.分析 java 源文件 2.搜索源文件路径 3.搜索类文件路径 4.加载依赖的类 5.把结果写入 .class 文件,但是这5个事情 javac 到底是怎么做的,请高人解答一下,如果有和我一样想知道的同学请帮忙点一下这个
免得没人看到就沉了,小弟在此先行谢过!
|