--- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java 2016-04-08 16:17:30.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java 2016-04-08 16:17:30.000000000 +0300 @@ -31,7 +31,7 @@ import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.VariableBase; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.types.TypeKlass; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java 2016-04-08 16:17:30.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java 2016-04-08 16:17:30.000000000 +0300 @@ -29,7 +29,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java 2016-04-08 16:17:31.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java 2016-04-08 16:17:31.000000000 +0300 @@ -28,7 +28,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java 2016-04-08 16:17:31.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java 2016-04-08 16:17:31.000000000 +0300 @@ -28,11 +28,11 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeLong; import jdk.test.lib.jittester.utils.PseudoRandom; +import jdk.test.lib.jittester.utils.TypeUtil; class BinaryShiftOperatorFactory extends BinaryOperatorFactory { BinaryShiftOperatorFactory(OperatorKind opKind, long complexityLimit, int operatorLimit, --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java 2016-04-08 16:17:32.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java 2016-04-08 16:17:32.000000000 +0300 @@ -28,7 +28,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.UnaryOperator; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeInt; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java 2016-04-08 16:17:32.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java 2016-04-08 16:17:32.000000000 +0300 @@ -33,7 +33,7 @@ import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.loops.DoWhile; import jdk.test.lib.jittester.loops.For; import jdk.test.lib.jittester.loops.While; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java 2016-04-08 16:17:33.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java 2016-04-08 16:17:33.000000000 +0300 @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java 2016-04-08 16:17:33.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java 2016-04-08 16:17:33.000000000 +0300 @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java 2016-04-08 16:17:34.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java 2016-04-08 16:17:34.000000000 +0300 @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.utils.PseudoRandom; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java 2016-04-08 16:17:34.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java 2016-04-08 16:17:34.000000000 +0300 @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.loops.CounterInitializer; import jdk.test.lib.jittester.types.TypeKlass; @@ -48,7 +48,7 @@ @Override protected IRNode sproduce() throws ProductionFailedException { - List types = TypeUtil.getMoreCapatiousThan(TypeList.getBuiltIn(), new TypeInt()); + List types = TypeUtil.getMoreCapaciousThan(TypeList.getBuiltIn(), new TypeInt()); types.add(new TypeInt()); final Type selectedType = PseudoRandom.randomElement(types); IRNode init = new LiteralInitializer(counterValue, selectedType); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java 2016-04-08 16:17:35.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java 2016-04-08 16:17:35.000000000 +0300 @@ -34,7 +34,7 @@ import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Switch; import jdk.test.lib.jittester.Type; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeByte; import jdk.test.lib.jittester.types.TypeChar; @@ -63,7 +63,7 @@ @Override protected IRNode sproduce() throws ProductionFailedException { if (statementLimit > 0 && complexityLimit > 0) { - ArrayList switchTypes = new ArrayList<>(); + List switchTypes = new ArrayList<>(); switchTypes.add(new TypeChar()); switchTypes.add(new TypeByte()); switchTypes.add(new TypeShort()); @@ -78,8 +78,8 @@ .setCanHaveReturn(canHaveReturn); MAIN_LOOP: for (Type type : switchTypes) { - ArrayList caseConsts = new ArrayList<>(); - ArrayList caseBlocks = new ArrayList<>(); + List caseConsts = new ArrayList<>(); + List caseBlocks = new ArrayList<>(); try { int accumulatedStatements = 0; int currentStatementsLimit = 0; @@ -94,10 +94,10 @@ .getLimitedExpressionFactory() .produce(); accumulatedComplexity += currentComplexityLimit; - ArrayList caseTypes = new ArrayList<>(); + List caseTypes = new ArrayList<>(); caseTypes.add(new TypeByte()); caseTypes.add(new TypeChar()); - caseTypes = new ArrayList<>(TypeUtil.getLessCapatiousOrEqualThan(caseTypes, + caseTypes = new ArrayList<>(TypeUtil.getLessCapaciousOrEqualThan(caseTypes, (BuiltInType) type)); if (PseudoRandom.randomBoolean()) { // "default" currentStatementsLimit = (int) (PseudoRandom.random() --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java 2016-04-08 16:17:36.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java 2016-04-08 16:17:35.000000000 +0300 @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.TernaryOperator; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.utils.PseudoRandom; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java 2016-04-08 16:17:36.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java 2016-04-08 16:17:36.000000000 +0300 @@ -31,7 +31,7 @@ import jdk.test.lib.jittester.TryCatchBlock; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java 2016-04-08 16:17:37.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java 2016-04-08 16:17:36.000000000 +0300 @@ -29,7 +29,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.UnaryOperator; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeInt; --- /dev/null 2016-04-08 16:17:37.000000000 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/TypeUtil.java 2016-04-08 16:17:37.000000000 +0300 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.jittester.utils; + +import jdk.test.lib.jittester.BuiltInType; +import jdk.test.lib.jittester.Type; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Utility functions for type system + */ +public class TypeUtil { + /** + * Gets a list of implicitly castable types to a given one from the collection of types + * + * @param types a collection to get types from + * @param type a target type which result type could be implicitly cast to + * @return a result collection of types that match given conditions + */ + public static Collection getImplicitlyCastable(Collection types, Type type) { + return types.stream() + .filter(t -> t.canImplicitlyCastTo(type)) + .collect(Collectors.toList()); + } + + /** + * Gets a list of explicitly castable types to a given one from the collection of types + * + * @param types a collection to get types from + * @param type a target type which result type could be explicitly cast to + * @return a result collection of types that match given conditions + */ + public static Collection getExplicitlyCastable(Collection types, Type type) { + return types.stream() + .filter(t -> t.canExplicitlyCastTo(type)) + .collect(Collectors.toList()); + } + + /** + * Gets a list of more capacious types than a given one from the collection of types + * + * @param types a collection to get types from + * @param type a type to filter given types by capacity + * @return a result collection of types that match given conditions + */ + public static List getMoreCapaciousThan(Collection types, BuiltInType type) { + return types.stream() + .filter(t -> ((BuiltInType) t).isMoreCapaciousThan(type)) + .collect(Collectors.toList()); + } + + /** + * Gets a list of less or equal capacious types than a given one from the collection of types + * + * @param types a collection to get types from + * @param type a type to filter given types by capacity + * @return a result collection of types that match given conditions + */ + public static List getLessCapaciousOrEqualThan(Collection types, BuiltInType type) { + return types.stream() + .filter(t -> !((BuiltInType) t).isMoreCapaciousThan(type) || t.equals(type)) + .collect(Collectors.toList()); + } +} --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeUtil.java 2016-04-08 16:17:37.000000000 +0300 +++ /dev/null 2016-04-08 16:17:37.000000000 +0300 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.test.lib.jittester; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - - -public class TypeUtil { - - public static Collection getImplicitlyCastable(Collection types, Type type) { - ArrayList result = new ArrayList<>(types); - Iterator iterator = result.iterator(); - while (iterator.hasNext()) { - if (!iterator.next().canImplicitlyCastTo(type)) { - iterator.remove(); - } - } - return result; - } - - public static Collection getExplicitlyCastable(Collection types, Type type) { - ArrayList result = new ArrayList<>(types); - Iterator iterator = result.iterator(); - while (iterator.hasNext()) { - if (!iterator.next().canExplicitlyCastTo(type)) { - iterator.remove(); - } - } - return result; - } - - public static List getMoreCapatiousThan(Collection types, BuiltInType type) { - ArrayList result = new ArrayList<>(); - Iterator iterator = types.iterator(); - while (iterator.hasNext()) { - try { - BuiltInType builtInType = (BuiltInType) iterator.next(); - if (builtInType.isMoreCapaciousThan(type)) { - result.add(builtInType); - } - } catch (Exception e) { - } - } - return result; - } - - public static List getLessCapatiousOrEqualThan(Collection types, BuiltInType type) { - ArrayList result = new ArrayList<>(); - Iterator iterator = types.iterator(); - while (iterator.hasNext()) { - try { - BuiltInType builtInType = (BuiltInType) iterator.next(); - if (!builtInType.isMoreCapaciousThan(type) || builtInType.equals(type)) { - result.add(builtInType); - } - } catch (Exception e) { - } - } - return result; - } -}