From 82388a66d167133686f5c5f73eae05a54d0fdf55 Mon Sep 17 00:00:00 2001 From: Jiri Date: Wed, 14 Feb 2024 17:59:59 +0100 Subject: [PATCH 1/5] Modules and theirs loaders are now shown in detailed info the module loader seesm to be same as classloader,so candidate to drop --- .../main/java/org/jrd/agent/AgentLogger.java | 8 + .../jrd/agent/InstrumentationProvider.java | 21 ++- .../jrd/backend/communication/FsAgent.java | 8 +- .../java/org/jrd/backend/core/ClassInfo.java | 25 ++- .../java/org/jrd/backend/data/cli/Lib.java | 4 +- .../BytecodeDecompilerView.java | 2 +- .../main/decompilerview/ClassOverwriter.java | 2 +- .../DecompilationController.java | 2 +- .../main/renderer/ClassListRenderer.java | 23 ++- .../java/org/kcc/wordsets/JrdApiKeywords.java | 151 +----------------- 10 files changed, 90 insertions(+), 156 deletions(-) diff --git a/decompiler_agent/src/main/java/org/jrd/agent/AgentLogger.java b/decompiler_agent/src/main/java/org/jrd/agent/AgentLogger.java index 93bfe0c9d..0e1f1c698 100644 --- a/decompiler_agent/src/main/java/org/jrd/agent/AgentLogger.java +++ b/decompiler_agent/src/main/java/org/jrd/agent/AgentLogger.java @@ -39,4 +39,12 @@ public static String classLoaderId(ClassLoader cl) { return cl.toString(); } } + + public static String moduleId(Module cl) { + if (cl == null) { + return "unknown"; + } else { + return cl.getName(); + } + } } diff --git a/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java b/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java index 0f0e7a99a..d8c482b80 100644 --- a/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java +++ b/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java @@ -123,14 +123,33 @@ public void getClasses(BlockingQueue queue, Boolean abort, boolean doGet if (found) { if (doGetInfo) { String location; + String module; + String moduleloader; try { location = loadedClass.getProtectionDomain().getCodeSource().getLocation().getPath(); } catch (Exception ex) { location = "unknown"; } + try { + module = AgentLogger.moduleId(loadedClass.getModule()); + } catch (Exception ex) { + module = "unknown"; + } + try { + if (loadedClass.getModule()!=null) { + moduleloader = AgentLogger.classLoaderId(loadedClass.getModule().getClassLoader()); + } else { + moduleloader = "unknown"; + } + } catch (Exception ex) { + moduleloader = "unknown"; + } String classLoader; classLoader = AgentLogger.classLoaderId(loadedClass.getClassLoader()); - queue.put(className + INFO_DELIMITER + location + INFO_DELIMITER + classLoader); + queue.put( + className + INFO_DELIMITER + location + INFO_DELIMITER + classLoader + INFO_DELIMITER + module + + INFO_DELIMITER + moduleloader + ); } else { queue.put(className); } diff --git a/runtime-decompiler/src/main/java/org/jrd/backend/communication/FsAgent.java b/runtime-decompiler/src/main/java/org/jrd/backend/communication/FsAgent.java index e7f7af7e8..d73095eca 100644 --- a/runtime-decompiler/src/main/java/org/jrd/backend/communication/FsAgent.java +++ b/runtime-decompiler/src/main/java/org/jrd/backend/communication/FsAgent.java @@ -291,8 +291,12 @@ private static void addJustClass(String s, List classes, String root, bo if (s.endsWith(".class")) { if (details) { classes.add( - new ClassInfo(toClass(s.substring(root.length() + 1)), detailsPath, "class order in realvm may differ") - .toAgentLikeAnswer() + new ClassInfo( + toClass(s.substring(root.length() + 1)), + detailsPath, + "class order in realvm may differ", + "unknown", + "unknown").toAgentLikeAnswer() ); } else { classes.add(toClass(s.substring(root.length() + 1))); diff --git a/runtime-decompiler/src/main/java/org/jrd/backend/core/ClassInfo.java b/runtime-decompiler/src/main/java/org/jrd/backend/core/ClassInfo.java index d2c0d6709..0e8dd2bcf 100644 --- a/runtime-decompiler/src/main/java/org/jrd/backend/core/ClassInfo.java +++ b/runtime-decompiler/src/main/java/org/jrd/backend/core/ClassInfo.java @@ -7,15 +7,18 @@ public class ClassInfo { private String name; private String location; private String classLoader; + private String module; + private String moduleLoader; private static final String INFO_DELIMITER_STRING = "|"; private static final Pattern INFO_DELIMITER_PATTERN = Pattern.compile("\\" + INFO_DELIMITER_STRING); - public ClassInfo(String name, String location, String classLoader) { + public ClassInfo(String name, String location, String classLoader, String module, String moduleLoader) { this.name = name; this.location = location; this.classLoader = classLoader; - + this.module = module; + this.moduleLoader = moduleLoader; } public ClassInfo(String classString) { @@ -33,6 +36,16 @@ public ClassInfo(String classString) { } else { // backwards compatibility this.classLoader = "unknown"; } + if (splitClassString.length >= 4 && !splitClassString[3].trim().isEmpty()) { + this.module = splitClassString[3]; + } else { // backwards compatibility + this.module = "unknown"; + } + if (splitClassString.length >= 5 && !splitClassString[4].trim().isEmpty()) { + this.moduleLoader = splitClassString[4]; + } else { // backwards compatibility + this.moduleLoader = "unknown"; + } } public String toAgentLikeAnswer() { @@ -59,6 +72,14 @@ public String getClassLoader() { return classLoader; } + public String getModule() { + return module; + } + + public String getModuleLoader() { + return moduleLoader; + } + public String getSearchableString(boolean isLocationVisible) { return isLocationVisible ? (name + " " + location + " " + classLoader) : name; } diff --git a/runtime-decompiler/src/main/java/org/jrd/backend/data/cli/Lib.java b/runtime-decompiler/src/main/java/org/jrd/backend/data/cli/Lib.java index 24f7e5ded..f08416824 100644 --- a/runtime-decompiler/src/main/java/org/jrd/backend/data/cli/Lib.java +++ b/runtime-decompiler/src/main/java/org/jrd/backend/data/cli/Lib.java @@ -168,13 +168,13 @@ public static List obtainFilteredClasses( .collect(Collectors.toList()); } else { allClasses = Arrays.stream(searchClasses(vmInfo, vmManager, ecodedSearch, filter.get(0).pattern(), classloader)) - .map(a -> new ClassInfo(a, null, null)).collect(Collectors.toList()); + .map(a -> new ClassInfo(a, null, null, null, null)).collect(Collectors.toList()); } } else { if (details) { allClasses = Arrays.stream(obtainClassesDetails(vmInfo, vmManager, classloader)).collect(Collectors.toList()); } else { - allClasses = Arrays.stream(obtainClasses(vmInfo, vmManager, classloader)).map(a -> new ClassInfo(a, null, null)) + allClasses = Arrays.stream(obtainClasses(vmInfo, vmManager, classloader)).map(a -> new ClassInfo(a, null, null, null, null)) .collect(Collectors.toList()); } } diff --git a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/BytecodeDecompilerView.java b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/BytecodeDecompilerView.java index d0eb9cac1..2cebba779 100644 --- a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/BytecodeDecompilerView.java +++ b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/BytecodeDecompilerView.java @@ -148,7 +148,7 @@ public class BytecodeDecompilerView { private DependenciesReader dependenciesReader; private ClassInfo[] loadedClasses; - private ClassInfo lastDecompiledClass = new ClassInfo("", "unknown", "unknown"); + private ClassInfo lastDecompiledClass = new ClassInfo("", "unknown", "unknown", "unknown", "unknown"); private String lastFqn = "java.lang.Override"; private String lastAddedFqn = "fully.qualified.name"; private File lastAddedFile = new File("."); diff --git a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/ClassOverwriter.java b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/ClassOverwriter.java index 711c167a9..a1e6939b7 100644 --- a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/ClassOverwriter.java +++ b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/ClassOverwriter.java @@ -18,7 +18,7 @@ void overwriteClass(DecompilerWrapper selectedDecompiler, ClassInfo name, String if (name == null) { throw new RuntimeException("null name, in overwriteClass"); } else if (name.getName() == null || name.getName().trim().isEmpty()) { - name = new ClassInfo("???", name.getLocation(), name.getClassLoader()); + name = new ClassInfo("???", name.getLocation(), name.getClassLoader(), "???", "???"); } final OverwriteClassDialog overwriteClassDialog = new OverwriteClassDialog( diff --git a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/DecompilationController.java b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/DecompilationController.java index e52080263..2b5e90538 100644 --- a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/DecompilationController.java +++ b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/DecompilationController.java @@ -332,7 +332,7 @@ private void cleanup(boolean halt) { mainFrameView.switchPanel(false); mainFrameView.getBytecodeDecompilerView().reloadClassList(new ClassInfo[0]); mainFrameView.getBytecodeDecompilerView() - .reloadTextField(new ClassInfo("", "", ""), "", new byte[16], "", new byte[16], null, null); + .reloadTextField(new ClassInfo("", "", "", "", ""), "", new byte[16], "", new byte[16], null, null); if (halt) { haltAgent(); } diff --git a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/renderer/ClassListRenderer.java b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/renderer/ClassListRenderer.java index e9a111a0e..095807fc6 100644 --- a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/renderer/ClassListRenderer.java +++ b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/renderer/ClassListRenderer.java @@ -18,17 +18,23 @@ public class ClassListRenderer extends JPanel implements ListCellRenderer Date: Sat, 17 Feb 2024 11:06:05 +0100 Subject: [PATCH 2/5] Restored JrdApiKeywords --- .../java/org/kcc/wordsets/JrdApiKeywords.java | 151 +++++++++++++++++- 1 file changed, 143 insertions(+), 8 deletions(-) diff --git a/runtime-decompiler/src/main/java/org/kcc/wordsets/JrdApiKeywords.java b/runtime-decompiler/src/main/java/org/kcc/wordsets/JrdApiKeywords.java index 8854de39d..3b18d8719 100644 --- a/runtime-decompiler/src/main/java/org/kcc/wordsets/JrdApiKeywords.java +++ b/runtime-decompiler/src/main/java/org/kcc/wordsets/JrdApiKeywords.java @@ -32,15 +32,150 @@ public class JrdApiKeywords implements CompletionItem.CompletionItemSet { private static final String CLAZZS_UNBOUND = "\nThis call is lacking initial Class, and is trying to detect it." + "It is not always what you require\n"; private static final String GLOBAL = "Global fields and methods are unbound.\n" + - "They represents C/Pascal const wittou namesapce so you can access them globally.\n" + "It is simple pair name/value.\n\n"; + "They represents C/Pascal const wittou namesapce so you can access them globally.\n" + + "It is simple pair name/value.\n\n"; - private static final CompletionItem[] BASE_JRDAPI_KEYWORDS = - new CompletionItem[]{new CompletionItem( - "org.jrd.agent.api.Variables.NoSuchFakeVariableException", - "exception cast from " + - "eg methods which are getting/setting/removing new field/method but are not allowed to create.\n" + - "Extends FakeVariableException" - ), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Local.create(Object, String, Object));", INTRO + LOCAL + SAFE + "Allows you to create local field/method in object(1st param) of String name of " + "Object(third param)" + "initial value. Will throw FakeVariableAlreadyDeclaredException if that variable " + "already exists.\n" + "it returns freshly created field (the 3rd argument)"), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Local.get(Object, String));", INTRO + LOCAL + SAFE + "get the value of stored local field/method in object(1st param) of String name of " + "Object(second param). Will throw NoSuchFakeVariableException if that variable " + "do not already exists."), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Local.getOrCreate(Object, String, Object));", INTRO + LOCAL + SAFE + "Allows you to adjust/create local field/method in object(1st param) of String name of " + "Object(third param)" + "initial value. If that variable already exists, will be rewritten.\n" + "it returns freshly created field (the 3rd argument)"), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Local.remove(Object, String));", INTRO + LOCAL + SAFE + "Will remove the declared fake method/variable " + "of name String from instance of Object"), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Local.set(Object, String, Object));", INTRO + LOCAL + SAFE + "Will set the variable/method of String name to instance of Object (first param) to value of " + "Object (3rd param). Unlike create, it do not throw exception if the field is already created. " + "If field is not created, it will be. Returns freshly inserted value."), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Local.setNoReplace(Object, String, Object));", INTRO + LOCAL + SAFE + "Will set the variable/method of String name to instance of Object (first param) to value of " + "Object (3rd param). Unlike create, it do not throw exception if the field is already created. " + "But unlike set, if it already exists, it throws FakeVariableAlreadyDeclaredException if the " + "variable/method is already set. Returns freshly inserted value."), new CompletionItem("(String)(org.jrd.agent.api.Variables.Local.dump());", "Will dump to String all safe, local variables/methods currently declared"), new CompletionItem("(String)(org.jrd.agent.api.Variables.Local.dump(Object...));", "Will dump to String all safe, local variables/methods currently " + "declared in selected Object...s"), new CompletionItem("org.jrd.agent.api.Variables.Local.destroy();", "Will remove all safe, local variables/methods currently declared"), new CompletionItem("org.jrd.agent.api.Variables.Local.removeAll(Object);", "Will remove all safe, local variables/methods bound to given Object"), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Global.create(String, Object));", INTRO + GLOBAL + SAFE + "Allows you to create global field/method of String name of Object(second param)" + "initial value. Will throw FakeVariableAlreadyDeclaredException if that variable " + "already exists.\n" + "it returns freshly created field (the 2nf argument)"), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Global.get(String));", INTRO + GLOBAL + SAFE + "get the value of stored global field/method of String name" + "). Will throw NoSuchFakeVariableException if that variable " + "do not already exists."), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Global.getOrCreate(String, Object));", INTRO + GLOBAL + SAFE + "Allows you to adjust/create global field/method of String name of Object(seconf param)" + "initial value. If that variable already exists, will be rewritten.\n" + "it returns freshly created field (the 2nd argument)"), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Global.remove(String));", INTRO + GLOBAL + SAFE + "Will remove the declared fake method/variable " + "of name String from global scope"), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Global.set(String, Object));", INTRO + GLOBAL + SAFE + "Will set the global variable/method of String name to value of " + "Object (2nd param). Unlike create, it do not throw exception if the field is already created. " + "If field is not created, it will be. Returns freshly inserted value."), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Global.setNoReplace(String, Object));", INTRO + GLOBAL + SAFE + "Will set the global variable/method of String name to value of " + "Object (2nd param). Unlike create, it do not throw exception if the field is already created. " + "But unlike set, if it already exists, it throws FakeVariableAlreadyDeclaredException if the " + "variable/method is already set. Returns freshly inserted value."), new CompletionItem("(String)(org.jrd.agent.api.Variables.Global.dump());", INTRO + GLOBAL + SAFE + "Will dump to String all safe, global variables/methods currently declared"), new CompletionItem("org.jrd.agent.api.Variables.Global.removeAll();", INTRO + GLOBAL + SAFE + "Will remove all safe, global variables/methods." + "It is moreover equal to destroy method of Clazzs anf Locals."), new CompletionItem("org.jrd.agent.api.Variables.FakeVariableException", "Generic forefather for all fake values exceptions"), new CompletionItem("org.jrd.agent.api.Variables.FakeVariableAlreadyDeclaredException", "exception cast from " + "eg methods which are creating/setting new field/method but are not allowed to replace.\n" + "Extends FakeVariableException"), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.create(Class, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.create(String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.create(String, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.get(Class, String));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.get(String));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.get(String, String));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.getOrCreate(Class, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.getOrCreate(String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.getOrCreate(String, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.remove(Class, String));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.remove(String));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.remove(String, String));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.set(Class, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.set(String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.set(String, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.setNoReplace(Class, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.setNoReplace(String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.setNoReplace(String, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(String)(org.jrd.agent.api.Variables.Clazzs.dump());", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(String)(org.jrd.agent.api.Variables.Clazzs.dump(Class...));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("org.jrd.agent.api.Variables.Clazzs.destroy();", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("org.jrd.agent.api.Variables.Clazzs.removeAll();", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("org.jrd.agent.api.Variables.Clazzs.removeAll(Class);", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("org.jrd.agent.api.Variables.Clazzs.removeAll(String);", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + "This calls classForName on String."), new CompletionItem("(String)(org.jrd.agent.api.Variables.dumpAll());", "Will dump to String all safe variables currently declared"), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Local.create(Object, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Local.get(Object, String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Local.getOrCreate(Object, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Local.remove(Object, String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Local.set(Object, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Local.setNoReplace(Object, String, Object));", UNSAFE), new CompletionItem("(String)(org.jrd.agent.api.UnsafeVariables.Local.dump());", UNSAFE), new CompletionItem("org.jrd.agent.api.UnsafeVariables.Local.destroy();", UNSAFE), new CompletionItem("org.jrd.agent.api.UnsafeVariables.Local.removeAll(Object);", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Global.create(String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Global.get(String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Global.getOrCreate(String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Global.remove(String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Global.set(String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Global.setNoReplace(String, Object));", UNSAFE), new CompletionItem("(String)(org.jrd.agent.api.UnsafeVariables.Global.dump());", UNSAFE), new CompletionItem("org.jrd.agent.api.UnsafeVariables.Global.removeAll();", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.create(Class, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.create(String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.create(String, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.get(Class, String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.get(String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.get(String, String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.getOrCreate(Class, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.getOrCreate(String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.getOrCreate(String, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.remove(Class, String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.remove(String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.remove(String, String));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.set(Class, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.set(String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.set(String, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.setNoReplace(Class, String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.setNoReplace(String, Object));", UNSAFE), new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.setNoReplace(String, String, Object));", UNSAFE), new CompletionItem("(String)(org.jrd.agent.api.UnsafeVariables.Clazzs.dump());", UNSAFE), new CompletionItem("org.jrd.agent.api.UnsafeVariables.Clazzs.destroy();", UNSAFE), new CompletionItem("org.jrd.agent.api.UnsafeVariables.Clazzs.removeAll();", UNSAFE), new CompletionItem("org.jrd.agent.api.UnsafeVariables.Clazzs.removeAll(Class);", UNSAFE), new CompletionItem("org.jrd.agent.api.UnsafeVariables.Clazzs.removeAll(String);", UNSAFE), new CompletionItem("(String)(org.jrd.agent.api.UnsafeVariables.dumpAll());", "Will dump to String all unsafe variables currently declared")}; + private static final CompletionItem[] BASE_JRDAPI_KEYWORDS = new CompletionItem[]{new CompletionItem( + "org.jrd.agent.api.Variables.NoSuchFakeVariableException", + "exception cast from " + "eg methods which are getting/setting/removing new field/method but are not allowed to create.\n" + + "Extends FakeVariableException"), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Local.create(Object, String, Object));", + INTRO + LOCAL + SAFE + "Allows you to create local field/method in object(1st param) of String name of " + + "Object(third param)" + "initial value. Will throw FakeVariableAlreadyDeclaredException if that variable " + + "already exists.\n" + "it returns freshly created field (the 3rd argument)"), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Local.get(Object, String));", + INTRO + LOCAL + SAFE + "get the value of stored local field/method in object(1st param) of String name of " + + "Object(second param). Will throw NoSuchFakeVariableException if that variable " + "do not already exists."), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Local.getOrCreate(Object, String, Object));", + INTRO + LOCAL + SAFE + "Allows you to adjust/create local field/method in object(1st param) of String name of " + + "Object(third param)" + "initial value. If that variable already exists, will be rewritten.\n" + + "it returns freshly created field (the 3rd argument)"), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Local.remove(Object, String));", + INTRO + LOCAL + SAFE + "Will remove the declared fake method/variable " + "of name String from instance of Object"), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Local.set(Object, String, Object));", INTRO + LOCAL + SAFE + + "Will set the variable/method of String name to instance of Object (first param) to value of " + + "Object (3rd param). Unlike create, it do not throw exception if the field is already created. " + + "If field is not created, it will be. Returns freshly inserted value."), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Local.setNoReplace(Object, String, Object));", + INTRO + LOCAL + SAFE + "Will set the variable/method of String name to instance of Object (first param) to value of " + + "Object (3rd param). Unlike create, it do not throw exception if the field is already created. " + + "But unlike set, if it already exists, it throws FakeVariableAlreadyDeclaredException if the " + + "variable/method is already set. Returns freshly inserted value."), new CompletionItem( + "(String)(org.jrd.agent.api.Variables.Local.dump());", + "Will dump to String all safe, local variables/methods currently declared"), new CompletionItem( + "(String)(org.jrd.agent.api.Variables.Local.dump(Object...));", + "Will dump to String all safe, local variables/methods currently " + "declared in selected Object...s"), + new CompletionItem("org.jrd.agent.api.Variables.Local.destroy();", + "Will remove all safe, local variables/methods currently declared"), new CompletionItem( + "org.jrd.agent.api.Variables.Local.removeAll(Object);", + "Will remove all safe, local variables/methods bound to given Object"), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Global.create(String, Object));", + INTRO + GLOBAL + SAFE + "Allows you to create global field/method of String name of Object(second param)" + + "initial value. Will throw FakeVariableAlreadyDeclaredException if that variable " + "already exists.\n" + + "it returns freshly created field (the 2nf argument)"), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Global.get(String));", + INTRO + GLOBAL + SAFE + "get the value of stored global field/method of String name" + + "). Will throw NoSuchFakeVariableException if that variable " + "do not already exists."), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Global.getOrCreate(String, Object));", + INTRO + GLOBAL + SAFE + "Allows you to adjust/create global field/method of String name of Object(seconf param)" + + "initial value. If that variable already exists, will be rewritten.\n" + + "it returns freshly created field (the 2nd argument)"), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Global.remove(String));", + INTRO + GLOBAL + SAFE + "Will remove the declared fake method/variable " + "of name String from global scope"), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Global.set(String, Object));", + INTRO + GLOBAL + SAFE + "Will set the global variable/method of String name to value of " + + "Object (2nd param). Unlike create, it do not throw exception if the field is already created. " + + "If field is not created, it will be. Returns freshly inserted value."), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Global.setNoReplace(String, Object));", + INTRO + GLOBAL + SAFE + "Will set the global variable/method of String name to value of " + + "Object (2nd param). Unlike create, it do not throw exception if the field is already created. " + + "But unlike set, if it already exists, it throws FakeVariableAlreadyDeclaredException if the " + + "variable/method is already set. Returns freshly inserted value."), new CompletionItem( + "(String)(org.jrd.agent.api.Variables.Global.dump());", + INTRO + GLOBAL + SAFE + "Will dump to String all safe, global variables/methods currently declared"), new CompletionItem( + "org.jrd.agent.api.Variables.Global.removeAll();", + INTRO + GLOBAL + SAFE + "Will remove all safe, global variables/methods." + + "It is moreover equal to destroy method of Clazzs anf Locals."), new CompletionItem( + "org.jrd.agent.api.Variables.FakeVariableException", "Generic forefather for all fake values exceptions"), + new CompletionItem("org.jrd.agent.api.Variables.FakeVariableAlreadyDeclaredException", + "exception cast from " + "eg methods which are creating/setting new field/method but are not allowed to replace.\n" + + "Extends FakeVariableException"), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.create(Class, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.create(String, Object));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.create(String, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.get(Class, String));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.get(String));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.get(String, String));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.getOrCreate(Class, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.getOrCreate(String, Object));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.getOrCreate(String, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.remove(Class, String));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.remove(String));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.remove(String, String));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.set(Class, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.set(String, Object));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.set(String, String, Object));", INTRO + CLAZZS + SAFE + CLAZZS_FINAL), + new CompletionItem("(Object)(org.jrd.agent.api.Variables.Clazzs.setNoReplace(Class, String, Object));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.setNoReplace(String, Object));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL + CLAZZS_UNBOUND), new CompletionItem( + "(Object)(org.jrd.agent.api.Variables.Clazzs.setNoReplace(String, String, Object));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(String)(org.jrd.agent.api.Variables.Clazzs.dump());", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("(String)(org.jrd.agent.api.Variables.Clazzs.dump(Class...));", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("org.jrd.agent.api.Variables.Clazzs.destroy();", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("org.jrd.agent.api.Variables.Clazzs.removeAll();", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("org.jrd.agent.api.Variables.Clazzs.removeAll(Class);", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL), new CompletionItem("org.jrd.agent.api.Variables.Clazzs.removeAll(String);", + INTRO + CLAZZS + SAFE + CLAZZS_FINAL + "This calls classForName on String."), new CompletionItem( + "(String)(org.jrd.agent.api.Variables.dumpAll());", "Will dump to String all safe variables currently declared"), + new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Local.create(Object, String, Object));", UNSAFE), + new CompletionItem("(Object)(org.jrd.agent.api.UnsafeVariables.Local.get(Object, String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Local.getOrCreate(Object, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Local.remove(Object, String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Local.set(Object, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Local.setNoReplace(Object, String, Object));", UNSAFE), new CompletionItem( + "(String)(org.jrd.agent.api.UnsafeVariables.Local.dump());", UNSAFE), new CompletionItem( + "org.jrd.agent.api.UnsafeVariables.Local.destroy();", UNSAFE), new CompletionItem( + "org.jrd.agent.api.UnsafeVariables.Local.removeAll(Object);", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Global.create(String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Global.get(String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Global.getOrCreate(String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Global.remove(String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Global.set(String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Global.setNoReplace(String, Object));", UNSAFE), new CompletionItem( + "(String)(org.jrd.agent.api.UnsafeVariables.Global.dump());", UNSAFE), new CompletionItem( + "org.jrd.agent.api.UnsafeVariables.Global.removeAll();", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.create(Class, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.create(String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.create(String, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.get(Class, String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.get(String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.get(String, String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.getOrCreate(Class, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.getOrCreate(String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.getOrCreate(String, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.remove(Class, String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.remove(String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.remove(String, String));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.set(Class, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.set(String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.set(String, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.setNoReplace(Class, String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.setNoReplace(String, Object));", UNSAFE), new CompletionItem( + "(Object)(org.jrd.agent.api.UnsafeVariables.Clazzs.setNoReplace(String, String, Object));", UNSAFE), new CompletionItem( + "(String)(org.jrd.agent.api.UnsafeVariables.Clazzs.dump());", UNSAFE), new CompletionItem( + "org.jrd.agent.api.UnsafeVariables.Clazzs.destroy();", UNSAFE), new CompletionItem( + "org.jrd.agent.api.UnsafeVariables.Clazzs.removeAll();", UNSAFE), new CompletionItem( + "org.jrd.agent.api.UnsafeVariables.Clazzs.removeAll(Class);", UNSAFE), new CompletionItem( + "org.jrd.agent.api.UnsafeVariables.Clazzs.removeAll(String);", UNSAFE), new CompletionItem( + "(String)(org.jrd.agent.api.UnsafeVariables.dumpAll());", "Will dump to String all unsafe variables currently declared")}; private static final CompletionItem[] JRDAPI_KEYWORDS = JavaKeywordsWithHelp.concatWithArrayCopy(JavaKeywordsWithHelp.EXT_JAVA_KEYWORDS, BASE_JRDAPI_KEYWORDS); From 277f1856117b11c16afca2d21439cd1cc8127c7b Mon Sep 17 00:00:00 2001 From: Jiri Date: Sat, 17 Feb 2024 11:46:49 +0100 Subject: [PATCH 3/5] Search now search also in module names --- .../decompilerview/BytecodeDecompilerView.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/BytecodeDecompilerView.java b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/BytecodeDecompilerView.java index 2cebba779..2dd3b0144 100644 --- a/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/BytecodeDecompilerView.java +++ b/runtime-decompiler/src/main/java/org/jrd/frontend/frame/main/decompilerview/BytecodeDecompilerView.java @@ -856,6 +856,20 @@ private boolean matchesAny(List filtered, Pattern p, ClassInfo clazz) return true; } } + if (clazz.getModule() != null) { + Matcher m = p.matcher(clazz.getModule()); + if (m.matches()) { + filtered.add(clazz); + return true; + } + } + if (clazz.getModuleLoader() != null) { + Matcher m = p.matcher(clazz.getModuleLoader()); + if (m.matches()) { + filtered.add(clazz); + return true; + } + } return false; } From 71e166be327ce14fb28aa427aebb558cd5aef151 Mon Sep 17 00:00:00 2001 From: Jiri Date: Sat, 17 Feb 2024 11:47:38 +0100 Subject: [PATCH 4/5] Module load now cathces throwable so it can work on jd8 without reflection --- .../main/java/org/jrd/agent/InstrumentationProvider.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java b/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java index d8c482b80..ce95eee22 100644 --- a/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java +++ b/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java @@ -127,21 +127,21 @@ public void getClasses(BlockingQueue queue, Boolean abort, boolean doGet String moduleloader; try { location = loadedClass.getProtectionDomain().getCodeSource().getLocation().getPath(); - } catch (Exception ex) { + } catch (Throwable ex) { location = "unknown"; } try { module = AgentLogger.moduleId(loadedClass.getModule()); - } catch (Exception ex) { + } catch (Throwable ex) { module = "unknown"; } try { - if (loadedClass.getModule()!=null) { + if (loadedClass.getModule() != null) { moduleloader = AgentLogger.classLoaderId(loadedClass.getModule().getClassLoader()); } else { moduleloader = "unknown"; } - } catch (Exception ex) { + } catch (Throwable ex) { moduleloader = "unknown"; } String classLoader; From e9d840547cacf7cb9d62f3a24c6880a718ff1f7a Mon Sep 17 00:00:00 2001 From: Jiri Date: Sat, 17 Feb 2024 11:48:08 +0100 Subject: [PATCH 5/5] agent prins port on attach and detach --- .../org/jrd/agent/ConnectionDelegator.java | 2 +- .../jrd/agent/InstrumentationProvider.java | 6 +++-- .../src/main/java/org/jrd/agent/Main.java | 22 +++++++++---------- .../jrd/backend/communication/FsAgent.java | 8 +++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/decompiler_agent/src/main/java/org/jrd/agent/ConnectionDelegator.java b/decompiler_agent/src/main/java/org/jrd/agent/ConnectionDelegator.java index 2da37610d..c7dc5f807 100644 --- a/decompiler_agent/src/main/java/org/jrd/agent/ConnectionDelegator.java +++ b/decompiler_agent/src/main/java/org/jrd/agent/ConnectionDelegator.java @@ -46,7 +46,7 @@ public static synchronized void initialize(String hostname, Integer port, Instru initServerSocket.bind(new InetSocketAddress(hostname, port)); } catch (IOException e) { try { - Main.deregister(loneliness); + Main.deregister(loneliness, port + ""); } finally { AgentLogger.getLogger().log(new RuntimeException("Exception occurred when opening the socket: ", e)); throw e; diff --git a/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java b/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java index ce95eee22..666023487 100644 --- a/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java +++ b/decompiler_agent/src/main/java/org/jrd/agent/InstrumentationProvider.java @@ -25,12 +25,14 @@ public class InstrumentationProvider { private final Transformer transformer; private final Instrumentation instrumentation; private final String loneliness; + private final String origArgs; private static final String INFO_DELIMITER = "|"; - InstrumentationProvider(Instrumentation inst, Transformer transformer, String loneliness) { + InstrumentationProvider(Instrumentation inst, Transformer transformer, String loneliness, String origArgs) { this.transformer = transformer; this.instrumentation = inst; this.loneliness = loneliness; + this.origArgs = origArgs; } public void setClassBody(String cname, byte[] nwBody, String classloader) throws UnmodifiableClassException { @@ -196,7 +198,7 @@ public int cleanOverrides(String pattern) { } public void detach() { - Main.deregister(loneliness); + Main.deregister(loneliness, origArgs); cleanOverrides(".*"); //optional? instrumentation.removeTransformer(transformer); int loader = Integer.parseInt(System.getProperty(Main.JRD_AGENT_LOADED, "0")) - 1; diff --git a/decompiler_agent/src/main/java/org/jrd/agent/Main.java b/decompiler_agent/src/main/java/org/jrd/agent/Main.java index b89e9c964..6770ba15d 100644 --- a/decompiler_agent/src/main/java/org/jrd/agent/Main.java +++ b/decompiler_agent/src/main/java/org/jrd/agent/Main.java @@ -41,7 +41,7 @@ private Main() { * @param agentArgs arguments with parameters for listener * @param inst instance of instrumentation of given VM */ - public static void premain(String agentArgs, Instrumentation inst) throws Exception { + public static void premain(final String agentArgs, Instrumentation inst) throws Exception { String hostname = null; Integer port = null; final String loneliness; @@ -58,7 +58,7 @@ public static void premain(String agentArgs, Instrumentation inst) throws Except InstrumentationProvider p = AccessController.doPrivileged(new PrivilegedAction() { @Override public InstrumentationProvider run() { - InstrumentationProvider p = new InstrumentationProvider(inst, transformer, lonelinessCopy); + InstrumentationProvider p = new InstrumentationProvider(inst, transformer, lonelinessCopy, agentArgs); return p; } }); @@ -95,17 +95,17 @@ public static void agentmain(String args, Instrumentation inst) throws Exception premain(args, inst); } - public static void deregister(String loneliness) { + public static void deregister(String loneliness, String port) { if (loneliness.equals(LONELINESS_VAL_S)) { confirmedAttaches--; - System.err.println("Removed JRD agent: " + loneliness); + System.err.println("Removed JRD agent: " + loneliness + "/" + port); } else if (loneliness.equals(LONELINESS_VAL_A)) { - System.err.println("Removed JRD agent: " + loneliness); + System.err.println("Removed JRD agent: " + loneliness + "/" + port); } else if (loneliness.equals(LONELINESS_VAL_F)) { confirmedAttaches--; - System.err.println("Removed JRD agent: " + loneliness); + System.err.println("Removed JRD agent: " + loneliness + "/" + port); } else if (loneliness.equals(LONELINESS_VAL_AF)) { - System.err.println("Removed JRD agent: " + loneliness); + System.err.println("Removed JRD agent: " + loneliness + "/" + port); } } @@ -123,18 +123,18 @@ private static String checkLonelienss(String agentArgs) { if (confirmedAttaches != 0) { throw new RuntimeException("Main : attempting to load JRD agent more than once in mode: " + loneliness); } - System.err.println("Added JRD agent: " + loneliness); + System.err.println("Added JRD agent: " + loneliness + "/" + agentArgs); confirmedAttaches++; } else if (loneliness.equals(LONELINESS_VAL_A)) { if (confirmedAttaches != 0) { throw new RuntimeException("Main : attempting to load JRD agent more than once in mode: " + loneliness); } - System.err.println("Added JRD agent: " + loneliness); + System.err.println("Added JRD agent: " + loneliness + "/" + agentArgs); } else if (loneliness.equals(LONELINESS_VAL_F)) { confirmedAttaches++; - System.err.println("Added JRD agent: " + loneliness); + System.err.println("Added JRD agent: " + loneliness + "/" + agentArgs); } else if (loneliness.equals(LONELINESS_VAL_AF)) { - System.err.println("Added JRD agent: " + loneliness); + System.err.println("Added JRD agent: " + loneliness + "/" + agentArgs); } return loneliness; } diff --git a/runtime-decompiler/src/main/java/org/jrd/backend/communication/FsAgent.java b/runtime-decompiler/src/main/java/org/jrd/backend/communication/FsAgent.java index d73095eca..080d5cccf 100644 --- a/runtime-decompiler/src/main/java/org/jrd/backend/communication/FsAgent.java +++ b/runtime-decompiler/src/main/java/org/jrd/backend/communication/FsAgent.java @@ -292,11 +292,9 @@ private static void addJustClass(String s, List classes, String root, bo if (details) { classes.add( new ClassInfo( - toClass(s.substring(root.length() + 1)), - detailsPath, - "class order in realvm may differ", - "unknown", - "unknown").toAgentLikeAnswer() + toClass(s.substring(root.length() + 1)), detailsPath, "class order in realvm may differ", "unknown", + "unknown" + ).toAgentLikeAnswer() ); } else { classes.add(toClass(s.substring(root.length() + 1)));