FindBugs Report

Project Information

Project: <<unnamed project>>

FindBugs version: 0.9.4

Code analyzed:

Contents

Summary

Warning Type Number
Correctness Warnings 5
Internationalization Warnings 0
Multithreaded Correctness Warnings 1
Malicious Code Vulnerability Warnings 6
Performance Warnings 16
Style Warnings 2
Total 30

Warnings

Click on a warning row to see full context information.

Correctness Warnings

Code  Warning
DE biz.xsoftware.test.mock.TestMockCreator.testThrowCheckedException() might ignore java.io.IOException
Dm biz.xsoftware.manifest.ManifestUtilImpl.getFile(java.net.URL) invokes System.exit(...), which shuts down the entire virtual machine
EC Call to equals() comparing unrelated class and interface in biz.xsoftware.test.mock.TestMockCreator.testEqualsAndToString()
RCN Nullcheck of value previously dereferenced biz.xsoftware.impl.mock.MockSuperclass.getLeftOverMethods(java.util.Set)
Se Class biz.xsoftware.mock.ExpectFailedException defines non-transient non-serializable instance field biz.xsoftware.mock.ExpectFailedException.methods

Internationalization Warnings

Code  Warning

Multithreaded Correctness Warnings

Code  Warning
Ru biz.xsoftware.impl.mock.test.TestOrderedCalls.testOrderBeforeFails() explicitly invokes run on a thread (did you mean to start it instead?)

Malicious Code Vulnerability Warnings

Code  Warning
EI biz.xsoftware.impl.mock.MockObjectImpl.getClasses() may expose internal representation by returning biz.xsoftware.impl.mock.MockObjectImpl.classes
EI biz.xsoftware.mock.CalledMethod.getAllParams() may expose internal representation by returning biz.xsoftware.mock.CalledMethod.params
EI biz.xsoftware.mock.ExpectFailedException.getCalledMethods() may expose internal representation by returning biz.xsoftware.mock.ExpectFailedException.methods
EI2 biz.xsoftware.impl.mock.MockObjectImpl.(String,Class[]) may expose internal representation by storing an externally mutable object into biz.xsoftware.impl.mock.MockObjectImpl.classes
EI2 biz.xsoftware.mock.CalledMethod.(String,Object[],Throwable) may expose internal representation by storing an externally mutable object into biz.xsoftware.mock.CalledMethod.params
EI2 biz.xsoftware.mock.ExpectFailedException.(String,CalledMethod[],String) may expose internal representation by storing an externally mutable object into biz.xsoftware.mock.ExpectFailedException.methods

Performance Warnings

Code  Warning
Dm biz.xsoftware.impl.mock.MockObjectImpl.callSuperMethod(Object,java.lang.reflect.Method,Object[]) invokes dubious Boolean constructor; use Boolean.valueOf(...) instead
SBSC Method biz.xsoftware.impl.mock.MessageHelper.getMethodSignature(String,java.lang.reflect.Method,String) concatenates strings using + in a loop
SBSC Method biz.xsoftware.impl.mock.MessageHelper.putTogetherReason(String[],java.util.Set,java.util.List,String) concatenates strings using + in a loop
SBSC Method biz.xsoftware.impl.mock.MethodVerifier.getClassNamesString(Class[]) concatenates strings using + in a loop
SBSC Method biz.xsoftware.impl.mock.MethodVerifier.getMethod(Class[],boolean,String,Class[]) concatenates strings using + in a loop
SBSC Method biz.xsoftware.impl.mock.MethodVerifier.getMethodSigString(String,Class[]) concatenates strings using + in a loop
SBSC Method biz.xsoftware.impl.mock.MockObjectImpl.getCleanMethodString(java.lang.reflect.Method) concatenates strings using + in a loop
SBSC Method biz.xsoftware.impl.mock.MockSuperclass.expectImpl(String[]) concatenates strings using + in a loop
SBSC Method biz.xsoftware.impl.mock.MockSuperclass.methodCalledImpl(String,Object[]) concatenates strings using + in a loop
SBSC Method biz.xsoftware.impl.mock.MockSuperclass$LeftOverMethods.toString() concatenates strings using + in a loop
SBSC Method biz.xsoftware.manifest.ManifestInfo.toString() concatenates strings using + in a loop
SIC Should biz.xsoftware.examples.basic2.TestExample$BadCreditSimulator be a _static_ inner class?
SIC Should biz.xsoftware.examples.behavior.TestExample$MyBehavior be a _static_ inner class?
SIC Should biz.xsoftware.impl.mock.MockSuperclass$LeftOverMethods be a _static_ inner class?
SIC Should biz.xsoftware.manifest.TestManifestInfo$FakeJarLocator be a _static_ inner class?
WMI Method biz.xsoftware.manifest.ManifestInfo.toString() makes inefficient use of keySet iterator instead of entrySet iterator

