| 53 | } |
| 54 | |
| 55 | private static void agent(String args, Instrumentation inst) { |
| 56 | InstrumentationResource.instrumentation = inst; |
| 57 | if (Recaf.class.getClassLoader() == ClassLoader.getSystemClassLoader()) { |
| 58 | warn("Recaf was attached and loaded into system class loader," + |
| 59 | " that is not a good thing!"); |
| 60 | } |
| 61 | |
| 62 | init(); |
| 63 | VMUtil.patchInstrumentation(inst); |
| 64 | // Log that we are an agent |
| 65 | info("Starting as agent..."); |
| 66 | // Add instrument launch arg |
| 67 | if(args == null || args.trim().isEmpty()) |
| 68 | args = "--instrument"; |
| 69 | else if(!args.contains("--instrument")) |
| 70 | args = args + ",--instrument"; |
| 71 | // Set instance |
| 72 | // Start Recaf |
| 73 | launch(args.split("[=,]")); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Run pre-launch initialization tasks. |