This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug java/19629] New: simple anonymous constructor bug


test case:

public class z
{
  public static void main(String[] args) throws Throwable
  {
    final String name = "java_cup.terminal";
    Class k;

    ClassLoader cl = new ClassLoader(null) { };
    k = cl.loadClass(name);

    System.out.println(k);
    System.out.println(k.getProtectionDomain().getCodeSource());
    System.out.println(k.getClassLoader());
  }
}


gcj gives:

opsy. gcj -C z.java
z.java: In class 'z$1':
z.java: In constructor '(z,java.lang.String,java.lang.Object)':
z.java:9: error: No constructor matching ?(z,java.lang.String,java.lang.Object)?
found in class ?java.lang.ClassLoader?.
       ClassLoader cl = new ClassLoader(null) { };
                                                 ^
1 error


This is wrong.
It looks like variable capture is confusing creation of the
super() call in the anonymous class constructor.

-- 
           Summary: simple anonymous constructor bug
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tromey at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]