This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Possible gcj command line bug related to CNI ?
- From: Andy Tai <atai at atai dot org>
- To: java at gcc dot gnu dot org
- Date: Fri, 3 Jan 2003 16:05:27 -0800 (PST)
- Subject: Possible gcj command line bug related to CNI ?
- Reply-to: atai at atai dot org
Hi, I find some problems when trying to compile Java
and C++ source together (via CNI).
I have two source files:
main.cc:
----
#include <gcj/cni.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
#include <java/lang/Throwable.h>
#include <test.h>
int main(int argc, char *argv)
{
using namespace java::lang;
try
{
JvCreateJavaVM(NULL);
JvAttachCurrentThread(NULL, NULL);
JvInitClass(&System::class$);
test *tt = new test();
tt->test1();
JvDetachCurrentThread();
}
catch (Throwable *t)
{
}
}
----
and test.java:
----
import java.lang.System;
public class test
{
final void test1()
{
int i;
i = 2;
System.out.println(new String("test"));
}
}
----
The following sequence of commands works:
$ gcj -C test.java
$ gcjh test
$ gcj -c test.java
$ gcc -I. test.o main.cc -lgcj -o test
$ ./test
test
However, if I try the following, I get a segmentation
fault:
$ gcj -C test.java
$ gcjh test
$ gcc -I. test.java main.cc -lgcj -o test
$ ./test
Segmentation fault
$ gdb test
GNU gdb 5.2.1
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 "i686-pc-linux-gnu"...
(gdb) r
Starting program: /home/atai/tmp/gcj/test
[New Thread 8192 (LWP 23177)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 8192 (LWP 23177)]
0x40245718 in _Jv_RegisterClassHookDefault
(klass=0x804d0a0)
at
../../../gcc-3.2.1/libjava/java/lang/natClassLoader.cc:459
459 jint hash = HASH_UTF (klass->name);
Current language: auto; currently c++
(gdb)
My system is an x86 (AMD Duron) runing Red Hat 7.3,
gcc and gcj 3.2.1
Hope this is useful, if it shows a real gcj or gcc
bug.
=====
Andy Tai, atai@atai.org
Free Software: the software by the people, of the people and for the people! Develop! Share! Enhance! Enjoy!