@@ -0,0 +1,1956 @@
+/*%0A * FindBugs - Find bugs in Java programs%0A * Copyright (C) 2003, University of Maryland%0A * %0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A * %0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A * %0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA%0A */%0A%0Apackage edu.umd.cs.findbugs.detect;%0Aimport edu.umd.cs.findbugs.*;%0Aimport java.util.*;%0Aimport java.io.PrintStream;%0Aimport org.apache.bcel.classfile.*;%0Aimport java.util.zip.*;%0Aimport java.io.*;%0A%0Aimport edu.umd.cs.pugh.visitclass.DismantleBytecode;%0Aimport edu.umd.cs.pugh.visitclass.Constants2;%0A%0Apublic class PreferZeroLengthArrays extends BytecodeScanningDetector implements   Constants2 %7B%0A    boolean nullOnTOS = false;%0A    private BugReporter bugReporter;%0A%0A  public PreferZeroLengthArrays(BugReporter bugReporter) %7B%0A%09this.bugReporter = bugReporter;%0A  %7D%0A%0A   public void visit(Code obj) %7B%0A%09String returnType = methodSig.substring(methodSig.indexOf(%22)%22)+1);%0A%09if (returnType.startsWith(%22%5B%22)) %7B%0A%09%09nullOnTOS = false;%0A%09%09super.visit(obj);%0A%09%09%7D%0A%09%7D%0A%0A%0A    public void sawOpcode(int seen) %7B%0A%0A%09switch (seen) %7B%0A%09case ACONST_NULL:%0A%09%09nullOnTOS = true;%0A%09%09return;%0A%09case ARETURN:%0A%09%09if (nullOnTOS) %0A                  bugReporter.reportBug(new BugInstance(%22PZLA_PREFER_ZERO_LENGTH_ARRAYS%22, LOW_PRIORITY)%0A                        .addClassAndMethod(this)%0A                        .addSourceLine(this, PC));%0A%09%09break;%0A%09%7D%0A%09nullOnTOS = false;%0A%09%7D%0A%7D%0A

Check for methods with array return type that return null