当前位置: 首页>>代码示例>>Java>>正文


Java Type.getType方法代码示例

本文整理汇总了Java中org.apache.bcel.generic.Type.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getType方法的具体用法?Java Type.getType怎么用?Java Type.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.bcel.generic.Type的用法示例。


在下文中一共展示了Type.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllLocalDecls

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
static String[] getAllLocalDecls(Method m) {
LocalVariable[] lt = getLocalTable(m).getLocalVariableTable();
Vector<String> v = new Vector<String>();

for (int i = 0; i < lt.length; i++) {
    LocalVariable l = lt[i];
    Type tp = Type.getType(l.getSignature());
    String e = tp.toString() + " "
	    + generatedLocalName(tp, l.getName()) + ";";
    if (!v.contains(e)) {
	v.addElement(e);
    }
}

String[] result = new String[v.size()];
result = v.toArray(result);
// for (int i = 0; i < v.size(); i++) {
// result[i] = (String) v.elementAt(i);
// System.out.println("localdecls for " + m + ": " + result[i]);
// }

return result;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:24,代码来源:MethodTable.java

示例2: mergeTypes

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
public Type mergeTypes(Type a, Type b) throws DataflowAnalysisException {
	byte aType = a.getType(), bType = b.getType();

	if (aType == T_TOP)			// Top is the identity element
		return b;
	else if (bType == T_TOP)	// Top is the identity element
		return a;
	else if (aType == T_BOTTOM || bType == T_BOTTOM)	// Bottom meet anything is bottom
		return BottomType.instance();
	else if (isReferenceType(aType) && isReferenceType(bType)) {	// Two object types!
		// Handle the Null type, which serves as a special "top"
		// value for reference types.
		if (aType == T_NULL)
			return b;
		else if (bType == T_NULL)
			return a;

		ReferenceType aRef = (ReferenceType) a;
		ReferenceType bRef = (ReferenceType) b;
		return mergeReferenceTypes(aRef, bRef);
	} else if (isReferenceType(aType) || isReferenceType(bType))	// Object meet non-object is bottom
		return BottomType.instance();
	else if (aType == bType)	// Same non-object type?
		return a;
	else if (isIntegerType(aType) && isIntegerType(bType)) // Two different integer types - use T_INT
		return Type.INT;
	else						// Default - types are incompatible
		return BottomType.instance();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:StandardTypeMerger.java

示例3: fromExceptionSet

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:ExceptionObjectType.java

示例4: getAllLocalTypes

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
static Type[] getAllLocalTypes(Method m) {
LocalVariable[] lt = getLocalTable(m).getLocalVariableTable();
Type[] result = new Type[lt.length];

for (int i = 0; i < lt.length; i++) {
    LocalVariable l = lt[i];
    Type tp = Type.getType(l.getSignature());
    result[i] = tp;
}

return result;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:13,代码来源:MethodTable.java

示例5: getAllLocalNames

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
static String[] getAllLocalNames(Method m) {
LocalVariable[] lt = getLocalTable(m).getLocalVariableTable();
String[] result = new String[lt.length];

for (int i = 0; i < lt.length; i++) {
    LocalVariable l = lt[i];
    Type tp = Type.getType(l.getSignature());
    String e = generatedLocalName(tp, l.getName());
    result[i] = e;
}
return result;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:13,代码来源:MethodTable.java

示例6: className

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
private static String className(Type type) {
    if (type.getType() <= Constants.T_VOID) {
        return PRIMITIVE_NAME;
    } else if (type instanceof ArrayType) {
        return className(((ArrayType) type).getBasicType());
    } else {
        return type.toString();
    }
}
 
开发者ID:Pyknic,项目名称:CK4J,代码行数:10,代码来源:Cbo.java

示例7: mergeSummary

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
public void mergeSummary(XField fieldOperand, OpcodeStack.Item mergeValue) {
    if (SystemProperties.ASSERTIONS_ENABLED) {
        String mSignature = mergeValue.getSignature();

        Type mergeType = Type.getType(mSignature);
        Type fieldType = Type.getType(fieldOperand.getSignature());
        IncompatibleTypes check = IncompatibleTypes.getPriorityForAssumingCompatible(mergeType, fieldType, false);
        if (check.getPriority() <= Priorities.NORMAL_PRIORITY) {
            AnalysisContext.logError(fieldOperand + " not compatible with " + mergeValue,
                    new IllegalArgumentException(check.toString()));
        }

    }

    OpcodeStack.Item oldSummary = summary.get(fieldOperand);
    if (oldSummary != null) {
        Item newValue = OpcodeStack.Item.merge(mergeValue, oldSummary);
        newValue.clearNewlyAllocated();
        summary.put(fieldOperand, newValue);
    } else {
        if (mergeValue.isNewlyAllocated()) {
            mergeValue = new OpcodeStack.Item(mergeValue);
            mergeValue.clearNewlyAllocated();
        }
        summary.put(fieldOperand, mergeValue);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:28,代码来源:FieldSummary.java

示例8: purgeBoringEntries

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
public void purgeBoringEntries() {
    Collection<FieldDescriptor> keys = new ArrayList<FieldDescriptor>(getKeys());
    for (FieldDescriptor f : keys) {
        String s = f.getSignature();
        FieldStoreType type = getProperty(f);
        Type fieldType = Type.getType(f.getSignature());
        if (!(fieldType instanceof ReferenceType)) {
            removeProperty(f);
            continue;
        }
        ReferenceType storeType = type.getLoadType((ReferenceType) fieldType);
        if (storeType.equals(fieldType))
            removeProperty(f);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:16,代码来源:FieldStoreTypeDatabase.java

示例9: mergeTypes

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
public Type mergeTypes(Type a, Type b) throws DataflowAnalysisException {
    byte aType = a.getType(), bType = b.getType();

    if (aType == T_TOP) // Top is the identity element
        return b;
    else if (bType == T_TOP) // Top is the identity element
        return a;
    else if (aType == T_BOTTOM || bType == T_BOTTOM) // Bottom meet anything
                                                     // is bottom
        return BottomType.instance();
    else if (isReferenceType(aType) && isReferenceType(bType)) { // Two
                                                                 // object
                                                                 // types!
        // Handle the Null type, which serves as a special "top"
        // value for reference types.
        if (aType == T_NULL)
            return b;
        else if (bType == T_NULL)
            return a;

        ReferenceType aRef = (ReferenceType) a;
        ReferenceType bRef = (ReferenceType) b;
        return mergeReferenceTypes(aRef, bRef);
    } else if (isReferenceType(aType) || isReferenceType(bType)) // Object
                                                                 // meet
                                                                 // non-object
                                                                 // is
                                                                 // bottom
        return BottomType.instance();
    else if (aType == bType) // Same non-object type?
        return a;
    else if (isIntegerType(aType) && isIntegerType(bType)) // Two different
                                                           // integer types
                                                           // - use T_INT
        return Type.INT;
    else
        // Default - types are incompatible
        return BottomType.instance();
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:40,代码来源:StandardTypeMerger.java

示例10: fromExceptionSet

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
/**
 * 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;

    String className = exceptionSupertype.getClassName();
    if (className.equals("java.lang.Throwable"))
        return exceptionSupertype;
    return new ExceptionObjectType(className, exceptionSet);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:21,代码来源:ExceptionObjectType.java

示例11: generateMethods

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
private static void generateMethods(RootClass k, ConstantPoolGen cp, InstructionList il, InstructionFactory factory, ClassGen cg, String className, Class implementedInterface)
{
   RootMember[] members = k.getMembers();
   for (int i = 0; i < members.length; i++)
   {
      Type type = ((BasicMember) members[i]).getJavaType();
      Type returnType = type;
      try
      {
         if (implementedInterface != null) returnType = Type.getType(implementedInterface.getMethod(nameMangler.mangleMember(members[i].getName()),(Class[]) null).getReturnType());
         if (!returnType.equals(type) && debugRoot)
         {
            System.err.println("Warning: Interface type mismatch "+implementedInterface.getName()+"."+nameMangler.mangleMember(members[i].getName())+" "+returnType+" "+type);
         }
      }
      catch (NoSuchMethodException x)
      {
      }
      if (cg.containsMethod(nameMangler.mangleMember(members[i].getName()), "()" + returnType.getSignature()) == null)
      {
         MethodGen mg = new MethodGen(ACC_PUBLIC, returnType, null, null, nameMangler.mangleMember(members[i].getName()), null, il, cp);
         if (members[i].getType() == null) // Dummy object
         {
            il.append(new PUSH(cp, "<<Unreadable>>"));
         }
         else
         {
            il.append(InstructionConstants.ALOAD_0);
            il.append(factory.createGetField(className, members[i].getName(), type));
         }
         if (!returnType.equals(type)  &&  !(returnType == Type.INT  &&  (type == Type.BYTE  ||  type == Type.CHAR  ||  type == Type.SHORT)))
             il.append(factory.createCast(type,returnType));

         il.append(InstructionFactory.createReturn(returnType));
         mg.setMaxStack();
         mg.setMaxLocals();
         cg.addMethod(mg.getMethod());
         il.dispose();
      }
   }
}
 
开发者ID:diana-hep,项目名称:root4j,代码行数:42,代码来源:ProxyBuilder.java

示例12: counterAdaptClass

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
byte[] counterAdaptClass(final InputStream is, final String name)
        throws Exception
{
    JavaClass jc = new ClassParser(is, name + ".class").parse();
    ClassGen cg = new ClassGen(jc);
    ConstantPoolGen cp = cg.getConstantPool();
    if (!cg.isInterface()) {
        FieldGen fg = new FieldGen(ACC_PUBLIC,
                Type.getType("I"),
                "_counter",
                cp);
        cg.addField(fg.getField());
    }
    Method[] ms = cg.getMethods();
    for (int j = 0; j < ms.length; ++j) {
        MethodGen mg = new MethodGen(ms[j], cg.getClassName(), cp);
        if (!mg.getName().equals("<init>") && !mg.isStatic()
                && !mg.isAbstract() && !mg.isNative())
        {
            if (mg.getInstructionList() != null) {
                InstructionList il = new InstructionList();
                il.append(new ALOAD(0));
                il.append(new ALOAD(0));
                il.append(new GETFIELD(cp.addFieldref(name, "_counter", "I")));
                il.append(new ICONST(1));
                il.append(new IADD());
                il.append(new PUTFIELD(cp.addFieldref(name, "_counter", "I")));
                mg.getInstructionList().insert(il);
                mg.setMaxStack(Math.max(mg.getMaxStack(), 2));
                boolean lv = ms[j].getLocalVariableTable() == null;
                boolean ln = ms[j].getLineNumberTable() == null;
                if (lv) {
                    mg.removeLocalVariables();
                }
                if (ln) {
                    mg.removeLineNumbers();
                }
                cg.replaceMethod(ms[j], mg.getMethod());
            }
        }
    }
    return cg.getJavaClass().getBytes();
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:44,代码来源:BCELPerfTest.java

示例13: handleStringComparison

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
private void handleStringComparison(JavaClass jclass, Method method, MethodGen methodGen,
        RefComparisonTypeFrameModelingVisitor visitor, List<WarningWithProperties> stringComparisonList, Location location,
        Type lhsType, Type rhsType) {
    if (DEBUG) {
        System.out.println("String/String comparison at " + location.getHandle());
    }

    // Compute the priority:
    // - two static strings => do not report
    // - dynamic string and anything => high
    // - static string and unknown => medium
    // - all other cases => low
    // System.out.println("Compare " + lhsType + " == " + rhsType);
    byte type1 = lhsType.getType();
    byte type2 = rhsType.getType();

    String bugPattern = "ES_COMPARING_STRINGS_WITH_EQ";
    // T1 T2 result
    // S S no-op
    // D ? high
    // ? D high
    // S ? normal
    // ? S normal
    WarningPropertySet<WarningProperty> propertySet = new WarningPropertySet<WarningProperty>();
    if (type1 == T_STATIC_STRING && type2 == T_STATIC_STRING) {
        propertySet.addProperty(RefComparisonWarningProperty.COMPARE_STATIC_STRINGS);
    } else if (type1 == T_DYNAMIC_STRING || type2 == T_DYNAMIC_STRING) {
        propertySet.addProperty(RefComparisonWarningProperty.DYNAMIC_AND_UNKNOWN);
    } else if (type2 == T_PARAMETER_STRING || type1 == T_PARAMETER_STRING) {
        bugPattern = "ES_COMPARING_PARAMETER_STRING_WITH_EQ";
        if (methodGen.isPublic() || methodGen.isProtected()) {
            propertySet.addProperty(RefComparisonWarningProperty.STRING_PARAMETER_IN_PUBLIC_METHOD);
        } else {
            propertySet.addProperty(RefComparisonWarningProperty.STRING_PARAMETER);
        }
    } else if (type1 == T_STATIC_STRING || type2 == T_STATIC_STRING) {
        if (lhsType instanceof EmptyStringType || rhsType instanceof EmptyStringType)
            propertySet.addProperty(RefComparisonWarningProperty.EMPTY_AND_UNKNOWN);
        else
            propertySet.addProperty(RefComparisonWarningProperty.STATIC_AND_UNKNOWN);
    } else if (visitor.sawStringIntern()) {
        propertySet.addProperty(RefComparisonWarningProperty.SAW_INTERN);
    }

    String sourceFile = jclass.getSourceFileName();
    BugInstance instance = new BugInstance(this, bugPattern, BASE_ES_PRIORITY).addClassAndMethod(methodGen, sourceFile)
            .addType("Ljava/lang/String;").describe(TypeAnnotation.FOUND_ROLE).addSomeSourceForTopTwoStackValues(classContext, method, location);
    SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen,
            sourceFile, location.getHandle());
    if (sourceLineAnnotation != null) {
        WarningWithProperties warn = new WarningWithProperties(instance, propertySet, sourceLineAnnotation, location);
        stringComparisonList.add(warn);
    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:56,代码来源:FindRefComparison.java

示例14: initEntryFact

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
public void initEntryFact(TypeFrame result) {
    // Make the frame valid
    result.setValid();

    int slot = 0;

    // Clear the stack slots in the frame
    result.clearStack();

    // Add local for "this" pointer, if present
    if (!methodGen.isStatic())
        result.setValue(slot++, ObjectTypeFactory.getInstance(methodGen.getClassName()));

    // [Added: Support for Generics]
    // Get a parser that reads the generic signature of the method and
    // can be used to get the correct GenericObjectType if an argument
    // has a class type
    Iterator<String> iter = GenericSignatureParser.getGenericSignatureIterator(method);

    // Add locals for parameters.
    // Note that long and double parameters need to be handled
    // specially because they occupy two locals.
    Type[] argumentTypes = methodGen.getArgumentTypes();
    for (Type argType : argumentTypes) {
        // Add special "extra" type for long or double params.
        // These occupy the slot before the "plain" type.
        if (argType.getType() == Constants.T_LONG) {
            result.setValue(slot++, TypeFrame.getLongExtraType());
        } else if (argType.getType() == Constants.T_DOUBLE) {
            result.setValue(slot++, TypeFrame.getDoubleExtraType());
        }

        // [Added: Support for Generics]
        String s = (iter == null || !iter.hasNext()) ? null : iter.next();
        if (s != null && (argType instanceof ObjectType || argType instanceof ArrayType)
                && !(argType instanceof ExceptionObjectType)) {
            // replace with a generic version of the type
            try {
                Type t = GenericUtilities.getType(s);
                if (t != null)
                    argType = t;
            } catch (RuntimeException e) {
            } // degrade gracefully
        }

        // Add the plain parameter type.
        result.setValue(slot++, argType);
    }

    // Set remaining locals to BOTTOM; this will cause any
    // uses of them to be flagged
    while (slot < methodGen.getMaxLocals())
        result.setValue(slot++, TypeFrame.getBottomType());
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:55,代码来源:TypeAnalysis.java

示例15: mergeTypes

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
public Type mergeTypes(Type a, Type b) throws DataflowAnalysisException {
    if (a == null) return b;
    if (b == null) return a;
    byte aType = a.getType(), bType = b.getType();

    if (aType == T_TOP) // Top is the identity element
        return b;
    else if (bType == T_TOP) // Top is the identity element
        return a;
    else if (aType == T_BOTTOM || bType == T_BOTTOM) // Bottom meet anything
                                                     // is bottom
        return BottomType.instance();
    else if (isReferenceType(aType) && isReferenceType(bType)) { // Two
                                                                 // object
                                                                 // types!
        // Handle the Null type, which serves as a special "top"
        // value for reference types.
        if (aType == T_NULL)
            return b;
        else if (bType == T_NULL)
            return a;

        ReferenceType aRef = (ReferenceType) a;
        ReferenceType bRef = (ReferenceType) b;
        return mergeReferenceTypes(aRef, bRef);
    } else if (isReferenceType(aType) || isReferenceType(bType)) // Object
                                                                 // meet
                                                                 // non-object
                                                                 // is
                                                                 // bottom
        return BottomType.instance();
    else if (aType == bType) // Same non-object type?
        return a;
    else if (isIntegerType(aType) && isIntegerType(bType)) // Two different
                                                           // integer types
                                                           // - use T_INT
        return Type.INT;
    else
        // Default - types are incompatible
        return BottomType.instance();
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:42,代码来源:StandardTypeMerger.java


注:本文中的org.apache.bcel.generic.Type.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。