langtools/test/tools/javac/7003595/T7003595.java
changeset 27319 030080f03e4f
parent 10627 d8e900b62e02
child 30730 d3ce7619db2c
equal deleted inserted replaced
27318:4660a5da7d90 27319:030080f03e4f
     1 /*
     1 /*
     2  * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    46 
    46 
    47 
    47 
    48 public class T7003595 {
    48 public class T7003595 {
    49 
    49 
    50     /** global decls ***/
    50     /** global decls ***/
    51 
       
    52     // Create a single file manager and reuse it for each compile to save time.
       
    53     static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
       
    54 
    51 
    55     //statistics
    52     //statistics
    56     static int checkCount = 0;
    53     static int checkCount = 0;
    57 
    54 
    58     enum ClassKind {
    55     enum ClassKind {
   110             this.canonicalInnerStr = canonicalInnerStr;
   107             this.canonicalInnerStr = canonicalInnerStr;
   111         }
   108         }
   112     }
   109     }
   113 
   110 
   114     public static void main(String... args) throws Exception {
   111     public static void main(String... args) throws Exception {
   115         for (ClassKind ck1 : ClassKind.values()) {
   112         // Create a single file manager and reuse it for each compile to save time.
   116             String cname1 = "C1";
   113         try (StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null)) {
   117             for (ClassKind ck2 : ClassKind.values()) {
   114             for (ClassKind ck1 : ClassKind.values()) {
   118                 if (!ck1.isAllowed(ck2)) continue;
   115                 String cname1 = "C1";
   119                 String cname2 = "C2";
   116                 for (ClassKind ck2 : ClassKind.values()) {
   120                 for (ClassKind ck3 : ClassKind.values()) {
   117                     if (!ck1.isAllowed(ck2)) continue;
   121                     if (!ck2.isAllowed(ck3)) continue;
   118                     String cname2 = "C2";
   122                     String cname3 = "C3";
   119                     for (ClassKind ck3 : ClassKind.values()) {
   123                     new T7003595(new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
   120                         if (!ck2.isAllowed(ck3)) continue;
       
   121                         String cname3 = "C3";
       
   122                         new T7003595(fm, new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
       
   123                     }
   124                 }
   124                 }
   125             }
   125             }
   126         }
   126         }
   127 
   127 
   128         System.out.println("Total checks made: " + checkCount);
   128         System.out.println("Total checks made: " + checkCount);
   130 
   130 
   131     /** instance decls **/
   131     /** instance decls **/
   132 
   132 
   133     ClassKind[] cks;
   133     ClassKind[] cks;
   134     String[] cnames;
   134     String[] cnames;
   135 
   135     StandardJavaFileManager fm;
   136     T7003595(ClassKind[] cks, String[] cnames) {
   136 
       
   137     T7003595(StandardJavaFileManager fm, ClassKind[] cks, String[] cnames) {
       
   138         this.fm = fm;
   137         this.cks = cks;
   139         this.cks = cks;
   138         this.cnames = cnames;
   140         this.cnames = cnames;
   139     }
   141     }
   140 
   142 
   141     void compileAndCheck() throws Exception {
   143     void compileAndCheck() throws Exception {