Beispiel #1
0
 static ReferenceType getReferenceTypeFromToken(String idToken) {
   ReferenceType cls = null;
   if (Character.isDigit(idToken.charAt(0))) {
     cls = null;
   } else if (idToken.startsWith("*.")) {
     // This notation saves typing by letting the user omit leading
     // package names. The first
     // loaded class whose name matches this limited regular
     // expression is selected.
     idToken = idToken.substring(1);
     for (ReferenceType type : Env.vm().allClasses()) {
       if (type.name().endsWith(idToken)) {
         cls = type;
         break;
       }
     }
   } else {
     // It's a class name
     List<ReferenceType> classes = Env.vm().classesByName(idToken);
     if (classes.size() > 0) {
       // TO DO: handle multiples
       cls = classes.get(0);
     }
   }
   return cls;
 }
Beispiel #2
0
  synchronized VirtualMachine open() {
    if (connector instanceof LaunchingConnector) {
      vm = launchTarget();
    } else if (connector instanceof AttachingConnector) {
      vm = attachTarget();
    } else if (connector instanceof ListeningConnector) {
      vm = listenTarget();
    } else {
      throw new InternalError(MessageOutput.format("Invalid connect type"));
    }
    vm.setDebugTraceMode(traceFlags);
    if (vm.canBeModified()) {
      setEventRequests(vm);
      resolveEventRequests();
    }
    /*
     * Now that the vm connection is open, fetch the debugee
     * classpath and set up a default sourcepath.
     * (Unless user supplied a sourcepath on the command line)
     * (Bug ID 4186582)
     */
    if (Env.getSourcePath().length() == 0) {
      if (vm instanceof PathSearchingVirtualMachine) {
        PathSearchingVirtualMachine psvm = (PathSearchingVirtualMachine) vm;
        Env.setSourcePath(psvm.classPath());
      } else {
        Env.setSourcePath(".");
      }
    }

    return vm;
  }
 private void checkClassName(String className) throws ClassNotFoundException {
   // Do stricter checking of class name validity on deferred
   //  because if the name is invalid, it will
   // never match a future loaded class, and we'll be silent
   // about it.
   StringTokenizer tokenizer = new StringTokenizer(className, ".");
   while (tokenizer.hasMoreTokens()) {
     String token = tokenizer.nextToken();
     // Each dot-separated piece must be a valid identifier
     // and the first token can also be "*".
     if (!isJavaIdentifier(token)
         && (tokenizer.hasMoreTokens() || !isAnonymousClassSuffix(token))) {
       throw new ClassNotFoundException();
     }
   }
   if (!classIsPlausible()) Env.noticeln("Warning: class %s does not seem to exist.", classId);
 }
 /**
  * False iff there is some evidence that no class described by this pattern exists in the
  * classpath. Conservatively returns true for patterns containing "*", for cases where the virtual
  * machine is not a PathSearchingVirtualMachine, and for anonymous classes for a parent class
  * exists.
  */
 boolean classIsPlausible() {
   if (classId.startsWith("*")
       || classId.endsWith("*")
       || !(Env.vm() instanceof PathSearchingVirtualMachine)) return true;
   else return Env.classMayExist(transClassId);
 }