< prev index next >

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

Print this page

        

@@ -91,10 +91,11 @@
     private final Name dollarAssertionsDisabled;
     private final Name classDollar;
     private final Name dollarCloseResource;
     private final Types types;
     private final boolean debugLower;
+    private final boolean disableProtectedAccessors; // experimental
     private final PkgInfo pkginfoOpt;
 
     protected Lower(Context context) {
         context.put(lowerKey, this);
         names = Names.instance(context);

@@ -119,10 +120,11 @@
 
         types = Types.instance(context);
         Options options = Options.instance(context);
         debugLower = options.isSet("debuglower");
         pkginfoOpt = PkgInfo.get(options);
+        disableProtectedAccessors = options.isSet("disableProtectedAccessors");
     }
 
     /** The currently enclosing class.
      */
     ClassSymbol currentClass;

@@ -1004,10 +1006,13 @@
     }
 
     /** Do we need an access method to reference private symbol?
      */
     boolean needsPrivateAccess(Symbol sym) {
+        if (target.hasNestmateAccess()) {
+            return false;
+        }
         if ((sym.flags() & PRIVATE) == 0 || sym.owner == currentClass) {
             return false;
         } else if (sym.name == names.init && sym.owner.isLocal()) {
             // private constructor in local class: relax protection
             sym.flags_field &= ~PRIVATE;

@@ -1018,10 +1023,11 @@
     }
 
     /** Do we need an access method to reference symbol in other package?
      */
     boolean needsProtectedAccess(Symbol sym, JCTree tree) {
+        if (disableProtectedAccessors) return false;
         if ((sym.flags() & PROTECTED) == 0 ||
             sym.owner.owner == currentClass.owner || // fast special case
             sym.packge() == currentClass.packge())
             return false;
         if (!currentClass.isSubClass(sym.owner, types))
< prev index next >