Esempio n. 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;
 }
 /**
  * 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);
 }