From: <ls...@us...> - 2007-10-11 20:12:49
|
Revision: 3544 http://jnode.svn.sourceforge.net/jnode/?rev=3544&view=rev Author: lsantha Date: 2007-10-11 13:12:46 -0700 (Thu, 11 Oct 2007) Log Message: ----------- Tidy up usage of java.security.PrivilegedAction by crawley. Modified Paths: -------------- trunk/core/src/classpath/vm/gnu/java/security/action/GetBooleanAction.java trunk/core/src/classpath/vm/gnu/java/security/action/GetIntegerAction.java trunk/core/src/classpath/vm/gnu/java/security/action/GetPolicyAction.java trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java trunk/core/src/classpath/vm/gnu/java/security/action/InvokeAction.java trunk/core/src/classpath/vm/gnu/java/security/action/SetPropertyAction.java trunk/core/src/classpath/vm/java/lang/Class.java trunk/core/src/classpath/vm/java/lang/ClassLoader.java trunk/core/src/core/org/jnode/debugger/Debugger.java trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java trunk/gui/src/awt/org/jnode/awt/KeyboardHandler.java trunk/gui/src/driver/org/jnode/driver/console/swing/SwingTextScreenConsoleManager.java trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonCore.java trunk/gui/src/test/org/jnode/test/gui/ConsoleTest.java trunk/gui/src/test/org/jnode/test/gui/Editor.java trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/CommandShell.java trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/ProcletCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/help/argument/FileArgument.java trunk/shell/src/shell/org/jnode/shell/help/argument/ThreadNameArgument.java Modified: trunk/core/src/classpath/vm/gnu/java/security/action/GetBooleanAction.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/security/action/GetBooleanAction.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/classpath/vm/gnu/java/security/action/GetBooleanAction.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -29,7 +29,7 @@ * @see Boolean#getBoolean(String) * @author Ewout Prangsma (ep...@us...) */ -public class GetBooleanAction implements PrivilegedAction { +public class GetBooleanAction implements PrivilegedAction<Boolean> { private final String key; @@ -40,7 +40,7 @@ /** * @see java.security.PrivilegedAction#run() */ - public Object run() { + public Boolean run() { return Boolean.valueOf(Boolean.getBoolean(key)); } } Modified: trunk/core/src/classpath/vm/gnu/java/security/action/GetIntegerAction.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/security/action/GetIntegerAction.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/classpath/vm/gnu/java/security/action/GetIntegerAction.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -30,7 +30,7 @@ * @see Integer#getInteger(String, Integer) * @author Ewout Prangsma (ep...@us...) */ -public class GetIntegerAction implements PrivilegedAction { +public class GetIntegerAction implements PrivilegedAction<Integer> { private final String key; private final Integer defaultValue; @@ -51,7 +51,7 @@ /** * @see java.security.PrivilegedAction#run() */ - public Object run() { + public Integer run() { return Integer.getInteger(key, defaultValue); } } Modified: trunk/core/src/classpath/vm/gnu/java/security/action/GetPolicyAction.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/security/action/GetPolicyAction.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/classpath/vm/gnu/java/security/action/GetPolicyAction.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -30,7 +30,7 @@ * @see java.security.Policy * @author Ewout Prangsma (ep...@us...) */ -public class GetPolicyAction implements PrivilegedAction { +public class GetPolicyAction implements PrivilegedAction<Policy> { private static final GetPolicyAction instance = new GetPolicyAction(); @@ -45,7 +45,7 @@ /** * @see java.security.PrivilegedAction#run() */ - public Object run() { + public Policy run() { return Policy.getPolicy(); } Modified: trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/classpath/vm/gnu/java/security/action/GetPropertiesAction.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -22,6 +22,7 @@ package gnu.java.security.action; import java.security.PrivilegedAction; +import java.util.Properties; /** @@ -29,12 +30,12 @@ * * @author Ewout Prangsma (ep...@us...) */ -public class GetPropertiesAction implements PrivilegedAction { +public class GetPropertiesAction implements PrivilegedAction<Properties> { /** * @see java.security.PrivilegedAction#run() */ - public Object run() { + public Properties run() { return System.getProperties(); } } Modified: trunk/core/src/classpath/vm/gnu/java/security/action/InvokeAction.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/security/action/InvokeAction.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/classpath/vm/gnu/java/security/action/InvokeAction.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -31,7 +31,7 @@ * * @author Ewout Prangsma (ep...@us...) */ -public class InvokeAction implements PrivilegedExceptionAction { +public class InvokeAction implements PrivilegedExceptionAction<Object> { private final Method method; private final Object object; Modified: trunk/core/src/classpath/vm/gnu/java/security/action/SetPropertyAction.java =================================================================== --- trunk/core/src/classpath/vm/gnu/java/security/action/SetPropertyAction.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/classpath/vm/gnu/java/security/action/SetPropertyAction.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -29,7 +29,7 @@ * * @author Ewout Prangsma (ep...@us...) */ -public class SetPropertyAction implements PrivilegedAction { +public class SetPropertyAction implements PrivilegedAction<Void> { private final String key; private final String value; @@ -47,7 +47,7 @@ * Set the property * @see java.security.PrivilegedAction#run() */ - public Object run() { + public Void run() { System.setProperty(key, value); return null; } Modified: trunk/core/src/classpath/vm/java/lang/Class.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/Class.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/classpath/vm/java/lang/Class.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -1424,8 +1424,8 @@ try { final Method values = getMethod("values"); java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction() { - public Object run() { + (new java.security.PrivilegedAction<Void>() { + public Void run() { values.setAccessible(true); return null; } Modified: trunk/core/src/classpath/vm/java/lang/ClassLoader.java =================================================================== --- trunk/core/src/classpath/vm/java/lang/ClassLoader.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/classpath/vm/java/lang/ClassLoader.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -133,9 +133,9 @@ static final ProtectionDomain defaultProtectionDomain; static { final CodeSource cs = new CodeSource(null, null); - PermissionCollection perm = (PermissionCollection) AccessController - .doPrivileged(new PrivilegedAction() { - public Object run() { + PermissionCollection perm = AccessController + .doPrivileged(new PrivilegedAction<PermissionCollection>() { + public PermissionCollection run() { return Policy.getPolicy().getPermissions(cs); } }); @@ -406,10 +406,10 @@ } if (protDomain == null) { - protDomain = (ProtectionDomain) AccessController - .doPrivileged(new PrivilegedAction() { + protDomain = AccessController + .doPrivileged(new PrivilegedAction<ProtectionDomain>() { - public Object run() { + public ProtectionDomain run() { return getDefaultProtectionDomain(); } }); @@ -434,10 +434,9 @@ throw new NullPointerException(); } if (protDomain == null) { - protDomain = (ProtectionDomain) AccessController - .doPrivileged(new PrivilegedAction() { - - public Object run() { + protDomain = AccessController.doPrivileged( + new PrivilegedAction<ProtectionDomain>() { + public ProtectionDomain run() { return getDefaultProtectionDomain(); } }); Modified: trunk/core/src/core/org/jnode/debugger/Debugger.java =================================================================== --- trunk/core/src/core/org/jnode/debugger/Debugger.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/core/src/core/org/jnode/debugger/Debugger.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -42,7 +42,7 @@ * @author Ewout Prangsma (ep...@us...) */ public class Debugger implements SystemTriggerListener, KeyboardListener, - PrivilegedAction { + PrivilegedAction<Void> { private boolean enabled; @@ -93,7 +93,7 @@ * * @see java.security.PrivilegedAction#run() */ - public Object run() { + public Void run() { final PrintStream out = VmSystem.getOut(); DebugState st = this.state; @@ -143,7 +143,7 @@ private void setPreferredListener() { final KeyboardListener l = this; - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { try { Modified: trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -492,9 +492,9 @@ */ public Image getImage(final String filename) { log.debug("getImage(" + filename + ")"); - return testErrorImage((Image) AccessController.doPrivileged(new PrivilegedAction() { + return testErrorImage(AccessController.doPrivileged(new PrivilegedAction<Image>() { - public Object run() { + public Image run() { try { final String userDir = (String) AccessController.doPrivileged( new GetPropertyAction("user.dir")); @@ -514,8 +514,8 @@ * @see java.awt.Toolkit#getImage(java.net.URL) */ public Image getImage(final URL url) { - return testErrorImage((Image) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return testErrorImage(AccessController.doPrivileged(new PrivilegedAction<Image>() { + public Image run() { try { return ImageIO.read(url); } catch (Exception ex) { @@ -663,8 +663,8 @@ screenSize, eventQueue, keyboardHandler); keyboardHandler.install(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { onInitialize(); return null; } Modified: trunk/gui/src/awt/org/jnode/awt/KeyboardHandler.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/KeyboardHandler.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/gui/src/awt/org/jnode/awt/KeyboardHandler.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -70,8 +70,8 @@ keyboardAPI = (KeyboardAPI) keyboardDevice .getAPI(KeyboardAPI.class); keyboardAPI.addKeyboardListener(this); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { keyboardAPI.setPreferredListener(KeyboardHandler.this); return null; } @@ -147,8 +147,8 @@ if (key_code == KeyEvent.VK_F12 && event.isAltDown() || key_code == KeyEvent.VK_BACK_SPACE && event.isAltDown() && event.isControlDown()) { event.consume(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { JNodeToolkit.stopGui(); return null; } @@ -156,8 +156,8 @@ return true; } else if (key_code == KeyEvent.VK_F11 && event.isAltDown()) { event.consume(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { JNodeToolkit.getJNodeToolkit().leaveGUI(); return null; } @@ -165,8 +165,8 @@ return true; } else if (key_code == KeyEvent.VK_F5 && event.isControlDown() && event.isAltDown()) { event.consume(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { JNodeToolkit.refreshGui(); return null; } @@ -196,8 +196,8 @@ * Install this handler as current keyboard focus manager. */ public void install() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { //setCurrentKeyboardFocusManager(KeyboardHandler.this); return null; } @@ -208,8 +208,8 @@ * Uninstall this handler as current keyboard focus manager. */ public void uninstall() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { //setCurrentKeyboardFocusManager(null); return null; } Modified: trunk/gui/src/driver/org/jnode/driver/console/swing/SwingTextScreenConsoleManager.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/console/swing/SwingTextScreenConsoleManager.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/gui/src/driver/org/jnode/driver/console/swing/SwingTextScreenConsoleManager.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -28,8 +28,8 @@ } protected void openInput(DeviceManager devMan) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { SwingPcTextScreen systemScreen = getTextScreenManager().getSystemScreen(); final JComponent screen = systemScreen.getScreenComponent(); initializeKeyboard(systemScreen.getKeyboardDevice()); Modified: trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonCore.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonCore.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/gui/src/driver/org/jnode/driver/video/ati/radeon/RadeonCore.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -393,10 +393,10 @@ */ private final MemoryResource findRom(final ResourceOwner owner, final ResourceManager rm) throws ResourceNotFreeException { - final MemoryScanner scanner = (MemoryScanner) AccessController - .doPrivileged(new PrivilegedAction() { + final MemoryScanner scanner = AccessController + .doPrivileged(new PrivilegedAction<MemoryScanner>() { - public Object run() { + public MemoryScanner run() { return rm.getMemoryScanner(); } }); Modified: trunk/gui/src/test/org/jnode/test/gui/ConsoleTest.java =================================================================== --- trunk/gui/src/test/org/jnode/test/gui/ConsoleTest.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/gui/src/test/org/jnode/test/gui/ConsoleTest.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -55,8 +55,8 @@ private void claimPrintStreams() { System.out.println( "Claiming print streams." ); - AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged( new PrivilegedAction<Void>() { + public Void run() { System.setOut( savedOut ); System.setErr( savedOut ); return null; Modified: trunk/gui/src/test/org/jnode/test/gui/Editor.java =================================================================== --- trunk/gui/src/test/org/jnode/test/gui/Editor.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/gui/src/test/org/jnode/test/gui/Editor.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -161,8 +161,8 @@ } private void readFile(final File file) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { try { FileInputStream fis = new FileInputStream(file); byte[] data = new byte[fis.available()]; @@ -189,8 +189,8 @@ } private void writeFile(final File file) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { try { FileWriter fw = new FileWriter(file); fw.write(textArea.getText()); Modified: trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -255,8 +255,8 @@ if (threadProcess != null) { unblock(); - AccessController.doPrivileged(new PrivilegedAction(){ - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>(){ + public Void run() { threadProcess.stop(new ThreadDeath()); return null; }}); Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -243,8 +243,8 @@ } final String user_home = (String) AccessController.doPrivileged(new GetPropertyAction("user.home", "")); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { try { final File shell_ini = new File(user_home + "/shell.ini"); if(shell_ini.exists()) Modified: trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -65,8 +65,8 @@ try { // System.err.println("Invoking..."); try { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { System.setOut(commandShell.getOutputStream()); System.setErr(commandShell.getErrorStream()); System.setIn(commandShell.getInputStream()); Modified: trunk/shell/src/shell/org/jnode/shell/ProcletCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ProcletCommandInvoker.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/shell/src/shell/org/jnode/shell/ProcletCommandInvoker.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -93,8 +93,8 @@ public void run() { try { try { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { System.setOut(commandOut); System.setErr(commandErr); System.setIn(commandIn); Modified: trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/shell/src/shell/org/jnode/shell/ThreadCommandInvoker.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -88,8 +88,8 @@ try { try { // - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { System.setOut(commandOut); System.setErr(commandErr); System.setIn(commandIn); Modified: trunk/shell/src/shell/org/jnode/shell/help/argument/FileArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/argument/FileArgument.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/shell/src/shell/org/jnode/shell/help/argument/FileArgument.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -91,10 +91,9 @@ // Find the final File f = new File(dir); - final String[] names = (String[]) AccessController - .doPrivileged(new PrivilegedAction() { - - public Object run() { + final String[] names = AccessController + .doPrivileged(new PrivilegedAction <String[]>() { + public String[] run() { if (!f.exists()) { return null; } else { Modified: trunk/shell/src/shell/org/jnode/shell/help/argument/ThreadNameArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/argument/ThreadNameArgument.java 2007-10-11 09:16:06 UTC (rev 3543) +++ trunk/shell/src/shell/org/jnode/shell/help/argument/ThreadNameArgument.java 2007-10-11 20:12:46 UTC (rev 3544) @@ -48,8 +48,8 @@ } final ThreadGroup grp_f = grp; - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { findList(grp_f, partial, names); return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |