Java 类org.apache.bcel.generic.ObjectType 实例源码

项目:parabuild-ci    文件:AnyMethodReturnValueStreamFactory.java   
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;
}
项目:parabuild-ci    文件:StaticFieldLoadStreamFactory.java   
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
                           RepositoryLookupFailureCallback lookupFailureCallback) {

    Instruction ins = location.getHandle().getInstruction();
    if (ins.getOpcode() != Constants.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);
}
项目:parabuild-ci    文件:ExceptionSet.java   
public String toString() {
    StringBuffer buf = new StringBuffer();
    buf.append('{');
    boolean first = true;
    for (ThrownExceptionIterator i = iterator(); i.hasNext();) {
        ObjectType type = i.next();
        if (first)
            first = false;
        else
            buf.append(',');
        boolean implicit = !i.isExplicit();
        if (implicit) buf.append('[');
        buf.append(type.toString());
        if (implicit) buf.append(']');
    }
    buf.append('}');
    return buf.toString();
}
项目:parabuild-ci    文件:BlockTypeAnalysis.java   
public void transfer(BasicBlock basicBlock, InstructionHandle end, BlockType start, BlockType result)
        throws DataflowAnalysisException {
    result.copyFrom(start);

    if (start.isValid()) {
        if (basicBlock.isExceptionHandler()) {
            CodeExceptionGen exceptionGen = basicBlock.getExceptionGen();
            ObjectType catchType = exceptionGen.getCatchType();
            if (catchType == null) {
                // Probably a finally block, or a synchronized block
                // exception-compensation catch block.
                result.pushFinally();
            } else {
                // Catch type was explicitly specified:
                // this is probably a programmer-written catch block
                result.pushCatch();
            }
        }
    }
}
项目:Android_Code_Arbiter    文件:TaintFrameModelingVisitor.java   
@Override
public void visitCHECKCAST(CHECKCAST obj) {
    // cast to a safe object type
    ObjectType objectType = obj.getLoadClassType(cpg);
    if (objectType == null) {
        return;
    }

    String objectTypeSignature = objectType.getSignature();

    if(!taintConfig.isClassTaintSafe(objectTypeSignature)) {
        return;
    }

    try {
        getFrame().popValue();
        pushSafe();
    }
    catch (DataflowAnalysisException ex) {
        throw new InvalidBytecodeException("empty stack for checkcast", ex);
    }
}
项目:antipatterns    文件:FinalSignatureDetector.java   
private static boolean isIllegalFinalType(Type type, ClassContext classContext) {
    if (type instanceof ObjectType) {
        try {
            String className = ((ObjectType) type).getClassName();
            if (className.startsWith("java.")) {
                // Types in java.lang are final for security reasons.
                return false;
            }
            JavaClass cls = classContext.getAnalysisContext().lookupClass(className);
            return cls.isFinal() && !cls.isEnum();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    return false;
}
项目:JRemoting    文件:BcelStubGenerator.java   
/**
 * Creates a method class$(String) which is used
 * during SomeClass.class instruction
 *
 * @param generatedClassName the instance class name
 */
protected void createHelperMethodForDotClassCalls(String generatedClassName) {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(Constants.ACC_STATIC, new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, new String[]{"arg0"}, "class$", generatedClassName, il, constantsPool);
    InstructionHandle ih0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
    il.append(factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, Constants.INVOKESTATIC));
    InstructionHandle ih4 = il.append(InstructionFactory.createReturn(Type.OBJECT));
    InstructionHandle ih5 = il.append(InstructionFactory.createStore(Type.OBJECT, 1));
    il.append(factory.createNew("java.lang.NoClassDefFoundError"));
    il.append(InstructionConstants.DUP);
    il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
    il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
    il.append(factory.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ATHROW);
    method.addExceptionHandler(ih0, ih4, ih5, new ObjectType("java.lang.ClassNotFoundException"));
    method.setMaxStack();
    method.setMaxLocals();
    classGen.addMethod(method.getMethod());
    il.dispose();
}
项目:JRemoting    文件:BcelStubGenerator.java   
private void generateEqualsMethod(String generatedClassName) {

        /* public boolean equals(Object o) {
         *   return stubHelper.isEquals(this,o);
         * }
         */

        InstructionList il = new InstructionList();
        MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.BOOLEAN, new Type[]{Type.OBJECT}, new String[]{"arg0"}, "equals", generatedClassName, il, constantsPool);

        il.append(InstructionFactory.createLoad(Type.OBJECT, 0));

        il.append(factory.createFieldAccess(generatedClassName, "stubHelper", new ObjectType("org.codehaus.jremoting.client.StubHelper"), Constants.GETFIELD));
        il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
        il.append(InstructionFactory.createLoad(Type.OBJECT, 1));

        il.append(factory.createInvoke("org.codehaus.jremoting.client.StubHelper", "isEquals", Type.BOOLEAN, new Type[]{Type.OBJECT, Type.OBJECT}, Constants.INVOKEINTERFACE));
        il.append(InstructionFactory.createReturn(Type.INT));
        method.setMaxStack();
        method.setMaxLocals();
        classGen.addMethod(method.getMethod());
        il.dispose();
    }
