[Fb-contrib-commit] SF.net SVN: fb-contrib:[1696] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2011-07-03 05:37:57
|
Revision: 1696
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1696&view=rev
Author: dbrosius
Date: 2011-07-03 05:37:51 +0000 (Sun, 03 Jul 2011)
Log Message:
-----------
don't report S508C for colors that come from UIManager
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2011-07-02 03:48:25 UTC (rev 1695)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2011-07-03 05:37:51 UTC (rev 1696)
@@ -47,6 +47,9 @@
*/
public class Section508Compliance extends BytecodeScanningDetector
{
+ private static final String SAW_TEXT_LABEL = "SAW_TEXT_LABEL";
+ private static final String FROM_UIMANAGER = "FROM_UIMANAGER";
+
private static JavaClass windowClass;
private static JavaClass componentClass;
private static JavaClass jcomponentClass;
@@ -200,13 +203,14 @@
@Override
public void sawOpcode(int seen) {
boolean sawTextLabel = false;
+ boolean sawUIManager = false;
try {
stack.mergeJumps(this);
if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
if ("Ljavax/swing/JLabel;".equals(item.getSignature())
- && (item.getUserValue() != null)) {
+ && (SAW_TEXT_LABEL.equals(item.getUserValue()))) {
int reg = RegisterUtils.getAStoreReg(this, seen);
localLabels.put(Integer.valueOf(reg), SourceLineAnnotation.fromVisitedInstruction(this));
}
@@ -214,7 +218,7 @@
} else if (seen == PUTFIELD) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
- if (item.getUserValue() == null) {
+ if (!SAW_TEXT_LABEL.equals(item.getUserValue())) {
FieldAnnotation fa = new FieldAnnotation(getDottedClassName(), getNameConstantOperand(), getSigConstantOperand(), false);
fieldLabels.remove(XFactory.createXField(fa));
}
@@ -278,17 +282,24 @@
|| "setForeground".equals(methodName)) {
int argCount = Type.getArgumentTypes(getSigConstantOperand()).length;
if (stack.getStackDepth() > argCount) {
- OpcodeStack.Item item = stack.getStackItem(argCount);
- JavaClass cls = item.getJavaClass();
- if (((jcomponentClass != null) && cls.instanceOf(jcomponentClass))
- || ((componentClass != null) && cls.instanceOf(componentClass))) {
- bugReporter.reportBug(new BugInstance(this, "S508C_SET_COMP_COLOR", NORMAL_PRIORITY)
- .addClass(this)
- .addMethod(this)
- .addSourceLine(this));
- }
+ OpcodeStack.Item item = stack.getStackItem(0);
+ if (!FROM_UIMANAGER.equals(item.getUserValue())) {
+ item = stack.getStackItem(argCount);
+ JavaClass cls = item.getJavaClass();
+ if (((jcomponentClass != null) && cls.instanceOf(jcomponentClass))
+ || ((componentClass != null) && cls.instanceOf(componentClass))) {
+ bugReporter.reportBug(new BugInstance(this, "S508C_SET_COMP_COLOR", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
+ }
}
}
+ } else if (seen == INVOKESTATIC) {
+ if ("javax/swing/UIManager".equals(getClassConstantOperand())) {
+ sawUIManager = true;
+ }
}
if ((seen == INVOKEVIRTUAL) || (seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE)) {
@@ -319,8 +330,13 @@
if (sawTextLabel) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
- item.setUserValue(Boolean.TRUE);
+ item.setUserValue(SAW_TEXT_LABEL);
}
+ } else if (sawUIManager) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ item.setUserValue(FROM_UIMANAGER);
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|