Before Jigsaw it was quite easy to replace one or several classes in OpenJDK (to perform some test or make a contribution). I could copy an original file from OpenJDK source, for example, java/util/ArrayList.java
into src/java/util/
, add any changes I want, then compile it normally (outputting to mypatch
directory):
$ javac.exe src\java\util\ArrayList.java -d mypatch
After that I could launch JVM with -Xbootclasspath/p
to replace original ArrayList
with the patched one:
$ java -Xbootclasspath/p:mypatch MyTestClass
However this does not work anymore since Jigsaw integration in Java 9-ea+111. The compilation command reports tons of errors starting like this:
src\java\util\ArrayList.java:26: error: package exists in another module: java.base
package java.util;
^
src\java\util\ArrayList.java:108: error: cannot find symbol
public class ArrayList<E> extends AbstractList<E>
^
symbol: class AbstractList
src\java\util\ArrayList.java:109: error: cannot find symbol
implements List<E>, RandomAccess, Cloneable, java.io.Serializable
^
And even if I compile with older JDK, then JVM cannot start:
-Xbootclasspath/p is no longer a supported option.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
How to make patches for JDK with Jigsaw?