Skip to content
Advertisement

Tag: java-native-interface

Socket binding through JNI

I try to open a socket connection on a Linux machine through JNI. If I combine Java_Socket_socket and Java_Socket_bind in same C function, the JNI call works perfectly, but it doesn’t work when I run methods sequentially. This is my code Java code Output: If I create C program from this code, and as regular C program, gcc … &&

JVMTI Invoke toString(); on an Java object from C++ code

So, I was trying to invoke the toString(); method on an object (in this case an enum). This immediately crashed my application. I am assuming that, since the toString(); method isn’t declared directly in the enum but inherited from the Object class (Enum in this case) it is not able to find the method and therefore causes an error. How

java.lang.Error: Invalid memory access on 32 bit Windows

I have JNA wrapper for a C DLL. It works fine, except when used on a Windows 32-bit system. Here is a simplified example: I created JNA bindings as follows: The first function SetData() works fine on both 32-bit as well as 64-bit Windows, but the second function crashes on Windows 7 32-bit. I tried using NativeLong as suggested in

Difference between “native” keyword and @HotSpotIntrinsicCandidate annotation

Why use one over another and vice-versa? Which is more performant? Answer The javadoc comments for the @HotSpotIntrinsicCandidate annotation say the following: “The @HotSpotIntrinsicCandidate annotation is specific to the HotSpot Virtual Machine. It indicates that an annotated method may be (but is not guaranteed to be) intrinsified by the HotSpot VM. A method is intrinsified if the HotSpot VM replaces

Advertisement