[Fb-contrib-commit] SF.net SVN: fb-contrib:[1093] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-02-20 05:22:51
|
Revision: 1093
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1093&view=rev
Author: dbrosius
Date: 2009-02-20 05:22:46 +0000 (Fri, 20 Feb 2009)
Log Message:
-----------
add detector IICU
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
Added Paths:
-----------
trunk/fb-contrib/samples/IICU_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2009-02-16 01:04:37 UTC (rev 1092)
+++ trunk/fb-contrib/etc/findbugs.xml 2009-02-20 05:22:46 UTC (rev 1093)
@@ -324,6 +324,10 @@
speed="fast"
reports="LO_SUSPECT_LOG_CLASS" />
+ <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse"
+ speed="fast"
+ reports="IICU_INCORRECT_INTERNAL_CLASS_USE" />
+
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" />
@@ -436,4 +440,5 @@
<BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" />
<BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" experimental="true" />
<BugPattern abbrev="LO" type="LO_SUSPECT_LOG_CLASS" category="CORRECTNESS" experimental="true" />
+ <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" experimental="true" />
</FindbugsPlugin>
\ No newline at end of file
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2009-02-16 01:04:37 UTC (rev 1092)
+++ trunk/fb-contrib/etc/messages.xml 2009-02-20 05:22:46 UTC (rev 1093)
@@ -890,6 +890,16 @@
</Details>
</Detector>
+ <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse">
+ <Details>
+ <![CDATA[
+ <p>looks for classes that rely on sun internal classes in the package com.sun.xxxx. As these classes
+ are not officially released from sun, they are subject to change or removal, and thus,
+ should not be counted on.</p>
+ ]]>
+ </Details>
+ </Detector>
+
<!-- BugPattern -->
<BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING">
@@ -2336,6 +2346,18 @@
</Details>
</BugPattern>
+ <BugPattern type="IICU_INCORRECT_INTERNAL_CLASS_USE">
+ <ShortDescription>class relies on internal sun classes</ShortDescription>
+ <LongDescription>class {0} relies on internal sun classes</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This class makes use of internal sun classes in the package com.sun.xxx. As these
+ classes are not documented, nor externally released as part of the api, they are subject
+ to change or removal. You should not be using these classes.</p>
+ ]]>
+ </Details>
+ </BugPattern>
+
<!-- BugCode -->
<BugCode abbrev="ISB">Inefficient String Buffering</BugCode>
@@ -2411,4 +2433,5 @@
<BugCode abbrev="WEM">Weak Exception Messaging</BugCode>
<BugCode abbrev="SCSS">Suspicious Clustered Session Support</BugCode>
<BugCode abbrev="LO">Logger Oddities</BugCode>
+ <BugCode abbrev="IICU">Incorrect Internal Class use</BugCode>
</MessageCollection>
\ No newline at end of file
Added: trunk/fb-contrib/samples/IICU_Sample.java
===================================================================
--- trunk/fb-contrib/samples/IICU_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/IICU_Sample.java 2009-02-20 05:22:46 UTC (rev 1093)
@@ -0,0 +1,12 @@
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
+
+
+public class IICU_Sample
+{
+ public void test()
+ {
+ XMLGregorianCalendar cal = new XMLGregorianCalendarImpl();
+ }
+}
Property changes on: trunk/fb-contrib/samples/IICU_Sample.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2009-02-20 05:22:46 UTC (rev 1093)
@@ -0,0 +1,73 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2009 Dave Brosius
+ *
+ * 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 com.mebigfatguy.fbcontrib.detect;
+import org.apache.bcel.classfile.Constant;
+import org.apache.bcel.classfile.ConstantClass;
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.JavaClass;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.Detector;
+import edu.umd.cs.findbugs.ba.ClassContext;
+
+/**
+ * looks for classes that use objects from com.sun.xxx packages. As these are internal
+ * to sun and subject to change, this should not be done.
+ */
+public class IncorrectInternalClassUse implements Detector
+{
+ private final BugReporter bugReporter;
+
+ /**
+ * constructs a IICU detector given the reporter to report bugs on
+ * @param bugReporter the sync of bug reports
+ */
+ public IncorrectInternalClassUse(BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ /**
+ * implements the visitor to look for classes that reference com.sun.xxx classes
+ * by looking for class constants in the constant pool
+ *
+ * @param classContext the context object of the currently parsed class
+ */
+ public void visitClassContext(ClassContext context) {
+ JavaClass cls = context.getJavaClass();
+ if (!cls.getClassName().startsWith("com/sun/")) {
+ ConstantPool pool = cls.getConstantPool();
+ int numItems = pool.getLength();
+ for (int i = 0; i < numItems; i++) {
+ Constant c = pool.getConstant(i);
+ if (c instanceof ConstantClass) {
+ String clsName = ((ConstantClass) c).getBytes(pool);
+ if (clsName.startsWith("com/sun/")) {
+ bugReporter.reportBug(new BugInstance(this, "IICU_INCORRECT_INTERNAL_CLASS_USE", NORMAL_PRIORITY)
+ .addClass(cls)
+ .addString(clsName));
+ }
+ }
+ }
+ }
+ }
+
+ public void report() {
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|