Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.Type


        }

        private void handleLoad(FieldInstruction obj) {
            consumeStack(obj);

            Type type = obj.getType(getCPG());
            if (!type.getSignature().equals(STRING_SIGNATURE)) {
                throw new IllegalArgumentException("type is not String: " + type);
            }
            try {
                String className = obj.getClassName(getCPG());
                String fieldName = obj.getName(getCPG());
View Full Code Here


                continue;
            }

            // Check if field type is a reference type
            FieldInstruction fins = (FieldInstruction) ins;
            Type fieldType = fins.getType(cpg);
            if (!(fieldType instanceof ReferenceType)) {
                continue;
            }

            // Find the exact field being stored into
            XField xfield = Hierarchy.findXField(fins, cpg);
            if (xfield == null) {
                continue;
            }

            // Skip public and protected fields, since it is reasonable to
            // assume
            // we won't see every store to those fields
            if (xfield.isPublic() || xfield.isProtected()) {
                continue;
            }

            // The top value on the stack is the one which will be stored
            // into the field
            TypeFrame frame = typeDataflow.getFactAtLocation(location);
            if (!frame.isValid()) {
                continue;
            }
            Type storeType = frame.getTopValue();
            if (!(storeType instanceof ReferenceType)) {
                continue;
            }

            // Get or create the field store type set
            FieldStoreType property = database.getProperty(xfield.getFieldDescriptor());
            if (property == null) {
                property = new FieldStoreType();
                database.setProperty(xfield.getFieldDescriptor(), property);
            }

            // Add the store type to the set
            property.addTypeSignature(storeType.getSignature());
        }
    }
View Full Code Here

            TypeFrame frame = typeDataflow.getFactAtLocation(location);
            if (!frame.isValid()) {
                // This basic block is probably dead
                continue;
            }
            Type operandType = frame.getTopValue();

            if (operandType.equals(TopType.instance())) {
                // unreachable
                continue;
            }
            if (!(operandType instanceof ReferenceType)) {
                // Shouldn't happen - illegal bytecode
View Full Code Here

        if (!typeFrame.isValid()) {
            return new HashSet<JavaClassAndMethod>();
        }

        Type receiverType;
        boolean receiverTypeIsExact;

        if (opcode == Constants.INVOKESPECIAL) {
            // invokespecial instructions are dispatched to EXACTLY
            // the class specified by the instruction
View Full Code Here

    }

    public static double isDeepSerializable(ReferenceType type) throws ClassNotFoundException {
        if (type instanceof ArrayType) {
            ArrayType a = (ArrayType) type;
            Type t = a.getBasicType();
            if (t instanceof ReferenceType) {
                type = (ReferenceType) t;
            } else {
                return 1.0;
            }
View Full Code Here

    }
    public static ReferenceType getLeastSerializableTypeComponent(ReferenceType type)
            throws ClassNotFoundException {
        if (type instanceof ArrayType) {
            ArrayType a = (ArrayType) type;
            Type t = a.getBasicType();
            if (t instanceof ReferenceType) {
                type = (ReferenceType) t;
            } else {
                return type;
            }
View Full Code Here

            // Must have same number of dimensions
            if (typeAsArrayType.getDimensions() < possibleSupertypeAsArrayType.getDimensions()) {
                return false;
            }
            Type possibleSupertypeBasicType = possibleSupertypeAsArrayType.getBasicType();
            if (!(possibleSupertypeBasicType instanceof ObjectType)) {
                return false;
            }
            Type typeBasicType = typeAsArrayType.getBasicType();

            // If dimensions differ, see if element types are compatible.
            if (typeAsArrayType.getDimensions() > possibleSupertypeAsArrayType.getDimensions()) {
                return isSubtype(
                        new ArrayType(typeBasicType, typeAsArrayType.getDimensions()
View Full Code Here

     */
    private ReferenceType computeFirstCommonSuperclassOfSameDimensionArrays(ArrayType aArrType, ArrayType bArrType)
            throws ClassNotFoundException {
        assert aArrType.getDimensions() == bArrType.getDimensions();

        Type aBaseType = aArrType.getBasicType();
        Type bBaseType = bArrType.getBasicType();
        boolean aBaseIsObjectType = (aBaseType instanceof ObjectType);
        boolean bBaseIsObjectType = (bBaseType instanceof ObjectType);

        if (!aBaseIsObjectType || !bBaseIsObjectType) {
            assert (aBaseType instanceof BasicType) || (bBaseType instanceof BasicType);
View Full Code Here

        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;
View Full Code Here

        }
        GenericSignatureParser parser = new GenericSignatureParser(args[0]);
        for (Iterator<String> i = parser.parameterSignatureIterator(); i.hasNext();) {
            String s = i.next();
            System.out.println(s);
            Type t = GenericUtilities.getType(s);
            System.out.println("-~- " + t);
            if (t instanceof ObjectType) {
                System.out.println("-~- " + ((ObjectType) t).toString());
            }
            if (t != null) {
                System.out.println("-~- " + t.getClass());
            }
        }
        System.out.println(parser.getNumParameters() + " parameter(s)");

    }
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.