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
🥺 block which is in a method apple provided (doesn't work)
apple framework definition (CoreML)
publicabstractclassVNCoreMLRequestextendsVNImageBasedRequest {
︙
/** * Creates a model container to be used with VNCoreMLRequest * based on a Core ML model, with an optional completion handler. */publicabstractVNCoreMLRequestinitWithModel_completionHandler(VNCoreMLModelmodel, BlockLiteral/* ^VNRequestCompletionHandler */completionHandler);
publicinterfaceVNRequestCompletionHandlerextendsObjCBlock {
voidcallback(BlockLiteralliteral, IDid, IDerror);
}
sample using a block which is in a method apple provided
# SIGSEGV (0xb) at pc=0x000000018d5fb8f8, pid=78669, tid=10243
#
# JRE version: OpenJDK Runtime Environment JBR-17.0.10+1-1087.17-jcef (17.0.10+1) (build 17.0.10+1-b1087.17)
# Java VM: OpenJDK 64-Bit Server VM JBR-17.0.10+1-1087.17-jcef (17.0.10+1-b1087.17, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# C [libobjc.A.dylib+0x78f8] objc_retain+0x10
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# https://youtrack.jetbrains.com/issues/JBR
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- S U M M A R Y ------------
Command Line: -ea -Djava.util.logging.config.file=/Users/nsano/src/java/rococoa/rococoa-contrib/target/test-classes/logging.properties -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=57480:/Applications/IntelliJ IDEA CE.app/Contents/bin -Djunit.jupiter.conditions.deactivate=org.junit.*Enabled*Condition -Dfile.encoding=UTF-8 com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 org.rococoa.cocoa.coreml.CoreMLTest,test2
Host: "Mac14,14" arm64, 24 cores, 192G, Darwin 23.3.0, macOS 14.3.1 (23D60)
Time: Tue Feb 27 01:27:49 2024 JST elapsed time: 0.843533 seconds (0d 0h 0m 0s)
--------------- T H R E A D ---------------
Current thread (0x000000013a813600): JavaThread "main" [_thread_in_native, id=10243, stack(0x000000016b824000,0x000000016ba27000)]
Stack: [0x000000016b824000,0x000000016ba27000], sp=0x000000016ba22a50, free space=2042k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libobjc.A.dylib+0x78f8] objc_retain+0x10
C [Vision+0x225de8] -[VNCoreMLRequest initWithModel:completionHandler:]+0x50
C [jna4316463068936839408.tmp+0x1004c] ffi_prep_closure_loc+0x164c
C [jna4316463068936839408.tmp+0xe970] ffi_call+0x57c
C [jna4316463068936839408.tmp+0x678c] Java_com_sun_jna_Native_invokePointer+0x96c
C [jna4316463068936839408.tmp+0x6b74] Java_com_sun_jna_Native_invokeLong+0x2c
j com.sun.jna.Native.invokeLong(Lcom/sun/jna/Function;JI[Ljava/lang/Object;)J+0
j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;ZI)Ljava/lang/Object;+245
j com.sun.jna.Function.invoke(Ljava/lang/reflect/Method;[Ljava/lang/Class;Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+271
j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+37
j org.rococoa.internal.MsgSendHandler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+114
j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+363
j jdk.proxy2.$Proxy16.syntheticSendMessage(Ljava/lang/Class;Lorg/rococoa/ID;Lorg/rococoa/Selector;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;+34 jdk.proxy2
j org.rococoa.Foundation.send(Lorg/rococoa/ID;Lorg/rococoa/Selector;Ljava/lang/Class;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+202
j org.rococoa.Foundation.send(Lorg/rococoa/ID;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+9
j org.rococoa.Foundation.send(Lorg/rococoa/ID;Ljava/lang/String;Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;+5
j org.rococoa.internal.ObjCObjectInvocationHandler.sendOnThisOrMainThread(Ljava/lang/reflect/Method;Lorg/rococoa/ID;Ljava/lang/String;Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;+29
j org.rococoa.internal.ObjCObjectInvocationHandler.invokeCocoa(Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+78
j org.rococoa.internal.ObjCObjectInvocationHandler.intercept(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;Ljava/lang/reflect/Method;Ljava/lang/Object;)Ljava/lang/Object;+130
j org.rococoa.cocoa.vision.VNCoreMLRequest$$ByRococoa.initWithModel_completionHandler(Lorg/rococoa/cocoa/vision/VNCoreMLModel;Lorg/rococoa/ObjCBlocks$BlockLiteral;)Lorg/rococoa/cocoa/vision/VNCoreMLRequest;+21
j org.rococoa.cocoa.coreml.CoreMLTest.test2()V+34
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
-
❣ Obj-C Block Implementation
Background
Rococoa is Objective-C bindings over JNA(Java Native Access).
But JNA does NOT support obj-c block.
I've tried to adapt obj-c block to Java.
So far
my test implementation works!
id
argumentObjCObject
argumentbut a block which is used in a method provided by Apple doesn't work. WHY?
it got error
SIGSEGV
atobjc_retain
.working codes, not working codes and error log, see below.
😀 working codes
objective-c block definitions
java implementation for block
test code (works)
🥺 block which is in a method apple provided (doesn't work)
apple framework definition (CoreML)
sample using a block which is in a method apple provided
error log
references
Beta Was this translation helpful? Give feedback.
All reactions