Merge
authorddehaven
Tue, 06 Oct 2015 07:35:16 -0700
changeset 32877 b22f84a6b9d7
parent 32876 650e7f1dc0fc (current diff)
parent 32856 c654cdf1d685 (diff)
child 32878 8b3f72ecd702
Merge
--- a/jdk/src/java.base/linux/classes/sun/nio/ch/EPollSelectorImpl.java	Mon Oct 05 13:45:50 2015 -0700
+++ b/jdk/src/java.base/linux/classes/sun/nio/ch/EPollSelectorImpl.java	Tue Oct 06 07:35:16 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,9 +65,23 @@
         long pipeFds = IOUtil.makePipe(false);
         fd0 = (int) (pipeFds >>> 32);
         fd1 = (int) pipeFds;
-        pollWrapper = new EPollArrayWrapper();
-        pollWrapper.initInterrupt(fd0, fd1);
-        fdToKey = new HashMap<>();
+        try {
+            pollWrapper = new EPollArrayWrapper();
+            pollWrapper.initInterrupt(fd0, fd1);
+            fdToKey = new HashMap<>();
+        } catch (Throwable t) {
+            try {
+                FileDispatcherImpl.closeIntFD(fd0);
+            } catch (IOException ioe0) {
+                t.addSuppressed(ioe0);
+            }
+            try {
+                FileDispatcherImpl.closeIntFD(fd1);
+            } catch (IOException ioe1) {
+                t.addSuppressed(ioe1);
+            }
+            throw t;
+        }
     }
 
     protected int doSelect(long timeout) throws IOException {
--- a/jdk/src/java.base/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java	Mon Oct 05 13:45:50 2015 -0700
+++ b/jdk/src/java.base/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java	Tue Oct 06 07:35:16 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,10 +84,24 @@
         long fds = IOUtil.makePipe(false);
         fd0 = (int)(fds >>> 32);
         fd1 = (int)fds;
-        kqueueWrapper = new KQueueArrayWrapper();
-        kqueueWrapper.initInterrupt(fd0, fd1);
-        fdMap = new HashMap<>();
-        totalChannels = 1;
+        try {
+            kqueueWrapper = new KQueueArrayWrapper();
+            kqueueWrapper.initInterrupt(fd0, fd1);
+            fdMap = new HashMap<>();
+            totalChannels = 1;
+        } catch (Throwable t) {
+            try {
+                FileDispatcherImpl.closeIntFD(fd0);
+            } catch (IOException ioe0) {
+                t.addSuppressed(ioe0);
+            }
+            try {
+                FileDispatcherImpl.closeIntFD(fd1);
+            } catch (IOException ioe1) {
+                t.addSuppressed(ioe1);
+            }
+            throw t;
+        }
     }
 
 
--- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageFileCreator.java	Mon Oct 05 13:45:50 2015 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageFileCreator.java	Tue Oct 06 07:35:16 2015 -0700
@@ -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;
     }
 
--- a/jdk/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java	Mon Oct 05 13:45:50 2015 -0700
+++ b/jdk/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java	Tue Oct 06 07:35:16 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,9 +68,23 @@
         long pipeFds = IOUtil.makePipe(false);
         fd0 = (int) (pipeFds >>> 32);
         fd1 = (int) pipeFds;
-        pollWrapper = new DevPollArrayWrapper();
-        pollWrapper.initInterrupt(fd0, fd1);
-        fdToKey = new HashMap<Integer,SelectionKeyImpl>();
+        try {
+            pollWrapper = new DevPollArrayWrapper();
+            pollWrapper.initInterrupt(fd0, fd1);
+            fdToKey = new HashMap<>();
+        } catch (Throwable t) {
+            try {
+                FileDispatcherImpl.closeIntFD(fd0);
+            } catch (IOException ioe0) {
+                t.addSuppressed(ioe0);
+            }
+            try {
+                FileDispatcherImpl.closeIntFD(fd1);
+            } catch (IOException ioe1) {
+                t.addSuppressed(ioe1);
+            }
+            throw t;
+        }
     }
 
     protected int doSelect(long timeout)
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java	Mon Oct 05 13:45:50 2015 -0700
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java	Tue Oct 06 07:35:16 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,9 +57,23 @@
         long pipeFds = IOUtil.makePipe(false);
         fd0 = (int) (pipeFds >>> 32);
         fd1 = (int) pipeFds;
-        pollWrapper = new PollArrayWrapper(INIT_CAP);
-        pollWrapper.initInterrupt(fd0, fd1);
-        channelArray = new SelectionKeyImpl[INIT_CAP];
+        try {
+            pollWrapper = new PollArrayWrapper(INIT_CAP);
+            pollWrapper.initInterrupt(fd0, fd1);
+            channelArray = new SelectionKeyImpl[INIT_CAP];
+        } catch (Throwable t) {
+            try {
+                FileDispatcherImpl.closeIntFD(fd0);
+            } catch (IOException ioe0) {
+                t.addSuppressed(ioe0);
+            }
+            try {
+                FileDispatcherImpl.closeIntFD(fd1);
+            } catch (IOException ioe1) {
+                t.addSuppressed(ioe1);
+            }
+            throw t;
+        }
     }
 
     protected int doSelect(long timeout)