mercredi 8 juillet 2020

ExceptionInInitializerError: code size limit exceeded when loading a DLL in JNA

I am trying to load a "nicaiu.dll" in JAVA to acquire data using NI-DAQ devices.

I have converted the Native Library "nicaiu.dll" and the C Header "NIDAQmx.h" to a complete native bindings by JNAerator. But when I load the dll, there is a exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at TestDAQ.main(TestDAQ.java:151)
Caused by: java.lang.IllegalArgumentException: code size limit exceeded
    at sun.misc.ProxyGenerator.generateStaticInitializer(ProxyGenerator.java:1261)
    at sun.misc.ProxyGenerator.generateClassFile(ProxyGenerator.java:484)
    at sun.misc.ProxyGenerator.generateProxyClass(ProxyGenerator.java:339)
    at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:639)
    at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557)
    at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230)
    at java.lang.reflect.WeakCache.get(WeakCache.java:127)
    at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
    at com.sun.jna.Native.loadLibrary(Native.java:415)
    at com.sun.jna.Native.loadLibrary(Native.java:391)
    at org.xjtu.nidaqmx4j.NicaiuLibrary.<clinit>(NicaiuLibrary.java:29)
    ... 1 more

Here is the code about loading the dll

public static final String JNA_LIBRARY_NAME = "nicaiu";
    public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(NicaiuLibrary.JNA_LIBRARY_NAME);
    public static final NicaiuLibrary INSTANCE = (NicaiuLibrary)Native.loadLibrary(NicaiuLibrary.JNA_LIBRARY_NAME, NicaiuLibrary.class);

I would like to know what's wrong with my way to load a dll, is it an error in my code or in the Dll?





Aucun commentaire:

Enregistrer un commentaire