本文整理汇总了Java中javax.annotation.meta.When类的典型用法代码示例。如果您正苦于以下问题:Java When类的具体用法?Java When怎么用?Java When使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
When类属于javax.annotation.meta包,在下文中一共展示了When类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: backwardsValueConflictsWithSource
import javax.annotation.meta.When; //导入依赖的package包/类
/**
* Determine whether given backwards FlowValue conflicts with given source.
*
* @param backwardsFlowValue
* a backwards FlowValue
* @param source
* SourceSinkInfo object representing a source reached by the
* backwards flow value
* @param typeQualifierValue
* TypeQualifierValue being checked
* @param isIdentity TODO
* @return true if backwards value conflicts with source, false if not
*/
public static boolean backwardsValueConflictsWithSource(FlowValue backwardsFlowValue, SourceSinkInfo source,
TypeQualifierValue typeQualifierValue, boolean isIdentity) {
When sourceWhen = source.getWhen();
if (typeQualifierValue.isStrictQualifier() && !isIdentity) {
// strict checking
return (backwardsFlowValue == ALWAYS && sourceWhen != When.ALWAYS)
|| (backwardsFlowValue == NEVER && sourceWhen != When.NEVER);
} else {
// NOT strict checking
return (backwardsFlowValue == ALWAYS && (sourceWhen == When.NEVER || sourceWhen == When.MAYBE))
|| (backwardsFlowValue == NEVER && (sourceWhen == When.ALWAYS || sourceWhen == When.MAYBE));
}
}
示例2: registerParameterSources
import javax.annotation.meta.When; //导入依赖的package包/类
private void registerParameterSources() {
ValueNumberFrame vnaFrameAtEntry = vnaDataflow.getStartFact(cfg.getEntry());
SignatureParser sigParser = new SignatureParser(xmethod.getSignature());
int firstParamSlot = xmethod.isStatic() ? 0 : 1;
int param = 0;
int slotOffset = 0;
for (Iterator<String> i = sigParser.parameterSignatureIterator(); i.hasNext();) {
String paramSig = i.next();
// Get the TypeQualifierAnnotation for this parameter
SourceSinkInfo info;
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xmethod, param,
typeQualifierValue);
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
ValueNumber vn = vnaFrameAtEntry.getValue(slotOffset + firstParamSlot);
info = new SourceSinkInfo(SourceSinkType.PARAMETER, cfg.getLocationAtEntry(), vn, when);
info.setParameterAndLocal(param, slotOffset + firstParamSlot);
registerSourceSink(info);
param++;
slotOffset += SignatureParser.getNumSlotsForType(paramSig);
}
}
示例3: modelFieldStore
import javax.annotation.meta.When; //导入依赖的package包/类
private void modelFieldStore(Location location) throws DataflowAnalysisException {
// Model field stores
XField writtenField = XFactory.createXField((FieldInstruction) location.getHandle().getInstruction(), cpg);
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(writtenField,
typeQualifierValue);
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
// The ValueNumberFrame *before* the FieldInstruction should
// have the ValueNumber of the stored value on the top of the stack.
ValueNumberFrame vnaFrameAtStore = vnaDataflow.getFactAtLocation(location);
if (vnaFrameAtStore.isValid()) {
ValueNumber vn = vnaFrameAtStore.getTopValue();
SourceSinkInfo sink = new SourceSinkInfo(SourceSinkType.FIELD_STORE, location, vn, when);
registerSourceSink(sink);
}
}
示例4: validate
import javax.annotation.meta.When; //导入依赖的package包/类
public When validate(Object constantValue) {
if (validator == null)
throw new IllegalStateException("No validator");
IAnalysisCache analysisCache = Global.getAnalysisCache();
Profiler profiler = analysisCache.getProfiler();
profiler.start(validator.getClass());
AtomicBoolean performing = performingValidation.get();
try {
if (!performing.compareAndSet(false, true)) {
throw new IllegalStateException("recursive validation");
}
return validator.forConstantValue(proxy, constantValue);
} catch (Exception e) {
AnalysisContext.logError("Error executing custom validator for " + typeQualifier + " " + constantValue, e);
return When.UNKNOWN;
} finally {
if (!performing.compareAndSet(true, false)) {
throw new IllegalStateException("performingValidation not set when validation completes");
}
profiler.end(validator.getClass());
}
}
示例5: combineAnnotations
import javax.annotation.meta.When; //导入依赖的package包/类
private static TypeQualifierAnnotation combineAnnotations(TypeQualifierAnnotation a, TypeQualifierAnnotation b,
When[][] mergeMatrix) {
assert a.typeQualifier.equals(b.typeQualifier);
When aWhen = a.when;
When bWhen = b.when;
if (aWhen.ordinal() < bWhen.ordinal()) {
When tmp = aWhen;
aWhen = bWhen;
bWhen = tmp;
}
When combined = mergeMatrix[aWhen.ordinal()][bWhen.ordinal()];
if (combined != null) {
return getValue(a.typeQualifier, combined);
} else {
return null;
}
}
示例6: parameterMustBeNonNull
import javax.annotation.meta.When; //导入依赖的package包/类
public boolean parameterMustBeNonNull(XMethod m, int param) {
if (DEBUG) {
System.out.print("Checking " + m + " param " + param + " for @Nonnull...");
}
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(m, param,
nonnullTypeQualifierValue);
if (tqa == null && param == 0) {
String name = m.getName();
String signature = m.getSignature();
if (name.equals("main") && signature.equals("([Ljava/lang/String;)V") && m.isStatic() && m.isPublic())
return true;
else if (NullnessAnnotationDatabase.assertsFirstParameterIsNonnull(m))
return true;
else if (name.equals("compareTo") && signature.substring(signature.indexOf(";") + 1).equals(")Z") && !m.isStatic())
return true;
}
boolean answer = (tqa != null) && tqa.when == When.ALWAYS;
if (DEBUG) {
System.out.println(answer ? "yes" : "no");
}
return answer;
}
示例7: registerParameterSources
import javax.annotation.meta.When; //导入依赖的package包/类
private void registerParameterSources() {
ValueNumberFrame vnaFrameAtEntry = vnaDataflow.getStartFact(cfg.getEntry());
SignatureParser sigParser = new SignatureParser(xmethod.getSignature());
int firstParamSlot = xmethod.isStatic() ? 0 : 1;
int param = 0;
int slotOffset = 0;
for ( String paramSig : sigParser.parameterSignatures()) {
// Get the TypeQualifierAnnotation for this parameter
SourceSinkInfo info;
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(xmethod, param,
typeQualifierValue);
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
ValueNumber vn = vnaFrameAtEntry.getValue(slotOffset + firstParamSlot);
info = new SourceSinkInfo(SourceSinkType.PARAMETER, cfg.getLocationAtEntry(), vn, when);
info.setParameterAndLocal(param, slotOffset + firstParamSlot);
registerSourceSink(info);
param++;
slotOffset += SignatureParser.getNumSlotsForType(paramSig);
}
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:26,代码来源:ForwardTypeQualifierDataflowAnalysis.java
示例8: parameterMustBeNonNull
import javax.annotation.meta.When; //导入依赖的package包/类
public boolean parameterMustBeNonNull(XMethod m, int param) {
if (DEBUG) {
System.out.print("Checking " + m + " param " + param + " for @Nonnull...");
}
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(m, param,
nonnullTypeQualifierValue);
if (tqa == null && param == 0) {
String name = m.getName();
String signature = m.getSignature();
if (name.equals("main") && signature.equals("([Ljava/lang/String;)V") && m.isStatic() && m.isPublic())
return true;
else if (assertsFirstParameterIsNonnull(m))
return true;
else if (name.equals("compareTo") && signature.substring(signature.indexOf(";") + 1).equals(")Z") && !m.isStatic())
return true;
}
boolean answer = (tqa != null) && tqa.when == When.ALWAYS;
if (DEBUG) {
System.out.println(answer ? "yes" : "no");
}
return answer;
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:26,代码来源:TypeQualifierNullnessAnnotationDatabase.java
示例9: options
import javax.annotation.meta.When; //导入依赖的package包/类
/**
* Java options.
* @return Options
*/
private Collection<String> options() {
final Collection<String> opts = new LinkedList<>();
opts.add("-classpath");
opts.add(
StringUtils.join(
Arrays.asList(
this.jar(Wrap.class),
this.jar(FindBugs2.class),
this.jar(ClassFormatException.class),
this.jar(DocumentException.class),
this.jar(JaxenException.class),
this.jar(ClassNode.class),
this.jar(ClassVisitor.class),
this.jar(When.class),
this.jar(FormatterNumberFormatException.class),
this.jar(StringEscapeUtils.class),
this.jar(FBContrib.class),
this.jar(Iterables.class)
),
// @checkstyle MultipleStringLiteralsCheck (1 line)
System.getProperty("path.separator")
).replace("\\", "/")
);
return opts;
}
示例10: requireNonNull
import javax.annotation.meta.When; //导入依赖的package包/类
@Nonnull( when = When.ALWAYS )
public static <T> T requireNonNull( T object ) throws NullPointerException {
if ( object == null ) {
throw new NullPointerException();
}
return object;
}
示例11: visitClassContext
import javax.annotation.meta.When; //导入依赖的package包/类
public void visitClassContext(ClassContext classContext) {
JavaClass jclass = classContext.getJavaClass();
for (Method method : jclass.getMethods()) {
XMethod xmethod = XFactory.createXMethod(classContext.getJavaClass(), method);
ParameterProperty nonnullParameters = AnalysisContext.currentAnalysisContext().getUnconditionalDerefParamDatabase()
.getProperty(xmethod.getMethodDescriptor());
if (nonnullParameters != null) {
for (int p : nonnullParameters.iterable()) {
TypeQualifierAnnotation directTypeQualifierAnnotation = TypeQualifierApplications
.getDirectTypeQualifierAnnotation(xmethod, p, nonnullTypeQualifierValue);
if (directTypeQualifierAnnotation != null && directTypeQualifierAnnotation.when == When.UNKNOWN) {
//
// The LocalVariableAnnotation is constructed using the
// local variable
// number of the parameter, not the parameter number.
//
int paramLocal = xmethod.isStatic() ? p : p + 1;
reporter.reportBug(new BugInstance(this, "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
NORMAL_PRIORITY).addClassAndMethod(jclass, method).add(
LocalVariableAnnotation.getParameterLocalVariableAnnotation(method, paramLocal)));
}
}
}
}
}
示例12: flowValueFromWhen
import javax.annotation.meta.When; //导入依赖的package包/类
/**
* Convert a When value to a FlowValue value.
*
* @param when
* a When value
* @return the corresponding FlowValue
*/
public static FlowValue flowValueFromWhen(When when) {
switch (when) {
case ALWAYS:
return FlowValue.ALWAYS;
case MAYBE:
return FlowValue.UNKNOWN;
case NEVER:
return FlowValue.NEVER;
case UNKNOWN:
return FlowValue.UNKNOWN;
default:
throw new IllegalStateException();
}
}
示例13: registerConstantSource
import javax.annotation.meta.When; //导入依赖的package包/类
private void registerConstantSource(Location location, Object constantValue) throws DataflowAnalysisException {
When w;
if (typeQualifierValue.canValidate(constantValue)) {
w = typeQualifierValue.validate(constantValue);
} else if (typeQualifierValue.isStrictQualifier())
return;
else
w = When.UNKNOWN;
registerTopOfStackSource(SourceSinkType.CONSTANT_VALUE, location, w, false, constantValue);
}
示例14: registerReturnValueSource
import javax.annotation.meta.When; //导入依赖的package包/类
private void registerReturnValueSource(Location location) throws DataflowAnalysisException {
// Nothing to do if called method does not return a value
InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
String calledMethodSig = inv.getSignature(cpg);
if (calledMethodSig.endsWith(")V")) {
return;
}
XMethod calledXMethod = XFactory.createXMethod(inv, cpg);
if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(calledXMethod))
return;
if (calledXMethod.isResolved()) {
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledXMethod,
typeQualifierValue);
boolean interproc = false;
if (TypeQualifierDatabase.USE_DATABASE && tqa == null) {
// See if there's an entry in the interprocedural
// type qualifier database.
TypeQualifierDatabase tqdb = Global.getAnalysisCache().getDatabase(TypeQualifierDatabase.class);
tqa = tqdb.getReturnValue(calledXMethod.getMethodDescriptor(), typeQualifierValue);
if (tqa != null) {
interproc = true;
}
}
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
registerTopOfStackSource(SourceSinkType.RETURN_VALUE_OF_CALLED_METHOD, location, when, interproc, null);
}
}
示例15: registerFieldLoadSource
import javax.annotation.meta.When; //导入依赖的package包/类
private void registerFieldLoadSource(Location location) throws DataflowAnalysisException {
XField loadedField = XFactory.createXField((FieldInstruction) location.getHandle().getInstruction(), cpg);
if (loadedField.isResolved()) {
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(loadedField,
typeQualifierValue);
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
registerTopOfStackSource(SourceSinkType.FIELD_LOAD, location, when, false, null);
}
}