211 // allow access to public types in all unconditionally exported packages
212 if ((allowedModes & UNCONDITIONAL_ALLOWED) != 0) {
213 return refModule.isExported(refc.getPackageName());
214 }
215
216 if (lookupModule == refModule && prevLookupClass == null) {
217 // allow access to all public types in lookupModule
218 if ((allowedModes & MODULE_ALLOWED) != 0)
219 return true;
220
221 assert (allowedModes & PUBLIC) != 0;
222 return refModule.isExported(refc.getPackageName());
223 }
224
225 // cross-module access
226 // 1. refc is in different module from lookupModule, or
227 // 2. refc is in lookupModule and a different module from prevLookupModule
228 Module prevLookupModule = prevLookupClass != null ? prevLookupClass.getModule()
229 : null;
230 assert refModule != lookupModule || refModule != prevLookupModule;
231 if (isModuleAccessible(refc, lookupModule, prevLookupModule))
232 return true;
233
234 // public class not accessible to lookupClass
235 return false;
236 }
237
238 return false;
239 }
240
241 /*
242 * Tests if a class or interface REFC is accessible to m1 and m2 where m2
243 * may be null.
244 *
245 * A class or interface REFC in m is accessible to m1 and m2 if and only if
246 * both m1 and m2 read m and m exports the package of REFC at least to
247 * both m1 and m2.
248 */
249 public static boolean isModuleAccessible(Class<?> refc, Module m1, Module m2) {
250 Module refModule = refc.getModule();
|
211 // allow access to public types in all unconditionally exported packages
212 if ((allowedModes & UNCONDITIONAL_ALLOWED) != 0) {
213 return refModule.isExported(refc.getPackageName());
214 }
215
216 if (lookupModule == refModule && prevLookupClass == null) {
217 // allow access to all public types in lookupModule
218 if ((allowedModes & MODULE_ALLOWED) != 0)
219 return true;
220
221 assert (allowedModes & PUBLIC) != 0;
222 return refModule.isExported(refc.getPackageName());
223 }
224
225 // cross-module access
226 // 1. refc is in different module from lookupModule, or
227 // 2. refc is in lookupModule and a different module from prevLookupModule
228 Module prevLookupModule = prevLookupClass != null ? prevLookupClass.getModule()
229 : null;
230 assert refModule != lookupModule || refModule != prevLookupModule;
231
232 if (isModuleAccessible(refc, lookupModule, prevLookupModule))
233 return true;
234
235 // public class not accessible to lookupClass
236 return false;
237 }
238
239 return false;
240 }
241
242 /*
243 * Tests if a class or interface REFC is accessible to m1 and m2 where m2
244 * may be null.
245 *
246 * A class or interface REFC in m is accessible to m1 and m2 if and only if
247 * both m1 and m2 read m and m exports the package of REFC at least to
248 * both m1 and m2.
249 */
250 public static boolean isModuleAccessible(Class<?> refc, Module m1, Module m2) {
251 Module refModule = refc.getModule();
|