/* SecurityManager.java -- security checks for privileged actions
- Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
import gnu.classpath.VMStackWalker;
import java.awt.AWTPermission;
-import java.awt.Frame;
-import java.awt.Toolkit;
-import java.awt.Window;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
*/
public SecurityManager()
{
+ /* "When there is security manager installed, the security manager
+ need to check the package access. However, if the security
+ manager itself uses any unloaded class, it will trigger the
+ classloading, which causes infinite loop. There is no easy
+ legal solution. The workaround will be that security manager
+ can not depend on any unloaded class. In the constructor of
+ security manager, it must transitively load all classes it
+ refers to." Sun bug #4242924. */
+
+ // Load and initialize java.security.Security
+ java.security.Security.getProvider((String)null);
+
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(new RuntimePermission("createSecurityManager"));
* @return the most recent non-system Class on the execution stack
* @deprecated use {@link #checkPermission(Permission)} instead
*/
- protected Class currentLoadedClass()
+ protected Class<?> currentLoadedClass()
{
int i = classLoaderDepth();
return i >= 0 ? getClassContext()[i] : null;
public void checkAccess(Thread thread)
{
if (thread.getThreadGroup() != null
- && thread.getThreadGroup().getParent() != null)
+ && thread.getThreadGroup().parent == null)
checkPermission(new RuntimePermission("modifyThread"));
}
*/
public void checkAccess(ThreadGroup g)
{
- if (g.getParent() != null)
+ if (g.parent == null)
checkPermission(new RuntimePermission("modifyThreadGroup"));
}
* @param window the window to create
* @return true if there is permission to show the window without warning
* @throws NullPointerException if window is null
- * @see Window#Window(Frame)
+ * @see java.awt.Window#Window(java.awt.Frame)
*/
public boolean checkTopLevelWindow(Object window)
{
* an exception.
*
* @throws SecurityException if permission is denied
- * @see Toolkit#getPrintJob(Frame, String, Properties)
+ * @see java.awt.Toolkit#getPrintJob(java.awt.Frame, String, Properties)
* @since 1.1
*/
public void checkPrintJobAccess()
* rather than throwing an exception.
*
* @throws SecurityException if permission is denied
- * @see Toolkit#getSystemClipboard()
+ * @see java.awt.Toolkit#getSystemClipboard()
* @since 1.1
*/
public void checkSystemClipboardAccess()
* rather than throwing an exception.
*
* @throws SecurityException if permission is denied
- * @see Toolkit#getSystemEventQueue()
+ * @see java.awt.Toolkit#getSystemEventQueue()
* @since 1.1
*/
public void checkAwtEventQueueAccess()
* @see Member#PUBLIC
* @since 1.1
*/
- public void checkMemberAccess(Class c, int memberType)
+ public void checkMemberAccess(Class<?> c, int memberType)
{
if (c == null)
throw new NullPointerException();