Could you please advise how the JDK source files can be compiled with debug information using Javac.
I am using the following command:
javac -J-Xms16m -J-Xmx1024m -source 8 -target 8 -sourcepath d:\jdk_src -classpath ".:rt.jar:javax-crypto.jar:ui.jar" -bootclasspath ".:rt.jar:javax-crypto.jar:ui.jar" -d "jdk_debug" -g @filelist.txt >> log.txt 2>&1
Steps to reproduce:
dir /B /S /X jdk_src\*.java > filelist.txt
Instead of the classes being compiled successfully, errors like the following are being raised:
\jdk\jdk_src\java\lang\reflect\AccessibleObject.java:29: error: package sun.reflect does not exist import sun.reflect.Reflection;
\jdk\jdk_src\java\lang\reflect\AccessibleObject.java:30: error: package sun.reflect does not exist import sun.reflect.ReflectionFactory;
\jdk\jdk_src\java\util\jar\Attributes.java:37: error: package >sun.util.logging does not exist
These packages are present in the provided jars (rt.jar, ui.jar and javax-crypto.jar). Could you please explain why the source code is not being compiled since the classpath files are given to the compiler?
Any feedback will be appreciated.
Thank you.
The Java source code is not designed to be built that way. What to should do is to checkout the OpenJDK source tree and follow the build instructions in the source tree. You should be able to tweak the build scripts to compile with debug information ... and either use the built "rt.jar" directly or extract the classes that you need from the build artifacts.
You can get the Java 8 source code from Github: https://github.com/openjdk/jdk8u. (Other versions are nearby ...) Select the git tag corresponding to the Java version that you want to build. The links to the build instructions are in the README.md
file.
It is not entirely clear why the compilation is failing when you do it the way you are doing. However, the javac
compiler implements some restrictions that are designed to stop you compiling ordinary application code against internal APIs in the "rt.jar". Some of the "src.zip" code you are compiling (legitimately) depend on the internal APIs.