[Bug java/24442] New: wrong class instantiated

aph at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Oct 19 13:01:00 GMT 2005


public class SameName
{
    public Object foo ()
    {
        class SingleName
        {
            public String toString ()
            {
                return "foo.SingleName";
            }
        }
        return new SingleName ();
    }
    public Object bar ()
    {
        class SingleName
        {
            public String toString ()
            {
                throw new RuntimeException ("bar.SingleName");
            }
        }
        return new SingleName ();
    }
    public static void main (String[] args)
    {
        System.out.println (new SameName ().foo().toString());
    }
}

cagney@localhost$ ./a.out
Exception in thread "main" java.lang.RuntimeException: bar.SingleName
   at SameName$2$SingleName.toString() (Unknown Source)
   at SameName.main(java.lang.String[]) (Unknown Source)
   at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
   at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)


-- 
           Summary: wrong class instantiated
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: aph at gcc dot gnu dot org
        ReportedBy: aph at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24442



More information about the Java-prs mailing list