且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过Ant编译JDK

更新时间:2022-10-14 23:05:53

构建JDK本身是一个复杂的过程,是无法实现通过一个简单的的javac 呼叫包裹内的蚂蚁项目。

您应该看看的OpenJDK构建自述以得到关于如何建立你的平台的说明。

I want to compile jdk files in order to include debug infromation. I'd like to use ant, because it's included in my NetBeans environement, so i've done the following:

  1. unzipped /src.zip in a tmp directory
  2. created a very simple build.xml file (one default target, one taks) in my tmp directory:

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="CompileJDK" default="default" basedir=".">
    <target name="default">
    <javac srcdir="."
             destdir="jdkwd"
             debug="on"
    />
    </target>
    </project>

  1. created a jdkwd directory
  2. launched ant without parameters (just >log.txt)

This leads to 100 compilation errors such as:

    [javac] C:\jdkdebug\java\awt\Window.java:196: cannot find symbol
[javac] symbol  : class IdentityArrayList
[javac] location: class java.awt.Window
[javac]     private static final IdentityArrayList<Window> allWindows = new IdentityArrayList<Window>();

I have just one JDK installed on my machine, so i don't know why it does not resolve all this references.

UPDATE: The majority of these unresolved references belongs to the package:

sun.awt.util

The question now is corrected to: where are the missing jdk files?

Building the JDK itself is a complex process and is not achievable by a simple javac call wrapped inside an ant project.

You should look at the OpenJDK Build README to get instructions on how to build for your platform.