jdk/src/share/instrument/JPLISAgent.h
author apangin
Wed, 04 Aug 2010 20:25:02 -0700
changeset 6296 7718201e668f
parent 5506 202f599c92aa
permissions -rw-r--r--
6945961: SIGSEGV in memcpy() during class loading on linux-i586 Summary: Check the result of strchr() in Bytecode Verifier Reviewed-by: kamg, acorn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     2
 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
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
 * Copyright 2003 Wily Technology, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#ifndef _JPLISAGENT_H_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#define _JPLISAGENT_H_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include    <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include    <jvmti.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#ifdef __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *  The JPLISAgent manages the initialization all of the Java programming language Agents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *  It also supports the native method bridge between the JPLIS and the JVMTI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *  It maintains a single JVMTI Env that all JPL agents share.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *  It parses command line requests and creates individual Java agents.
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
 *  Forward definitions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
struct  _JPLISAgent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
typedef struct _JPLISAgent        JPLISAgent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
typedef struct _JPLISEnvironment  JPLISEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
/* constants for class names and methods names and such
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    these all must stay in sync with Java code & interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#define JPLIS_INSTRUMENTIMPL_CLASSNAME                      "sun/instrument/InstrumentationImpl"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define JPLIS_INSTRUMENTIMPL_CONSTRUCTOR_METHODNAME         "<init>"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#define JPLIS_INSTRUMENTIMPL_CONSTRUCTOR_METHODSIGNATURE    "(JZZ)V"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define JPLIS_INSTRUMENTIMPL_PREMAININVOKER_METHODNAME      "loadClassAndCallPremain"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#define JPLIS_INSTRUMENTIMPL_PREMAININVOKER_METHODSIGNATURE "(Ljava/lang/String;Ljava/lang/String;)V"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#define JPLIS_INSTRUMENTIMPL_AGENTMAININVOKER_METHODNAME      "loadClassAndCallAgentmain"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define JPLIS_INSTRUMENTIMPL_AGENTMAININVOKER_METHODSIGNATURE "(Ljava/lang/String;Ljava/lang/String;)V"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODNAME           "transform"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODSIGNATURE      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    "(Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *  Error messages
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#define JPLIS_ERRORMESSAGE_CANNOTSTART              "processing of -javaagent failed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *  Our initialization errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  JPLIS_INIT_ERROR_NONE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  JPLIS_INIT_ERROR_CANNOT_CREATE_NATIVE_AGENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  JPLIS_INIT_ERROR_FAILURE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  JPLIS_INIT_ERROR_ALLOCATION_FAILURE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  JPLIS_INIT_ERROR_AGENT_CLASS_NOT_SPECIFIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
} JPLISInitializationError;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
struct _JPLISEnvironment {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    jvmtiEnv *              mJVMTIEnv;              /* the JVM TI environment */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    JPLISAgent *            mAgent;                 /* corresponding agent */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    jboolean                mIsRetransformer;       /* indicates if special environment */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
struct _JPLISAgent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    JavaVM *                mJVM;                   /* handle to the JVM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    JPLISEnvironment        mNormalEnvironment;     /* for every thing but retransform stuff */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    JPLISEnvironment        mRetransformEnvironment;/* for retransform stuff only */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    jobject                 mInstrumentationImpl;   /* handle to the Instrumentation instance */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    jmethodID               mPremainCaller;         /* method on the InstrumentationImpl that does the premain stuff (cached to save lots of lookups) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    jmethodID               mAgentmainCaller;       /* method on the InstrumentationImpl for agents loaded via attach mechanism */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    jmethodID               mTransform;             /* method on the InstrumentationImpl that does the class file transform */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    jboolean                mRedefineAvailable;     /* cached answer to "does this agent support redefine" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    jboolean                mRedefineAdded;         /* indicates if can_redefine_classes capability has been added */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    jboolean                mNativeMethodPrefixAvailable; /* cached answer to "does this agent support prefixing" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    jboolean                mNativeMethodPrefixAdded;     /* indicates if can_set_native_method_prefix capability has been added */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    char const *            mAgentClassName;        /* agent class name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    char const *            mOptionsString;         /* -javaagent options string */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * JVMTI event handlers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
/* VMInit event handler. Installed during OnLoad, then removed during VMInit. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
extern void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
eventHandlerVMInit( jvmtiEnv *      jvmtienv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    JNIEnv *        jnienv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    jthread         thread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
/* ClassFileLoadHook event handler. Installed during VMInit, then left in place forever. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
extern void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
eventHandlerClassFileLoadHook(  jvmtiEnv *              jvmtienv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                                JNIEnv *                jnienv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                                jclass                  class_being_redefined,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                                jobject                 loader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                                const char*             name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                jobject                 protectionDomain,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                jint                    class_data_len,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                                const unsigned char*    class_data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                jint*                   new_class_data_len,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                unsigned char**         new_class_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * Main entry points for the JPLIS JVMTI agent code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
/* looks up the  environment instance. returns null if there isn't one */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
extern JPLISEnvironment *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
getJPLISEnvironment(jvmtiEnv * jvmtienv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
/*  Creates a new JPLIS agent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 *  Returns error if the agent cannot be created and initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 *  The JPLISAgent* pointed to by agent_ptr is set to the new broker,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *  or NULL if an error has occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
extern JPLISInitializationError
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
createNewJPLISAgent(JavaVM * vm, JPLISAgent **agent_ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
/* Adds can_redefine_classes capability */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
addRedefineClassesCapability(JPLISAgent * agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
/* Add the can_set_native_method_prefix capability */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
addNativeMethodPrefixCapability(JPLISAgent * agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
/* Add the can_maintain_original_method_order capability (for testing) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
addOriginalMethodOrderCapability(JPLISAgent * agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
/* Our JPLIS agent is paralleled by a Java InstrumentationImpl instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 * This routine uses JNI to create and initialized the Java instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 * Returns true if it succeeds, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
extern jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
createInstrumentationImpl( JNIEnv *        jnienv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                           JPLISAgent *    agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
/* during OnLoad phase (command line parsing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 *  record the parameters of -javaagent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
extern JPLISInitializationError
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
recordCommandLineData(  JPLISAgent *    agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                        const char *    agentClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                        const char *    optionsString );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
/* Swaps the start phase event handlers out and the live phase event handlers in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 * Also used in attach to enabled live phase event handlers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 * Returns true if it succeeds, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
extern jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
setLivePhaseEventHandlers(  JPLISAgent * agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
/* Loads the Java agent according to the already processed command line. For each,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * loads the Java agent class, then calls the premain method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * Returns true if all Java agent classes are loaded and all premain methods complete with no exceptions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
extern jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
startJavaAgent( JPLISAgent *    agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                JNIEnv *        jnienv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                const char *    classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                const char *    optionsString,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                jmethodID       agentMainMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
/* during VMInit processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 *  this is how the invocation engine (callback wrapper) tells us to start up all the javaagents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
extern jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
processJavaStart(   JPLISAgent *    agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    JNIEnv *        jnienv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
/* on an ongoing basis,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 *  this is how the invocation engine (callback wrapper) tells us to process a class file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
transformClassFile(             JPLISAgent *            agent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                JNIEnv *                jnienv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                jobject                 loader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                                const char*             name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                jclass                  classBeingRedefined,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                                jobject                 protectionDomain,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                                jint                    class_data_len,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                const unsigned char*    class_data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                jint*                   new_class_data_len,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                unsigned char**         new_class_data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                                jboolean                is_retransformer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
/* on an ongoing basis,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 *  Return the environment with the retransformation capability.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 *  Create it if it doesn't exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
extern jvmtiEnv *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
retransformableEnvironment(JPLISAgent * agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
/* on an ongoing basis,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 *  these are implementations of the Instrumentation services.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
 *  Most are simple covers for JVMTI access services. These are the guts of the InstrumentationImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
 *  native methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
extern jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
isModifiableClass(JNIEnv * jnienv, JPLISAgent * agent, jclass clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
extern jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
isRetransformClassesSupported(JNIEnv * jnienv, JPLISAgent * agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
setHasRetransformableTransformers(JNIEnv * jnienv, JPLISAgent * agent, jboolean has);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
retransformClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
redefineClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classDefinitions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
extern jobjectArray
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
getAllLoadedClasses(JNIEnv * jnienv, JPLISAgent * agent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
extern jobjectArray
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
getInitiatedClasses(JNIEnv * jnienv, JPLISAgent * agent, jobject classLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
extern jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
getObjectSize(JNIEnv * jnienv, JPLISAgent * agent, jobject objectToSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
appendToClassLoaderSearch(JNIEnv * jnienv, JPLISAgent * agent, jstring jarFile, jboolean isBootLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
extern void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
setNativeMethodPrefixes(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray prefixArray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                        jboolean isRetransformable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
#define jvmti(a) a->mNormalEnvironment.mJVMTIEnv
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
282
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   269
/*
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   270
 * A set of macros for insulating the JLI method callers from
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   271
 * JVMTI_ERROR_WRONG_PHASE return codes.
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   272
 */
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   273
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   274
/* for a JLI method where "blob" is executed before simply returning */
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   275
#define check_phase_blob_ret(ret, blob)      \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   276
    if ((ret) == JVMTI_ERROR_WRONG_PHASE) {  \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   277
        blob;                                \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   278
        return;                              \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   279
    }
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   280
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   281
/* for a JLI method where simply returning is benign */
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   282
#define check_phase_ret(ret)                 \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   283
    if ((ret) == JVMTI_ERROR_WRONG_PHASE) {  \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   284
        return;                              \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   285
    }
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   286
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   287
/* for a JLI method where returning zero (0) is benign */
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   288
#define check_phase_ret_0(ret)               \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   289
    if ((ret) == JVMTI_ERROR_WRONG_PHASE) {  \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   290
        return 0;                            \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   291
    }
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   292
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   293
/* for a JLI method where returning one (1) is benign */
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   294
#define check_phase_ret_1(ret)               \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   295
    if ((ret) == JVMTI_ERROR_WRONG_PHASE) {  \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   296
        return 1;                            \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   297
    }
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   298
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   299
/* for a case where a specific "blob" must be returned */
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   300
#define check_phase_ret_blob(ret, blob)      \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   301
    if ((ret) == JVMTI_ERROR_WRONG_PHASE) {  \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   302
        return (blob);                       \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   303
    }
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   304
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   305
/* for a JLI method where returning false is benign */
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   306
#define check_phase_ret_false(ret)           \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   307
    if ((ret) == JVMTI_ERROR_WRONG_PHASE) {  \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   308
        return (jboolean) 0;                 \
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   309
    }
bca3e5a71df1 6572160: 3/3 Instrumentation.getObjectSize triggers JVM crash in JPLISAssert in shutdown
dcubed
parents: 2
diff changeset
   310
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
#ifdef __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
#endif /* __cplusplus */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
#endif