Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JNI - Application has exited due to signal 10 (SIGBUS).



Hi.
This piece of code is handy to safely always get a JNIEnv valid for the current thread, think I found it in suns JNI documentation.


JNIEnv getEnv(JavaVM *VMPtr)
{
	JNIEnv	*env = NULL;
	int result = VMPtr->GetEnv((void**)&env, JNI_VERSION_1_4);
	if (result == JNI_EDETACHED)
	{
		result = VMPtr->AttachCurrentThreadAsDaemon((void**)&env, NULL);
		if (result != 0)
		{
			return NULL;
		}
	}
	return env;
}

AttachCurrentThreadAsDemon is handy, because you don't need to quit that thread when quitting (JVM quit's when there are no user threas, only Daemon threads).
I'm using JNI to communicate with a J2EE server from a legacy C++ application. Every call to the server is done in a new thread. The initial tread creates the JVM and authenticates to the server. In following invocations I need the initial threads class loader. That's accomplished by a call to:
Thread.currentThread().setContextClassLoader(theGlobalClassLoader). There might be other reasons to reuse the same classloader.


OlaM

On 2004-12-12, at 11.07, Dr. Jörg Wurzer wrote:

I have to develop a JNI to integrate the os x addressbook into an application. It was rather easy to use the API and all junit tests of my classes are successfull, but the application crashes with the message:

... has exited due to signal 10 (SIGBUS).

Because of parallel threads I tried to solve the problem by programing the class with the native methods as a singelton. But that doesn't help. For the native class I use C.

Has anyone an idea how to solve the problem or how to search for the error in the code?

Jörg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >JNI - Application has exited due to signal 10 (SIGBUS). (From: "Dr. Jörg Wurzer" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.