@Override public void sawOpcode(int seen) { if (seen == Const.ARETURN && getPrevOpcode(1) == Const.ACONST_NULL){ accumulateBug(); } }
@Override public void visit(Code code) { SignatureParser sp = new SignatureParser(getMethodSig()); // Check to see if the method has expected return type String returnSignature = sp.getReturnTypeSignature(); if (!matchesReturnSignature(returnSignature)){ return; } if (isExplicitlyNullable()){ return; } super.visit(code); // make callbacks to sawOpcode for all opcodes bugAccumulator.reportAccumulatedBugs(); }
private boolean isExplicitlyNullable() { AnalysisContext analysisContext = AnalysisContext.currentAnalysisContext(); INullnessAnnotationDatabase nullnessAnnotationDatabase = analysisContext.getNullnessAnnotationDatabase(); XMethod xMethod = getXMethod(); NullnessAnnotation na = nullnessAnnotationDatabase.getResolvedAnnotation(xMethod, true); return na != null && na != NullnessAnnotation.NONNULL; }
private boolean isExplicitlyNullable() { AnalysisContext analysisContext = AnalysisContext.currentAnalysisContext(); INullnessAnnotationDatabase nullnessAnnotationDatabase = analysisContext.getNullnessAnnotationDatabase(); XMethod xMethod = getXMethod(); NullnessAnnotation na = nullnessAnnotationDatabase.getResolvedAnnotation(xMethod, true); return na != null && na != NullnessAnnotation.NONNULL; }
@Override public void visit(Code code) { SignatureParser sp = new SignatureParser(getMethodSig()); // Check to see if the method has expected return type String returnSignature = sp.getReturnTypeSignature(); if (!matchesReturnSignature(returnSignature)){ return; } if (isExplicitlyNullable()){ return; } super.visit(code); // make callbacks to sawOpcode for all opcodes bugAccumulator.reportAccumulatedBugs(); }
@Override public void sawOpcode(int seen) { if (seen == ARETURN && getPrevOpcode(1) == ACONST_NULL){ accumulateBug(); } }