[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/22757] javah complains if native method called from stati
From: |
gcc-bugzilla at gcc dot gnu dot org |
Subject: |
[Bug classpath/22757] javah complains if native method called from static initializer |
Date: |
16 Oct 2005 01:27:02 -0000 |
If a static initializer calls a native method, then
gnu.classpath.tools.JavahMain emits:
*** Couldn't bind native method Java_Foo_bar ***
*** or Java_Foo_bar__ ***
Here is a small test case:
/* Foo.java
* Compile with:
* jikes-sablevm Foo.java
* sablevm -Y -c /usr/share/java/cp-tools.jar:. gnu.classpath.tools.JavahMain
-o Foo.h Foo
*/
public class Foo {
private static native void bar();
static { bar(); }
static void foo(int a) { bar(); }
void foo() { bar(); }
}
If you comment out the static initializer, then javah gives no message,
otherwise it gives the message above. Note that static methods and non-static
methods calling native methods are ok, it is only the static initializer that
is causing the problem.
Versions:
jikes-sablevm 1.1.5-1
sablevm 1.1.5-1
classpath-tool 0.0.20020812-1
linux 2.6.3-1-686
------- Comment #1 from from-classpath at savannah dot gnu dot org 2004-08-03
02:16 -------
I was unable to produce this problem with javah, but did see it with javap.
The error, if you had a stacktrace, is because gnu.bytecode is doing a
Class.forName() call and this will result in the static initializer being
called which requires the native method to exist in some library somewhere and
be part of your environment. I would like to see if there is some way to fix
this such that it is not necessary to initialize a Class instance.
------- Comment #2 from from-classpath at savannah dot gnu dot org 2004-08-12
04:04 -------
The version of gnu.bytecode in use has been updated that resolves this problem
by using a version of Class.forName that does not require Class initialization.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22757
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug classpath/22757] javah complains if native method called from static initializer,
gcc-bugzilla at gcc dot gnu dot org <=