changeset 47421:b87d7b5d5ded jdk-10+27

8189209: java/lang/invoke/lambda/LambdaAsm.java failed with "could not create proxy classes" Summary: Use an inner class for the closer instead of a lambda Reviewed-by: alanb, rriggs
author bpb
date Thu, 12 Oct 2017 10:28:20 -0700
parents 39d1de71faca
children dcd8a022b933 60922e959a98 bb7e023e52fd 194bc551c790 ed6b1ad2cb86 0c2e5ef6a1c6 89e5860b4e33
files src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java	Thu Oct 12 16:00:29 2017 +0200
+++ b/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java	Thu Oct 12 10:28:20 2017 -0700
@@ -90,6 +90,18 @@
     // Cleanable with an action which closes this channel's file descriptor
     private final Cleanable closer;
 
+    private static class Closer implements Runnable {
+        private final FileDescriptor fd;
+
+        Closer(FileDescriptor fd) {
+            this.fd = fd;
+        }
+
+        public void run() {
+            fdAccess.close(fd);
+        }
+    }
+
     private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
                             boolean writable, Object parent)
     {
@@ -101,8 +113,10 @@
         this.nd = new FileDispatcherImpl();
         // Register a cleaning action if and only if there is no parent
         // as the parent will take care of closing the file descriptor.
-        this.closer= parent != null ? null :
-            CleanerFactory.cleaner().register(this, () -> fdAccess.close(fd));
+        // FileChannel is used by the LambdaMetaFactory so a lambda cannot
+        // be used here hence we use a nested class instead.
+        this.closer = parent != null ? null :
+            CleanerFactory.cleaner().register(this, new Closer(fd));
     }
 
     // Used by FileInputStream.getChannel(), FileOutputStream.getChannel