*not part of the build*

fix for 90573


git-svn-id: svn://10.0.0.236/trunk@99224 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
2001-07-13 22:14:57 +00:00
parent db7a14cab5
commit 0947413732
5 changed files with 49 additions and 14 deletions

View File

@@ -40,6 +40,8 @@ PRLogModuleInfo* bcJavaGlobal::log = NULL;
static int counter = 0;
JNIEnv * bcJavaGlobal::GetJNIEnv(int *detachRequired) {
PRLogModuleInfo * l = GetLog();
PR_LOG(l,PR_LOG_DEBUG,("--bcJavaGlobal::GetJNIEnv\n"));
JNIEnv * env;
int res;
*detachRequired = 1;
@@ -53,7 +55,7 @@ JNIEnv * bcJavaGlobal::GetJNIEnv(int *detachRequired) {
} else {
res = jvm->AttachCurrentThread(JNIENV &env,NULL);
#ifdef DEBUG_idk
printf("--bcJavaGlobal::GetJNIEnv ++counter %d\n",++counter);
PR_LOG(l,PR_LOG_DEBUG,("--bcJavaGlobal::GetJNIEnv ++counter %d\n",++counter));
#endif
}
}
@@ -61,11 +63,13 @@ JNIEnv * bcJavaGlobal::GetJNIEnv(int *detachRequired) {
}
void bcJavaGlobal::ReleaseJNIEnv() {
PRLogModuleInfo * l = GetLog();
PR_LOG(l,PR_LOG_DEBUG,("--bcJavaGlobal::ReleaseJNIEnv\n"));
int res;
if (jvm) {
res = jvm->DetachCurrentThread();
#ifdef DEBUG_idk
printf("--bcJavaGlobal::ReleaseJNIEnv --counter %d\n",--counter);
PR_LOG(l,PR_LOG_DEBUG,("--bcJavaGlobal::ReleaseJNIEnv --counter %d\n",--counter));
#endif
}
}

View File

@@ -198,6 +198,7 @@ NS_IMETHODIMP bcJavaStubsAndProxies::GetOID(char *location, bcOID *oid) {
//location[strlen(location)-5] = 0; //nb dirty hack. location is xyz.jar.info
strcpy(location + strlen(location)-4,"comp");
jstring jstr = env->NewStringUTF(location);
strcpy(location + strlen(location)-4,"info");
jobject object = env->CallStaticObjectMethod(componentLoader, loadComponentID, jstr);
bcIStub *stub = new bcJavaStub(object);
NS_WITH_SERVICE(bcIORBComponent,_orb,kORBComponent,&result);

View File

@@ -51,6 +51,7 @@ bcIJavaSample.java : bcIJavaSample.idl
install-component: bcJavaSample.jar.comp bcJavaSample.jar.info
cp bcJavaSample.jar.comp bcJavaSample.jar.info $(DEPTH)/dist/bin/components/
cp bcIJavaSample.class $(DIST)/classes
clobber-java:
rm -f *.class *.jar

View File

@@ -137,28 +137,40 @@ NS_IMETHODIMP bcJavaSample::Test9(nsIID * *po) {
static bcIJavaSample * javaSample = NULL;
#if 1
void thread_start( void *arg ) {
printf("--thread_start currentThread=%p\n",PR_GetCurrentThread());
printf("--thread_start currentThread=%d\n",PR_GetCurrentThread());
nsresult r;
if (javaSample == NULL) {
nsresult r;
r = nsComponentManager::CreateInstance("bcJavaSample",
nsnull,
NS_GET_IID(bcIJavaSample),
(void**)&javaSample);
// } else {
bcIJavaSample *t;
javaSample->Test1((int)PR_GetCurrentThread());
printf("--thread_start after first invocation \n");
javaSample->Test1((int)PR_GetCurrentThread());
printf("--thread_start after second invocation \n");
}
javaSample->Test1((int)PR_GetCurrentThread());
printf("--thread_start after first invocation \n");
javaSample->Test1((int)PR_GetCurrentThread());
printf("--thread_start after second invocation \n");
}
#endif
#if 0
void thread_start( void *arg ) {
printf("--thread_start currentThread=%p\n",PR_GetCurrentThread());
nsresult r;
bcIJavaSample *t;
javaSample->Test1((int)PR_GetCurrentThread());
printf("--thread_start after first invocation \n");
}
#endif
void test() {
printf("--BlackConnect test start\n");
nsresult r;
bcIJavaSample *test;
bcIJavaSample *a = new bcJavaSample();
#if 0
r = nsComponentManager::CreateInstance("bcJavaSample",
nsnull,
NS_GET_IID(bcIJavaSample),
@@ -167,11 +179,22 @@ void test() {
printf("--[debug] can not load bcJavaSample\n");
return;
}
#endif
//sigsend(P_PID, getpid(),SIGINT);
//test->Test1(2000);
#if 1
{
for (int i = 0; i < 1; i++) {
PRThread *thr = PR_CreateThread( PR_USER_THREAD,
thread_start,
test,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_JOINABLE_THREAD,
0);
PR_JoinThread(thr);
for (int i = 0; i < 200; i++) {
printf("\n--we are creating threads i=%d\n",i);
PRThread *thr = PR_CreateThread( PR_USER_THREAD,
thread_start,
@@ -180,12 +203,17 @@ void test() {
PR_LOCAL_THREAD,
PR_JOINABLE_THREAD,
0);
PR_JoinThread(thr);
//PR_JoinThread(thr);
}
}
return;
#endif
test->Test1(1000);
//thread_start(test);
if (javaSample == NULL) {
return;
}
test = javaSample;
test->Test1((int)PR_GetCurrentThread());
return;
bcIJavaSample *test1;
if (NS_FAILED(r)) {
printf("failed to get component. try to restart test\n");

View File

@@ -55,6 +55,7 @@ bcIJavaSample.java : bcIJavaSample.idl
install-component: bcJavaSample.jar.comp bcJavaSample.jar.info $(DLL)
copy bcJavaSample.jar* $(DIST)\bin\components
copy $(DLL) $(DIST)\bin\components
copy bcIJavaSample.class $(DEPTH)\dist\classes
clobber-java:
-del *.class *.jar.comp