public final class NativeHelper extends java.lang.Object implements INativeHelper
Modifier | Constructor and Description |
---|---|
protected |
NativeHelper()
Create helper.
|
Modifier and Type | Method and 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 main
|
void |
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.
|
public void setAccessible(java.lang.String flagname, java.lang.reflect.AccessibleObject accobj, boolean flag)
setAccessible
in interface INativeHelper
accobj
- The accessible object.flag
- The flag value.public boolean canSetAccessible()
canSetAccessible
in interface INativeHelper
public java.lang.Class<?> defineClass(java.lang.String name, byte[] b, java.lang.ClassLoader loader)
defineClass
in interface INativeHelper
public boolean tryChangeUser(java.lang.String username)
tryChangeUser
in interface INativeHelper
username
- The target user name.public boolean isRootAdmin()
public boolean startInstrumentationAgent(java.lang.String jarfile)
startInstrumentationAgent
in interface INativeHelper
jarfile
- The path to the jar file of the agent.public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception