cp-tools-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cp-tools-discuss] [bugs #9508] javah complains if native method called


From: Brian Jones
Subject: [Cp-tools-discuss] [bugs #9508] javah complains if native method called from static initializer
Date: Sat, 14 Aug 2004 08:27:44 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040626 Firefox/0.8

This mail is an automated notification from the bugs tracker
 of the project: classpath-tools.

/**************************************************************************/
[bugs #9508] Latest Modifications:

Changes by: 
                Brian Jones <address@hidden>
'Date: 
                Thu 08/12/2004 at 04:04 (US/Eastern)

            What     | Removed                   | Added
---------------------------------------------------------------------------
          Resolution | None                      | Fixed
              Status | Open                      | Closed


------------------ Additional Follow-up Comments ----------------------------
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.






/**************************************************************************/
[bugs #9508] Full Item Snapshot:

URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=9508>
Project: classpath-tools
Submitted by: 0
On: Wed 06/30/2004 at 16:21

Category:  None
Severity:  5 - Average
Item Group:  None
Resolution:  Fixed
Assigned to:  cbj
Status:  Closed


Summary:  javah complains if native method called from static initializer

Original Submission:  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



Follow-up Comments
------------------


-------------------------------------------------------
Date: Thu 08/12/2004 at 04:04       By: cbj
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.

-------------------------------------------------------
Date: Tue 08/03/2004 at 02:16       By: cbj
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.












For detailed info, follow this link:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=9508>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/







reply via email to

[Prev in Thread] Current Thread [Next in Thread]