Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.ArrayType


                s_typeMap.put(base, type);
            }
           
            // create and record array type
            if (dimen > 0) {
                type = new ArrayType(type, dimen);
                s_typeMap.put(name, type);
            }
        }
        return type;
    }
View Full Code Here


        org.apache.bcel.generic.InstructionFactory factory = new org.apache.bcel.generic.InstructionFactory(cg);

        MethodGen mg = new MethodGen(Constants.ACC_STATIC
                | Constants.ACC_PUBLIC,
                org.apache.bcel.generic.Type.VOID,
                new org.apache.bcel.generic.Type[] { new ArrayType(org.apache.bcel.generic.Type.STRING,
                        1) },
                null,
                "main",
                "HelloWorld",
                il,
View Full Code Here

            } else {
                throw new InternalError();
            }

        } else if (clazz.isArray()) {
            return new ArrayType(translate(clazz.getComponentType()), 1);

        } else {

            return new ObjectType(clazz.getName());
        }
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

        return result;
    }
    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

                return false;
            }

            // Check array/array subtype relationship

            ArrayType typeAsArrayType = (ArrayType) type;
            ArrayType possibleSupertypeAsArrayType = (ArrayType) possibleSupertype;

            // 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()
                                - possibleSupertypeAsArrayType.getDimensions()), (ObjectType) possibleSupertypeBasicType);
            }

            // type's base type must be a subtype of possibleSupertype's base
            // type.
            // Note that neither base type can be a non-ObjectType if we are to
View Full Code Here

        boolean bIsArrayType = (b instanceof ArrayType);

        if (aIsArrayType && bIsArrayType) {
            // Merging array types - kind of a pain.

            ArrayType aArrType = (ArrayType) a;
            ArrayType bArrType = (ArrayType) b;

            if (aArrType.getDimensions() == bArrType.getDimensions()) {
                return computeFirstCommonSuperclassOfSameDimensionArrays(aArrType, bArrType);
            } else {
                return computeFirstCommonSuperclassOfDifferentDimensionArrays(aArrType, bArrType);
            }
        }
View Full Code Here

            assert (aBaseType instanceof BasicType) || (bBaseType instanceof BasicType);

            if (aArrType.getDimensions() > 1) {
                // E.g.: first common supertype of int[][] and WHATEVER[][] is
                // Object[]
                return new ArrayType(Type.OBJECT, aArrType.getDimensions() - 1);
            } else {
                assert aArrType.getDimensions() == 1;
                // E.g.: first common supertype type of int[] and WHATEVER[] is
                // Object
                return Type.OBJECT;
            }
        } else {
            assert (aBaseType instanceof ObjectType);
            assert (bBaseType instanceof ObjectType);

            // Base types are both ObjectTypes, and number of dimensions is
            // same.
            // We just need to find the first common supertype of base types
            // and return a new ArrayType using that base type.
            ObjectType firstCommonBaseType = getFirstCommonSuperclass((ObjectType) aBaseType, (ObjectType) bBaseType);
            return new ArrayType(firstCommonBaseType, aArrType.getDimensions());
        }
    }
View Full Code Here

                // Object[]
                // because f.c.s. of int[] and char[][] is Object
                // - first common supertype of int[][][] and char[][][][][] is
                // Object[][]
                // because f.c.s. of int[] and char[][][] is Object
                return new ArrayType(Type.OBJECT, maxDimensions - minDimensions);
            }
        } else {
            // Both a and b have base types which are ObjectTypes.
            // Since the arrays have different numbers of dimensions, the
            // f.c.s. will have Object as its base type.
            // E.g., f.c.s. of Cat[] and Dog[][] is Object[]
            return new ArrayType(Type.OBJECT, Math.min(aArrType.getDimensions(), bArrType.getDimensions()));
        }
    }
View Full Code Here

                }
                Type componentType = getType(signature.substring(index));
                if (componentType == null) {
                    return null;
                }
                return new ArrayType(componentType, index);

            } else if (signature.startsWith("*")) {
                return new GenericObjectType("*");

            } else if (signature.startsWith("+") || signature.startsWith("-")) {
View Full Code Here

TOP

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

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.