This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/13006] New: NoSuchMethodError thrown at runtime
- From: "s28patel at student dot math dot uwaterloo dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Nov 2003 09:04:53 -0000
- Subject: [Bug java/13006] New: NoSuchMethodError thrown at runtime
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
**********Summary:
The following code throws a runtime error when run, yet runs fine when
compiled it with IBM's jikes compiler. I think there is both a
compiler and library error.
**********Platform:
Cygwin on Windows XP
**********Source code (test.java):
import javax.swing.BoxLayout;
import javax.swing.JPanel;
class test {
public static void main(String argv[]) {
BoxLayout b = new BoxLayout(new JPanel(), 0);
}
}
**********Runtime error:
java.lang.NoSuchMethodError:
javax.swing.BoxLayout.<init>(Ljavax/swing/JComponent;I)V
at test.main(test.java:5)
Exception in thread "main"
**********Details and my experimentation:
Compile command and compiler output follow.
The only reason I created the JPanel object is because the BoxLayout
constructor requires a JPanel object.
When compiling with jikes, I first compiled using Sun's java's runtime
jar file (lib/rt.jar in my java runtime directory), and it worked
fine. I then experimented by using gcc's classes
(/usr/share/java/libgcj-3.3.1.jar) with jikes, and got the following
"semantic error" message:
The constructor "BoxLayout(javax.swing.JComponent $1, int $2);" in
type "javax.swing.BoxLayout" has default access and is not accessible
here.
Browsing the current CVS source in directory
gcc/libjava/javax/swing/BoxLayout.java confirms the constructors for
BoxLayout have no access modifiers (no public/private designation).
I think the gcj compiler ought to provide an error message like jikes
does when trying to call a constructor that cannot be accessed.
It seems to me gcj is outputing code to call an inaccessible
constructor. When I run the class with gij, it seems to hang... but
when I used another class instead of BoxLayout
(e.g. java.awt.GridLayout) the code ran fine.
**********Compile command:
gcj -v -save-temps -C test.java -Wall
**********Compiler output:
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /netrel/src/gcc-3.3.1-2/configure
--enable-languages=c,c++,f77,java --enable-libgcj --enable-threads=posix
--with-system-zlib --enable-nls --without-included-gettext --enable-interpreter
--enable-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared
--build=i686-pc-linux --host=i686-pc-cygwin --target=i686-pc-cygwin
--prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
--includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.3.1 (cygming special)
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/jc1.exe test.java -quiet -dumpbase
test.java -auxbase-strip NONE -g1 -Wall -version -fsyntax-only
-femit-class-files -o test
GNU Java version 3.3.1 (cygming special) (i686-pc-cygwin)
compiled by GNU C version 3.3.1 (cygming special).
GGC heuristics: --param ggc-min-expand=46 --param ggc-min-heapsize=31678
Class path starts here:
./
/usr/share/java/libgcj-3.3.1.jar/ (system) (zip)
**********thank you! (end)
--
Summary: NoSuchMethodError thrown at runtime
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: s28patel at student dot math dot uwaterloo dot ca
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-cygwin
GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13006