From 13744cd098af65cce0426b9bb4acd6bf57a4b78d Mon Sep 17 00:00:00 2001 From: David Holmes Date: Thu, 3 Jul 2025 01:26:08 -0400 Subject: [PATCH 1/4] 8356942: invokeinterface Throws AbstractMethodError Instead of IncompatibleClassChangeError --- src/hotspot/share/oops/klassVtable.cpp | 72 +++++++++++++------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/src/hotspot/share/oops/klassVtable.cpp b/src/hotspot/share/oops/klassVtable.cpp index 20a8063771d97..108cf410e8823 100644 --- a/src/hotspot/share/oops/klassVtable.cpp +++ b/src/hotspot/share/oops/klassVtable.cpp @@ -1180,38 +1180,42 @@ void klassItable::check_constraints(GrowableArray* supers, TRAPS) { Method* interface_method = supers->at(i); // method overridden if (target != nullptr && interface_method != nullptr) { - InstanceKlass* method_holder = target->method_holder(); - InstanceKlass* interf = interface_method->method_holder(); - HandleMark hm(THREAD); - Handle method_holder_loader(THREAD, method_holder->class_loader()); - Handle interface_loader(THREAD, interf->class_loader()); - - if (method_holder_loader() != interface_loader()) { - ResourceMark rm(THREAD); - Symbol* failed_type_symbol = - SystemDictionary::check_signature_loaders(target->signature(), - _klass, - method_holder_loader, - interface_loader, - true); - if (failed_type_symbol != nullptr) { - stringStream ss; - ss.print("loader constraint violation in interface itable" - " initialization for class %s: when selecting method '", - _klass->external_name()); - interface_method->print_external_name(&ss), - ss.print("' the class loader %s for super interface %s, and the class" - " loader %s of the selected method's %s, %s have" - " different Class objects for the type %s used in the signature (%s; %s)", - interf->class_loader_data()->loader_name_and_id(), - interf->external_name(), - method_holder->class_loader_data()->loader_name_and_id(), - method_holder->external_kind(), - method_holder->external_name(), - failed_type_symbol->as_klass_external_name(), - interf->class_in_module_of_loader(false, true), - method_holder->class_in_module_of_loader(false, true)); - THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string()); + // Do not check loader constraints for overpass methods because overpass + // methods are created by the jvm to throw exceptions. + if (!target->is_overpass()) { + InstanceKlass* method_holder = target->method_holder(); + InstanceKlass* interf = interface_method->method_holder(); + HandleMark hm(THREAD); + Handle method_holder_loader(THREAD, method_holder->class_loader()); + Handle interface_loader(THREAD, interf->class_loader()); + + if (method_holder_loader() != interface_loader()) { + ResourceMark rm(THREAD); + Symbol* failed_type_symbol = + SystemDictionary::check_signature_loaders(target->signature(), + _klass, + method_holder_loader, + interface_loader, + true); + if (failed_type_symbol != nullptr) { + stringStream ss; + ss.print("loader constraint violation in interface itable" + " initialization for class %s: when selecting method '", + _klass->external_name()); + interface_method->print_external_name(&ss), + ss.print("' the class loader %s for super interface %s, and the class" + " loader %s of the selected method's %s, %s have" + " different Class objects for the type %s used in the signature (%s; %s)", + interf->class_loader_data()->loader_name_and_id(), + interf->external_name(), + method_holder->class_loader_data()->loader_name_and_id(), + method_holder->external_kind(), + method_holder->external_name(), + failed_type_symbol->as_klass_external_name(), + interf->class_in_module_of_loader(false, true), + method_holder->class_in_module_of_loader(false, true)); + THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string()); + } } } } @@ -1333,9 +1337,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Insta target = LinkResolver::lookup_instance_method_in_klasses(_klass, m->name(), m->signature(), Klass::PrivateLookupMode::skip); } - if (target == nullptr || !target->is_public() || target->is_abstract() || target->is_overpass()) { - assert(target == nullptr || !target->is_overpass() || target->is_public(), - "Non-public overpass method!"); + if (target == nullptr || !target->is_public() || target->is_abstract()) { // Entry does not resolve. Leave it empty for AbstractMethodError or other error. if (!(target == nullptr) && !target->is_public()) { // Stuff an IllegalAccessError throwing method in there instead. From 5e49c497bd2a41e145be36e19257919559390092 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Thu, 3 Jul 2025 02:40:04 -0400 Subject: [PATCH 2/4] regression test --- .../jtreg/runtime/defaultMethods/C.java | 24 +++++++++ .../jtreg/runtime/defaultMethods/I1.java | 25 ++++++++++ .../jtreg/runtime/defaultMethods/I2.jasm | 29 +++++++++++ .../jtreg/runtime/defaultMethods/I2.java | 26 ++++++++++ .../TestConflictingDefaults.java | 50 +++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 test/hotspot/jtreg/runtime/defaultMethods/C.java create mode 100644 test/hotspot/jtreg/runtime/defaultMethods/I1.java create mode 100644 test/hotspot/jtreg/runtime/defaultMethods/I2.jasm create mode 100644 test/hotspot/jtreg/runtime/defaultMethods/I2.java create mode 100644 test/hotspot/jtreg/runtime/defaultMethods/TestConflictingDefaults.java diff --git a/test/hotspot/jtreg/runtime/defaultMethods/C.java b/test/hotspot/jtreg/runtime/defaultMethods/C.java new file mode 100644 index 0000000000000..c454a2134da87 --- /dev/null +++ b/test/hotspot/jtreg/runtime/defaultMethods/C.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025, 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. + */ +public class C implements I1, I2 { +} diff --git a/test/hotspot/jtreg/runtime/defaultMethods/I1.java b/test/hotspot/jtreg/runtime/defaultMethods/I1.java new file mode 100644 index 0000000000000..fcac9febc9a76 --- /dev/null +++ b/test/hotspot/jtreg/runtime/defaultMethods/I1.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025, 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. + */ +public interface I1 { + default Integer m() { return Integer.valueOf(1); } +} diff --git a/test/hotspot/jtreg/runtime/defaultMethods/I2.jasm b/test/hotspot/jtreg/runtime/defaultMethods/I2.jasm new file mode 100644 index 0000000000000..460f55a9714e7 --- /dev/null +++ b/test/hotspot/jtreg/runtime/defaultMethods/I2.jasm @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025, 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. + */ + public interface I2 version 52:0 { + public Method m:"()Ljava/lang/Integer;" stack 1 locals 1 { + iconst_2; + invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;"; + areturn; + } +} diff --git a/test/hotspot/jtreg/runtime/defaultMethods/I2.java b/test/hotspot/jtreg/runtime/defaultMethods/I2.java new file mode 100644 index 0000000000000..23a7cbbcb4bbb --- /dev/null +++ b/test/hotspot/jtreg/runtime/defaultMethods/I2.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025, 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. + */ +public interface I2 { + // I2.jasm renames this to `m` + default Integer n() { return Integer.valueOf(2); } +} diff --git a/test/hotspot/jtreg/runtime/defaultMethods/TestConflictingDefaults.java b/test/hotspot/jtreg/runtime/defaultMethods/TestConflictingDefaults.java new file mode 100644 index 0000000000000..46ce2161c2d3a --- /dev/null +++ b/test/hotspot/jtreg/runtime/defaultMethods/TestConflictingDefaults.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025, 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 8356942 + * @summary Ensure invokeinterface throws the correct exception when + * conflicting default methods are found. + * @compile C.java I1.java I2.java + * @comment Now replace I2 with a version that renames the default method + * to cause a conflict. + * @compile I2.jasm + * @run driver TestConflictingDefaults + * + */ +public class TestConflictingDefaults { + public static void main(String[] args) { + String error = "Conflicting default methods: I1.m I2.m"; + try { + I1 var1 = new C(); + Integer i = var1.m(); + throw new RuntimeException("Invocation should have failed!"); + } + catch(IncompatibleClassChangeError icce) { + if (!icce.getMessage().contains(error)) { + throw new RuntimeException("Unexpected ICCE thrown: " + icce); + } + } + } +} From 29883542bf46b6c217a06132e5de668015fd5d73 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Tue, 8 Jul 2025 03:06:05 -0400 Subject: [PATCH 3/4] Replaced new test by updating existing defmeth case that was missing the invokeinterface variants of the test scenario. Also updated all tests therein to use `throwsExact` so that the wrong kind of ICCE does not cause the test to pass by mistake. --- .../jtreg/runtime/defaultMethods/C.java | 24 --------- .../jtreg/runtime/defaultMethods/I1.java | 25 --------- .../jtreg/runtime/defaultMethods/I2.jasm | 29 ---------- .../jtreg/runtime/defaultMethods/I2.java | 26 --------- .../TestConflictingDefaults.java | 50 ----------------- .../defmeth/ConflictingDefaultsTest.java | 54 +++++++++++-------- 6 files changed, 31 insertions(+), 177 deletions(-) delete mode 100644 test/hotspot/jtreg/runtime/defaultMethods/C.java delete mode 100644 test/hotspot/jtreg/runtime/defaultMethods/I1.java delete mode 100644 test/hotspot/jtreg/runtime/defaultMethods/I2.jasm delete mode 100644 test/hotspot/jtreg/runtime/defaultMethods/I2.java delete mode 100644 test/hotspot/jtreg/runtime/defaultMethods/TestConflictingDefaults.java diff --git a/test/hotspot/jtreg/runtime/defaultMethods/C.java b/test/hotspot/jtreg/runtime/defaultMethods/C.java deleted file mode 100644 index c454a2134da87..0000000000000 --- a/test/hotspot/jtreg/runtime/defaultMethods/C.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2025, 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. - */ -public class C implements I1, I2 { -} diff --git a/test/hotspot/jtreg/runtime/defaultMethods/I1.java b/test/hotspot/jtreg/runtime/defaultMethods/I1.java deleted file mode 100644 index fcac9febc9a76..0000000000000 --- a/test/hotspot/jtreg/runtime/defaultMethods/I1.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2025, 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. - */ -public interface I1 { - default Integer m() { return Integer.valueOf(1); } -} diff --git a/test/hotspot/jtreg/runtime/defaultMethods/I2.jasm b/test/hotspot/jtreg/runtime/defaultMethods/I2.jasm deleted file mode 100644 index 460f55a9714e7..0000000000000 --- a/test/hotspot/jtreg/runtime/defaultMethods/I2.jasm +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2025, 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. - */ - public interface I2 version 52:0 { - public Method m:"()Ljava/lang/Integer;" stack 1 locals 1 { - iconst_2; - invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;"; - areturn; - } -} diff --git a/test/hotspot/jtreg/runtime/defaultMethods/I2.java b/test/hotspot/jtreg/runtime/defaultMethods/I2.java deleted file mode 100644 index 23a7cbbcb4bbb..0000000000000 --- a/test/hotspot/jtreg/runtime/defaultMethods/I2.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2025, 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. - */ -public interface I2 { - // I2.jasm renames this to `m` - default Integer n() { return Integer.valueOf(2); } -} diff --git a/test/hotspot/jtreg/runtime/defaultMethods/TestConflictingDefaults.java b/test/hotspot/jtreg/runtime/defaultMethods/TestConflictingDefaults.java deleted file mode 100644 index 46ce2161c2d3a..0000000000000 --- a/test/hotspot/jtreg/runtime/defaultMethods/TestConflictingDefaults.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2025, 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 8356942 - * @summary Ensure invokeinterface throws the correct exception when - * conflicting default methods are found. - * @compile C.java I1.java I2.java - * @comment Now replace I2 with a version that renames the default method - * to cause a conflict. - * @compile I2.jasm - * @run driver TestConflictingDefaults - * - */ -public class TestConflictingDefaults { - public static void main(String[] args) { - String error = "Conflicting default methods: I1.m I2.m"; - try { - I1 var1 = new C(); - Integer i = var1.m(); - throw new RuntimeException("Invocation should have failed!"); - } - catch(IncompatibleClassChangeError icce) { - if (!icce.getMessage().contains(error)) { - throw new RuntimeException("Unexpected ICCE thrown: " + icce); - } - } - } -} diff --git a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/ConflictingDefaultsTest.java b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/ConflictingDefaultsTest.java index c5de16d583e11..6421797298062 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/ConflictingDefaultsTest.java +++ b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/ConflictingDefaultsTest.java @@ -82,6 +82,8 @@ public static void main(String[] args) { * class C implements I, J {} * * TEST: C c = new C(); c.m() ==> ICCE + * TEST: I c = new C(); c.m() ==> ICCE + * TEST: J c = new C(); c.m() ==> ICCE */ public void testConflict(TestBuilder b) { Interface I = b.intf("I") @@ -95,7 +97,13 @@ public void testConflict(TestBuilder b) { ConcreteClass C = b.clazz("C").implement(I,J).build(); b.test().callSite(C, C, "m","()I") - .throws_(IncompatibleClassChangeError.class) + .throwsExact(IncompatibleClassChangeError.class) + .done() + .test().callSite(I, C, "m","()I") + .throwsExact(IncompatibleClassChangeError.class) + .done() + .test().callSite(J, C, "m","()I") + .throwsExact(IncompatibleClassChangeError.class) .done(); } @@ -145,7 +153,7 @@ public void testReabstract(TestBuilder b) { ConcreteClass C = b.clazz("C").implement(J).build(); b.test().callSite(C, C, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done(); } @@ -177,16 +185,16 @@ public void testReabstract2(TestBuilder b) { .build(); b.test().callSite(C, C, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done() .test().callSite(J, C, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done() .test().callSite(I, C, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done() .test().callSite(D, D, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done(); } @@ -218,7 +226,7 @@ public void testReabstractConflictingDefaults(TestBuilder b) { ConcreteClass C = b.clazz("C").extend(A).implement(K).build(); b.test().callSite(A, C, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done(); } @@ -259,13 +267,13 @@ public void testReabstractConflictingDefaultsInvokeInterface(TestBuilder b) { ConcreteClass D = b.clazz("D").extend(C).implement(L).build(); b.test().callSite(I, A, "m","()I") - .throws_(IncompatibleClassChangeError.class) + .throwsExact(IncompatibleClassChangeError.class) .done() .test().callSite(K, C, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done() .test().callSite(L, D, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done(); } @@ -307,10 +315,10 @@ public void testReabstractConflictingDefaultsSuper(TestBuilder b) { .build(); b.test().callSite(I, A, "m","()I") - .throws_(IncompatibleClassChangeError.class) + .throwsExact(IncompatibleClassChangeError.class) .done() .test().callSite(L, D, "m","()I") - .throws_(AbstractMethodError.class) + .throwsExact(AbstractMethodError.class) .done(); } @@ -370,22 +378,22 @@ public void testReabstractResolveMethod00705m2(TestBuilder b) { } b.test().callSite(A, C, "m", "()I") - .throws_(expectedError2) + .throwsExact(expectedError2) .done() .test().callSite(C, C, "m", "()I") - .throws_(expectedError2) + .throwsExact(expectedError2) .done() .test().callSite(J, C, "m", "()I") - .throws_(expectedError1) + .throwsExact(expectedError1) .done() .test().callSite(I, C, "m", "()I") - .throws_(expectedError1) + .throwsExact(expectedError1) .done() .test().callSite(C, C, "test_Cmethod_ISMR", "()V") - .throws_(expectedError2) + .throwsExact(expectedError2) .done() .test().callSite(A, C, "test_Amethod_ISIMR", "()V") - .throws_(expectedError2) + .throwsExact(expectedError2) .done(); } @@ -486,13 +494,13 @@ public void testMixedArity1(TestBuilder b) { .test() .callSite(I, C, "m","(I)I") .params(0) - .throws_(NoSuchMethodError.class) + .throwsExact(NoSuchMethodError.class) .done() // J j = new C(); ... .test() .callSite(J, C, "m","()I") - .throws_(NoSuchMethodError.class) + .throwsExact(NoSuchMethodError.class) .done() .test() .callSite(J, C, "m","(I)I") @@ -539,19 +547,19 @@ public void testMixedArity2(TestBuilder b) { // I i = new C(); ... b.test() .callSite(I, C, "m","()I") - .throws_(IncompatibleClassChangeError.class) + .throwsExact(IncompatibleClassChangeError.class) .done() // J j = new C(); ... .test() .callSite(J, C, "m","()I") - .throws_(IncompatibleClassChangeError.class) + .throwsExact(IncompatibleClassChangeError.class) .done() // C c = new C(); ... .test() .callSite(C, C, "m","()I") - .throws_(IncompatibleClassChangeError.class) + .throwsExact(IncompatibleClassChangeError.class) .done() .test() .callSite(C, C, "m","(I)I") From d12213e37d59d9bf1c8621ef56f071051c94dd2a Mon Sep 17 00:00:00 2001 From: David Holmes Date: Tue, 8 Jul 2025 17:22:54 -0400 Subject: [PATCH 4/4] Fix weird logic - requested by Coleen --- src/hotspot/share/oops/klassVtable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/oops/klassVtable.cpp b/src/hotspot/share/oops/klassVtable.cpp index 108cf410e8823..8d13310cdc7a0 100644 --- a/src/hotspot/share/oops/klassVtable.cpp +++ b/src/hotspot/share/oops/klassVtable.cpp @@ -1339,7 +1339,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Insta } if (target == nullptr || !target->is_public() || target->is_abstract()) { // Entry does not resolve. Leave it empty for AbstractMethodError or other error. - if (!(target == nullptr) && !target->is_public()) { + if (target != nullptr && !target->is_public()) { // Stuff an IllegalAccessError throwing method in there instead. itableOffsetEntry::method_entry(_klass, method_table_offset)[m->itable_index()]. initialize(_klass, Universe::throw_illegal_access_error());