United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4722616 : ArrayIndexOutOfBoundsException when printing with a Card Printer

Details
Type:
Bug
Submit Date:
2002-07-30
Status:
Resolved
Updated Date:
2002-10-16
Project Name:
JDK
Resolved Date:
2002-10-16
Component:
client-libs
OS:
windows_2000
Sub-Component:
2d
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.2 (mantis)

Related Reports

Sub Tasks

Description

Name: jk109818			Date: 07/29/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :

Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
I am trying to write a program that will perform
silent printing to a card printer.  Everything seems
to work when printing to another printer that we have but
nothing seems to happen when the program prints
to the card printer.  I tried playing around and
noticed that an exception gets thrown when
trying to get default values from the printer.

printer driver url:
http://www.eltroncards.com/drivers/downloads/winnt/p420_wnt_
0206.exe

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.ArrayIndexOutOfBoundsException
	at sun.print.Win32PrintService.getDefaultAttributeValue
(Win32PrintService.java:786)
	at sun.print.Win32PrintService.getSupportedAttributeValues
(Win32PrintService.java:1049)


This bug can be reproduced always.

---------- BEGIN SOURCE ----------


import javax.print.*;
import javax.print.event.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;

public class test {

  public test() {
                PrintService printer =
PrintServiceLookup.lookupDefaultPrintService();
              Class[] categories = printer.getSupportedAttributeCategories();

		for (int i=0; i<categories.length; i++)
		{
			System.out.print("Class "+categories[i]);
			System.out.print(' ');
			Object value = printer.getSupportedAttributeValues
(categories[i], null, null);
			if (value.getClass().isArray())
			{
				Object[] v = (Object[])value;
				for (int j=0; j<v.length; j++)
				{
					if (j > 0)
						System.out.print(", ");
					System.out.print(v[j]);
				}
			}
			else
				System.out.print(value);
			System.out.println();
		}


  }
  public static void main(String[] args) {
    test test1 = new test();
  }
}
---------- END SOURCE ----------
(Review ID: 145232) 
======================================================================

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mantis

FIXED IN:
mantis

INTEGRATED IN:
mantis
mantis-b04


                                     
2004-06-14
EVALUATION

Looks like we are accessing an array with 0 size.  To avoid this exception, we need to check for mediasizenames.length > 0. 

###@###.### 2002-07-29

No longer reproducible with the recent fix for 4701198 but length still needs to be checked.

###@###.### 2002-09-04
=================================

Fix: Added check for length = 0.

###@###.### 2002-09-16
====================================
                                     
2002-09-04



Hardware and Software, Engineered to Work Together