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)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: igor, Assigned: norrisboyd)

Details

Attachments

(2 files)

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".
CC to Hannes Wallnoefer
OS: Linux → All
Hardware: PC → All
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.
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.
Yep, patch works well for me!
I committed the patch.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
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.
Marking Verified per Comment #4
Status: RESOLVED → VERIFIED
Targeting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: