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