< prev index next >

src/java.base/share/classes/jdk/internal/module/ModulePatcher.java

Print this page




 132                             .map(path -> toPackageName(top, path))
 133                             .filter(Checks::isJavaIdentifier)
 134                             .forEach(packages::add);
 135 
 136                 }
 137             }
 138 
 139         } catch (IOException ioe) {
 140             throw new UncheckedIOException(ioe);
 141         }
 142 
 143         // if there are new packages then we need a new ModuleDescriptor
 144         Set<String> original = descriptor.packages();
 145         packages.addAll(original);
 146         if (packages.size() > original.size()) {
 147             descriptor = JLMA.newModuleDescriptor(descriptor, packages);
 148         }
 149 
 150         // return a module reference to the patched module
 151         URI location = mref.location().orElse(null);
 152         return JLMA.newPatchedModule(descriptor,






 153                                      location,
 154                                      () -> new PatchedModuleReader(paths, mref));




 155 
 156     }
 157 
 158     /**
 159      * Returns true is this module patcher has no patches.
 160      */
 161     public boolean isEmpty() {
 162         return map.isEmpty();
 163     }
 164 
 165 
 166     /**
 167      * A ModuleReader that reads resources from a patched module.
 168      *
 169      * This class is public so as to expose the findResource method to the
 170      * built-in class loaders and avoid locating the resource twice during
 171      * class loading (once to locate the resource, the second to gets the
 172      * URL for the CodeSource).
 173      */
 174     public static class PatchedModuleReader implements ModuleReader {




 132                             .map(path -> toPackageName(top, path))
 133                             .filter(Checks::isJavaIdentifier)
 134                             .forEach(packages::add);
 135 
 136                 }
 137             }
 138 
 139         } catch (IOException ioe) {
 140             throw new UncheckedIOException(ioe);
 141         }
 142 
 143         // if there are new packages then we need a new ModuleDescriptor
 144         Set<String> original = descriptor.packages();
 145         packages.addAll(original);
 146         if (packages.size() > original.size()) {
 147             descriptor = JLMA.newModuleDescriptor(descriptor, packages);
 148         }
 149 
 150         // return a module reference to the patched module
 151         URI location = mref.location().orElse(null);
 152 
 153         ModuleResolution mres = null;
 154         if (mref instanceof ModuleReferenceImpl) {
 155             mres = ((ModuleReferenceImpl)mref).moduleResolution();
 156         }
 157 
 158         return new ModuleReferenceImpl(descriptor,
 159                                        location,
 160                                        () -> new PatchedModuleReader(paths, mref),
 161                                        this,
 162                                        null,
 163                                        null,
 164                                        mres);
 165 
 166     }
 167 
 168     /**
 169      * Returns true is this module patcher has no patches.
 170      */
 171     public boolean isEmpty() {
 172         return map.isEmpty();
 173     }
 174 
 175 
 176     /**
 177      * A ModuleReader that reads resources from a patched module.
 178      *
 179      * This class is public so as to expose the findResource method to the
 180      * built-in class loaders and avoid locating the resource twice during
 181      * class loading (once to locate the resource, the second to gets the
 182      * URL for the CodeSource).
 183      */
 184     public static class PatchedModuleReader implements ModuleReader {


< prev index next >