< prev index next >

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

Print this page
@@ -419,49 +419,54 @@
          if (env.info.visitingServiceImplementation &&
              env.toplevel.modle == sym.packge().modle) {
              return true;
          }
  
-         switch ((short)(sym.flags() & AccessFlags)) {
-         case PRIVATE:
-             return
-                 (env.enclClass.sym == sym.owner // fast special case
-                  ||
-                  env.enclClass.sym.outermostClass() ==
-                  sym.owner.outermostClass()
-                  ||
-                  privateMemberInPermitsClauseIfAllowed(env, sym))
-                 &&
-                 sym.isInheritedIn(site.tsym, types);
-         case 0:
-             return
-                 (env.toplevel.packge == sym.owner.owner // fast special case
-                  ||
-                  env.toplevel.packge == sym.packge())
-                 &&
-                 isAccessible(env, site, checkInner)
-                 &&
-                 sym.isInheritedIn(site.tsym, types)
-                 &&
-                 notOverriddenIn(site, sym);
-         case PROTECTED:
-             return
-                 (env.toplevel.packge == sym.owner.owner // fast special case
-                  ||
-                  env.toplevel.packge == sym.packge()
-                  ||
-                  isProtectedAccessible(sym, env.enclClass.sym, site)
-                  ||
-                  // OK to select instance method or field from 'super' or type name
-                  // (but type names should be disallowed elsewhere!)
-                  env.info.selectSuper && (sym.flags() & STATIC) == 0 && sym.kind != TYP)
-                 &&
-                 isAccessible(env, site, checkInner)
-                 &&
-                 notOverriddenIn(site, sym);
-         default: // this case includes erroneous combinations as well
-             return isAccessible(env, site, checkInner) && notOverriddenIn(site, sym);
+         ClassSymbol enclosingCsym = env.enclClass.sym;
+         try {
+             switch ((short)(sym.flags() & AccessFlags)) {
+                 case PRIVATE:
+                     return
+                             (env.enclClass.sym == sym.owner // fast special case
+                                     ||
+                                     env.enclClass.sym.outermostClass() ==
+                                     sym.owner.outermostClass()
+                                     ||
+                                     privateMemberInPermitsClauseIfAllowed(env, sym))
+                                 &&
+                                     sym.isInheritedIn(site.tsym, types);
+                 case 0:
+                     return
+                             (env.toplevel.packge == sym.owner.owner // fast special case
+                                     ||
+                                     env.toplevel.packge == sym.packge())
+                                     &&
+                                     isAccessible(env, site, checkInner)
+                                     &&
+                                     sym.isInheritedIn(site.tsym, types)
+                                     &&
+                                     notOverriddenIn(site, sym);
+                 case PROTECTED:
+                     return
+                             (env.toplevel.packge == sym.owner.owner // fast special case
+                                     ||
+                                     env.toplevel.packge == sym.packge()
+                                     ||
+                                     isProtectedAccessible(sym, env.enclClass.sym, site)
+                                     ||
+                                     // OK to select instance method or field from 'super' or type name
+                                     // (but type names should be disallowed elsewhere!)
+                                     env.info.selectSuper && (sym.flags() & STATIC) == 0 && sym.kind != TYP)
+                                     &&
+                                     isAccessible(env, site, checkInner)
+                                     &&
+                                     notOverriddenIn(site, sym);
+                 default: // this case includes erroneous combinations as well
+                     return isAccessible(env, site, checkInner) && notOverriddenIn(site, sym);
+             }
+         } finally {
+             env.enclClass.sym = enclosingCsym;
          }
      }
  
      private boolean privateMemberInPermitsClauseIfAllowed(Env<AttrContext> env, Symbol sym) {
          return allowPrivateMembersInPermitsClause &&

@@ -1528,12 +1533,15 @@
                  if (sym.kind == VAR &&
                          sym.owner.kind == TYP &&
                          (sym.flags() & STATIC) == 0) {
                      if (staticOnly)
                          return new StaticError(sym);
-                     if (env1.info.ctorPrologue && !isAllowedEarlyReference(pos, env1, (VarSymbol)sym))
-                         return new RefBeforeCtorCalledError(sym);
+                     if (env1.info.ctorPrologue && !isAllowedEarlyReference(pos, env1, (VarSymbol)sym)) {
+                         if (!env.tree.hasTag(ASSIGN) || !TreeInfo.isIdentOrThisDotIdent(((JCAssign)env.tree).lhs)) {
+                             return new RefBeforeCtorCalledError(sym);
+                         }
+                     }
                  }
                  return sym;
              } else {
                  bestSoFar = bestOf(bestSoFar, sym);
              }

@@ -4310,11 +4318,10 @@
                      return diags.create(dkind, log.currentSource(), pos,
                                "cant.apply.symbol.noargs",
                                rewriter,
                                kindName(ws),
                                ws.name == names.init ? ws.owner.name : ws.name,
-                               kindName(ws.owner),
                                ws.owner.type,
                                c.snd);
                  default:
                      // Avoid saying "constructor Array in class Array"
                      if (ws.owner == syms.arrayClass && ws.name == names.init) {

@@ -5207,13 +5214,9 @@
          }
  
          DeferredAttr.AttrMode attrMode() {
              return attrMode;
          }
- 
-         boolean internal() {
-             return internalResolution;
-         }
      }
  
      MethodResolutionContext currentResolutionContext = null;
  }
< prev index next >