gcj compilation aborts with a segfault in the following situation: Class: a/A.java a package protected interface. a/B.java a class that implement interface A. a/b/C.java a class in a different package that import both A and B and try to use a constant defined in interface A. Note that "A" and therefore "A.Hello" are protected in package "a" and should not be accessible from class "C". Sun JDK correctly reports: tournesol$ javac a/b/C.java a/b/C.java:3: a.A is not public in a; cannot be accessed from outside package import a.A; ^ a/b/C.java:10: a.A is not public in a; cannot be accessed from outside package System.out.println(A.HELLO); but gcj gets confused by the fact that class "B" (also imported) is public in package "a" and implements "A". It wrongly believes that "A" is accessible and segfault. Release: gcc version 3.1 20011211 (experimental) Environment: Reading specs from /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs Configured with: ../../program/cvs/gcc/configure --prefix=/usr/local/gcc --enable-shared --enable-threads=posix --enable-languages=c++,java Thread model: posix gcc version 3.1 20011211 (experimental) How-To-Repeat: gcj -C a/b/C.java
Fix: Unknown...
From: Tom Tromey <tromey@redhat.com> To: olivier@zipworld.com.au Cc: gcc-gnats@gcc.gnu.org, Alexandre Petit-Bianco <apbianco@cygnus.com> Subject: Re: java/5135: Compiler segfault on non public Interfaces Date: 16 Dec 2001 18:51:24 -0700 Olivier> Note that "A" and therefore "A.Hello" are protected in Olivier> package "a" and should not be accessible from class "C". First, thanks for your report. It is concise and self-contained -- exactly how I like bug reports. I looked at this a bit today. gcj does correctly detect that A.HELLO is inaccessible, but unfortunately it crashes while trying to tell you that. The appended patch fixes the crash, but I think this patch is almost certainly incorrect. I don't really understand the code in this function. Something else I don't understand is that if you get rid of class `a.B', then the error in check_pkg_class_access is printed. Why does the presence of B make a difference here? Tom Index: parse.y =================================================================== RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v retrieving revision 1.333 diff -u -r1.333 parse.y --- parse.y 2001/12/16 16:23:49 1.333 +++ parse.y 2001/12/17 01:40:13 @@ -9660,10 +9659,9 @@ if (not_accessible_p (TREE_TYPE (decl), decl, type, 0)) { parse_error_context - (qual_wfl, "Can't access %s field `%s.%s' from `%s'", + (qual_wfl, "Can't access %s `%s' from `%s'", java_accstring_lookup (get_access_flags_from_decl (decl)), - GET_TYPE_NAME (type), - IDENTIFIER_POINTER (DECL_NAME (decl)), + GET_TYPE_NAME (TREE_TYPE (decl)), IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class)))); return 1; }
From: Daniel Bonniot <Daniel.Bonniot@inria.fr> To: gcc-gnats@gcc.gnu.org, java-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org, olivier@zipworld.com.au Cc: Subject: Re: java/5135: Compiler segfault on non public Interfaces Date: Mon, 21 Apr 2003 23:41:44 +0200 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5135 I reproduced this bug in gcc version 3.3 20030412 (Debian prerelease) Here is the output: $ gcj-3.3 -C a/b/C.java a/b/C.java: In class `a.b.C': a/b/C.java: In method `a.b.C.hello()': a/b/C.java:10: internal compiler error: Segmentation fault
From: Dara Hazeghi <dhazeghi@yahoo.com> To: gcc-gnats@gcc.gnu.org Cc: Subject: Re: java/5135: Compiler segfault on non public Interfaces Date: Mon, 12 May 2003 12:50:16 -0700 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- trail&database=gcc&pr=5135 Hello, I can confirm this bug still exists on gcc 3.2, 3.3 branch and mainline (20030511). Dara
See Dara's comment.
Related to bug 11075.
Fixed on the mainline.