< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java

Print this page




 383             }
 384             classEnter(tree.defs, topEnv);
 385             if (addEnv) {
 386                 todo.append(packageEnv);
 387             }
 388         }
 389         log.useSource(prev);
 390         result = null;
 391     }
 392 
 393     @Override
 394     public void visitClassDef(JCClassDecl tree) {
 395         Symbol owner = env.info.scope.owner;
 396         WriteableScope enclScope = enterScope(env);
 397         ClassSymbol c;
 398         if (owner.kind == PCK) {
 399             // We are seeing a toplevel class.
 400             PackageSymbol packge = (PackageSymbol)owner;
 401             for (Symbol q = packge; q != null && q.kind == PCK; q = q.owner)
 402                 q.flags_field |= EXISTS;



 403             c = syms.enterClass(env.toplevel.modle, tree.name, packge);
 404             packge.members().enterIfAbsent(c);
 405             if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) {
 406                 KindName topElement = KindName.CLASS;
 407                 if ((tree.mods.flags & ENUM) != 0) {
 408                     topElement = KindName.ENUM;
 409                 } else if ((tree.mods.flags & INTERFACE) != 0) {
 410                     topElement = KindName.INTERFACE;
 411                 }
 412                 log.error(tree.pos(),
 413                           Errors.ClassPublicShouldBeInFile(topElement, tree.name));
 414             }
 415         } else {
 416             if (!tree.name.isEmpty() &&
 417                 !chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) {
 418                 result = null;
 419                 return;
 420             }
 421             if (owner.kind == TYP) {
 422                 // We are seeing a member class.




 383             }
 384             classEnter(tree.defs, topEnv);
 385             if (addEnv) {
 386                 todo.append(packageEnv);
 387             }
 388         }
 389         log.useSource(prev);
 390         result = null;
 391     }
 392 
 393     @Override
 394     public void visitClassDef(JCClassDecl tree) {
 395         Symbol owner = env.info.scope.owner;
 396         WriteableScope enclScope = enterScope(env);
 397         ClassSymbol c;
 398         if (owner.kind == PCK) {
 399             // We are seeing a toplevel class.
 400             PackageSymbol packge = (PackageSymbol)owner;
 401             for (Symbol q = packge; q != null && q.kind == PCK; q = q.owner)
 402                 q.flags_field |= EXISTS;
 403             if ((tree.mods.flags & Flags.RECORD) != 0) {
 404                 tree.mods.flags &= ~Flags.STATIC;
 405             }
 406             c = syms.enterClass(env.toplevel.modle, tree.name, packge);
 407             packge.members().enterIfAbsent(c);
 408             if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) {
 409                 KindName topElement = KindName.CLASS;
 410                 if ((tree.mods.flags & ENUM) != 0) {
 411                     topElement = KindName.ENUM;
 412                 } else if ((tree.mods.flags & INTERFACE) != 0) {
 413                     topElement = KindName.INTERFACE;
 414                 }
 415                 log.error(tree.pos(),
 416                           Errors.ClassPublicShouldBeInFile(topElement, tree.name));
 417             }
 418         } else {
 419             if (!tree.name.isEmpty() &&
 420                 !chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) {
 421                 result = null;
 422                 return;
 423             }
 424             if (owner.kind == TYP) {
 425                 // We are seeing a member class.


< prev index next >