title: java.lang.VerifyError: (class: GregorSamsa, method: ...) Illegal target of jump or branch
body: <p>I'm facing a VerifyError while creating a lot of xml-transformers (javax.xml.transform.Transformer) with fairly complex XSLT document (2000 conditions). Please see example:</p>
  
  <pre><code>    public class XsltVerifyErrorTest {
  
      private static final int MAX_ITERATIONS_COUNT = 1000000;
  
      public static void main(String[] args) throws Exception {
          final byte[] xslBytes = Files.readAllBytes(new File(args[0]).toPath());
  
          for (int i = 0; i &lt; MAX_ITERATIONS_COUNT; i++) {
              System.out.println(String.format("Iteration %d", i));
  
              final StreamSource xslSource = new StreamSource(new ByteArrayInputStream(xslBytes));
              final Transformer transformer = TransformerFactory.newInstance().newTransformer(xslSource);
          }
      }
  }
  
  
  
  m49216@ubuntu:~/xslt-verify-error-test$ javac XsltVerifyErrorTest.java
  m49216@ubuntu:~/xslt-verify-error-test$ java -showversion XsltVerifyErrorTest XsltVerifyErrorTest.xsl
  openjdk version "1.8.0_162"
  OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-0ubuntu0.16.04.2-b12)
  OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)
  
  Iteration 0
  Iteration 1
  Iteration 2
  ...
  Iteration 79
  Iteration 80
  Iteration 81
  Exception in thread "main" java.lang.VerifyError: (class: GregorSamsa, method: TestTemplate signature: (Lcom/sun/org/apache/xalan/internal/xsltc/DOM;Lcom/sun/org/apache/xml/internal/dtm/DTMAxisIterator;Lcom/sun/org/apache/xml/internal/serializer/SerializationHandler;ILjava/lang/Object;)V) Illegal target of jump or branch
          at java.lang.Class.getDeclaredConstructors0(Native Method)
          at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
          at java.lang.Class.getConstructor0(Class.java:3075)
          at java.lang.Class.newInstance(Class.java:412)
          at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.getTransletInstance(TemplatesImpl.java:455)
          at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.newTransformer(TemplatesImpl.java:486)
          at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:762)
          at XsltVerifyErrorTest.main(XsltVerifyErrorTest.java:25)
  </code></pre>
  
  <p>Full example with test data can be found <a href="https://gist.github.com/MihailOstapenko/392390376de6931a2168c665b96e5798" rel="nofollow noreferrer">here</a>.</p>
  
  <p>The issue can be reproduced on many versions of jdk: 8u101, 8u121, 8u152, 8u161, 8u162.</p>
  
  <p>Has anyone run into this problem? Does it look like a jvm bug?</p>
  
  <p><strong>Edit 1:</strong> JDK 9 is also affected, but it's much harder to reproduce the issue - it takes ~20 minutes and 660 iterations on my machine.</p>
  
  <pre><code>java version "9.0.4"
  Java(TM) SE Runtime Environment (build 9.0.4+11)
  Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
  Iteration 0
  Iteration 1
  Iteration 2
  ...
  Iteration 658
  Iteration 659
  Iteration 660
  Exception in thread "main" java.lang.VerifyError: (class: die/verwandlung/GregorSamsa, method: TestTemplate signature: (Lcom/sun/org/apache/xalan/internal/xsltc/DOM;Lcom/sun/org/apache/xml/internal/dtm/DTMAxisIterator;Lcom/sun/org/apache/xml/internal/serializer/SerializationHandler;ILjava/lang/Object;)V) Illegal target of jump or branch
      at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3110)
      at java.base/java.lang.Class.getConstructor0(Class.java:3315)
      at java.base/java.lang.Class.newInstance(Class.java:530)
      at java.xml/com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.getTransletInstance(TemplatesImpl.java:552)
      at java.xml/com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.newTransformer(TemplatesImpl.java:583)
      at java.xml/com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:817)
      at XsltVerifyErrorTest.main(XsltVerifyErrorTest.java:19)
  </code></pre>
  
  <p><strong>Edit 2:</strong> Works fine on JDK 10.</p>