FindInconsistentSync2.java

Index Score
edu.umd.cs.findbugs.detect
FindBugs

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
LINE_COMMENTNumber of line comments
JAVA0034JAVA0034 Missing braces in if statement
EXEC_COMMENTSComments in executable code
EXITSProcedure exits
CYCLOMATICCyclomatic complexity
JAVA0266JAVA0266 Use of System.out
UNIQUE_OPERANDSNumber of unique operands
OPERANDSNumber of operands
SIZESize of the file in bytes
PROGRAM_VOCABHalstead program vocabulary
PROGRAM_LENGTHHalstead program length
OPERATORSNumber of operators
LOGICAL_LINESNumber of statements
COMPARISONSNumber of comparison operators
ELOCEffective lines of code
LINESNumber of lines in the source file
LOCLines of code
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
RETURNSNumber of return points from functions
JAVA0145JAVA0145 Tab character used in source file
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
COMMENTSComment lines
JAVA0160JAVA0160 Method does not throw specified exception
BLOCKSNumber of blocks
INTERFACE_COMPLEXITYInterface complexity
LOOPSNumber of loops
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0130JAVA0130 Non-static method does not use instance fields
UNIQUE_OPERATORSNumber of unique operators
JAVA0144JAVA0144 Line exceeds maximum M characters
BLOCK_COMMENTNumber of block comment lines
JAVA0031JAVA0031 Case statement not properly closed
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
DECL_COMMENTSComments in declarations
WHITESPACENumber of whitespace lines
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
JAVA0032JAVA0032 Switch statement missing default
JAVA0126JAVA0126 Method declares unchecked exception in throws
FUNCTIONSNumber of function declarations
JAVA0064JAVA0064 N variations of identifier name (maximum: M)
PARAMSNumber of formal parameter declarations
/* * FindBugs - Find bugs in Java programs * Copyright (C) 2003-2005, 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.detect; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.bcel.Constants; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.FieldInstruction; import org.apache.bcel.generic.IFNONNULL; import org.apache.bcel.generic.IFNULL; import org.apache.bcel.generic.INVOKESTATIC; import org.apache.bcel.generic.Instruction; import org.apache.bcel.generic.InstructionHandle; import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.MethodGen; import org.apache.bcel.generic.ObjectType; import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.CallGraph; import edu.umd.cs.findbugs.CallGraphEdge; import edu.umd.cs.findbugs.CallGraphNode; import edu.umd.cs.findbugs.CallSite; import edu.umd.cs.findbugs.Detector; import edu.umd.cs.findbugs.FindBugsAnalysisFeatures; import edu.umd.cs.findbugs.IntAnnotation; import edu.umd.cs.findbugs.Priorities; import edu.umd.cs.findbugs.SelfCalls; import edu.umd.cs.findbugs.SourceLineAnnotation; import edu.umd.cs.findbugs.SystemProperties; import edu.umd.cs.findbugs.ba.AnalysisContext; import edu.umd.cs.findbugs.ba.CFG; import edu.umd.cs.findbugs.ba.CFGBuilderException; import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.ba.DataflowAnalysisException; import edu.umd.cs.findbugs.ba.Hierarchy; import edu.umd.cs.findbugs.ba.InnerClassAccess; import edu.umd.cs.findbugs.ba.InnerClassAccessMap; import edu.umd.cs.findbugs.ba.JCIPAnnotationDatabase; import edu.umd.cs.findbugs.ba.Location; import edu.umd.cs.findbugs.ba.LockChecker; import edu.umd.cs.findbugs.ba.LockSet; import edu.umd.cs.findbugs.ba.SignatureConverter; import edu.umd.cs.findbugs.ba.XFactory; import edu.umd.cs.findbugs.ba.XField; import edu.umd.cs.findbugs.ba.ch.Subtypes2; import edu.umd.cs.findbugs.ba.type.TopType; import edu.umd.cs.findbugs.ba.type.TypeDataflow; import edu.umd.cs.findbugs.ba.type.TypeFrame; import edu.umd.cs.findbugs.ba.vna.ValueNumber; import edu.umd.cs.findbugs.ba.vna.ValueNumberDataflow; import edu.umd.cs.findbugs.ba.vna.ValueNumberFrame; import edu.umd.cs.findbugs.classfile.ClassDescriptor; import edu.umd.cs.findbugs.classfile.DescriptorFactory; import edu.umd.cs.findbugs.classfile.MethodDescriptor; import edu.umd.cs.findbugs.props.WarningPropertySet; /** * Find instance fields which are sometimes accessed (read or written) * with the receiver lock held and sometimes without. * These are candidates to be data races. * * @author David Hovemeyer * @author Bill Pugh */ public class FindInconsistentSync2 implements Detector { private static final boolean DEBUG = SystemProperties.getBoolean("fis.debug"); private static final boolean SYNC_ACCESS = true; // Boolean.getBoolean("fis.syncAccess"); private static final boolean ADJUST_SUBCLASS_ACCESSES = !SystemProperties.getBoolean("fis.noAdjustSubclass"); private static final boolean EVAL = SystemProperties.getBoolean("fis.eval"); /* ---------------------------------------------------------------------- * Tuning parameters * ---------------------------------------------------------------------- */ /** * Minimum percent of unbiased field accesses that must be synchronized in * order to report a field as inconsistently synchronized. * This is meant to distinguish incidental synchronization from * intentional synchronization. */ private static final int MIN_SYNC_PERCENT = SystemProperties.getInteger("findbugs.fis.minSyncPercent", 50).intValue(); /** * Bias that writes are given with respect to reads. * The idea is that this should be above 1.0, because unsynchronized * writes are more dangerous than unsynchronized reads. */ private static final double WRITE_BIAS = Double.parseDouble(SystemProperties.getProperty("findbugs.fis.writeBias", "2.0")); /** * Factor which the biased number of unsynchronized accesses is multiplied by. * I.e., for factor <i>f</i>, if <i>nUnsync</i> is the biased number of unsynchronized * accesses, and <i>nSync</i> is the biased number of synchronized accesses, * and * <pre> * <i>f</i>(<i>nUnsync</i>) &gt; <i>nSync</i> * </pre> * then we report a bug. Default value is 2.0, which means that we * report a bug if more than 1/3 of accesses are unsynchronized. * <p/> * <p> Note that <code>MIN_SYNC_PERCENT</code> also influences * whether we report a bug: it specifies the minimum unbiased percentage * of synchronized accesses. */ private static final double UNSYNC_FACTOR = Double.parseDouble(SystemProperties.getProperty("findbugs.fis.unsyncFactor", "1.6")); /* ---------------------------------------------------------------------- * Helper classes * ---------------------------------------------------------------------- */ private static final int UNLOCKED = 0; private static final int LOCKED = 1; private static final int READ = 0; private static final int WRITE = 2; private static final int NULLCHECK = 4; private static final int READ_UNLOCKED = READ | UNLOCKED; private static final int WRITE_UNLOCKED = WRITE | UNLOCKED; private static final int NULLCHECK_UNLOCKED = NULLCHECK | UNLOCKED; private static final int READ_LOCKED = READ | LOCKED; private static final int WRITE_LOCKED = WRITE | LOCKED; private static final int NULLCHECK_LOCKED = NULLCHECK | LOCKED; private static class FieldAccess { final MethodDescriptor methodDescriptor; final int position; FieldAccess(MethodDescriptor methodDescriptor, int position) { this.methodDescriptor = methodDescriptor; this.position = position; } SourceLineAnnotation asSourceLineAnnotation() { return SourceLineAnnotation.fromVisitedInstruction(methodDescriptor, position); } public static Collection<SourceLineAnnotation> asSourceLineAnnotation(Collection<FieldAccess> c) { ArrayList<SourceLineAnnotation> result = new ArrayList<SourceLineAnnotation>(c.size()); for(FieldAccess f : c) result.add(f.asSourceLineAnnotation()); return result; } } private static ClassDescriptor servlet = DescriptorFactory.createClassDescriptor("javax/servlet/GenericServlet"); private static ClassDescriptor singleThreadedServlet = DescriptorFactory.createClassDescriptor("javax/servlet/SingleThreadModel"); public static boolean isServletField(XField field) { ClassDescriptor classDescriptor = field.getClassDescriptor(); try { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); if (subtypes2.isSubtype(classDescriptor, servlet) && !subtypes2.isSubtype(classDescriptor,singleThreadedServlet)) return true; } catch (ClassNotFoundException e) { assert true; } if (classDescriptor.getClassName().endsWith("Servlet")) return true; return false; } /** * The access statistics for a field. * Stores the number of locked and unlocked reads and writes, * as well as the number of accesses made with a lock held. */ private static class FieldStats { private final XField field; private final int[] countList = new int[6]; private int numLocalLocks = 0; private int numGetterMethodAccesses = 0; private List<FieldAccess> unsyncAccessList = new ArrayList<FieldAccess>(); private List<FieldAccess> syncAccessList = new ArrayList<FieldAccess>(); boolean interesting = true; final boolean servletField; FieldStats(XField field) { this.field = field; servletField = FindInconsistentSync2.isServletField(field); } public void addAccess(int kind) { countList[kind]++; } public int getNumAccesses(int kind) { return countList[kind]; } public void addLocalLock() { numLocalLocks++; } public int getNumLocalLocks() { return numLocalLocks; } public void addGetterMethodAccess() { numGetterMethodAccesses++; } public int getNumGetterMethodAccesses() { return numGetterMethodAccesses; } public boolean isInteresting() { return interesting; } public boolean isServletField() { return servletField; } public void addAccess(MethodDescriptor method, InstructionHandle handle, boolean isLocked) { if (!interesting) return; if (!SYNC_ACCESS && isLocked) return; if (!servletField && !isLocked && syncAccessList.size() == 0 && unsyncAccessList.size() > 10) { interesting = false; syncAccessList = null; unsyncAccessList = null; return; } (isLocked ? syncAccessList : unsyncAccessList).add(new FieldAccess(method, handle.getPosition())); } public Iterator<SourceLineAnnotation> unsyncAccessIterator() { if (!interesting) throw new IllegalStateException("Not interesting"); return FieldAccess.asSourceLineAnnotation(unsyncAccessList).iterator(); } public Iterator<SourceLineAnnotation> syncAccessIterator() { if (!interesting) throw new IllegalStateException("Not interesting"); return FieldAccess.asSourceLineAnnotation(syncAccessList).iterator(); } } /* ---------------------------------------------------------------------- * Fields * ---------------------------------------------------------------------- */ private BugReporter bugReporter; private Map<XField, FieldStats> statMap = new HashMap<XField, FieldStats>(); /* ---------------------------------------------------------------------- * Public methods * ---------------------------------------------------------------------- */ public FindInconsistentSync2(BugReporter bugReporter) { this.bugReporter = bugReporter; } public void visitClassContext(ClassContext classContext) { JavaClass javaClass = classContext.getJavaClass(); if (DEBUG) System.out.println("******** Analyzing class " + javaClass.getClassName()); // Build self-call graph SelfCalls selfCalls = new SelfCalls(classContext) { @Override public boolean wantCallsFor(Method method) { return !method.isPublic(); } }; Set<Method> lockedMethodSet; //Set<Method> publicReachableMethods; Set<Method> allMethods = new HashSet<Method>(Arrays.asList(javaClass.getMethods())); try { selfCalls.execute(); CallGraph callGraph = selfCalls.getCallGraph(); if (DEBUG) System.out.println("Call graph (not unlocked methods): " + callGraph.getNumVertices() + " nodes, " + callGraph.getNumEdges() + " edges"); // Find call edges that are obviously locked Set<CallSite> obviouslyLockedSites = findObviouslyLockedCallSites(classContext, selfCalls); lockedMethodSet = findNotUnlockedMethods(classContext, selfCalls, obviouslyLockedSites); lockedMethodSet.retainAll(findLockedMethods(classContext, selfCalls, obviouslyLockedSites)); //publicReachableMethods = findPublicReachableMethods(classContext, selfCalls); } catch (CFGBuilderException e) { bugReporter.logError("Error finding locked call sites", e); return; } catch (DataflowAnalysisException e) { bugReporter.logError("Error finding locked call sites", e); return; } for (Method method : allMethods) { if (DEBUG) System.out.println("******** Analyzing method " + method.getName()); if (classContext.getMethodGen(method) == null) continue; if (method.getName().startsWith("access$")) // Ignore inner class access methods; // we will treat calls to them as field accesses continue; try { analyzeMethod(classContext, method, lockedMethodSet); } catch (CFGBuilderException e) { bugReporter.logError("Error analyzing method", e); } catch (DataflowAnalysisException e) { bugReporter.logError("Error analyzing method", e); } } } public void report() { for (XField xfield : statMap.keySet()) { FieldStats stats = statMap.get(xfield); if (!stats.interesting) continue; JCIPAnnotationDatabase jcipAnotationDatabase = AnalysisContext.currentAnalysisContext() .getJCIPAnnotationDatabase(); boolean guardedByThis = "this".equals(jcipAnotationDatabase.getFieldAnnotation(xfield, "GuardedBy")); boolean notThreadSafe = jcipAnotationDatabase.hasClassAnnotation(xfield.getClassName(), "NotThreadSafe"); boolean threadSafe = jcipAnotationDatabase.hasClassAnnotation(xfield.getClassName().replace('/','.'), "ThreadSafe"); if (notThreadSafe) continue; WarningPropertySet<InconsistentSyncWarningProperty> propertySet = new WarningPropertySet<InconsistentSyncWarningProperty>(); int numReadUnlocked = stats.getNumAccesses(READ_UNLOCKED); int numWriteUnlocked = stats.getNumAccesses(WRITE_UNLOCKED); int numNullCheckUnlocked = stats.getNumAccesses(NULLCHECK_UNLOCKED); int numReadLocked = stats.getNumAccesses(READ_LOCKED); int numWriteLocked = stats.getNumAccesses(WRITE_LOCKED); int numNullCheckLocked = stats.getNumAccesses(NULLCHECK_LOCKED); int extra = 0; if (numWriteUnlocked > 0) extra = numNullCheckLocked; int locked = numReadLocked + numWriteLocked + numNullCheckLocked; int biasedLocked = numReadLocked + (int) (WRITE_BIAS * (numWriteLocked + numNullCheckLocked + extra) ); int unlocked = numReadUnlocked + numWriteUnlocked + numNullCheckUnlocked; int biasedUnlocked = numReadUnlocked + (int) (WRITE_BIAS * (numWriteUnlocked)); //int writes = numWriteLocked + numWriteUnlocked; if (unlocked == 0) { continue; // propertySet.addProperty(InconsistentSyncWarningProperty.NEVER_UNLOCKED); } if (guardedByThis) { propertySet.addProperty(InconsistentSyncWarningProperty.ANNOTATED_AS_GUARDED_BY_THIS); } if (threadSafe) { propertySet.addProperty(InconsistentSyncWarningProperty.ANNOTATED_AS_THREAD_SAFE); } if (!guardedByThis && locked == 0 && !stats.isServletField()) { continue; // propertySet.addProperty(InconsistentSyncWarningProperty.NEVER_LOCKED); } if (stats.isServletField() && numWriteLocked == 0 && numWriteUnlocked == 0) continue; if (DEBUG) { System.out.println("IS2: " + xfield); if (guardedByThis) System.out.println("Guarded by this"); System.out.println(" RL: " + numReadLocked); System.out.println(" WL: " + numWriteLocked); System.out.println(" NL: " + numNullCheckLocked); System.out.println(" RU: " + numReadUnlocked); System.out.println(" WU: " + numWriteUnlocked); System.out.println(" NU: " + numNullCheckUnlocked); } if (!EVAL && numReadUnlocked > 0 && ((int) (UNSYNC_FACTOR * (biasedUnlocked-1))) > biasedLocked && !stats.isServletField()) { // continue; propertySet.addProperty(InconsistentSyncWarningProperty.MANY_BIASED_UNLOCKED); } // NOTE: we ignore access to public, volatile, and final fields if (numWriteUnlocked + numWriteLocked == 0) { // No writes outside of constructor if (DEBUG) System.out.println(" No writes outside of constructor"); propertySet.addProperty(InconsistentSyncWarningProperty.NEVER_WRITTEN); // continue; } if (numReadUnlocked + numReadLocked == 0) { // No reads outside of constructor if (DEBUG) System.out.println(" No reads outside of constructor"); // continue; propertySet.addProperty(InconsistentSyncWarningProperty.NEVER_READ); } if (stats.getNumLocalLocks() == 0) { if (DEBUG) System.out.println(" No local locks"); // continue; propertySet.addProperty(InconsistentSyncWarningProperty.NO_LOCAL_LOCKS); } int freq, printFreq; if (locked + unlocked > 0) { freq = (100 * locked) / (locked + unlocked); printFreq = (100 * locked) / (locked + unlocked + numNullCheckUnlocked); } else { printFreq = freq = 0; } if (freq < MIN_SYNC_PERCENT) { // continue; propertySet.addProperty(InconsistentSyncWarningProperty.BELOW_MIN_SYNC_PERCENT); } if (DEBUG) System.out.println(" Sync %: " + freq); if (stats.getNumGetterMethodAccesses() >= unlocked) { // Unlocked accesses are only in getter method(s). propertySet.addProperty(InconsistentSyncWarningProperty.ONLY_UNSYNC_IN_GETTERS); } // At this point, we report the field as being inconsistently synchronized int priority = propertySet.computePriority(NORMAL_PRIORITY); if (!propertySet.isFalsePositive(priority) || stats.isServletField()) { BugInstance bugInstance; if (stats.isServletField()) bugInstance = new BugInstance(this, "MSF_MUTABLE_SERVLET_FIELD" , Priorities.NORMAL_PRIORITY) .addClass(xfield.getClassName()) .addField(xfield); else bugInstance = new BugInstance(this, guardedByThis? "IS_FIELD_NOT_GUARDED" : "IS2_INCONSISTENT_SYNC", priority) .addClass(xfield.getClassName()) .addField(xfield) .addInt(printFreq).describe(IntAnnotation.INT_SYNC_PERCENT); if (FindBugsAnalysisFeatures.isRelaxedMode()) { propertySet.decorateBugInstance(bugInstance); } // Add source lines for unsynchronized accesses for (Iterator<SourceLineAnnotation> j = stats.unsyncAccessIterator(); j.hasNext();) { SourceLineAnnotation accessSourceLine = j.next(); bugInstance.addSourceLine(accessSourceLine).describe("SOURCE_LINE_UNSYNC_ACCESS"); } if (SYNC_ACCESS) { // Add source line for synchronized accesses; // useful for figuring out what the detector is doing for (Iterator<SourceLineAnnotation> j = stats.syncAccessIterator(); j.hasNext();) { SourceLineAnnotation accessSourceLine = j.next(); bugInstance.addSourceLine(accessSourceLine).describe("SOURCE_LINE_SYNC_ACCESS"); } } if (EVAL) { bugInstance.addInt(biasedLocked).describe("INT_BIASED_LOCKED"); bugInstance.addInt(biasedUnlocked).describe("INT_BIASED_UNLOCKED"); } bugReporter.reportBug(bugInstance); } } } /* ---------------------------------------------------------------------- * Implementation * ---------------------------------------------------------------------- */ private static boolean isConstructor(String methodName) { return methodName.equals("<init>") || methodName.equals("<clinit>") || methodName.equals("readObject") || methodName.equals("clone") || methodName.equals("close") || methodName.equals("writeObject") || methodName.equals("toString") || methodName.equals("init") || methodName.equals("initialize") || methodName.equals("dispose") || methodName.equals("finalize") || methodName.equals("this") || methodName.equals("_jspInit") || methodName.equals("_jspDestroy") ; } private void analyzeMethod(ClassContext classContext, Method method, Set<Method> lockedMethodSet) throws CFGBuilderException, DataflowAnalysisException { InnerClassAccessMap icam = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap(); ConstantPoolGen cpg = classContext.getConstantPoolGen(); MethodGen methodGen = classContext.getMethodGen(method); if (methodGen == null) return; CFG cfg = classContext.getCFG(method); LockChecker lockChecker = classContext.getLockChecker(method); ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); boolean isGetterMethod = isGetterMethod(classContext, method); MethodDescriptor methodDescriptor = DescriptorFactory.instance().getMethodDescriptor(classContext.getJavaClass(), method); if (DEBUG) System.out.println("**** Analyzing method " + SignatureConverter.convertMethodSignature(methodGen)); for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) { Location location = i.next(); try { Instruction ins = location.getHandle().getInstruction(); XField xfield = null; boolean isWrite = false; boolean isLocal = false; boolean isNullCheck = false; if (ins instanceof FieldInstruction) { InstructionHandle n = location.getHandle().getNext(); isNullCheck = n.getInstruction() instanceof IFNONNULL || n.getInstruction() instanceof IFNULL; if (DEBUG && isNullCheck) System.out.println("is null check"); FieldInstruction fins = (FieldInstruction) ins; xfield = Hierarchy.findXField(fins, cpg); isWrite = ins.getOpcode() == Constants.PUTFIELD; isLocal = fins.getClassName(cpg).equals(classContext.getJavaClass().getClassName()); if (DEBUG) System.out.println("Handling field access: " + location.getHandle() + " (frame=" + vnaDataflow.getFactAtLocation(location) + ") :" + n); } else if (ins instanceof INVOKESTATIC) { INVOKESTATIC inv = (INVOKESTATIC) ins; InnerClassAccess access = icam.getInnerClassAccess(inv, cpg); if (access != null && access.getMethodSignature().equals(inv.getSignature(cpg))) { xfield = access.getField(); isWrite = !access.isLoad(); isLocal = false; if (DEBUG) System.out.println("Handling inner class access: " + location.getHandle() + " (frame=" + vnaDataflow.getFactAtLocation(location) + ")"); } } if (xfield == null) continue; // We only care about mutable nonvolatile nonpublic instance fields. if (xfield.isStatic() || xfield.isPublic() || xfield.isVolatile() || xfield.isFinal()) continue; // The value number frame could be invalid if the basic // block became unreachable due to edge pruning (dead code). ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location); if (!frame.isValid()) continue; // Get lock set and instance value ValueNumber thisValue = !method.isStatic() ? vnaDataflow.getAnalysis().getThisValue() : null; LockSet lockSet = lockChecker.getFactAtLocation(location); InstructionHandle handle = location.getHandle(); ValueNumber instance = frame.getInstance(handle.getInstruction(), cpg); if (DEBUG) { System.out.println("Lock set: " + lockSet); System.out.println("value number: " + instance.getNumber()); System.out.println("Lock count: " + lockSet.getLockCount(instance.getNumber())); } // Is the instance locked? // We consider the access to be locked if either // - the object is explicitly locked, or // - the field is accessed through the "this" reference, // and the method is in the locked method set, or // - any value returned by a called method is locked; // the (conservative) assumption is that the return lock object // is correct for synchronizing the access boolean isExplicitlyLocked = lockSet.getLockCount(instance.getNumber()) > 0; boolean isAccessedThroughThis = thisValue != null && thisValue.equals(instance); boolean isLocked = isExplicitlyLocked || ((isConstructor(method.getName()) || lockedMethodSet.contains(method)) && isAccessedThroughThis) || lockSet.containsReturnValue(vnaDataflow.getAnalysis().getFactory()); // Adjust the field so its class name is the same // as the type of reference it is accessed through. // This helps fix false positives produced when a // threadsafe class is extended by a subclass that // doesn't care about thread safety. if (ADJUST_SUBCLASS_ACCESSES) { // Find the type of the object instance TypeDataflow typeDataflow = classContext.getTypeDataflow(method); TypeFrame typeFrame = typeDataflow.getFactAtLocation(location); if (!typeFrame.isValid()) continue; Type instanceType = typeFrame.getInstance(handle.getInstruction(), cpg); if (instanceType instanceof TopType) { if (DEBUG) System.out.println("Freaky: typeFrame is " + typeFrame); continue; } // Note: instance type can be Null, // in which case we won't adjust the field type. if (instanceType != TypeFrame.getNullType()) { if (!(instanceType instanceof ObjectType)) { throw new DataflowAnalysisException("Field accessed through non-object reference " + instanceType, methodGen, handle); } ObjectType objType = (ObjectType) instanceType; // If instance class name is not the same as that of the field, // make it so String instanceClassName = objType.getClassName(); if (!instanceClassName.equals(xfield.getClassName())) { xfield = XFactory.getExactXField( instanceClassName, xfield.getName(), xfield.getSignature(), xfield.isStatic()); } } } int kind = 0; kind |= isLocked ? LOCKED : UNLOCKED; kind |= isWrite ? WRITE : isNullCheck ? NULLCHECK : READ; //if (isLocked || !isConstructor(method.getName())) { if (DEBUG) System.out.println("IS2:\t" + SignatureConverter.convertMethodSignature(methodGen) + "\t" + xfield + "\t" + ((isWrite ? "W" : "R") + "/" + (isLocked ? "L" : "U"))); FieldStats stats = getStats(xfield); // Don't count a contructor's synchronized access // toward the field statistics because it's // trivially true and doesn't really represent the // programmer's intention if(!(isLocked && isConstructor(method.getName()))) { stats.addAccess(kind); } if (isExplicitlyLocked && isLocal) stats.addLocalLock(); if (isGetterMethod && !isLocked) stats.addGetterMethodAccess(); stats.addAccess(methodDescriptor, handle, isLocked); //} } catch (ClassNotFoundException e) { bugReporter.reportMissingClass(e); } } } /** * Determine whether or not the the given method is * a getter method. I.e., if it just returns the * value of an instance field. * * @param classContext the ClassContext for the class containing the method * @param method the method */ @SuppressWarnings("unchecked") public static boolean isGetterMethod(ClassContext classContext, Method method) { MethodGen methodGen = classContext.getMethodGen(method); if (methodGen == null) return false; InstructionList il = methodGen.getInstructionList(); // System.out.println("Checking getter method: " + method.getName()); if (il.getLength() > 60) return false; int count = 0; Iterator<InstructionHandle> it = il.iterator(); while (it.hasNext()) { InstructionHandle ih = it.next(); switch (ih.getInstruction().getOpcode()) { case Constants.GETFIELD: count++; if (count > 1) return false; break; case Constants.PUTFIELD: case Constants.BALOAD: case Constants.CALOAD: case Constants.DALOAD: case Constants.FALOAD: case Constants.IALOAD: case Constants.LALOAD: case Constants.SALOAD: case Constants.AALOAD: case Constants.BASTORE: case Constants.CASTORE: case Constants.DASTORE: case Constants.FASTORE: case Constants.IASTORE: case Constants.LASTORE: case Constants.SASTORE: case Constants.AASTORE: case Constants.PUTSTATIC: return false; case Constants.INVOKESTATIC: case Constants.INVOKEVIRTUAL: case Constants.INVOKEINTERFACE: case Constants.INVOKESPECIAL: case Constants.GETSTATIC: // no-op } } // System.out.println("Found getter method: " + method.getName()); return true; } /** * Get the access statistics for given field. */ private FieldStats getStats(XField field) { FieldStats stats = statMap.get(field); if (stats == null) { stats = new FieldStats(field); statMap.put(field, stats); } return stats; } /** * Find methods that appear to never be called from an unlocked context * We assume that nonpublic methods will only be called from * within the class, which is not really a valid assumption. */ private Set<Method> findNotUnlockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites) throws CFGBuilderException, DataflowAnalysisException { JavaClass javaClass = classContext.getJavaClass(); Method[] methodList = javaClass.getMethods(); CallGraph callGraph = selfCalls.getCallGraph(); // Initially, assume no methods are called from an // unlocked context Set<Method> lockedMethodSet = new HashSet<Method>(); lockedMethodSet.addAll(Arrays.asList(methodList)); // Assume all public methods are called from // unlocked context for (Method method : methodList) { if (method.isPublic() && !isConstructor(method.getName())) { lockedMethodSet.remove(method); } } // Explore the self-call graph to find nonpublic methods // that can be called from an unlocked context. boolean change; do { change = false; for (Iterator<CallGraphEdge> i = callGraph.edgeIterator(); i.hasNext();) { CallGraphEdge edge = i.next(); CallSite callSite = edge.getCallSite(); // Ignore obviously locked edges if (obviouslyLockedSites.contains(callSite)) continue; // If the calling method is locked, ignore the edge if (lockedMethodSet.contains(callSite.getMethod())) continue; // Calling method is unlocked, so the called method // is also unlocked. CallGraphNode target = edge.getTarget(); if (lockedMethodSet.remove(target.getMethod())) change = true; } } while (change); if (DEBUG) { System.out.println("Apparently not unlocked methods:"); for (Method method : lockedMethodSet) { System.out.println("\t" + method.getName()); } } // We assume that any methods left in the locked set // are called only from a locked context. return lockedMethodSet; } /** * Find methods that appear to always be called from a locked context. * We assume that nonpublic methods will only be called from * within the class, which is not really a valid assumption. */ private Set<Method> findLockedMethods(ClassContext classContext, SelfCalls selfCalls, Set<CallSite> obviouslyLockedSites) throws CFGBuilderException, DataflowAnalysisException { JavaClass javaClass = classContext.getJavaClass(); Method[] methodList = javaClass.getMethods(); CallGraph callGraph = selfCalls.getCallGraph(); // Initially, assume all methods are locked Set<Method> lockedMethodSet = new HashSet<Method>(); // Assume all public methods are unlocked for (Method method : methodList) { if (method.isSynchronized()) { lockedMethodSet.add(method); } } // Explore the self-call graph to find nonpublic methods // that can be called from an unlocked context. boolean change; do { change = false; for (Iterator<CallGraphEdge> i = callGraph.edgeIterator(); i.hasNext();) { CallGraphEdge edge = i.next(); CallSite callSite = edge.getCallSite(); if (obviouslyLockedSites.contains(callSite) || lockedMethodSet.contains(callSite.getMethod())) { // Calling method is locked, so the called method // is also locked. CallGraphNode target = edge.getTarget(); if (lockedMethodSet.add(target.getMethod())) change = true; } } } while (change); if (DEBUG) { System.out.println("Apparently locked methods:"); for (Method method : lockedMethodSet) { System.out.println("\t" + method.getName()); } } // We assume that any methods left in the locked set // are called only from a locked context. return lockedMethodSet; } /** * Find methods that do not appear to be reachable from public methods. * Such methods will not be analyzed. */ /* private Set<Method> findPublicReachableMethods(ClassContext classContext, SelfCalls selfCalls) throws CFGBuilderException, DataflowAnalysisException { JavaClass javaClass = classContext.getJavaClass(); Method[] methodList = javaClass.getMethods(); CallGraph callGraph = selfCalls.getCallGraph(); // Initially, assume all methods are locked Set<Method> publicReachableMethodSet = new HashSet<Method>(); // Assume all public methods are unlocked for (Method method : methodList) { if (method.isPublic() && !isConstructor(method.getName())) { publicReachableMethodSet.add(method); } } // Explore the self-call graph to find nonpublic methods // that can be called from an unlocked context. boolean change; do { change = false; for (Iterator<CallGraphEdge> i = callGraph.edgeIterator(); i.hasNext();) { CallGraphEdge edge = i.next(); CallSite callSite = edge.getCallSite(); // Ignore obviously locked edges // If the calling method is locked, ignore the edge if (publicReachableMethodSet.contains(callSite.getMethod())) { // Calling method is reachable, so the called method // is also reachable. CallGraphNode target = edge.getTarget(); if (publicReachableMethodSet.add(target.getMethod())) change = true; } } } while (change); if (DEBUG) { System.out.println("Methods apparently reachable from public non-constructor methods:"); for (Method method : publicReachableMethodSet) { System.out.println("\t" + method.getName()); } } return publicReachableMethodSet; } */ /** * Find all self-call sites that are obviously locked. */ private Set<CallSite> findObviouslyLockedCallSites(ClassContext classContext, SelfCalls selfCalls) throws CFGBuilderException, DataflowAnalysisException { ConstantPoolGen cpg = classContext.getConstantPoolGen(); // Find all obviously locked call sites Set<CallSite> obviouslyLockedSites = new HashSet<CallSite>(); for (Iterator<CallSite> i = selfCalls.callSiteIterator(); i.hasNext();) { CallSite callSite = i.next(); Method method = callSite.getMethod(); Location location = callSite.getLocation(); InstructionHandle handle = location.getHandle(); // Only instance method calls qualify as candidates for // "obviously locked" Instruction ins = handle.getInstruction(); if (ins.getOpcode() == Constants.INVOKESTATIC) continue; // Get lock set for site LockChecker lockChecker = classContext.getLockChecker(method); LockSet lockSet = lockChecker.getFactAtLocation(location); // Get value number frame for site ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location); // NOTE: if the CFG on which the value number analysis was performed // was pruned, there may be unreachable instructions. Therefore, // we can't assume the frame is valid. if (!frame.isValid()) continue; // Find the ValueNumber of the receiver object int numConsumed = ins.consumeStack(cpg); MethodGen methodGen = classContext.getMethodGen(method); assert methodGen != null; if (numConsumed == Constants.UNPREDICTABLE) throw new DataflowAnalysisException( "Unpredictable stack consumption", methodGen, handle); //if (DEBUG) System.out.println("Getting receiver for frame: " + frame); ValueNumber instance = frame.getStackValue(numConsumed - 1); // Is the instance locked? int lockCount = lockSet.getLockCount(instance.getNumber()); if (lockCount > 0) { // This is a locked call site obviouslyLockedSites.add(callSite); } } return obviouslyLockedSites; } } // vim:ts=3

The table below shows all metrics for FindInconsistentSync2.java.

MetricValueDescription
BLOCKS87.00Number of blocks
BLOCK_COMMENT85.00Number of block comment lines
COMMENTS239.00Comment lines
COMMENT_DENSITY 0.45Comment density
COMPARISONS102.00Number of comparison operators
CYCLOMATIC176.00Cyclomatic complexity
DECL_COMMENTS20.00Comments in declarations
DOC_COMMENT67.00Number of javadoc comment lines
ELOC536.00Effective lines of code
EXEC_COMMENTS55.00Comments in executable code
EXITS149.00Procedure exits
FUNCTIONS27.00Number of function declarations
HALSTEAD_DIFFICULTY98.68Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY94.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 1.00JAVA0031 Case statement not properly closed
JAVA0032 1.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003445.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 2.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 2.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 2.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 9.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 5.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 6.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA011714.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 3.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 3.00JAVA0144 Line exceeds maximum M characters
JAVA01452356.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 4.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 6.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 7.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 1.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA026628.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES984.00Number of lines in the source file
LINE_COMMENT87.00Number of line comments
LOC617.00Lines of code
LOGICAL_LINES357.00Number of statements
LOOPS 9.00Number of loops