< prev index next >
test/java/lang/invoke/MethodHandles/CatchExceptionTest.java
Print this page
rev 11972 : 8055269: java/lang/invoke/MethodHandles/CatchExceptionTest.java fails intermittently
Reviewed-by:
@@ -70,16 +70,10 @@
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
final int catchDrops) {
this.testCase = testCase;
this.dropped = catchDrops;
- if (Helper.IS_VERBOSE) {
- System.out.printf("CatchException::CatchException(%s, isVararg=%b " +
- "argsCount=%d catchDrops=%d)%n",
- testCase, isVararg, argsCount, catchDrops
- );
- }
MethodHandle thrower = testCase.thrower;
int throwerLen = thrower.type().parameterCount();
List<Class<?>> classes;
int extra = Math.max(0, argsCount - throwerLen);
classes = getThrowerParams(isVararg, extra);
@@ -95,13 +89,15 @@
catcher = testCase.getCatcher(getCatcherParams());
nargs = Math.max(2, this.argsCount);
}
public static void main(String[] args) throws Throwable {
+ System.out.println("classes = " + ARGS_CLASSES);
+
TestFactory factory = new TestFactory();
long timeout = Helper.IS_THOROUGH ? 0L : Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT);
- // substract vm init time and reserve time for vm exit
+ // subtract vm init time and reserve time for vm exit
timeout *= 0.9;
TimeLimitedRunner runner = new TimeLimitedRunner(timeout, 2.0d,
() -> {
CatchExceptionTest test = factory.nextTest();
if (test != null) {
@@ -129,10 +125,16 @@
result.add(0, testCase.throwableClass);
return result;
}
private void runTest() {
+ if (Helper.IS_VERBOSE) {
+ System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " +
+ "dropped=%d)%n",
+ testCase, thrower.isVarargsCollector(), argsCount, dropped);
+ }
+
Helper.clear();
Object[] args = Helper.randomArgs(
argsCount, thrower.type().parameterArray());
Object arg0 = Helper.MISSING_ARG;
@@ -210,14 +212,11 @@
+ Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY)
+ 1;
args = 1;
}
- if (Helper.IS_VERBOSE) {
- System.out.printf("maxArgs = %d%nmaxDrops = %d%n",
- maxArgs, maxDrops);
- }
+ System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops);
constructorSize = TestCase.CONSTRUCTORS.size();
}
private static List<CatchExceptionTest> createTests(int argsCount,
int catchDrops) {
@@ -241,11 +240,11 @@
return result;
}
/**
* @return next test from test matrix:
- * {varArgs, noVarArgs} x TestCase.rtypes x TestCase.THROWABLES x {1, .., maxArgs } x {1, .., maxDrops}
+ * {varArgs, noVarArgs} x TestCase.rtypes x TestCase.THROWABLES x {1, .., maxArgs } x {0, .., maxDrops}
*/
public CatchExceptionTest nextTest() {
if (constructor < constructorSize) {
return createTest();
}
@@ -254,11 +253,11 @@
if (!Helper.IS_THOROUGH && count > Helper.TEST_LIMIT) {
System.out.println("test limit is exceeded");
return null;
}
if (dropArgs <= currentMaxDrops) {
- if (dropArgs == 1) {
+ if (dropArgs == 0) {
if (Helper.IS_THOROUGH || Helper.RNG.nextBoolean()) {
++dropArgs;
return createTest();
} else if (Helper.IS_VERBOSE) {
System.out.printf(
@@ -269,12 +268,12 @@
++dropArgs;
return createTest();
}
}
- if (args <= maxArgs) {
- dropArgs = 1;
+ if (args < maxArgs) {
+ dropArgs = 0;
currentMaxDrops = Math.min(args, maxDrops);
++args;
return createTest();
}
return null;
< prev index next >