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); }