changeset 32855:452710dfb667

8136365: Provider "jrt" is not available after bootmodules.jimage recreation Summary: META-INF content was lost during recreate. Reviewed-by: jlaskey, sundar
author jfdenise
date Tue, 06 Oct 2015 09:12:00 +0200
parents f29975c5b3c1
children c654cdf1d685
files jdk/src/java.base/share/classes/jdk/internal/jimage/ImageFileCreator.java
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageFileCreator.java	Mon Oct 05 08:16:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageFileCreator.java	Tue Oct 06 09:12:00 2015 +0200
@@ -261,6 +261,7 @@
             Map<String, List<Entry>> entriesForModule,
             ByteOrder byteOrder) throws IOException {
         ResourcePoolImpl resources = new ResourcePoolImpl(byteOrder);
+        // Doesn't contain META-INF
         Set<String> mods = modulePackagesMap.keySet();
         for (String mn : mods) {
             for (Entry entry : entriesForModule.get(mn)) {
@@ -286,6 +287,31 @@
             Archive archive = nameToArchive.get(mn);
             archive.close();
         }
+        // Fix for 8136365. Do we have an archive with module name "META-INF"?
+        // If yes, we are recreating a jimage.
+        // This is a workaround for META-INF being at the top level of resource path
+        String mn = "META-INF";
+        Archive archive = nameToArchive.get(mn);
+        if (archive != null) {
+            try {
+                for (Entry entry : entriesForModule.get(mn)) {
+                    String path = entry.name();
+                    try (InputStream stream = entry.stream()) {
+                        byte[] bytes = readAllBytes(stream);
+                        path = mn + "/" + path;
+                        try {
+                            resources.addResource(new ResourcePool.Resource(path,
+                                    ByteBuffer.wrap(bytes)));
+                        } catch (Exception ex) {
+                            throw new IOException(ex);
+                        }
+                    }
+                }
+            } finally {
+                // Done with this archive, close it.
+                archive.close();
+            }
+        }
         return resources;
     }