Re: NoClassDefFoundError when call from native side
John Bergin <[email protected]> Fri, 02 May 2014 13:34:33 +0100
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Hi. At line 236 of sun.lwawt.maxcosx.CPlatormWindow http://cr.openjdk.java.net/~anthony/x-11-MaximizedBoth-7132809.0/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java.html there is an invocation to a native method with thefollowing signature: nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h) invocations to native methods are handled via Java Native Interface (JNI). You will need to read up on the JNI specification and understand how Java and native code invoke each other. But in a nutshell your agent converts primitives to objects and breaks the JNI bindings to "nativeCreateNSWindow"hence the UnsatisfiedLinkError. Try tinkering around with a simple JNI hello-word example (and iterate from there) and you'll have a better understanding of the problem. On 02/05/14 12:20, [email protected] wrote: > Hi, > > I have a javaagent who replaces primitive types by an object version. For the > calls to natives methods, I have set a prefix for native methods and I call it > from the original method name who is converting types. > > Now my problem is when the program want to call java methods from native side. > I thought to write a wrapper with the original signature of the methods where I > replace types but I have an java.lang.NoClassDefFoundError before that. > > Is that the class is not found because the signature has changed? > Is there a way to allow the call of a java method on a modified class from > native side? > > Thank you > > The error when I try to run my agent with a graphical interface program: > 2014-05-02 13:00:46.187 java[6399:2407] java.lang.NoClassDefFoundError: Could > not initialize class sun.java2d.opengl.OGLSurfaceData > 2014-05-02 13:00:46.189 java[6399:2407] ( > 0 CoreFoundation 0x00007fff8950725c > __exceptionPreprocess + 172 > 1 libobjc.A.dylib 0x00007fff9005ee75 > objc_exception_throw + 43 > 2 CoreFoundation 0x00007fff89506e09 > -[NSException raise] + 9 > 3 JavaNativeFoundation 0x0000000113846c3f > JNFCallStaticVoidMethod + 213 > 4 liblwawt.dylib 0x00000001156cc23f setBusy + > 121 > 5 CoreFoundation 0x00007fff89437e17 > __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 > 6 CoreFoundation 0x00007fff89437d87 > __CFRunLoopDoObservers + 391 > 7 CoreFoundation 0x00007fff89429543 > __CFRunLoopRun + 995 > 8 CoreFoundation 0x00007fff89428f25 > CFRunLoopRunSpecific + 309 > 9 HIToolbox 0x00007fff91b60a0d > RunCurrentEventLoopInMode + 226 > 10 HIToolbox 0x00007fff91b607b7 > ReceiveNextEventCommon + 479 > 11 HIToolbox 0x00007fff91b605bc > _BlockUntilNextEventMatchingListInModeWithFilter + 65 > 12 AppKit 0x00007fff8dba83de > _DPSNextEvent + 1434 > 13 AppKit 0x00007fff8dba7a2b > -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122 > 14 libosxapp.dylib 0x0000000113fc9b56 > -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 124 > 15 AppKit 0x00007fff8db9bb2c > -[NSApplication run] + 553 > 16 libosxapp.dylib 0x0000000113fc99b9 > +[NSApplicationAWT runAWTLoopWithApp:] + 156 > 17 liblwawt.dylib 0x00000001156cc13e -[AWTStarter > starter:] + 1591 > 18 Foundation 0x00007fff93a2513e > __NSThreadPerformPerform + 229 > 19 CoreFoundation 0x00007fff89438661 > __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 > 20 CoreFoundation 0x00007fff89429d12 > __CFRunLoopDoSources0 + 242 > 21 CoreFoundation 0x00007fff8942949f > __CFRunLoopRun + 831 > 22 CoreFoundation 0x00007fff89428f25 > CFRunLoopRunSpecific + 309 > 23 java 0x000000010eb9942d > CreateExecutionEnvironment + 871 > 24 java 0x000000010eb93bdc JLI_Launch + > 1952 > 25 java 0x000000010eb9978a main + 101 > 26 java 0x000000010eb93434 start + 52 > 27 ??? 0x0000000000000005 0x0 + 5 > ) > Exception in thread "main" java.lang.UnsatisfiedLinkError: > sun.lwawt.macosx.CPlatformWindow.$$$WRAPPER_NATIVE_METHOD$$$_nativeCreateNSWindow(JJDDDD)J > at sun.lwawt.macosx.CPlatformWindow.$$$WRAPPER_NATIVE_METHOD > $$$_nativeCreateNSWindow(Native Method) > at > sun.lwawt.macosx.CPlatformWindow.nativeCreateNSWindow(CPlatformWindow.java) > at > sun.lwawt.macosx.CPlatformWindow.initialize(CPlatformWindow.java:237) > at sun.lwawt.LWWindowPeer.<init>(LWWindowPeer.java:158) > at sun.lwawt.LWToolkit.createDelegatedPeer(LWToolkit.java:215) > at sun.lwawt.LWToolkit.createFrame(LWToolkit.java:232) > at java.awt.Frame.addNotify(Frame.java:477) > at java.awt.Window.show(Window.java:1031) > at java.awt.Component.show(Component.java:1651) > at java.awt.Component.setVisible(Component.java:1603) > at java.awt.Window.setVisible(Window.java:1014) > at pkgfloat.FloatClass.main(FloatClass.java:47)
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws