changeset 17314:c7a227b5f650

Merge
author asaha
date Thu, 27 Jul 2017 13:59:57 -0700
parents 94378d697bf4 bd66ea2fdde3
children 9a7bdc3ff45d
files .hgtags
diffstat 6 files changed, 188 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Jul 25 22:25:18 2017 -0700
+++ b/.hgtags	Thu Jul 27 13:59:57 2017 -0700
@@ -421,6 +421,9 @@
 e6c4f6ef717d104dba880e2dae538690c993b46f jdk-9+175
 9f27d513658d5375b0e26846857d92563f279073 jdk-9+176
 80acf577b7d0b886fb555c9916552844f6cc72af jdk-9+177
+443025bee731eb2225371b92c1c74b519b7baf33 jdk-9+178
+06df1ce4b9b887d05ce6a13f4def3547e434dd1a jdk-9+179
+4feab1acec6a9c3620a19ff379a65ab8618d0e2a jdk-9+180
 383a0001f6a0981aa061bf62d7562240abec0b18 jdk-9.0.3+1
 77eba1b12ee981b9d7e6b10b33b233669a1cb23e jdk-9.0.3+2
 f13da3f2da08667ff74541440bb5d67b2dad1aa9 jdk-9.0.3+3
--- a/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Tue Jul 25 22:25:18 2017 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Thu Jul 27 13:59:57 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, 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
@@ -879,9 +879,9 @@
         System.arraycopy(lambdaForm.names, skip + outArgs, names2, skip + inTypes, bodyLength);
         int arity2 = names2.length - bodyLength;
         int result2 = lambdaForm.result;
-        if (result2 >= 0) {
+        if (result2 >= skip) {
             if (result2 < skip + outArgs) {
-                result2 = reorder[result2 - skip];
+                result2 = reorder[result2 - skip] + skip;
             } else {
                 result2 = result2 - outArgs + inTypes;
             }
--- a/src/java.base/share/native/libzip/zlib/deflate.c	Tue Jul 25 22:25:18 2017 -0700
+++ b/src/java.base/share/native/libzip/zlib/deflate.c	Thu Jul 27 13:59:57 2017 -0700
@@ -505,6 +505,8 @@
     s->pending = 0;
     s->pending_out = s->pending_buf;
 
+    s->high_water = 0;      /* reset to its inital value 0 */
+
     if (s->wrap < 0) {
         s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
     }
--- a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java	Tue Jul 25 22:25:18 2017 -0700
+++ b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java	Thu Jul 27 13:59:57 2017 -0700
@@ -76,6 +76,21 @@
 >                 n = len;
 --------------------------
 
+(6) deflate.c  #8184306
 
+*** 503,512 ****
+--- 503,514 ----
+  
+      s = (deflate_state *)strm->state;
+      s->pending = 0;
+      s->pending_out = s->pending_buf;
+  
++     s->high_water = 0;      /* reset to its inital value 0 */
++ 
+      if (s->wrap < 0) {
+          s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
+      }
+      s->status =
+  #ifdef GZIP
 
   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/PermuteArgsReturnVoidTest.java	Thu Jul 27 13:59:57 2017 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2017, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8184119
+ * @summary test permutation when return value is directly derived from an argument
+ * @run testng/othervm test.java.lang.invoke.PermuteArgsReturnVoidTest
+ */
+
+
+package test.java.lang.invoke;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+import static java.lang.invoke.MethodHandles.dropArguments;
+import static java.lang.invoke.MethodHandles.identity;
+
+public class PermuteArgsReturnVoidTest {
+
+    static String consumeIdentity(String s, int i1, int i2) {
+        return s;
+    }
+
+    static void consumeVoid(String s, int i1, int i2) {
+    }
+
+    @Test
+    public void testReturnOnStack() throws Throwable {
+        MethodHandles.Lookup l = MethodHandles.lookup();
+
+        MethodHandle consumeIdentity = l.findStatic(
+                PermuteArgsReturnVoidTest.class, "consumeIdentity",
+                MethodType.methodType(String.class, String.class, int.class, int.class));
+        MethodHandle consumeVoid = l.findStatic(
+                PermuteArgsReturnVoidTest.class, "consumeVoid",
+                MethodType.methodType(void.class, String.class, int.class, int.class));
+
+        MethodHandle f = MethodHandles.foldArguments(consumeIdentity, consumeVoid);
+
+        MethodHandle p = MethodHandles.permuteArguments(f, MethodType.methodType(String.class, String.class, int.class, int.class), 0, 2, 1);
+
+        String s = (String) p.invoke("IN", 0, 0);
+        Assert.assertEquals(s.getClass(), String.class);
+        Assert.assertEquals(s, "IN");
+    }
+
+    @Test
+    public void testReturnFromArg() throws Throwable {
+        MethodHandles.Lookup l = MethodHandles.lookup();
+
+        MethodHandle consumeIdentity = dropArguments(
+                identity(String.class), 1, int.class, int.class);
+        MethodHandle consumeVoid = l.findStatic(
+                PermuteArgsReturnVoidTest.class, "consumeVoid",
+                MethodType.methodType(void.class, String.class, int.class, int.class));
+
+        MethodHandle f = MethodHandles.foldArguments(consumeIdentity, consumeVoid);
+
+        MethodHandle p = MethodHandles.permuteArguments(f, MethodType.methodType(String.class, String.class, int.class, int.class), 0, 2, 1);
+
+        String s = (String) p.invoke("IN", 0, 0);
+        Assert.assertEquals(s.getClass(), String.class);
+        Assert.assertEquals(s, "IN");
+    }
+}
--- a/test/java/util/zip/DeInflate.java	Tue Jul 25 22:25:18 2017 -0700
+++ b/test/java/util/zip/DeInflate.java	Thu Jul 27 13:59:57 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, 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
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 7110149
+ * @bug 7110149 8184306
  * @summary Test basic deflater & inflater functionality
  * @key randomness
  */
@@ -34,64 +34,110 @@
 
 public class DeInflate {
 
-    static void check(Deflater compresser, byte[] in, int len,
+    static void checkStream(Deflater def, byte[] in, int len,
+                            byte[] out1, byte[] out2, boolean nowrap)
+        throws Throwable
+    {
+        Arrays.fill(out1, (byte)0);
+        Arrays.fill(out2, (byte)0);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try (DeflaterOutputStream defos = new DeflaterOutputStream(baos, def)) {
+            defos.write(in, 0, len);
+        }
+        out1 = baos.toByteArray();
+        int m = out1.length;
+
+        Inflater inf = new Inflater(nowrap);
+        inf.setInput(out1, 0, m);
+        int n = inf.inflate(out2);
+
+        if (n != len ||
+            !Arrays.equals(Arrays.copyOf(in, len), Arrays.copyOf(out2, len)) ||
+            inf.inflate(out2) != 0) {
+            System.out.printf("m=%d, n=%d, len=%d, eq=%b%n",
+                              m, n, len, Arrays.equals(in, out2));
+            throw new RuntimeException("De/inflater failed:" + def);
+        }
+    }
+
+    static void check(Deflater def, byte[] in, int len,
                       byte[] out1, byte[] out2, boolean nowrap)
         throws Throwable
     {
         Arrays.fill(out1, (byte)0);
         Arrays.fill(out2, (byte)0);
 
-        compresser.setInput(in, 0, len);
-        compresser.finish();
-        int m = compresser.deflate(out1);
+        def.setInput(in, 0, len);
+        def.finish();
+        int m = def.deflate(out1);
 
-        Inflater decompresser = new Inflater(nowrap);
-        decompresser.setInput(out1, 0, m);
-        int n = decompresser.inflate(out2);
+        Inflater inf = new Inflater(nowrap);
+        inf.setInput(out1, 0, m);
+        int n = inf.inflate(out2);
 
         if (n != len ||
             !Arrays.equals(Arrays.copyOf(in, len), Arrays.copyOf(out2, len)) ||
-            decompresser.inflate(out2) != 0) {
+            inf.inflate(out2) != 0) {
             System.out.printf("m=%d, n=%d, len=%d, eq=%b%n",
                               m, n, len, Arrays.equals(in, out2));
-            throw new RuntimeException("De/inflater failed:" + compresser);
+            throw new RuntimeException("De/inflater failed:" + def);
         }
     }
 
+    private static Deflater newDeflater(int level, int strategy, boolean dowrap, byte[] tmp) {
+        Deflater def = new Deflater(level, dowrap);
+        if (strategy != Deflater.DEFAULT_STRATEGY) {
+            def.setStrategy(strategy);
+            // The first invocation after setLevel/Strategy()
+            // with a different level/stragety returns 0, if
+            // there is no need to flush out anything for the
+            // previous setting/"data", this is tricky and
+            // appears un-documented.
+            def.deflate(tmp);
+        }
+        return def;
+    }
+
+    private static Deflater resetDeflater(Deflater def, int level, int strategy) {
+        def.setLevel(level);
+        def.setStrategy(strategy);
+        def.reset();
+        return def;
+    }
+
     public static void main(String[] args) throws Throwable {
+
         byte[] dataIn = new byte[1024 * 512];
         new Random().nextBytes(dataIn);
         byte[] dataOut1 = new byte[dataIn.length + 1024];
         byte[] dataOut2 = new byte[dataIn.length];
-        boolean wrap[] = new boolean[] { false, true };
+
+        Deflater defNotWrap = new Deflater(Deflater.DEFAULT_COMPRESSION, false);
+        Deflater defWrap = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
 
         for (int level = Deflater.DEFAULT_COMPRESSION;
                  level <= Deflater.BEST_COMPRESSION; level++) {
-            System.out.print("level=" + level + ", strategy= ");
             for (int strategy = Deflater.DEFAULT_STRATEGY;
                      strategy <= Deflater.HUFFMAN_ONLY; strategy++) {
-                System.out.print(" " + strategy + " nowrap[");
-                for (int dowrap = 0; dowrap <= 1; dowrap++) {
-                    System.out.print(" " + wrap[dowrap]);
+                for (boolean dowrap : new boolean[] { false, true }) {
+                    System.out.println("level:" + level +
+                                     ", strategy: " + strategy +
+                                     ", dowrap: " + dowrap);
                     for (int i = 0; i < 5; i++) {
-                        Deflater def = new Deflater(level, wrap[dowrap]);
-                        if (strategy != Deflater.DEFAULT_STRATEGY) {
-                            def.setStrategy(strategy);
-                            // The first invocation after setLevel/Strategy()
-                            // with a different level/stragety returns 0, if
-                            // there is no need to flush out anything for the
-                            // previous setting/"data", this is tricky and
-                            // appears un-documented.
-                            def.deflate(dataOut2);
-                        }
                         int len = (i == 0)? dataIn.length
                                           : new Random().nextInt(dataIn.length);
-                            check(def, dataIn, len, dataOut1, dataOut2, wrap[dowrap]);
+                        // use a new deflater
+                        Deflater def = newDeflater(level, strategy, dowrap, dataOut2);
+                        check(def, dataIn, len, dataOut1, dataOut2, dowrap);
+
+                        // reuse the deflater (with reset) and test on stream, which
+                        // uses a "smaller" buffer (smaller than the overall data)
+                        def = resetDeflater(dowrap ? defWrap : defNotWrap, level, strategy);
+                        checkStream(def, dataIn, len, dataOut1, dataOut2, dowrap);
                     }
                 }
-                System.out.print("] ");
             }
-            System.out.println();
         }
     }
 }