Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.Type


     * @return corresponding type
     */
    public static Type typeFromName(String name) {
       
        // first check for type already created
        Type type = (Type)s_typeMap.get(name);
        if (type == null) {
           
            // new type, strip off array dimensions
            int dimen = 0;
            String base = name;
View Full Code Here


               
                // make sure the return type is compatible
                boolean match = true;
                int ndiff = 0;
                if (ret != null) {
                    Type type = method.getReturnType();
                    match = isAssignmentCompatible(ret, type);
                }
                if (match && args != null) {
                   
                    // check closeness of argument types
                    Type[] types = method.getArgumentTypes();
                    if (args.length == types.length) {
                        for (int j = 0; j < args.length; j++) {
                            Type type = types[j];
                            Type arg = args[j];
                            if (!type.equals(arg)) {
                                ndiff++;
                                match = isAssignmentCompatible(arg, type);
                                if (!match) {
                                    break;
View Full Code Here

     * @param ret return value type (<code>null</code> if indeterminant)
     * @param args argument value types (<code>null</code> if indeterminant)
     * @return method information, or <code>null</code> if method not found
     */
    public ClassItem getBestMethod(String name, String ret, String[] args) {
        Type rtype = null;
        if (ret != null) {
            rtype = ClassItem.typeFromName(ret);
        }
        Type[] atypes = null;
        if (args != null) {
View Full Code Here

           
            // set up for constructing new method
            String name = m_container.getBindingRoot().getPrefix() +
                NEWINSTANCE_SUFFIX;
            ClassFile cf = m_class.getMungedFile();
            Type type = m_class.getClassFile().getType();
            ContextMethodBuilder mb = new ContextMethodBuilder(name, type,
                new Type[] {type, UNMARSHALCONTEXT_TYPE}, cf,
                Constants.ACC_PUBLIC|Constants.ACC_STATIC, 0,
                m_class.getClassName(), 1, UNMARSHALLING_CONTEXT);
           
View Full Code Here

        if (method == null) {

            // set up for constructing new method
            String name = ACCESS_PREFIX + "load_" + item.getName();
            ClassFile cf = item.getClassFile();
            Type type = Type.getType(Utility.getSignature(item.getTypeName()));
            MethodBuilder mb = new ExceptionMethodBuilder(name, type,
                EMPTY_TYPE_ARGS, cf, Constants.ACC_PUBLIC);

            // add the actual access method code
            mb.appendLoadLocal(0);
View Full Code Here

        if (method == null) {

            // set up for constructing new method
            String name = ACCESS_PREFIX + "store_" + item.getName();
            ClassFile cf = item.getClassFile();
            Type type;
            if (item.isMethod()) {
                String sig = item.getSignature();
                int start = sig.indexOf('(');
                int end = sig.indexOf(')');
                type = Type.getType(sig.substring(start + 1, end));
View Full Code Here

                    handle = lastLogHandle;
                }
                if (inst instanceof GETSTATIC) {
                    getStatic = (GETSTATIC) inst;
                    Type type = getStatic.getFieldType(cp);
                    logger.info(
                        "Found a GETSTATIC instruction of type: "
                            + type.toString());

                    if (getStatic
                        .getFieldName(cp)
                        .equals(loggerAttribute.getName())) {
                        logger.info("This is a logger access");
View Full Code Here

                        this.addMessage("Warning: ReturnInstruction '"+ic+"' may leave method with an uninitialized object on the operand stack '"+os+"'.");
                    }
                }
                //see JVM $4.8.2
                //TODO implement all based on stack
                Type returnedType = null;
                if( ih.getPrev().getInstruction() instanceof InvokeInstruction )
                {
                    returnedType = ((InvokeInstruction)ih.getPrev().getInstruction()).getType(m.getConstantPool());
                }
                if( ih.getPrev().getInstruction() instanceof LoadInstruction )
                {
                    int index = ((LoadInstruction)ih.getPrev().getInstruction()).getIndex();
                    returnedType = lvs.get(index);
                }
                if( ih.getPrev().getInstruction() instanceof GETFIELD )
                {
                    returnedType = ((GETFIELD)ih.getPrev().getInstruction()).getType(m.getConstantPool());
                }
                if( returnedType != null )
                {
                    if( returnedType instanceof ObjectType )
                    {
                        try
                        {
                            if( !((ObjectType)returnedType).isAssignmentCompatibleWith(m.getReturnType()) )
                            {
                                throw new StructuralCodeConstraintException("Returned type "+returnedType+" does not match Method's return type "+m.getReturnType());
                            }
                        }
                        catch (Exception e)
                        {
                            //dont know what do do now, so raise RuntimeException
                            throw new RuntimeException(e);
                        }
                    }
                    else if( !returnedType.equals(m.getReturnType()) )
                    {
                        throw new StructuralCodeConstraintException("Returned type "+returnedType+" does not match Method's return type "+m.getReturnType());
                    }
                }
            }
View Full Code Here

                    "Handler's 1st argument must be super-type for "
                            + superClass);
        }

        // the type of data fields
        Type typeOfDataFields = translate(paramTypes[1]);

        if (Object[].class != paramTypes[2]) {
            throw new IllegalArgumentException(
                    "Handler's 3rd argument must be Object[]");
        }
View Full Code Here

                    "Handler's 1st argument must be super-type for "
                            + superClass);
        }

        // the type of data fields
        Type typeOfDataFields = translate(paramTypes[1]);

        if (Object[].class != paramTypes[2]) {
            throw new IllegalArgumentException(
                    "Handler's 3rd argument must be Object[]");
        }
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.