/*
 * FindBugs - Find bugs in Java programs
 * Copyright (C) 2003, University of Maryland
 * 
 * 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
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * 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 edu.umd.cs.findbugs;
import org.apache.bcel.classfile.*;
import edu.umd.cs.pugh.visitclass.Constants2;
import java.util.HashSet;

public class FindRunInvocations extends BytecodeScanningDetector implements   Constants2 {

   private BugReporter bugReporter;

   public FindRunInvocations(BugReporter bugReporter) {
	this.bugReporter = bugReporter;
	}


   private boolean isThread(String clazz) {
	return org.apache.bcel.Repository.instanceOf(clazz,"java.lang.Thread");
	}
   public void sawOpcode(int seen) {
	if ((seen == INVOKEVIRTUAL || seen == INVOKEINTERFACE) 
				&& nameConstant.equals("run")
				&& sigConstant.equals("()V")
				&& isThread(betterClassConstant)
				)
		bugReporter.reportBug(new BugInstance("RU_INVOKE_RUN", NORMAL_PRIORITY).addClassAndMethod(this));
	}
}

@@ -1235,16 +1235,26 @@
 lazz) %7B%0A
+%09  try %7B%0A%09
 %09return 
@@ -1318,16 +1318,141 @@
 read%22);%0A
+%09  %7D catch (RuntimeException e) %7B%0A%09%09bugReporter.logError(%22Repository lookup failure: %22 + e.toString());%0A%09%09return false;%0A%09  %7D%0A
 %09%7D%0A   pu

Work around BCEL Repository bug.