diff -r 6d6d54dc0ae1 -r 7fb1616f52f3 langtools/test/tools/javac/defaultMethods/fd/shapegen/HierarchyGenerator.java --- a/langtools/test/tools/javac/defaultMethods/fd/shapegen/HierarchyGenerator.java Fri Nov 30 12:00:07 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2012, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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 shapegen; - -import shapegen.ClassCase.Kind; - -import java.util.Collection; -import java.util.Set; -import java.util.HashSet; -import java.util.Collections; -import java.util.ArrayList; -import java.util.List; - -import static shapegen.ClassCase.Kind.*; - -import static java.lang.Math.pow; - -/** - * - * @author Robert Field - */ -public final class HierarchyGenerator { - - private static int okcnt = 0; - private static int errcnt = 0; - private static Set uniqueOK = new HashSet<>(); - private static Set uniqueErr = new HashSet<>(); - - /** - * @param args the command line arguments - */ - public HierarchyGenerator() { - organize("exhaustive interface", iExhaustive(2)); - organize("exhaustive class", cExhaustive()); - organize("shapes interface", iShapes()); - organize("shapes class/interface", ciShapes()); - - System.out.printf("\nExpect OK: %d -- unique %d", okcnt, uniqueOK.size()); - System.out.printf("\nExpect Error: %d -- unique %d\n", errcnt, uniqueErr.size()); - } - - public Collection getOK() { - return uniqueOK; - } - - public Collection getErr() { - return uniqueErr; - } - - private void organize(String tname, List totest) { - System.out.printf("\nTesting %s....\n", tname); - int nodefault = 0; - List ok = new ArrayList<>(); - List err = new ArrayList<>(); - for (Hierarchy cc : totest) { - if (cc.anyDefaults()) { - //System.out.printf(" %s\n", cc); - if (cc.get_OK()) { - ok.add(cc); - } else { - err.add(cc); - } - } else { - ++nodefault; - } - } - - errcnt += err.size(); - okcnt += ok.size(); - uniqueErr.addAll(err); - uniqueOK.addAll(ok); - - System.out.printf(" %5d No default\n %5d Error\n %5d OK\n %5d Total\n", - nodefault, err.size(), ok.size(), totest.size()); - } - - public List iExhaustive(int idepth) { - List current = new ArrayList<>(); - for (int i = 0; i < idepth; ++i) { - current = ilayer(current); - } - return wrapInClassAndHierarchy(current); - } - - private List ilayer(List srcLayer) { - List lay = new ArrayList<>(); - for (int i = (int) pow(2, srcLayer.size()) - 1; i >= 0; --i) { - List itfs = new ArrayList<>(); - for (int b = srcLayer.size() - 1; b >= 0; --b) { - if ((i & (1< cExhaustive() { - final Kind[] iKinds = new Kind[]{IDEFAULT, IVAC, IPRESENT, null}; - final Kind[] cKinds = new Kind[]{CNONE, CABSTRACT, CCONCRETE}; - List totest = new ArrayList<>(); - for (int i1 = 0; i1 < iKinds.length; ++i1) { - for (int i2 = 0; i2 < iKinds.length; ++i2) { - for (int i3 = 0; i3 < iKinds.length; ++i3) { - for (int c1 = 0; c1 < cKinds.length; ++c1) { - for (int c2 = 0; c2 < cKinds.length; ++c2) { - for (int c3 = 0; c3 < cKinds.length; ++c3) { - totest.add( new Hierarchy( - new ClassCase(cKinds[c1], - new ClassCase(cKinds[c2], - new ClassCase(cKinds[c3], - null, - iList(iKinds[i1]) - ), - iList(iKinds[i2]) - ), - iList(iKinds[i3]) - ))); - } - } - } - } - } - } - return totest; - } - - private List iList(Kind kind) { - if (kind == null) { - return Collections.EMPTY_LIST; - } else { - List itfs = new ArrayList<>(); - itfs.add(new ClassCase(kind, null, Collections.EMPTY_LIST)); - return itfs; - } - } - - public List ciShapes() { - return wrapInHierarchy(TTShape.allCases(true)); - } - - public List iShapes() { - return wrapInClassAndHierarchy(TTShape.allCases(false)); - } - - public List wrapInClassAndHierarchy(List ihs) { - List totest = new ArrayList<>(); - for (ClassCase cc : ihs) { - List interfaces = new ArrayList<>(); - interfaces.add(cc); - totest.add(new Hierarchy(new ClassCase(CNONE, null, interfaces))); - } - return totest; - } - - public List wrapInHierarchy(List ihs) { - List totest = new ArrayList<>(); - for (ClassCase cc : ihs) { - totest.add(new Hierarchy(cc)); - } - return totest; - } -}