项目:JRemoting    文件:BcelStubGenerator.java   
/**
 * Method getBCELType.
 * Maps the java datatype and the BCEL datatype
 *
 * @param clazz the class
 * @return Type the type
 */
protected Type getBCELType(Class clazz) {

    if (clazz.isPrimitive()) {
        return getBCELPrimitiveType(clazz.getName());
    } else if (!clazz.isArray()) {
        return new ObjectType(clazz.getName());
    } else {
        String className = clazz.getName();
        int index = className.lastIndexOf('[');
        int arrayDepth = className.indexOf('[') - className.lastIndexOf('[') + 1;
        if (className.charAt(index + 1) == 'L') {
            return new ArrayType(new ObjectType(clazz.getComponentType().getName()), arrayDepth);
        }

        return new ArrayType(getBCELPrimitiveType(className.substring(arrayDepth)), arrayDepth);
    }

}
项目:FindBug-for-Domino-Designer    文件:BlockTypeAnalysis.java   
public void transfer(BasicBlock basicBlock, @CheckForNull InstructionHandle end, BlockType start, BlockType result)
        throws DataflowAnalysisException {
    result.copyFrom(start);

    if (start.isValid()) {
        if (basicBlock.isExceptionHandler()) {
            CodeExceptionGen exceptionGen = basicBlock.getExceptionGen();
            ObjectType catchType = exceptionGen.getCatchType();
            if (catchType == null) {
                // Probably a finally block, or a synchronized block
                // exception-compensation catch block.
                result.pushFinally();
            } else {
                // Catch type was explicitly specified:
                // this is probably a programmer-written catch block
                result.pushCatch();
            }
        }
    }
}
项目:findbugs-all-the-bugs    文件:AnyMethodReturnValueStreamFactory.java   
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;
}
项目:findbugs-all-the-bugs    文件:ObligationFactory.java   
/**
 * Get array of Obligation types corresponding to the parameters of the
 * given method.
 * 
 * @param xmethod
 *            a method
 * @return array of Obligation types for each of the method's parameters; a
 *         null element means the corresponding parameter is not an
 *         Obligation type
 */
public Obligation[] getParameterObligationTypes(XMethod xmethod) {
    Type[] paramTypes = Type.getArgumentTypes(xmethod.getSignature());
    Obligation[] result = new Obligation[paramTypes.length];
    for (int i = 0; i < paramTypes.length; i++) {
        if (!(paramTypes[i] instanceof ObjectType)) {
            continue;
        }
        try {
            result[i] = getObligationByType((ObjectType) paramTypes[i]);
        } catch (ClassNotFoundException e) {
            Global.getAnalysisCache().getErrorLogger().reportMissingClass(e);
        }
    }
    return result;
}
项目:autodao    文件:DAOAnalysis.java   
protected void addFindMethod(ParsedMethod m) {
    GeneratedMethod gm = new GeneratedMethod(m);
    InstructionList il = gm.start();

    writeMethodPreamble(gm, il);
    il.append(new PUSH(_cp, (ObjectType) gm.getReturnType()));

    m.getArguments()[0].pushAsObject(il);

    il.append(_factory.createInvoke(EM_TYPE, "find", Type.OBJECT,
        new Type[] { Type.CLASS, Type.OBJECT }, Constants.INVOKEINTERFACE));

    il.append(_factory.createCheckCast(((ReferenceType) gm.getReturnType())));
    il.append(InstructionFactory.createReturn(gm.getReturnType()));

    gm.done();
}
项目:findbugs-all-the-bugs    文件:ObjectTypeFactory.java   
public static ObjectType getInstance(@DottedClassName String s) {
    if (FindBugs.DEBUG && s.startsWith("[")) {
        throw new IllegalArgumentException("Cannot create an ObjectType to represent an array type: " + s);
    }
    if (s.endsWith(";"))
        throw new IllegalArgumentException(s);
    if (s.indexOf("/") >= 0) {
        s = s.replace('/', '.');
    }

    Map<String, ObjectType> map = instance.get();
    ObjectType result = map.get(s);
    if (result != null)
        return result;
    result = ObjectType.getInstance(s);
    map.put(s, result);
    return result;
}
项目:findbugs-all-the-bugs    文件:Subtypes2.java   
/**
 * 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);
}
项目:findbugs-all-the-bugs    文件:Hierarchy2.java   
/**
 * Find the declared exceptions for the method called by given instruction.
 * 
 * @param inv
 *            the InvokeInstruction
 * @param cpg
 *            the ConstantPoolGen used by the class the InvokeInstruction
 *            belongs to
 * @return array of ObjectTypes of thrown exceptions, or null if we can't
 *         find the method implementation
 */
