Beispiel #1
0
 private static Class<?> forNameInternal(
     String className, boolean initialize, ClassLoader classLoader)
     throws ClassNotFoundException, LinkageError, ExceptionInInitializerError {
   try {
     if (className.startsWith("[")) {
       if (!validArrayDescriptor(className)) {
         throw new ClassNotFoundException(className);
       }
     }
     Atom descriptor =
         Atom.findOrCreateAsciiAtom(className.replace('.', '/')).descriptorFromClassName();
     TypeReference tRef = TypeReference.findOrCreate(classLoader, descriptor);
     RVMType ans = tRef.resolve();
     Callbacks.notifyForName(ans);
     if (initialize && !ans.isInitialized()) {
       ans.resolve();
       ans.instantiate();
       ans.initialize();
     }
     return ans.getClassForType();
   } catch (NoClassDefFoundError ncdfe) {
     Throwable cause2 = ncdfe.getCause();
     ClassNotFoundException cnf;
     // If we get a NCDFE that was caused by a CNFE, throw the original CNFE.
     if (cause2 instanceof ClassNotFoundException) cnf = (ClassNotFoundException) cause2;
     else cnf = new ClassNotFoundException(className, ncdfe);
     throw cnf;
   }
 }
Beispiel #2
0
 public Class<?> getEnclosingClass() {
   if (type.isClassType()) {
     TypeReference enclosingClass = type.asClass().getEnclosingClass();
     if (enclosingClass != null) {
       return enclosingClass.resolve().getClassForType();
     } else {
       return null;
     }
   } else {
     return null;
   }
 }
Beispiel #3
0
  public Class<?>[] getClasses() throws SecurityException {
    checkMemberAccess(Member.PUBLIC);
    if (!type.isClassType()) return new Class[0];

    ArrayList<Class<?>> publicClasses = new ArrayList<Class<?>>();
    for (Class<?> c = this; c != null; c = c.getSuperclass()) {
      c.checkMemberAccess(Member.PUBLIC);
      TypeReference[] declaredClasses = c.type.asClass().getDeclaredClasses();
      if (declaredClasses != null) {
        for (TypeReference declaredClass : declaredClasses) {
          if (declaredClass != null) {
            RVMClass dc = declaredClass.resolve().asClass();
            if (dc.isPublic()) {
              publicClasses.add(dc.getClassForType());
            }
          }
        }
      }
    }
    Class<?>[] result = new Class[publicClasses.size()];
    result = publicClasses.toArray(result);
    return result;
  }
Beispiel #4
0
 public Class<?> getDeclaringClass() {
   if (!type.isClassType()) return null;
   TypeReference dc = type.asClass().getDeclaringClass();
   if (dc == null) return null;
   return dc.resolve().getClassForType();
 }