title: Why javaassist throws invalid constant type: 18 when loading Entitymanager only when lambdas are used in project
body: <p>I read many QnA before posting this specific question. Most of the <strong><em>javaassist invalid constant 18</em></strong> question were answered to upgrade the <strong>javaassist</strong> lib. Base on those QnA, I also upgraded lib to latest version in my project and it really worked. But I am not understanding following and need someone's assistance to give some insight please, if you could:</p>
  
  <p><strong>Here is the Environment</strong></p>
  
  <p><em>Current Version:</em>
  JDK: build 1.8.0_92-b14</p>
  
  <p>javaassist: 3.14.0.GA</p>
  
  <p>Hibernate: 3.5.1-Final</p>
  
  <p>Build Uses: Ant</p>
  
  <p><strong>Till date project does not have lamda or streams in code.
  Code Builds and Runs Successfully. No issues so far.</strong></p>
  
  <p>Now, here is what happens when I am using Lambdas and Streams.</p>
  
  <p><strong>Case 1:</strong> Without javaassist Upgrade
  Now, as soon as I introduce any Lamda and Stream in same project, then following 
  Exception throws during Server Start up specially while Spring container is starting up.
  Weird thing is The class that had Lambda and Stream did get initialized with no issues as per the log showing in IoC container, however one of the existing bean trying to initiate EntityYmanager gets Run Time Exception.
  based on one of the QnA comment talking about </p>
  
  <p><strong>Case 2:</strong> As soon as java assist is upgraded to latest version(or anything above <strong>3.17.0-GA</strong>), everything works fine.</p>
  
  <p>Question: Why Exception is not thrown at the class having Lambdas, but the existing hibernate's Entitity Manager which was working fine when project did not have any lambda/stream? Infact Bean that had lambda got loaded successfully and inside container when this Exception is thrown.</p>
  
  <p>Could someone please explain?</p>
  
  <p>Here is the complete Error Trace:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean     
  with name 'ldbEntityManagerFactory' defined in ServletContext resource  
  [/WEB-INF/spring/JPA.xml]: Invocation of init method failed; nested     
  exception is java.lang.RuntimeException: Error while reading   
      file:/C:/home/tcserver/profiles/instance/webapps/app/WEB-INF/classes
      -------deleted--------------
      ... 25 more
      **Caused by: java.io.IOException: invalid constant type: 18**
      at javassist.bytecode.ConstPool.readOne(ConstPool.java:1090)
      at javassist.bytecode.ConstPool.read(ConstPool.java:1033)
      at javassist.bytecode.ConstPool.&lt;init&gt;(ConstPool.java:149)
      at javassist.bytecode.ClassFile.read(ClassFile.java:764)
      at javassist.bytecode.ClassFile.&lt;init&gt;(ClassFile.java:108)
      atorg.hibernate.ejb.packaging.AbstractJarVisitor.checkAnnotationMatching(Abs
      tractJarVisitor.java:236)
      atorg.hibernate.ejb.packaging.AbstractJarVisitor.executeJavaElementFilter(Ab
      stractJarVisitor.java:202)
      aorg.hibernate.ejb.packaging.AbstractJarVisitor.addElement(AbstractJarVisito
      r.java:163)
      aorg.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(Exploded
      JarVisitor.java:101)
      ----DELETED---       
      g.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:614)
      ... 31 more
  </code></pre>