Closed Bug 15711 Opened 25 years ago Closed 21 years ago

Can't call java.lang.Class methods from JS

Categories

(Rhino Graveyard :: Core, defect, P3)

All
Mac System 8.6
defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: beard, Assigned: norrisboyd)

Details

If I do the following:

js> o = new java.lang.Object();
js> c = o.getClass();
js> c.getName();

It doesn't work, because classes only reflect the static methods of a
class, but not the instance methods of java.lang.Class. Should we fix
this? If, so how? Here's one way to fix this:  each java.lang.Class is
wrapped in Rhino as a NativeJavaClass instance. We could  create a
NativeJavaObject wrapper for the class object that reflects the instance
methods, and make that the prototype of the NativeJavaClass. Then we
would have any public static methods defined on the class shadow methods
that come from java.lang.Class, but those could be called by accessing
the prototype.
0
If this is how Rhino LiveConnect works (or doesn't work, as the case may
be), then Rhino acts differently from the way LiveConnect works in
Mozilla and all previous releases of LiveConnect.  LiveConnect has always
treated 'java.lang.Object' and '(new java.lang.Object()).getClass()' as two
distinctly different types of objects.  The former object has as properties all
the static members of the java.lang.Object class and the latter is a JS
wrapper around an instance of java.lang.Class.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Status: RESOLVED → CLOSED
I've verified that we now have the correct "LiveConnect" behavior.
Status CLOSED is deprecated as per bug 169885
Status: CLOSED → REOPENED
Resolution: FIXED → ---
Re-Resolving
Status: REOPENED → RESOLVED
Closed: 25 years ago21 years ago
Resolution: --- → FIXED
verifying former CLOSED bugs
Status: RESOLVED → VERIFIED
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
Untargeting wrong milestone assignment
Target Milestone: 1.5R5 → ---
You need to log in before you can comment on or make changes to this bug.