gcj, gij; Classes cannot be found?

weppnesp@eckerd.edu weppnesp@eckerd.edu
Sun Jun 22 23:54:00 GMT 2003


Hello,

  i apologize with a person compilation problem. I hope you can help me and it
is not to silly a problem.

I upgraded last week to GCC 3.3. All compilers work fine, g77, g++, gcc but not
gcj and gij. I have spend the weekend on it and am getting closer but need some
help. (RedHat 7.3, Athalon, 2.4.18-3 linux)

My testsuite results are good for all compilers except gcj, which compiles .java
well (passed mauve, forms good classes which can be run using Sun Java) but
writes corrupt executables which are missing the main program. Example:
----------------------------------------------------------------
class HelloWorld {
    public static void main(String [] args) {
      System.out.println("Hello");
    }
  }
---------------------------------------------------------------
[root@hildegard2 java]# gcj -o Hello --main=HelloWorld -g HelloWorld.java
[root@hildegard2 java]# gcj  -C -g HelloWorld.java
[root@hildegard2 java]# java HelloWorld
Hello
------------------------------------------------------------------
..all good so far (java is the SUN JRE), now the problems....
------------------------------------------------------------------
[root@hildegard2 java]# gij HelloWorld
Segmentation fault (core dumped)
[root@hildegard2 java]# Hello
Segmentation fault (core dumped)
--------------------------------------------------------------------
Now some GDB trace stuff (a similiar trace worked fine on HelloWorld.cpp)
-------------------------------------------------------------------------------
[root@hildegard2 java]# gdb Hello core.20442
GNU gdb Red Hat Linux (5.1.90CVS-5)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
Core was generated by `Hello'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/local/lib/libgcc_s.so.1...done.
Loaded symbols for /usr/local/lib/libgcc_s.so.1
Reading symbols from /usr/local/lib/libgcj.so.4...done.
Loaded symbols for /usr/local/lib/libgcj.so.4
Reading symbols from /lib/i686/libm.so.6...done.
Loaded symbols for /lib/i686/libm.so.6
Reading symbols from /lib/i686/libpthread.so.0...done.
Loaded symbols for /lib/i686/libpthread.so.0
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
#0  0x00006000 in ?? ()
(gdb) list
1	/tmp/ccPF2V8D.i: No such file or directory.
	in /tmp/ccPF2V8D.i
(gdb) 
1	in /tmp/ccPF2V8D.i
(gdb) bt  
#0  0x00006000 in ?? ()
#1  0x40394882 in _Jv_Throw (value=0x808cfa0) at exception.cc:100
#2  0x403a5b65 in java::lang::Class::forName(java::lang::String*, bool,
java::lang::ClassLoader*) (className=0x80988c0, initialize=1 '\001',
loader=0x80acfc0)
    at java/lang/natClass.cc:83
#3  0x403a5c2a in java::lang::Class::forName(java::lang::String*)
(className=0x4a415641)
    at java/lang/natClass.cc:110
#4  0x4036fc0a in gnu.gcj.convert.UnicodeToBytes.getDefaultEncoder() ()
    at gnu/gcj/convert/UnicodeToBytes.java:49
#5  0x403e6fac in java.io.PrintStream.PrintStream(java.io.OutputStream, boolean) (
    this=0x2, out=0x4a415641) at java/io/PrintStream.java:241
#6  0x403cd3be in java.lang.System.__U3c_clinit__U3e_() () at
java/lang/System.java:135
#7  0x403a7279 in java::lang::Class::initializeClass() (this=0x8049d10)
    at java/lang/natClass.cc:814
#8  0x4055158c in _Jv_InitClass (klass=0x4a415641) at java/lang/Class.h:265
#9  0x403ccc98 in java.lang.System.getProperty(java.lang.String) (key=0x1)
    at java/lang/System.java:393
#10 0x403d0022 in java.lang.Throwable.__U3c_clinit__U3e_() ()
    at java/lang/Throwable.java:403
#11 0x403a7279 in java::lang::Class::initializeClass() (this=0x8049d10)
    at java/lang/natClass.cc:814
#12 0x403a72b5 in java::lang::Class::initializeClass() (this=0x8049d10)
    at java/lang/Class.h:265
#13 0x403a72b5 in java::lang::Class::initializeClass() (this=0x8049d10)
    at java/lang/Class.h:265
#14 0x403a72b5 in java::lang::Class::initializeClass() (this=0x8049d10)
    at java/lang/Class.h:265
#15 0x40387341 in _Jv_AllocObjectNoFinalizer (klass=0x8049d10, size=20)
    at java/lang/Class.h:265
#16 0x4038737c in _Jv_AllocObject (klass=0x1, size=1245795905) at prims.cc:415
#17 0x40388213 in _Jv_CreateJavaVM(void*) () at prims.cc:921
#18 0x403883ff in _Jv_RunMain(java::lang::Class*, char const*, int, char
const**, bool)
    (klass=0x8049ae0, name=0x0, argc=1, argv=0xbfffe364, is_jar=false) at
prims.cc:973
#19 0x403885bd in JvRunMain (klass=0x4a415641, argc=1245795905, argv=0x4a415641)
    at prims.cc:1011
#20 0x080488f4 in main (argc=1, argv=0xbfffe364) at /tmp/ccPF2V8D.i:11
#21 0x42017499 in __libc_start_main () from /lib/i686/libc.so.6
----------------------------------------------------------------------
I see a couple problems, I am new to this (especially java in GDB) but what is
the situation about this main file located in /tmp? Is that right?

The backtrace looks good until it tries to go to the Class Package to find a
Class name (the only one) and then the crash, why does it have problems?

A little more detail:
-------------------------------------------------------------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 20698)]
0x00006000 in ?? ()
(gdb) 
(gdb) up
#1  0x40394882 in _Jv_Throw (value=0x808cfa0) at exception.cc:100
100	  code = _Unwind_RaiseException (&xh->unwindHeader);
(gdb) up
#2  0x403a5b65 in java::lang::Class::forName(java::lang::String*, bool,
java::lang::ClassLoader*) (className=0x80988c0, initialize=1 '\001',
loader=0x80acfc0)
    at java/lang/natClass.cc:83
83	    throw new java::lang::ClassNotFoundException (className);
(gdb) list
78	  jclass klass = (buffer[0] == '[' 
79			  ? _Jv_FindClassFromSignature (name->data, loader)
80			  : _Jv_FindClass (name, loader));
81	
82	  if (klass == NULL)
83	    throw new java::lang::ClassNotFoundException (className);
84	
85	  if (initialize)
86	    _Jv_InitClass (klass);
87	
(gdb) print name[0]
$18 = {hash = 22081, length = 19009, data = "C"}
(gdb) print name[1]
$19 = {hash = 18254, length = 0, data = ""}
(gdb) print name->data[0]
$20 = 67 'C'
(gdb) print name->data[1]
$21 = 85 'U'
(gdb) print name->data[2]
$22 = 78 'N'
(gdb) print name->data[3]
$23 = 71 'G'
(gdb) print name->data[4]
$24 = 0 '\0'
(gdb) 
------------------------------------------------------------------------
Really means nothing to me. My only ideas right now is that one of the bin
utilities is too old, is this a possability? Also I run Sun Java, could some
libraries be conflicting?

[root@hildegard2 java]# ld --version
GNU ld version 2.11.93.0.2 20020207

Thanks in advance,

  Steve Weppner
  



--------------------------------------------------------
This mail sent via Eckerd IMP: http://webmail.eckerd.edu



More information about the Java mailing list