changeset 13571:e310798b834d mvt

8185673: assertion failure when creating an array of empty value type Summary: throw ClassFormatError for empty value type instances Reviewed-by: thartmann
author dsimms
date Fri, 25 Aug 2017 12:19:05 +0200
parents 4f5042758ccc
children df4d4ef05b87
files src/share/vm/classfile/classFileParser.cpp test/runtime/valhalla/valuetypes/Empty.java
diffstat 2 files changed, 58 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/classFileParser.cpp	Thu Aug 24 14:49:23 2017 +0200
+++ b/src/share/vm/classfile/classFileParser.cpp	Fri Aug 25 12:19:05 2017 +0200
@@ -4000,6 +4000,13 @@
     super_has_nonstatic_fields || (nonstatic_fields_count != 0);
   const bool has_nonstatic_value_fields = nonstatic_value_type_count > 0;
 
+  if (is_value_type() && (!has_nonstatic_fields)) {
+    // There are a number of fixes required throughout the type system and JIT
+    if (class_name() != vmSymbols::java_lang____Value()) {
+      throwValueTypeLimitation(THREAD_AND_LOCATION, "Value Types do not support zero instance size yet");
+    }
+  }
+
   // Prepare list of oops for oop map generation.
   //
   // "offset" and "count" lists are describing the set of contiguous oop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/valhalla/valuetypes/Empty.java	Fri Aug 25 12:19:05 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+package runtime.valhalla.valuetypes;
+
+__ByValue final class EmptyValue {
+
+    private EmptyValue() {
+    }
+
+    __ValueFactory public static EmptyValue createEmptyValue() {
+	EmptyValue e = __MakeDefault EmptyValue();
+	return e;
+    }
+}
+
+/**
+ * @test Empty
+ * @summary Test empty value type
+ * @compile -XDenableValueTypes Empty.java
+ * @run main/othervm -Xint -noverify -XX:+EnableValhalla runtime.valhalla.valuetypes.Empty
+ * @run main/othervm -Xcomp -noverify -XX:+EnableValhalla runtime.valhalla.valuetypes.Empty
+ */
+public class Empty {
+    public static void main(String[] args) {
+        try {
+            EmptyValue.createEmptyValue();
+            throw new RuntimeException("Excepted class file parse error");
+        } catch (ClassFormatError cfe) {}
+    }
+}