Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * fb-contrib - Auxiliary detectors for Java programs
   * Copyright (C) 2005-2015 Dave Brosius
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 package com.mebigfatguy.fbcontrib.detect;
looks for methods that are defined to return Boolean, but return null. This thus allows three return values, Boolean.FALSE, Boolean.TRUE and null. If three values intended, it would be more clear to just create an enumeration with three values and return that type.
 	private OpcodeStack stack;
 	private boolean methodReported;

constructs a TBP detector given the reporter to report bugs on

bugReporter the sync of bug reports
 	public TristateBooleanPattern(BugReporter bugReporter) {
 		this. = bugReporter;

implements the visitor to allocate the opcode stack

classContext the context object of the currently parsed class
 	public void visitClassContext(ClassContext classContext) {
 		try {
 			 = new OpcodeStack();
 		} finally {
 			 = null;

implements the visitor to filter out methods that don't return Boolean, and to reset the methodReported flag

obj the context object for the currently parsed code block
 	public void visitCode(Code obj) {
 		Method m = getMethod();
 		Type retType = m.getReturnType();
 		if ("Ljava/lang/Boolean;".equals(retType.getSignature())) {
 			 = false;

implements the visitor to look for null returns
 	public void sawOpcode(int seen) {
 		try {
 			if (seen == ) {
 				if (.getStackDepth() > 0) {
 					if (item.isNull()) {
finally {
New to GrepCode? Check out our FAQ X