862 Module m = c.getModule();
863 // add read edge and qualified export for the target module to access
864 if (!target.canRead(m)) {
865 Modules.addReads(target, m);
866 }
867 String pn = c.getPackageName();
868 if (!m.isExported(pn, target)) {
869 Modules.addExports(m, pn, target);
870 }
871 }
872
873 /*
874 * Ensure the given class is visible to the class loader.
875 */
876 private static void ensureVisible(ClassLoader ld, Class<?> c) {
877 Class<?> type = null;
878 try {
879 type = Class.forName(c.getName(), false, ld);
880 } catch (ClassNotFoundException e) {
881 }
882 if (type != c) {
883 throw new IllegalArgumentException(c.getName() +
884 " referenced from a method is not visible from class loader");
885 }
886 }
887
888 private static Class<?> getElementType(Class<?> type) {
889 Class<?> e = type;
890 while (e.isArray()) {
891 e = e.getComponentType();
892 }
893 return e;
894 }
895
896 private static final ClassLoaderValue<Module> dynProxyModules =
897 new ClassLoaderValue<>();
898 private static final AtomicInteger counter = new AtomicInteger();
899
900 /*
901 * Define a dynamic module with a packge named $MODULE which
902 * is unconditionally exported and another package named
|
862 Module m = c.getModule();
863 // add read edge and qualified export for the target module to access
864 if (!target.canRead(m)) {
865 Modules.addReads(target, m);
866 }
867 String pn = c.getPackageName();
868 if (!m.isExported(pn, target)) {
869 Modules.addExports(m, pn, target);
870 }
871 }
872
873 /*
874 * Ensure the given class is visible to the class loader.
875 */
876 private static void ensureVisible(ClassLoader ld, Class<?> c) {
877 Class<?> type = null;
878 try {
879 type = Class.forName(c.getName(), false, ld);
880 } catch (ClassNotFoundException e) {
881 }
882 if (type.asPrimaryType() != c.asPrimaryType()) {
883 throw new IllegalArgumentException(c.getName() +
884 " referenced from a method is not visible from class loader");
885 }
886 }
887
888 private static Class<?> getElementType(Class<?> type) {
889 Class<?> e = type;
890 while (e.isArray()) {
891 e = e.getComponentType();
892 }
893 return e;
894 }
895
896 private static final ClassLoaderValue<Module> dynProxyModules =
897 new ClassLoaderValue<>();
898 private static final AtomicInteger counter = new AtomicInteger();
899
900 /*
901 * Define a dynamic module with a packge named $MODULE which
902 * is unconditionally exported and another package named
|