[commit-cp] classpath javax/swing/text/html/StyleSheet.java...

Pekka Enberg <[email protected]> Mon, 14 Mar 2011 19:35:50 +0000
Newsgroups gmane.comp.java.classpath.cvs
Message-ID <[email protected]>
CVSROOT:	/sources/classpath
Module name:	classpath
Changes by:	Pekka Enberg <penberg>	11/03/14 19:35:50

Modified files:
	javax/swing/text/html: StyleSheet.java 
	.              : ChangeLog 

Log message:
	Fix Use ArrayList.set() in StyleSheet.resolveStyle
	
	The following cleanup patch:
	
	    More warning fixes.
	
	    2009-03-09  Andrew John Hughes  <[email protected]>
	
	[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  <[email protected]>
	
	        * javax/swing/text/html/StyleSheet.java:
	        (resolveStyle()): Fix misuse of ArrayList.set().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/swing/text/html/StyleSheet.java?cvsroot=classpath&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.9820&r2=1.9821