jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java
author sspitsyn
Sat, 09 Jul 2016 21:41:14 -0700
changeset 39739 5d058d6bd245
parent 36511 9d0388c6b336
child 44545 83b611b88ac8
permissions -rw-r--r--
8159147: Add ClassLoader parameter to new ClassFileTransformer transform method Summary: Add ClassLoader parameter to new ClassFileTransformer transform method Reviewed-by: alanb, dholmes, dcubed, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
     2
 * Copyright (c) 2003, 2016, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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
package sun.instrument;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.lang.instrument.Instrumentation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.lang.instrument.ClassFileTransformer;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
    31
import java.lang.reflect.Module;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.ProtectionDomain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Copyright 2003 Wily Technology, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Support class for the InstrumentationImpl. Manages the list of registered transformers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Keeps everything in the right order, deals with sync of the list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * and actually does the calling of the transformers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public class TransformerManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private class TransformerInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        final ClassFileTransformer  mTransformer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        String                      mPrefix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        TransformerInfo(ClassFileTransformer transformer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            mTransformer = transformer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            mPrefix = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        ClassFileTransformer transformer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            return  mTransformer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        String getPrefix() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            return mPrefix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        void setPrefix(String prefix) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            mPrefix = prefix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * a given instance of this list is treated as immutable to simplify sync;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * we pay copying overhead whenever the list is changed rather than every time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * the list is referenced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * The array is kept in the order the transformers are added via addTransformer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * (first added is 0, last added is length-1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Use an array, not a List or other Collection. This keeps the set of classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * used by this code to a minimum. We want as few dependencies as possible in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * code, since it is used inside the class definition system. Any class referenced here
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * cannot be transformed by Java code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private TransformerInfo[]  mTransformerList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /***
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Is this TransformerManager for transformers capable of retransformation?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private boolean            mIsRetransformable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    TransformerManager(boolean isRetransformable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        mTransformerList    = new TransformerInfo[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        mIsRetransformable  = isRetransformable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    boolean isRetransformable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return mIsRetransformable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public synchronized void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    addTransformer( ClassFileTransformer    transformer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        TransformerInfo[] oldList = mTransformerList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        TransformerInfo[] newList = new TransformerInfo[oldList.length + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        System.arraycopy(   oldList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                            0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                            newList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                            0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                            oldList.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        newList[oldList.length] = new TransformerInfo(transformer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        mTransformerList = newList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public synchronized boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    removeTransformer(ClassFileTransformer  transformer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        boolean                 found           = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        TransformerInfo[]       oldList         = mTransformerList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        int                     oldLength       = oldList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        int                     newLength       = oldLength - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // look for it in the list, starting at the last added, and remember
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        // where it was if we found it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        int matchingIndex   = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        for ( int x = oldLength - 1; x >= 0; x-- ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            if ( oldList[x].transformer() == transformer ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                found           = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                matchingIndex   = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        // make a copy of the array without the matching element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if ( found ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            TransformerInfo[]  newList = new TransformerInfo[newLength];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            // copy up to but not including the match
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            if ( matchingIndex > 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                System.arraycopy(   oldList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                    0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                    newList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                    0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                    matchingIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            // if there is anything after the match, copy it as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            if ( matchingIndex < (newLength) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                System.arraycopy(   oldList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                                    matchingIndex + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                                    newList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                                    matchingIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                                    (newLength) - matchingIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            mTransformerList = newList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        return found;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    synchronized boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    includesTransformer(ClassFileTransformer transformer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        for (TransformerInfo info : mTransformerList) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            if ( info.transformer() == transformer ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    // This function doesn't actually snapshot anything, but should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    // used to set a local variable, which will snapshot the transformer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    // list because of the copying semantics of mTransformerList (see
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    // the comment for mTransformerList).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    private TransformerInfo[]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    getSnapshotTransformerList() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        return mTransformerList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public byte[]
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   171
    transform(  Module              module,
39739
5d058d6bd245 8159147: Add ClassLoader parameter to new ClassFileTransformer transform method
sspitsyn
parents: 36511
diff changeset
   172
                ClassLoader         loader,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                String              classname,
11125
99b115114fa3 7117357: Warnings in sun.instrument, tools and other sun.* classes
alanb
parents: 5506
diff changeset
   174
                Class<?>            classBeingRedefined,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                ProtectionDomain    protectionDomain,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                byte[]              classfileBuffer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        boolean someoneTouchedTheBytecode = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        TransformerInfo[]  transformerList = getSnapshotTransformerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        byte[]  bufferToUse = classfileBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        // order matters, gotta run 'em in the order they were added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        for ( int x = 0; x < transformerList.length; x++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            TransformerInfo         transformerInfo = transformerList[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            ClassFileTransformer    transformer = transformerInfo.transformer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            byte[]                  transformedBytes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            try {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 25859
diff changeset
   190
                transformedBytes = transformer.transform(   module,
39739
5d058d6bd245 8159147: Add ClassLoader parameter to new ClassFileTransformer transform method
sspitsyn
parents: 36511
diff changeset
   191
                                                            loader,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                                                            classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                                                            classBeingRedefined,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                                            protectionDomain,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                                            bufferToUse);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            catch (Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                // don't let any one transformer mess it up for the others.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                // This is where we need to put some logging. What should go here? FIXME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            if ( transformedBytes != null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                someoneTouchedTheBytecode = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                bufferToUse = transformedBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        // if someone modified it, return the modified buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        // otherwise return null to mean "no transforms occurred"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        byte [] result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        if ( someoneTouchedTheBytecode ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            result = bufferToUse;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            result = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    getTransformerCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        TransformerInfo[]  transformerList = getSnapshotTransformerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        return transformerList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    setNativeMethodPrefix(ClassFileTransformer transformer, String prefix) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        TransformerInfo[]  transformerList = getSnapshotTransformerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        for ( int x = 0; x < transformerList.length; x++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            TransformerInfo         transformerInfo = transformerList[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            ClassFileTransformer    aTransformer = transformerInfo.transformer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            if ( aTransformer == transformer ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                transformerInfo.setPrefix(prefix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    String[]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    getNativeMethodPrefixes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        TransformerInfo[]  transformerList = getSnapshotTransformerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        String[] prefixes                  = new String[transformerList.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        for ( int x = 0; x < transformerList.length; x++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            TransformerInfo         transformerInfo = transformerList[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            prefixes[x] = transformerInfo.getPrefix();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return prefixes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
}