[Bug libgcj/23431] abstract method resolve error in gij

snambi at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Aug 19 06:17:00 GMT 2005


------- Additional Comments From snambi at gmail dot com  2005-08-19 06:17 -------
some more analysis of the problem.

looks like this bug has been introduced in gcj 4.0.1
it works correctly in gcj 3.3.3 and javac 1.4.2, ie it gives an error while
compiling. please look below, to see the messages. but gij fails to run. it
should give an compile time error message.

hope it helps.

matrix:/home/snambi/src/java/abs_classes>
$gcj -C --classpath .:./jms.jar B.java C.java
B.java:9: error: Class `B' must override `B.onMessage(javax.jms.Message)' with a
public method in order to implement interface `javax.jms.MessageListener'.
        abstract void onMessage( javax.jms.Message message );
                         ^
1 error
matrix:/home/snambi/src/java/abs_classes>
$export JAVA_HOME=/otp/software/java/j2sdk1.4.2_08/
matrix:/home/snambi/src/java/abs_classes>
$export PATH=$PATH:$JAVA_HOME/bin
matrix:/home/snambi/src/java/abs_classes>
$javac -classpath .:./jms.jar B.java C.java
B.java:9: onMessage(javax.jms.Message) in B cannot implement
onMessage(javax.jms.Message) in javax.jms.MessageListener; attempting to assign
weaker access privileges; was public
        abstract void onMessage( javax.jms.Message message );
                      ^
C.java:8: onMessage(javax.jms.Message) in C cannot implement
onMessage(javax.jms.Message) in javax.jms.MessageListener; attempting to assign
weaker access privileges; was public
         void onMessage(javax.jms.Message message)
              ^
2 errors
matrix:/home/snambi/src/java/abs_classes>
$/otp/software/gcc/4.0.1/bin/gcj -C --classpath .:./jms.jar B.java C.java

matrix:/home/snambi/src/java/abs_classes>
$/otp/software/gcc/4.0.1/bin/gcj -C --classpath .:./jms.jar B.java C.java A.java

matrix:/home/snambi/src/java/abs_classes>
$/otp/software/gcc/4.0.1/bin/gij --classpath .:./jms.jar A
A is getting instantiated
Exception in thread "main" java.lang.IllegalAccessError: C.onMessage
(Ljavax.jms.Message;)V
   at java.lang.VMClassLoader.resolveClass(java.lang.Class)
(/otp/software/gcc/4.0.1/lib/libgcj.so.6.0.0)
   at java.lang.Class.initializeClass()
(/otp/software/gcc/4.0.1/lib/libgcj.so.6.0.0)
   at A.A() (Unknown Source)
   at A.main(java.lang.String[]) (Unknown Source)
   at gnu.java.lang.MainThread.call_main()
(/otp/software/gcc/4.0.1/lib/libgcj.so.6.0.0)
(In reply to comment #0)
> there is an abstract class, class B which implements an interface. the method
> defined by the interface, is the abstract method. Another class C extends B and
> implements the method. it compiles in gcj -C.
> 
> while executing in gij, it throws an IllegalAccessError from
> VMClassLoader.resolveClass.
> 
> below is the sequence.
> 
> $cat B.java
> abstract class B implements javax.jms.MessageListener
> {
>         public B()
>         {
>         System.out.println("Class B instantiated");
>         }
> 
>         abstract void onMessage( javax.jms.Message message );
> }
> matrix:~/src/java/abs_classes>
> $cat C.java
> class C extends B
> {
>         public C()
>         {
>                 System.out.println("Class C instantiated");
>         }
> 
>         void onMessage(javax.jms.Message message)
>         {
>                 System.out.println("abstract method test implemented");
>         }
> }
> 
> $cat A.java
> class A
> {
>     private C c = null;
>         public A()
>         {
>                 System.out.println("A is getting instantiated");
> 
>         c = new C();
>         }
> 
>         public static void main( String[] args )
>         {
>                 A a = new A();
>         }
> }
> 
> matrix:~/src/java/abs_classes>
> $gcj --classpath=.:jms.jar -C *.java
> 
> there is a jms.jar file in the current directry.
> 
> matrix:~/src/java/abs_classes>
> $gij --cp ".:jms.jar" A
> A is getting instantiated
> Exception in thread "main" java.lang.IllegalAccessError: C.onMessage
> (Ljavax.jms.Message;)V
>    at java.lang.VMClassLoader.resolveClass(java.lang.Class)
> (/otp/software/gcc/4.0.1/lib/libgcj.so.6.0.0)
>    at java.lang.Class.initializeClass()
> (/otp/software/gcc/4.0.1/lib/libgcj.so.6.0.0)
>    at A.A() (Unknown Source)
>    at A.main(java.lang.String[]) (Unknown Source)
>    at gnu.java.lang.MainThread.call_main()
> (/otp/software/gcc/4.0.1/lib/libgcj.so.6.0.0)
>    at gnu.java.lang.MainThread.run() (/otp/software/gcc/4.0.1/lib/libgcj.so.6.0.0)
> 
> sorry for pasting the source code. it is too difficult to explain it otherwise.
> 
> gcj -v --help 
> .
> .
> .
> Target: i686-pc-linux-gnu
> Configured with: ../configure --prefix=/otp/software/gcc/4.0.1
> Thread model: posix
> gcc version 4.0.1



-- 


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



More information about the Java-prs mailing list