public static @CheckForNull
ObjectType[] findDeclaredExceptions(InvokeInstruction inv, ConstantPoolGen cpg)  {
    XMethod method = findInvocationLeastUpperBound(inv, cpg, inv instanceof INVOKESTATIC ? Hierarchy.STATIC_METHOD
            : Hierarchy.INSTANCE_METHOD);

    if (method == null)
        return null;
    String[] exceptions = method.getThrownExceptions();

    if (exceptions == null)
        return new ObjectType[0];

    ObjectType[] result = new ObjectType[exceptions.length];
    for (int i = 0; i < exceptions.length; ++i) {
        result[i] = ObjectTypeFactory.getInstance(ClassName.toDottedClassName(exceptions[i]));
    }
    return result;
}
项目:findbugs-all-the-bugs    文件:BlockTypeAnalysis.java   
public void transfer(BasicBlock basicBlock, @CheckForNull InstructionHandle end, BlockType start, BlockType result)
        throws DataflowAnalysisException {
    result.copyFrom(start);

    if (start.isValid()) {
        if (basicBlock.isExceptionHandler()) {
            CodeExceptionGen exceptionGen = basicBlock.getExceptionGen();
            ObjectType catchType = exceptionGen.getCatchType();
            if (catchType == null) {
                // Probably a finally block, or a synchronized block
                // exception-compensation catch block.
                result.pushFinally();
            } else {
                // Catch type was explicitly specified:
                // this is probably a programmer-written catch block
                result.pushCatch();
            }
        }
    }
}
项目:findbugs-all-the-bugs    文件:ExceptionSet.java   
@Override
public String toString() {
    StringBuilder buf = new StringBuilder();
    buf.append('{');
    boolean first = true;
    for (ThrownExceptionIterator i = iterator(); i.hasNext();) {
        ObjectType type = i.next();
        if (first)
            first = false;
        else
            buf.append(',');
        boolean implicit = !i.isExplicit();
        if (implicit)
            buf.append('[');
        buf.append(type.toString());
        if (implicit)
            buf.append(']');
    }
    buf.append('}');
    return buf.toString();
}
项目:FindBug-for-Domino-Designer    文件:Hierarchy2.java   
/**
 * Find the declared exceptions for the method called by given instruction.
 * 
 * @param inv
 *            the InvokeInstruction
 * @param cpg
 *            the ConstantPoolGen used by the class the InvokeInstruction
 *            belongs to
 * @return array of ObjectTypes of thrown exceptions, or null if we can't
 *         find the method implementation
 */
public static @CheckForNull
ObjectType[] findDeclaredExceptions(InvokeInstruction inv, ConstantPoolGen cpg)  {
    XMethod method = findInvocationLeastUpperBound(inv, cpg, inv instanceof INVOKESTATIC ? Hierarchy.STATIC_METHOD
            : Hierarchy.INSTANCE_METHOD);

    if (method == null)
        return null;
    String[] exceptions = method.getThrownExceptions();

    if (exceptions == null)
        return new ObjectType[0];

    ObjectType[] result = new ObjectType[exceptions.length];
    for (int i = 0; i < exceptions.length; ++i) {
        result[i] = ObjectTypeFactory.getInstance(ClassName.toDottedClassName(exceptions[i]));
    }
    return result;
}
项目:FindBug-for-Domino-Designer    文件:AnyMethodReturnValueStreamFactory.java   
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;
}
项目:FindBug-for-Domino-Designer    文件:ObligationFactory.java   
/**
 * Get array of Obligation types corresponding to the parameters of the
 * given method.
 * 
 * @param xmethod
 *            a method
 * @return array of Obligation types for each of the method's parameters; a
 *         null element means the corresponding parameter is not an
 *         Obligation type
 */
