From 28789fb0abb54b1d4451516ec459edd71f37a72b Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 14 Mar 2011 19:35:48 +0000 Subject: Fix Use ArrayList.set() in StyleSheet.resolveStyle The following cleanup patch: More warning fixes. 2009-03-09 Andrew John Hughes [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> attributes = new ArrayList>(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.(ViewAttributeSet.java:112) at javax.swing.text.html.StyleSheet.getViewAttributes(StyleSheet.java:562) [snip] Fix that up. 2011-03-14 Pekka Enberg * javax/swing/text/html/StyleSheet.java: (resolveStyle()): Fix misuse of ArrayList.set(). --- javax/swing/text/html/StyleSheet.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'javax') 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(); -- cgit v1.2.1