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 protected
NativeHelper()
Create helper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canSetAccessible()
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.boolean
isRootAdmin()
Tests if the JVM is running as root/admin.static void
main(java.lang.String[] args)
Test mainvoid
setAccessible(java.lang.String flagname, java.lang.reflect.AccessibleObject accobj, boolean flag)
Sets reflective object accessible without checks.boolean
startInstrumentationAgent(java.lang.String jarfile)
Method for starting an instrumentation agent.boolean
tryChangeUser(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:
setAccessible
in interfaceINativeHelper
- Parameters:
accobj
- The accessible object.flag
- The flag value.
-
canSetAccessible
public boolean canSetAccessible()
Tests if the setAccessible() method can be used.- Specified by:
canSetAccessible
in 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:
defineClass
in interfaceINativeHelper
-
tryChangeUser
public boolean tryChangeUser(java.lang.String username)
Attempts to change the user of the process to the given name.- Specified by:
tryChangeUser
in 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:
startInstrumentationAgent
in 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.Exception
Test main- Throws:
java.lang.Exception
-
-