1 Reply Latest reply on Jan 26, 2010 1:43 PM by 791266

    Silently Attaching to a JVM

      I want to use the Attach API to silently attach to a running JVM - that is through the agentmain() method. By silently, I mean I don't want the target JVM to detect my act of attaching to it. But the problem is, assuming my class name is widely known (say I distribute it as a product to users), the attach api will try to append my class into the system class path. In that case, all the target JVM classes need to do to detect my intruding class is to search for the existence of my classname in the classpath e.g.

      try {
      Class s=Class.forName("IntrudingClassName");
      if (s!=null)
      return "intruder detected";
      } catch (ClassNotFoundException e) {
      return "intruder not found";

      Is there any way to prevent my class being visible in the attached JVM's classpath? I tried to rename my attaching class to say, java.awt.Canvas (same as the core system library classes); however, this just make the attach api fails to find the agentmain() method as it probably looked into the core system library's version of the class. I am not sure if renaming my attaching class to one of the target JVM's running class instead of the core system library classes would work or not. But is there any better method, say replacing the ClassLoader returned by the ClassLoader.getSystemClassLoader to my own version.( according to the specification, it is the SystemClassLoader the append the jar to the system class path)