Package jadex.nativetools
Class NativeHelper
java.lang.Object
jadex.nativetools.NativeHelper
Helper class using JNA to provide native features.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClass
<?> defineClass
(String name, byte[] b, ClassLoader loader) Define a class in any ClassLoader.Class
<?> Find a class in system classloader.Returns the field of a class, overriding security checks.boolean
Tests if the JVM is running as root/admin.static final void
Test mainvoid
setAccessible
(AccessibleObject accobj, boolean flag) Sets reflective object accessible without checks.boolean
startInstrumentationAgent
(String jarfile) Method for starting an instrumentation agent.boolean
tryChangeUser
(String username) Attempts to change the user of the process to the given name.
-
Constructor Details
-
NativeHelper
public NativeHelper()Create helper.
-
-
Method Details
-
setAccessible
Sets reflective object accessible without checks.- Parameters:
accobj
- The accessible object.flag
- The flag value.
-
defineClass
Define a class in any ClassLoader. -
findClass
Find a class in system classloader.- Parameters:
name
- Fully-qualified name of class.- Returns:
- The class.
-
getField
Returns the field of a class, overriding security checks.- Parameters:
clazz
- The class.fieldname
- The field name.type
- The field type in VM notation.isstatic
- If the field is static or not.- Returns:
- The field.
-
tryChangeUser
Attempts to change the user of the process to the given name.- 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
Method for starting an instrumentation agent.- Parameters:
jarfile
- The path to the jar file of the agent.- Returns:
- True, on successful start.
-
main
Test main- Throws:
Exception
-