compiler segfault (confusion with non public interfaces)

Olivier LF olivier@zipworld.com.au
Sat Dec 1 17:36:00 GMT 2001


Hi,
gcj (the compiler) segfault in the following case. This is with 
CVS head from 14/10/2001. I haven't try with the latest.
file a/A.java (package protected interface)
--------------------------------------------------------------------------
package a;
interface A
{
 String HELLO = "hello";
}
file a/B.java (a public class that implements the interface)
--------------------------------------------------------------------------
package a;
public class B
implements A
{
}
file a/b/C.java (a class in a different package that imports both A and B,
and tries to use the constant A.HELLO)
--------------------------------------------------------------------------
package a.b;
import a.A;
import a.B;
public class C
{
 public static void hello()
 {
 System.out.println(A.HELLO);
 }
}
	 
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:
 tournesol$ gcj -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 error: Segmentation fault
 Please submit a full bug report,
Olivier
-- 
----------------------------------------------------------------------
Olivier Louchart-Fletcher
Email: olivier@zipworld.com.au


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /