Path: blob/master/src/java.instrument/share/native/libinstrument/InstrumentationImplNativeMethods.c
41149 views
/*1* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include <jni.h>2627#include "JPLISAgent.h"28#include "JPLISAssert.h"29#include "Utilities.h"30#include "JavaExceptions.h"31#include "FileSystemSupport.h" /* For uintptr_t */32#include "sun_instrument_InstrumentationImpl.h"3334/*35* Copyright 2003 Wily Technology, Inc.36*/3738/**39* This module contains the native method implementations to back the40* sun.instrument.InstrumentationImpl class.41* The bridge between Java and native code is built by storing a native42* pointer to the JPLISAgent data structure in a 64 bit scalar field43* in the InstrumentationImpl instance which is passed to each method.44*/454647/*48* Native methods49*/5051/*52* Declare library specific JNI_Onload entry if static build53*/54DEF_STATIC_JNI_OnLoad5556/*57* Class: sun_instrument_InstrumentationImpl58* Method: isModifiableClass059* Signature: (Ljava/lang/Class;)Z60*/61JNIEXPORT jboolean JNICALL62Java_sun_instrument_InstrumentationImpl_isModifiableClass063(JNIEnv * jnienv, jobject implThis, jlong agent, jclass clazz) {64return isModifiableClass(jnienv, (JPLISAgent*)(intptr_t)agent, clazz);65}6667/*68* Class: sun_instrument_InstrumentationImpl69* Method: isRetransformClassesSupported070* Signature: ()Z71*/72JNIEXPORT jboolean JNICALL73Java_sun_instrument_InstrumentationImpl_isRetransformClassesSupported074(JNIEnv * jnienv, jobject implThis, jlong agent) {75return isRetransformClassesSupported(jnienv, (JPLISAgent*)(intptr_t)agent);76}7778/*79* Class: sun_instrument_InstrumentationImpl80* Method: setHasTransformers81* Signature: (Z)V82*/83JNIEXPORT void JNICALL84Java_sun_instrument_InstrumentationImpl_setHasTransformers85(JNIEnv * jnienv, jobject implThis, jlong agent, jboolean has) {86setHasTransformers(jnienv, (JPLISAgent*)(intptr_t)agent, has);87}8889/*90* Class: sun_instrument_InstrumentationImpl91* Method: setHasRetransformableTransformers92* Signature: (Z)V93*/94JNIEXPORT void JNICALL95Java_sun_instrument_InstrumentationImpl_setHasRetransformableTransformers96(JNIEnv * jnienv, jobject implThis, jlong agent, jboolean has) {97setHasRetransformableTransformers(jnienv, (JPLISAgent*)(intptr_t)agent, has);98}99100/*101* Class: sun_instrument_InstrumentationImpl102* Method: retransformClasses0103* Signature: ([Ljava/lang/Class;)V104*/105JNIEXPORT void JNICALL106Java_sun_instrument_InstrumentationImpl_retransformClasses0107(JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray classes) {108retransformClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classes);109}110111/*112* Class: sun_instrument_InstrumentationImpl113* Method: redefineClasses0114* Signature: ([Ljava/lang/instrument/ClassDefinition;)V115*/116JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_redefineClasses0117(JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray classDefinitions) {118redefineClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classDefinitions);119}120121/*122* Class: sun_instrument_InstrumentationImpl123* Method: getAllLoadedClasses0124* Signature: ()[Ljava/lang/Class;125*/126JNIEXPORT jobjectArray JNICALL Java_sun_instrument_InstrumentationImpl_getAllLoadedClasses0127(JNIEnv * jnienv, jobject implThis, jlong agent) {128return getAllLoadedClasses(jnienv, (JPLISAgent*)(intptr_t)agent);129}130131/*132* Class: sun_instrument_InstrumentationImpl133* Method: getInitiatedClasses0134* Signature: (Ljava/lang/ClassLoader;)[Ljava/lang/Class;135*/136JNIEXPORT jobjectArray JNICALL Java_sun_instrument_InstrumentationImpl_getInitiatedClasses0137(JNIEnv * jnienv, jobject implThis, jlong agent, jobject classLoader) {138return getInitiatedClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classLoader);139}140141/*142* Class: sun_instrument_InstrumentationImpl143* Method: getObjectSize0144* Signature: (Ljava/lang/Object;)J145*/146JNIEXPORT jlong JNICALL Java_sun_instrument_InstrumentationImpl_getObjectSize0147(JNIEnv * jnienv, jobject implThis, jlong agent, jobject objectToSize) {148return getObjectSize(jnienv, (JPLISAgent*)(intptr_t)agent, objectToSize);149}150151152/*153* Class: sun_instrument_InstrumentationImpl154* Method: appendToClassLoaderSearch0155* Signature: (Ljava/lang/String;Z)V156*/157JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_appendToClassLoaderSearch0158(JNIEnv * jnienv, jobject implThis, jlong agent, jstring jarFile, jboolean isBootLoader) {159appendToClassLoaderSearch(jnienv, (JPLISAgent*)(intptr_t)agent, jarFile, isBootLoader);160}161162163/*164* Class: sun_instrument_InstrumentationImpl165* Method: setNativeMethodPrefixes166* Signature: ([Ljava/lang/String;Z)V167*/168JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_setNativeMethodPrefixes169(JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray prefixArray, jboolean isRetransformable) {170setNativeMethodPrefixes(jnienv, (JPLISAgent*)(intptr_t)agent, prefixArray, isRetransformable);171}172173174/*175* Class: sun_instrument_InstrumentationImpl176* Method: loadAgent0177*/178JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_loadAgent0179(JNIEnv* env, jclass clazz, jstring jarfile)180{181extern jint loadAgent(JNIEnv* env, jstring path);182if (loadAgent(env, jarfile) != JNI_OK) {183if (!(*env)->ExceptionCheck(env)) {184createAndThrowInternalError(env);185}186}187}188189190191