test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTShape.java

Mon, 21 Jan 2013 20:15:16 +0000

author
mcimadamore
date
Mon, 21 Jan 2013 20:15:16 +0000
changeset 1512
b12ffdfa1341
parent 0
959103a6100f
permissions
-rw-r--r--

8005851: Remove support for synchronized interface methods
Summary: Synchronized default methods are no longer supported
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package org.openjdk.tests.shapegen;
    28 import java.util.ArrayList;
    29 import java.util.HashSet;
    30 import java.util.List;
    31 import java.util.Set;
    33 /**
    34  *
    35  * @author Robert Field
    36  */
    37 public class TTShape {
    39     private final TTNode root;
    40     private final TTNode[] nodes;
    42     TTShape(TTNode root) {
    43         this.root = root;
    44         Set<TTNode> subs = new HashSet<>();
    45         root.collectAllSubtypes(subs);
    46         nodes = subs.toArray(new TTNode[subs.size()]);
    47     }
    49     private List<ClassCase> toCases(boolean includeClasses) {
    50         List<ClassCase> ccs = new ArrayList<>();
    51         root.start(includeClasses);
    52         int i;
    53         outer:
    54         while (true) {
    55             if (root.isValid()) {
    56                 ClassCase cc = root.genCase();
    57                 //System.out.println(cc);
    58                 ccs.add(cc);
    59             }
    61             i = 0;
    62             do {
    63                 if (i >= nodes.length) {
    64                     break outer;
    65                 }
    66             } while(!nodes[i++].next());
    67         }
    68         return ccs;
    69     }
    71    public static List<ClassCase> allCases(boolean includeClasses) {
    72         List<ClassCase> ccs = new ArrayList<>();
    73         for (TTShape shape : SHAPES) {
    74             ccs.addAll(shape.toCases(includeClasses));
    75         }
    76         return ccs;
    77     }
    79     public static TTShape parse(String s) {
    80         return new TTShape(new TTParser(s).parse());
    81     }
    83     public static final TTShape[] SHAPES = new TTShape[] {
    84         parse("a"),
    85         parse("a(b)"),
    86         parse("A(bb)"),
    87         parse("A(B(d)c(d))"),
    88         parse("A(b(c))"),
    89         parse("A(B(cd)d)"),
    90         parse("A(B(c)c)"),
    91         parse("A(B(Ce)d(e))"),
    92         parse("A(B(C)d(e))"),
    93         parse("A(Bc(d))"),
    94         parse("A(B(d)dc)"),
    95         parse("A(B(dc)dc)"),
    96         parse("A(B(c(d))d)"),
    97         parse("A(B(C(d))d)"),
    98         parse("A(B(C(e)d(e))e)"),
    99         parse("A(B(c(d))c)"),
   100         parse("A(B(dc(d))c)"),
   101         parse("A(B(C(d))d)"),
   102     };
   104 }

mercurial