title: Patching java.base results in java.lang.LinkageError
body: <p>I am trying to do the same thing in Java 11 that could be done with <code>-Xbootclasspath/p:path</code> in pre java 9. </p>
  
  <p>As a simple example I modified one of the <code>valueOf</code> methods of <code>java.lang.Integer</code> and compiled the project with:</p>
  
  <p><code>javac --module-source-path=src/java.base --patch-module java.base=src/java.base -d mods  $(find src -name '*.java')</code></p>
  
  <p>I then ran a simple sample using: </p>
  
  <p><code>java --patch-module java.base=&lt;pathToMyModifiedJavaBaseClasses&gt; -p lib -m my.moduleA/my.moduleA.Main</code></p>
  
  <p>That worked an I'm seeing the modifications displayed (a simple print out I did from <code>valueOf</code>). </p>
  
  <p>When I try, however, to do the same thing with <code>java.lang.ClassLoader</code> I get the following error when executing the program (compile works): </p>
  
  <p><code>Error occurred during initialization of boot layer
  java.lang.LinkageError: loader 'bootstrap' attempted duplicate class definition for java.lang.invoke.SimpleMethodHandle.</code></p>
  
  <p>I do not even need to make changes in <code>java.lang.ClassLoader</code>. The sheer existence of that class in my patch folder seems to be provocing this error. (I only wanted to add a field though at the bottom of the class)</p>
  
  <p>NOTE: I just figured that it works when the <code>ClassLoader</code> class is compiled with Eclipse. One of the few differences I know is that the Eclipse compiler does not seem to follow <a href="http://openjdk.java.net/jeps/280" rel="nofollow noreferrer">JEP 280</a> yet. But there are <code>invokedynamic</code> instructions in the bytecode resulting from <code>javac</code> as well, so I doubt that this is the problem. </p>