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:
- unzipped /src.zip in a tmp directory
- 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>
- created a jdkwd directory
- 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.
http://www.oracle.com/technetwork/java/faq-141681.html
A14. Where can I get the Java programming language source code?
Java Software has two separate bundles of source code that you can obtain at no charge:
The Java 2 SDK, Standard Edition itself contains a file called src.zip that contains the source code for the public classes in the java package. Because this does not contain sun.* classes, you cannot do a complete build of the Java technology from these source files. These source files are for your information, to supplement the documentation, so you can see how Java technology works.
The full source code release is available from us by going to the Community Source Code Licensing web site..
The community source code link is incorrect: it's now http://download.java.net/openjdk/jdk7/
Try adding a classpath to your javac call.
<classpath path="/PATH/to/missing_class/" />
Also, try running ant with the -d and -v options. It's a lot of output but will show you where its searching for classes.
According to this post (from 2007), you should include rt.jar and tools.jar on your classpath to compile the JRE sources.
However, I tried that, and it doesn't work for me (100 errors).
There are more elaborate and older (2004) instructions in christhielen's post in the Java bug requesting debug symbols.
If you use Gentoo compiling OpenJDK would be as simple as running emerge dev-java/icedtea
.
There is a debug
use flag that would switch off all optimizations, I haven't tried it myself but chances are that this is what you want. If it's not - then it should not be a big deal to change build scripts, but would require you to learn a little bit of portage.