public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/8618: call to private constructor allowed for anonymous inner class
@ 2002-11-22 14:01 jmr
0 siblings, 0 replies; only message in thread
From: jmr @ 2002-11-22 14:01 UTC (permalink / raw)
To: gcc-gnats
>Number: 8618
>Category: java
>Synopsis: call to private constructor allowed for anonymous inner class
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Sun Nov 17 20:06:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Jesse Rosenstock
>Release: gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>Organization:
>Environment:
>Description:
Calls to private constructors are (incorrectly) allowed when creating an anonymous inner class.
; cat X.java
public class X {
public static void main(String[] args) {
// new Y();
new Y() { }; // should be illegal
}
}
; cat Y.java
public class Y {
private Y() {
}
}
; gcj X.java Y.java --main=X
gcj doesn't give an error, whereas Sun's javac does
; javac X.java
X.java:4: Y() has private access in Y
new Y() { };
^
X.java:4: Y() has private access in Y
new Y() { };
^
2 errors
If you switch around which line is commented out in X.main, then gcj correctly
gives an error:
gcj X.java Y.java --main=X
X.java:3: Can't access private constructor `Y.<init>' from `X'.
new Y();
^
1 error
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-18 4:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-22 14:01 java/8618: call to private constructor allowed for anonymous inner class jmr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).