JDK-6750288 : Regression after 6315717. ArrayIndexOutOfBoundsException.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: generic
  • Submitted: 2008-09-19
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b48Fixed
Related Reports
Relates :  
Description
The last build of jdk workspace is broken by the fix

Support For Mouse With Multiple Scroll Wheels and 4 or More Buttons.

To reproduce the problem you need just to move a mouse pointer over component.

Sep 19, 2008 10:59:47 AM sun.awt.X11.XToolkit processException
WARNING: Exception on Toolkit thread
java.lang.ArrayIndexOutOfBoundsException: 24
       at sun.awt.X11.XWindow.handleMotionNotify(XWindow.java:776)
       at sun.awt.X11.XBaseWindow.dispatchEvent(XBaseWindow.java:1083)
       at sun.awt.X11.XBaseWindow.dispatchToWindow(XBaseWindow.java:1053)
       at sun.awt.X11.XToolkit.dispatchEvent(XToolkit.java:511)
       at sun.awt.X11.XToolkit.run(XToolkit.java:606)
       at sun.awt.X11.XToolkit.run(XToolkit.java:541)
       at java.lang.Thread.run(Thread.java:674)

Comments
SUGGESTED FIX Actual patch is right there: http://sa.sfbay.sun.com/projects/awt_data/7/6750288/
07-10-2008

SUGGESTED FIX Even less intrusive approach is to get minimum of 24 and the number obtained from the system. This change would look as follows. --- old/src/solaris/classes/sun/awt/X11/XToolkit.java 2008-10-03 18:18:56.000000000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XToolkit.java 2008-10-03 18:18:55.000000000 +0400 @@ -78,6 +78,12 @@ //Set to true by default. private static boolean areExtraMouseButtonsEnabled = true; + /* XFree standard mention 24 buttons as maximum: + * http://www.xfree86.org/current/mouse.4.html + * We workaround systems supporting more than 24 buttons. + */ + private static int MAX_BUTTONS_SUPPORT = 24; + /** * True when the x settings have been loaded. */ @@ -1393,7 +1399,8 @@ public static int getNumMouseButtons() { awtLock(); try { - return XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0); + int systemValue = XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0); + return Math.min(systemValue, MAX_BUTTONS_SUPPORT); } finally { awtUnlock(); }
03-10-2008

EVALUATION Introducing a wider field for mouse modifiers will also affect shared code including specification at least for the following methods: - InputEvent.getMaskForButton(int button) - MouseEvent.getButton() - MouseEvent.Constructor(..., int button) - Robot.mousePress(int button) - Robot.mouseRelease(int button)
22-09-2008

EVALUATION There are seem no other ways except to expand the width of the button's set.
19-09-2008

SUGGESTED FIX --- old/src/solaris/classes/sun/awt/X11/XConstants.java 2008-09-19 18:17:18.000000000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XConstants.java 2008-09-19 18:17:17.000000000 +0400 @@ -197,7 +197,7 @@ /* button masks. Used in same manner as Key masks above. Not to be confused with button names below. */ - public static final int [] buttonsMask = new int []{ 1<<8, + public static final long [] buttonsMask = new long []{ 1<<8, 1<<9, 1<<10, 1<<11, @@ -220,7 +220,16 @@ 1<<28, 1<<29, 1<<30, - 1<<31 }; + 1<<31, + 1<<32, + 1<<33, + 1<<34, + 1<<35, + 1<<36, + 1<<37, + 1<<38, + 1<<39 + }; public static final int AnyModifier = (1<<15) ; /* used in GrabButton, GrabKey */ @@ -229,7 +238,7 @@ and ButtonRelease events. Not to be confused with button masks above. Note that 0 is already defined above as "AnyButton". */ - public static final int buttons [] = new int [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}; + public static final int buttons [] = new int [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}; /* Notify modes */ --- old/src/solaris/classes/sun/awt/X11/XWindow.java 2008-09-19 18:17:19.000000000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XWindow.java 2008-09-19 18:17:18.000000000 +0400 @@ -764,8 +764,7 @@ return; } - int mouseKeyState = 0; //(xme.get_state() & (XConstants.buttonsMask[0] | XConstants.buttonsMask[1] | XConstants.buttonsMask[2])); - + long mouseKeyState = 0; //this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event. // we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE) // should be passed from XWindow.
19-09-2008

EVALUATION It appears that the system showing this failure has 32 buttons on the attached mouse. There is nothing strange with the configuration of the system, but by some reason it detected all these buttons and still don't want to take the option from xorg.conf into consideration.
19-09-2008

EVALUATION Downgrading mercurial revision completely elimenates the problem.
19-09-2008