java.lang.IllegalStateException: Failed to instantiate CompiledExpression

Spring JIRA | Thomas Darimont | 2 years ago
  1. 0

    I tried to speed up dynamic instance creation by compiling constructor invocations with SpEL. Unfortunately I get a VerifyError when I try to evaluate the expression via {{getValue();}}. I added a test case that demonstrates the issue. The test case passes when {{SpelCompilerMode.OFF}} is used. Tested this with (java version "1.8.0_20") and compile target java6. {code:java} package test; import org.junit.Assert; import org.junit.Test; import org.springframework.expression.Expression; import org.springframework.expression.spel.SpelCompilerMode; import org.springframework.expression.spel.SpelParserConfiguration; import org.springframework.expression.spel.standard.SpelExpressionParser; /** * @author Thomas Darimont */ public class CompiledSpelBug { @Test public void compiledConstructorInvocations(){ SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, Thread.currentThread().getContextClassLoader())); Expression expr = parser.parseExpression("new test.CompiledSpelBug.Obj([0])"); Obj o = (Obj)expr.getValue(new Object[]{"test"}); Assert.assertEquals("test",o.param1); //the next line fails with: //java.lang.VerifyError: (class: spel/Ex2, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/ EvaluationContext;)Ljava/lang/Object;) Incompatible argument to function o = (Obj)expr.getValue(new Object[]{"test"}); Assert.assertEquals("test",o.param1); } public static class Obj{ private final String param1; public Obj(String param1){ this.param1 = param1; } } } {code} StackTrace with Spring Framework 4.1: {code} java.lang.VerifyError: (class: spel/Ex2, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;) Incompatible argument to function at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2658) at java.lang.Class.getConstructor0(Class.java:2964) at java.lang.Class.newInstance(Class.java:403) at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:106) at org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:464) at org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:434) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:153) at bob.spel.CompiledSpelBug.foo(CompiledSpelBug.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) {code} StackTrace with Spring Framework 4.1.1: {code} java.lang.IllegalStateException: Failed to instantiate CompiledExpression at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:111) at org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:464) at org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:434) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:153) at bob.spel.CompiledSpelBug.compiledConstructorInvocations(CompiledSpelBug.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: java.lang.VerifyError: (class: spel/Ex2, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;) Incompatible argument to function at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2658) at java.lang.Class.getConstructor0(Class.java:2964) at java.lang.Class.newInstance(Class.java:403) at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:108) ... 30 more {code}

    Spring JIRA | 2 years ago | Thomas Darimont
    java.lang.IllegalStateException: Failed to instantiate CompiledExpression
  2. 0

    I tried to speed up dynamic instance creation by compiling constructor invocations with SpEL. Unfortunately I get a VerifyError when I try to evaluate the expression via {{getValue();}}. I added a test case that demonstrates the issue. The test case passes when {{SpelCompilerMode.OFF}} is used. Tested this with (java version "1.8.0_20") and compile target java6. {code:java} package test; import org.junit.Assert; import org.junit.Test; import org.springframework.expression.Expression; import org.springframework.expression.spel.SpelCompilerMode; import org.springframework.expression.spel.SpelParserConfiguration; import org.springframework.expression.spel.standard.SpelExpressionParser; /** * @author Thomas Darimont */ public class CompiledSpelBug { @Test public void compiledConstructorInvocations(){ SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, Thread.currentThread().getContextClassLoader())); Expression expr = parser.parseExpression("new test.CompiledSpelBug.Obj([0])"); Obj o = (Obj)expr.getValue(new Object[]{"test"}); Assert.assertEquals("test",o.param1); //the next line fails with: //java.lang.VerifyError: (class: spel/Ex2, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/ EvaluationContext;)Ljava/lang/Object;) Incompatible argument to function o = (Obj)expr.getValue(new Object[]{"test"}); Assert.assertEquals("test",o.param1); } public static class Obj{ private final String param1; public Obj(String param1){ this.param1 = param1; } } } {code} StackTrace with Spring Framework 4.1: {code} java.lang.VerifyError: (class: spel/Ex2, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;) Incompatible argument to function at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2658) at java.lang.Class.getConstructor0(Class.java:2964) at java.lang.Class.newInstance(Class.java:403) at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:106) at org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:464) at org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:434) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:153) at bob.spel.CompiledSpelBug.foo(CompiledSpelBug.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) {code} StackTrace with Spring Framework 4.1.1: {code} java.lang.IllegalStateException: Failed to instantiate CompiledExpression at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:111) at org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:464) at org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:434) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:153) at bob.spel.CompiledSpelBug.compiledConstructorInvocations(CompiledSpelBug.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: java.lang.VerifyError: (class: spel/Ex2, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;) Incompatible argument to function at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2658) at java.lang.Class.getConstructor0(Class.java:2964) at java.lang.Class.newInstance(Class.java:403) at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:108) ... 30 more {code}

    Spring JIRA | 2 years ago | Thomas Darimont
    java.lang.IllegalStateException: Failed to instantiate CompiledExpression
  3. 0

    Why is spring.expression.compiler.mode not able to compile the following?

    Stack Overflow | 2 years ago | Tony Falabella
    java.lang.IllegalStateException: Failed to instantiate CompiledExpression
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    AspectJ Internal Error: unable to add stackmap attributes. null

    GitHub | 2 years ago | apanashchenko
    java.lang.VerifyError: Expecting a stackmap frame at branch target 56 Exception Details: Location: com/zoomdata/base/CustomTestListener.onTestFailure(Lorg/testng/ITestResult;)V @44: ifnull Reason: Expected stackmap frame at this location. Bytecode: 0000000: 2ab7 0010 572a b400 04bb 0005 59b7 0006 0000010: 1211 b600 082b b900 0e01 00b6 0008 b600 0000020: 0bb9 000c 0200 2bb9 0012 0100 c600 0c2b 0000030: b900 1201 00b6 0013 b1
  6. 0

    java.lang.VerifyError exception when opening editor.

    GitHub | 2 years ago | bruno-medeiros
    org.eclipse.core.runtime.CoreException: Plug-in "org.dsource.ddt.ide.ui" was unable to instantiate class "mmrnmhrm.ui.editor.DeeEditor".

  1. esaar 1 times, last 4 months ago
  2. asvid 10 times, last 5 months ago
  3. Akshay 2 times, last 6 months ago
  4. tone5992 4 times, last 7 months ago
  5. Roberto Tomás 1 times, last 7 months ago
