This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/19629] New: simple anonymous constructor bug
- From: "tromey at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Jan 2005 20:41:13 -0000
- Subject: [Bug java/19629] New: simple anonymous constructor bug
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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