public Obligation[] getParameterObligationTypes(XMethod xmethod) {
    Type[] paramTypes = Type.getArgumentTypes(xmethod.getSignature());
    Obligation[] result = new Obligation[paramTypes.length];
    for (int i = 0; i < paramTypes.length; i++) {
        if (!(paramTypes[i] instanceof ObjectType)) {
            continue;
        }
        try {
            result[i] = getObligationByType((ObjectType) paramTypes[i]);
        } catch (ClassNotFoundException e) {
            Global.getAnalysisCache().getErrorLogger().reportMissingClass(e);
        }
    }
    return result;
}
项目:autodao    文件:DAOAnalysis.java   
protected void processQuerySetOperation(ParsedMethod m, Argument arg,
        InstructionList il, String methodName, String queryClass) {
    Class<?> type = arg.getArgumentClass();
    if (type == Integer.class) {
        arg.push(il);
        il.append(_factory.createInvoke(INT_CLASS, "intValue", Type.INT,
            Type.NO_ARGS, Constants.INVOKEINTERFACE));
    } else if (type == int.class) {
        arg.pushPrimitive(il);
    } else {
        throw new IllegalArgumentException("Parameter #" + arg.getArgNo()
                + " of " + m.getMethod() + " needs to be Integer or int.");
    }
    il.append(_factory
            .createInvoke(queryClass, methodName,
                new ObjectType(queryClass), new Type[] { Type.INT },
                Constants.INVOKEINTERFACE));
}
项目:FindBug-for-Domino-Designer    文件:ExceptionHandlerMap.java   
public static CodeExceptionGen merge(@CheckForNull TypeMerger m, CodeExceptionGen e1, CodeExceptionGen e2) {
    if (e1 == null) return e2;
    if (e2 == null) return e1;
    if (m == null)
        return e1;
    if ( ! e1.getHandlerPC().equals( e2.getHandlerPC() ) ){
        // log error
                    return e1;
    }
    try {
        Type t = m.mergeTypes(e1.getCatchType(), e2.getCatchType());
        return new CodeExceptionGen(e1.getStartPC(), e1.getEndPC(), e1.getHandlerPC(), (ObjectType) t);
    } catch (DataflowAnalysisException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return e1;
    }
}
项目:FindBug-for-Domino-Designer    文件:ObjectTypeFactory.java   
public static ObjectType getInstance(@DottedClassName String s) {
    if (FindBugs.DEBUG && s.startsWith("[")) {
        throw new IllegalArgumentException("Cannot create an ObjectType to represent an array type: " + s);
    }
    if (s.endsWith(";"))
        throw new IllegalArgumentException(s);
    if (s.indexOf("/") >= 0) {
        s = s.replace('/', '.');
    }

    Map<String, ObjectType> map = instance.get();
    ObjectType result = map.get(s);
    if (result != null)
        return result;
    result = ObjectType.getInstance(s);
    map.put(s, result);
    return result;
}
项目:FindBug-for-Domino-Designer    文件:Subtypes2.java   
/**
 * 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);
}
项目:parabuild-ci    文件:IOStreamFactory.java   
public IOStreamFactory(String baseClass, String[] uninterestingSubclassList, String bugType) {
    this.baseClassType = new ObjectType(baseClass);
    this.uninterestingSubclassTypeList = new ObjectType[uninterestingSubclassList.length];
    for (int i = 0; i < uninterestingSubclassList.length; ++i) {
        this.uninterestingSubclassTypeList[i] = new ObjectType(uninterestingSubclassList[i]);
    }
    this.bugType = bugType;
}
项目:parabuild-ci    文件:IOStreamFactory.java   
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
                           RepositoryLookupFailureCallback lookupFailureCallback) {

    try {
        Instruction ins = location.getHandle().getInstruction();

        if (ins.getOpcode() != Constants.NEW)
            return null;

        if (Hierarchy.isSubtype(type, baseClassType)) {
            boolean isUninteresting = false;
            for (int i = 0; i < uninterestingSubclassTypeList.length; ++i) {
                if (Hierarchy.isSubtype(type, uninterestingSubclassTypeList[i])) {
                    isUninteresting = true;
                    break;
                }
            }
            Stream result = new Stream(location, type.getClassName(), baseClassType.getClassName())
                    .setIgnoreImplicitExceptions(true);
            if (!isUninteresting)
                result.setInteresting(bugType);
            return result;
        }
    } catch (ClassNotFoundException e) {
        lookupFailureCallback.reportMissingClass(e);
    }

    return null;
}
项目:parabuild-ci    文件:InstanceFieldLoadStreamFactory.java   
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
                           RepositoryLookupFailureCallback lookupFailureCallback) {

    Instruction ins = location.getHandle().getInstruction();
    if (ins.getOpcode() != Constants.GETFIELD)
        return null;

    String fieldClass = type.getClassName();
    try {
        if (fieldClass.startsWith("["))
            return null;
        if (!Hierarchy.isSubtype(fieldClass, streamBaseClass))
            return null;

        Stream stream = new Stream(location, fieldClass, streamBaseClass);
        stream.setIsOpenOnCreation(true);
        stream.setOpenLocation(location);
        if (bugPatternType != null)
            stream.setInteresting(bugPatternType);

        //System.out.println("Instance field stream at " + location);
        return stream;
    } catch (ClassNotFoundException e) {
        lookupFailureCallback.reportMissingClass(e);
        return null;
    }
}
项目:parabuild-ci    文件:StandardTypeMerger.java   
/**
 * Default implementation of merging reference types.
 * This just returns the first common superclass, which is compliant
 * with the JVM Spec.  Subclasses may override this method
 * in order to implement extended type rules.
 *
 * @param aRef a ReferenceType
 * @param bRef a ReferenceType
 * @return the merged Type
 */
