Class NativeHelper

java.lang.Object
jadex.nativetools.NativeHelper

public final class NativeHelper extends Object
Helper class using JNA to provide native features.
  • Constructor Details

    • NativeHelper

      public NativeHelper()
      Create helper.
  • Method Details

    • setAccessible

      public void setAccessible(AccessibleObject accobj, boolean flag)
      Sets reflective object accessible without checks.
      Parameters:
      accobj - The accessible object.
      flag - The flag value.
    • defineClass

      public Class<?> defineClass(String name, byte[] b, ClassLoader loader)
      Define a class in any ClassLoader.
    • findClass

      public Class<?> findClass(String name)
      Find a class in system classloader.
      Parameters:
      name - Fully-qualified name of class.
      Returns:
      The class.
    • getField

      public Field getField(Class<?> clazz, String fieldname, String type, boolean isstatic)
      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

      public boolean tryChangeUser(String username)
      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

      public boolean startInstrumentationAgent(String jarfile)
      Method for starting an instrumentation agent.
      Parameters:
      jarfile - The path to the jar file of the agent.
      Returns:
      True, on successful start.
    • main

      public static final void main(String[] args) throws Exception
      Test main
      Throws:
      Exception