[Bug java/30844] New: invalid "Can't find method" error

rizzolo at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Feb 18 21:03:00 GMT 2007


The following code, placed in a file named A.java, fails to compile with GCJ
4.1.0.  Sun's javac has no problem with it.  Interestingly, if you comment out
the line marked with "/**/", the code compiles.

/* Begin A.java */
public class A
{
  public A() { }

  public int foo(Object a) { return 1; }
  public int foo(Object[] a) { return 1; }

  public static class B extends A
  {
    public B() { }
    /**/ public int foo(Object a) { return 1; }
  }

  public static class C extends B
  {
    public C() { }
    public int foo(Object[] a) { return super.foo(a); }
  }
}
/* End A.java */


The command I ran:
$ gcj4 -v -C A.java
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --with-gxx-include-dir=/usr/include/c++/3.4.3
--enable-libgcj-multifile --enable-languages=c,c++,java,f95
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=i386-redhat-linux
Thread model: posix
gcc version 4.1.0 20060515 (Red Hat 4.1.0-18)
 /usr/libexec/gcc/i386-redhat-linux/4.1.0/jc1 A.java -quiet -dumpbase A.java
-mtune=generic -auxbase-strip NONE -g1 -version -fsyntax-only
-femit-class-files -o A
GNU Java version 4.1.0 20060515 (Red Hat 4.1.0-18) (i386-redhat-linux)
        compiled by GNU C version 4.1.0 20060515 (Red Hat 4.1.0-18).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Class path starts here:
    ./
    /home/rizzolo/lib/
    /home/rizzolo/lib/java_cup.jar/ (zip)
    /home/rizzolo/cogcomp/LBP/LBJ2/
    /usr/share/java/libgcj-4.1.0.jar/ (system) (zip)
A.java: In class 'A$C':
A.java: In method 'A$C.foo(java.lang.Object[])':
A.java:18: error: Can't find method ‘foo([Ljava/lang/Object;)’ in type ‘A$B’.
Candidates are:
  'A$B.foo(java.lang.Object)' in 'A$B'
  'A.foo(java.lang.Object[])' in 'A'.
    public int foo(Object[] a) { return super.foo(a); }
                                                 ^
1 error


By the way, it is not necessary for classes A, B, and C to be defined in the
same file with B and C defined as static member classes of A.  The problem is
also present when the three classes are defined in separate files and not as
member classes.

 - Nick


-- 
           Summary: invalid "Can't find method" error
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rizzolo at gmail dot com
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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



More information about the Gcc-bugs mailing list