protected Type mergeReferenceTypes(ReferenceType aRef, ReferenceType bRef) throws DataflowAnalysisException {
    // Two concrete object types.
    // According to the JVM spec, 2nd edition, 4.9.2,
    // the result of merging types is the "first common superclass".
    // Interfaces are NOT considered!
    // This will use the Repository to look up classes.
    try {
        // Special case: ExceptionObjectTypes.
        // We want to preserve the ExceptionSets associated,
        // in order to track the exact set of exceptions
        if (isObjectType(aRef.getType()) && isObjectType(bRef.getType()) &&
                (aRef.getType() == T_EXCEPTION || bRef.getType() == T_EXCEPTION)) {
            ExceptionSet union = exceptionSetFactory.createExceptionSet();

            updateExceptionSet(union, (ObjectType) aRef);
            updateExceptionSet(union, (ObjectType) bRef);

            return ExceptionObjectType.fromExceptionSet(union);
        }

        return aRef.getFirstCommonSuperclass(bRef);
    } catch (ClassNotFoundException e) {
        lookupFailureCallback.reportMissingClass(e);
        throw new DataflowAnalysisException("Repository lookup failure: " + e.toString(), e);
    }
}
项目:parabuild-ci    文件:ExceptionSetFactory.java   
int getIndexOfType(ObjectType type) {
    Integer index = typeIndexMap.get(type);
    if (index == null) {
        index = new Integer(getNumTypes());
        typeList.add(type);
        typeIndexMap.put(type, index);
    }
    return index.intValue();
}
项目:parabuild-ci    文件:ExceptionObjectType.java   
/**
 * 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() != T_OBJECT)
        return commonSupertype;

    ObjectType exceptionSupertype = (ObjectType) commonSupertype;
    return new ExceptionObjectType(exceptionSupertype.getClassName(), exceptionSet);
}
项目:parabuild-ci    文件:ExceptionSet.java   
public ObjectType next() {
    if (!hasNext())
        throw new NoSuchElementException();
    ObjectType result = factory.getType(next);
    last = next;
    return result;
}
项目:parabuild-ci    文件:ExceptionSet.java   
/**
 * Add an exception.
 *
 * @param type     the exception type
 * @param explicit true if the exception is explicitly declared
 *                 or thrown, false if implicit
 */
public void add(ObjectType type, boolean explicit) {
    int index = factory.getIndexOfType(type);
    if (!exceptionSet.get(index))
        ++size;
    exceptionSet.set(index);
    if (explicit)
        explicitSet.set(index);

    commonSupertype = null;
}
项目:parabuild-ci    文件:ExceptionSet.java   
/**
 * Return whether or not the set contains any checked exceptions.
 */
