In the JDK-8, we could compile our changed java.lang classes and reconstruct the rt.jar
. Then we could overwrite java.lang classfiles by augmenting the bootclasspath with -Xbootclasspath:<yourpathto>/rt.jar
. Doing this, we could for example make java.lang.Integer be non-final for testing purposes.
In JDK-11, this is different. Patching is done via --patch-modules
and I can't get it to work. I have done the following:
- Remove the final modifier and recompiled the java.base module from the openjdk-11 source
- Added the
--patch-module java.base=<path-to-my-compiled-java.base-directory>
- It still fails on
error: cannot inherit from final Integer
. Possibly we can't overwrite the class declarations of JDK source files anymore? That would be strange. - I've also tried adding these classfiles to a jar and tried to pass all possible root directories to the
--patch-module
argument - I've tried removing the module
package-info.class
from the compiledjava.base
directory and tried explicitly addingjava.base.java.lang.Integer
with--add-opens
The docs aren't really clear on this particular usage.
The entire javac command from maven (I have tried both javac and the maven-compiler-plugin):
javac -d ./target/classes -classpath <classpathfiles> -sourcepath <sourcefiles> -s ./target/generated-sources/annotations -g -nowarn -target 11 -source 11 -encoding UTF-8 --patch-module=java.base=../runtimejar/mods/src/java.base -Xplugin:Manifold
(Shortened path names etc. for readability)
What am I missing here? Why can't I modify java.base/java.lang.Integer
like this?