You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
I ran into a problem. I can't solve the following problem. I need the function to return a structure or a pointer to it.
But I get the error Process finished with exit code -1073741819 (0xC0000005) when using a pointer, and the following stack of errors when calling a structure: (If you remove the Pointer and the Structure, the function will complete successfully)
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at jnr.ffi.provider.jffi.NativeClosureProxy$Factory.newClosureProxy(NativeClosureProxy.java:89)
at jnr.ffi.provider.jffi.NativeClosureFactory.allocateClosurePointer(NativeClosureFactory.java:156)
at jnr.ffi.provider.jffi.NativeClosureFactory.newClosureReference(NativeClosureFactory.java:177)
at jnr.ffi.provider.jffi.NativeClosureFactory.getClosureReference(NativeClosureFactory.java:218)
at jnr.ffi.provider.jffi.NativeClosureManager$ClosureSite.toNative(NativeClosureManager.java:117)
at dev.ordinal1.ru.Main$Csclink$jnr$ffi$0.GetAccountTransactions(Unknown Source)
at dev.ordinal1.ru.Main.main(Main.java:66)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at jnr.ffi.provider.jffi.NativeClosureProxy$Factory.newClosureProxy(NativeClosureProxy.java:87)
... 6 more
Caused by: java.lang.NoClassDefFoundError: dev/ordinal1/ru/Main$TTransactionInfo$$jnr$$StructByReferenceFromNativeConverter$$0
at jnr.ffi.provider.jffi.NativeClosureProxy$$impl$$0.<init>(Unknown Source)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
... 9 more
Caused by: java.lang.ClassNotFoundException: dev.ordinal1.ru.Main$TTransactionInfo$$jnr$$StructByReferenceFromNativeConverter$$0
at java.base/java.lang.ClassLoader.findClass(ClassLoader.java:733)
at jnr.ffi.provider.jffi.AsmClassLoader.findClass(AsmClassLoader.java:48)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
... 11 more
And next:
//Initialize library
Csclink csc = LibraryLoader.create(Csclink.class).option(LibraryOption.LoadNow, true)
.search(libPath).convention(CallingConvention.STDCALL)
.load("CscLink");
//My callback
public interface TEnumTransactions{
@Delegate @StdCall
void callback(Integer account, Double date, TTransactionInfo transactionInfo);
}
//My call interface
boolean GetAccountTransactions(int account, double firstDate, double SecondDate, TEnumTransactions transactions);
//Struct of TTransactionInfo p.s if I fill the structure myself and send it to another function, everything is done
public static class TTransactionInfo extends Struct {
public Unsigned16 Size = new Unsigned16();
public Unsigned16 Kind = new Unsigned16();
public Signed64 Summa = new Signed64();
public Unsigned16 RestCode = new Unsigned16();
public Signed32 LogDate = new Signed32();
public BYTE UnitNum = new BYTE();
public Signed32 CheckNo = new Signed32();
public String Comment = new UTFString(256, Charset.forName("CP1251"));
public TTransactionInfo(Runtime runtime, Alignment alignment) {
super(runtime, alignment);
}
public TTransactionInfo(Runtime runtime) {
super(runtime);
}
}
//Calling func
csc.GetAccountTransactions(16972, 0, 49998, (account, date, transactionInfo) -> {
System.out.println(...)
});
In addition, I am attaching implementation examples (presumably Delphi, 32-bit library):
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello!
I ran into a problem. I can't solve the following problem. I need the function to return a structure or a pointer to it.
But I get the error
Process finished with exit code -1073741819 (0xC0000005)
when using a pointer, and the following stack of errors when calling a structure: (If you remove the Pointer and the Structure, the function will complete successfully)And next:
In addition, I am attaching implementation examples (presumably Delphi, 32-bit library):
I checked the functionality of these functions via JNA, everything runs successfully there.
Beta Was this translation helpful? Give feedback.
All reactions