Closed Bug 40844 Opened 25 years ago Closed 25 years ago

Incorrect static method called for inherited class

Categories

(Rhino Graveyard :: Core, defect, P3)

x86
Windows NT

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mberney, Assigned: norrisboyd)

Details

From Rhino Newsgroup (netscape.public.mozilla.jseng): I have potentially discovered a problem with Javascript. Here is my java code: public abstract class ParentClass { public static void printSomething() { System.out.println("ParentClass.printSomething()"); } } public class ChildClass extends ParentClass { public static void printSomething() { System.out.println("ChildClass.printSomething()"); } } java org.mozilla.javascript.tools.shell.Main js> importClass(Packages.ChildClass); js> js> ChildClass.printSomething(); ParentClass.printSomething(); js> quit(); Now, I could be wrong, but the way I understand things, it seems like the Child Class method should be invoked here. Is this something similar to the bug report I found in: 37381? Thanks, Matt
reassign to my other account
Assignee: norrisboyd → nboyd
Interesting: this bug occurs in Sun's JDK, but not in Microsoft's JView
Status: NEW → ASSIGNED
On some JVMs, Class.getMethods will return all static methods of the class heirarchy, even if a derived class's parameters match exactly. We want to call the dervied class's method. Added code to do that: Checking in NativeJavaMethod.java; /cvsroot/mozilla/js/rhino/org/mozilla/javascript/NativeJavaMethod.java,v <-- N ativeJavaMethod.java new revision: 1.13; previous revision: 1.12 done
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.