[浅读openjdk7] 0. 获取openjdk7源代码
呃,我自己都觉得很惭愧… 距离那篇 [浅读openjdk6] 0. 获取openjdk6源代码 过去了要2年了吧,期间总算不出意外地没有怎么继续那个系列。草稿箱里累积了大概5篇,顺着main函数开始的一些理解,结果还是没能坚持下来,哪天都删掉好了… 最近身边一个小朋友也开始看openjdk6了,加上网上某些著名人士年前也都零零散散地开始看代码并且发布了些blog,各种奋发图强人士让我感觉真是情何以堪。想了想,不行我也继续看吧,只不过目标换到了openjdk7,不是为了别人看6我看7显得多牛逼,而是对project coin那些小改动比较感兴趣。 结果,因为现在换了MacBook Pro了,不再频繁用Linux,照着自己以前在Linux下的方法做果然没能成功(呃,简直是一定的吧,尤其我也不是MacPorts用户),上网搜了搜,发现一篇 Build OpenJDK Java 1.7.0 on Mac OS X 10.5 ,已经装过MacPorts的权当参考吧,其实和Linux下差不多了。不过我不老喜欢MacPorts那样的东西,原先也许会喜欢吧,原汁原味的感觉,但是到了要决定是不是真要搞到自己机器上来的那一霎那,就觉得它太过臃肿了,转去用Homebrew了,虽然我也不是ruby用户… 继续搜,然后发现,好像年初的时候openjdk在BSD port的基础之上有了专门的mac os x port项目,见 http://mail.openjdk.java.net/pipermail/macosx-port-dev/2011-January/000007.html ,Apple员工发的,也算是Oracle宣称的和Apple合作提高OpenJDK在Mac机器上的覆盖面吧——这点来说Oracle至少及格了,借用开源的openjdk和Apple这样的商业公司达成了某些协议,阻止乔不死大爷试图在Mac上扼杀Java的企图。 所以现在如果在Mac OS X上想要拿到openjdk7的代码,需要clone专门的那个mac os x port项目的代码库: [code lang=“bash”] hg clone http://hg.openjdk.java.net/macosx-port/macosx-port cd macosx-port chmod a+x get_source.sh ./get_source.sh [/code] 这样这个脚本会自动去clone位于macosx-port项目下的corba,jaxp,jaxws,langtools,jdk和hotspot这些子项目,和标准的其他平台上的openjdk7是一样的。看脚本的代码应该是不再需要mercurial的forest那个插件了,不过里面也写到了fclone分支,不知道到底什么动机,所以为求保险,建议还是安装forest插件,但是最开始的老版的forest插件已经不维护了,更新的在 http://hg.akoha.org/hgforest/ ,github上也看到过一个fork,说是提供了一些bug fix,不过我没试过。对于Linux和Windows来说,hg fclone依旧,顶层库的URL为http://hg.openjdk.java.net/jdk7/jdk7/ 。 此外,Mac上XCode据说也要安装,最低要3.2.x。不知道对于拿代码来说是不是必需的,不过后期做build肯定是必备无疑。 最后,以./get_source.sh运行输出结尾。 [code lang=“bash”] iusr-mbp:macosx-port iusr$ ./get_source.sh # Repos: corba jaxp jaxws langtools jdk hotspot Starting on corba Starting on jaxp Starting on jaxws Starting on langtools Starting on jdk Starting on hotspo t# hg clone http://hg.openjdk.java.net/macosx-port/macosx-port/corba corba requesting all changes adding changesets adding manifests adding file changes added 333 changesets with 3221 changes to 1379 files updating to branch default 1357 files updated, 0 files merged, 0 files removed, 0 files unresolved # exit code 0 # hg clone http://hg.openjdk.java.net/macosx-port/macosx-port/jaxp jaxp requesting all changes adding changesets adding manifests adding file changes added 252 changesets with 2188 changes to 1984 files updating to branch default 18 files updated, 0 files merged, 0 files removed, 0 files unresolved # exit code 0 # hg clone http://hg.openjdk.java.net/macosx-port/macosx-port/jaxws jaxws requesting all changes adding changesets adding manifests adding file changes added 242 changesets with 6427 changes to 3002 files updating to branch default 18 files updated, 0 files merged, 0 files removed, 0 files unresolved # exit code 0 # hg clone http://hg.openjdk.java.net/macosx-port/macosx-port/langtools langtools requesting all changes adding changesets adding manifests adding file changes added 945 changesets with 12323 changes to 4546 files updating to branch default 4225 files updated, 0 files merged, 0 files removed, 0 files unresolved # exit code 0 # hg clone http://hg.openjdk.java.net/macosx-port/macosx-port/hotspot hotspot requesting all changes adding changesets adding manifests adding file changes added 2287 changesets with 20293 changes to 4202 files updating to branch default 3903 files updated, 0 files merged, 0 files removed, 0 files unresolved # exit code 0 # hg clone http://hg.openjdk.java.net/macosx-port/macosx-port/jdk jdk requesting all changes adding changesets adding manifests adding file changes added 3767 changesets with 54877 changes to 20574 files updating to branch default 19580 files updated, 0 files merged, 0 files removed, 0 files unresolved # exit code 0 # Repos: . ./corba ./hotspot ./jaxp ./jaxws ./jdk ./langtools Starting on . Starting on ./corba Starting on ./hotspot Starting on ./jaxp Starting on ./jaxws Starting on ./jdk Starting on ./langtools # cd . && hg pull -u pulling from http://hg.openjdk.java.net/macosx-port/macosx-port searching for changes no changes found # exit code 0 # cd ./hotspot && hg pull -u pulling from http://hg.openjdk.java.net/macosx-port/macosx-port/hotspot searching for changes no changes found # exit code 0 # cd ./corba && hg pull -u pulling from http://hg.openjdk.java.net/macosx-port/macosx-port/corba searching for changes no changes found # exit code 0 # cd ./langtools && hg pull -u pulling from http://hg.openjdk.java.net/macosx-port/macosx-port/langtools searching for changes no changes found # exit code 0 # cd ./jaxws && hg pull -u pulling from http://hg.openjdk.java.net/macosx-port/macosx-port/jaxws searching for changes no changes found # exit code 0 # cd ./jaxp && hg pull -u pulling from http://hg.openjdk.java.net/macosx-port/macosx-port/jaxp searching for changes no changes found # exit code 0 # cd ./jdk && hg pull -u pulling from http://hg.openjdk.java.net/macosx-port/macosx-port/jdk searching for changes no changes found # exit code 0 [/code]