changeset 58544:9d2ec504577f lworld

8237057: [lworld] Upgrade lambda proxy classes to class file version 58
author mchung
date Mon, 13 Jan 2020 17:18:47 -0800
parents 8901f6c4bfd0
children 57fcdeb4a5b2
files src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java test/jdk/valhalla/valuetypes/StreamTest.java
diffstat 2 files changed, 86 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java	Thu Jan 09 09:31:46 2020 -0500
+++ b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java	Mon Jan 13 17:18:47 2020 -0800
@@ -53,9 +53,8 @@
  */
 /* package */ final class InnerClassLambdaMetafactory extends AbstractValidatingLambdaMetafactory {
     private static final Unsafe UNSAFE = Unsafe.getUnsafe();
-    private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
 
-    private static final int CLASSFILE_VERSION = 52;
+    private static final int CLASSFILE_VERSION = V14;
     private static final String METHOD_DESCRIPTOR_VOID = Type.getMethodDescriptor(Type.VOID_TYPE);
     private static final String JAVA_LANG_OBJECT = "java/lang/Object";
     private static final String NAME_CTOR = "<init>";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/valhalla/valuetypes/StreamTest.java	Mon Jan 13 17:18:47 2020 -0800
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2020, 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
+ * @summary Basic test for Array::get, Array::set, Arrays::setAll on inline class array
+ * @compile -XDallowGenericsOverValues StreamTest.java
+ * @run testng StreamTest
+ */
+
+import java.util.Arrays;
+import java.util.stream.*;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+public class StreamTest {
+    final Value[] values = init();
+    private Value[] init() {
+        Value[] values = new Value[10];
+        for (int i = 0; i < 10; i++) {
+            values[i] = new Value(i, new Point(i,i*2), (i%2) == 0 ? null : new Point(i*10, i*20));
+        }
+        return values;
+    }
+
+    @Test
+    public void testPrimitive() {
+        Arrays.stream(values)
+              .filter(v -> (v.i % 2) == 0)
+              .forEach(System.out::println);
+    }
+
+    @Test
+    public void testInlineType() {
+        Arrays.stream(values)
+                .map(Value::point)
+                .filter(p -> p.x >= 5)
+                .forEach(System.out::println);
+
+        Arrays.stream(values)
+                .map(Value::nullablePoint)
+                .filter(p -> p != null)
+                .forEach(System.out::println);
+    }
+
+    static inline class Value {
+        int i;
+        Point p;
+        Point? nullable;
+        Value(int i, Point p, Point? np) {
+            this.i = i;
+            this.p = p;
+            this.nullable = np;
+        }
+
+        Point point() {
+            return p;
+        }
+
+        Point? nullablePoint() {
+            return nullable;
+        }
+    }
+}