Package jadex.bytecode.vmhacks
Class VmHacks.Unsafe
- java.lang.Object
- 
- jadex.bytecode.vmhacks.VmHacks.Unsafe
 
- 
- Enclosing class:
- VmHacks
 
 public static final class VmHacks.Unsafe extends java.lang.ObjectAccess to unsafe operations.
- 
- 
Field SummaryFields Modifier and Type Field Description protected static java.io.FileTEMP_JAR_DIRDirectory for temporary jar files.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendToBootstrapClassLoaderSearch(java.lang.String classname, byte[] classcontent)Appends a new class to the bootstrap classloader.voidappendToBootstrapClassLoaderSearch(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.booleanhasAsm()Tests if ASM is available.booleanhasIndirectRedefinition()Checks if redefineClassIndirect() is available.booleanhasInstrumentation()Checks if instrumentation is available.booleanhasNative()Tests if native access is available.protected voidinit()Initialization step after constructor to allow bootstrapping.voidredefineClass(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 voidrunInstrumentationCommand(VmHacks.InstrumentationCommand command)Run an instrumentation commandvoidsetAccessible(java.lang.reflect.AccessibleObject accobj, boolean flag)Sets reflective object accessible without checks if native support is available.java.lang.StringtoString()Debug message.booleantryChangeUser(java.lang.String username)Attempts to change the user of the process to the given name.
 
- 
- 
- 
Method Detail- 
hasAsmpublic boolean hasAsm() Tests if ASM is available.- Returns:
- True, if ASM is available.
 
 - 
hasNativepublic boolean hasNative() Tests if native access is available.- Returns:
- True, if native access is available.
 
 - 
hasInstrumentationpublic boolean hasInstrumentation() Checks if instrumentation is available.- Returns:
- True, if instrumentation is available.
 
 - 
hasIndirectRedefinitionpublic boolean hasIndirectRedefinition() Checks if redefineClassIndirect() is available.- Returns:
- True, if indirect redefinition is available.
 
 - 
tryChangeUserpublic boolean tryChangeUser(java.lang.String username) Attempts to change the user of the process to the given name. If set to null, a list of default user accounts is tried.- Parameters:
- username- The target user name, set to null for a list of default user account.
- Returns:
- True, if successful, false if the attempt probably failed.
 
 - 
setAccessiblepublic void setAccessible(java.lang.reflect.AccessibleObject accobj, boolean flag)Sets reflective object accessible without checks if native support is available.- Parameters:
- accobj- The accessible object.
- flag- The flag value.
 
 - 
defineClasspublic 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.
 - 
redefineClassIndirectpublic java.lang.Class<?> redefineClassIndirect(java.lang.Class<?> clazz, byte[] bytecode)Redefine class byte code. Check HAS_INSTRUMENTATION before use. Uses indirect route via classloader enhancement, more likely to work.- Parameters:
- clazz- Class to be redefined.
- bytecode- The new byte code.
- Returns:
- Redefined class.
 
 - 
redefineClasspublic void redefineClass(java.lang.Class<?> clazz, byte[] bytecode)Redefine class byte code. Check HAS_INSTRUMENTATION before use.- Parameters:
- clazz- Class to be redefined.
- bytecode- The new byte code.
 
 - 
appendToBootstrapClassLoaderSearchpublic void appendToBootstrapClassLoaderSearch(java.lang.String classname, byte[] classcontent)Appends a new class to the bootstrap classloader.- Parameters:
- classname- The class name.
- classcontent- The bytecode.
 
 - 
appendToBootstrapClassLoaderSearchpublic void appendToBootstrapClassLoaderSearch(java.lang.String classname, java.io.InputStream classcontent)Appends a new class to the bootstrap classloader.- Parameters:
- classname- The class name.
- classcontent- The bytecode.
 
 - 
toStringpublic java.lang.String toString() Debug message.- Overrides:
- toStringin class- java.lang.Object
 
 - 
initprotected void init() Initialization step after constructor to allow bootstrapping.
 - 
runInstrumentationCommandprotected void runInstrumentationCommand(VmHacks.InstrumentationCommand command) Run an instrumentation command
 
- 
 
-