當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。