summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2011-03-14 19:35:48 +0000
committerPekka Enberg <penberg@kernel.org>2011-03-14 19:35:48 +0000
commit28789fb0abb54b1d4451516ec459edd71f37a72b (patch)
treec5cac6caab7c23f95fa17aa46943fe95f9c3c3b3
parentc66bb894bbb5b92fee599155b29d9081567e379a (diff)
downloadclasspath-28789fb0abb54b1d4451516ec459edd71f37a72b.tar.gz
Fix Use ArrayList.set() in StyleSheet.resolveStyle
The following cleanup patch: More warning fixes. 2009-03-09 Andrew John Hughes <ahughes@redhat.com> [snip] * javax/swing/text/html/StyleSheet.java: Add generic typing. changed the code to do ArrayList.set() on an instance thats allocated like this: List<Map<String,String>> attributes = new ArrayList<Map<String,String>>(count); This is, however, broken as ArrayList constructor only ensures capacity but doesn't allow you to set() elements outside of ArrayList.size(). This causes the following exception to happen upon JPC start-up: penberg@jaguar:~/testing/jato$ /usr/local/jamvm/bin/jamvm -jar JPCApplication.jar Exception in thread "main" java.lang.ExceptionInInitializerError at java.lang.VMClass.forName(Native Method) at java.lang.Class.forName(Class.java:233) at jamvm.java.lang.JarLauncher.main(JarLauncher.java:46) Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.raiseBoundsError(ArrayList.java:504) at java.util.ArrayList.checkBoundExclusive(ArrayList.java:490) at java.util.ArrayList.set(ArrayList.java:323) at javax.swing.text.html.StyleSheet.resolveStyle(StyleSheet.java:417) at javax.swing.text.html.StyleSheet.getResolvedStyle(StyleSheet.java:376) at javax.swing.text.html.StyleSheet.getRule(StyleSheet.java:358) at javax.swing.text.html.ViewAttributeSet.<init>(ViewAttributeSet.java:112) at javax.swing.text.html.StyleSheet.getViewAttributes(StyleSheet.java:562) [snip] Fix that up. 2011-03-14 Pekka Enberg <penberg@kernel.org> * javax/swing/text/html/StyleSheet.java: (resolveStyle()): Fix misuse of ArrayList.set().
-rw-r--r--ChangeLog5
-rw-r--r--javax/swing/text/html/StyleSheet.java3
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 823be7929..bc9a41a08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-14 Pekka Enberg <penberg@kernel.org>
+
+ * javax/swing/text/html/StyleSheet.java:
+ (resolveStyle()): Fix misuse of ArrayList.set().
+
2011-02-22 Andrew John Hughes <ahughes@redhat.com>
PR classpath/42390
diff --git a/javax/swing/text/html/StyleSheet.java b/javax/swing/text/html/StyleSheet.java
index 5cf015bc5..31879b2b2 100644
--- a/javax/swing/text/html/StyleSheet.java
+++ b/javax/swing/text/html/StyleSheet.java
@@ -414,11 +414,12 @@ public class StyleSheet extends StyleContext
tags[i] = t.toString();
else
tags[i] = null;
- attributes.set(i, attributeSetToMap(atts));
+ attributes.add(attributeSetToMap(atts));
}
else
{
tags[i] = null;
+ attributes.add(null);
}
}
tags[0] = tag.toString();