/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.instrument;
/*
* Copyright 2003 Wily Technology, Inc.
*/
/**
* Support class for the InstrumentationImpl. Manages the list of registered transformers.
* Keeps everything in the right order, deals with sync of the list,
* and actually does the calling of the transformers.
*/
public class TransformerManager
{
private class TransformerInfo {
}
return mTransformer;
}
return mPrefix;
}
}
}
/**
* a given instance of this list is treated as immutable to simplify sync;
* we pay copying overhead whenever the list is changed rather than every time
* the list is referenced.
* The array is kept in the order the transformers are added via addTransformer
* (first added is 0, last added is length-1)
* Use an array, not a List or other Collection. This keeps the set of classes
* used by this code to a minimum. We want as few dependencies as possible in this
* code, since it is used inside the class definition system. Any class referenced here
* cannot be transformed by Java code.
*/
/***
* Is this TransformerManager for transformers capable of retransformation?
*/
private boolean mIsRetransformable;
}
boolean isRetransformable() {
return mIsRetransformable;
}
public synchronized void
0,
0,
}
public synchronized boolean
boolean found = false;
// look for it in the list, starting at the last added, and remember
// where it was if we found it
int matchingIndex = 0;
found = true;
matchingIndex = x;
break;
}
}
// make a copy of the array without the matching element
if ( found ) {
// copy up to but not including the match
if ( matchingIndex > 0 ) {
0,
0,
}
// if there is anything after the match, copy it as well
if ( matchingIndex < (newLength) ) {
matchingIndex + 1,
(newLength) - matchingIndex);
}
}
return found;
}
synchronized boolean
return true;
}
}
return false;
}
// This function doesn't actually snapshot anything, but should be
// used to set a local variable, which will snapshot the transformer
// list because of the copying semantics of mTransformerList (see
// the comment for mTransformerList).
private TransformerInfo[]
return mTransformerList;
}
public byte[]
byte[] classfileBuffer) {
boolean someoneTouchedTheBytecode = false;
byte[] bufferToUse = classfileBuffer;
// order matters, gotta run 'em in the order they were added
byte[] transformedBytes = null;
try {
}
catch (Throwable t) {
// don't let any one transformer mess it up for the others.
// This is where we need to put some logging. What should go here? FIXME
}
if ( transformedBytes != null ) {
someoneTouchedTheBytecode = true;
}
}
// if someone modified it, return the modified buffer.
// otherwise return null to mean "no transforms occurred"
byte [] result;
if ( someoneTouchedTheBytecode ) {
}
else {
}
return result;
}
int
return transformerList.length;
}
boolean
if ( aTransformer == transformer ) {
return true;
}
}
return false;
}
String[]
}
return prefixes;
}
}