blob: f4a1239699614a6fecc06e15f904dea02592c2e7 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003-2007 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26
27#include <jni.h>
28
29#include "JPLISAgent.h"
30#include "JPLISAssert.h"
31#include "Utilities.h"
32#include "JavaExceptions.h"
33#include "sun_instrument_InstrumentationImpl.h"
34#include "typedefs.h"
35
36/*
37 * Copyright 2003 Wily Technology, Inc.
38 */
39
40/**
41 * This module contains the native method implementations to back the
42 * sun.instrument.InstrumentationImpl class.
43 * The bridge between Java and native code is built by storing a native
44 * pointer to the JPLISAgent data structure in a 64 bit scalar field
45 * in the InstrumentationImpl instance which is passed to each method.
46 */
47
48
49/*
50 * Native methods
51 */
52
53/*
54 * Class: sun_instrument_InstrumentationImpl
55 * Method: isModifiableClass0
56 * Signature: (Ljava/lang/Class;)Z
57 */
58JNIEXPORT jboolean JNICALL
59Java_sun_instrument_InstrumentationImpl_isModifiableClass0
60 (JNIEnv * jnienv, jobject implThis, jlong agent, jclass clazz) {
61 return isModifiableClass(jnienv, (JPLISAgent*)(intptr_t)agent, clazz);
62}
63
64/*
65 * Class: sun_instrument_InstrumentationImpl
66 * Method: isRetransformClassesSupported0
67 * Signature: ()Z
68 */
69JNIEXPORT jboolean JNICALL
70Java_sun_instrument_InstrumentationImpl_isRetransformClassesSupported0
71 (JNIEnv * jnienv, jobject implThis, jlong agent) {
72 return isRetransformClassesSupported(jnienv, (JPLISAgent*)(intptr_t)agent);
73}
74
75/*
76 * Class: sun_instrument_InstrumentationImpl
77 * Method: setHasRetransformableTransformers
78 * Signature: (Z)V
79 */
80JNIEXPORT void JNICALL
81Java_sun_instrument_InstrumentationImpl_setHasRetransformableTransformers
82 (JNIEnv * jnienv, jobject implThis, jlong agent, jboolean has) {
83 setHasRetransformableTransformers(jnienv, (JPLISAgent*)(intptr_t)agent, has);
84}
85
86/*
87 * Class: sun_instrument_InstrumentationImpl
88 * Method: retransformClasses0
89 * Signature: ([Ljava/lang/Class;)V
90 */
91JNIEXPORT void JNICALL
92Java_sun_instrument_InstrumentationImpl_retransformClasses0
93 (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray classes) {
94 retransformClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classes);
95}
96
97/*
98 * Class: sun_instrument_InstrumentationImpl
99 * Method: redefineClasses0
100 * Signature: ([Ljava/lang/instrument/ClassDefinition;)V
101 */
102JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_redefineClasses0
103 (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray classDefinitions) {
104 redefineClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classDefinitions);
105}
106
107/*
108 * Class: sun_instrument_InstrumentationImpl
109 * Method: getAllLoadedClasses0
110 * Signature: ()[Ljava/lang/Class;
111 */
112JNIEXPORT jobjectArray JNICALL Java_sun_instrument_InstrumentationImpl_getAllLoadedClasses0
113 (JNIEnv * jnienv, jobject implThis, jlong agent) {
114 return getAllLoadedClasses(jnienv, (JPLISAgent*)(intptr_t)agent);
115}
116
117/*
118 * Class: sun_instrument_InstrumentationImpl
119 * Method: getInitiatedClasses0
120 * Signature: (Ljava/lang/ClassLoader;)[Ljava/lang/Class;
121 */
122JNIEXPORT jobjectArray JNICALL Java_sun_instrument_InstrumentationImpl_getInitiatedClasses0
123 (JNIEnv * jnienv, jobject implThis, jlong agent, jobject classLoader) {
124 return getInitiatedClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classLoader);
125}
126
127/*
128 * Class: sun_instrument_InstrumentationImpl
129 * Method: getObjectSize0
130 * Signature: (Ljava/lang/Object;)J
131 */
132JNIEXPORT jlong JNICALL Java_sun_instrument_InstrumentationImpl_getObjectSize0
133 (JNIEnv * jnienv, jobject implThis, jlong agent, jobject objectToSize) {
134 return getObjectSize(jnienv, (JPLISAgent*)(intptr_t)agent, objectToSize);
135}
136
137
138/*
139 * Class: sun_instrument_InstrumentationImpl
140 * Method: appendToClassLoaderSearch0
141 * Signature: (Ljava/lang/String;Z)V
142 */
143JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_appendToClassLoaderSearch0
144 (JNIEnv * jnienv, jobject implThis, jlong agent, jstring jarFile, jboolean isBootLoader) {
145 appendToClassLoaderSearch(jnienv, (JPLISAgent*)(intptr_t)agent, jarFile, isBootLoader);
146}
147
148
149/*
150 * Class: sun_instrument_InstrumentationImpl
151 * Method: setNativeMethodPrefixes
152 * Signature: ([Ljava/lang/String;Z)V
153 */
154JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_setNativeMethodPrefixes
155 (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray prefixArray, jboolean isRetransformable) {
156 setNativeMethodPrefixes(jnienv, (JPLISAgent*)(intptr_t)agent, prefixArray, isRetransformable);
157}