jdk/src/share/instrument/InstrumentationImplNativeMethods.c
author ohair
Fri, 22 Aug 2008 12:24:27 -0700
changeset 1090 c5805b1672a6
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6732421: Removed old javavm and Classic VM files from the jdk7 sources Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1090
c5805b1672a6 6732421: Removed old javavm and Classic VM files from the jdk7 sources
ohair
parents: 2
diff changeset
     2
 * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
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
#include    <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include    "JPLISAgent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include    "JPLISAssert.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include    "Utilities.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include    "JavaExceptions.h"
1090
c5805b1672a6 6732421: Removed old javavm and Classic VM files from the jdk7 sources
ohair
parents: 2
diff changeset
    32
#include    "FileSystemSupport.h"   /* For uintptr_t */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include    "sun_instrument_InstrumentationImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Copyright 2003 Wily Technology, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * This module contains the native method implementations to back the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * sun.instrument.InstrumentationImpl class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * The bridge between Java and native code is built by storing a native
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * pointer to the JPLISAgent data structure in a 64 bit scalar field
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * in the InstrumentationImpl instance which is passed to each method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 */
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
 * Native methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Method:    isModifiableClass0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * Signature: (Ljava/lang/Class;)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
Java_sun_instrument_InstrumentationImpl_isModifiableClass0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  (JNIEnv * jnienv, jobject implThis, jlong agent, jclass clazz) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    return isModifiableClass(jnienv, (JPLISAgent*)(intptr_t)agent, clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * Method:    isRetransformClassesSupported0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
Java_sun_instrument_InstrumentationImpl_isRetransformClassesSupported0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  (JNIEnv * jnienv, jobject implThis, jlong agent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    return isRetransformClassesSupported(jnienv, (JPLISAgent*)(intptr_t)agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * Method:    setHasRetransformableTransformers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * Signature: (Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
Java_sun_instrument_InstrumentationImpl_setHasRetransformableTransformers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  (JNIEnv * jnienv, jobject implThis, jlong agent, jboolean has) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    setHasRetransformableTransformers(jnienv, (JPLISAgent*)(intptr_t)agent, has);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * Method:    retransformClasses0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * Signature: ([Ljava/lang/Class;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
Java_sun_instrument_InstrumentationImpl_retransformClasses0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
  (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray classes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    retransformClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * Method:    redefineClasses0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * Signature: ([Ljava/lang/instrument/ClassDefinition;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_redefineClasses0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray classDefinitions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    redefineClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classDefinitions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * Method:    getAllLoadedClasses0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * Signature: ()[Ljava/lang/Class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
JNIEXPORT jobjectArray JNICALL Java_sun_instrument_InstrumentationImpl_getAllLoadedClasses0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  (JNIEnv * jnienv, jobject implThis, jlong agent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    return getAllLoadedClasses(jnienv, (JPLISAgent*)(intptr_t)agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * Method:    getInitiatedClasses0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * Signature: (Ljava/lang/ClassLoader;)[Ljava/lang/Class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
JNIEXPORT jobjectArray JNICALL Java_sun_instrument_InstrumentationImpl_getInitiatedClasses0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
  (JNIEnv * jnienv, jobject implThis, jlong agent, jobject classLoader) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    return getInitiatedClasses(jnienv, (JPLISAgent*)(intptr_t)agent, classLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * Method:    getObjectSize0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * Signature: (Ljava/lang/Object;)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
JNIEXPORT jlong JNICALL Java_sun_instrument_InstrumentationImpl_getObjectSize0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  (JNIEnv * jnienv, jobject implThis, jlong agent, jobject objectToSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    return getObjectSize(jnienv, (JPLISAgent*)(intptr_t)agent, objectToSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
}
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
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * Method:    appendToClassLoaderSearch0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * Signature: (Ljava/lang/String;Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_appendToClassLoaderSearch0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  (JNIEnv * jnienv, jobject implThis, jlong agent, jstring jarFile, jboolean isBootLoader) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    appendToClassLoaderSearch(jnienv, (JPLISAgent*)(intptr_t)agent, jarFile, isBootLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
}
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
 * Class:     sun_instrument_InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 * Method:    setNativeMethodPrefixes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * Signature: ([Ljava/lang/String;Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_setNativeMethodPrefixes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray prefixArray, jboolean isRetransformable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    setNativeMethodPrefixes(jnienv, (JPLISAgent*)(intptr_t)agent, prefixArray, isRetransformable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
}