test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
Print this page
@@ -22,12 +22,14 @@
*/
import com.oracle.testlibrary.jsr292.Helper;
import com.sun.management.HotSpotDiagnosticMXBean;
import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Method;
import java.util.Collection;
+import java.util.List;
import java.util.function.Function;
/**
* Lambda forms caching test case class. Contains all necessary test routines to
* test lambda forms caching in method handles returned by methods of
@@ -93,10 +95,16 @@
int failCounter = 0;
long testCaseNum = testMethods.size();
long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
iterations, iterations * testCaseNum);
+ RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
+ List<String> vmopts = runtimeMxBean.getInputArguments();
+ if (vmopts.contains("-Xcomp")) {
+ System.out.println("Number of iterations is limited to 1 because -Xcomp is set");
+ iterations = 1;
+ } else {
HotSpotDiagnosticMXBean hsDiagBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
long codeCacheSize = Long.parseLong(
hsDiagBean.getVMOption("ReservedCodeCacheSize").getValue());
System.out.printf("Code cache size is %d bytes%n", codeCacheSize);
long iterationsByCodeCacheSize = (long) (codeCacheSize
@@ -115,10 +123,11 @@
if (iterations == 0) {
System.out.println("Warning: code cache size is too small to provide at"
+ " least one iteration! Test will try to do one iteration.");
iterations = 1;
}
+ }
System.out.printf("Number of iterations is set to %d (%d cases)%n",
iterations, iterations * testCaseNum);
System.out.flush();
for (long i = 0; i < iterations; i++) {
System.err.println(String.format("Iteration %d:", i));