Closed
Bug 214608
Opened 21 years ago
Closed 21 years ago
HEAD regression: no more access to public members of package private classes
Categories
(Rhino Graveyard :: Core, defect)
Rhino Graveyard
Core
Tracking
(Not tracked)
VERIFIED
FIXED
1.5R5
People
(Reporter: igor, Assigned: norrisboyd)
Details
Attachments
(2 files)
493 bytes,
application/octet-stream
|
Details | |
4.20 KB,
patch
|
Details | Diff | Splinter Review |
A work related to bug 201893 made the following regression as reported by Hannes
Wallnoefer in the comments at bug 201893#c6 :
I think there are some problems with the patch you committed. I'm no longer able
to invoke public methods on non-public classes. The error message I get is:
TypeError: undefined is not a function.
Which may serve as clue, because it's not that we get a security exception when
invoking the method, the method is simply not there.
Also, when trying to invoke a public static method on a non-public class, I get
the following message:
org.mozilla.javascript.EvaluatorException: Java class "java.lang.Object" has no
public instance field or method named "foo".
Reporter | ||
Comment 2•21 years ago
|
||
To test, compile X.java, make all the resulting classes available to JVM and
run the following Java scripts in Rhino shell:
print(Packages.X.test().str())
print(Packages.X.test().str2())
Currenly only the first line works properly and prints TEST but the second line
gives instead of printing TEST2:
uncaught JavaScript exception: TypeError: str2 is not a function.
Note that the second line is supposed to work only if SecurityManager allows to
access public methods of package-private classes, but even in that situation
the error should be about IllegalAccessException, not about non-existing
function.
Reporter | ||
Comment 3•21 years ago
|
||
The reason for the regression is that now JavaMembers.lookupClass never
attempts to reflect package-private classes. But this is wrong since even with
SecirutyManager installed JVM allows to call Class.getMethos()( and returns
list of all public methods in the class and its super classes.
The patch removes the restrictions while making JavaMembers.lookupClass much
simpler.
Comment 4•21 years ago
|
||
Yep, patch works well for me!
Reporter | ||
Comment 5•21 years ago
|
||
I committed the patch.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 6•21 years ago
|
||
Now with the patch committed Rhino shell prints TEST2 for
print(Packages.X.test().str2()) if access permissions allows access to public
methods of package-private classes and when not it prints:
js: "<command>", line 1: While attempting to call "str2" in class "MyTest"
receieved java.lang.IllegalAccessException
which is expected.
You need to log in
before you can comment on or make changes to this bug.
Description
•