United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7080109 Dialog.show() lacks doPrivileged() to access system event queue
7080109 : Dialog.show() lacks doPrivileged() to access system event queue

Details
Type:
Bug
Submit Date:
2011-08-17
Status:
Closed
Updated Date:
2012-06-18
Project Name:
JDK
Resolved Date:
2012-06-18
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
8

Related Reports
Backport:
Relates:

Sub Tasks

Description
The following block in Dialog.show():

    try {
        EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
        secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
        if (!secondaryLoop.enter()) {
            secondaryLoop = null;
        }
    } finally {
        modalityPopped();
    }

should be wrapped to a doPrivileged() block as getSystemEventQueue() is protected with a permission:

Exception in thread "AWT-EventQueue-1"
java.security.AccessControlException: access denied
("java.awt.AWTPermission" "accessEventQueue")
	at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
	at
java.security.AccessController.checkPermission(AccessController.java:555)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at
java.lang.SecurityManager.checkAwtEventQueueAccess(SecurityManager.java:1415)
	at java.awt.Toolkit.getSystemEventQueue(Toolkit.java:1730)
	at java.awt.Dialog.show(Dialog.java:1070)
	at javax.swing.ColorChooserDialog.show(JColorChooser.java:720)
	at ColorChooserDemo$1.actionPerformed(ColorChooserDemo.java:131)
	at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
	at javax.swing.AbstractButton
$Handler.actionPerformed(AbstractButton.java:2341)
	at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
	at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
	at java.awt.Component.processMouseEvent(Component.java:6503)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
	at java.awt.Component.processEvent(Component.java:6268)
	at java.awt.Container.processEvent(Container.java:2213)
	at java.awt.Component.dispatchEventImpl(Component.java:4859)
	at java.awt.Container.dispatchEventImpl(Container.java:2271)
	at java.awt.Component.dispatchEvent(Component.java:4685)
	at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4816)
	at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4476)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4406)
	at java.awt.Container.dispatchEventImpl(Container.java:2257)
	at java.awt.Window.dispatchEventImpl(Window.java:2713)
	at java.awt.Component.dispatchEvent(Component.java:4685)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
	at java.awt.EventQueue.access$000(EventQueue.java:101)
	at java.awt.EventQueue$3.run(EventQueue.java:666)
	at java.awt.EventQueue$3.run(EventQueue.java:664)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain
$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain
$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:680)
	at java.awt.EventQueue$4.run(EventQueue.java:678)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain
$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
	at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
	at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
test/java/awt/Dialog/ModalDialogPermission/ModalDialogPermission.java 
still failed on Mac OS X 10.7.4. the please see the attachment for the .jtr file.

It is not sure if this failure is due to another bug or the fix introduced in jdk 8 b40 is not good.
Test failed because of another bug http://monaco.us.oracle.com/detail.jsf?cr=7171776.

                                    

Comments
SUGGESTED FIX

http://cr.openjdk.java.net/~serb/7080109/webrev.01/
                                     
2012-04-16
EVALUATION

doPrivileged() should be added
                                     
2012-03-30



Hardware and Software, Engineered to Work Together