195 |
|
* </ul> |
196 |
|
*/ |
197 |
|
public class JSR166TestCase extends TestCase { |
198 |
+ |
// No longer run with custom securityManagers |
199 |
|
private static final boolean useSecurityManager = |
200 |
< |
Boolean.getBoolean("jsr166.useSecurityManager"); |
200 |
> |
Boolean.getBoolean("jsr166.useSecurityManager"); |
201 |
|
|
202 |
|
protected static final boolean expensiveTests = |
203 |
|
Boolean.getBoolean("jsr166.expensiveTests"); |
408 |
|
* Runs all unit tests in the given test suite. |
409 |
|
* Actual behavior influenced by jsr166.* system properties. |
410 |
|
*/ |
411 |
+ |
@SuppressWarnings("removal") |
412 |
|
static void main(Test suite, String[] args) { |
413 |
|
if (useSecurityManager) { |
414 |
|
System.err.println("Setting a permissive security manager"); |
415 |
|
Policy.setPolicy(permissivePolicy()); |
416 |
< |
System.setSecurityManager(new SecurityManager()); |
416 |
> |
try { |
417 |
> |
System.setSecurityManager(new SecurityManager()); |
418 |
> |
} catch(Throwable ok) { // failure OK during deprecation |
419 |
> |
} |
420 |
|
} |
421 |
|
for (int i = 0; i < suiteRuns; i++) { |
422 |
|
TestResult result = newPithyTestRunner().doRun(suite); |
457 |
|
public static final String JAVA_SPECIFICATION_VERSION; |
458 |
|
static { |
459 |
|
try { |
460 |
< |
JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged( |
460 |
> |
@SuppressWarnings("removal") double jcv = |
461 |
> |
java.security.AccessController.doPrivileged( |
462 |
|
new java.security.PrivilegedAction<Double>() { |
463 |
|
public Double run() { |
464 |
|
return Double.valueOf(System.getProperty("java.class.version"));}}); |
465 |
< |
JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged( |
465 |
> |
JAVA_CLASS_VERSION = jcv; |
466 |
> |
@SuppressWarnings("removal") String jsv = |
467 |
> |
java.security.AccessController.doPrivileged( |
468 |
|
new java.security.PrivilegedAction<String>() { |
469 |
|
public String run() { |
470 |
|
return System.getProperty("java.specification.version");}}); |
471 |
+ |
JAVA_SPECIFICATION_VERSION = jsv; |
472 |
|
} catch (Throwable t) { |
473 |
|
throw new Error(t); |
474 |
|
} |
605 |
|
addNamedTestClasses(suite, java9TestClassNames); |
606 |
|
} |
607 |
|
|
608 |
+ |
if (atLeastJava17()) { |
609 |
+ |
String[] java17TestClassNames = { |
610 |
+ |
"ForkJoinPool19Test", |
611 |
+ |
}; |
612 |
+ |
addNamedTestClasses(suite, java17TestClassNames); |
613 |
+ |
} |
614 |
|
return suite; |
615 |
|
} |
616 |
|
|
1069 |
|
void joinPool(ExecutorService pool) { |
1070 |
|
try { |
1071 |
|
pool.shutdown(); |
1072 |
< |
if (!pool.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) { |
1072 |
> |
if (!pool.awaitTermination(20 * LONG_DELAY_MS, MILLISECONDS)) { |
1073 |
|
try { |
1074 |
|
threadFail("ExecutorService " + pool + |
1075 |
|
" did not terminate in a timely manner"); |
1153 |
|
* A debugging tool to print stack traces of most threads, as jstack does. |
1154 |
|
* Uninteresting threads are filtered out. |
1155 |
|
*/ |
1156 |
+ |
@SuppressWarnings("removal") |
1157 |
|
static void dumpTestThreads() { |
1158 |
|
SecurityManager sm = System.getSecurityManager(); |
1159 |
|
if (sm != null) { |
1362 |
|
assertTrue(c.remove(i)); |
1363 |
|
} |
1364 |
|
static void mustNotRemove(Collection<Item> c, int i) { |
1365 |
< |
Item[] items = defaultItems; |
1350 |
< |
Item x = (i >= 0 && i < items.length) ? items[i] : new Item(i); |
1351 |
< |
assertFalse(c.remove(x)); |
1365 |
> |
assertFalse(c.remove(itemFor(i))); |
1366 |
|
} |
1367 |
|
static void mustNotRemove(Collection<Item> c, Item i) { |
1368 |
|
assertFalse(c.remove(i)); |
1387 |
|
* security manager. We require that any security manager permit |
1388 |
|
* getPolicy/setPolicy. |
1389 |
|
*/ |
1390 |
+ |
@SuppressWarnings("removal") |
1391 |
|
public void runWithPermissions(Runnable r, Permission... permissions) { |
1392 |
|
SecurityManager sm = System.getSecurityManager(); |
1393 |
|
if (sm == null) { |
1403 |
|
* Runnable. We require that any security manager permit |
1404 |
|
* getPolicy/setPolicy. |
1405 |
|
*/ |
1406 |
+ |
@SuppressWarnings("removal") |
1407 |
|
public void runWithSecurityManagerWithPermissions(Runnable r, |
1408 |
|
Permission... permissions) { |
1409 |
+ |
if (!useSecurityManager) return; |
1410 |
|
SecurityManager sm = System.getSecurityManager(); |
1411 |
|
if (sm == null) { |
1412 |
|
Policy savedPolicy = Policy.getPolicy(); |
1414 |
|
Policy.setPolicy(permissivePolicy()); |
1415 |
|
System.setSecurityManager(new SecurityManager()); |
1416 |
|
runWithSecurityManagerWithPermissions(r, permissions); |
1417 |
+ |
} catch (UnsupportedOperationException ok) { |
1418 |
|
} finally { |
1419 |
< |
System.setSecurityManager(null); |
1420 |
< |
Policy.setPolicy(savedPolicy); |
1419 |
> |
try { |
1420 |
> |
System.setSecurityManager(null); |
1421 |
> |
Policy.setPolicy(savedPolicy); |
1422 |
> |
} catch (Exception ok) { |
1423 |
> |
} |
1424 |
|
} |
1425 |
|
} else { |
1426 |
|
Policy savedPolicy = Policy.getPolicy(); |
1447 |
|
* A security policy where new permissions can be dynamically added |
1448 |
|
* or all cleared. |
1449 |
|
*/ |
1450 |
+ |
@SuppressWarnings("removal") |
1451 |
|
public static class AdjustablePolicy extends java.security.Policy { |
1452 |
|
Permissions perms = new Permissions(); |
1453 |
|
AdjustablePolicy(Permission... permissions) { |
1477 |
|
/** |
1478 |
|
* Returns a policy containing all the permissions we ever need. |
1479 |
|
*/ |
1480 |
+ |
@SuppressWarnings("removal") |
1481 |
|
public static Policy permissivePolicy() { |
1482 |
|
return new AdjustablePolicy |
1483 |
|
// Permissions j.u.c. needs directly |