-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b03
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.7.0_02-ea"
Java(TM) SE Runtime Environment (build 1.7.0_02-ea-b02)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
javax.swing.text.html.CSS.CssValue is the base class of all values for CSS attributes. CSS attributes are usually stored as key/value pairs in AttributeSet-s. Two AttributeSet-s can be compared using the AttributeSet.isEqual() method. In case of CSS attributes this test may fail due to the missing implementation of equals() and hashCode() for class CssValue and its subclasses.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The test should print out "a is equal b".
ACTUAL -
The test prints out "a is NOT equal b".
The two AttributeSet-s a and b in the example should be equal. The test fails as using StyleSheet.addCSSAttribute() wraps the value (i.e. 42) in a new CSS.FontSize instance. Fixing this is important for HTMLWriter!
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.html.CSS;
import javax.swing.text.html.StyleSheet;
public class Test {
public static void main(String[] args) {
StyleSheet ss = new StyleSheet();
String fontSize = "42";
SimpleAttributeSet a = new SimpleAttributeSet();
ss.addCSSAttribute( a, CSS.Attribute.FONT_SIZE, fontSize);
SimpleAttributeSet b = new SimpleAttributeSet();
ss.addCSSAttribute( b, CSS.Attribute.FONT_SIZE, fontSize);
if (a.isEqual( b) ) System.out.println( "a is equal b"); else System.out.println( "a is NOT equal b");
}
}
---------- END SOURCE ----------
java version "1.7.0_02-ea"
Java(TM) SE Runtime Environment (build 1.7.0_02-ea-b02)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
javax.swing.text.html.CSS.CssValue is the base class of all values for CSS attributes. CSS attributes are usually stored as key/value pairs in AttributeSet-s. Two AttributeSet-s can be compared using the AttributeSet.isEqual() method. In case of CSS attributes this test may fail due to the missing implementation of equals() and hashCode() for class CssValue and its subclasses.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The test should print out "a is equal b".
ACTUAL -
The test prints out "a is NOT equal b".
The two AttributeSet-s a and b in the example should be equal. The test fails as using StyleSheet.addCSSAttribute() wraps the value (i.e. 42) in a new CSS.FontSize instance. Fixing this is important for HTMLWriter!
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.html.CSS;
import javax.swing.text.html.StyleSheet;
public class Test {
public static void main(String[] args) {
StyleSheet ss = new StyleSheet();
String fontSize = "42";
SimpleAttributeSet a = new SimpleAttributeSet();
ss.addCSSAttribute( a, CSS.Attribute.FONT_SIZE, fontSize);
SimpleAttributeSet b = new SimpleAttributeSet();
ss.addCSSAttribute( b, CSS.Attribute.FONT_SIZE, fontSize);
if (a.isEqual( b) ) System.out.println( "a is equal b"); else System.out.println( "a is NOT equal b");
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8305918 SimpleAttributeSet.isEqual may throw NPE instead of returning result
- Open
-
JDK-8318101 Additional test cases for CSSAttributeEqualityBug
- Resolved
-
JDK-8318112 CSS percentage values are capped at 100%
- Resolved
-
JDK-8318113 CSS.BackgroundImage doesn't implement equals
- Resolved
(1 links to)