-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SpEL: cannot call methods declared in java.lang.Object
on a JDK proxy
#25316
Conversation
Make sure to have methods of Object on Proxy-Objects.
@MrCoffee77 Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@MrCoffee77 Thank you for signing the Contributor License Agreement! |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per Code-Style#import-statements we should avoid wildcard imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. We do not use wildcard imports for types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
And... sorry for taking so long to process this.
I've left a few comments that are intended to be informational. There is no need to modify this PR to make the suggested changes.
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. We do not use wildcard imports for types.
methods.addAll(Arrays.asList(Object.class.getMethods())); | ||
|
||
Method[] methods1 = methods.toArray(new Method[0]); | ||
return methods1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to make a change specific to JDK proxies in getMethods(Class<?>, Object)
instead of having this change globally applied in getMethods(Class<?>)
.
However, there is no need to modify this PR.
I already have such a change in place locally and will apply that when merging your PR.
} | ||
}); | ||
MethodExecutor mexec=resolver.resolve(evaluationContext,obj,"toString",new ArrayList<>()); | ||
Assert.notNull(mexec,"MethodExecutor should not be empty."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use AssertJ for test assertions, not Spring's org.springframework.util.Assert
class.
In any case, I'll make that change when merging the PR.
java.lang.Object
on a JDK proxy
Hi @MrCoffee77, Congratulations on having your first pull request for the Spring Framework accepted! 👍 This has been merged into This will also be backported to Thanks |
This commit ensures that methods declared in java.lang.Object (such as toString() can be invoked on a JDK proxy instance in a SpEL expression. Closes gh-25316
Hello, I built a fix for my problem with SpEL and proxy objects as described in #23369.
Now I want to contribute my changes.
Regards
Florian