@Override public String getMsg() { return "class implements non-interface " + iface.getReference() + " as an interface"; } });
private TypeReference chooseAnImplementor(IClass iface) { Set implementors = cha.getImplementors(iface.getReference()); if (!implementors.isEmpty()) { return ((IClass) implementors.iterator().next()).getReference(); } else { return null; } }
public static boolean isStringish(IClass C) { if (C == null) { throw new IllegalArgumentException("C is null"); } return C.getReference().equals(TypeReference.JavaLangString) || C.getReference().equals(JavaLangStringBuffer) || C.getReference().equals(JavaLangStringBuilder) || C.getReference().equals(JavaLangAbstractStringBuilder); }
@Override protected boolean isUncataloguedField(IClass type, String fieldName) { if (!type.getReference().equals(JavaScriptTypes.Object)) { return true; } return "prototype".equals(fieldName) || "constructor".equals(fieldName) || "arguments".equals(fieldName) || "class".equals(fieldName) || "$value".equals(fieldName) || "__proto__".equals(fieldName); }
/** * @throws IllegalArgumentException if type is null */ public PointType(IClass type) { if (type == null) { throw new IllegalArgumentException("type is null"); } this.type = type; assert type.getReference().isReferenceType(); }
/** * Keep this method private .. this returns the actual backing set for the class, which we do not want to expose to clients. */ private MutableIntSet findOrCreateSparseSetForClass(IClass klass) { assert klass.getReference() != TypeReference.JavaLangObject; MutableIntSet result = class2InstanceKey.get(klass); if (result == null) { result = IntSetUtil.getDefaultIntSetFactory().make(); class2InstanceKey.put(klass, result); } return result; }
@Override public boolean recordFactoryType(CGNode node, IClass klass) { if (klass == null) { throw new IllegalArgumentException("klass is null"); } if (node == null) { throw new IllegalArgumentException("node is null"); } return recordType(node.getMethod().getClassHierarchy(), node.getContext(), klass.getReference()); }
private static MethodReference genSyntheticMethodRef(IClass receiver) { Atom atom = Atom.findOrCreateUnicodeAtom(SYNTHETIC_APPLY_METHOD_PREFIX); Descriptor desc = Descriptor.findOrCreateUTF8(JavaScriptLoader.JS, "()LRoot;"); MethodReference ref = MethodReference.findOrCreate(receiver.getReference(), atom, desc); return ref; }
private static MethodReference genSyntheticMethodRef(IClass receiver) { Atom atom = Atom.findOrCreateUnicodeAtom(SYNTHETIC_APPLY_METHOD_PREFIX); Descriptor desc = Descriptor.findOrCreateUTF8(JavaScriptLoader.JS, "()LRoot;"); MethodReference ref = MethodReference.findOrCreate(receiver.getReference(), atom, desc); return ref; }
/** * for an array class, get the innermost type, or null if it's primitive */ private IClass getInnermostTypeOfArrayClass(IClass klass) { TypeReference result = klass.getReference(); while (result.isArrayType()) { result = result.getArrayElementType(); } return result.isPrimitiveType() ? null : lookupClass(result); }
private TypeAbstraction interceptType(TypeAbstraction T) { TypeReference type = T.getType().getReference(); if (type.equals(TypeReference.JavaIoSerializable)) { Warnings.add(IgnoreSerializableWarning.create()); return null; } else { return T; } }
@Override public TypeReference[] getParameterTypes(int i) { assert i == 0; if (getMethod().isStatic()) { return new TypeReference[0]; } else { return new TypeReference[] { getMethod().getDeclaringClass().getReference() }; } }
@Override public TypeReference[] getParameterTypes(int i) { assert i == 0; if (getMethod().isStatic()) { return new TypeReference[0]; } else { return new TypeReference[] { getMethod().getDeclaringClass().getReference() }; } }
private TypeAbstraction interceptType(TypeAbstraction T) { TypeReference type = T.getType().getReference(); if (type.equals(TypeReference.JavaIoSerializable)) { Warnings.add(IgnoreSerializableWarning.create()); return null; } else { return T; } }
private static boolean isExcluded(final IClass cls) { final SetOfClasses set = cls.getClassHierarchy().getScope().getExclusions(); if (set == null) { return false; // exclusions null ==> no exclusions ==> no class is excluded } else { final String clsName = cls.getReference().getName().toString().substring(1); return set.contains(clsName); } }
@Override public Iterator<? extends Pair<CGNode, NewSiteReference>> makeInner(final CGNode outer) { return new MapIterator<>( new FilterIterator<>( outer.iterateNewSites(), o -> o.getDeclaredType().equals(type.getReference()) ), object -> Pair.make(outer, object)); } };
private MethodReference computeMethodReference() { try { Atom name = Atom.findOrCreateUnicodeAtom(getMethodName()); ImmutableByteArray desc = ImmutableByteArray.make(getMethodSignature()); Descriptor D = Descriptor.findOrCreate(declaringClass.getClassLoader().getLanguage(), desc); return MethodReference.findOrCreate(declaringClass.getReference(), name, D); } catch (InvalidClassFileException e) { Assertions.UNREACHABLE(); return null; } }
private MethodReference computeMethodReference() { try { Atom name = Atom.findOrCreateUnicodeAtom(getMethodName()); ImmutableByteArray desc = ImmutableByteArray.make(getMethodSignature()); Descriptor D = Descriptor.findOrCreate(declaringClass.getClassLoader().getLanguage(), desc); return MethodReference.findOrCreate(declaringClass.getReference(), name, D); } catch (InvalidClassFileException e) { Assertions.UNREACHABLE(); return null; } }
protected JavaField(CAstEntity fieldEntity, IClassLoader loader, IClass declaringClass, Collection<Annotation> annotations) { super(FieldReference.findOrCreate(declaringClass.getReference(), Atom.findOrCreateUnicodeAtom(fieldEntity.getName()), TypeReference.findOrCreate(loader.getReference(), TypeName.string2TypeName(fieldEntity.getType().getName()))), fieldEntity.getQualifiers(), declaringClass, declaringClass.getClassHierarchy(), annotations); } }
@Override public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) { return new MapIterator<>( new FilterIterator<>( getNode().iterateNewSites(), o -> o.getDeclaredType().equals(getConcreteType().getReference())), object -> Pair.make(getNode(), object)); } }