本文整理汇总了Java中edu.umd.cs.findbugs.ba.generic.GenericUtilities.getType方法的典型用法代码示例。如果您正苦于以下问题:Java GenericUtilities.getType方法的具体用法?Java GenericUtilities.getType怎么用?Java GenericUtilities.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.generic.GenericUtilities
的用法示例。
在下文中一共展示了GenericUtilities.getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleGetMapView
import edu.umd.cs.findbugs.ba.generic.GenericUtilities; //导入方法依赖的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;
}
示例2: getLocalVariable
import edu.umd.cs.findbugs.ba.generic.GenericUtilities; //导入方法依赖的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;
}
示例3: initEntryFact
import edu.umd.cs.findbugs.ba.generic.GenericUtilities; //导入方法依赖的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());
}