-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
11
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at java.desktop/sun.print.Win32PrintService$Win32ServiceUIFactory.getUIClassNamesForRole(Win32PrintService.java:1707) // maps to line 1674
public String[] getUIClassNamesForRole(int role) {
if (role <= ServiceUIFactory.MAIN_UIROLE) {
return null;
}
if (role == DocumentPropertiesUI.DOCUMENTPROPERTIES_ROLE) {
String[] names = new String[0];
names[0] = DocumentPropertiesUI.DOCPROPERTIESCLASSNAME;
return names;
}
throw new IllegalArgumentException("Unsupported role");
}
getUIClassNamesForRole(int role) defines an array "names" of length 0 (String[] names = new String[0]) and sets DocumentPropertiesUI.DOCPROPERTIESCLASSNAME to the non-existing index 0 (names[0] = DocumentPropertiesUI.DOCPROPERTIESCLASSNAME).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
// 1) Include module java.desktop
// 2) Import package javax.print in the test case
// 3) A system printer was set up properly in Windows
PrintService printService = PrinterJob.getPrinterJob().getPrintService();
ServiceUIFactory uiFactory = printService.getServiceUIFactory();
// sun.print.DocumentPropertiesUI.DOCUMENTPROPERTIES_ROLE = 199
String[] uiClassNames = uiFactory.getUIClassNamesForRole (199);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The string array uiClassNames should have a length of 1 containing the string content of sun.print.DocumentPropertiesUI.DOCPROPERTIESCLASSNAME at index 1.
ACTUAL -
Crash with ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
---------- BEGIN SOURCE ----------
// 199 == sun.print.DocumentPropertiesUI.DOCUMENTPROPERTIES_ROLE
javax.print.PrinterJob.getPrinterJob().getPrintService().getServiceUIFactory().getUIClassNamesForRole (199);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround known.
FREQUENCY : always
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at java.desktop/sun.print.Win32PrintService$Win32ServiceUIFactory.getUIClassNamesForRole(Win32PrintService.java:1707) // maps to line 1674
public String[] getUIClassNamesForRole(int role) {
if (role <= ServiceUIFactory.MAIN_UIROLE) {
return null;
}
if (role == DocumentPropertiesUI.DOCUMENTPROPERTIES_ROLE) {
String[] names = new String[0];
names[0] = DocumentPropertiesUI.DOCPROPERTIESCLASSNAME;
return names;
}
throw new IllegalArgumentException("Unsupported role");
}
getUIClassNamesForRole(int role) defines an array "names" of length 0 (String[] names = new String[0]) and sets DocumentPropertiesUI.DOCPROPERTIESCLASSNAME to the non-existing index 0 (names[0] = DocumentPropertiesUI.DOCPROPERTIESCLASSNAME).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
// 1) Include module java.desktop
// 2) Import package javax.print in the test case
// 3) A system printer was set up properly in Windows
PrintService printService = PrinterJob.getPrinterJob().getPrintService();
ServiceUIFactory uiFactory = printService.getServiceUIFactory();
// sun.print.DocumentPropertiesUI.DOCUMENTPROPERTIES_ROLE = 199
String[] uiClassNames = uiFactory.getUIClassNamesForRole (199);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The string array uiClassNames should have a length of 1 containing the string content of sun.print.DocumentPropertiesUI.DOCPROPERTIESCLASSNAME at index 1.
ACTUAL -
Crash with ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
---------- BEGIN SOURCE ----------
// 199 == sun.print.DocumentPropertiesUI.DOCUMENTPROPERTIES_ROLE
javax.print.PrinterJob.getPrinterJob().getPrintService().getServiceUIFactory().getUIClassNamesForRole (199);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround known.
FREQUENCY : always