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"); |
454 |
|
public static final String JAVA_SPECIFICATION_VERSION; |
455 |
|
static { |
456 |
|
try { |
457 |
< |
JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged( |
457 |
> |
@SuppressWarnings("removal") double jcv = |
458 |
> |
java.security.AccessController.doPrivileged( |
459 |
|
new java.security.PrivilegedAction<Double>() { |
460 |
|
public Double run() { |
461 |
|
return Double.valueOf(System.getProperty("java.class.version"));}}); |
462 |
< |
JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged( |
462 |
> |
JAVA_CLASS_VERSION = jcv; |
463 |
> |
@SuppressWarnings("removal") String jsv = |
464 |
> |
java.security.AccessController.doPrivileged( |
465 |
|
new java.security.PrivilegedAction<String>() { |
466 |
|
public String run() { |
467 |
|
return System.getProperty("java.specification.version");}}); |
468 |
+ |
JAVA_SPECIFICATION_VERSION = jsv; |
469 |
|
} catch (Throwable t) { |
470 |
|
throw new Error(t); |
471 |
|
} |
602 |
|
addNamedTestClasses(suite, java9TestClassNames); |
603 |
|
} |
604 |
|
|
605 |
+ |
if (atLeastJava17()) { |
606 |
+ |
String[] java17TestClassNames = { |
607 |
+ |
"ForkJoinPool19Test", |
608 |
+ |
}; |
609 |
+ |
addNamedTestClasses(suite, java17TestClassNames); |
610 |
+ |
} |
611 |
|
return suite; |
612 |
|
} |
613 |
|
|
1066 |
|
void joinPool(ExecutorService pool) { |
1067 |
|
try { |
1068 |
|
pool.shutdown(); |
1069 |
< |
if (!pool.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) { |
1069 |
> |
if (!pool.awaitTermination(20 * LONG_DELAY_MS, MILLISECONDS)) { |
1070 |
|
try { |
1071 |
|
threadFail("ExecutorService " + pool + |
1072 |
|
" did not terminate in a timely manner"); |
1150 |
|
* A debugging tool to print stack traces of most threads, as jstack does. |
1151 |
|
* Uninteresting threads are filtered out. |
1152 |
|
*/ |
1153 |
+ |
@SuppressWarnings("removal") |
1154 |
|
static void dumpTestThreads() { |
1155 |
|
SecurityManager sm = System.getSecurityManager(); |
1156 |
|
if (sm != null) { |
1359 |
|
assertTrue(c.remove(i)); |
1360 |
|
} |
1361 |
|
static void mustNotRemove(Collection<Item> c, int i) { |
1362 |
< |
Item[] items = defaultItems; |
1350 |
< |
Item x = (i >= 0 && i < items.length) ? items[i] : new Item(i); |
1351 |
< |
assertFalse(c.remove(x)); |
1362 |
> |
assertFalse(c.remove(itemFor(i))); |
1363 |
|
} |
1364 |
|
static void mustNotRemove(Collection<Item> c, Item i) { |
1365 |
|
assertFalse(c.remove(i)); |
1384 |
|
* security manager. We require that any security manager permit |
1385 |
|
* getPolicy/setPolicy. |
1386 |
|
*/ |
1387 |
+ |
@SuppressWarnings("removal") |
1388 |
|
public void runWithPermissions(Runnable r, Permission... permissions) { |
1389 |
|
SecurityManager sm = System.getSecurityManager(); |
1390 |
|
if (sm == null) { |
1400 |
|
* Runnable. We require that any security manager permit |
1401 |
|
* getPolicy/setPolicy. |
1402 |
|
*/ |
1403 |
+ |
@SuppressWarnings("removal") |
1404 |
|
public void runWithSecurityManagerWithPermissions(Runnable r, |
1405 |
|
Permission... permissions) { |
1406 |
+ |
if (!useSecurityManager) return; |
1407 |
|
SecurityManager sm = System.getSecurityManager(); |
1408 |
|
if (sm == null) { |
1409 |
|
Policy savedPolicy = Policy.getPolicy(); |
1440 |
|
* A security policy where new permissions can be dynamically added |
1441 |
|
* or all cleared. |
1442 |
|
*/ |
1443 |
+ |
@SuppressWarnings("removal") |
1444 |
|
public static class AdjustablePolicy extends java.security.Policy { |
1445 |
|
Permissions perms = new Permissions(); |
1446 |
|
AdjustablePolicy(Permission... permissions) { |
1470 |
|
/** |
1471 |
|
* Returns a policy containing all the permissions we ever need. |
1472 |
|
*/ |
1473 |
+ |
@SuppressWarnings("removal") |
1474 |
|
public static Policy permissivePolicy() { |
1475 |
|
return new AdjustablePolicy |
1476 |
|
// Permissions j.u.c. needs directly |