io.earcam.instrumental.agent.InstrumentationWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of io.earcam.instrumental.agent Show documentation
Show all versions of io.earcam.instrumental.agent Show documentation
Dynamically load a Java Agent or acquire java.lang.instrument.Instrumentation via SPI
The newest version!
/*-
* #%L
* io.earcam.instrumental.agent
* %%
* Copyright (C) 2018 earcam
* %%
* SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT)
*
* You must choose to accept, in full - any individual or combination of
* the following licenses:
*
* - BSD-3-Clause
* - EPL-1.0
* - Apache-2.0
* - MIT
*
* #L%
*/
package io.earcam.instrumental.agent;
import java.lang.instrument.ClassDefinition;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import java.util.jar.JarFile;
/**
*
* InstrumentationWrapper class.
*
*
*/
public class InstrumentationWrapper implements Instrumentation {
private volatile Instrumentation delegate;
/**
*
* Setter for the field delegate
.
*
*
* @param delegate a {@link java.lang.instrument.Instrumentation} object.
*/
protected void setDelegate(Instrumentation delegate)
{
this.delegate = delegate;
}
/**
*
* Getter for the field delegate
.
*
*
* @return a {@link java.lang.instrument.Instrumentation} object.
*/
protected Instrumentation getDelegate()
{
return delegate;
}
@Override
public void addTransformer(ClassFileTransformer transformer, boolean canRetransform)
{
delegate.addTransformer(transformer, canRetransform);
}
@Override
public void addTransformer(ClassFileTransformer transformer)
{
delegate.addTransformer(transformer);
}
@Override
public boolean removeTransformer(ClassFileTransformer transformer)
{
return delegate.removeTransformer(transformer);
}
@Override
public boolean isRetransformClassesSupported()
{
return delegate.isRetransformClassesSupported();
}
@Override
public void retransformClasses(Class>... classes) throws UnmodifiableClassException
{
delegate.retransformClasses(classes);
}
@Override
public boolean isRedefineClassesSupported()
{
return delegate.isRedefineClassesSupported();
}
@Override
public void redefineClasses(ClassDefinition... definitions) throws ClassNotFoundException, UnmodifiableClassException
{
delegate.redefineClasses(definitions);
}
@Override
public boolean isModifiableClass(Class> theClass)
{
return delegate.isModifiableClass(theClass);
}
@Override
public Class>[] getAllLoadedClasses()
{
return delegate.getAllLoadedClasses();
}
@Override
public Class>[] getInitiatedClasses(ClassLoader loader)
{
return delegate.getInitiatedClasses(loader);
}
@Override
public long getObjectSize(Object objectToSize)
{
return delegate.getObjectSize(objectToSize);
}
@Override
public void appendToBootstrapClassLoaderSearch(JarFile jarfile)
{
delegate.appendToBootstrapClassLoaderSearch(jarfile);
}
@Override
public void appendToSystemClassLoaderSearch(JarFile jarfile)
{
delegate.appendToSystemClassLoaderSearch(jarfile);
}
@Override
public boolean isNativeMethodPrefixSupported()
{
return delegate.isNativeMethodPrefixSupported();
}
@Override
public void setNativeMethodPrefix(ClassFileTransformer transformer, String prefix)
{
delegate.setNativeMethodPrefix(transformer, prefix);
}
}