< prev index next >
test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java
Print this page
@@ -23,21 +23,22 @@
package jdk.test.lib.jittester.factories;
import java.util.ArrayList;
import java.util.List;
+
+import jdk.test.lib.jittester.Block;
import jdk.test.lib.jittester.CatchBlock;
-import jdk.test.lib.jittester.IRNode;
import jdk.test.lib.jittester.ProductionFailedException;
import jdk.test.lib.jittester.TryCatchBlock;
import jdk.test.lib.jittester.Type;
import jdk.test.lib.jittester.TypeList;
import jdk.test.lib.jittester.utils.TypeUtil;
import jdk.test.lib.jittester.types.TypeKlass;
import jdk.test.lib.jittester.utils.PseudoRandom;
-class TryCatchBlockFactory extends Factory {
+class TryCatchBlockFactory extends Factory<TryCatchBlock> {
private final static double CATCH_SELECTION_COEF = 0.1d;
private final Type returnType;
private final long complexityLimit;
private final int statementLimit, operatorLimit;
private final boolean subBlock;
@@ -62,11 +63,11 @@
this.canHaveContinues = canHaveContinues;
this.canHaveReturn = canHaveReturn;
}
@Override
- public IRNode produce() throws ProductionFailedException {
+ public TryCatchBlock produce() throws ProductionFailedException {
if (complexityLimit < 1 || statementLimit < 1) {
throw new ProductionFailedException();
}
List<Type> uncheckedThrowables = getUncheckedThrowables();
IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlass(ownerClass)
@@ -75,11 +76,11 @@
.setLevel(level)
.setSubBlock(subBlock)
.setCanHaveReturn(canHaveReturn)
.setCanHaveContinues(canHaveContinues)
.setCanHaveBreaks(canHaveBreaks);
- IRNode body = getBlock(builder, 0.6);
+ Block body = getBlock(builder, 0.6);
int catchBlocksCount = (int) (CATCH_SELECTION_COEF
* PseudoRandom.random() * uncheckedThrowables.size());
List<CatchBlock> catchBlocks = new ArrayList<>();
List<Type> caught = new ArrayList<>();
for (int i = 0; i < catchBlocksCount; i++) {
@@ -90,11 +91,11 @@
whatToCatch.add(selectUniqueThrowable(uncheckedThrowables, caught));
}
catchBlocks.add(new CatchBlock(getBlock(builder, 0.3/catchBlocksCount),
whatToCatch, level));
}
- IRNode finallyBody = PseudoRandom.randomBoolean() || catchBlocksCount == 0 ? getBlock(builder, 0.1) : null;
+ Block finallyBody = PseudoRandom.randomBoolean() || catchBlocksCount == 0 ? getBlock(builder, 0.1) : null;
return new TryCatchBlock(body, finallyBody, catchBlocks, level);
}
private Type selectUniqueThrowable(List<Type> variants, List<Type> caught) {
Type selected;
@@ -104,11 +105,11 @@
} while (caught.contains(selected));
caught.add(selected);
return selected;
}
- private IRNode getBlock(IRNodeBuilder builder, double weight)
+ private Block getBlock(IRNodeBuilder builder, double weight)
throws ProductionFailedException {
long actualComplexityLim = (long) (weight * PseudoRandom.random()
* complexityLimit);
int actualStatementLim = (int) (weight * PseudoRandom.random()
* statementLimit);
< prev index next >