-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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
Gary Russell opened SPR-16122 and commented
SpEL method invocation on a proxy does not work with varargs.
Consider the following:
@SpringBootApplication
public class So46953884Application extends GlobalAuthenticationConfigurerAdapter {
public static void main(String[] args) {
SpringApplication.run(So46953884Application.class, args);
}
@Value("#{foo.foo('a', 'b')}")
private String fooValue;
// @Value("#{fooProxy.foo('c', 'd')}")
private String fooProxyValue;
@Autowired
private Foo foo;
@Autowired
private Foo fooProxy;
@Bean
public ApplicationRunner runner() {
return args -> {
System.out.println(fooValue);
System.out.println(foo.getClass());
System.out.println(fooProxyValue);
System.out.println(fooProxy.getClass());
};
}
@Bean
public Foo foo() {
return new FooImpl();
}
@Bean
public Foo fooProxy() {
return new FooImpl();
}
@Bean
public static BeanPostProcessor bpp() {
return new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
if (name.equals("fooProxy")) {
ProxyFactoryBean pfb = new ProxyFactoryBean();
pfb.setTarget(bean);
return pfb.getObject();
}
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
return bean;
}
};
}
public interface Foo {
String foo(String... strings);
}
public static class FooImpl implements Foo {
@Override
public String foo(String... strings) {
return "filled: " + Arrays.toString(strings);
}
}
}As written, this emits
filled: [a, b]
class com.example.two.So46953884Application$FooImpl
null
class com.sun.proxy.$Proxy36
Uncommenting the second @Value results in...
EL1004E: Method call: Method foo(java.lang.String,java.lang.String) cannot be found on com.sun.proxy.$Proxy36 type
Affects: 4.3.12
Reference URL: https://stackoverflow.com/questions/46953884
Issue Links:
- Wrong byte code for compiled SpEL when JDK proxy method invocation is used [SPR-16191] #20739 Wrong byte code for compiled SpEL when JDK proxy method invocation is used
Referenced from: commits 419b444, 9cc3349
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