1 /* 2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #include <jni.h> 27 28 #include "JPLISAgent.h" 29 #include "JPLISAssert.h" 30 #include "Utilities.h" 31 #include "JavaExceptions.h" 32 #include "FileSystemSupport.h" /* For uintptr_t */ 33 #include "sun_instrument_InstrumentationImpl.h" 34 35 /* 36 * Copyright 2003 Wily Technology, Inc. 37 */ 38 39 /** 40 * This module contains the native method implementations to back the 41 * sun.instrument.InstrumentationImpl class. 42 * The bridge between Java and native code is built by storing a native 43 * pointer to the JPLISAgent data structure in a 64 bit scalar field 44 * in the InstrumentationImpl instance which is passed to each method. 45 */ 46 47 48 /* 49 * Native methods 50 */ 51 52 /* 53 * Declare library specific JNI_Onload entry if static build 54 */ 55 DEF_STATIC_JNI_OnLoad 56 57 /* 58 * Class: sun_instrument_InstrumentationImpl 59 * Method: isModifiableClass0 60 * Signature: (Ljava/lang/Class;)Z 61 */ 62 JNIEXPORT jboolean JNICALL 63 Java_sun_instrument_InstrumentationImpl_isModifiableClass0 64 (JNIEnv * jnienv, jobject implThis, jlong agent, jclass clazz) { 65 return isModifiableClass(jnienv, (JPLISAgent*)(intptr_t)agent, clazz); 66 } 67 68 /* 69 * Class: sun_instrument_InstrumentationImpl 70 * Method: isRetransformClassesSupported0 71 * Signature: ()Z 72 */ 73 JNIEXPORT jboolean JNICALL 74 Java_sun_instrument_InstrumentationImpl_isRetransformClassesSupported0 75 (JNIEnv * jnienv, jobject implThis, jlong agent) { 76 return isRetransformClassesSupported(jnienv, (JPLISAgent*)(intptr_t)agent); 77 } 78 79 /* 80 * Class: sun_instrument_InstrumentationImpl 81 * Method: setHasRetransformableTransformers 82 * Signature: (Z)V 83 */ 84 JNIEXPORT void JNICALL 85 Java_sun_instrument_InstrumentationImpl_setHasRetransformableTransformers 86 (JNIEnv * jnienv, jobject implThis, jlong agent, jboolean has) { 87 setHasRetransformableTransformers(jnienv, (JPLISAgent*)(intptr_t)agent, has); 88 } 89 90 /* 91 * Class: sun_instrument_InstrumentationImpl 92 * Method: retransformClasses0 93 * Signature: ([Ljava/lang/Class;)V 94 */ 95 JNIEXPORT void JNICALL 96 Java_sun_instrument_InstrumentationImpl_retransformClasses0 97 (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray classes) { 98 retransformClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classes); 99 } 100 101 /* 102 * Class: sun_instrument_InstrumentationImpl 103 * Method: redefineClasses0 104 * Signature: ([Ljava/lang/instrument/ClassDefinition;)V 105 */ 106 JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_redefineClasses0 107 (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray classDefinitions) { 108 redefineClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classDefinitions); 109 } 110 111 /* 112 * Class: sun_instrument_InstrumentationImpl 113 * Method: getAllLoadedClasses0 114 * Signature: ()[Ljava/lang/Class; 115 */ 116 JNIEXPORT jobjectArray JNICALL Java_sun_instrument_InstrumentationImpl_getAllLoadedClasses0 117 (JNIEnv * jnienv, jobject implThis, jlong agent) { 118 return getAllLoadedClasses(jnienv, (JPLISAgent*)(intptr_t)agent); 119 } 120 121 /* 122 * Class: sun_instrument_InstrumentationImpl 123 * Method: getInitiatedClasses0 124 * Signature: (Ljava/lang/ClassLoader;)[Ljava/lang/Class; 125 */ 126 JNIEXPORT jobjectArray JNICALL Java_sun_instrument_InstrumentationImpl_getInitiatedClasses0 127 (JNIEnv * jnienv, jobject implThis, jlong agent, jobject classLoader) { 128 return getInitiatedClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classLoader); 129 } 130 131 /* 132 * Class: sun_instrument_InstrumentationImpl 133 * Method: getObjectSize0 134 * Signature: (Ljava/lang/Object;)J 135 */ 136 JNIEXPORT jlong JNICALL Java_sun_instrument_InstrumentationImpl_getObjectSize0 137 (JNIEnv * jnienv, jobject implThis, jlong agent, jobject objectToSize) { 138 return getObjectSize(jnienv, (JPLISAgent*)(intptr_t)agent, objectToSize); 139 } 140 141 142 /* 143 * Class: sun_instrument_InstrumentationImpl 144 * Method: appendToClassLoaderSearch0 145 * Signature: (Ljava/lang/String;Z)V 146 */ 147 JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_appendToClassLoaderSearch0 148 (JNIEnv * jnienv, jobject implThis, jlong agent, jstring jarFile, jboolean isBootLoader) { 149 appendToClassLoaderSearch(jnienv, (JPLISAgent*)(intptr_t)agent, jarFile, isBootLoader); 150 } 151 152 153 /* 154 * Class: sun_instrument_InstrumentationImpl 155 * Method: setNativeMethodPrefixes 156 * Signature: ([Ljava/lang/String;Z)V 157 */ 158 JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_setNativeMethodPrefixes 159 (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray prefixArray, jboolean isRetransformable) { 160 setNativeMethodPrefixes(jnienv, (JPLISAgent*)(intptr_t)agent, prefixArray, isRetransformable); 161 }