/** * @return the IClass that represents the innermost array element type, or null if the element * type is a primitive */ public IClass getInnermostElementClass() { TypeReference elementType = getReference().getInnermostElementType(); if (elementType.isPrimitiveType()) { return null; } return loader.lookupClass(elementType.getName()); }
@Override public boolean equals(Object obj) { if (obj instanceof ArrayClass) { ArrayClass other = (ArrayClass) obj; return loader.equals(other.loader) && type.equals(other.type); } else { return false; } }
/** @param classLoader The delegate that loads the classes. */ public ClassLoaderIClassLoader(ClassLoader classLoader) { super( null // optionalParentIClassLoader ); if (classLoader == null) throw new NullPointerException(); this.classLoader = classLoader; super.postConstruct(); }
/* * @see com.ibm.wala.classLoader.IClass#getAllImplementedInterfaces() */ @Override public Collection<IClass> getAllImplementedInterfaces() { HashSet<IClass> result = HashSetFactory.make(2); for (TypeReference ref : getClassLoader().getLanguage().getArrayInterfaces()) { IClass klass = loader.lookupClass(ref.getName()); if (klass != null) { result.add(klass); } } return result; }
/** * Package-visible constructor; only for use by ArrayClassLoader class. 'loader' must be the * Primordial IClassLoader. * * <p>[WHY? -- array classes are loaded by the element classloader??] */ ArrayClass(TypeReference type, IClassLoader loader, IClassHierarchy cha) { this.type = type; this.loader = loader; this.cha = cha; TypeReference elementType = type.getInnermostElementType(); if (!elementType.isPrimitiveType()) { IClass klass = loader.lookupClass(elementType.getName()); if (klass == null) { Assertions.UNREACHABLE("caller should not attempt to create an array with type " + type); } } else { // assert loader.getReference().equals(ClassLoaderReference.Primordial); } }
/* * @see com.ibm.wala.classLoader.IClass#getSuperclass() */ @Override public IClass getSuperclass() { IClass elt = getElementClass(); assert getReference().getArrayElementType().isPrimitiveType() || elt != null; // super is Ljava/lang/Object in two cases: // 1) [Ljava/lang/Object // 2) [? for primitive arrays (null from getElementClass) if (elt == null || elt.getReference() == getClassLoader().getLanguage().getRootType()) { return loader.lookupClass(getClassLoader().getLanguage().getRootType().getName()); } // else it is array of super of element type (yuck) else { TypeReference eltSuperRef = elt.getSuperclass().getReference(); TypeReference superRef = TypeReference.findOrCreateArrayOf(eltSuperRef); return elt.getSuperclass().getClassLoader().lookupClass(superRef.getName()); } }
/* * @see com.ibm.wala.classLoader.IClass#getAllMethods() */ @Override public Collection<IMethod> getAllMethods() { return loader .lookupClass(getClassLoader().getLanguage().getRootType().getName()) .getAllMethods(); }