<AWT Dev> Missing doPrivileged() in Dialog.show()

Artem Ananiev artem.ananiev at oracle.com
Wed Aug 17 01:51:46 PDT 2011


Hi, Roman,

it really looks like a bug. I will file it shortly.

Thanks,

Artem

On 8/16/2011 11:52 PM, Roman Kennke wrote:
> Hi all,
>
> when running an app with security manager (I am talking about the
> ubercool Cacio-Web project [1]), I get the attached exception when
> trying to open a modal dialog. I am wondering if the following code in
> Dialog.show() shouldn't be wrapped in a doPrivileged() to enable the
> secondary event loop:
>
>                      try {
>                          EventQueue eventQueue =
> Toolkit.getDefaultToolkit().getSystemEventQueue();
>                          secondaryLoop =
> eventQueue.createSecondaryLoop(cond, modalFilter, 0);
>                          if (!secondaryLoop.enter()) {
>                              secondaryLoop = null;
>                          }
>                      } finally {
>                          modalityPopped();
>                      }
>
>
> That is because getSystemEventQueue() is protected by the security
> manager, and we probably don't want to bother calling code with this
> implementation detail.
>
>
> Any thoughts?
>
> [1] http://jroller.com/neugens/entry/java_on_ipad_part_ii
>
>
>
> 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)
>
>



More information about the awt-dev mailing list