Пример #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);
     List classes = Env.vm().allClasses();
     Iterator iter = classes.iterator();
     while (iter.hasNext()) {
       ReferenceType type = ((ReferenceType) iter.next());
       if (type.name().endsWith(idToken)) {
         cls = type;
         break;
       }
     }
   } else {
     // It's a class name
     List classes = Env.vm().classesByName(idToken);
     if (classes.size() > 0) {
       // TO DO: handle multiples
       cls = (ReferenceType) classes.get(0);
     }
   }
   return cls;
 }
Пример #2
0
 /** Return a description of an object. */
 static String description(ObjectReference ref) {
   ReferenceType clazz = ref.referenceType();
   long id = ref.uniqueID();
   if (clazz == null) {
     return toHex(id);
   } else {
     return MessageOutput.format(
         "object description and hex id", new Object[] {clazz.name(), toHex(id)});
   }
 }