bsh handles subclassing and static methods incorrectly

Bug #379304 reported by Matthew Flaschen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bsh (Ubuntu)
New
Undecided
Unassigned
Nominated for Hardy by Matthew Flaschen

Bug Description

Binary package hint: bsh

As noted at http://sourceforge.net/tracker/?func=detail&aid=1781130&group_id=4075&atid=104075 , bsh does not call the correct method when a subclass has the same static method signature as a superclass. For example:

class A
{
    public static String foo()
    {
 return "A";
    }
}

class B extends A
{
    public static String foo()
    {
 return "B";
    }
}

public class StaticInherit
{
    public static void main(String[] a)
    {
System.out.println("A.foo: " + A.foo());
System.out.println("(new B()).foo: " + (new B()).foo());
System.out.println("B.foo: " + B.foo());
    }
}

If this file is compiled with javac and run with java, it will output A, B, B. However, if entered into Hardy bsh (and run with StaticInherit.main(new String[]{})), it results in A, A, A.

This bug has been fixed in beanshell2 (http://code.google.com/p/beanshell2/); see r21 (http://code.google.com/p/beanshell2/source/diff?spec=svn21&old=10&r=21&format=unidiff&path=%2Ftrunk%2Fsrc%2Fbsh%2FReflect.java) . It would be great to merge at least this, and it may be wise to start using them as upstream eventually.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.