langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java
changeset 43756 118221d3960d
parent 42828 cce89649f958
child 43760 bdbe9f1571f0
equal deleted inserted replaced
43755:ae42964e27e3 43756:118221d3960d
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2017, 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.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    30 
    30 
    31 import javax.tools.JavaFileObject;
    31 import javax.tools.JavaFileObject;
    32 import javax.tools.JavaFileManager;
    32 import javax.tools.JavaFileManager;
    33 
    33 
    34 import com.sun.tools.javac.code.*;
    34 import com.sun.tools.javac.code.*;
       
    35 import com.sun.tools.javac.code.Kinds.KindName;
    35 import com.sun.tools.javac.code.Kinds.KindSelector;
    36 import com.sun.tools.javac.code.Kinds.KindSelector;
    36 import com.sun.tools.javac.code.Scope.*;
    37 import com.sun.tools.javac.code.Scope.*;
    37 import com.sun.tools.javac.code.Symbol.*;
    38 import com.sun.tools.javac.code.Symbol.*;
    38 import com.sun.tools.javac.code.Type.*;
    39 import com.sun.tools.javac.code.Type.*;
    39 import com.sun.tools.javac.main.Option.PkgInfo;
    40 import com.sun.tools.javac.main.Option.PkgInfo;
   398             for (Symbol q = packge; q != null && q.kind == PCK; q = q.owner)
   399             for (Symbol q = packge; q != null && q.kind == PCK; q = q.owner)
   399                 q.flags_field |= EXISTS;
   400                 q.flags_field |= EXISTS;
   400             c = syms.enterClass(env.toplevel.modle, tree.name, packge);
   401             c = syms.enterClass(env.toplevel.modle, tree.name, packge);
   401             packge.members().enterIfAbsent(c);
   402             packge.members().enterIfAbsent(c);
   402             if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) {
   403             if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) {
       
   404                 KindName topElement = KindName.CLASS;
       
   405                 if ((tree.mods.flags & ENUM) != 0) {
       
   406                     topElement = KindName.ENUM;
       
   407                 } else if ((tree.mods.flags & INTERFACE) != 0) {
       
   408                     topElement = KindName.INTERFACE;
       
   409                 }
   403                 log.error(tree.pos(),
   410                 log.error(tree.pos(),
   404                           "class.public.should.be.in.file", tree.name);
   411                           "class.public.should.be.in.file", topElement, tree.name);
   405             }
   412             }
   406         } else {
   413         } else {
   407             if (!tree.name.isEmpty() &&
   414             if (!tree.name.isEmpty() &&
   408                 !chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) {
   415                 !chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) {
   409                 result = null;
   416                 result = null;