--- old/src/hotspot/share/classfile/verificationType.cpp 2019-01-09 15:17:18.248992440 -0500 +++ new/src/hotspot/share/classfile/verificationType.cpp 2019-01-09 15:17:17.740395427 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -111,6 +111,9 @@ VerificationType comp_this = get_component(context, CHECK_false); VerificationType comp_from = from.get_component(context, CHECK_false); + // This code implements non-covariance between value type arrays and both + // arrays of objects and arrays of interface types. If covariance is + // supported for value type arrays then this code should be removed. if (comp_from.is_valuetype() && !comp_this.is_null() && comp_this.is_reference()) { // An array of value types is not assignable to an array of java.lang.Objects. if (comp_this.name() == vmSymbols::java_lang_Object()) { --- old/test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/VerifierValueTypes.java 2019-01-09 15:17:19.510008434 -0500 +++ new/test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/VerifierValueTypes.java 2019-01-09 15:17:19.000637230 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -35,9 +35,10 @@ System.out.println("Testing: " + test_name); try { Class newClass = Class.forName(test_name); + throw new RuntimeException("Expected VerifyError exception not thrown"); } catch (java.lang.VerifyError e) { if (!e.getMessage().contains(message)) { - throw new RuntimeException( "Wrong VerifyError: " + e.getMessage()); + throw new RuntimeException("Wrong VerifyError: " + e.getMessage()); } } } @@ -46,9 +47,10 @@ System.out.println("Testing: " + test_name); try { Class newClass = Class.forName(test_name); + throw new RuntimeException("Expected ClassFormatError exception not thrown"); } catch (java.lang.ClassFormatError e) { if (!e.getMessage().contains(message)) { - throw new RuntimeException( "Wrong ClassFormatError: " + e.getMessage()); + throw new RuntimeException("Wrong ClassFormatError: " + e.getMessage()); } } } @@ -96,11 +98,11 @@ // Test VerifyError is thrown if a withfield's class operand is not a value type. runTestVerifyError("withfieldObj", "Bad type on operand stack"); - // Test that an array of value types is not assignable to [Ljava/lang/Object;. + // Test that an array of value types is not assignable to [Ljava/lang/Object; (Non-covariance). runTestVerifyError("NoArrayCov", "Type '[QNoArrayCov;' (current frame, stack[1]) is not assignable to '[Ljava/lang/Object;'"); - // Test that an array of value types is not assignable to an array of interfaces. + // Test that an array of value types is not assignable to an array of interfaces (Non-covariance). runTestVerifyError("NoArrayCovIntf", "Type '[QNoArrayCovIntf;' (current frame, stack[1]) is not assignable to '[LII;'");