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


Java Type.equals方法代码示例

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


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

示例1: available_slot

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
private boolean available_slot(Type[] types, int ind, Type t) {
Type tp = types[ind];
if (tp != null) {
    if (t.equals(tp)) {
	return true;
    }
    return false;
}
if (t.equals(Type.LONG) || t.equals(Type.DOUBLE)) {
    if (types[ind + 1] != null) {
	return false;
    }
    types[ind + 1] = Type.VOID;
}
types[ind] = t;
return true;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:18,代码来源:MethodTable.java

示例2: rewriteStore

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
InstructionHandle rewriteStore(MethodGen m, InstructionList il,
    InstructionHandle i, int maxLocals, String localClassName) {
    LocalVariableInstruction curr = (LocalVariableInstruction) (i
        .getInstruction());
    Type type = mtab.getLocalType(m, curr, i.getPosition());
    if (type == null) {
        return i;
    }
    String name = mtab.getLocalName(m, curr, i.getPosition());
    String fieldName = MethodTable.generatedLocalName(type, name);

    i.setInstruction(new ALOAD(maxLocals));
    i = i.getNext();

    if (type.equals(Type.LONG) || type.equals(Type.DOUBLE)) {
        il.insert(i, new DUP_X2());
        il.insert(i, new POP());
    } else {
        il.insert(i, new SWAP());
    }

    i = il.insert(i, ins_f.createFieldAccess(localClassName, fieldName,
        type, Constants.PUTFIELD));
    return i;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:26,代码来源:Cashmerec.java

示例3: insertReturnPop

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
void insertReturnPop(Method m, InstructionList il) {
    Type returnType = m.getReturnType();

    if (returnType.equals(Type.DOUBLE) || returnType.equals(Type.LONG)) {
        il.append(new POP2());
    } else if (returnType.equals(Type.VOID)) {
        // do nothing
    } else {
        il.append(new POP());
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:12,代码来源:Cashmerec.java

示例4: initEntryFact

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
@Override
public void initEntryFact(TypeFrame result) {
    super.initEntryFact(result);
    for (int i = 0; i < methodGen.getMaxLocals(); i++) {
        Type t = result.getValue(i);
        if (t.equals(Type.STRING)) {
            result.setValue(i, parameterStringTypeInstance);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:11,代码来源:FindRefComparison.java

示例5: getPriorityForAssumingCompatibleWithArray

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
private static IncompatibleTypes getPriorityForAssumingCompatibleWithArray(Type rhsType) {
    if (rhsType.equals(Type.OBJECT))
        return ARRAY_AND_OBJECT;
    String sig = rhsType.getSignature();
    if (sig.equals("Ljava/io/Serializable;") || sig.equals("Ljava/lang/Cloneable;"))
        return SEEMS_OK;
    return ARRAY_AND_NON_ARRAY;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:9,代码来源:IncompatibleTypes.java

示例6: isCompatible

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
/**
 * Tests whether one type is compatible with another for method
 * invocation conversion. This includes assignment conversion,
 * except the implicit narrowing of integer constants.
 * JLS Section 5.2
 * @param aSubType the type to be converted.
 * @param aSuperType the converted type.
 * @return true if aSubType can be converted to aSuperType.
 */
public static boolean isCompatible(Type aSubType, Type aSuperType)
{
    boolean result = false;

    if (aSubType.equals(aSuperType)) {
        // identity conversion
        result = true;
    }
    else if ((aSubType instanceof ReferenceType)
        && (aSuperType instanceof ReferenceType))
    {
        // widening reference conversion?
        final ReferenceType aSubRefType = (ReferenceType) aSubType;
        result = aSubRefType.isAssignmentCompatibleWith(aSuperType);
    }
    // widening primitive conversion?
    else if (aSubType.equals(Type.BYTE)) {
        result =
            aSuperType.equals(Type.SHORT)
                || aSuperType.equals(Type.INT)
                || aSuperType.equals(Type.LONG)
                || aSuperType.equals(Type.FLOAT)
                || aSuperType.equals(Type.DOUBLE);
    }
    else if (aSubType.equals(Type.SHORT)) {
        result =
            aSuperType.equals(Type.INT)
                || aSuperType.equals(Type.LONG)
                || aSuperType.equals(Type.FLOAT)
                || aSuperType.equals(Type.DOUBLE);
    }
    else if (aSubType.equals(Type.INT)) {
        result =
            aSuperType.equals(Type.LONG)
                || aSuperType.equals(Type.FLOAT)
                || aSuperType.equals(Type.DOUBLE);
    }
    else if (aSubType.equals(Type.LONG)) {
        result =
            aSuperType.equals(Type.FLOAT) || aSuperType.equals(Type.DOUBLE);
    }
    else if (aSubType.equals(Type.DOUBLE)) {
        result = aSuperType.equals(Type.DOUBLE);
    }
    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:56,代码来源:Utils.java

示例7: 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

示例8: getJNIType

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
/**
 * Returns a JNI-style representation of the given data type passed
 * as a Class object.
 * 
 * @param type - a Class object that wraps a data type.
 * @return a string that represents a JNI-style data type.
 */
public static String getJNIType(Type type) {
    StringBuffer result = new StringBuffer();

    String suffix = "";
    if (type instanceof ArrayType) {
        suffix = "Array";
        type = ((ArrayType) type).getElementType();
    }

    if (type instanceof ObjectType) {
        String objectType = "jobject";
        // The suffix length is 0 only if the given type is not an array.
        if (suffix.length() == 0) {
            if (type.equals(Type.STRING)) {
                objectType = "jstring";
            } else if (type.equals(Type.THROWABLE)) {
                objectType = "jthrowable";
            } else if (((ObjectType) type).getClassName()
                    .equals("java.lang.Class")) {
                objectType = "jclass";
            }
        }
        result.append(objectType);
    } else if (type == Type.INT) {
        result.append("jint");
    } else if (type == Type.BYTE) {
        result.append("jbyte");
    } else if (type == Type.LONG) {
        result.append("jlong");
    } else if (type == Type.FLOAT) {
        result.append("jfloat");
    } else if (type == Type.DOUBLE) {
        result.append("jdouble");
    } else if (type == Type.SHORT) {
        result.append("jshort");
    } else if (type == Type.CHAR) {
        result.append("jchar");
    } else if (type == Type.BOOLEAN) {
        result.append("jboolean");
    } else if (type == Type.VOID) {
        result.append("void");
    }

    return result.append(suffix).toString();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:53,代码来源:ClazzMethod.java

示例9: analyzeMethod

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
    MethodGen methodGen = classContext.getMethodGen(method);
    if (methodGen == null)
        return;
    BitSet bytecodeSet = classContext.getBytecodeSet(method);
    if (bytecodeSet == null)
        return;
    // We don't adequately model instanceof interfaces yet
    if (bytecodeSet.get(Constants.INSTANCEOF) || bytecodeSet.get(Constants.CHECKCAST))
        return;
    CFG cfg = classContext.getCFG(method);
    TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
    ConstantPoolGen cpg = classContext.getConstantPoolGen();

    String sourceFile = classContext.getJavaClass().getSourceFileName();
    if (DEBUG) {
        String methodName = methodGen.getClassName() + "." + methodGen.getName();
        System.out.println("Checking " + methodName);
    }

    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
        Location location = i.next();
        InstructionHandle handle = location.getHandle();
        Instruction ins = handle.getInstruction();

        if (!(ins instanceof INVOKEINTERFACE))
            continue;

        INVOKEINTERFACE invoke = (INVOKEINTERFACE) ins;
        String mName = invoke.getMethodName(cpg);
        if (!mName.equals("setAttribute"))
            continue;
        String cName = invoke.getClassName(cpg);
        if (!cName.equals("javax.servlet.http.HttpSession"))
            continue;

        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
            continue;
        }
        ReferenceType refType = (ReferenceType) operandType;

        if (refType.equals(NullType.instance())) {
            continue;
        }

        try {

            double isSerializable = DeepSubtypeAnalysis.isDeepSerializable(refType);

            if (isSerializable < 0.9) {
                SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext,
                        methodGen, sourceFile, handle);
                ReferenceType problem = DeepSubtypeAnalysis.getLeastSerializableTypeComponent(refType);

                bugAccumulator.accumulateBug(new BugInstance(this, "J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION",
                        isSerializable < 0.15 ? HIGH_PRIORITY : isSerializable > 0.5 ? LOW_PRIORITY : NORMAL_PRIORITY)
                        .addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE),
                        sourceLineAnnotation);

            }
        } catch (ClassNotFoundException e) {
            // ignore
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:78,代码来源:FindNonSerializableStoreIntoSession.java

示例10: checkRefComparison

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
private void checkRefComparison(Location location, JavaClass jclass, Method method, MethodGen methodGen,
        RefComparisonTypeFrameModelingVisitor visitor, TypeDataflow typeDataflow,
        List<WarningWithProperties> stringComparisonList, List<WarningWithProperties> refComparisonList)
        throws DataflowAnalysisException {

    InstructionHandle handle = location.getHandle();

    TypeFrame frame = typeDataflow.getFactAtLocation(location);
    if (frame.getStackDepth() < 2) {
        throw new DataflowAnalysisException("Stack underflow", methodGen, handle);
    }

    int numSlots = frame.getNumSlots();
    Type lhsType = frame.getValue(numSlots - 2);
    Type rhsType = frame.getValue(numSlots - 1);

    if (lhsType instanceof NullType || rhsType instanceof NullType) {
        return;
    }
    if (lhsType instanceof ReferenceType && rhsType instanceof ReferenceType) {
        IncompatibleTypes result = IncompatibleTypes.getPriorityForAssumingCompatible(lhsType, rhsType, true);
        if (result != IncompatibleTypes.SEEMS_OK && result != IncompatibleTypes.UNCHECKED) {
            String sourceFile = jclass.getSourceFileName();

            boolean isAssertSame = handle.getInstruction() instanceof INVOKESTATIC;
            if (isAssertSame)
                bugAccumulator.accumulateBug(
                        new BugInstance(this, "TESTING", result.getPriority())
                        .addClassAndMethod(methodGen, sourceFile)
                        .addString("Calling assertSame with two distinct objects")
                        .addFoundAndExpectedType(rhsType, lhsType)
                                .addSomeSourceForTopTwoStackValues(classContext, method, location),
                        SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, handle));
                else
            bugAccumulator.accumulateBug(
                    new BugInstance(this, "EC_UNRELATED_TYPES_USING_POINTER_EQUALITY", result.getPriority())
                            .addClassAndMethod(methodGen, sourceFile).addFoundAndExpectedType(rhsType, lhsType)
                            .addSomeSourceForTopTwoStackValues(classContext, method, location),
                    SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, handle));
            return;
        }
        if (lhsType.equals(Type.OBJECT) && rhsType.equals(Type.OBJECT))
            return;
        String lhs = SignatureConverter.convert(lhsType.getSignature());
        String rhs = SignatureConverter.convert(rhsType.getSignature());

        if (lhs.equals("java.lang.String") || rhs.equals("java.lang.String")) {
            handleStringComparison(jclass, method, methodGen, visitor, stringComparisonList, location, lhsType, rhsType);
        } else if (suspiciousSet.contains(lhs)) {
            handleSuspiciousRefComparison(jclass, method, methodGen, refComparisonList, location, lhs,
                    (ReferenceType) lhsType, (ReferenceType) rhsType);
        } else if (suspiciousSet.contains(rhs)) {
            handleSuspiciousRefComparison(jclass, method, methodGen, refComparisonList, location, rhs,
                    (ReferenceType) lhsType, (ReferenceType) rhsType);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:58,代码来源:FindRefComparison.java

示例11: mergeValues

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
@Override
protected void mergeValues(TypeFrame otherFrame, TypeFrame resultFrame, int slot) throws DataflowAnalysisException {

    Type type2 = resultFrame.getValue(slot);
    Type type1 = otherFrame.getValue(slot);
    Type value = typeMerger.mergeTypes(type2, type1);
    resultFrame.setValue(slot, value);

    // Result type is exact IFF types are identical and both are exact

    boolean typesAreIdentical = type1.equals(type2);

    boolean bothExact = resultFrame.isExact(slot) && otherFrame.isExact(slot);

    resultFrame.setExact(slot, typesAreIdentical && bothExact);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:17,代码来源:TypeAnalysis.java

示例12: getPriorityForAssumingCompatible

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
static public @Nonnull
IncompatibleTypes getPriorityForAssumingCompatible(Type expectedType, Type actualType, boolean pointerEquality) {
    if (!(expectedType instanceof ReferenceType))
        return SEEMS_OK;
    if (!(actualType instanceof ReferenceType))
        return SEEMS_OK;

    if (expectedType instanceof BasicType ^ actualType instanceof BasicType) {
        return INCOMPATIBLE_CLASSES;
    }
    while (expectedType instanceof ArrayType && actualType instanceof ArrayType) {
        expectedType = ((ArrayType) expectedType).getElementType();
        actualType = ((ArrayType) actualType).getElementType();
    }

    if (expectedType instanceof BasicType ^ actualType instanceof BasicType) {
        return PRIMATIVE_ARRAY_AND_OTHER_ARRAY;
    }
    if (expectedType instanceof BasicType && actualType instanceof BasicType) {
        if (!expectedType.equals(actualType))
            return INCOMPATIBLE_PRIMATIVE_ARRAYS;
        else
            return SEEMS_OK;
    }
    if (expectedType instanceof ArrayType) {
        return getPriorityForAssumingCompatibleWithArray(actualType);
    }
    if (actualType instanceof ArrayType) {
        return getPriorityForAssumingCompatibleWithArray(expectedType);
    }
    if (expectedType.equals(actualType))
        return SEEMS_OK;

    // For now, ignore the case where either reference is not
    // of an object type. (It could be either an array or null.)
    if (!(expectedType instanceof ObjectType) || !(actualType instanceof ObjectType))
        return SEEMS_OK;

    return getPriorityForAssumingCompatible((ObjectType) expectedType, (ObjectType) actualType, pointerEquality);

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

示例13: getPriorityForAssumingCompatible

import org.apache.bcel.generic.Type; //导入方法依赖的package包/类
static public @Nonnull
IncompatibleTypes getPriorityForAssumingCompatible(Type expectedType, Type actualType, boolean pointerEquality) {
    if (expectedType.equals(actualType))
        return SEEMS_OK;
    
    if (!(expectedType instanceof ReferenceType))
        return SEEMS_OK;
    if (!(actualType instanceof ReferenceType))
        return SEEMS_OK;

    if (expectedType instanceof BasicType ^ actualType instanceof BasicType) {
        return INCOMPATIBLE_CLASSES;
    }
    while (expectedType instanceof ArrayType && actualType instanceof ArrayType) {
        expectedType = ((ArrayType) expectedType).getElementType();
        actualType = ((ArrayType) actualType).getElementType();
    }

    if (expectedType instanceof BasicType ^ actualType instanceof BasicType) {
        return PRIMATIVE_ARRAY_AND_OTHER_ARRAY;
    }
    if (expectedType instanceof BasicType && actualType instanceof BasicType) {
        if (!expectedType.equals(actualType))
            return INCOMPATIBLE_PRIMATIVE_ARRAYS;
        else
            return SEEMS_OK;
    }
    if (expectedType instanceof ArrayType) {
        return getPriorityForAssumingCompatibleWithArray(actualType);
    }
    if (actualType instanceof ArrayType) {
        return getPriorityForAssumingCompatibleWithArray(expectedType);
    }
    if (expectedType.equals(actualType))
        return SEEMS_OK;

    // For now, ignore the case where either reference is not
    // of an object type. (It could be either an array or null.)
    if (!(expectedType instanceof ObjectType) || !(actualType instanceof ObjectType))
        return SEEMS_OK;

    return getPriorityForAssumingCompatible((ObjectType) expectedType, (ObjectType) actualType, pointerEquality);

}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:45,代码来源:IncompatibleTypes.java


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