public static final class VmHacks.Unsafe
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.io.File |
TEMP_JAR_DIR
Directory for temporary jar files.
|
Modifier and Type | Method and Description |
---|---|
void |
appendToBootstrapClassLoaderSearch(java.lang.String classname,
byte[] classcontent)
Appends a new class to the bootstrap classloader.
|
void |
appendToBootstrapClassLoaderSearch(java.lang.String classname,
java.io.InputStream classcontent)
Appends a new class to the bootstrap classloader.
|
java.lang.Class<?> |
defineClass(java.lang.String name,
byte[] b,
int off,
int len,
java.lang.ClassLoader loader,
java.security.ProtectionDomain pd)
Access to sun.misc.Unsafe or equivalent.
|
boolean |
hasAsm()
Tests if ASM is available.
|
boolean |
hasIndirectRedefinition()
Checks if redefineClassIndirect() is available.
|
boolean |
hasInstrumentation()
Checks if instrumentation is available.
|
boolean |
hasNative()
Tests if native access is available.
|
protected void |
init()
Initialization step after constructor to allow bootstrapping.
|
void |
redefineClass(java.lang.Class<?> clazz,
byte[] bytecode)
Redefine class byte code.
|
java.lang.Class<?> |
redefineClassIndirect(java.lang.Class<?> clazz,
byte[] bytecode)
Redefine class byte code.
|
protected void |
runInstrumentationCommand(VmHacks.InstrumentationCommand command)
Run an instrumentation command
|
void |
setAccessible(java.lang.reflect.AccessibleObject accobj,
boolean flag)
Sets reflective object accessible without checks if native support is available.
|
java.lang.String |
toString()
Debug message.
|
boolean |
tryChangeUser(java.lang.String username)
Attempts to change the user of the process to the given name.
|
protected static final java.io.File TEMP_JAR_DIR
public boolean hasAsm()
public boolean hasNative()
public boolean hasInstrumentation()
public boolean hasIndirectRedefinition()
public boolean tryChangeUser(java.lang.String username)
username
- The target user name, set to null for a list of default user account.public void setAccessible(java.lang.reflect.AccessibleObject accobj, boolean flag)
accobj
- The accessible object.flag
- The flag value.public java.lang.Class<?> defineClass(java.lang.String name, byte[] b, int off, int len, java.lang.ClassLoader loader, java.security.ProtectionDomain pd)
public java.lang.Class<?> redefineClassIndirect(java.lang.Class<?> clazz, byte[] bytecode)
clazz
- Class to be redefined.bytecode
- The new byte code.public void redefineClass(java.lang.Class<?> clazz, byte[] bytecode)
clazz
- Class to be redefined.bytecode
- The new byte code.public void appendToBootstrapClassLoaderSearch(java.lang.String classname, byte[] classcontent)
classname
- The class name.classcontent
- The bytecode.public void appendToBootstrapClassLoaderSearch(java.lang.String classname, java.io.InputStream classcontent)
classname
- The class name.classcontent
- The bytecode.public java.lang.String toString()
toString
in class java.lang.Object
protected void init()
protected void runInstrumentationCommand(VmHacks.InstrumentationCommand command)