public static Type getJCRefType(String signature) { return Type.getType(signature); }
/** * Return whether the given FieldInstruction accesses a long or double * field. * * @param fieldIns * the FieldInstruction * @param cpg * the ConstantPoolGen for the method */ protected static boolean isLongOrDouble(FieldInstruction fieldIns, ConstantPoolGen cpg) { Type type = fieldIns.getFieldType(cpg); int code = type.getType(); return code == Const.T_LONG || code == Const.T_DOUBLE; }
/** * Helper for pushing the return type of an invoke instruction. */ protected void pushReturnType(InvokeInstruction ins) { ConstantPoolGen cpg = getCPG(); Type type = ins.getType(cpg); if (type.getType() != Const.T_VOID) { pushValue(type); } }
/** * 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); }
/** * Work around some weirdness in BCEL (inherited from JVM Spec 1): BCEL * considers long and double types to consume two slots on the stack. This * method ensures that we push two types for each double or long value. */ protected void pushValue(Type type) { if (type.getType() == Const.T_VOID) { throw new IllegalArgumentException("Can't push void"); } TypeFrame frame = getFrame(); if (type.getType() == Const.T_LONG) { frame.pushValue(Type.LONG); frame.pushValue(TypeFrame.getLongExtraType()); } else if (type.getType() == Const.T_DOUBLE) { frame.pushValue(Type.DOUBLE); frame.pushValue(TypeFrame.getDoubleExtraType()); } else { frame.pushValue(type); } }
@Override public void visitINVOKESTATIC(INVOKESTATIC obj) { String methodName = obj.getMethodName(cpg); String signature = obj.getSignature(cpg); String className = obj.getClassName(cpg); if ("asList".equals(methodName) && "java.util.Arrays".equals(className) && "([Ljava/lang/Object;)Ljava/util/List;".equals(signature)) { consumeStack(obj); Type returnType = Type.getType("Ljava/util/Arrays$ArrayList;"); pushValue(returnType); return; } visitInvokeInstructionCommon(obj); }
public void mergeSummary(XField fieldOperand, OpcodeStack.Item mergeValue) { if (SystemProperties.ASSERTIONS_ENABLED) { String mSignature = mergeValue.getSignature(); Type mergeType = Type.getType(mSignature); Type fieldType = Type.getType(fieldOperand.getSignature()); IncompatibleTypes check = IncompatibleTypes.getPriorityForAssumingCompatible(mergeType, fieldType, false); if (check.getPriority() <= Priorities.NORMAL_PRIORITY) { AnalysisContext.logError(fieldOperand + " not compatible with " + mergeValue, new IllegalArgumentException(check.toString())); } } OpcodeStack.Item oldSummary = summary.get(fieldOperand); if (oldSummary != null) { Item newValue = OpcodeStack.Item.merge(mergeValue, oldSummary); newValue.clearNewlyAllocated(); summary.put(fieldOperand, newValue); } else { if (mergeValue.isNewlyAllocated()) { mergeValue = new OpcodeStack.Item(mergeValue); mergeValue.clearNewlyAllocated(); } summary.put(fieldOperand, mergeValue); } }
public void purgeBoringEntries() { Collection<FieldDescriptor> keys = new ArrayList<>(getKeys()); for (FieldDescriptor f : keys) { FieldStoreType type = getProperty(f); Type fieldType = Type.getType(f.getSignature()); if (!(fieldType instanceof ReferenceType)) { removeProperty(f); continue; } ReferenceType storeType = type.getLoadType((ReferenceType) fieldType); if (storeType.equals(fieldType)) { removeProperty(f); } } }
try { String signature = i.next(); Type type = Type.getType(signature); if (!(type instanceof ReferenceType)) { continue;
c = "L" + c.replace('.', '/') + ";"; Type type = Type.getType(c); if (type instanceof ReferenceType) { instanceOfValueNumber = vnaFrame.getTopValue(); return; ObjectType mapType = (ObjectType) Type.getType("Ljava/util/Map$Entry;"); Type t = GenericUtilities.getType(rv); if (t != null) { assert t.getType() != Const.T_VOID; result = merge(result, t); foundSomething = true; String rv = p.getReturnTypeSignature(); Type t = Type.getType(rv); result = merge(result, t); foundSomething = true;
/** * */ private void check(ClassDescriptor c) { OpcodeStack.Item item = stack.getStackItem(0); if (item.isInitialParameter() && item.getRegisterNumber() == 1) { ClassDescriptor thisClassDescriptor = getClassDescriptor(); if (c.equals(thisClassDescriptor)) { return; } Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); try { if (!c.isArray() && (subtypes2.isSubtype(c, thisClassDescriptor) || subtypes2.isSubtype(thisClassDescriptor, c))) { return; } Type thisType = Type.getType(thisClassDescriptor.getSignature()); Type cType = Type.getType(c.getSignature()); IncompatibleTypes check = IncompatibleTypes.getPriorityForAssumingCompatible(thisType, cType, false); int priority = check.getPriority(); if ("java/lang/Object".equals(getSuperclassName()) && ClassName.isLocalOrAnonymous(getClassName())) { priority++; } bugAccumulator.accumulateBug(new BugInstance(this, "EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS", priority) .addClassAndMethod(this).addType(c).describe(TypeAnnotation.FOUND_ROLE), this); classSummary.checksForEqualTo(thisClassDescriptor, c); } catch (ClassNotFoundException e) { bugReporter.reportMissingClass(e); } } }
switch (type.getType()) { case Const.T_LONG: case Const.T_DOUBLE:
field.getName(), Type.getType(field.getSignature()))); InstructionHandle getter_ih_4 = getter.append(fac.createReturn(Type.OBJECT)); InstructionHandle setter_ih_1 = setter.append(fac.createLoad(Type.OBJECT, 1)); InstructionHandle setter_ih_2 = setter.append(fac.createPutField(cg.getClassName(), field.getName(), Type.getType(field.getSignature()))); InstructionHandle setter_ih_0_ih_5 = setter.append(fac.createReturn(Type.VOID));
/** * Helper for pushing the return type of an invoke instruction. */ protected void pushReturnType(InvokeInstruction ins) { ConstantPoolGen cpg = getCPG(); Type type = ins.getType(cpg); if (type.getType() != T_VOID) { pushValue(type); } }