< prev index next >

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

Print this page
@@ -417,47 +417,52 @@
          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())
-                 &&
-                 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())
+                                     &&
+                                     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;
          }
      }
      //where
      /* `sym' is accessible only if not overridden by
       * another symbol which is a member of `site'

@@ -1517,12 +1522,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);
              }

@@ -4299,11 +4307,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) {

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