/** * Determine if the given ObjectType reference represents a * <em>universal</em> exception handler. That is, one that will catch any * kind of exception. * * @param catchType * the ObjectType of the exception handler * @return true if catchType is null, or if catchType is java.lang.Throwable */ public static boolean isUniversalExceptionHandler(ObjectType catchType) { return catchType == null || catchType.equals(Type.THROWABLE); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof FinalConstant)) { return false; } FinalConstant other = (FinalConstant) obj; return super.equals(other) && this.field.equals(other.field); }
@Override public boolean equals(Object o) { if (o == null) { return false; } if (o.getClass() != this.getClass()) { return false; } ThrownException other = (ThrownException) o; return this.type.equals(other.type) && this.explicit == other.explicit; } }
@Override public boolean equals(Object o) { if (!(o instanceof GenericObjectType)) { return false; } if (!super.equals(o)) { return false; } GenericObjectType that = (GenericObjectType) o; return Objects.equals(parameters, that.parameters) && Objects.equals(variable, that.variable) && Objects.equals(extension, that.extension); }
/** * Determine if the given ObjectType refers to an unchecked exception * (RuntimeException or Error). */ public static boolean isUncheckedException(ObjectType type) throws ClassNotFoundException { if (type.equals(Type.THROWABLE) || type.equals(RUNTIME_EXCEPTION_TYPE) || type.equals(ERROR_TYPE)) { return true; } ClassDescriptor c = DescriptorFactory.getClassDescriptor(type); Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class); return subtypes2.isSubtype(c, RUNTIME_EXCEPTION, ERROR); }
/** * Determine whether or not a given ObjectType is a subtype of another. * Throws ClassNotFoundException if the question cannot be answered * definitively due to a missing class. * * @param type * a ReferenceType * @param possibleSupertype * another Reference type * @return true if <code>type</code> is a subtype of * <code>possibleSupertype</code>, false if not * @throws ClassNotFoundException * if a missing class prevents a definitive answer */ public boolean isSubtype(ObjectType type, ObjectType possibleSupertype) throws ClassNotFoundException { if (DEBUG_QUERIES) { System.out.println("isSubtype: check " + type + " subtype of " + possibleSupertype); } if (type.equals(possibleSupertype)) { if (DEBUG_QUERIES) { System.out.println(" ==> yes, types are same"); } return true; } ClassDescriptor typeClassDescriptor = DescriptorFactory.getClassDescriptor(type); ClassDescriptor possibleSuperclassClassDescriptor = DescriptorFactory.getClassDescriptor(possibleSupertype); return isSubtype(typeClassDescriptor, possibleSuperclassClassDescriptor); }
if (a.equals(b)) { return a;
.toDottedClassName()); if (firstCommonSupertype.equals(Type.OBJECT)) {
static public @Nonnull IncompatibleTypes getPriorityForAssumingCompatible(ObjectType expectedType, ObjectType actualType, boolean pointerEquality) { if (expectedType.equals(actualType)) { return SEEMS_OK; if (actualType.equals(Type.OBJECT)) { return IncompatibleTypes.UNCHECKED; if (expectedType.equals(Type.OBJECT)) { return IncompatibleTypes.SEEMS_OK;
if (typeOfValue instanceof BasicType || Type.STRING.equals(typeOfValue)) { propertySet.addProperty(DeadLocalStoreProperty.BASE_VALUE);
/** * Determine if the given ObjectType reference represents a * <em>universal</em> exception handler. That is, one that will catch any * kind of exception. * * @param catchType * the ObjectType of the exception handler * @return true if catchType is null, or if catchType is java.lang.Throwable */ public static boolean isUniversalExceptionHandler(ObjectType catchType) { return catchType == null || catchType.equals(Type.THROWABLE); }
/** * Returns true on equality of this and o. * Equality means the ObjectType instances of "initialized" * equal one another in this and the o instance. * */ public boolean equals(Object o){ if (! (o instanceof UninitializedObjectType)) return false; return initialized.equals(((UninitializedObjectType)o).initialized); } }
/** * Returns true on equality of this and o. * Equality means the ObjectType instances of "initialized" * equal one another in this and the o instance. * */ @Override public boolean equals(final Object o) { if (! (o instanceof UninitializedObjectType)) { return false; } return initialized.equals(((UninitializedObjectType)o).initialized); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof FinalConstant)) { return false; } FinalConstant other = (FinalConstant) obj; return super.equals(other) && this.field.equals(other.field); }
@Override public boolean equals(Object o) { if (o == null) { return false; } if (o.getClass() != this.getClass()) { return false; } ThrownException other = (ThrownException) o; return this.type.equals(other.type) && this.explicit == other.explicit; } }
/** * Determine if the given ObjectType refers to an unchecked exception * (RuntimeException or Error). */ public static boolean isUncheckedException(ObjectType type) throws ClassNotFoundException { if (type.equals(Type.THROWABLE) || type.equals(RUNTIME_EXCEPTION_TYPE) || type.equals(ERROR_TYPE)) { return true; } ClassDescriptor c = DescriptorFactory.getClassDescriptor(type); Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class); return subtypes2.isSubtype(c, RUNTIME_EXCEPTION, ERROR); }
@Override public boolean equals(Object o) { if (!(o instanceof GenericObjectType)) { return false; } if (!super.equals(o)) { return false; } GenericObjectType that = (GenericObjectType) o; return Util.nullSafeEquals(this.parameters, that.parameters) && Util.nullSafeEquals(this.variable, that.variable) && Util.nullSafeEquals(this.extension, that.extension); }
private static void mergeRealInstanceClass(Taint a, Taint b, Taint result) { if (a.realInstanceClass != null && b.realInstanceClass != null) { try { if (a.realInstanceClass.equals(b.realInstanceClass) || b.realInstanceClass.subclassOf(a.realInstanceClass)) { result.realInstanceClass = a.realInstanceClass; } else if (a.realInstanceClass.subclassOf(b.realInstanceClass)) { result.realInstanceClass = b.realInstanceClass; } } catch (ClassNotFoundException ex) { AnalysisContext.reportMissingClass(ex); } } }
private static void mergeRealInstanceClass(Taint a, Taint b, Taint result) { if (a.realInstanceClass != null && b.realInstanceClass != null) { try { if (a.realInstanceClass.equals(b.realInstanceClass) || b.realInstanceClass.subclassOf(a.realInstanceClass)) { result.realInstanceClass = a.realInstanceClass; } else if (a.realInstanceClass.subclassOf(b.realInstanceClass)) { result.realInstanceClass = b.realInstanceClass; } } catch (ClassNotFoundException ex) { AnalysisContext.reportMissingClass(ex); } } }
/** * Ensures the specific preconditions of the said instruction. */ public void visitATHROW(ATHROW o){ // It's stated that 'objectref' must be of a ReferenceType --- but since Throwable is // not derived from an ArrayType, it follows that 'objectref' must be of an ObjectType or Type.NULL. if (! ((stack().peek() instanceof ObjectType) || (stack().peek().equals(Type.NULL))) ){ constraintViolated(o, "The 'objectref' is not of an (initialized) ObjectType but of type "+stack().peek()+"."); } // NULL is a subclass of every class, so to speak. if (stack().peek().equals(Type.NULL)) return; ObjectType exc = (ObjectType) (stack().peek()); ObjectType throwable = (ObjectType) (Type.getType("Ljava/lang/Throwable;")); if ( (! (exc.subclassOf(throwable)) ) && (! (exc.equals(throwable))) ){ constraintViolated(o, "The 'objectref' is not of class Throwable or of a subclass of Throwable, but of '"+stack().peek()+"'."); } }