9 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.VerifyError

    (class: spel/Ex2, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;) Incompatible argument to function

    at java.lang.Class.getDeclaredConstructors0()
  2. Java RT
    Class.newInstance
    1. java.lang.Class.getDeclaredConstructors0(Native Method)
    2. java.lang.Class.privateGetDeclaredConstructors(Class.java:2658)
    3. java.lang.Class.getConstructor0(Class.java:2964)
    4. java.lang.Class.newInstance(Class.java:403)
    4 frames
  3. Spring Expression Language (SpEL)
    SpelExpression.getValue
    1. org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:108)
    2. org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:111)
    3. org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:464)
    4. org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:434)
    5. org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:153)
    5 frames
  4. bob.spel
    CompiledSpelBug.compiledConstructorInvocations
    1. bob.spel.CompiledSpelBug.compiledConstructorInvocations(CompiledSpelBug.java:26)
    1 frame
  5. Java RT
    DelegatingMethodAccessorImpl.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    3 frames
  6. JUnit
    JUnitCore.run
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    5. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    8. org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    9. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    10. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    11. org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    12. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    13. org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    14. org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    14 frames
  7. IntelliJ junit4 module
    JUnit4IdeaTestRunner.startRunnerWithArgs
    1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    1 frame
  8. IDEA
    JUnitStarter.main
    1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
    2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
    2 frames
  9. Java RT
    NativeMethodAccessorImpl.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    2 frames
  10. IDEA
    AppMain.main
    1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
    1 frame