8209611: use C++ compiler for hotspot tests
Reviewed-by: vlivanov, ihse, erikj, jcbeyler
This commit is contained in:
parent
86c476b5e5
commit
8c47dc4a94
@ -60,13 +60,13 @@ define SetupTestFilesCompilationBody
|
||||
ifeq ($$($1_TYPE), LIBRARY)
|
||||
$1_PREFIX = lib
|
||||
$1_OUTPUT_SUBDIR := lib
|
||||
$1_CFLAGS := $(CFLAGS_TESTLIB)
|
||||
$1_CFLAGS += $(CFLAGS_TESTLIB)
|
||||
$1_LDFLAGS := $(LDFLAGS_TESTLIB) $(call SET_SHARED_LIBRARY_ORIGIN)
|
||||
$1_COMPILATION_TYPE := LIBRARY
|
||||
else ifeq ($$($1_TYPE), PROGRAM)
|
||||
$1_PREFIX = exe
|
||||
$1_OUTPUT_SUBDIR := bin
|
||||
$1_CFLAGS := $(CFLAGS_TESTEXE)
|
||||
$1_CFLAGS += $(CFLAGS_TESTEXE)
|
||||
$1_LDFLAGS := $(LDFLAGS_TESTEXE)
|
||||
$1_COMPILATION_TYPE := EXECUTABLE
|
||||
else
|
||||
@ -75,7 +75,8 @@ define SetupTestFilesCompilationBody
|
||||
|
||||
# Locate all files with the matching prefix
|
||||
$1_FILE_LIST := \
|
||||
$$(shell $$(FIND) $$($1_SOURCE_DIRS) -type f -name "$$($1_PREFIX)*.c")
|
||||
$$(shell $$(FIND) $$($1_SOURCE_DIRS) -type f \( -name "$$($1_PREFIX)*.c" \
|
||||
-o -name "$$($1_PREFIX)*.cpp" \))
|
||||
|
||||
$1_EXCLUDE_PATTERN := $$(addprefix %/, $$($1_EXCLUDE))
|
||||
$1_FILTERED_FILE_LIST := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_FILE_LIST))
|
||||
@ -94,6 +95,7 @@ define SetupTestFilesCompilationBody
|
||||
CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
|
||||
LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \
|
||||
LIBS := $$($1_LIBS_$$(name)), \
|
||||
TOOLCHAIN := $(if $$(filter %.cpp, $$(file)), TOOLCHAIN_LINK_CXX, TOOLCHAIN_DEFAULT), \
|
||||
OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)),$$($1_OPTIMIZATION_$$(name)),LOW), \
|
||||
COPY_DEBUG_SYMBOLS := false, \
|
||||
STRIP_SYMBOLS := false, \
|
||||
|
@ -148,6 +148,9 @@ BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libNoFramePointer := $(NO_FRAMEPOINTER_CFLA
|
||||
# Optimization -O3 needed, HIGH == -O3
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_OPTIMIZATION_libNoFramePointer := HIGH
|
||||
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS := -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
|
||||
BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS := -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
|
||||
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libProcessUtils := $(VM_SHARE_INCLUDES)
|
||||
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libThreadController := $(NSK_MONITORING_INCLUDES)
|
||||
@ -845,10 +848,6 @@ BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libVirtualMachine09agent00 := $(NSK_AOD_INC
|
||||
|
||||
################################################################################
|
||||
|
||||
ifeq ($(TOOLCHAIN_TYPE), solstudio)
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libji06t001 += -erroff=E_END_OF_LOOP_CODE_NOT_REACHED
|
||||
endif
|
||||
|
||||
# Platform specific setup
|
||||
ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc)
|
||||
BUILD_HOTSPOT_JTREG_EXCLUDE += liboverflow.c exeThreadSignalMask.c
|
||||
|
@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <jvmti.h>
|
||||
|
||||
#define STATUS_FAILED 2
|
||||
#define STATUS_PASSED 0
|
||||
|
||||
#define REFERENCES_ARRAY_SIZE 10000000
|
||||
|
||||
#ifndef JNI_ENV_ARG
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define JNI_ENV_ARG(x, y) x
|
||||
#define JNI_ENV_PTR(x) x
|
||||
#else
|
||||
#define JNI_ENV_ARG(x, y) x , y
|
||||
#define JNI_ENV_PTR(x) (*x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _Included_gc_g1_unloading_unloading_classloaders_JNIClassloader
|
||||
#define _Included_gc_g1_unloading_unloading_classloaders_JNIClassloader
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_classloaders_JNIClassloader
|
||||
* Method: loadThroughJNI0
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;[B)Ljava/lang/Class;
|
||||
*/
|
||||
JNIEXPORT jclass JNICALL Java_gc_g1_unloading_classloaders_JNIClassloader_loadThroughJNI0 (JNIEnv * env,
|
||||
jclass clazz, jstring className, jobject classLoader, jbyteArray bytecode) {
|
||||
|
||||
const char * classNameChar = JNI_ENV_PTR(env)->GetStringUTFChars(JNI_ENV_ARG(env, className), NULL);
|
||||
jbyte * arrayContent = JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, bytecode), NULL);
|
||||
jsize bytecodeLength = JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, bytecode));
|
||||
jclass returnValue = JNI_ENV_PTR(env)->DefineClass(JNI_ENV_ARG(env, classNameChar), classLoader, arrayContent, bytecodeLength);
|
||||
if (!returnValue) {
|
||||
printf("ERROR: DefineClass call returned NULL by some reason. Classloading failed.\n");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_loading_ClassLoadingThread
|
||||
* Method: makeRedefinition0
|
||||
* Signature: (ILjava/lang/Class;[B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_gc_g1_unloading_loading_ClassLoadingThread_makeRedefinition0(JNIEnv *env,
|
||||
jclass cls, jint fl, jclass redefCls, jbyteArray classBytes) {
|
||||
JavaVM * jvm;
|
||||
jvmtiEnv * jvmti;
|
||||
jvmtiError err;
|
||||
jvmtiCapabilities caps;
|
||||
jvmtiClassDefinition classDef;
|
||||
jint jint_err = JNI_ENV_PTR(env)->GetJavaVM(JNI_ENV_ARG(env, &jvm));
|
||||
if (jint_err) {
|
||||
printf("GetJavaVM returned nonzero: %d", jint_err);
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
jint_err = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **)&jvmti), JVMTI_VERSION_1_0);
|
||||
if (jint_err) {
|
||||
printf("GetEnv returned nonzero: %d", jint_err);
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
err = JNI_ENV_PTR(jvmti)->GetPotentialCapabilities(JNI_ENV_ARG(jvmti, &caps));
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
printf("(GetPotentialCapabilities) unexpected error: %d\n",err);
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
err = JNI_ENV_PTR(jvmti)->AddCapabilities(JNI_ENV_ARG(jvmti, &caps));
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
printf("(AddCapabilities) unexpected error: %d\n", err);
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!caps.can_redefine_classes) {
|
||||
printf("ERROR: Can't redefine classes. jvmtiCapabilities.can_redefine_classes isn't set up.");
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
classDef.klass = redefCls;
|
||||
classDef.class_byte_count =
|
||||
JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
|
||||
classDef.class_bytes = (unsigned char *)
|
||||
JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes),
|
||||
NULL);
|
||||
|
||||
if (fl == 2) {
|
||||
printf(">>>>>>>> Invoke RedefineClasses():\n");
|
||||
printf("\tnew class byte count=%d\n", classDef.class_byte_count);
|
||||
}
|
||||
err = JNI_ENV_PTR(jvmti)->RedefineClasses(JNI_ENV_ARG(jvmti, 1), &classDef);
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
printf("%s: Failed to call RedefineClasses():\n", __FILE__);
|
||||
printf("\tthe function returned error %d\n", err);
|
||||
printf("\tFor more info about this error see the JVMTI spec.\n");
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
if (fl == 2)
|
||||
printf("<<<<<<<< RedefineClasses() is successfully done\n");
|
||||
|
||||
return STATUS_PASSED;
|
||||
}
|
||||
|
||||
jobject referencesArray[REFERENCES_ARRAY_SIZE];
|
||||
int firstFreeIndex = 0;
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_keepref_JNIGlobalRefHolder
|
||||
* Method: keepGlobalJNIReference
|
||||
* Signature: (Ljava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_gc_g1_unloading_keepref_JNIGlobalRefHolder_keepGlobalJNIReference
|
||||
(JNIEnv * env, jclass clazz, jobject obj) {
|
||||
int returnValue;
|
||||
referencesArray[firstFreeIndex] = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, obj));
|
||||
printf("checkpoint1 %d \n", firstFreeIndex);
|
||||
returnValue = firstFreeIndex;
|
||||
firstFreeIndex++;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_keepref_JNIGlobalRefHolder
|
||||
* Method: deleteGlobalJNIReference
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_gc_g1_unloading_keepref_JNIGlobalRefHolder_deleteGlobalJNIReference
|
||||
(JNIEnv * env, jclass clazz, jint index) {
|
||||
JNI_ENV_PTR(env)->DeleteGlobalRef(JNI_ENV_ARG(env, referencesArray[index]));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_keepref_JNILocalRefHolder
|
||||
* Method: holdWithJNILocalReference
|
||||
* Signature: (Ljava/lang/Object;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_gc_g1_unloading_keepref_JNILocalRefHolder_holdWithJNILocalReference
|
||||
(JNIEnv * env, jobject thisObject, jobject syncObject) {
|
||||
jclass clazz, objectClazz;
|
||||
jfieldID objectToKeepField;
|
||||
jobject objectToKeep, localRef;
|
||||
jmethodID waitMethod;
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, thisObject);
|
||||
objectToKeepField = (*env)->GetFieldID(env, clazz, "objectToKeep", "Ljava/lang/Object;");
|
||||
objectToKeep = (*env)->GetObjectField(env, thisObject, objectToKeepField);
|
||||
localRef = (*env)->NewLocalRef(env, objectToKeep);
|
||||
(*env)->SetObjectField(env, thisObject, objectToKeepField, NULL);
|
||||
|
||||
objectClazz = (*env)->FindClass(env, "Ljava/lang/Object;");
|
||||
waitMethod = (*env)->GetMethodID(env, objectClazz, "wait", "()V");
|
||||
(*env)->CallVoidMethod(env, syncObject, waitMethod);
|
||||
printf("checkpoint2 \n");
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
194
test/hotspot/jtreg/vmTestbase/gc/g1/unloading/libdefine.cpp
Normal file
194
test/hotspot/jtreg/vmTestbase/gc/g1/unloading/libdefine.cpp
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <jvmti.h>
|
||||
|
||||
#define STATUS_FAILED 2
|
||||
#define STATUS_PASSED 0
|
||||
|
||||
#define REFERENCES_ARRAY_SIZE 10000000
|
||||
|
||||
#ifndef JNI_ENV_ARG
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define JNI_ENV_ARG(x, y) y
|
||||
#define JNI_ENV_PTR(x) x
|
||||
#else
|
||||
#define JNI_ENV_ARG(x, y) x , y
|
||||
#define JNI_ENV_PTR(x) (*x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _Included_gc_g1_unloading_unloading_classloaders_JNIClassloader
|
||||
#define _Included_gc_g1_unloading_unloading_classloaders_JNIClassloader
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_classloaders_JNIClassloader
|
||||
* Method: loadThroughJNI0
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;[B)Ljava/lang/Class;
|
||||
*/
|
||||
JNIEXPORT jclass JNICALL Java_gc_g1_unloading_classloaders_JNIClassloader_loadThroughJNI0 (JNIEnv * env,
|
||||
jclass clazz, jstring className, jobject classLoader, jbyteArray bytecode) {
|
||||
|
||||
const char * classNameChar = JNI_ENV_PTR(env)->GetStringUTFChars(JNI_ENV_ARG(env, className), NULL);
|
||||
jbyte * arrayContent = JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, bytecode), NULL);
|
||||
jsize bytecodeLength = JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, bytecode));
|
||||
jclass returnValue = JNI_ENV_PTR(env)->DefineClass(JNI_ENV_ARG(env, classNameChar), classLoader, arrayContent, bytecodeLength);
|
||||
if (!returnValue) {
|
||||
printf("ERROR: DefineClass call returned NULL by some reason. Classloading failed.\n");
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_loading_ClassLoadingThread
|
||||
* Method: makeRedefinition0
|
||||
* Signature: (ILjava/lang/Class;[B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_gc_g1_unloading_loading_ClassLoadingThread_makeRedefinition0(JNIEnv *env,
|
||||
jclass cls, jint fl, jclass redefCls, jbyteArray classBytes) {
|
||||
JavaVM * jvm;
|
||||
jvmtiEnv * jvmti;
|
||||
jvmtiError err;
|
||||
jvmtiCapabilities caps;
|
||||
jvmtiClassDefinition classDef;
|
||||
jint jint_err = JNI_ENV_PTR(env)->GetJavaVM(JNI_ENV_ARG(env, &jvm));
|
||||
if (jint_err) {
|
||||
printf("GetJavaVM returned nonzero: %d", jint_err);
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
jint_err = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **)&jvmti), JVMTI_VERSION_1_0);
|
||||
if (jint_err) {
|
||||
printf("GetEnv returned nonzero: %d", jint_err);
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
err = JNI_ENV_PTR(jvmti)->GetPotentialCapabilities(JNI_ENV_ARG(jvmti, &caps));
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
printf("(GetPotentialCapabilities) unexpected error: %d\n",err);
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
err = JNI_ENV_PTR(jvmti)->AddCapabilities(JNI_ENV_ARG(jvmti, &caps));
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
printf("(AddCapabilities) unexpected error: %d\n", err);
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!caps.can_redefine_classes) {
|
||||
printf("ERROR: Can't redefine classes. jvmtiCapabilities.can_redefine_classes isn't set up.");
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
classDef.klass = redefCls;
|
||||
classDef.class_byte_count =
|
||||
JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
|
||||
classDef.class_bytes = (unsigned char *)
|
||||
JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes),
|
||||
NULL);
|
||||
|
||||
if (fl == 2) {
|
||||
printf(">>>>>>>> Invoke RedefineClasses():\n");
|
||||
printf("\tnew class byte count=%d\n", classDef.class_byte_count);
|
||||
}
|
||||
err = JNI_ENV_PTR(jvmti)->RedefineClasses(JNI_ENV_ARG(jvmti, 1), &classDef);
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
printf("%s: Failed to call RedefineClasses():\n", __FILE__);
|
||||
printf("\tthe function returned error %d\n", err);
|
||||
printf("\tFor more info about this error see the JVMTI spec.\n");
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
if (fl == 2)
|
||||
printf("<<<<<<<< RedefineClasses() is successfully done\n");
|
||||
|
||||
return STATUS_PASSED;
|
||||
}
|
||||
|
||||
jobject referencesArray[REFERENCES_ARRAY_SIZE];
|
||||
int firstFreeIndex = 0;
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_keepref_JNIGlobalRefHolder
|
||||
* Method: keepGlobalJNIReference
|
||||
* Signature: (Ljava/lang/Object;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_gc_g1_unloading_keepref_JNIGlobalRefHolder_keepGlobalJNIReference
|
||||
(JNIEnv * env, jclass clazz, jobject obj) {
|
||||
int returnValue;
|
||||
referencesArray[firstFreeIndex] = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, obj));
|
||||
printf("checkpoint1 %d \n", firstFreeIndex);
|
||||
returnValue = firstFreeIndex;
|
||||
firstFreeIndex++;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_keepref_JNIGlobalRefHolder
|
||||
* Method: deleteGlobalJNIReference
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_gc_g1_unloading_keepref_JNIGlobalRefHolder_deleteGlobalJNIReference
|
||||
(JNIEnv * env, jclass clazz, jint index) {
|
||||
JNI_ENV_PTR(env)->DeleteGlobalRef(JNI_ENV_ARG(env, referencesArray[index]));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: gc_g1_unloading_unloading_keepref_JNILocalRefHolder
|
||||
* Method: holdWithJNILocalReference
|
||||
* Signature: (Ljava/lang/Object;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_gc_g1_unloading_keepref_JNILocalRefHolder_holdWithJNILocalReference
|
||||
(JNIEnv * env, jobject thisObject, jobject syncObject) {
|
||||
jclass clazz, objectClazz;
|
||||
jfieldID objectToKeepField;
|
||||
jobject objectToKeep, localRef;
|
||||
jmethodID waitMethod;
|
||||
|
||||
clazz = env->GetObjectClass(thisObject);
|
||||
objectToKeepField = env->GetFieldID(clazz, "objectToKeep", "Ljava/lang/Object;");
|
||||
objectToKeep = env->GetObjectField(thisObject, objectToKeepField);
|
||||
localRef = env->NewLocalRef(objectToKeep);
|
||||
env->SetObjectField(thisObject, objectToKeepField, NULL);
|
||||
|
||||
objectClazz = env->FindClass("Ljava/lang/Object;");
|
||||
waitMethod = env->GetMethodID(objectClazz, "wait", "()V");
|
||||
env->CallVoidMethod(syncObject, waitMethod);
|
||||
printf("checkpoint2 \n");
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
JNIEXPORT void JNICALL Java_gc_gctests_mallocWithGC1_mallocWithGC1_getMallocLock01
|
||||
(JNIEnv *env, jobject obj) {
|
||||
char *c_ptr;
|
||||
time_t current_time, old_time;
|
||||
|
||||
old_time = time(NULL);
|
||||
current_time = 0;
|
||||
|
||||
while (current_time - old_time < 180) {
|
||||
c_ptr = (char *) malloc(1);
|
||||
free(c_ptr);
|
||||
current_time = time(NULL);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL Java_gc_gctests_mallocWithGC1_mallocWithGC1_getMallocLock01
|
||||
(JNIEnv *env, jobject obj) {
|
||||
char *c_ptr;
|
||||
time_t current_time, old_time;
|
||||
|
||||
old_time = time(NULL);
|
||||
current_time = 0;
|
||||
|
||||
while (current_time - old_time < 180) {
|
||||
c_ptr = (char *) malloc(1);
|
||||
free(c_ptr);
|
||||
current_time = time(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
JNIEXPORT void JNICALL Java_gc_gctests_mallocWithGC2_mallocWithGC2_getMallocLock02
|
||||
(JNIEnv *env, jobject obj) {
|
||||
char *c_ptr;
|
||||
time_t current_time, old_time;
|
||||
|
||||
old_time = time(NULL);
|
||||
current_time = 0;
|
||||
|
||||
while (current_time - old_time < 180) {
|
||||
c_ptr = (char *) malloc(1);
|
||||
free(c_ptr);
|
||||
current_time = time(NULL);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL Java_gc_gctests_mallocWithGC2_mallocWithGC2_getMallocLock02
|
||||
(JNIEnv *env, jobject obj) {
|
||||
char *c_ptr;
|
||||
time_t current_time, old_time;
|
||||
|
||||
old_time = time(NULL);
|
||||
current_time = 0;
|
||||
|
||||
while (current_time - old_time < 180) {
|
||||
c_ptr = (char *) malloc(1);
|
||||
free(c_ptr);
|
||||
current_time = time(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_gc_gctests_mallocWithGC3_mallocWithGC3_getMallocLock03
|
||||
(JNIEnv *env, jobject obj) {
|
||||
char *c_ptr;
|
||||
time_t current_time, old_time;
|
||||
|
||||
old_time = time(NULL);
|
||||
current_time = 0;
|
||||
|
||||
while (current_time - old_time < 180) {
|
||||
c_ptr = (char *) malloc(1);
|
||||
free(c_ptr);
|
||||
current_time = time(NULL);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_gc_gctests_mallocWithGC3_mallocWithGC3_getMallocLock03
|
||||
(JNIEnv *env, jobject obj) {
|
||||
char *c_ptr;
|
||||
time_t current_time, old_time;
|
||||
|
||||
old_time = time(NULL);
|
||||
current_time = 0;
|
||||
|
||||
while (current_time - old_time < 180) {
|
||||
c_ptr = (char *) malloc(1);
|
||||
free(c_ptr);
|
||||
current_time = time(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
/*
|
||||
* A C function that takes a reference to java Object( a circular Linked list)
|
||||
* and utilizes this reference to do a java method callback to determine the
|
||||
* number of elements in the linked list
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_gc_gctests_nativeGC01_nativeGC01_nativeMethod01
|
||||
(JNIEnv *env, jobject obj, jobject linked_list) {
|
||||
jclass cls, clss;
|
||||
jmethodID mid, mid2;
|
||||
int elementCount;
|
||||
|
||||
/* Before doing anything force a GC by
|
||||
invoking a callback where System.gc() is called
|
||||
*/
|
||||
cls = (*env)->GetObjectClass(env, obj);
|
||||
mid = (*env)->GetMethodID(env, cls, "callbackGC", "()V");
|
||||
if (mid == 0) {
|
||||
printf("couldnt locate method callbackGC()");
|
||||
return -1;
|
||||
}
|
||||
(*env)->CallVoidMethod(env,obj,mid);
|
||||
|
||||
/* Now that a GC has been done, invoke the callback
|
||||
that counts the number of elements in the
|
||||
circular linked list
|
||||
*/
|
||||
|
||||
clss = (*env)->GetObjectClass(env, linked_list);
|
||||
mid2 = (*env)->GetMethodID(env, clss, "getLength", "()I" );
|
||||
if (mid2 == 0) {
|
||||
printf("couldnt locate method getLength()");
|
||||
return -1;
|
||||
}
|
||||
elementCount = (*env)->CallIntMethod(env, linked_list, mid2);
|
||||
return elementCount;
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A C function that takes a reference to java Object( a circular Linked list)
|
||||
* and utilizes this reference to do a java method callback to determine the
|
||||
* number of elements in the linked list
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_gc_gctests_nativeGC01_nativeGC01_nativeMethod01
|
||||
(JNIEnv *env, jobject obj, jobject linked_list) {
|
||||
jclass cls, clss;
|
||||
jmethodID mid, mid2;
|
||||
int elementCount;
|
||||
|
||||
/* Before doing anything force a GC by
|
||||
invoking a callback where System.gc() is called
|
||||
*/
|
||||
cls = env->GetObjectClass(obj);
|
||||
mid = env->GetMethodID(cls, "callbackGC", "()V");
|
||||
if (mid == 0) {
|
||||
printf("couldnt locate method callbackGC()");
|
||||
return -1;
|
||||
}
|
||||
env->CallVoidMethod(obj,mid);
|
||||
|
||||
/* Now that a GC has been done, invoke the callback
|
||||
that counts the number of elements in the
|
||||
circular linked list
|
||||
*/
|
||||
|
||||
clss = env->GetObjectClass(linked_list);
|
||||
mid2 = env->GetMethodID(clss, "getLength", "()I" );
|
||||
if (mid2 == 0) {
|
||||
printf("couldnt locate method getLength()");
|
||||
return -1;
|
||||
}
|
||||
elementCount = env->CallIntMethod(linked_list, mid2);
|
||||
return elementCount;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* A C function that takes a reference to java Object( a circular Linked list)
|
||||
and utilizes this reference to do a java method callback to determine the
|
||||
number of elements in the linked list */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_gc_gctests_nativeGC02_nativeGC02_nativeMethod02
|
||||
(JNIEnv *env, jobject obj, jobject linked_list) {
|
||||
jclass cls, clss;
|
||||
jmethodID mid, mid2;
|
||||
jfieldID fid;
|
||||
jobject llist;
|
||||
int elementCount;
|
||||
|
||||
/* Store a reference to the linked list in the C stack */
|
||||
|
||||
clss = (*env)->GetObjectClass(env, obj);
|
||||
fid = (*env)->GetFieldID(env, clss, "cl", "Lnsk/share/gc/CircularLinkedList;");
|
||||
if (fid == 0) {
|
||||
printf("could not locate field - cl\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
llist = (*env)->GetObjectField(env, obj, fid);
|
||||
|
||||
/* force a GC by invoking a callback where System.gc() is called
|
||||
*/
|
||||
|
||||
cls = (*env)->GetObjectClass(env, obj);
|
||||
mid = (*env)->GetMethodID(env, cls, "callbackGC", "()V");
|
||||
if (mid == 0){
|
||||
printf("couldnt locate method callbackGC()\n");
|
||||
return -1;
|
||||
}
|
||||
(*env)->CallVoidMethod(env,obj,mid);
|
||||
|
||||
/* Now that a GC has been done, invoke the callback
|
||||
that counts the number of elements in the
|
||||
circular linked list
|
||||
*/
|
||||
|
||||
clss = (*env)->GetObjectClass(env, linked_list);
|
||||
mid2 = (*env)->GetMethodID(env, clss, "getLength", "(Lnsk/share/gc/CircularLinkedList;)I" );
|
||||
if (mid2 == 0 ){
|
||||
printf("couldnt locate method getLength(CircularLinkedList)\n");
|
||||
return -1;
|
||||
}
|
||||
elementCount = (*env)->CallIntMethod(env, linked_list, mid2, llist);
|
||||
return elementCount;
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* A C function that takes a reference to java Object( a circular Linked list)
|
||||
and utilizes this reference to do a java method callback to determine the
|
||||
number of elements in the linked list */
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_gc_gctests_nativeGC02_nativeGC02_nativeMethod02
|
||||
(JNIEnv *env, jobject obj, jobject linked_list) {
|
||||
jclass cls, clss;
|
||||
jmethodID mid, mid2;
|
||||
jfieldID fid;
|
||||
jobject llist;
|
||||
int elementCount;
|
||||
|
||||
/* Store a reference to the linked list in the C stack */
|
||||
|
||||
clss = env->GetObjectClass(obj);
|
||||
fid = env->GetFieldID(clss, "cl", "Lnsk/share/gc/CircularLinkedList;");
|
||||
if (fid == 0) {
|
||||
printf("could not locate field - cl\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
llist = env->GetObjectField(obj, fid);
|
||||
|
||||
/* force a GC by invoking a callback where System.gc() is called
|
||||
*/
|
||||
|
||||
cls = env->GetObjectClass(obj);
|
||||
mid = env->GetMethodID(cls, "callbackGC", "()V");
|
||||
if (mid == 0){
|
||||
printf("couldnt locate method callbackGC()\n");
|
||||
return -1;
|
||||
}
|
||||
env->CallVoidMethod(obj,mid);
|
||||
|
||||
/* Now that a GC has been done, invoke the callback
|
||||
that counts the number of elements in the
|
||||
circular linked list
|
||||
*/
|
||||
|
||||
clss = env->GetObjectClass(linked_list);
|
||||
mid2 = env->GetMethodID(clss, "getLength", "(Lnsk/share/gc/CircularLinkedList;)I" );
|
||||
if (mid2 == 0 ){
|
||||
printf("couldnt locate method getLength(CircularLinkedList)\n");
|
||||
return -1;
|
||||
}
|
||||
elementCount = env->CallIntMethod(linked_list, mid2, llist);
|
||||
return elementCount;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_gc_gctests_nativeGC03_nativeGC03_nativeMethod03
|
||||
(JNIEnv *env, jobject obj, jobjectArray listHolder) {
|
||||
jsize len;
|
||||
int i, count;
|
||||
jmethodID mid;
|
||||
jclass clss;
|
||||
|
||||
len = (*env)->GetArrayLength(env, listHolder);
|
||||
i = 0;
|
||||
count = 0;
|
||||
/*Trash all the linked lists */
|
||||
while (count < 10) {
|
||||
while (i < len) {
|
||||
(*env)->SetObjectArrayElement(env, listHolder, i, NULL);
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Invoke a callback that will refill the array */
|
||||
|
||||
clss = (*env)->GetObjectClass(env, obj);
|
||||
mid = (*env)->GetMethodID(env, clss, "fillArray", "()V");
|
||||
if (mid == 0) {
|
||||
return;
|
||||
}
|
||||
(*env)->CallVoidMethod(env, obj, mid);
|
||||
count++;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_gc_gctests_nativeGC03_nativeGC03_nativeMethod03
|
||||
(JNIEnv *env, jobject obj, jobjectArray listHolder) {
|
||||
jsize len;
|
||||
int i, count;
|
||||
jmethodID mid;
|
||||
jclass clss;
|
||||
|
||||
len = env->GetArrayLength(listHolder);
|
||||
i = 0;
|
||||
count = 0;
|
||||
/*Trash all the linked lists */
|
||||
while (count < 10) {
|
||||
while (i < len) {
|
||||
env->SetObjectArrayElement(listHolder, i, NULL);
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Invoke a callback that will refill the array */
|
||||
|
||||
clss = env->GetObjectClass(obj);
|
||||
mid = env->GetMethodID(clss, "fillArray", "()V");
|
||||
if (mid == 0) {
|
||||
return;
|
||||
}
|
||||
env->CallVoidMethod(obj, mid);
|
||||
count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_gc_gctests_nativeGC05_nativeGC05_kickOffRefillers
|
||||
(JNIEnv *env, jobject obj, jobject matrix, jobject stack) {
|
||||
jclass matrixClass, stackClass, pairClass = 0;
|
||||
jmethodID stack_pop_mid, stack_empty_mid, matrix_repopulate_mid, pair_geti_mid = 0, pair_getj_mid = 0;
|
||||
jobject pair;
|
||||
jint i, j;
|
||||
jboolean b;
|
||||
|
||||
/* Get class objects associated with the objects passed in */
|
||||
matrixClass = (*env)->GetObjectClass(env, matrix);
|
||||
stackClass = (*env)->GetObjectClass(env, stack);
|
||||
|
||||
/* GetMethodID's for the pop() and Repopulate() methods */
|
||||
stack_pop_mid = (*env)->GetMethodID(env, stackClass, "pop", "()Ljava/lang/Object;");
|
||||
if (stack_pop_mid == 0) {
|
||||
printf("could not get a methodID for Stack::pop()\n");
|
||||
return;
|
||||
}
|
||||
stack_empty_mid = (*env)->GetMethodID(env, stackClass, "empty", "()Z");
|
||||
if (stack_empty_mid == 0) {
|
||||
printf("could not get a methodID for Stack::empty()\n");
|
||||
return;
|
||||
}
|
||||
|
||||
matrix_repopulate_mid = (*env)->GetMethodID(env, matrixClass, "repopulate", "(II)V");
|
||||
if (matrix_repopulate_mid == 0) {
|
||||
printf("could not get a methodID for Matrix::repopulate(int, int)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/** b = stack.empty(); */
|
||||
b = (*env)->CallBooleanMethod(env, stack, stack_empty_mid);
|
||||
while (b == JNI_FALSE) {
|
||||
/** pair = stack.pop() */
|
||||
pair = (*env)->CallObjectMethod(env, stack, stack_pop_mid);
|
||||
|
||||
if (pairClass == 0) {
|
||||
pairClass = (*env)->GetObjectClass(env, pair);
|
||||
pair_geti_mid = (*env)->GetMethodID(env, pairClass, "getI", "()I");
|
||||
if (pair_geti_mid == 0) {
|
||||
printf("could not get a methodID for IndexPair::getI()\n");
|
||||
return;
|
||||
}
|
||||
pair_getj_mid = (*env)->GetMethodID(env, pairClass, "getJ", "()I");
|
||||
if (pair_getj_mid == 0) {
|
||||
printf("could not get a methodID for IndexPair::getJ()\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/** i = pair.getI(); */
|
||||
i = (*env)->CallIntMethod(env, pair, pair_geti_mid);
|
||||
/** j = pair.getJ(); */
|
||||
j = (*env)->CallIntMethod(env, pair, pair_getj_mid);
|
||||
|
||||
/* matrix.repopulate(i, j); */
|
||||
(*env)->CallVoidMethod(env, matrix, matrix_repopulate_mid, i, j);
|
||||
|
||||
/** b = stack.empty(); */
|
||||
b = (*env)->CallBooleanMethod(env, stack, stack_empty_mid);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_gc_gctests_nativeGC05_nativeGC05_kickOffRefillers
|
||||
(JNIEnv *env, jobject obj, jobject matrix, jobject stack) {
|
||||
jclass matrixClass, stackClass, pairClass = 0;
|
||||
jmethodID stack_pop_mid, stack_empty_mid, matrix_repopulate_mid, pair_geti_mid = 0, pair_getj_mid = 0;
|
||||
jobject pair;
|
||||
jint i, j;
|
||||
jboolean b;
|
||||
|
||||
/* Get class objects associated with the objects passed in */
|
||||
matrixClass = env->GetObjectClass(matrix);
|
||||
stackClass = env->GetObjectClass(stack);
|
||||
|
||||
/* GetMethodID's for the pop() and Repopulate() methods */
|
||||
stack_pop_mid = env->GetMethodID(stackClass, "pop", "()Ljava/lang/Object;");
|
||||
if (stack_pop_mid == 0) {
|
||||
printf("could not get a methodID for Stack::pop()\n");
|
||||
return;
|
||||
}
|
||||
stack_empty_mid = env->GetMethodID(stackClass, "empty", "()Z");
|
||||
if (stack_empty_mid == 0) {
|
||||
printf("could not get a methodID for Stack::empty()\n");
|
||||
return;
|
||||
}
|
||||
|
||||
matrix_repopulate_mid = env->GetMethodID(matrixClass, "repopulate", "(II)V");
|
||||
if (matrix_repopulate_mid == 0) {
|
||||
printf("could not get a methodID for Matrix::repopulate(int, int)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/** b = stack.empty(); */
|
||||
b = env->CallBooleanMethod(stack, stack_empty_mid);
|
||||
while (b == JNI_FALSE) {
|
||||
/** pair = stack.pop() */
|
||||
pair = env->CallObjectMethod(stack, stack_pop_mid);
|
||||
|
||||
if (pairClass == 0) {
|
||||
pairClass = env->GetObjectClass(pair);
|
||||
pair_geti_mid = env->GetMethodID(pairClass, "getI", "()I");
|
||||
if (pair_geti_mid == 0) {
|
||||
printf("could not get a methodID for IndexPair::getI()\n");
|
||||
return;
|
||||
}
|
||||
pair_getj_mid = env->GetMethodID(pairClass, "getJ", "()I");
|
||||
if (pair_getj_mid == 0) {
|
||||
printf("could not get a methodID for IndexPair::getJ()\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/** i = pair.getI(); */
|
||||
i = env->CallIntMethod(pair, pair_geti_mid);
|
||||
/** j = pair.getJ(); */
|
||||
j = env->CallIntMethod(pair, pair_getj_mid);
|
||||
|
||||
/* matrix.repopulate(i, j); */
|
||||
env->CallVoidMethod(matrix, matrix_repopulate_mid, i, j);
|
||||
|
||||
/** b = stack.empty(); */
|
||||
b = env->CallBooleanMethod(stack, stack_empty_mid);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.c"
|
||||
#include "jni_tools.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "agent00.c"
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "agent00.cpp"
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.c"
|
||||
#include "jni_tools.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "agent01.c"
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "agent01.cpp"
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.c"
|
||||
#include "jni_tools.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "agent02.c"
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "agent02.cpp"
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.c"
|
||||
#include "jni_tools.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "agent03.c"
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "agent03.cpp"
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.c"
|
||||
#include "jni_tools.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "agent00.c"
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "aod.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "agent00.cpp"
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "jni.h"
|
||||
#include "nsk_tools.c"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef JNI_ENV_PTR
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define JNI_ENV_ARG_2(x, y) y
|
||||
#define JNI_ENV_ARG_3(x,y,z) y, z
|
||||
#define JNI_ENV_PTR(x) x
|
||||
#else
|
||||
#define JNI_ENV_ARG_2(x,y) x, y
|
||||
#define JNI_ENV_ARG_3(x,y,z) x, y, z
|
||||
#define JNI_ENV_PTR(x) (*x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_nsk_jdi_ThreadReference_forceEarlyReturn_forceEarlyReturn005_forceEarlyReturn005a_nativeJNIMonitorEnter(JNIEnv *env, jobject classObject, jobject object)
|
||||
{
|
||||
jint success = JNI_ENV_PTR(env)->MonitorEnter(JNI_ENV_ARG_2(env, object));
|
||||
|
||||
if(success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
|
||||
|
||||
JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorEnter return non-zero"));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "jni.h"
|
||||
#include "nsk_tools.cpp"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef JNI_ENV_PTR
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define JNI_ENV_ARG_2(x, y) y
|
||||
#define JNI_ENV_ARG_3(x,y,z) y, z
|
||||
#define JNI_ENV_PTR(x) x
|
||||
#else
|
||||
#define JNI_ENV_ARG_2(x,y) x, y
|
||||
#define JNI_ENV_ARG_3(x,y,z) x, y, z
|
||||
#define JNI_ENV_PTR(x) (*x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_nsk_jdi_ThreadReference_forceEarlyReturn_forceEarlyReturn005_forceEarlyReturn005a_nativeJNIMonitorEnter(JNIEnv *env, jobject classObject, jobject object)
|
||||
{
|
||||
jint success = JNI_ENV_PTR(env)->MonitorEnter(JNI_ENV_ARG_2(env, object));
|
||||
|
||||
if(success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
|
||||
|
||||
JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorEnter return non-zero"));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "agent_common.c"
|
||||
#include "addcaps001.c"
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "agent_common.cpp"
|
||||
#include "addcaps001.cpp"
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "agent_common.c"
|
||||
#include "addcaps002.c"
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "agent_common.cpp"
|
||||
#include "addcaps002.cpp"
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "agent_common.c"
|
||||
#include "addcaps003.c"
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "agent_common.cpp"
|
||||
#include "addcaps003.cpp"
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "agent_common.c"
|
||||
#include "agentonload001.c"
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "agent_common.cpp"
|
||||
#include "agentonload001.cpp"
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "agent_common.c"
|
||||
#include "agentonload002.c"
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "agent_common.cpp"
|
||||
#include "agentonload002.cpp"
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "agent_common.c"
|
||||
#include "agentonload003.c"
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "agent_common.cpp"
|
||||
#include "agentonload003.cpp"
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "agent_common.c"
|
||||
#include "agentonunload001.c"
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "agent_common.cpp"
|
||||
#include "agentonunload001.cpp"
|
@ -1,190 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "jvmti.h"
|
||||
#include "agent_common.h"
|
||||
#include "JVMTITools.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef JNI_ENV_ARG
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define JNI_ENV_ARG(x, y) y
|
||||
#define JNI_ENV_PTR(x) x
|
||||
#else
|
||||
#define JNI_ENV_ARG(x,y) x, y
|
||||
#define JNI_ENV_PTR(x) (*x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define PASSED 0
|
||||
#define STATUS_FAILED 2
|
||||
#define FAILED_NO_OOM 3
|
||||
#define MAX_CHUNK 1024*1024
|
||||
|
||||
// Limit total allocations to 8Gb.
|
||||
// Without this check we will loop forever if the OS does not
|
||||
// limit virtual memory (this usually happens on mac).
|
||||
#define MAX_CHUNK_COUNT 8*1024
|
||||
|
||||
static jvmtiEnv *jvmti = NULL;
|
||||
static jint result = PASSED;
|
||||
static jboolean printdump = JNI_FALSE;
|
||||
|
||||
#ifdef STATIC_BUILD
|
||||
JNIEXPORT jint JNICALL Agent_OnLoad_alloc001(JavaVM *jvm, char *options, void *reserved) {
|
||||
return Agent_Initialize(jvm, options, reserved);
|
||||
}
|
||||
JNIEXPORT jint JNICALL Agent_OnAttach_alloc001(JavaVM *jvm, char *options, void *reserved) {
|
||||
return Agent_Initialize(jvm, options, reserved);
|
||||
}
|
||||
JNIEXPORT jint JNI_OnLoad_alloc001(JavaVM *jvm, char *options, void *reserved) {
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
|
||||
jint res;
|
||||
|
||||
if (options != NULL && strcmp(options, "printdump") == 0) {
|
||||
printdump = JNI_TRUE;
|
||||
}
|
||||
|
||||
res = JNI_ENV_PTR(jvm)->
|
||||
GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
|
||||
if (res != JNI_OK || jvmti == NULL) {
|
||||
printf("Wrong result of a valid call to GetEnv!\n");
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_nsk_jvmti_Allocate_alloc001_check(JNIEnv *env, jclass cls) {
|
||||
jvmtiError err;
|
||||
size_t size;
|
||||
void *prev = NULL;
|
||||
void **mem;
|
||||
int memCount = 1;
|
||||
|
||||
if (jvmti == NULL) {
|
||||
printf("JVMTI client was not properly loaded!\n");
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> Null pointer check ...\n");
|
||||
}
|
||||
err = (*jvmti)->Allocate(jvmti, (jlong)1, NULL);
|
||||
if (err != JVMTI_ERROR_NULL_POINTER) {
|
||||
printf("Error expected: JVMTI_ERROR_NULL_POINTER, got: %s\n",
|
||||
TranslateError(err));
|
||||
result = STATUS_FAILED;
|
||||
}
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> ... done\n");
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> Accessibility check ...\n");
|
||||
}
|
||||
for (size = sizeof(mem); size <= MAX_CHUNK; size <<= 1) {
|
||||
err = (*jvmti)->Allocate(jvmti, size, (unsigned char **)&mem);
|
||||
if (err == JVMTI_ERROR_NONE) {
|
||||
memset(mem, 0, size);
|
||||
*mem = prev;
|
||||
prev = mem;
|
||||
} else if (err == JVMTI_ERROR_OUT_OF_MEMORY) {
|
||||
break;
|
||||
} else {
|
||||
printf("(Allocate) Error expected: JVMTI_ERROR_NONE, got: %s\n",
|
||||
TranslateError(err));
|
||||
result = STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> ... done\n");
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> Out of memory check ...\n");
|
||||
}
|
||||
while (err != JVMTI_ERROR_OUT_OF_MEMORY) {
|
||||
err = (*jvmti)->Allocate(jvmti, (jlong)MAX_CHUNK, (unsigned char **)&mem);
|
||||
if (err == JVMTI_ERROR_NONE) {
|
||||
*mem = prev;
|
||||
prev = mem;
|
||||
memCount++;
|
||||
if (memCount > MAX_CHUNK_COUNT) {
|
||||
printf("Allocated %dMb. Virtual memory limit too high. Quit to avoid timeout.\n", memCount);
|
||||
result = FAILED_NO_OOM;
|
||||
break;
|
||||
}
|
||||
} else if (err == JVMTI_ERROR_OUT_OF_MEMORY) {
|
||||
break;
|
||||
} else {
|
||||
printf("Error expected: JVMTI_ERROR_OUT_OF_MEMORY, got: %s\n",
|
||||
TranslateError(err));
|
||||
result = STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE && (memCount % 50 == 0) ) {
|
||||
printf(">>> ... done (%dMb)\n", memCount);
|
||||
}
|
||||
}
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> ... done (%dMb)\n", memCount);
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> Deallocation ...\n");
|
||||
}
|
||||
while (prev != NULL) {
|
||||
mem = prev;
|
||||
prev = *mem;
|
||||
err = (*jvmti)->Deallocate(jvmti, (unsigned char *)mem);
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
printf("(Deallocate) Error expected: JVMTI_ERROR_NONE, got: %s\n",
|
||||
TranslateError(err));
|
||||
result = STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> ... done\n");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "jvmti.h"
|
||||
#include "agent_common.h"
|
||||
#include "JVMTITools.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef JNI_ENV_ARG
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define JNI_ENV_ARG(x, y) y
|
||||
#define JNI_ENV_PTR(x) x
|
||||
#else
|
||||
#define JNI_ENV_ARG(x,y) x, y
|
||||
#define JNI_ENV_PTR(x) (*x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define PASSED 0
|
||||
#define STATUS_FAILED 2
|
||||
#define FAILED_NO_OOM 3
|
||||
#define MAX_CHUNK 1024*1024
|
||||
|
||||
// Limit total allocations to 8Gb.
|
||||
// Without this check we will loop forever if the OS does not
|
||||
// limit virtual memory (this usually happens on mac).
|
||||
#define MAX_CHUNK_COUNT 8*1024
|
||||
|
||||
static jvmtiEnv *jvmti = NULL;
|
||||
static jint result = PASSED;
|
||||
static jboolean printdump = JNI_FALSE;
|
||||
|
||||
#ifdef STATIC_BUILD
|
||||
JNIEXPORT jint JNICALL Agent_OnLoad_alloc001(JavaVM *jvm, char *options, void *reserved) {
|
||||
return Agent_Initialize(jvm, options, reserved);
|
||||
}
|
||||
JNIEXPORT jint JNICALL Agent_OnAttach_alloc001(JavaVM *jvm, char *options, void *reserved) {
|
||||
return Agent_Initialize(jvm, options, reserved);
|
||||
}
|
||||
JNIEXPORT jint JNI_OnLoad_alloc001(JavaVM *jvm, char *options, void *reserved) {
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
|
||||
jint res;
|
||||
|
||||
if (options != NULL && strcmp(options, "printdump") == 0) {
|
||||
printdump = JNI_TRUE;
|
||||
}
|
||||
|
||||
res = JNI_ENV_PTR(jvm)->
|
||||
GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
|
||||
if (res != JNI_OK || jvmti == NULL) {
|
||||
printf("Wrong result of a valid call to GetEnv!\n");
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_nsk_jvmti_Allocate_alloc001_check(JNIEnv *env, jclass cls) {
|
||||
jvmtiError err;
|
||||
size_t size;
|
||||
void *prev = NULL;
|
||||
void **mem;
|
||||
int memCount = 1;
|
||||
|
||||
if (jvmti == NULL) {
|
||||
printf("JVMTI client was not properly loaded!\n");
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> Null pointer check ...\n");
|
||||
}
|
||||
err = jvmti->Allocate((jlong)1, NULL);
|
||||
if (err != JVMTI_ERROR_NULL_POINTER) {
|
||||
printf("Error expected: JVMTI_ERROR_NULL_POINTER, got: %s\n",
|
||||
TranslateError(err));
|
||||
result = STATUS_FAILED;
|
||||
}
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> ... done\n");
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> Accessibility check ...\n");
|
||||
}
|
||||
for (size = sizeof(mem); size <= MAX_CHUNK; size <<= 1) {
|
||||
err = jvmti->Allocate(size, (unsigned char **)&mem);
|
||||
if (err == JVMTI_ERROR_NONE) {
|
||||
memset(mem, 0, size);
|
||||
*mem = prev;
|
||||
prev = mem;
|
||||
} else if (err == JVMTI_ERROR_OUT_OF_MEMORY) {
|
||||
break;
|
||||
} else {
|
||||
printf("(Allocate) Error expected: JVMTI_ERROR_NONE, got: %s\n",
|
||||
TranslateError(err));
|
||||
result = STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> ... done\n");
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> Out of memory check ...\n");
|
||||
}
|
||||
while (err != JVMTI_ERROR_OUT_OF_MEMORY) {
|
||||
err = jvmti->Allocate((jlong)MAX_CHUNK, (unsigned char **)&mem);
|
||||
if (err == JVMTI_ERROR_NONE) {
|
||||
*mem = prev;
|
||||
prev = mem;
|
||||
memCount++;
|
||||
if (memCount > MAX_CHUNK_COUNT) {
|
||||
printf("Allocated %dMb. Virtual memory limit too high. Quit to avoid timeout.\n", memCount);
|
||||
result = FAILED_NO_OOM;
|
||||
break;
|
||||
}
|
||||
} else if (err == JVMTI_ERROR_OUT_OF_MEMORY) {
|
||||
break;
|
||||
} else {
|
||||
printf("Error expected: JVMTI_ERROR_OUT_OF_MEMORY, got: %s\n",
|
||||
TranslateError(err));
|
||||
result = STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE && (memCount % 50 == 0) ) {
|
||||
printf(">>> ... done (%dMb)\n", memCount);
|
||||
}
|
||||
}
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> ... done (%dMb)\n", memCount);
|
||||
}
|
||||
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> Deallocation ...\n");
|
||||
}
|
||||
while (prev != NULL) {
|
||||
mem = (void**) prev;
|
||||
prev = *mem;
|
||||
err = jvmti->Deallocate((unsigned char *)mem);
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
printf("(Deallocate) Error expected: JVMTI_ERROR_NONE, got: %s\n",
|
||||
TranslateError(err));
|
||||
result = STATUS_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (printdump == JNI_TRUE) {
|
||||
printf(">>> ... done\n");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "agent_common.c"
|
||||
#include "alloc001.c"
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "agent_common.cpp"
|
||||
#include "alloc001.cpp"
|
@ -1,246 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
#include <jvmti.h>
|
||||
#include <aod.h>
|
||||
#include <jvmti_aod.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Expected agent work scenario:
|
||||
* - receive ClassFileLoadHook event for class 'ClassToRedefine'
|
||||
* - receive ClassLoad event for class 'ClassToRedefine' and redefine class from ClassLoad event handler
|
||||
* - receive one more ClassFileLoadHook event for class 'ClassToRedefine'
|
||||
* - receive ClassPrepare event for class 'ClassToRedefine' and finish work
|
||||
*/
|
||||
|
||||
#define REDEFINED_CLASS_NAME "Lnsk/jvmti/AttachOnDemand/attach002/ClassToRedefine;"
|
||||
#define REDEFINED_CLASS_FILE_NAME "nsk/jvmti/AttachOnDemand/attach002/ClassToRedefine"
|
||||
|
||||
// class name in the ClassFileLoadHook callback
|
||||
#define REDEFINED_CLASS_NAME_INTERNAL "nsk/jvmti/AttachOnDemand/attach002/ClassToRedefine"
|
||||
|
||||
static Options* options = NULL;
|
||||
static const char* agentName;
|
||||
|
||||
static volatile jboolean agentGotCapabilities = JNI_FALSE;
|
||||
|
||||
static jvmtiEvent testEvents[] = {
|
||||
JVMTI_EVENT_CLASS_LOAD,
|
||||
JVMTI_EVENT_CLASS_PREPARE,
|
||||
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK};
|
||||
|
||||
static const int testEventsNumber = 3;
|
||||
|
||||
static volatile int classLoadReceived = 0;
|
||||
static volatile int classFileLoadHookReceived = 0;
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities(JNIEnv * jni,
|
||||
jclass klass, jobject obj) {
|
||||
return agentGotCapabilities;
|
||||
}
|
||||
|
||||
#define ATTACH002_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach002/attach002Target"
|
||||
|
||||
int registerNativeMethods(JNIEnv* jni) {
|
||||
jclass appClass;
|
||||
JNINativeMethod nativeMethods[] = {
|
||||
{"agentGotCapabilities", "()Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities}};
|
||||
jint nativeMethodsNumber = 1;
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni, (appClass =
|
||||
NSK_CPP_STUB2(FindClass, jni, ATTACH002_TARGET_APP_CLASS_NAME)) != NULL)) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(NSK_CPP_STUB4(RegisterNatives, jni, appClass, nativeMethods, nativeMethodsNumber) == 0))) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
return NSK_TRUE;
|
||||
}
|
||||
|
||||
void JNICALL classLoadHandler(
|
||||
jvmtiEnv *jvmti,
|
||||
JNIEnv* jni,
|
||||
jthread thread,
|
||||
jclass klass) {
|
||||
char className[MAX_STRING_LENGTH];
|
||||
|
||||
if (!nsk_jvmti_aod_getClassName(jvmti, klass, className)) {
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("%s: ClassLoad event was received for class '%s'\n", agentName, className);
|
||||
|
||||
if (!strcmp(className, REDEFINED_CLASS_NAME)) {
|
||||
|
||||
classLoadReceived = 1;
|
||||
|
||||
NSK_DISPLAY1("%s: redefining class\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_jvmti_aod_redefineClass(options, jvmti, klass, REDEFINED_CLASS_FILE_NAME))) {
|
||||
NSK_COMPLAIN1("%s: failed to redefine class\n", agentName);
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JNICALL classPrepareHandler(
|
||||
jvmtiEnv *jvmti,
|
||||
JNIEnv* jni,
|
||||
jthread thread,
|
||||
jclass klass) {
|
||||
char className[MAX_STRING_LENGTH];
|
||||
|
||||
if (!nsk_jvmti_aod_getClassName(jvmti, klass, className)) {
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("%s: ClassPrepare event received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
|
||||
|
||||
if (!strcmp(className, REDEFINED_CLASS_NAME)) {
|
||||
int success = 1;
|
||||
|
||||
if (!classLoadReceived) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("%s: expected ClassLoad event wasn't received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
* ClassFileLoadHook event should be received twice - when class is loaded and when class is redefined
|
||||
*/
|
||||
if (classFileLoadHookReceived != 2) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("%s: expected ClassFileLoadHook event wasn't received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
|
||||
}
|
||||
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, success, jvmti, jni);
|
||||
}
|
||||
}
|
||||
|
||||
void JNICALL classFileLoadHoockHandler(
|
||||
jvmtiEnv * jvmti,
|
||||
JNIEnv * jni,
|
||||
jclass class_beeing_redefined,
|
||||
jobject loader,
|
||||
const char * name,
|
||||
jobject protection_domain,
|
||||
jint class_data_len,
|
||||
const unsigned char * class_data,
|
||||
jint * new_class_data_len,
|
||||
unsigned char** new_class_data) {
|
||||
|
||||
if (name != NULL) {
|
||||
NSK_DISPLAY2("%s: ClassFileLoadHook event received for class '%s'\n", agentName, name);
|
||||
if (!strcmp(name, REDEFINED_CLASS_NAME_INTERNAL)) {
|
||||
classFileLoadHookReceived++;
|
||||
}
|
||||
} else {
|
||||
NSK_DISPLAY1("%s: ClassFileLoadHook event received for class with NULL name\n", agentName);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef STATIC_BUILD
|
||||
JNIEXPORT jint JNI_OnLoad_attach002Agent00(JavaVM *jvm, char *options, void *reserved) {
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
#ifdef STATIC_BUILD
|
||||
Agent_OnAttach_attach002Agent00(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#else
|
||||
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#endif
|
||||
{
|
||||
jvmtiEventCallbacks eventCallbacks;
|
||||
jvmtiCapabilities caps;
|
||||
jvmtiEnv* jvmti = NULL;
|
||||
JNIEnv* jni = NULL;
|
||||
|
||||
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
|
||||
|
||||
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
|
||||
return NSK_FALSE;
|
||||
|
||||
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY(registerNativeMethods(jni))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
caps.can_generate_all_class_hook_events = 1;
|
||||
caps.can_redefine_classes = 1;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
|
||||
/*
|
||||
* If VM is run with -Xshare:on agent can't get required capabilities (see 6718407)
|
||||
*/
|
||||
NSK_DISPLAY1("%s: warning: agent failed to get required capabilities, agent finishing\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
|
||||
return JNI_ERR;
|
||||
|
||||
nsk_aod_agentFinished(jni, agentName, 1);
|
||||
} else {
|
||||
agentGotCapabilities = JNI_TRUE;
|
||||
|
||||
memset(&eventCallbacks,0, sizeof(eventCallbacks));
|
||||
eventCallbacks.ClassLoad = classLoadHandler;
|
||||
eventCallbacks.ClassPrepare = classPrepareHandler;
|
||||
eventCallbacks.ClassFileLoadHook = classFileLoadHoockHandler;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!(nsk_jvmti_aod_enableEvents(jvmti, testEvents, testEventsNumber))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
NSK_DISPLAY1("%s: initialization was done\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
#include <jvmti.h>
|
||||
#include <aod.h>
|
||||
#include <jvmti_aod.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Expected agent work scenario:
|
||||
* - receive ClassFileLoadHook event for class 'ClassToRedefine'
|
||||
* - receive ClassLoad event for class 'ClassToRedefine' and redefine class from ClassLoad event handler
|
||||
* - receive one more ClassFileLoadHook event for class 'ClassToRedefine'
|
||||
* - receive ClassPrepare event for class 'ClassToRedefine' and finish work
|
||||
*/
|
||||
|
||||
#define REDEFINED_CLASS_NAME "Lnsk/jvmti/AttachOnDemand/attach002/ClassToRedefine;"
|
||||
#define REDEFINED_CLASS_FILE_NAME "nsk/jvmti/AttachOnDemand/attach002/ClassToRedefine"
|
||||
|
||||
// class name in the ClassFileLoadHook callback
|
||||
#define REDEFINED_CLASS_NAME_INTERNAL "nsk/jvmti/AttachOnDemand/attach002/ClassToRedefine"
|
||||
|
||||
static Options* options = NULL;
|
||||
static const char* agentName;
|
||||
|
||||
static volatile jboolean agentGotCapabilities = JNI_FALSE;
|
||||
|
||||
static jvmtiEvent testEvents[] = {
|
||||
JVMTI_EVENT_CLASS_LOAD,
|
||||
JVMTI_EVENT_CLASS_PREPARE,
|
||||
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK};
|
||||
|
||||
static const int testEventsNumber = 3;
|
||||
|
||||
static volatile int classLoadReceived = 0;
|
||||
static volatile int classFileLoadHookReceived = 0;
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities(JNIEnv * jni,
|
||||
jclass klass, jobject obj) {
|
||||
return agentGotCapabilities;
|
||||
}
|
||||
|
||||
#define ATTACH002_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach002/attach002Target"
|
||||
|
||||
int registerNativeMethods(JNIEnv* jni) {
|
||||
jclass appClass;
|
||||
JNINativeMethod nativeMethods[] = {
|
||||
{(char*) "agentGotCapabilities", (char*) "()Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities}};
|
||||
jint nativeMethodsNumber = 1;
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni, (appClass =
|
||||
NSK_CPP_STUB2(FindClass, jni, ATTACH002_TARGET_APP_CLASS_NAME)) != NULL)) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(NSK_CPP_STUB4(RegisterNatives, jni, appClass, nativeMethods, nativeMethodsNumber) == 0))) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
return NSK_TRUE;
|
||||
}
|
||||
|
||||
void JNICALL classLoadHandler(
|
||||
jvmtiEnv *jvmti,
|
||||
JNIEnv* jni,
|
||||
jthread thread,
|
||||
jclass klass) {
|
||||
char className[MAX_STRING_LENGTH];
|
||||
|
||||
if (!nsk_jvmti_aod_getClassName(jvmti, klass, className)) {
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("%s: ClassLoad event was received for class '%s'\n", agentName, className);
|
||||
|
||||
if (!strcmp(className, REDEFINED_CLASS_NAME)) {
|
||||
|
||||
classLoadReceived = 1;
|
||||
|
||||
NSK_DISPLAY1("%s: redefining class\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_jvmti_aod_redefineClass(options, jvmti, klass, REDEFINED_CLASS_FILE_NAME))) {
|
||||
NSK_COMPLAIN1("%s: failed to redefine class\n", agentName);
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JNICALL classPrepareHandler(
|
||||
jvmtiEnv *jvmti,
|
||||
JNIEnv* jni,
|
||||
jthread thread,
|
||||
jclass klass) {
|
||||
char className[MAX_STRING_LENGTH];
|
||||
|
||||
if (!nsk_jvmti_aod_getClassName(jvmti, klass, className)) {
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("%s: ClassPrepare event received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
|
||||
|
||||
if (!strcmp(className, REDEFINED_CLASS_NAME)) {
|
||||
int success = 1;
|
||||
|
||||
if (!classLoadReceived) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("%s: expected ClassLoad event wasn't received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
* ClassFileLoadHook event should be received twice - when class is loaded and when class is redefined
|
||||
*/
|
||||
if (classFileLoadHookReceived != 2) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("%s: expected ClassFileLoadHook event wasn't received for class '%s'\n", agentName, REDEFINED_CLASS_NAME);
|
||||
}
|
||||
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, success, jvmti, jni);
|
||||
}
|
||||
}
|
||||
|
||||
void JNICALL classFileLoadHoockHandler(
|
||||
jvmtiEnv * jvmti,
|
||||
JNIEnv * jni,
|
||||
jclass class_beeing_redefined,
|
||||
jobject loader,
|
||||
const char * name,
|
||||
jobject protection_domain,
|
||||
jint class_data_len,
|
||||
const unsigned char * class_data,
|
||||
jint * new_class_data_len,
|
||||
unsigned char** new_class_data) {
|
||||
|
||||
if (name != NULL) {
|
||||
NSK_DISPLAY2("%s: ClassFileLoadHook event received for class '%s'\n", agentName, name);
|
||||
if (!strcmp(name, REDEFINED_CLASS_NAME_INTERNAL)) {
|
||||
classFileLoadHookReceived++;
|
||||
}
|
||||
} else {
|
||||
NSK_DISPLAY1("%s: ClassFileLoadHook event received for class with NULL name\n", agentName);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef STATIC_BUILD
|
||||
JNIEXPORT jint JNI_OnLoad_attach002Agent00(JavaVM *jvm, char *options, void *reserved) {
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
#ifdef STATIC_BUILD
|
||||
Agent_OnAttach_attach002Agent00(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#else
|
||||
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#endif
|
||||
{
|
||||
jvmtiEventCallbacks eventCallbacks;
|
||||
jvmtiCapabilities caps;
|
||||
jvmtiEnv* jvmti = NULL;
|
||||
JNIEnv* jni = NULL;
|
||||
|
||||
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
|
||||
|
||||
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
|
||||
return NSK_FALSE;
|
||||
|
||||
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY(registerNativeMethods(jni))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
caps.can_generate_all_class_hook_events = 1;
|
||||
caps.can_redefine_classes = 1;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
|
||||
/*
|
||||
* If VM is run with -Xshare:on agent can't get required capabilities (see 6718407)
|
||||
*/
|
||||
NSK_DISPLAY1("%s: warning: agent failed to get required capabilities, agent finishing\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
|
||||
return JNI_ERR;
|
||||
|
||||
nsk_aod_agentFinished(jni, agentName, 1);
|
||||
} else {
|
||||
agentGotCapabilities = JNI_TRUE;
|
||||
|
||||
memset(&eventCallbacks,0, sizeof(eventCallbacks));
|
||||
eventCallbacks.ClassLoad = classLoadHandler;
|
||||
eventCallbacks.ClassPrepare = classPrepareHandler;
|
||||
eventCallbacks.ClassFileLoadHook = classFileLoadHoockHandler;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!(nsk_jvmti_aod_enableEvents(jvmti, testEvents, testEventsNumber))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
NSK_DISPLAY1("%s: initialization was done\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach002Agent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach002Agent00.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach002aAgent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach002aAgent00.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach008Agent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach008Agent00.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach009Agent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach009Agent00.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach012Agent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach012Agent00.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach014Agent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach014Agent00.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach015Agent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach015Agent00.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach015Agent01.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach015Agent01.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach015Target.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach015Target.cpp"
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach020Agent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach020Agent00.cpp"
|
@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
#include <jvmti.h>
|
||||
#include <aod.h>
|
||||
#include <jvmti_aod.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Expected agent work scenario:
|
||||
* - during initialization agent registers native methods used be target application and enables ObjectFree events
|
||||
* - target application using native method and agent's jvmti environment tags object and provokes collection
|
||||
* of this object
|
||||
* - agent receives ObjectFree event for tagged object
|
||||
* - target application using native method calls nsk_aod_agentFinished and agent finishes work
|
||||
* (agent can't call nsk_aod_agentFinished from ObjectFree handler, nsk_aod_agentFinished calls
|
||||
* JNI functions and it is prohibited in ObjectFree handler)
|
||||
*
|
||||
*/
|
||||
|
||||
#define TAG_VALUE (jlong)777
|
||||
#define ATTACH021_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach021/attach021Target"
|
||||
|
||||
static jvmtiEnv* jvmti;
|
||||
|
||||
static Options* options = NULL;
|
||||
static const char* agentName;
|
||||
|
||||
// agent should set success status from objectFreeHandler
|
||||
volatile int success = 0;
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_setTagFor(JNIEnv * jni,
|
||||
jclass klass, jobject obj) {
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, obj, TAG_VALUE))) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("%s: object is tagged (tag: %ld)\n", agentName, TAG_VALUE);
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_shutdownAgent(JNIEnv * jni,
|
||||
jclass klass) {
|
||||
nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_OBJECT_FREE, success, jvmti, jni);
|
||||
}
|
||||
|
||||
void JNICALL objectFreeHandler(jvmtiEnv *jvmti, jlong tag) {
|
||||
NSK_DISPLAY2("%s: object free event for object %ld\n", agentName, tag);
|
||||
|
||||
if (tag != TAG_VALUE) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("%s: unexpected tag value, expected is %ld\n", agentName, TAG_VALUE);
|
||||
} else {
|
||||
success = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Can't use JNI functions from ObjectFree event handler, in this test target application calls
|
||||
* function nsk_aod_agentFinished
|
||||
*/
|
||||
}
|
||||
|
||||
int registerNativeMethods(JNIEnv* jni) {
|
||||
jclass appClass;
|
||||
JNINativeMethod nativeMethods[] = {
|
||||
{"setTagFor", "(Ljava/lang/Object;)Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_setTagFor},
|
||||
{"shutdownAgent", "()V", (void*) Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_shutdownAgent}};
|
||||
jint nativeMethodsNumber = 2;
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni, (appClass =
|
||||
NSK_CPP_STUB2(FindClass, jni, ATTACH021_TARGET_APP_CLASS_NAME)) != NULL)) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(NSK_CPP_STUB4(RegisterNatives, jni, appClass, nativeMethods, nativeMethodsNumber) == 0))) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
return NSK_TRUE;
|
||||
}
|
||||
|
||||
#ifdef STATIC_BUILD
|
||||
JNIEXPORT jint JNI_OnLoad_attach021Agent00(JavaVM *jvm, char *options, void *reserved) {
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
#ifdef STATIC_BUILD
|
||||
Agent_OnAttach_attach021Agent00(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#else
|
||||
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#endif
|
||||
{
|
||||
jvmtiEventCallbacks eventCallbacks;
|
||||
jvmtiCapabilities caps;
|
||||
JNIEnv* jni;
|
||||
|
||||
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
|
||||
|
||||
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY(registerNativeMethods(jni))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&eventCallbacks,0, sizeof(eventCallbacks));
|
||||
eventCallbacks.ObjectFree = objectFreeHandler;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!(nsk_jvmti_aod_enableEvent(jvmti, JVMTI_EVENT_OBJECT_FREE))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
NSK_DISPLAY1("%s: initialization was done\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
|
||||
return JNI_ERR;
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
#include <jvmti.h>
|
||||
#include <aod.h>
|
||||
#include <jvmti_aod.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Expected agent work scenario:
|
||||
* - during initialization agent registers native methods used be target application and enables ObjectFree events
|
||||
* - target application using native method and agent's jvmti environment tags object and provokes collection
|
||||
* of this object
|
||||
* - agent receives ObjectFree event for tagged object
|
||||
* - target application using native method calls nsk_aod_agentFinished and agent finishes work
|
||||
* (agent can't call nsk_aod_agentFinished from ObjectFree handler, nsk_aod_agentFinished calls
|
||||
* JNI functions and it is prohibited in ObjectFree handler)
|
||||
*
|
||||
*/
|
||||
|
||||
#define TAG_VALUE (jlong)777
|
||||
#define ATTACH021_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach021/attach021Target"
|
||||
|
||||
static jvmtiEnv* jvmti;
|
||||
|
||||
static Options* options = NULL;
|
||||
static const char* agentName;
|
||||
|
||||
// agent should set success status from objectFreeHandler
|
||||
volatile int success = 0;
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_setTagFor(JNIEnv * jni,
|
||||
jclass klass, jobject obj) {
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, obj, TAG_VALUE))) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("%s: object is tagged (tag: %ld)\n", agentName, TAG_VALUE);
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_shutdownAgent(JNIEnv * jni,
|
||||
jclass klass) {
|
||||
nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_OBJECT_FREE, success, jvmti, jni);
|
||||
}
|
||||
|
||||
void JNICALL objectFreeHandler(jvmtiEnv *jvmti, jlong tag) {
|
||||
NSK_DISPLAY2("%s: object free event for object %ld\n", agentName, tag);
|
||||
|
||||
if (tag != TAG_VALUE) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("%s: unexpected tag value, expected is %ld\n", agentName, TAG_VALUE);
|
||||
} else {
|
||||
success = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Can't use JNI functions from ObjectFree event handler, in this test target application calls
|
||||
* function nsk_aod_agentFinished
|
||||
*/
|
||||
}
|
||||
|
||||
int registerNativeMethods(JNIEnv* jni) {
|
||||
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;
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni, (appClass =
|
||||
NSK_CPP_STUB2(FindClass, jni, ATTACH021_TARGET_APP_CLASS_NAME)) != NULL)) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(NSK_CPP_STUB4(RegisterNatives, jni, appClass, nativeMethods, nativeMethodsNumber) == 0))) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
return NSK_TRUE;
|
||||
}
|
||||
|
||||
#ifdef STATIC_BUILD
|
||||
JNIEXPORT jint JNI_OnLoad_attach021Agent00(JavaVM *jvm, char *options, void *reserved) {
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
#ifdef STATIC_BUILD
|
||||
Agent_OnAttach_attach021Agent00(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#else
|
||||
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#endif
|
||||
{
|
||||
jvmtiEventCallbacks eventCallbacks;
|
||||
jvmtiCapabilities caps;
|
||||
JNIEnv* jni;
|
||||
|
||||
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
|
||||
|
||||
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY(registerNativeMethods(jni))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&eventCallbacks,0, sizeof(eventCallbacks));
|
||||
eventCallbacks.ObjectFree = objectFreeHandler;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!(nsk_jvmti_aod_enableEvent(jvmti, JVMTI_EVENT_OBJECT_FREE))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
NSK_DISPLAY1("%s: initialization was done\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
|
||||
return JNI_ERR;
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach021Agent00.c"
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.cpp"
|
||||
#include "nsk_tools.cpp"
|
||||
#include "jni_tools.cpp"
|
||||
#include "jvmti_tools.cpp"
|
||||
#include "agent_tools.cpp"
|
||||
#include "jvmti_FollowRefObjects.cpp"
|
||||
#include "Injector.cpp"
|
||||
#include "JVMTITools.cpp"
|
||||
#include "aod.cpp"
|
||||
#include "jvmti_aod.cpp"
|
||||
#include "attach021Agent00.cpp"
|
@ -1,236 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
#include <jvmti.h>
|
||||
#include <aod.h>
|
||||
#include <jvmti_aod.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OBJECTS_FOR_ALLOCATION_TEST_CLASS_NAME "Lnsk/jvmti/AttachOnDemand/attach022/ClassForAllocationEventsTest;"
|
||||
|
||||
static jvmtiEnv* jvmti;
|
||||
static Options* options = NULL;
|
||||
static const char* agentName;
|
||||
|
||||
static jvmtiEvent testEvents[] = {JVMTI_EVENT_OBJECT_FREE, JVMTI_EVENT_VM_OBJECT_ALLOC};
|
||||
static const int testEventsNumber = 2;
|
||||
|
||||
static volatile int taggedObjectsCounter = 0;
|
||||
static volatile int freedObjectsCounter = 0;
|
||||
|
||||
static jrawMonitorID objectTagMonitor;
|
||||
static jrawMonitorID objectFreeMonitor;
|
||||
|
||||
volatile int success = 1;
|
||||
|
||||
volatile int agentFinished;
|
||||
|
||||
void shutdownAgent(JNIEnv* jni) {
|
||||
if (agentFinished)
|
||||
return;
|
||||
|
||||
if (!nsk_jvmti_aod_disableEvents(jvmti, testEvents, testEventsNumber))
|
||||
success = 0;
|
||||
|
||||
nsk_aod_agentFinished(jni, agentName, success);
|
||||
|
||||
agentFinished = 1;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_nsk_jvmti_AttachOnDemand_attach022_attach022Target_shutdownAgent(JNIEnv * jni,
|
||||
jclass klass, jint expectedTaggedObjectsCounter) {
|
||||
|
||||
if (taggedObjectsCounter != expectedTaggedObjectsCounter) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("ERROR: unexpected taggedObjectsCounter: %d (expected value is %d)\n", taggedObjectsCounter, expectedTaggedObjectsCounter);
|
||||
}
|
||||
|
||||
if (taggedObjectsCounter != freedObjectsCounter) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("ERROR: taggedObjectsCounter != freedObjectsCounter (taggedObjectsCounter: %d, freedObjectsCounter: %d)\n",
|
||||
taggedObjectsCounter, freedObjectsCounter);
|
||||
}
|
||||
|
||||
shutdownAgent(jni);
|
||||
|
||||
return success ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
void JNICALL objectFreeHandler(jvmtiEnv *jvmti, jlong tag) {
|
||||
NSK_DISPLAY2("%s: ObjectFree event received (object tag: %ld)\n", agentName, tag);
|
||||
|
||||
if (NSK_JVMTI_VERIFY(NSK_CPP_STUB2(
|
||||
RawMonitorEnter, jvmti, objectFreeMonitor))) {
|
||||
|
||||
freedObjectsCounter++;
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, objectFreeMonitor))) {
|
||||
success = 0;
|
||||
}
|
||||
} else {
|
||||
success = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define ATTACH022_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach022/attach022Target"
|
||||
|
||||
int registerNativeMethods(JNIEnv* jni) {
|
||||
jclass appClass;
|
||||
JNINativeMethod nativeMethods[] = {
|
||||
{"shutdownAgent", "(I)Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach022_attach022Target_shutdownAgent}};
|
||||
jint nativeMethodsNumber = 1;
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni, (appClass =
|
||||
NSK_CPP_STUB2(FindClass, jni, ATTACH022_TARGET_APP_CLASS_NAME)) != NULL)) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(NSK_CPP_STUB4(RegisterNatives, jni, appClass, nativeMethods, nativeMethodsNumber) == 0))) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
return NSK_TRUE;
|
||||
}
|
||||
|
||||
void JNICALL vmObjectAllocHandler(jvmtiEnv * jvmti,
|
||||
JNIEnv * jni,
|
||||
jthread thread,
|
||||
jobject object,
|
||||
jclass object_class,
|
||||
jlong size) {
|
||||
char className[MAX_STRING_LENGTH];
|
||||
|
||||
if (!nsk_jvmti_aod_getClassName(jvmti, object_class, className)) {
|
||||
success = 0;
|
||||
shutdownAgent(jni);
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("%s: ObjectAlloc event received (object class: %s)\n", agentName, className);
|
||||
|
||||
if (!strcmp(className, OBJECTS_FOR_ALLOCATION_TEST_CLASS_NAME)) {
|
||||
if (NSK_JVMTI_VERIFY(NSK_CPP_STUB2(
|
||||
RawMonitorEnter, jvmti, objectTagMonitor))) {
|
||||
jlong tagValue = taggedObjectsCounter + 1;
|
||||
|
||||
|
||||
if (!NSK_JVMTI_VERIFY( NSK_CPP_STUB3(SetTag, jvmti, object, tagValue))) {
|
||||
NSK_COMPLAIN1("%s: failed to set tag\n", agentName);
|
||||
success = 0;
|
||||
} else {
|
||||
NSK_DISPLAY2("%s: object was tagged (tag value: %ld)\n", agentName, tagValue);
|
||||
taggedObjectsCounter++;
|
||||
}
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, objectTagMonitor))) {
|
||||
success = 0;
|
||||
}
|
||||
} else {
|
||||
success = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
NSK_COMPLAIN1("%s: error happened during agent work, stop agent\n", agentName);
|
||||
shutdownAgent(jni);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef STATIC_BUILD
|
||||
JNIEXPORT jint JNI_OnLoad_attach022Agent00(JavaVM *jvm, char *options, void *reserved) {
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
#ifdef STATIC_BUILD
|
||||
Agent_OnAttach_attach022Agent00(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#else
|
||||
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#endif
|
||||
{
|
||||
jvmtiEventCallbacks eventCallbacks;
|
||||
jvmtiCapabilities caps;
|
||||
JNIEnv* jni;
|
||||
|
||||
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
|
||||
|
||||
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY(registerNativeMethods(jni))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, jvmti, "ObjectTagMonitor", &objectTagMonitor))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, jvmti, "ObjectFreeMonitor", &objectFreeMonitor))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
caps.can_generate_vm_object_alloc_events = 1;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&eventCallbacks,0, sizeof(eventCallbacks));
|
||||
eventCallbacks.ObjectFree = objectFreeHandler;
|
||||
eventCallbacks.VMObjectAlloc = vmObjectAllocHandler;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!(nsk_jvmti_aod_enableEvents(jvmti, testEvents, testEventsNumber))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
NSK_DISPLAY1("%s: initialization was done\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
|
||||
return JNI_ERR;
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
#include <jvmti.h>
|
||||
#include <aod.h>
|
||||
#include <jvmti_aod.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OBJECTS_FOR_ALLOCATION_TEST_CLASS_NAME "Lnsk/jvmti/AttachOnDemand/attach022/ClassForAllocationEventsTest;"
|
||||
|
||||
static jvmtiEnv* jvmti;
|
||||
static Options* options = NULL;
|
||||
static const char* agentName;
|
||||
|
||||
static jvmtiEvent testEvents[] = {JVMTI_EVENT_OBJECT_FREE, JVMTI_EVENT_VM_OBJECT_ALLOC};
|
||||
static const int testEventsNumber = 2;
|
||||
|
||||
static volatile int taggedObjectsCounter = 0;
|
||||
static volatile int freedObjectsCounter = 0;
|
||||
|
||||
static jrawMonitorID objectTagMonitor;
|
||||
static jrawMonitorID objectFreeMonitor;
|
||||
|
||||
volatile int success = 1;
|
||||
|
||||
volatile int agentFinished;
|
||||
|
||||
void shutdownAgent(JNIEnv* jni) {
|
||||
if (agentFinished)
|
||||
return;
|
||||
|
||||
if (!nsk_jvmti_aod_disableEvents(jvmti, testEvents, testEventsNumber))
|
||||
success = 0;
|
||||
|
||||
nsk_aod_agentFinished(jni, agentName, success);
|
||||
|
||||
agentFinished = 1;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_nsk_jvmti_AttachOnDemand_attach022_attach022Target_shutdownAgent(JNIEnv * jni,
|
||||
jclass klass, jint expectedTaggedObjectsCounter) {
|
||||
|
||||
if (taggedObjectsCounter != expectedTaggedObjectsCounter) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("ERROR: unexpected taggedObjectsCounter: %d (expected value is %d)\n", taggedObjectsCounter, expectedTaggedObjectsCounter);
|
||||
}
|
||||
|
||||
if (taggedObjectsCounter != freedObjectsCounter) {
|
||||
success = 0;
|
||||
NSK_COMPLAIN2("ERROR: taggedObjectsCounter != freedObjectsCounter (taggedObjectsCounter: %d, freedObjectsCounter: %d)\n",
|
||||
taggedObjectsCounter, freedObjectsCounter);
|
||||
}
|
||||
|
||||
shutdownAgent(jni);
|
||||
|
||||
return success ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
void JNICALL objectFreeHandler(jvmtiEnv *jvmti, jlong tag) {
|
||||
NSK_DISPLAY2("%s: ObjectFree event received (object tag: %ld)\n", agentName, tag);
|
||||
|
||||
if (NSK_JVMTI_VERIFY(NSK_CPP_STUB2(
|
||||
RawMonitorEnter, jvmti, objectFreeMonitor))) {
|
||||
|
||||
freedObjectsCounter++;
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, objectFreeMonitor))) {
|
||||
success = 0;
|
||||
}
|
||||
} else {
|
||||
success = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define ATTACH022_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach022/attach022Target"
|
||||
|
||||
int registerNativeMethods(JNIEnv* jni) {
|
||||
jclass appClass;
|
||||
JNINativeMethod nativeMethods[] = {
|
||||
{(char*)"shutdownAgent", (char*)"(I)Z",
|
||||
(void*) Java_nsk_jvmti_AttachOnDemand_attach022_attach022Target_shutdownAgent}};
|
||||
jint nativeMethodsNumber = 1;
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni, (appClass =
|
||||
NSK_CPP_STUB2(FindClass, jni, ATTACH022_TARGET_APP_CLASS_NAME)) != NULL)) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(NSK_CPP_STUB4(RegisterNatives, jni, appClass, nativeMethods, nativeMethodsNumber) == 0))) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
return NSK_TRUE;
|
||||
}
|
||||
|
||||
void JNICALL vmObjectAllocHandler(jvmtiEnv * jvmti,
|
||||
JNIEnv * jni,
|
||||
jthread thread,
|
||||
jobject object,
|
||||
jclass object_class,
|
||||
jlong size) {
|
||||
char className[MAX_STRING_LENGTH];
|
||||
|
||||
if (!nsk_jvmti_aod_getClassName(jvmti, object_class, className)) {
|
||||
success = 0;
|
||||
shutdownAgent(jni);
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("%s: ObjectAlloc event received (object class: %s)\n", agentName, className);
|
||||
|
||||
if (!strcmp(className, OBJECTS_FOR_ALLOCATION_TEST_CLASS_NAME)) {
|
||||
if (NSK_JVMTI_VERIFY(NSK_CPP_STUB2(
|
||||
RawMonitorEnter, jvmti, objectTagMonitor))) {
|
||||
jlong tagValue = taggedObjectsCounter + 1;
|
||||
|
||||
|
||||
if (!NSK_JVMTI_VERIFY( NSK_CPP_STUB3(SetTag, jvmti, object, tagValue))) {
|
||||
NSK_COMPLAIN1("%s: failed to set tag\n", agentName);
|
||||
success = 0;
|
||||
} else {
|
||||
NSK_DISPLAY2("%s: object was tagged (tag value: %ld)\n", agentName, tagValue);
|
||||
taggedObjectsCounter++;
|
||||
}
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, objectTagMonitor))) {
|
||||
success = 0;
|
||||
}
|
||||
} else {
|
||||
success = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
NSK_COMPLAIN1("%s: error happened during agent work, stop agent\n", agentName);
|
||||
shutdownAgent(jni);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef STATIC_BUILD
|
||||
JNIEXPORT jint JNI_OnLoad_attach022Agent00(JavaVM *jvm, char *options, void *reserved) {
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
#ifdef STATIC_BUILD
|
||||
Agent_OnAttach_attach022Agent00(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#else
|
||||
Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
|
||||
#endif
|
||||
{
|
||||
jvmtiEventCallbacks eventCallbacks;
|
||||
jvmtiCapabilities caps;
|
||||
JNIEnv* jni;
|
||||
|
||||
if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
|
||||
|
||||
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
if (!NSK_VERIFY(registerNativeMethods(jni))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, jvmti, "ObjectTagMonitor", &objectTagMonitor))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, jvmti, "ObjectFreeMonitor", &objectFreeMonitor))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
caps.can_generate_vm_object_alloc_events = 1;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&eventCallbacks,0, sizeof(eventCallbacks));
|
||||
eventCallbacks.ObjectFree = objectFreeHandler;
|
||||
eventCallbacks.VMObjectAlloc = vmObjectAllocHandler;
|
||||
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &eventCallbacks, sizeof(eventCallbacks))) ) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
if (!(nsk_jvmti_aod_enableEvents(jvmti, testEvents, testEventsNumber))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
NSK_DISPLAY1("%s: initialization was done\n", agentName);
|
||||
|
||||
if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
|
||||
return JNI_ERR;
|
||||
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include "native_thread.c"
|
||||
#include "nsk_tools.c"
|
||||
#include "jni_tools.c"
|
||||
#include "jvmti_tools.c"
|
||||
#include "agent_tools.c"
|
||||
#include "jvmti_FollowRefObjects.c"
|
||||
#include "Injector.c"
|
||||
#include "JVMTITools.c"
|
||||
#include "aod.c"
|
||||
#include "jvmti_aod.c"
|
||||
#include "attach022Agent00.c"
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user