8223044: Add back exception checking in tests

Add exception checking to previously modified tests

Reviewed-by: sspitsyn, cjplummer
This commit is contained in:
Jean Christophe Beyler 2019-05-07 07:43:41 -07:00
parent 7e142d54bf
commit 68ae1e7965
37 changed files with 293 additions and 308 deletions

View File

@ -69,14 +69,14 @@ Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities(JNI
#define ATTACH002_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach002/attach002Target"
void registerNativeMethods(JNIEnv* jni_env) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jclass appClass;
JNINativeMethod nativeMethods[] = {
{ (char*) "agentGotCapabilities", (char*) "()Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities } };
jint nativeMethodsNumber = 1;
appClass = jni->FindClass(ATTACH002_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
appClass = ec_jni->FindClass(ATTACH002_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
ec_jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
}
void JNICALL classLoadHandler(

View File

@ -89,15 +89,15 @@ void JNICALL objectFreeHandler(jvmtiEnv *jvmti, jlong tag) {
}
void registerNativeMethods(JNIEnv* jni_env) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jclass appClass;
JNINativeMethod nativeMethods[] = {
{ (char*) "setTagFor", (char*) "(Ljava/lang/Object;)Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_setTagFor },
{ (char*) "shutdownAgent", (char*) "()V", (void*) Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_shutdownAgent } };
jint nativeMethodsNumber = 2;
appClass = jni->FindClass(ATTACH021_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
appClass = ec_jni->FindClass(ATTACH021_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
ec_jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
}
#ifdef STATIC_BUILD

View File

@ -98,15 +98,15 @@ void JNICALL objectFreeHandler(jvmtiEnv *jvmti, jlong tag) {
#define ATTACH022_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach022/attach022Target"
void registerNativeMethods(JNIEnv* jni_env) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jclass appClass;
JNINativeMethod nativeMethods[] = {
{ (char*)"shutdownAgent", (char*)"(I)Z",
(void*) Java_nsk_jvmti_AttachOnDemand_attach022_attach022Target_shutdownAgent } };
jint nativeMethodsNumber = 1;
appClass = jni->FindClass(ATTACH022_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
appClass = ec_jni->FindClass(ATTACH022_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
ec_jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
}
void JNICALL vmObjectAllocHandler(jvmtiEnv * jvmti,

View File

@ -335,13 +335,13 @@ static int startThread(jthread threadObj) {
/** Create thread object for new agent thread. */
static jthread newThreadObj(JNIEnv* jni_env) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jclass thrClass;
jmethodID cid;
thrClass = jni->FindClass("java/lang/Thread", TRACE_JNI_CALL);
cid = jni->GetMethodID(thrClass, "<init>", "()V", TRACE_JNI_CALL);
return jni->NewObject(thrClass, cid, TRACE_JNI_CALL);
thrClass = ec_jni->FindClass("java/lang/Thread", TRACE_JNI_CALL);
cid = ec_jni->GetMethodID(thrClass, "<init>", "()V", TRACE_JNI_CALL);
return ec_jni->NewObject(thrClass, cid, TRACE_JNI_CALL);
}
/***********************************************************************/
@ -491,12 +491,12 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverInstancesOfClass
JNIEXPORT void JNICALL
Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverObjectsReachableFromObject(JNIEnv* jni_env,
jclass klass) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jobject root = NULL;
int modified = 0;
int found = 0;
root = jni->GetStaticObjectField(debugeeClass, rootFieldID, TRACE_JNI_CALL);
root = ec_jni->GetStaticObjectField(debugeeClass, rootFieldID, TRACE_JNI_CALL);
if (!prepareToIteration(jni_env))
return;
@ -524,7 +524,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverObjectsReachable
static void JNICALL
agentProc(jvmtiEnv* jvmti, JNIEnv* jni_env, void* arg) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
NSK_DISPLAY0("Wait for debugee start\n\n");
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
return;
@ -536,10 +536,10 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni_env, void* arg) {
return;
}
debugeeClass = (jclass) jni->NewGlobalRef(debugeeClass, TRACE_JNI_CALL);
debugeeClass = (jclass) ec_jni->NewGlobalRef(debugeeClass, TRACE_JNI_CALL);
NSK_DISPLAY1("Find ID of 'root' field: %s\n", ROOT_SIGNATURE);
rootFieldID = jni->GetStaticFieldID(debugeeClass, "root",
rootFieldID = ec_jni->GetStaticFieldID(debugeeClass, "root",
ROOT_SIGNATURE, TRACE_JNI_CALL);
NSK_DISPLAY0("Let debugee to run test cases\n");
@ -550,7 +550,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni_env, void* arg) {
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
return;
jni->DeleteGlobalRef(debugeeClass, TRACE_JNI_CALL);
ec_jni->DeleteGlobalRef(debugeeClass, TRACE_JNI_CALL);
NSK_TRACE(jvmti->DestroyRawMonitor(counterMonitor_ptr));
NSK_TRACE(jvmti->DestroyRawMonitor(startLock));
NSK_TRACE(jvmti->DestroyRawMonitor(runLock));

View File

@ -50,18 +50,18 @@ JNIEXPORT jboolean JNICALL
Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t001_setNewByteCode(JNIEnv *jni_env,
jobject o,
jbyteArray byteCode) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jbyte* elements;
jboolean isCopy;
newClassSize = jni->GetArrayLength(byteCode, TRACE_JNI_CALL);
newClassSize = ec_jni->GetArrayLength(byteCode, TRACE_JNI_CALL);
if (newClassSize <= 0) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
NSK_DISPLAY1("\t... got array size: %d\n", newClassSize);
elements = jni->GetByteArrayElements(byteCode, &isCopy, TRACE_JNI_CALL);
elements = ec_jni->GetByteArrayElements(byteCode, &isCopy, TRACE_JNI_CALL);
NSK_DISPLAY1("\t... got elements list: 0x%p\n", (void*)elements);
if (!NSK_JVMTI_VERIFY(jvmti->Allocate(newClassSize, &newClassBytes))) {
@ -78,7 +78,7 @@ Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t001_setNewByteCode(JNIEnv *jni_env,
NSK_DISPLAY1("\t... copied bytecode: %d bytes\n", (int)newClassSize);
NSK_DISPLAY1("\t... release elements list: 0x%p\n", (void*)elements);
jni->ReleaseByteArrayElements(byteCode, elements, JNI_ABORT, TRACE_JNI_CALL);
ec_jni->ReleaseByteArrayElements(byteCode, elements, JNI_ABORT, TRACE_JNI_CALL);
NSK_DISPLAY0("\t... released\n");
return NSK_TRUE;
}
@ -92,8 +92,8 @@ Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t001_setNewByteCode(JNIEnv *jni_env,
JNIEXPORT void JNICALL
Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t001_setClass(JNIEnv *jni_env,
jobject o, jclass cls) {
ExceptionCheckingJniEnvPtr jni(jni_env);
oldClassDef.klass = (jclass) jni->NewGlobalRef(cls, TRACE_JNI_CALL);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
oldClassDef.klass = (jclass) ec_jni->NewGlobalRef(cls, TRACE_JNI_CALL);
}
/* ============================================================================= */
@ -149,7 +149,7 @@ cbClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv* jni_env,
/** Agent algorithm. */
static void JNICALL
agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
ExceptionCheckingJniEnvPtr jni(agentJNI);
ExceptionCheckingJniEnvPtr ec_jni(agentJNI);
/*Wait for debuggee to read new byte codes nsk_jvmti_waitForSync#1*/
NSK_DISPLAY0("Wait for debuggee to read new byte codes nsk_jvmti_waitForSync#1\n");
@ -210,7 +210,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
if (!nsk_jvmti_waitForSync(timeout))
return;
jni->DeleteGlobalRef(oldClassDef.klass, TRACE_JNI_CALL);
ec_jni->DeleteGlobalRef(oldClassDef.klass, TRACE_JNI_CALL);
NSK_DISPLAY0("Let debuggee to finish\n");
if (!nsk_jvmti_resumeSync())

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "ExceptionCheckingJniEnv.hpp"
#include "jni_tools.h"
#include "jvmti_tools.h"
@ -51,21 +52,18 @@ JNIEXPORT jboolean JNICALL
Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t002_setNewByteCode(JNIEnv *jni_env,
jobject o, jint ind, jbyteArray byteCode) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jbyte* elements;
jboolean isCopy;
newClassSize[ind] = jni_env->GetArrayLength(byteCode);
if (!NSK_JNI_VERIFY(jni_env, newClassSize[ind] > 0)) {
newClassSize[ind] = ec_jni->GetArrayLength(byteCode, TRACE_JNI_CALL);
if (!NSK_VERIFY(newClassSize[ind] > 0)) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
NSK_DISPLAY1("\t... got array size: %d\n", newClassSize[ind]);
elements = jni_env->GetByteArrayElements(byteCode, &isCopy);
if (!NSK_JNI_VERIFY(jni_env, elements != NULL)) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
elements = ec_jni->GetByteArrayElements(byteCode, &isCopy, TRACE_JNI_CALL);
NSK_DISPLAY1("\t... got elements list: 0x%p\n", (void*)elements);
if (!NSK_JVMTI_VERIFY(jvmti->Allocate(newClassSize[ind], &newClassBytes[ind]))) {
@ -82,7 +80,7 @@ Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t002_setNewByteCode(JNIEnv *jni_env,
NSK_DISPLAY1("\t... copied bytecode: %d bytes\n", (int)newClassSize[ind]);
NSK_DISPLAY1("\t... release elements list: 0x%p\n", (void*)elements);
NSK_TRACE(jni_env->ReleaseByteArrayElements(byteCode, elements, JNI_ABORT));
NSK_TRACE(ec_jni->ReleaseByteArrayElements(byteCode, elements, JNI_ABORT, TRACE_JNI_CALL));
NSK_DISPLAY0("\t... released\n");
return NSK_TRUE;
}
@ -97,10 +95,8 @@ JNIEXPORT void JNICALL
Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t002_setClass(JNIEnv *jni_env,
jobject o, jint ind, jclass cls) {
oldClassDef[ind].klass = (jclass) jni_env->NewGlobalRef(cls);
if (!NSK_JNI_VERIFY(jni_env, oldClassDef[ind].klass != NULL)) {
nsk_jvmti_setFailStatus();
}
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
oldClassDef[ind].klass = (jclass) ec_jni->NewGlobalRef(cls, TRACE_JNI_CALL);
}
/* ============================================================================= */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,7 @@
* questions.
*/
#include "ExceptionCheckingJniEnv.cpp"
#include "native_thread.cpp"
#include "nsk_tools.cpp"
#include "jni_tools.cpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "ExceptionCheckingJniEnv.hpp"
#include "jni_tools.h"
#include "jvmti_tools.h"
@ -91,23 +92,15 @@ int readNewBytecode(jvmtiEnv* jvmti) {
static void JNICALL
agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
ExceptionCheckingJniEnvPtr ec_jni(jni);
/*Wait for debuggee to set classes to be redefined nsk_jvmti_waitForSync#4*/
NSK_DISPLAY0("Wait for debuggee to set classes to be redefined nsk_jvmti_waitForSync#4\n");
if (!nsk_jvmti_waitForSync(timeout))
return;
NSK_DISPLAY1("Find class: %s\n", TESTED_CLASS_NAME);
classDef.klass = jni->FindClass(TESTED_CLASS_NAME);
if (!NSK_JNI_VERIFY(jni, classDef.klass != NULL)) {
nsk_jvmti_setFailStatus();
return;
}
classDef.klass = (jclass) jni->NewGlobalRef(classDef.klass);
if (!NSK_JNI_VERIFY(jni, classDef.klass != NULL)) {
nsk_jvmti_setFailStatus();
return;
}
classDef.klass = ec_jni->FindClass(TESTED_CLASS_NAME, TRACE_JNI_CALL);
classDef.klass = (jclass) ec_jni->NewGlobalRef(classDef.klass, TRACE_JNI_CALL);
NSK_DISPLAY0("Redfine class with new byte code\n");
NSK_DISPLAY3("class definition:\n\t0x%p, 0x%p:%d\n",
@ -123,7 +116,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return;
}
jni->DeleteGlobalRef(classDef.klass);
ec_jni->DeleteGlobalRef(classDef.klass, TRACE_JNI_CALL);
if (!nsk_jvmti_resumeSync())
return;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,7 @@
* questions.
*/
#include "ExceptionCheckingJniEnv.cpp"
#include "native_thread.cpp"
#include "nsk_tools.cpp"
#include "jni_tools.cpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "ExceptionCheckingJniEnv.hpp"
#include "jni_tools.h"
#include "jvmti_tools.h"
#include "JVMTITools.h"
@ -135,17 +136,13 @@ classEventsHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env,
void
threadEventHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env,
jthread thread) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jclass classObject;
char *className;
char *generic;
jvmtiPhase phase;
classObject = jni_env->GetObjectClass(thread);
if (!NSK_JNI_VERIFY(jni_env, classObject != NULL)) {
nsk_jvmti_setFailStatus();
return;
}
classObject = ec_jni->GetObjectClass(thread, TRACE_JNI_CALL);
if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(classObject, &className, &generic))) {
nsk_jvmti_setFailStatus();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,7 @@
* questions.
*/
#include "ExceptionCheckingJniEnv.cpp"
#include "native_thread.cpp"
#include "nsk_tools.cpp"
#include "jni_tools.cpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "ExceptionCheckingJniEnv.hpp"
#include "jni_tools.h"
#include "jvmti_tools.h"
#include "JVMTITools.h"
@ -61,28 +62,16 @@ static jvmtiPhase currentPhase;
JNIEXPORT jclass JNICALL
Java_nsk_jvmti_scenarios_events_EM01_em01t002_loadClass(JNIEnv *jni_env,
jobject o, jobject loader, jstring className) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jclass klass;
jmethodID methodID;
jclass loadedClass;
klass = jni_env->GetObjectClass(loader);
if (!NSK_JNI_VERIFY(jni_env, klass != NULL)) {
nsk_jvmti_setFailStatus();
return NULL;
}
methodID = jni_env->GetMethodID(
klass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
if (!NSK_JNI_VERIFY(jni_env, methodID != NULL)) {
nsk_jvmti_setFailStatus();
return NULL;
}
loadedClass = (jclass) jni_env->CallObjectMethod(loader, methodID, className);
if (!NSK_JNI_VERIFY(jni_env, loadedClass != NULL)) {
nsk_jvmti_setFailStatus();
return NULL;
}
klass = ec_jni->GetObjectClass(loader, TRACE_JNI_CALL);
methodID = ec_jni->GetMethodID(
klass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;", TRACE_JNI_CALL);
loadedClass = (jclass) ec_jni->CallObjectMethod(loader, methodID,
TRACE_JNI_CALL_VARARGS(className));
return loadedClass;
}
@ -93,16 +82,12 @@ Java_nsk_jvmti_scenarios_events_EM01_em01t002_loadClass(JNIEnv *jni_env,
* Signature: (Ljava/lang/Class;)Z
*/
JNIEXPORT jboolean JNICALL
Java_nsk_jvmti_scenarios_events_EM01_em01t002_prepareClass(JNIEnv *jni_env,
Java_nsk_jvmti_scenarios_events_EM01_em01t002_prepareClass(JNIEnv *jni,
jobject o, jclass klass) {
ExceptionCheckingJniEnvPtr ec_jni(jni);
jfieldID fieldID;
fieldID = jni_env->GetStaticFieldID(klass, "toProvokePreparation", "I");
if (!NSK_JNI_VERIFY(jni_env, fieldID != NULL)) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
fieldID = ec_jni->GetStaticFieldID(klass, "toProvokePreparation", "I", TRACE_JNI_CALL);
return NSK_TRUE;
}
@ -114,26 +99,13 @@ Java_nsk_jvmti_scenarios_events_EM01_em01t002_prepareClass(JNIEnv *jni_env,
JNIEXPORT jboolean JNICALL
Java_nsk_jvmti_scenarios_events_EM01_em01t002_startThread(JNIEnv *jni_env,
jobject o, jobject thread) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jclass klass;
jmethodID methodID;
klass = jni_env->GetObjectClass(thread);
if (!NSK_JNI_VERIFY(jni_env, klass != NULL)) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
methodID = jni_env->GetMethodID(klass, "start", "()V");
if (!NSK_JNI_VERIFY(jni_env, methodID != NULL)) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
if (!NSK_JNI_VERIFY_VOID(jni_env,jni_env->CallVoidMethod(thread, methodID))) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
klass = ec_jni->GetObjectClass(thread, TRACE_JNI_CALL);
methodID = ec_jni->GetMethodID(klass, "start", "()V", TRACE_JNI_CALL);
ec_jni->CallVoidMethod(thread, methodID, TRACE_JNI_CALL);
return NSK_TRUE;
}
@ -224,17 +196,14 @@ classEventsHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env,
void
threadEventHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env,
jthread thread) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jclass classObject;
char *className;
char *generic;
jvmtiPhase phase;
classObject = jni_env->GetObjectClass(thread);
if (!NSK_JNI_VERIFY(jni_env, classObject != NULL)) {
nsk_jvmti_setFailStatus();
return;
}
classObject = ec_jni->GetObjectClass(thread, TRACE_JNI_CALL);
if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(classObject, &className, &generic))) {
nsk_jvmti_setFailStatus();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,7 @@
* questions.
*/
#include "ExceptionCheckingJniEnv.cpp"
#include "native_thread.cpp"
#include "nsk_tools.cpp"
#include "jni_tools.cpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "ExceptionCheckingJniEnv.hpp"
#include "jni_tools.h"
#include "jvmti_tools.h"
#include "JVMTITools.h"
@ -102,24 +103,20 @@ static jobject
getStaticObjField(const char* className, const char* objFieldName,
const char* signature) {
ExceptionCheckingJniEnvPtr ec_jni(jni);
jfieldID fieldID;
jclass klass = NULL;
klass = jni->FindClass(className);
if (!NSK_JNI_VERIFY(jni, klass != NULL))
return NULL;
fieldID = jni->GetStaticFieldID(klass, objFieldName, signature);
if (!NSK_JNI_VERIFY(jni, fieldID != NULL))
return NULL;
return jni->GetStaticObjectField(klass, fieldID);
klass = ec_jni->FindClass(className, TRACE_JNI_CALL);
fieldID = ec_jni->GetStaticFieldID(klass, objFieldName, signature, TRACE_JNI_CALL);
return ec_jni->GetStaticObjectField(klass, fieldID, TRACE_JNI_CALL);
}
/* ============================================================================= */
static int prepare() {
ExceptionCheckingJniEnvPtr ec_jni(jni);
mainThread = findThread(MAIN_THREAD_NAME);
if (!NSK_VERIFY(mainThread != NULL)) {
NSK_COMPLAIN1("<%s> thread not found\n", MAIN_THREAD_NAME);
@ -127,29 +124,20 @@ static int prepare() {
}
/* make thread accessable for a long time */
mainThread = jni->NewGlobalRef(mainThread);
if (!NSK_JNI_VERIFY(jni, mainThread != NULL))
return NSK_FALSE;
mainThread = ec_jni->NewGlobalRef(mainThread, TRACE_JNI_CALL);
startObject = getStaticObjField(DEBUGEE_CLASS_NAME, START_FIELD_NAME, OBJECT_FIELD_SIG);
if (!NSK_VERIFY(startObject != NULL))
return NSK_FALSE;
/*make object accessable for a long time*/
startObject = jni->NewGlobalRef(startObject);
if (!NSK_JNI_VERIFY(jni, startObject != NULL))
return NSK_FALSE;
startObject = ec_jni->NewGlobalRef(startObject, TRACE_JNI_CALL);
endObject = getStaticObjField(DEBUGEE_CLASS_NAME, END_FIELD_NAME, OBJECT_FIELD_SIG);
if (!NSK_VERIFY(endObject != NULL))
return NSK_FALSE;
/*make object accessable for a long time*/
endObject = jni->NewGlobalRef(endObject);
if (!NSK_JNI_VERIFY(jni, endObject != NULL))
return NSK_FALSE;
endObject = ec_jni->NewGlobalRef(endObject, TRACE_JNI_CALL);
debuggeeThread = (jthread) getStaticObjField(DEBUGEE_CLASS_NAME,
THREAD_FIELD_NAME,
@ -158,10 +146,7 @@ static int prepare() {
return NSK_FALSE;
/* make thread accessable for a long time */
debuggeeThread = jni->NewGlobalRef(debuggeeThread);
if (!NSK_JNI_VERIFY(jni, debuggeeThread != NULL))
return NSK_FALSE;
debuggeeThread = ec_jni->NewGlobalRef(debuggeeThread, TRACE_JNI_CALL);
return NSK_TRUE;
}
@ -170,6 +155,7 @@ static int prepare() {
static int
clean() {
ExceptionCheckingJniEnvPtr ec_jni(jni);
/* disable MonitorContendedEnter event */
if (!NSK_JVMTI_VERIFY(
jvmti->SetEventNotificationMode(
@ -177,10 +163,10 @@ clean() {
nsk_jvmti_setFailStatus();
/* dispose global references */
jni->DeleteGlobalRef(startObject);
jni->DeleteGlobalRef(endObject);
jni->DeleteGlobalRef(debuggeeThread);
jni->DeleteGlobalRef(mainThread);
ec_jni->DeleteGlobalRef(startObject, TRACE_JNI_CALL);
ec_jni->DeleteGlobalRef(endObject, TRACE_JNI_CALL);
ec_jni->DeleteGlobalRef(debuggeeThread, TRACE_JNI_CALL);
ec_jni->DeleteGlobalRef(mainThread, TRACE_JNI_CALL);
startObject = NULL;
endObject = NULL;
@ -409,18 +395,19 @@ void
handlerMC1(jvmtiEvent event, jvmtiEnv* jvmti, JNIEnv* jni_env,
jthread thread, jobject object,
jthread expectedThread, jobject expectedObject) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
if (expectedThread == NULL || expectedObject == NULL)
return;
/* check if event is for tested thread and for tested object */
if (jni_env->IsSameObject(expectedThread, thread) &&
jni_env->IsSameObject(expectedObject, object)) {
if (ec_jni->IsSameObject(expectedThread, thread, TRACE_JNI_CALL) &&
ec_jni->IsSameObject(expectedObject, object, TRACE_JNI_CALL)) {
NSK_DISPLAY1("--->%-40s is received\n", TranslateEvent(event));
showThreadInfo(thread);
if (jni_env->IsSameObject(expectedObject, endObject))
if (ec_jni->IsSameObject(expectedObject, endObject, TRACE_JNI_CALL))
NSK_DISPLAY0("\tobject: 'endingMonitor'\n");
else
NSK_DISPLAY0("\tobject: 'startingMonitor'\n");
@ -495,18 +482,19 @@ void
handlerMC2(jvmtiEvent event, jvmtiEnv* jvmti, JNIEnv* jni_env,
jthread thread, jobject object,
jthread expectedThread, jobject expectedObject) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
if (expectedThread == NULL || expectedObject == NULL)
return;
/* check if event is for tested thread and for tested object */
if (jni_env->IsSameObject(expectedThread, thread) &&
jni_env->IsSameObject(expectedObject, object)) {
if (ec_jni->IsSameObject(expectedThread, thread, TRACE_JNI_CALL) &&
ec_jni->IsSameObject(expectedObject, object, TRACE_JNI_CALL)) {
NSK_DISPLAY1("--->%-40s is received (new callbacks)\n", TranslateEvent(event));
showThreadInfo(thread);
if (jni_env->IsSameObject(expectedObject, endObject))
if (ec_jni->IsSameObject(expectedObject, endObject, TRACE_JNI_CALL))
NSK_DISPLAY0("\tobject: 'endingMonitor'\n");
else
NSK_DISPLAY0("\tobject: 'startingMonitor'\n");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,7 @@
* questions.
*/
#include "ExceptionCheckingJniEnv.cpp"
#include "native_thread.cpp"
#include "nsk_tools.cpp"
#include "jni_tools.cpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "ExceptionCheckingJniEnv.hpp"
#include "jni_tools.h"
#include "jvmti_tools.h"
#include "JVMTITools.h"
@ -451,6 +452,7 @@ setCallBacks(int step) {
static void JNICALL
agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
ExceptionCheckingJniEnvPtr ec_jni(agentJNI);
int i;
jfieldID field_accID, field_modID;
jclass cls;
@ -459,17 +461,9 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
if (!nsk_jvmti_waitForSync(timeout))
return;
cls = agentJNI->FindClass(CLASS_NAME);
if (!NSK_JNI_VERIFY(agentJNI, cls != NULL))
return;
field_accID = agentJNI->GetStaticFieldID(cls, FIELD_ACC_NAME, "I");
if (!NSK_JNI_VERIFY(agentJNI, field_accID != NULL))
return;
field_modID = agentJNI->GetStaticFieldID(cls, FIELD_MOD_NAME, "I");
if (!NSK_JNI_VERIFY(agentJNI, field_modID != NULL))
return;
cls = ec_jni->FindClass(CLASS_NAME, TRACE_JNI_CALL);
field_accID = ec_jni->GetStaticFieldID(cls, FIELD_ACC_NAME, "I", TRACE_JNI_CALL);
field_modID = ec_jni->GetStaticFieldID(cls, FIELD_MOD_NAME, "I", TRACE_JNI_CALL);
if (!NSK_JVMTI_VERIFY(jvmti->SetFieldModificationWatch(cls, field_modID)))
return;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,7 @@
* questions.
*/
#include "ExceptionCheckingJniEnv.cpp"
#include "native_thread.cpp"
#include "nsk_tools.cpp"
#include "jni_tools.cpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "ExceptionCheckingJniEnv.hpp"
#include "jni_tools.h"
#include "jvmti_tools.h"
#include "JVMTITools.h"
@ -436,6 +437,7 @@ setCallBacks(int step) {
static void JNICALL
agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
ExceptionCheckingJniEnvPtr ec_jni(agentJNI);
int i;
jmethodID methodID;
jclass cls;
@ -444,13 +446,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
if (!nsk_jvmti_waitForSync(timeout))
return;
cls = agentJNI->FindClass(CLASS_NAME);
if (!NSK_JNI_VERIFY(agentJNI, cls != NULL))
return;
methodID = agentJNI->GetStaticMethodID(cls, METHOD_NAME, "()I");
if (!NSK_JNI_VERIFY(agentJNI, methodID != NULL))
return;
cls = ec_jni->FindClass(CLASS_NAME, TRACE_JNI_CALL);
methodID = ec_jni->GetStaticMethodID(cls, METHOD_NAME, "()I", TRACE_JNI_CALL);
if (!NSK_JVMTI_VERIFY(jvmti->SetBreakpoint(methodID, 0)))
return;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,7 @@
* questions.
*/
#include "ExceptionCheckingJniEnv.cpp"
#include "native_thread.cpp"
#include "nsk_tools.cpp"
#include "jni_tools.cpp"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
#include "ExceptionCheckingJniEnv.hpp"
#include "jni_tools.h"
#include "jvmti_tools.h"
#include "JVMTITools.h"
@ -48,12 +49,11 @@ static int newEventCount[JVMTI_EVENT_COUNT];
/* ============================================================================= */
JNIEXPORT void JNICALL
Java_nsk_jvmti_scenarios_events_EM02_em02t012_setThread(JNIEnv *jni_env,
Java_nsk_jvmti_scenarios_events_EM02_em02t012_setThread(JNIEnv *jni,
jobject o, jthread thrd) {
ExceptionCheckingJniEnvPtr ec_jni(jni);
/* make thread accessable for a long time */
testedThread = jni_env->NewGlobalRef(thrd);
NSK_JNI_VERIFY(jni_env, testedThread != NULL);
testedThread = ec_jni->NewGlobalRef(thrd, TRACE_JNI_CALL);
}
static void

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,7 @@
* questions.
*/
#include "ExceptionCheckingJniEnv.cpp"
#include "native_thread.cpp"
#include "nsk_tools.cpp"
#include "jni_tools.cpp"

View File

@ -79,69 +79,69 @@ static void ErrorCheckerMessage(JNIEnv* env, const char* error_message) {
}
static bool checkSuccess(JNIEnv* env, jclass cls) {
ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
is_error_called = false;
jni->GetFieldID(cls, "anInteger", "I", TRACE_JNI_CALL);
ec_jni->GetFieldID(cls, "anInteger", "I", TRACE_JNI_CALL);
return !is_error_called;
}
static bool checkFailureMessageReturnNull(JNIEnv* env, jclass cls) {
ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
expected_message_start = null_return_expected_message_start;
expected_line_number = __LINE__ + 1;
jni->GetFieldID(cls, "whatever", "does not matter", TRACE_JNI_CALL);
ec_jni->GetFieldID(cls, "whatever", "does not matter", TRACE_JNI_CALL);
return is_error_called && error_message_ok;
}
static bool checkFailureMessageEmptyFile(JNIEnv* env, jclass cls) {
ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
expected_message_start = null_file_expected_message_start;
expected_line_number = __LINE__ + 1;
jni->GetFieldID(cls, "whatever", "does not matter", __LINE__, NULL);
ec_jni->GetFieldID(cls, "whatever", "does not matter", __LINE__, NULL);
return is_error_called && error_message_ok;
}
static bool checkFailureMessageNilLine(JNIEnv* env, jclass cls) {
ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
expected_message_start = null_return_expected_message_start;
expected_line_number = 0;
jni->GetFieldID(cls, "whatever", "does not matter", 0, __FILE__);
ec_jni->GetFieldID(cls, "whatever", "does not matter", 0, __FILE__);
return is_error_called && error_message_ok;
}
static bool checkFailureMessageNegativeLine(JNIEnv* env, jclass cls) {
ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
expected_message_start = null_return_expected_message_start;
expected_line_number = -1;
jni->GetFieldID(cls, "whatever", "does not matter", -1, __FILE__);
ec_jni->GetFieldID(cls, "whatever", "does not matter", -1, __FILE__);
return is_error_called && error_message_ok;
}
static bool checkFailureMessageMinLine(JNIEnv* env, jclass cls) {
ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
expected_message_start = null_return_expected_message_start;
expected_line_number = INT32_MIN;
jni->GetFieldID(cls, "whatever", "does not matter", INT32_MIN, __FILE__);
ec_jni->GetFieldID(cls, "whatever", "does not matter", INT32_MIN, __FILE__);
return is_error_called && error_message_ok;
}
static bool checkFailureMessageMaxLine(JNIEnv* env, jclass cls) {
ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
expected_message_start = null_return_expected_message_start;
expected_line_number = INT32_MAX;
jni->GetFieldID(cls, "whatever", "does not matter", INT32_MAX, __FILE__);
ec_jni->GetFieldID(cls, "whatever", "does not matter", INT32_MAX, __FILE__);
return is_error_called && error_message_ok;
}

View File

@ -37,7 +37,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jboolean JNICALL Java_nsk_share_gc_lock_jni_BooleanArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jbooleanArray arr;
@ -46,18 +46,18 @@ JNIEXPORT jboolean JNICALL Java_nsk_share_gc_lock_jni_BooleanArrayCriticalLocker
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jbooleanArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
arr = (jbooleanArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jboolean*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
pa = (jboolean*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
@ -65,11 +65,11 @@ JNIEXPORT jboolean JNICALL Java_nsk_share_gc_lock_jni_BooleanArrayCriticalLocker
hash = JNI_FALSE;
}
mssleep((long) sleepTime);
jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

View File

@ -36,7 +36,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jbyte JNICALL Java_nsk_share_gc_lock_jni_ByteArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jbyteArray arr;
@ -45,18 +45,18 @@ JNIEXPORT jbyte JNICALL Java_nsk_share_gc_lock_jni_ByteArrayCriticalLocker_criti
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jbyteArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
arr = (jbyteArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jbyte*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
pa = (jbyte*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
@ -64,11 +64,11 @@ JNIEXPORT jbyte JNICALL Java_nsk_share_gc_lock_jni_ByteArrayCriticalLocker_criti
hash = 0;
}
mssleep((long) sleepTime);
jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

View File

@ -37,7 +37,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_CharArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jcharArray arr;
@ -46,18 +46,18 @@ JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_CharArrayCriticalLocker_criti
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jcharArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
arr = (jcharArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
current_time = 0;
enterTime /= 1000;
while (current_time - start_time < enterTime) {
pa = (jchar*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
pa = (jchar*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
@ -65,11 +65,11 @@ JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_CharArrayCriticalLocker_criti
hash = 0;
}
mssleep((long) sleepTime);
jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

View File

@ -37,7 +37,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jdouble JNICALL Java_nsk_share_gc_lock_jni_DoubleArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jdoubleArray arr;
@ -46,18 +46,18 @@ JNIEXPORT jdouble JNICALL Java_nsk_share_gc_lock_jni_DoubleArrayCriticalLocker_c
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jdoubleArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
arr = (jdoubleArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jdouble*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
pa = (jdouble*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash += pa[i];
@ -65,11 +65,11 @@ JNIEXPORT jdouble JNICALL Java_nsk_share_gc_lock_jni_DoubleArrayCriticalLocker_c
hash = 0;
}
mssleep((long) sleepTime);
jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

View File

@ -37,7 +37,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jfloat JNICALL Java_nsk_share_gc_lock_jni_FloatArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jfloatArray arr;
@ -46,18 +46,18 @@ JNIEXPORT jfloat JNICALL Java_nsk_share_gc_lock_jni_FloatArrayCriticalLocker_cri
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jfloatArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
arr = (jfloatArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jfloat*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
pa = (jfloat*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash += pa[i];
@ -65,11 +65,11 @@ JNIEXPORT jfloat JNICALL Java_nsk_share_gc_lock_jni_FloatArrayCriticalLocker_cri
hash = 0;
}
mssleep((long) sleepTime);
jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

View File

@ -37,7 +37,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jint JNICALL Java_nsk_share_gc_lock_jni_IntArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jintArray arr;
@ -46,18 +46,18 @@ JNIEXPORT jint JNICALL Java_nsk_share_gc_lock_jni_IntArrayCriticalLocker_critica
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jintArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
arr = (jintArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jint*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
pa = (jint*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
@ -65,11 +65,11 @@ JNIEXPORT jint JNICALL Java_nsk_share_gc_lock_jni_IntArrayCriticalLocker_critica
hash = 0;
}
mssleep((long) sleepTime);
jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

View File

@ -37,7 +37,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jlong JNICALL Java_nsk_share_gc_lock_jni_LongArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jlongArray arr;
@ -46,18 +46,18 @@ JNIEXPORT jlong JNICALL Java_nsk_share_gc_lock_jni_LongArrayCriticalLocker_criti
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jlongArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
arr = (jlongArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jlong*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
pa = (jlong*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
@ -65,11 +65,11 @@ JNIEXPORT jlong JNICALL Java_nsk_share_gc_lock_jni_LongArrayCriticalLocker_criti
hash = 0;
}
mssleep((long) sleepTime);
jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

View File

@ -37,7 +37,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jshort JNICALL Java_nsk_share_gc_lock_jni_ShortArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jshortArray arr;
@ -46,18 +46,18 @@ JNIEXPORT jshort JNICALL Java_nsk_share_gc_lock_jni_ShortArrayCriticalLocker_cri
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jshortArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
arr = (jshortArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jshort*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
pa = (jshort*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
@ -65,11 +65,11 @@ JNIEXPORT jshort JNICALL Java_nsk_share_gc_lock_jni_ShortArrayCriticalLocker_cri
hash = 0;
}
mssleep((long) sleepTime);
jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

View File

@ -37,7 +37,7 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_StringCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jsize size, i;
jstring str;
@ -46,18 +46,18 @@ JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_StringCriticalLocker_critical
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
str = (jstring) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
str = (jstring) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
size = jni->GetStringLength(str, TRACE_JNI_CALL);
size = ec_jni->GetStringLength(str, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = jni->GetStringCritical(str, NULL, TRACE_JNI_CALL);
pa = ec_jni->GetStringCritical(str, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
@ -65,11 +65,11 @@ JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_StringCriticalLocker_critical
hash = JNI_FALSE;
}
mssleep((long) sleepTime);
jni->ReleaseStringCritical(str, pa, TRACE_JNI_CALL);
ec_jni->ReleaseStringCritical(str, pa, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, str, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, str, TRACE_JNI_CALL);
return hash;
}

View File

@ -38,29 +38,29 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIGlobalRefLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jobject obj;
jobject gref;
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
gref = jni->NewGlobalRef(obj, TRACE_JNI_CALL);
gref = ec_jni->NewGlobalRef(obj, TRACE_JNI_CALL);
mssleep((long) sleepTime);
jni->DeleteGlobalRef(gref, TRACE_JNI_CALL);
ec_jni->DeleteGlobalRef(gref, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
}
}

View File

@ -37,29 +37,29 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNILocalRefLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jobject obj;
jobject gref;
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
gref = jni->NewLocalRef(obj, TRACE_JNI_CALL);
gref = ec_jni->NewLocalRef(obj, TRACE_JNI_CALL);
mssleep((long) sleepTime);
jni->DeleteLocalRef(gref, TRACE_JNI_CALL);
ec_jni->DeleteLocalRef(gref, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
}
}

View File

@ -37,35 +37,35 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIRefLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jobject obj;
jobject gref, lref, gwref;
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
gref = jni->NewGlobalRef(obj, TRACE_JNI_CALL);
lref = jni->NewLocalRef(obj, TRACE_JNI_CALL);
gwref = jni->NewWeakGlobalRef(obj, TRACE_JNI_CALL);
gref = ec_jni->NewGlobalRef(obj, TRACE_JNI_CALL);
lref = ec_jni->NewLocalRef(obj, TRACE_JNI_CALL);
gwref = ec_jni->NewWeakGlobalRef(obj, TRACE_JNI_CALL);
mssleep((long) sleepTime);
jni->DeleteGlobalRef(gref, TRACE_JNI_CALL);
jni->DeleteLocalRef(lref, TRACE_JNI_CALL);
jni->DeleteWeakGlobalRef(gwref, TRACE_JNI_CALL);
ec_jni->DeleteGlobalRef(gref, TRACE_JNI_CALL);
ec_jni->DeleteLocalRef(lref, TRACE_JNI_CALL);
ec_jni->DeleteWeakGlobalRef(gwref, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
}
}

View File

@ -37,30 +37,30 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIWeakGlobalRefLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
jobject obj;
jobject gref;
time_t start_time, current_time;
if (objFieldId == NULL) {
jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
gref = jni->NewWeakGlobalRef(obj, TRACE_JNI_CALL);
gref = ec_jni->NewWeakGlobalRef(obj, TRACE_JNI_CALL);
mssleep((long) sleepTime);
jni->DeleteWeakGlobalRef(gref, TRACE_JNI_CALL);
ec_jni->DeleteWeakGlobalRef(gref, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
}
}

View File

@ -426,6 +426,17 @@ jmethodID ExceptionCheckingJniEnv::GetMethodID(jclass klass, const char* name, c
return marker.ResultNotNull(_jni_env->GetMethodID(klass, name, sig));
}
jmethodID ExceptionCheckingJniEnv::GetStaticMethodID(jclass klass, const char* name, const char* sig,
int line, const char* file_name) {
JNIVerifier<jmethodID> marker(this, "GetStaticMethodID", klass, name, sig, line, file_name);
return marker.ResultNotNull(_jni_env->GetStaticMethodID(klass, name, sig));
}
jboolean ExceptionCheckingJniEnv::IsSameObject(jobject ref1, jobject ref2, int line, const char* file_name) {
JNIVerifier<> marker(this, "IsSameObject", ref1, ref2, line, file_name);
return _jni_env->IsSameObject(ref1, ref2);
}
jobject ExceptionCheckingJniEnv::NewObject(jclass klass, jmethodID methodID,
int line, const char* file_name, ...) {
// In the case of NewObject, we miss the extra arguments passed to NewObject sadly.
@ -437,3 +448,24 @@ jobject ExceptionCheckingJniEnv::NewObject(jclass klass, jmethodID methodID,
va_end(args);
return result;
}
jobject ExceptionCheckingJniEnv::CallObjectMethod(jobject obj, jmethodID methodID, int line,
const char* file_name, ...) {
JNIVerifier<> marker(this, "CallObjectMethod", obj, methodID, line, file_name);
va_list args;
va_start(args, file_name);
jobject result = _jni_env->CallObjectMethodV(obj, methodID, args);
va_end(args);
return result;
}
void ExceptionCheckingJniEnv::CallVoidMethod(jobject obj, jmethodID methodID, int line,
const char* file_name, ...) {
JNIVerifier<> marker(this, "CallVoidMethod", obj, methodID, line, file_name);
va_list args;
va_start(args, file_name);
_jni_env->CallVoidMethodV(obj, methodID, args);
va_end(args);
}

View File

@ -59,6 +59,7 @@
*/
#define TRACE_JNI_CALL __LINE__, __FILE__
#define TRACE_JNI_CALL_VARARGS(...) __LINE__, __FILE__, __VA_ARGS__
class ExceptionCheckingJniEnv {
public:
@ -69,6 +70,8 @@ class ExceptionCheckingJniEnv {
int line, const char* file_name);
jfieldID GetFieldID(jclass klass, const char* name, const char* type,
int line, const char* file_name);
jmethodID GetStaticMethodID(jclass klass, const char* name, const char* sig,
int line, const char* file_name);
jmethodID GetMethodID(jclass klass, const char* name, const char* sig,
int line, const char* file_name);
@ -106,6 +109,14 @@ class ExceptionCheckingJniEnv {
jweak NewWeakGlobalRef(jobject obj, int line, const char* file_name);
void DeleteWeakGlobalRef(jweak obj, int line, const char* file_name);
jboolean IsSameObject(jobject ref1, jobject ref2, int line,
const char* file_name);
jobject CallObjectMethod(jobject obj, jmethodID methodID, int line,
const char* file_name, ...);
void CallVoidMethod(jobject obj, jmethodID methodID, int line,
const char* file_name, ...);
// ExceptionCheckingJniEnv methods.
JNIEnv* GetJNIEnv() {
return _jni_env;