United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6799099 : All automatic regression tests that create Robot fail on X11

Details
Type:
Bug
Submit Date:
2009-01-29
Status:
Closed
Updated Date:
2012-03-22
Project Name:
JDK
Resolved Date:
2009-07-16
Component:
client-libs
OS:
solaris,linux,generic
Sub-Component:
java.awt
CPU:
x86,sparc,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
Any application that creates the java.awt.Robot instance fails with the current JDK 7 build with the fowllowing exception:

java.lang.IllegalArgumentException: button doesn't exist 12
	at java.awt.event.InputEvent.getMaskForButton(InputEvent.java:233)
	at java.awt.Robot.<init>(Robot.java:101)

Almost half of AWT automatic regression tests use the Robot (throught the test.java.awt.regtesthelpers.Util.createRobot() method), and therefore fail, making it impossible to run the automatic tests.

For instance, this is what the test/java/awt/Frame/DynamicLayout/DynamicLayout.java ends up with:

----------System.err:(17/972)----------
java.lang.IllegalArgumentException: button doesn't exist 12
	at java.awt.event.InputEvent.getMaskForButton(InputEvent.java:233)
	at java.awt.Robot.<init>(Robot.java:101)
	at test.java.awt.regtesthelpers.Util.createRobot(Util.java:85)
	at DynamicLayout.init(DynamicLayout.java:90)
	at DynamicLayout.main(DynamicLayout.java:165)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:623)
	at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
	at java.lang.Thread.run(Thread.java:713)

Platforms tested:

Ubuntu 8.10 i586/KDE 
Mandriva Linux 2009/Gnome 2.24

                                    

Comments
EVALUATION

The exception happens on an attempt to get some index from the array of mouse buttons masks. That call comes from the Robot class which tries to get masks for every button.
InputEvent has the private int array (BUTTON_DOWN_MASK) containing these masks. Since it's an int array it may only contain up to 32 values (they are 1<<i numbers). Actually up to 31, since the last one is reserved. 
Moreover, there are about ten reserved values for SHIFT, META and others so we don't fit into 32 bit space with 24 buttons supported by standard X systems. One of the possible ways is to use masks for BUTTON1|2|3 but introduce a method to get mouse button states for extra buttons.
                                     
2009-01-29
SUGGESTED FIX

http://sa.sfbay.sun.com/projects/awt_data/7/6799099.5
                                     
2009-05-22



Hardware and Software, Engineered to Work Together