-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
OgnlRuntime#getReadMethod()
returns null
if the method is a bridge method
#104
OgnlRuntime#getReadMethod()
returns null
if the method is a bridge method
#104
Conversation
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.
LGTM 👍
Hi @harawata and @lukaszlenart . Is it possible that removing I am wondering if the scenario @harawata found maybe calls for The behaviour for synthetic read and write methods may have some weird corner-cases. When I run a build of ognl-3.2.16-SNAPSHOT using JDK 8 or 11, the build completes just fine. However, running the same build with JDK 7 causes the If there is something either of you would like me to try out, please let me know. |
Hello, @JCgH4164838Gh792C124B5 I could verify the test failure on Java 7. Note that the bug in To fix the bug, I would suggest applying the same fix made in #33 to
It might, but I doubt it (see below).
If there are cases that actually require some callable-check, I have no objection, of course.
|
The following implementation might make sense, actually. static boolean isMethodCallable(Method m) {
return !m.isSynthetic() || m.isBridge();
} |
Hello @harawata . Thanks for confirming that the Java 7 behaviour was not just a side-effect of my build environment. I only noticed it because I happened to try builds across all of my installed JDK versions. :) Also, thanks for your thoughts and comments on the |
The test passes on Java 8, but yields warning on 9+ and exception on 16+. It's essentially the same as orphan-oss#104 . OGNL should call `StringBuilder#codePointAt()` (which is a bridge method) rather than the method defined in its non-public parent class `AbstractStringBuilder`.
Considering the following two classes,
OgnlRuntime.getReadMethod(PublicChild.class, "name")
should return thegetName()
method, but it returnsnull
instead.In the
getReadMethod()
, candidate methods are checked byisMethodCallable()
which returnsfalse
for a bridge method even though it is callable.I simply removed the 'is callable' check from
getReadMethod()
and there is no broken test.p.s.
Note that this bug does not exists in
OgnlRuntime#getWriteMethod()
because it internally usesBeanInfo#getMethodDescriptors()[i]#getMethod()#getModifiers()
which returns a different value thanClass#getMethods()[i]#getModifiers()
for some reason [1].I added a test case to avoid possible regression in case someone wants to resolve the implementation inconsistency in future.
[1] Try the following code if you are curious.