1364 List<ModuleLayer> parents) { 1365 Module m = nameToSource.get(target); 1366 if (m == null) { 1367 m = nameToModule.get(target); 1368 if (m == null) { 1369 for (ModuleLayer parent : parents) { 1370 m = parent.findModule(target).orElse(null); 1371 if (m != null) break; 1372 } 1373 } 1374 } 1375 return m; 1376 } 1377 1378 1379 // -- annotations -- 1380 1381 /** 1382 * {@inheritDoc} 1383 * This method returns {@code null} when invoked on an unnamed module. 1384 */ 1385 @Override 1386 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { 1387 return moduleInfoClass().getDeclaredAnnotation(annotationClass); 1388 } 1389 1390 /** 1391 * {@inheritDoc} 1392 * This method returns an empty array when invoked on an unnamed module. 1393 */ 1394 @Override 1395 public Annotation[] getAnnotations() { 1396 return moduleInfoClass().getAnnotations(); 1397 } 1398 1399 /** 1400 * {@inheritDoc} 1401 * This method returns an empty array when invoked on an unnamed module. 1402 */ 1403 @Override 1404 public Annotation[] getDeclaredAnnotations() { 1405 return moduleInfoClass().getDeclaredAnnotations(); 1406 } 1407 1408 // cached class file with annotations 1409 private volatile Class<?> moduleInfoClass; 1410 1411 private Class<?> moduleInfoClass() { 1412 Class<?> clazz = this.moduleInfoClass; 1413 if (clazz != null) 1414 return clazz; 1415 1416 synchronized (this) { 1417 clazz = this.moduleInfoClass; 1418 if (clazz == null) { 1419 if (isNamed()) { 1420 PrivilegedAction<Class<?>> pa = this::loadModuleInfoClass; | 1364 List<ModuleLayer> parents) { 1365 Module m = nameToSource.get(target); 1366 if (m == null) { 1367 m = nameToModule.get(target); 1368 if (m == null) { 1369 for (ModuleLayer parent : parents) { 1370 m = parent.findModule(target).orElse(null); 1371 if (m != null) break; 1372 } 1373 } 1374 } 1375 return m; 1376 } 1377 1378 1379 // -- annotations -- 1380 1381 /** 1382 * {@inheritDoc} 1383 * This method returns {@code null} when invoked on an unnamed module. 1384 * <p>Note that any annotation returned by this method is a 1385 * declaration annotation. 1386 */ 1387 @Override 1388 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { 1389 return moduleInfoClass().getDeclaredAnnotation(annotationClass); 1390 } 1391 1392 /** 1393 * {@inheritDoc} 1394 * <p>Note that any annotations returned by this method are 1395 * declaration annotations. 1396 * This method returns an empty array when invoked on an unnamed module. 1397 */ 1398 @Override 1399 public Annotation[] getAnnotations() { 1400 return moduleInfoClass().getAnnotations(); 1401 } 1402 1403 /** 1404 * {@inheritDoc} 1405 * <p>Note that any annotations returned by this method are 1406 * declaration annotations. 1407 * This method returns an empty array when invoked on an unnamed module. 1408 */ 1409 @Override 1410 public Annotation[] getDeclaredAnnotations() { 1411 return moduleInfoClass().getDeclaredAnnotations(); 1412 } 1413 1414 // cached class file with annotations 1415 private volatile Class<?> moduleInfoClass; 1416 1417 private Class<?> moduleInfoClass() { 1418 Class<?> clazz = this.moduleInfoClass; 1419 if (clazz != null) 1420 return clazz; 1421 1422 synchronized (this) { 1423 clazz = this.moduleInfoClass; 1424 if (clazz == null) { 1425 if (isNamed()) { 1426 PrivilegedAction<Class<?>> pa = this::loadModuleInfoClass; |