Refine search
public org.apache.bcel.generic.Type toJCType() { return new org.apache.bcel.generic.ObjectType(NODE_ITERATOR); }
@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); } }
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; .getClassName()); ClassDescriptor rhsDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(actualType .getClassName());
System.out.println(" Analyzing method " + classContext.getJavaClass().getClassName() + "." + method.getName()); int pc = handle.getPosition(); IndexedInstruction ins = (IndexedInstruction) location.getHandle().getInstruction(); String sourceFileName = javaClass.getSourceFileName(); if (LocalVariableAnnotation.UNKNOWN_NAME.equals(lvAnnotation.getName())) { if (sourceFileName.endsWith(".groovy")) { + location.getHandle().getPosition() + " is " + (storeLive ? "live" : "dead")); System.out.println("Previous is: " + location.getHandle().getPrev()); for (Field f : javaClass.getFields()) { if (f.getName().equals(lvName) && f.isStatic() == method.isStatic()) { shadowedField = f; } else if (value instanceof ObjectType) { ObjectType v = (ObjectType) value; initializationOf = ClassName.toSignature(v.getClassName()); foundDeadClassInitialization = true; } else { if (typeOfValue instanceof BasicType || Type.STRING.equals(typeOfValue)) { propertySet.addProperty(DeadLocalStoreProperty.BASE_VALUE); String signatureOfValue = typeOfValue.getSignature(); if ((signatureOfValue.startsWith("Ljava/sql/") || signatureOfValue.startsWith("Ljavax/sql/")) && !signatureOfValue.endsWith("Exception")) {
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ public void visitPUTSTATIC(PUTSTATIC o){ String field_name = o.getFieldName(cpg); JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); Field f = null; for (int i=0; i<fields.length; i++){ if (fields[i].getName().equals(field_name)){ f = fields[i]; break; } } if (f == null){ throw new AssertionViolatedException("Field not found?!?"); } if (f.isFinal()){ if (!(myOwner.getClassName().equals(o.getClassType(cpg).getClassName()))){ constraintViolated(o, "Referenced field '"+f+"' is final and must therefore be declared in the current class '"+myOwner.getClassName()+"' which is not the case: it is declared in '"+o.getClassType(cpg).getClassName()+"'."); } } if (! (f.isStatic())){ constraintViolated(o, "Referenced field '"+f+"' is not static which it should be."); } String meth_name = Repository.lookupClass(myOwner.getClassName()).getMethods()[method_no].getName(); // If it's an interface, it can be set only in <clinit>. if ((!(jc.isClass())) && (!(meth_name.equals(Constants.STATIC_INITIALIZER_NAME)))){ constraintViolated(o, "Interface field '"+f+"' must be set in a '"+Constants.STATIC_INITIALIZER_NAME+"' method."); } }
Location location = i.next(); try { Instruction ins = location.getHandle().getInstruction(); XField xfield = null; boolean isWrite = false; InstructionHandle n = location.getHandle().getNext(); isNullCheck = n.getInstruction() instanceof IFNONNULL || n.getInstruction() instanceof IFNULL; if (DEBUG && isNullCheck) { System.out.println("is null check"); isLocal = fins.getClassName(cpg).equals(classContext.getJavaClass().getClassName()); if (DEBUG) { System.out.println("Handling field access: " + location.getHandle() + " (frame=" String instanceClassName = objType.getClassName(); if (!instanceClassName.equals(xfield.getClassName())) { xfield = XFactory.getExactXField(instanceClassName, xfield.getName(), xfield.getSignature(),
JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); Field f = null; for (int i=0; i<fields.length; i++){ constraintViolated(o, "Referenced field '"+field_name+"' does not exist in class '"+jc.getClassName()+"'."); Type f_type = Type.getType(f.getSignature()); Type o_type = o.getType(cpg);
supidx = jc.getSuperclassNameIndex(); if (jc != Repository.lookupClass(Type.OBJECT.getClassName())){ throw new ClassConstraintException("Superclass of '"+jc.getClassName()+"' missing but not "+Type.OBJECT.getClassName()+" itself!"); String supername = jc.getSuperclassName(); if (! hs.add(supername)){ // If supername already is in the list throw new ClassConstraintException("Circular superclass hierarchy detected.");
throw new IllegalArgumentException( message ); if ( classToWrap.isAbstract() || !classToWrap.isClass() ) m_wrapperSuperclassName = wrapperSuperclassName; m_classToWrap = classToWrap; m_classToWrapType = new ObjectType( m_classToWrap.getClassName() ); m_classGenerator = classGenerator; m_constPoolGenerator = m_classGenerator.getConstantPool();
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ @Override public void visitGETSTATIC(final GETSTATIC o) { try { final String field_name = o.getFieldName(cpg); final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); final Field[] fields = jc.getFields(); Field f = null; for (final Field field : fields) { if (field.getName().equals(field_name)) { f = field; break; } } if (f == null) { throw new AssertionViolatedException("Field '" + field_name + "' not found in " + jc.getClassName()); } if (! (f.isStatic())) { constraintViolated(o, "Referenced field '"+f+"' is not static which it should be."); } } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } }
JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName()); JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName()); while (e != o){ if (e == t) break; // It's a subclass of Throwable, OKAY, leave. v = VerifierFactory.getVerifier(e.getSuperclassName()); vr = v.doPass1(); if (vr != VerificationResult.VR_OK){ throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but '"+e.getSuperclassName()+"' in the ancestor hierachy does not pass verification pass 1: "+vr); e = Repository.lookupClass(e.getSuperclassName());
/** * 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); }
Type[] parameterTypeList = Type.getArgumentTypes(methodGen.getSignature()); Location firstLocation = new Location(cfg.getEntry().getFirstInstruction(), cfg.getEntry()); Stream paramStream = new Stream(firstLocation, objectType.getClassName(), streamBase.getClassName()); paramStream.setIsOpenOnCreation(true); paramStream.setOpenLocation(firstLocation); switch (type.getType()) { case Const.T_LONG: case Const.T_DOUBLE: String sourceFile = javaClass.getSourceFileName(); String leakClass = stream.getStreamBase(); if (isMainMethod(method) && (leakClass.contains("InputStream") || leakClass.contains("Reader"))) {
if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface()) || ((t instanceof ObjectType) && ((ObjectType) t).referencesInterface())) { return Type.OBJECT; final JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName()); final JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName()); if ((thiz_sups == null) || (other_sups == null)) { return null; System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length); System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length); this_sups[0] = Repository.lookupClass(thiz.getClassName()); t_sups[0] = Repository.lookupClass(other.getClassName()); for (final JavaClass t_sup : t_sups) { for (final JavaClass this_sup : this_sups) { if (this_sup.equals(t_sup)) { return ObjectType.getInstance(this_sup.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); }
JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); Field f = null; for (int i=0; i<fields.length; i++){ ObjectType curr = new ObjectType(mg.getClassName()); if ( classtype.equals(curr) || curr.subclassOf(classtype) ){ Type t = stack().peek(); if (t == Type.NULL){ if (! ( objreftype.equals(curr) || objreftype.subclassOf(curr) ) ){
JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); Field f = null; for (int i=0; i<fields.length; i++){ Type t = Type.getType(f.getSignature()); Type shouldbe = t; if (shouldbe == Type.BOOLEAN ||
ObjectType catchType = handler.getCatchType(); if (catchType != null) { String catchClass = catchType.getClassName(); if ("java.lang.CloneNotSupportedException".equals(catchClass) || "java.lang.InterruptedException".equals(catchClass)) { System.out.println("Set decision information"); System.out.println(" " + valueTested + " becomes " + decisionValue); System.out.println(" at " + targetBlock.getFirstInstruction().getPosition()); System.out.println(" prev available loads: " + prevVnaFrame.availableLoadMapAsString()); System.out.println(" target available loads: " .getHandle().getPosition()); if (knownNonnull != null) { tmpFact = replaceValues(fact, tmpFact, knownNonnull, prevVnaFrame, targetVnaFrame, Instruction firstInDest = edge.getTarget().getFirstInstruction().getInstruction();
short branchOpcode = edge.getSource().getLastInstruction().getInstruction().getOpcode(); boolean feasibleCheck = instanceOfType.equals(NullType.instance()) || Hierarchy.isSubtype((ReferenceType) instanceOfType, (ReferenceType) checkedType); double v = Analyze.deepInstanceOf(((ObjectType) instanceOfType).getClassName(), ((ObjectType) checkedType).getClassName()); if (v > 0.0) { feasibleCheck = true; } else if (!instanceOfType.equals(NullType.instance())) {
static InstructionHandle emitCoerceFromObject(InstructionList il, InstructionFactory fac, Type type) { int tag = type.getType(); switch (tag) { case Constants.T_BOOLEAN: case Constants.T_CHAR: case Constants.T_BYTE: case Constants.T_SHORT: case Constants.T_INT: case Constants.T_LONG: case Constants.T_FLOAT: case Constants.T_DOUBLE: il.append(fac.createCast(Type.OBJECT, new ObjectType( BASIC_CLASS_NAMES[tag]))); return emitInvoke(il, fac, UNBOXING_METHOD[tag]); case Constants.T_OBJECT: case Constants.T_ARRAY: return il.append(fac.createCast(Type.OBJECT, type)); case Constants.T_VOID: return il.append(InstructionConstants.POP); default: throw new RuntimeException("internal error"); } }