Class PluginManager

java.lang.Object
org.jrd.backend.decompiling.PluginManager

public class PluginManager extends Object
Executes manages external decompiler wrapper plugins. Wrapper plugins are stored as .java files along with .json file containing classname, wrapper url and dependencies url. When user calls decompile method with decompiler name and bytecode, wrapper plugin gets compiled and executed.
  • Field Details

  • Constructor Details

    • PluginManager

      public PluginManager()
  • Method Details

    • getWrappers

      public List<DecompilerWrapper> getWrappers()
    • loadConfigs

      public void loadConfigs()
      Searches plugin configuration locations and calls loadConfig(file) on files.
    • loadConfigsFromLocation

      private void loadConfigsFromLocation(String location)
    • loadConfig

      private void loadConfig(File file)
      Loads information decompiler json file into ListWrapper.
    • isDecompilableInnerClass

      private boolean isDecompilableInnerClass(String baseClass, String currentClass)
    • decompile

      public String decompile(DecompilerWrapper wrapper, String name, byte[] bytecode, String[] options, VmInfo vmInfo, VmManager vmManager) throws Exception
      Parameters:
      wrapper - decompiler used for decompiling
      name - optional name for decompilers supporting inner classes
      bytecode - bytecode to be decompiled
      options - decompile options
      vmInfo - optional vmInfo to find inner classes
      vmManager - optional vmManager to find inner classes
      Returns:
      Decompiled bytecode or exception String
      Throws:
      Exception - the exception String
    • getBundledCompilerStatus

      public PluginManager.BundledCompilerStatus getBundledCompilerStatus(DecompilerWrapper decompiler)
    • hasBundledCompiler

      public boolean hasBundledCompiler(DecompilerWrapper wrapper)
    • initializeWrapper

      private void initializeWrapper(DecompilerWrapper wrapper)
      Compiles wrapper plugin, loads it into JVM and stores it for later.
    • replace

      public void replace(DecompilerWrapper oldWrapper, DecompilerWrapper newWrapper) throws IOException
      Throws:
      IOException
    • deleteWrapper

      public void deleteWrapper(DecompilerWrapper wrapper)
    • setLocationForNewWrapper

      public void setLocationForNewWrapper(DecompilerWrapper wrapper)
    • compileWrapper

      private int compileWrapper(DecompilerWrapper wrapper, ByteArrayOutputStream errStream)
    • validatePlugin

      public String validatePlugin(DecompilerWrapper plugin)
      Validating the @param plugin using compilation
      Parameters:
      plugin - - plugin to validate
      Returns:
      error message or null
    • createWrapper

      public DecompilerWrapper createWrapper()
    • saveWrapper

      public void saveWrapper(DecompilerWrapper wrapper) throws IOException
      Throws:
      IOException
    • sortWrappers

      private void sortWrappers()
    • urlListToCsv

      private static String urlListToCsv(List<ExpandableUrl> list, String delimiter)
      Converts list of URLs to CSV String
      example: (list){URL1,URL2,URL3} -> (String)URL1:URL2:URL3
    • addWrapper

      public void addWrapper(DecompilerWrapper wrapper)