public boolean containsCheckedExceptions() throws ClassNotFoundException {
    for (ThrownExceptionIterator i = iterator(); i.hasNext();) {
        ObjectType type = i.next();
        if (!Hierarchy.isUncheckedException(type))
            return true;
    }
    return false;
}
项目:Android_Code_Arbiter    文件:TaintFrameModelingVisitor.java   
@Override
public void visitNEW(NEW obj) {
    Taint taint = new Taint(Taint.State.SAFE);
    ObjectType type = obj.getLoadClassType(cpg);
    taint.setRealInstanceClass(type);
    if (FindSecBugsGlobalConfig.getInstance().isDebugTaintState()) {
        taint.setDebugInfo("new " + type.getClassName() + "()");
    }
    getFrame().pushValue(taint);
}
项目:root4j    文件:Clones2Builder.java   
private void generateStaticFields(RootClass k, ConstantPoolGen cp, ClassGen cg)
{
   RootMember[] members = k.getMembers();
   for (int i = 0; i < members.length; i++)
   {
      BasicMember member = (BasicMember) members[i];
      TLeaf leaf = (TLeaf) lMap.get(member);
      if (leaf != null)
      {
         Type type = new ObjectType(leaf.getClass().getName());
         FieldGen fg = new FieldGen(ACC_PUBLIC | ACC_STATIC, type, member.getName() + "Leaf", cp);
         cg.addField(fg.getField());
      }
   }
}
项目:root4j    文件:Clone2Builder.java   
private static void generateMethods(RootClass k, ConstantPoolGen cp, InstructionList il, InstructionFactory factory, ClassGen cg, String className, String clonesClassName)
{
   RootMember[] members = k.getMembers();

   for (int i = 0; i < members.length; i++)
   {
      BasicMember member = (BasicMember) members[i];

      Type type = member.getJavaType();
      Type arrayType = new ArrayType(type, 1);
      MethodGen mg = new MethodGen(ACC_PUBLIC, type, null, null, nameMangler.mangleMember(member.getName()), className, il, cp);
      il.append(InstructionConstants.ALOAD_0);
      il.append(factory.createGetField(className, "clones", new ObjectType(clonesClassName)));
      il.append(InstructionConstants.ALOAD_0);
      il.append(factory.createGetField(className, "index", Type.INT));

      il.append(factory.createInvoke(clonesClassName, nameMangler.mangleMember(member.getName()), type, new Type[]
            {
               Type.INT
            }, INVOKEVIRTUAL));

      il.append(InstructionFactory.createReturn(type));
      mg.setMaxStack();
      mg.setMaxLocals();
      cg.addMethod(mg.getMethod());
      il.dispose();
   }
}
项目:cashmere    文件:MethodTable.java   
private Type[] getParamTypesThis(Method m) {
Type[] params = getParamTypesNoThis(m);

if (m.isStatic()) {
    return params;
}

Type[] newparams = new Type[1 + params.length];
newparams[0] = new ObjectType(c.getClassName());
for (int i = 0; i < params.length; i++) {
    newparams[i + 1] = params[i];
}
return newparams;
   }
项目:cashmere    文件:Cashmerec.java   
public Cashmerec() {
    cashmereObjectClass = lookupClass("ibis.cashmere.CashmereObject");
    spawnCounterType = new ObjectType(
            "ibis.cashmere.impl.spawnSync.SpawnCounter");
    irType = new ObjectType("ibis.cashmere.impl.spawnSync.InvocationRecord");
    cashmereType = new ObjectType("ibis.cashmere.impl.Cashmere");
    writeMethodsInterface = lookupClass(
            "ibis.cashmere.WriteMethodsInterface");
}
项目:cashmere    文件:Cashmerec.java   
InstructionHandle insertDeleteLocalRecord(MethodGen m, InstructionList il,
    InstructionHandle i, int maxLocals) {
    String local_record_name = localRecordName(m);

    // Note: maxLocals has been recomputed at this point.
    il.insert(i, new ALOAD(maxLocals - 5));
    il.insert(i, ins_f.createInvoke(local_record_name, "delete", Type.VOID,
        new Type[] { new ObjectType(local_record_name) },
        Constants.INVOKESTATIC));

    return i;
}