--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java 2018-06-20 00:54:29.851316079 -0400 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java 2018-06-20 00:54:28.331228549 -0400 @@ -94,6 +94,7 @@ 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) { @@ -122,6 +123,7 @@ Options options = Options.instance(context); debugLower = options.isSet("debuglower"); pkginfoOpt = PkgInfo.get(options); + disableProtectedAccessors = options.isSet("disableProtectedAccessors"); } /** The currently enclosing class. @@ -1031,6 +1033,9 @@ /** 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()) { @@ -1045,6 +1050,7 @@ /** 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())