-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug
Milestone
Description
Artem Bilan opened SPR-16191 and commented
The test-case to reproduce:
@Test
public void testCompiledSpELForProxy() {
Foo foo = new FooImpl();
foo = (Foo) new ProxyFactory(foo).getProxy();
SpelExpressionParser expressionParser =
new SpelExpressionParser(new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null));
Expression expression = expressionParser.parseExpression("#target.handle(#root)");
StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
evaluationContext.setVariable("target", foo);
String result = expression.getValue(evaluationContext, "foo", String.class);
result = expression.getValue(evaluationContext, "foo", String.class);
assertEquals("FOO", result);
}
public interface Foo {
String handle(String payload);
}
public class FooImpl implements Foo {
@Override
public String handle(String payload) {
return payload.toUpperCase();
}
}
The exception looks like:
java.lang.IllegalStateException: Failed to instantiate CompiledExpression
at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:110)
at org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:517)
at org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:487)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:372)
at org.springframework.integration.handler.MethodInvokingMessageProcessorTests.testCompiledSpELForProxy(MethodInvokingMessageProcessorTests.java:904)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.VerifyError: (class: spel/Ex2, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;) Illegal type in constant pool
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.getDeclaredConstructor(Class.java:2178)
at org.springframework.util.ReflectionUtils.accessibleConstructor(ReflectionUtils.java:503)
at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:107)
... 28 more
The byte code for the compiled class:
���� 1 !� �spel/Ex2� �� 6org/springframework/expression/spel/CompiledExpression� �� �<init>☃0001 �()V
getValue� X(Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;� 2org/springframework/expression/EvaluationException� �� �target
0org/springframework/expression/EvaluationContext� �� �lookupVariable� &(Ljava/lang/String;)Ljava/lang/Object; � �� � �� �com/sun/proxy/$Proxy5� �� Oorg/springframework/integration/handler/MethodInvokingMessageProcessorTests$Foo� �� �java/lang/String� �� �handle� &(Ljava/lang/String;)Ljava/lang/String; � �� � �� �Code
Exceptions � � � � � � � � � � � � �*� ��
" � � �,��� �� � �� �+� �� �� � �
With SF-5.0.1 it looks like (if that helps somehow..):
���� 1 �� �spel/Ex2� �� 6org/springframework/expression/spel/CompiledExpression� �� �<init>� �()V
getValue� X(Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;� 2org/springframework/expression/EvaluationException� �� �target
0org/springframework/expression/EvaluationContext� �� �lookupVariable� &(Ljava/lang/String;)Ljava/lang/Object; � �� � �� �com/sun/proxy/$Proxy5� �� �java/lang/String� �� �handle� &(Ljava/lang/String;)Ljava/lang/String;
Code
Exceptions � � � � � � � � � � � � ☃0005*� ��
,��� �� � �+� �� �� � � �
It might be like a side-effect of the fix for the #20670 since we have the same problem with the 4.3.13
as well.
Affects: 4.3.13, 5.0.2
Issue Links:
- SpEL method invocation with varargs on proxy [SPR-16122] #20670 SpEL method invocation with varargs on proxy
Referenced from: commits c30145d, 6dc7346
Backported to: 4.3.13
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug