Project: SWT
Bug 122496 java.lang.ArrayIndexOutOfBoundsException in StyledTextRenderer.setStyleRanges
Reported: 2006-01-03 05:01:35 | Status: resolved fixed

I found the Bug, because i looking for a printing problem in the Plugin "Eclipse Colorer". Then the function setStyleRanges is called from StyledText$Printing.cacheLineData(StyledText.java:262) and newStyles can be a empty array. Is newStyles a empty array ArrayIndexOutOfBoundsException is throw. old: void setStyleRanges (int[] newRanges, StyleRange[] newStyles) { if (newStyles == null) { stylesSetCount = styleCount = 0; must be: void setStyleRanges (int[] newRanges, StyleRange[] newStyles) { if (newStyles == null || newStyles.length == 0) { Stacktrace: java.lang.ArrayIndexOutOfBoundsException: 0 at org.eclipse.swt.custom.StyledTextRenderer.setStyleRanges(StyledTextRenderer.java:959) at org.eclipse.swt.custom.StyledText$Printing.cacheLineData(StyledText.java:262) at org.eclipse.swt.custom.StyledText$Printing.<init>(StyledText.java:228) at org.eclipse.swt.custom.StyledText.print(StyledText.java:5886)

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java