Package jadex.bytecode.vmhacks
Class NativeHelper
- java.lang.Object
 - 
- jadex.bytecode.vmhacks.NativeHelper
 
 
- 
- All Implemented Interfaces:
 INativeHelper
public final class NativeHelper extends java.lang.Object implements INativeHelper
Helper class using JNA to provide native features. 
- 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedNativeHelper()Create helper. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanSetAccessible()Tests if the setAccessible() method can be used.java.lang.Class<?>defineClass(java.lang.String name, byte[] b, java.lang.ClassLoader loader)Define a class in any ClassLoader.booleanisRootAdmin()Tests if the JVM is running as root/admin.static voidmain(java.lang.String[] args)Test mainvoidsetAccessible(java.lang.String flagname, java.lang.reflect.AccessibleObject accobj, boolean flag)Sets reflective object accessible without checks.booleanstartInstrumentationAgent(java.lang.String jarfile)Method for starting an instrumentation agent.booleantryChangeUser(java.lang.String username)Attempts to change the user of the process to the given name. 
 - 
 
- 
- 
Method Detail
- 
setAccessible
public void setAccessible(java.lang.String flagname, java.lang.reflect.AccessibleObject accobj, boolean flag)Sets reflective object accessible without checks.- Specified by:
 setAccessiblein interfaceINativeHelper- Parameters:
 accobj- The accessible object.flag- The flag value.
 
- 
canSetAccessible
public boolean canSetAccessible()
Tests if the setAccessible() method can be used.- Specified by:
 canSetAccessiblein interfaceINativeHelper- Returns:
 - True, if method can be used.
 
 
- 
defineClass
public java.lang.Class<?> defineClass(java.lang.String name, byte[] b, java.lang.ClassLoader loader)Define a class in any ClassLoader.- Specified by:
 defineClassin interfaceINativeHelper
 
- 
tryChangeUser
public boolean tryChangeUser(java.lang.String username)
Attempts to change the user of the process to the given name.- Specified by:
 tryChangeUserin interfaceINativeHelper- Parameters:
 username- The target user name.- Returns:
 - True, if successful, false if the attempt probably failed.
 
 
- 
isRootAdmin
public boolean isRootAdmin()
Tests if the JVM is running as root/admin.- Returns:
 - True, if running as root.
 
 
- 
startInstrumentationAgent
public boolean startInstrumentationAgent(java.lang.String jarfile)
Method for starting an instrumentation agent.- Specified by:
 startInstrumentationAgentin interfaceINativeHelper- Parameters:
 jarfile- The path to the jar file of the agent.- Returns:
 - True, on successful start.
 
 
- 
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionTest main- Throws:
 java.lang.Exception
 
 - 
 
 -