160 |
|
} |
161 |
|
|
162 |
|
protected void runTestProfiled() throws Throwable { |
163 |
+ |
// Warmup run, notably to trigger all needed classloading. |
164 |
+ |
super.runTest(); |
165 |
|
long t0 = System.nanoTime(); |
166 |
|
try { |
167 |
|
super.runTest(); |
168 |
|
} finally { |
169 |
< |
long elapsedMillis = |
168 |
< |
(System.nanoTime() - t0) / (1000L * 1000L); |
169 |
> |
long elapsedMillis = millisElapsedSince(t0); |
170 |
|
if (elapsedMillis >= profileThreshold) |
171 |
|
System.out.printf("%n%s: %d%n", toString(), elapsedMillis); |
172 |
|
} |
222 |
|
} |
223 |
|
|
224 |
|
public static final double JAVA_CLASS_VERSION; |
225 |
+ |
public static final String JAVA_SPECIFICATION_VERSION; |
226 |
|
static { |
227 |
|
try { |
228 |
|
JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged( |
229 |
|
new java.security.PrivilegedAction<Double>() { |
230 |
|
public Double run() { |
231 |
|
return Double.valueOf(System.getProperty("java.class.version"));}}); |
232 |
+ |
JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged( |
233 |
+ |
new java.security.PrivilegedAction<String>() { |
234 |
+ |
public String run() { |
235 |
+ |
return System.getProperty("java.specification.version");}}); |
236 |
|
} catch (Throwable t) { |
237 |
|
throw new Error(t); |
238 |
|
} |
241 |
|
public static boolean atLeastJava6() { return JAVA_CLASS_VERSION >= 50.0; } |
242 |
|
public static boolean atLeastJava7() { return JAVA_CLASS_VERSION >= 51.0; } |
243 |
|
public static boolean atLeastJava8() { return JAVA_CLASS_VERSION >= 52.0; } |
244 |
+ |
public static boolean atLeastJava9() { |
245 |
+ |
// As of 2014-05, java9 still uses 52.0 class file version |
246 |
+ |
return JAVA_SPECIFICATION_VERSION.startsWith("1.9"); |
247 |
+ |
} |
248 |
|
|
249 |
|
/** |
250 |
|
* Collects all JSR166 unit tests as one suite. |
337 |
|
addNamedTestClasses(suite, java8TestClassNames); |
338 |
|
} |
339 |
|
|
340 |
+ |
// Java9+ test classes |
341 |
+ |
if (atLeastJava9()) { |
342 |
+ |
String[] java9TestClassNames = { |
343 |
+ |
"ThreadPoolExecutor9Test", |
344 |
+ |
}; |
345 |
+ |
addNamedTestClasses(suite, java9TestClassNames); |
346 |
+ |
} |
347 |
+ |
|
348 |
|
return suite; |
349 |
|
} |
350 |
|
|
902 |
|
* startNanoTime, which must have been previously returned from a |
903 |
|
* call to {@link System.nanoTime()}. |
904 |
|
*/ |
905 |
< |
long millisElapsedSince(long startNanoTime) { |
905 |
> |
static long millisElapsedSince(long startNanoTime) { |
906 |
|
return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime); |
907 |
|
} |
908 |
|
|