/** * Create a GenericObjectType that represents a Wildcard with extensions * * @param variable * the type variable e.g. <code>T</code> */ GenericObjectType(@Nonnull String wildcard, @CheckForNull ReferenceType extension) { super(Type.OBJECT.getClassName()); this.variable = wildcard; this.extension = extension; parameters = null; }
public static ObjectType merge(@CheckForNull GenericObjectType t1, ObjectType t2) { if (t1 == null || t2 instanceof GenericObjectType) { return t2; } List<? extends ReferenceType> parameters = t1.getParameters(); if (parameters == null) { return t2; } return new GenericObjectType(t2.getClassName(), parameters); }
/** * Get a ClassDescriptor for the class described by given ObjectType object. * * @param type * an ObjectType * @return a ClassDescriptor for the class described by the ObjectType */ public static ClassDescriptor getClassDescriptor(ObjectType type) { return instance().getClassDescriptorForDottedClassName(type.getClassName()); }
/** * Initialize object from an exception set. * * @param exceptionSet * the exception set * @return a Type that is a supertype of all of the exceptions in the * exception set */ public static Type fromExceptionSet(ExceptionSet exceptionSet) throws ClassNotFoundException { Type commonSupertype = exceptionSet.getCommonSupertype(); if (commonSupertype.getType() != Const.T_OBJECT) { return commonSupertype; } ObjectType exceptionSupertype = (ObjectType) commonSupertype; String className = exceptionSupertype.getClassName(); if ("java.lang.Throwable".equals(className)) { return exceptionSupertype; } return new ExceptionObjectType(className, exceptionSet); }
@Override public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg, RepositoryLookupFailureCallback lookupFailureCallback) { Instruction ins = location.getHandle().getInstruction(); if (ins.getOpcode() != Const.GETSTATIC) { return null; } GETSTATIC getstatic = (GETSTATIC) ins; if (!className.equals(getstatic.getClassName(cpg)) || !fieldName.equals(getstatic.getName(cpg)) || !fieldSig.equals(getstatic.getSignature(cpg))) { return null; } return new Stream(location, type.getClassName(), streamBaseClass).setIgnoreImplicitExceptions(true).setIsOpenOnCreation( true); } }
@Override public void visitLDC(LDC obj) { Object constantValue = obj.getValue(cpg); ValueNumber value; if (constantValue instanceof ConstantClass) { ConstantClass constantClass = (ConstantClass) constantValue; String className = constantClass.getBytes(cpg.getConstantPool()); value = factory.getClassObjectValue(className); } else if (constantValue instanceof ObjectType) { ObjectType objectType = (ObjectType) constantValue; String className = objectType.getClassName(); value = factory.getClassObjectValue(className); } else { value = constantValueMap.get(constantValue); if (value == null) { value = factory.createFreshValue(ValueNumber.CONSTANT_VALUE); constantValueMap.put(constantValue, value); // Keep track of String constants if (constantValue instanceof String) { stringConstantMap.put(value, (String) constantValue); } } } getFrame().pushValue(value); }
@Override public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg, RepositoryLookupFailureCallback lookupFailureCallback) { Instruction ins = location.getHandle().getInstruction(); try { if (ins instanceof InvokeInstruction) { if (!Hierarchy.isSubtype(type, baseClassType)) { return null; } Stream stream = new Stream(location, type.getClassName(), baseClassType.getClassName()).setIsOpenOnCreation(true) .setIgnoreImplicitExceptions(true); if (bugType != null) { stream.setInteresting(bugType); } return stream; } } catch (ClassNotFoundException e) { lookupFailureCallback.reportMissingClass(e); } return null; } }
String receiverClassName = ((ObjectType) receiverType).getClassName();
public static boolean isNullCheck(InstructionHandle h, ConstantPoolGen cpg) { if (!(h.getInstruction() instanceof IFNONNULL)) { return false; } h = h.getNext(); final Instruction newInstruction = h.getInstruction(); if (!(newInstruction instanceof NEW)) { return false; } final ObjectType loadClassType = ((NEW) newInstruction).getLoadClassType(cpg); if (!"java.lang.NullPointerException".equals(loadClassType.getClassName())) { return false; } h = h.getNext(); return check(h, NULLCHECK1) || check(h, NULLCHECK2); }
return Repository.instanceOf(((ObjectType) argType).getClassName(), ((ObjectType) parmType).getClassName()); } catch (ClassNotFoundException e) {
Stream result = new Stream(location, type.getClassName(), baseClassType.getClassName()) .setIgnoreImplicitExceptions(true); if (!isUninteresting) {
String streamClass = type.getClassName(); if ("java.sql.CallableStatement".equals(streamClass)) { streamClass = "java.sql.PreparedStatement";
.getClassName()); ClassDescriptor rhsDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(actualType .getClassName());
String fieldClass = type.getClassName(); try { if (fieldClass.startsWith("[")) {
String receiverClassName = ((ObjectType) receiverType).getClassName(); JavaClass receiverClass = analysisContext.lookupClass(receiverClassName); ClassDescriptor receiverDesc = DescriptorFactory.createClassDescriptorFromDottedClassName(receiverClassName);
ObjectType catchType = handler.getCatchType(); if (catchType != null) { String catchClass = catchType.getClassName(); if ("java.lang.CloneNotSupportedException".equals(catchClass) || "java.lang.InterruptedException".equals(catchClass)) {
Stream paramStream = new Stream(firstLocation, objectType.getClassName(), streamBase.getClassName()); paramStream.setIsOpenOnCreation(true); paramStream.setOpenLocation(firstLocation);
String instanceClassName = objType.getClassName(); if (!instanceClassName.equals(xfield.getClassName())) { xfield = XFactory.getExactXField(instanceClassName, xfield.getName(), xfield.getSignature(),
double v = Analyze.deepInstanceOf(((ObjectType) instanceOfType).getClassName(), ((ObjectType) checkedType).getClassName()); if (v > 0.0) { feasibleCheck = true;
} else if (value instanceof ObjectType) { ObjectType v = (ObjectType) value; initializationOf = ClassName.toSignature(v.getClassName()); foundDeadClassInitialization = true; } else {