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


Java GenericObjectType类代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.ba.generic.GenericObjectType的典型用法代码示例。如果您正苦于以下问题:Java GenericObjectType类的具体用法?Java GenericObjectType怎么用?Java GenericObjectType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GenericObjectType类属于edu.umd.cs.findbugs.ba.generic包,在下文中一共展示了GenericObjectType类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResultTypeFromGenericType

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
private boolean getResultTypeFromGenericType(TypeFrame frame, int index, int expectedParameters) {
    try {
        Type mapType = frame.getStackValue(0);
        if (mapType instanceof GenericObjectType) {
            GenericObjectType genericMapType = (GenericObjectType) mapType;
            List<? extends ReferenceType> parameters = genericMapType.getParameters();
            if (parameters != null && parameters.size() == expectedParameters) {
                ReferenceType resultType = parameters.get(index);
                if (resultType instanceof GenericObjectType)
                    resultType = ((GenericObjectType) resultType).produce();
                typesComputedFromGenerics.add(resultType);
                frame.popValue();
                frame.pushValue(resultType);
                return true;
            }
        }

    } catch (DataflowAnalysisException e) {
        AnalysisContext.logError("oops", e);
    }

    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:24,代码来源:TypeFrameModelingVisitor.java

示例2: handleGetMapView

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
private boolean handleGetMapView(TypeFrame frame, String typeName, int index, int expectedNumberOfTypeParameters) {
    try {
        Type mapType = frame.getStackValue(0);
        if (mapType instanceof GenericObjectType) {
            GenericObjectType genericMapType = (GenericObjectType) mapType;
            List<? extends ReferenceType> parameters = genericMapType.getParameters();
            if (parameters == null)
                return false;
            if (parameters.size() == expectedNumberOfTypeParameters) {
                ReferenceType keyType = parameters.get(index);
                frame.popValue();
                typesComputedFromGenerics.add(keyType);
                GenericObjectType keySetType = GenericUtilities.getType(typeName, Collections.singletonList(keyType));
                typesComputedFromGenerics.add(keySetType);
                frame.pushValue(keySetType);
                return true;
            }
        }

    } catch (DataflowAnalysisException e) {
        AnalysisContext.logError("oops", e);
    }
    return false;

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

示例3: getLocalVariable

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
@CheckForNull
GenericObjectType getLocalVariable(int index, int pos) {
    if (genericLocalVariables == null || !genericLocalVariables.get(index))
        return null;
    for (LocalVariable local : localTypeTable.getLocalVariableTypeTable())
        if (local.getIndex() == index && local.getStartPC() <= pos
                && pos < +local.getStartPC() + local.getLength()) {
            String signature = local.getSignature();
            if (signature.indexOf('<') < 0) continue;
            Type t;
            try {
                t = GenericUtilities.getType(signature);
                if (t instanceof GenericObjectType)
                    return (GenericObjectType) t;
            } catch (RuntimeException e) {
                AnalysisContext.logError("Bad signature " + signature
                        + " for " + local.getName(), e);

            }
            return null;
        }
    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:24,代码来源:TypeFrameModelingVisitor.java

示例4: handleStoreInstruction

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
@Override
public void handleStoreInstruction(StoreInstruction obj) {
    try {
        int numConsumed = obj.consumeStack(cpg);
        if (numConsumed == 1) {
            boolean isExact = isTopOfStackExact();
            TypeFrame frame = getFrame();
            Type value = frame.popValue();
            int index = obj.getIndex();
            if (value instanceof ReferenceType && !(value instanceof GenericObjectType)) {
                     GenericObjectType gType = getLocalVariable(index,
                        getLocation().getHandle().getPosition());
                value = GenericUtilities.merge(gType, value);
            }
            frame.setValue(index, value);
            frame.setExact(index, isExact);
        } else
            super.handleStoreInstruction(obj);

    } catch (DataflowAnalysisException e) {
        throw new InvalidBytecodeException(
                "error handling store instruction ", e);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:TypeFrameModelingVisitor.java

示例5: handleLoadInstruction

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
/**
 * Handler for all instructions which load values from a local variable and
 * push them on the stack. Note that two locals are loaded for long and
 * double loads.
 */
@Override
public void handleLoadInstruction(LoadInstruction obj) {
    int numProduced = obj.produceStack(cpg);
    if (numProduced == Constants.UNPREDICTABLE)
        throw new InvalidBytecodeException("Unpredictable stack production");

    if (numProduced != 1) {
        super.handleLoadInstruction(obj);
        return;
    }
    int index = obj.getIndex();
    TypeFrame frame = getFrame();
    Type value = frame.getValue(index);
    if (value instanceof ReferenceType && !(value instanceof GenericObjectType)) {
        GenericObjectType gType = getLocalVariable(index,
                getLocation().getHandle().getPosition());
        value = GenericUtilities.merge(gType, value);
    }
    boolean isExact = frame.isExact(index);
    frame.pushValue(value);
    if (isExact)
        setTopOfStackIsExact();
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:29,代码来源:TypeFrameModelingVisitor.java

示例6: compareTypeParameters

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
private IncompatibleTypes compareTypeParameters(GenericObjectType parmGeneric, GenericObjectType argGeneric) {
    int p = parmGeneric.getNumParameters();
    if (p != argGeneric.getNumParameters()) {
        return IncompatibleTypes.SEEMS_OK;
    }
    for (int x = 0; x < p; x++) {
        IncompatibleTypes result = compareTypes(parmGeneric.getParameterAt(x), argGeneric.getParameterAt(x), false);
        if (result != IncompatibleTypes.SEEMS_OK)
            return result;
    }
    return IncompatibleTypes.SEEMS_OK;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:13,代码来源:FindUnrelatedTypesInGenericContainer.java

示例7: compareTypesOld

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
private boolean compareTypesOld(Type parmType, Type argType) {
    // XXX equality not implemented for GenericObjectType
    // if (parmType.equals(argType)) return true;
    // Compare type signatures instead
    if (GenericUtilities.getString(parmType).equals(GenericUtilities.getString(argType)))
        return true;

    if (parmType instanceof GenericObjectType) {
        GenericObjectType o = (GenericObjectType) parmType;
        if (o.getTypeCategory() == GenericUtilities.TypeCategory.WILDCARD_EXTENDS) {
            return compareTypesOld(o.getExtension(), argType);
        }
    }
    // ignore type variables for now
    if (parmType instanceof GenericObjectType && !((GenericObjectType) parmType).hasParameters())
        return true;
    if (argType instanceof GenericObjectType && !((GenericObjectType) argType).hasParameters())
        return true;

    // Case: Both are generic containers
    if (parmType instanceof GenericObjectType && argType instanceof GenericObjectType) {
        return true;
    } else {
        // Don't consider non reference types (should not be possible)
        if (!(parmType instanceof ReferenceType && argType instanceof ReferenceType))
            return true;

        // Don't consider non object types (for now)
        if (!(parmType instanceof ObjectType && argType instanceof ObjectType))
            return true;

        // Otherwise, compare base types ignoring generic information
        try {
            return Repository.instanceOf(((ObjectType) argType).getClassName(), ((ObjectType) parmType).getClassName());
        } catch (ClassNotFoundException e) {
        }
    }

    return true;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:41,代码来源:FindUnrelatedTypesInGenericContainer.java

示例8: getPriorityForAssumingCompatible

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
static public @Nonnull
IncompatibleTypes getPriorityForAssumingCompatible(GenericObjectType genericType, Type plainType) {
    IncompatibleTypes result = IncompatibleTypes.getPriorityForAssumingCompatible(genericType.getObjectType(), plainType);
    List<? extends ReferenceType> parameters = genericType.getParameters();
    if (result.getPriority() == Priorities.NORMAL_PRIORITY && parameters != null && parameters.contains(plainType)) {
        result = UNRELATED_TYPES_BUT_MATCHES_TYPE_PARAMETER;
    }
    return result;

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

示例9: TypeAnnotation

import edu.umd.cs.findbugs.ba.generic.GenericObjectType; //导入依赖的package包/类
public TypeAnnotation(Type objectType, String roleDescription) {
    this(objectType.getSignature(), roleDescription);
    if (objectType instanceof GenericObjectType) {
        GenericObjectType genericObjectType = (GenericObjectType) objectType;
        if (genericObjectType.getTypeCategory() == GenericUtilities.TypeCategory.PARAMETERIZED)
            typeParameters = genericObjectType.getGenericParametersAsString();
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:9,代码来源:TypeAnnotation.java


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