[Fb-contrib-commit] SF.net SVN: fb-contrib:[1455] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-01-10 02:05:58
|
Revision: 1455
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1455&view=rev
Author: dbrosius
Date: 2010-01-10 02:05:50 +0000 (Sun, 10 Jan 2010)
Log Message:
-----------
split CVAA into two bug patterns, one for array assignment, one for element assignment
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-01-10 01:19:04 UTC (rev 1454)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-01-10 02:05:50 UTC (rev 1455)
@@ -308,7 +308,7 @@
<Detector
class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment"
- speed="fast" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT" />
+ speed="fast" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" />
<Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField"
speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" />
@@ -566,6 +566,8 @@
category="CORRECTNESS" experimental="true" />
<BugPattern abbrev="CVAA" type="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT"
category="CORRECTNESS" experimental="true" />
+ <BugPattern abbrev="CVAA" type="CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT"
+ category="CORRECTNESS" experimental="true" />
<BugPattern abbrev="NFF" type="NFF_NON_FUNCTIONAL_FIELD"
category="CORRECTNESS" experimental="true" />
<BugPattern abbrev="WNG" type="WNG_WRONG_NULL_FIELD_GUARD"
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2010-01-10 01:19:04 UTC (rev 1454)
+++ trunk/fb-contrib/etc/messages.xml 2010-01-10 02:05:50 UTC (rev 1455)
@@ -2782,13 +2782,33 @@
B[] b = new B[2];
A[] a = b;
+ </pre>
+ <p>It is a fast detector</p>
+ ]]>
+ </Details>
+ </BugPattern>
+
+ <BugPattern type="CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT">
+ <ShortDescription>method performs a contravariant array element assignment</ShortDescription>
+ <LongDescription>method {1} performs a contravariant array element assignment</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method contains a contravariant array element assignment. Since arrays are mutable
+ data structures, their use must be restricted to covariant or invariant usage</p>
+
+ <pre>
+ class A {}
+ class B extends A {}
+
+ B[] b = new B[2];
+ A[] a = b;
a[0] = new A(); // results in ArrayStoreException (Runtime)
</pre>
<p>It is a fast detector</p>
]]>
</Details>
</BugPattern>
-
+
<BugPattern type="NFF_NON_FUNCTIONAL_FIELD">
<ShortDescription>serializable class defines a final transient field</ShortDescription>
<LongDescription>serializable class {0} defines a final transient field</LongDescription>
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java 2010-01-10 01:19:04 UTC (rev 1454)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java 2010-01-10 02:05:50 UTC (rev 1455)
@@ -153,22 +153,15 @@
return;
}
- if(isArrayType(sourceSignature)) {
- if(!isArrayType(targetSignature)){
- bugReporter.reportBug(new BugInstance(this, "CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT", LOW_PRIORITY)
- .addClass(this)
- .addMethod(this)
- .addSourceLine(this));
- } else {
- if(isObjectType(sourceSignature) && isObjectType(targetSignature)){
- ObjectType sourceType = (ObjectType) ((ArrayType) Type.getType(sourceSignature)).getBasicType();
- ObjectType targetType = (ObjectType) ((ArrayType) Type.getType(targetSignature)).getBasicType();
- if(!targetType.equals(sourceType) && !targetType.subclassOf(sourceType)) {
- bugReporter.reportBug(new BugInstance(this, "CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT", NORMAL_PRIORITY)
- .addClass(this)
- .addMethod(this)
- .addSourceLine(this));
- }
+ if(isArrayType(sourceSignature) && isArrayType(targetSignature)) {
+ if(isObjectType(sourceSignature) && isObjectType(targetSignature)) {
+ ObjectType sourceType = (ObjectType) ((ArrayType) Type.getType(sourceSignature)).getBasicType();
+ ObjectType targetType = (ObjectType) ((ArrayType) Type.getType(targetSignature)).getBasicType();
+ if(!targetType.equals(sourceType) && !targetType.subclassOf(sourceType)) {
+ bugReporter.reportBug(new BugInstance(this, "CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|