equal
deleted
inserted
replaced
92 private final Name dollarAssertionsDisabled; |
92 private final Name dollarAssertionsDisabled; |
93 private final Name classDollar; |
93 private final Name classDollar; |
94 private final Name dollarCloseResource; |
94 private final Name dollarCloseResource; |
95 private final Types types; |
95 private final Types types; |
96 private final boolean debugLower; |
96 private final boolean debugLower; |
|
97 private final boolean disableProtectedAccessors; // experimental |
97 private final PkgInfo pkginfoOpt; |
98 private final PkgInfo pkginfoOpt; |
98 |
99 |
99 protected Lower(Context context) { |
100 protected Lower(Context context) { |
100 context.put(lowerKey, this); |
101 context.put(lowerKey, this); |
101 names = Names.instance(context); |
102 names = Names.instance(context); |
120 |
121 |
121 types = Types.instance(context); |
122 types = Types.instance(context); |
122 Options options = Options.instance(context); |
123 Options options = Options.instance(context); |
123 debugLower = options.isSet("debuglower"); |
124 debugLower = options.isSet("debuglower"); |
124 pkginfoOpt = PkgInfo.get(options); |
125 pkginfoOpt = PkgInfo.get(options); |
|
126 disableProtectedAccessors = options.isSet("disableProtectedAccessors"); |
125 } |
127 } |
126 |
128 |
127 /** The currently enclosing class. |
129 /** The currently enclosing class. |
128 */ |
130 */ |
129 ClassSymbol currentClass; |
131 ClassSymbol currentClass; |
1029 } |
1031 } |
1030 |
1032 |
1031 /** Do we need an access method to reference private symbol? |
1033 /** Do we need an access method to reference private symbol? |
1032 */ |
1034 */ |
1033 boolean needsPrivateAccess(Symbol sym) { |
1035 boolean needsPrivateAccess(Symbol sym) { |
|
1036 if (target.hasNestmateAccess()) { |
|
1037 return false; |
|
1038 } |
1034 if ((sym.flags() & PRIVATE) == 0 || sym.owner == currentClass) { |
1039 if ((sym.flags() & PRIVATE) == 0 || sym.owner == currentClass) { |
1035 return false; |
1040 return false; |
1036 } else if (sym.name == names.init && sym.owner.isLocal()) { |
1041 } else if (sym.name == names.init && sym.owner.isLocal()) { |
1037 // private constructor in local class: relax protection |
1042 // private constructor in local class: relax protection |
1038 sym.flags_field &= ~PRIVATE; |
1043 sym.flags_field &= ~PRIVATE; |
1043 } |
1048 } |
1044 |
1049 |
1045 /** Do we need an access method to reference symbol in other package? |
1050 /** Do we need an access method to reference symbol in other package? |
1046 */ |
1051 */ |
1047 boolean needsProtectedAccess(Symbol sym, JCTree tree) { |
1052 boolean needsProtectedAccess(Symbol sym, JCTree tree) { |
|
1053 if (disableProtectedAccessors) return false; |
1048 if ((sym.flags() & PROTECTED) == 0 || |
1054 if ((sym.flags() & PROTECTED) == 0 || |
1049 sym.owner.owner == currentClass.owner || // fast special case |
1055 sym.owner.owner == currentClass.owner || // fast special case |
1050 sym.packge() == currentClass.packge()) |
1056 sym.packge() == currentClass.packge()) |
1051 return false; |
1057 return false; |
1052 if (!currentClass.isSubClass(sym.owner, types)) |
1058 if (!currentClass.isSubClass(sym.owner, types)) |