Submitted by: DJ Lucas (dj_AT_linuxfromscratch_DOT_org) Date: 2018-08-26 Initial Package Version: 4.12 Upstream Status: Applied Origin: https://github.com/junit-team/junit4/pull/1529 Description: Removes deprecated Overides diff -Naurp junit4-r4.12-orig/src/test/java/org/junit/tests/running/core/MainRunner.java junit4-r4.12/src/test/java/org/junit/tests/running/core/MainRunner.java --- junit4-r4.12-orig/src/test/java/org/junit/tests/running/core/MainRunner.java 2014-12-04 10:13:56.000000000 -0600 +++ junit4-r4.12/src/test/java/org/junit/tests/running/core/MainRunner.java 2018-08-25 23:23:19.916677565 -0500 @@ -1,9 +1,7 @@ package org.junit.tests.running.core; import java.io.ByteArrayOutputStream; -import java.io.FileDescriptor; import java.io.PrintStream; -import java.net.InetAddress; import java.security.Permission; public class MainRunner { @@ -24,15 +22,9 @@ public class MainRunner { /** * A {@code NoExitSecurityManager} throws a {@link ExitException} exception - * whenever {@link #checkExit(int)} is called. All other method calls are - * delegated to the original security manager. + * whenever {@link #checkExit(int)} is called; all other permissions are allowed. */ public class NoExitSecurityManager extends SecurityManager { - private final SecurityManager originalSecurityManager; - - public NoExitSecurityManager(SecurityManager originalSecurityManager) { - this.originalSecurityManager = originalSecurityManager; - } @Override public void checkExit(int status) { @@ -40,227 +32,12 @@ public class MainRunner { } @Override - public boolean getInCheck() { - return (originalSecurityManager != null) && originalSecurityManager.getInCheck(); - } - - @Override - public Object getSecurityContext() { - return (originalSecurityManager == null) ? super.getSecurityContext() : originalSecurityManager.getSecurityContext(); - } - - @Override public void checkPermission(Permission perm) { - if (originalSecurityManager != null) { - originalSecurityManager.checkPermission(perm); - } - } - - @Override - public void checkPermission(Permission perm, Object context) { - if (originalSecurityManager != null) { - originalSecurityManager.checkPermission(perm, context); - } - } - - @Override - public void checkCreateClassLoader() { - if (originalSecurityManager != null) { - originalSecurityManager.checkCreateClassLoader(); - } - } - - @Override - public void checkAccess(Thread t) { - if (originalSecurityManager != null) { - originalSecurityManager.checkAccess(t); - } - } - - @Override - public void checkAccess(ThreadGroup g) { - if (originalSecurityManager != null) { - originalSecurityManager.checkAccess(g); - } - } - - @Override - public void checkExec(String cmd) { - if (originalSecurityManager != null) { - originalSecurityManager.checkExec(cmd); - } - } - - @Override - public void checkLink(String lib) { - if (originalSecurityManager != null) { - originalSecurityManager.checkLink(lib); + if (perm.getName().startsWith("exitVM")) { + super.checkPermission(perm); } } - @Override - public void checkRead(FileDescriptor fd) { - if (originalSecurityManager != null) { - originalSecurityManager.checkRead(fd); - } - } - - @Override - public void checkRead(String file) { - if (originalSecurityManager != null) { - originalSecurityManager.checkRead(file); - } - } - - @Override - public void checkRead(String file, Object context) { - if (originalSecurityManager != null) { - originalSecurityManager.checkRead(file, context); - } - } - - @Override - public void checkWrite(FileDescriptor fd) { - if (originalSecurityManager != null) { - originalSecurityManager.checkWrite(fd); - } - } - - @Override - public void checkWrite(String file) { - if (originalSecurityManager != null) { - originalSecurityManager.checkWrite(file); - } - } - - @Override - public void checkDelete(String file) { - if (originalSecurityManager != null) { - originalSecurityManager.checkDelete(file); - } - } - - @Override - public void checkConnect(String host, int port) { - if (originalSecurityManager != null) { - originalSecurityManager.checkConnect(host, port); - } - } - - @Override - public void checkConnect(String host, int port, Object context) { - if (originalSecurityManager != null) { - originalSecurityManager.checkConnect(host, port, context); - } - } - - @Override - public void checkListen(int port) { - if (originalSecurityManager != null) { - originalSecurityManager.checkListen(port); - } - } - - @Override - public void checkAccept(String host, int port) { - if (originalSecurityManager != null) { - originalSecurityManager.checkAccept(host, port); - } - } - - @Override - public void checkMulticast(InetAddress maddr) { - if (originalSecurityManager != null) { - originalSecurityManager.checkMulticast(maddr); - } - } - - @Override - public void checkMulticast(InetAddress maddr, byte ttl) { - if (originalSecurityManager != null) { - originalSecurityManager.checkMulticast(maddr, ttl); - } - } - - @Override - public void checkPropertiesAccess() { - if (originalSecurityManager != null) { - originalSecurityManager.checkPropertiesAccess(); - } - } - - @Override - public void checkPropertyAccess(String key) { - if (originalSecurityManager != null) { - originalSecurityManager.checkPropertyAccess(key); - } - } - - @Override - public boolean checkTopLevelWindow(Object window) { - return (originalSecurityManager == null) ? super.checkTopLevelWindow(window) : originalSecurityManager.checkTopLevelWindow(window); - } - - @Override - public void checkPrintJobAccess() { - if (originalSecurityManager != null) { - originalSecurityManager.checkPrintJobAccess(); - } - } - - @Override - public void checkSystemClipboardAccess() { - if (originalSecurityManager != null) { - originalSecurityManager.checkSystemClipboardAccess(); - } - } - - @Override - public void checkAwtEventQueueAccess() { - if (originalSecurityManager != null) { - originalSecurityManager.checkAwtEventQueueAccess(); - } - } - - @Override - public void checkPackageAccess(String pkg) { - if (originalSecurityManager != null) { - originalSecurityManager.checkPackageAccess(pkg); - } - } - - @Override - public void checkPackageDefinition(String pkg) { - if (originalSecurityManager != null) { - originalSecurityManager.checkPackageDefinition(pkg); - } - } - - @Override - public void checkSetFactory() { - if (originalSecurityManager != null) { - originalSecurityManager.checkSetFactory(); - } - } - - @Override - public void checkMemberAccess(Class clazz, int which) { - if (originalSecurityManager != null) { - originalSecurityManager.checkMemberAccess(clazz, which); - } - } - - @Override - public void checkSecurityAccess(String target) { - if (originalSecurityManager != null) { - originalSecurityManager.checkSecurityAccess(target); - } - } - - @Override - public ThreadGroup getThreadGroup() { - return (originalSecurityManager == null) ? super.getThreadGroup() : originalSecurityManager.getThreadGroup(); - } } /** @@ -272,7 +49,7 @@ public class MainRunner { */ public Integer runWithCheckForSystemExit(Runnable runnable) { SecurityManager oldSecurityManager = System.getSecurityManager(); - System.setSecurityManager(new NoExitSecurityManager(oldSecurityManager)); + System.setSecurityManager(new NoExitSecurityManager()); PrintStream oldOut = System.out; System.setOut(new PrintStream(new ByteArrayOutputStream()));