The bug with JNI function RegisterNatives in Java 1.6

JDK 1.6 has problems with implementation of native methods in the class that loaded at runtime. I found it after making debug version of JVM.DLL.

I have JNI code that

- loads at runtime a new class with native methods;

- implements these methods with RegisterNatives();

- gets Field and Constructor IDs (at this time JVM cleans all finction pointers in Methods Table of the class);

- creates the object of this class and passes it to Java code for callbacks.

When Java calls my native methods I get the exception: "java.lang.UnsatisfiedLinkError", the naive method was not implemented.

I did workaround in my JNI code:

- load the class;

- get Field and Constructor IDs;

- implement methods with RegisterNatives();

- create the object of this class and pass it to Java code for callbacks.

This version of my code runs fine.

[901 byte] By [vitallisa] at [2007-11-26 13:10:49]
# 1
If you are sure it is a bug then the correct place to post is the bug database.
jschella at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
Yes, this is a bug. I have spent two days to generate MS Visual Studio Project with Java sources (make files are written very bad with a number of bugs) and run it in debug mode with my my tools to realize the problem. But I have no time to do a sample.
vitallisa at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
> But I have no time to do a sample.There is almost zero chance that it will get fixed then.
jschella at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4
Sun should be interested in fixing this bug! And I will wait.
vitallisa at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5
I second the motion that you file a bug with a test case. Without one, your problem is just a rumor.Sun is interested in fixing bugs, but won't go a wild goose chase. Submit a test case (or in the case of a crash, an error log) and give the problem a fighting chance to be fixed.
rasbolda at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 6

OK,

get my tool at

http://www.sharewareplaza.com/OOJNI-Add-in-NET-for-VC7-1-download_43587.html

Install it, start MS Visual Studio 7.1, open examples for C++ (unmanaged) and use the example "FlowLayoutTest" for debugging JVM code.

In a week I should substitute this version with new update that includes my workaround for JVM 1.6.

vitallisa at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 7

> OK,

> get my tool at

> http://www.sharewareplaza.com/OOJNI-Add-in-NET-for-VC7

> -1-download_43587.html

> Install it, start MS Visual Studio 7.1, open examples

> for C++ (unmanaged) and use the example

> "FlowLayoutTest" for debugging JVM code.

> In a week I should substitute this version with new

> update that includes my workaround for JVM 1.6.

What does this have to do with the rest of this thread and the suggestion that you should post a bug in the bug database?

jschella at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 8
I do not obliged to do this. This is my favour to JVM developers. Go Microsoft's forums and look how they correspond with clients.
vitallisa at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 9
> I do not obliged to do this. This is my favour to JVM> developers. Go Microsoft's forums and look how they> correspond with clients.If that is your criteria then you should be using .Net.
jschella at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 10

What I do with Java? I am developing

- .NET JNI SDK (like regular JNI SDK for C++) for integration .NET and SUN/IBM Java codes,

- technology of integrating Java applications with other programming platforms without knowledge of Java Application sources,

- automation of JNI programming in C++ and .NET,

- tools for conversion AWT based applications to SWING, etc.

Beside Java projects I develop projects with Databases, OLAP, WEB in .NET, C++, VB6, etc.

That is why I have no much time to focus in SUN Java.

vitallisa at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 11
Actually, the bug for this issue has been filed recently.You can refer to: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6493522The bug is accepted and test case is also supported. So if you are interested in quick fixing, you can start voting for it ;-)
iwanowa at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 12

> What I do with Java? I am developing

> - .NET JNI SDK (like regular JNI SDK for C++) for

> integration .NET and SUN/IBM Java codes,

> - technology of integrating Java applications with

> other programming platforms without knowledge of Java

> Application sources,

> - automation of JNI programming in C++ and .NET,

> - tools for conversion AWT based applications to

> SWING, etc.

>

> Beside Java projects I develop projects with

> Databases, OLAP, WEB in .NET, C++, VB6, etc.

>

> That is why I have no much time to focus in SUN Java.

Yes and I am busy too.

That had nothing to do with my post however.

I suggested that if your sole or primary critieria for langauge selection is whether the language forums have company representatives then you should choose .Net rather than java.

Myself the forum support is never even a minor factor in language selection.

jschella at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 13
for everybody who discovers this thread too, the matching bugreport is at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6493522
sebsauera at 2007-7-7 17:25:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...