Patch: FYI: Toolkit fixlet
Tom Tromey
tromey@redhat.com
Thu Sep 11 16:42:00 GMT 2003
I'm checking this in.
This is a patch from classpath. It adds a required security check to
java.awt.Toolkit.
Tom
Index: ChangeLog
from Sascha Brawer <brawer@dandelis.ch>
* java/awt/Toolkit.java (getSystemEventQueue): Call SecurityManager
if one is installed. Improve Javadoc.
(getSystemEventQueueImpl): Improve Javadoc.
Index: java/awt/Toolkit.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Toolkit.java,v
retrieving revision 1.23
diff -u -r1.23 Toolkit.java
--- java/awt/Toolkit.java 21 Aug 2003 18:39:56 -0000 1.23
+++ java/awt/Toolkit.java 11 Sep 2003 16:40:14 -0000
@@ -803,22 +803,57 @@
return props.getProperty(key, def);
}
+
/**
- * Returns the event queue for the applet. Despite the word "System"
- * in the name of this method, there is no guarantee that the same queue
- * is shared system wide.
+ * Returns the event queue that is suitable for the calling context.
+ *
+ * <p>Despite the word âÂÂSystemâ in the name of this
+ * method, a toolkit may provide different event queues for each
+ * applet. There is no guarantee that the same queue is shared
+ * system-wide.
+ *
+ * <p>The implementation first checks whether a
+ * SecurityManager has been installed. If so, its {@link
+ * java.lang.SecurityManager#checkAwtEventQueueAccess()} method gets
+ * called. The security manager will throw a SecurityException if it
+ * does not grant the permission to access the event queue.
*
- * @return The event queue for this applet (or application)
+ * <p>Next, the call is delegated to {@link
+ * #getSystemEventQueueImpl()}.
+ *
+ * @return The event queue for this applet (or application).
+ *
+ * @throws SecurityException if a security manager has been
+ * installed, and it does not grant the permission to access the
+ * event queue.
*/
public final EventQueue getSystemEventQueue()
{
+ SecurityManager sm;
+
+ sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkAwtEventQueueAccess();
+
return getSystemEventQueueImpl();
}
+
/**
- * // FIXME: What does this do?
+ * Returns the event queue that is suitable for the calling context.
+ *
+ * <p>Despite the word âÂÂ,SystemâÂÂ, in the name of this
+ * method, a toolkit may provide different event queues for each
+ * applet. There is no guarantee that the same queue is shared
+ * system-wide.
+ *
+ * <p>No security checks are performed, which is why this method
+ * may only be called by Toolkits.
+ *
+ * @see #getSystemEventQueue()
*/
protected abstract EventQueue getSystemEventQueueImpl();
+
/**
* @since 1.3
More information about the Java-patches
mailing list