[Fb-contrib-commit] SF.net SVN: fb-contrib: [646] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-09-12 02:57:33
|
Revision: 646 http://svn.sourceforge.net/fb-contrib/?rev=646&view=rev Author: dbrosius Date: 2006-09-11 19:57:27 -0700 (Mon, 11 Sep 2006) Log Message: ----------- don't report no setLabelFor when the JLabel doesn't have a String Modified Paths: -------------- trunk/fb-contrib/samples/S508C_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/samples/S508C_Sample.java =================================================================== --- trunk/fb-contrib/samples/S508C_Sample.java 2006-09-11 05:20:58 UTC (rev 645) +++ trunk/fb-contrib/samples/S508C_Sample.java 2006-09-12 02:57:27 UTC (rev 646) @@ -1,6 +1,7 @@ import java.awt.Color; import java.awt.Container; +import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; @@ -8,6 +9,7 @@ public class S508C_Sample extends JFrame { private JLabel fLabel = new JLabel("Hello"); + private JLabel imgLabel = new JLabel(new ImageIcon("/boo.gif")); private JComponent c = new MyComponent(); public S508C_Sample() { @@ -19,6 +21,9 @@ lLabel.setBackground(new Color(255, 0, 0)); lLabel.setForeground(new Color(255, 255, 100)); cp.add(lLabel); + + JLabel picLabel = new JLabel(new ImageIcon("/foo.gif")); + cp.add(picLabel); cp.add(c); setSize(300, 200); Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-09-11 05:20:58 UTC (rev 645) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2006-09-12 02:57:27 UTC (rev 646) @@ -164,16 +164,37 @@ */ @Override public void sawOpcode(int seen) { + boolean sawTextLabel = 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())) { + if ("Ljavax/swing/JLabel;".equals(item.getSignature()) + && (item.getUserValue() != null)) { int reg = RegisterUtils.getAStoreReg(this, seen); localLabels.put(Integer14.valueOf(reg), SourceLineAnnotation.fromVisitedInstruction(this)); } } + } else if (seen == PUTFIELD) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if (item.getUserValue() == null) { + FieldAnnotation fa = new FieldAnnotation(getClassName(), getNameConstantOperand(), getSigConstantOperand(), false); + if (fa != null) + fieldLabels.remove(fa); + } + } + } else if (seen == INVOKESPECIAL) { + String className = getClassConstantOperand(); + String methodName = getNameConstantOperand(); + if ("javax/swing/JLabel".equals(className) + && "<init>".equals(methodName)) { + String signature = getSigConstantOperand(); + if (signature.indexOf("Ljava/lang/String;") >= 0) { + sawTextLabel = true; + } + } } else if (seen == INVOKEVIRTUAL) { String className = getClassConstantOperand(); String methodName = getNameConstantOperand(); @@ -238,6 +259,12 @@ bugReporter.reportMissingClass(cnfe); } finally { stack.sawOpcode(this, seen); + if (sawTextLabel) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(Boolean.TRUE); + } + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |