langtools/test/tools/javac/scope/StarImportTest.java
changeset 32059 ea04f56aeacd
parent 30730 d3ce7619db2c
child 36526 3b41f1c69604
equal deleted inserted replaced
31945:eeea9adfd1e3 32059:ea04f56aeacd
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 7004029
    26  * @bug 7004029 8131915
    27  * @summary Basher for star-import scopes
    27  * @summary Basher for star-import scopes
    28  * @modules jdk.compiler/com.sun.tools.javac.code
    28  * @modules jdk.compiler/com.sun.tools.javac.code
    29  *          jdk.compiler/com.sun.tools.javac.file
    29  *          jdk.compiler/com.sun.tools.javac.file
    30  *          jdk.compiler/com.sun.tools.javac.util
    30  *          jdk.compiler/com.sun.tools.javac.util
    31  */
    31  */
    37 import com.sun.tools.javac.code.Scope.ImportFilter;
    37 import com.sun.tools.javac.code.Scope.ImportFilter;
    38 import com.sun.tools.javac.code.Scope.StarImportScope;
    38 import com.sun.tools.javac.code.Scope.StarImportScope;
    39 import com.sun.tools.javac.code.Scope.WriteableScope;
    39 import com.sun.tools.javac.code.Scope.WriteableScope;
    40 import com.sun.tools.javac.code.Symbol.*;
    40 import com.sun.tools.javac.code.Symbol.*;
    41 import com.sun.tools.javac.file.JavacFileManager;
    41 import com.sun.tools.javac.file.JavacFileManager;
       
    42 import com.sun.tools.javac.tree.TreeMaker;
    42 import com.sun.tools.javac.util.*;
    43 import com.sun.tools.javac.util.*;
    43 
    44 
    44 import static com.sun.tools.javac.code.Kinds.Kind.*;
    45 import static com.sun.tools.javac.code.Kinds.Kind.*;
    45 
    46 
    46 public class StarImportTest {
    47 public class StarImportTest {
   134          */
   135          */
   135         void setup() {
   136         void setup() {
   136             log ("setup");
   137             log ("setup");
   137             context = new Context();
   138             context = new Context();
   138             JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
   139             JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
       
   140             make = TreeMaker.instance(context);
   139             names = Names.instance(context);       // Name.Table impls tied to an instance of Names
   141             names = Names.instance(context);       // Name.Table impls tied to an instance of Names
   140             symtab = Symtab.instance(context);
   142             symtab = Symtab.instance(context);
   141             types = Types.instance(context);
   143             types = Types.instance(context);
   142             int setupCount = rgen.nextInt(MAX_SETUP_COUNT);
   144             int setupCount = rgen.nextInt(MAX_SETUP_COUNT);
   143             for (int i = 0; i < setupCount; i++) {
   145             for (int i = 0; i < setupCount; i++) {
   225                 starImportScope.importAll(types, members, new ImportFilter() {
   227                 starImportScope.importAll(types, members, new ImportFilter() {
   226                     @Override
   228                     @Override
   227                     public boolean accepts(Scope origin, Symbol t) {
   229                     public boolean accepts(Scope origin, Symbol t) {
   228                         return t.kind == TYP;
   230                         return t.kind == TYP;
   229                     }
   231                     }
   230                 }, false);
   232                 }, make.Import(null, false), (i, cf) -> { throw new IllegalStateException(); });
   231 
   233 
   232                 for (Symbol sym : members.getSymbols()) {
   234                 for (Symbol sym : members.getSymbols()) {
   233                     starImportModel.enter(sym);
   235                     starImportModel.enter(sym);
   234                 }
   236                 }
   235             }
   237             }
   293             return sym;
   295             return sym;
   294         }
   296         }
   295 
   297 
   296         Context context;
   298         Context context;
   297         Symtab symtab;
   299         Symtab symtab;
       
   300         TreeMaker make;
   298         Names names;
   301         Names names;
   299         Types types;
   302         Types types;
   300         int nextNameSerial;
   303         int nextNameSerial;
   301         List<PackageSymbol> packages = new ArrayList<PackageSymbol>();
   304         List<PackageSymbol> packages = new ArrayList<PackageSymbol>();
   302         int nextPackageSerial;
   305         int nextPackageSerial;