Style Warnings

Code  Warning
Nm Class biz.xsoftware.impl.mock.ThrowException is not derived from an Exception, even though it is named as such
PS Class biz.xsoftware.impl.mock.MockSuperclass exposes synchronization and semaphores in its public interface.

Details

DE_MIGHT_IGNORE: Method might ignore exception

This method might ignore an exception.  In general, exceptions should be handled or reported in some way, or they should be thrown out of the method.

DM_BOOLEAN_CTOR: Method invokes dubious Boolean constructor; use Boolean.valueOf(...) instead

Creating new instances of java.lang.Boolean wastes memory, since Boolean objects are immutable and there are only two useful values of this type.  Use the Boolean.valueOf() method to create Boolean objects instead.

DM_EXIT: Method invokes System.exit(...)

Invoking System.exit shuts down the entire Java virtual machine. This should only been done when it is appropriate. Such calls make it hard or impossible for your code to be invoked by other code. Consider throwing a RuntimeException instead.

EC_UNRELATED_CLASS_AND_INTERFACE: Call to equals() comparing unrelated class and interface

This method calls equals(Object) on two references, one of which is a class and the other an interface, where neither the class nor any of its non-abstract subclasses implement the interface. Therefore, the objects being compared are unlikely to be members of the same class at runtime (unless some application classes were not analyzed, or dynamic class loading can occur at runtime). According to the contract of equals(), objects of different classes should always compare as unequal; therefore, according to the contract defined by java.lang.Object.equals(Object), the result of this comparison will always be false at runtime.

EI_EXPOSE_REP: Method may expose internal representation by returning reference to mutable object

Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Returning a new copy of the object is better approach in many situations.

EI_EXPOSE_REP2: Method may expose internal representation by incorporating reference to mutable object

This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.

NM_CLASS_NOT_EXCEPTION: Class is not derived from an Exception, even though it is named as such

This class is not derived from another exception, but ends with 'Exception'. This will be confusing to users of this class.

PS_PUBLIC_SEMAPHORES: Class exposes synchronization and semaphores in its public interface.

This class uses synchronization along with wait(), notify() or notifyAll() on itself (the this reference). Client classes that use this class, may, in addition, use an instance of this class as a synchronizing object. Because two classes are using the same object for synchronization, Multithread correctness is suspect. You should not synchronize nor call semaphore methods on a public reference. Consider using a internal private member variable to control synchronization.

RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE: Nullcheck of value previously dereferenced

A value is checked here to see whether it is null, but this value can't be null because it was previously dereferences and if it were null a null pointer exception would have occurred. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.

RU_INVOKE_RUN: Invokes run on a thread (did you mean to start it instead?)

This method explicitly invokes run() on an object.  In general, classes implement the Runnable interface because they are going to have their run() method invoked in a new thread, in which case Thread.start() is the right method to call.

SBSC_USE_STRINGBUFFER_CONCATENATION: Method concatenates strings using + in a loop

The method seems to be building a String using concatenation in a loop. In each iteration, the String is converted to a StringBuffer/StringBuilder, appended to, and converted back to a String. This can lead to a cost quadratic in the number of iterations, as the growing string is recopied in each iteration.

Better performance can be obtained by using a StringBuffer (or StringBuilder in Java 1.5) explicitly.

For example:

  // This is bad
  String s = "";
  for (int i = 0; i < field.length; ++i) {
    s = s + field[i];
  }

  // This is better
  StringBuffer buf = new StringBuffer();
  for (int i = 0; i < field.length; ++i) {
    buf.append(field[i]);
  }
  String s = buf.toString();

SE_BAD_FIELD: Non-transient non-serializable instance field in serializable class

This Serializable class defines a non-primitive instance field which is neither transient, Serializable, or java.lang.Object, and does not appear to implement the Externalizable interface or the readObject() and writeObject() methods.  Objects of this class will not be deserialized correctly if a non-Serializable object is stored in this field.

SIC_INNER_SHOULD_BE_STATIC: Should be a static inner class

This class is an inner class, but does not use its embedded reference to the object which created it.  This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.  If possible, the class should be be made static.

WMI_WRONG_MAP_ITERATOR: Inefficient use of keySet iterator instead of entrySet iterator

This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.