Skip to content

Commit 0385975

Browse files
author
David Holmes
committed
8356941: AbstractMethodError in HotSpot Due to Incorrect Handling of Private Method
Reviewed-by: coleenp, heidinga
1 parent 7d7d308 commit 0385975

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/hotspot/share/classfile/defaultMethods.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,13 +658,11 @@ static void find_empty_vtable_slots(GrowableArray<EmptyVtableSlot*>* slots,
658658
if (super->default_methods() != nullptr) {
659659
for (int i = 0; i < super->default_methods()->length(); ++i) {
660660
Method* m = super->default_methods()->at(i);
661-
// m is a method that would have been a miranda if not for the
662-
// default method processing that occurred on behalf of our superclass,
663-
// so it's a method we want to re-examine in this new context. That is,
664-
// unless we have a real implementation of it in the current class.
665661
if (!already_in_vtable_slots(slots, m)) {
662+
// m is a method that we need to re-examine, unless we have a valid concrete
663+
// implementation in the current class - see FindMethodsByErasedSig::visit.
666664
Method* impl = klass->lookup_method(m->name(), m->signature());
667-
if (impl == nullptr || impl->is_overpass() || impl->is_static()) {
665+
if (impl == nullptr || impl->is_overpass() || impl->is_static() || impl->is_private()) {
668666
slots->append(new EmptyVtableSlot(m));
669667
}
670668
}

test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/PrivateMethodsTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ public void testPrivateSuperClassMethodDefaultMethod(TestBuilder b) {
680680
* public class C extends B { }
681681
*
682682
* TEST: { B b = new C(); b.m()I throws IllegalAccessError; }
683+
* TEST: { I b = new B(); b.m()I returns 3; }
684+
* TEST: { I c = new C(); c.m()I returns 3; }
683685
*/
684686
public void testPrivateSuperClassMethodDefaultMethodNoOverride(TestBuilder b) {
685687
ConcreteClass A = b.clazz("A")
@@ -694,6 +696,10 @@ public void testPrivateSuperClassMethodDefaultMethodNoOverride(TestBuilder b) {
694696

695697
ConcreteClass C = b.clazz("C").extend(B).build();
696698

697-
b.test().privateCallSite(B, C, "m", "()I").throws_(IllegalAccessError.class).done();
699+
b.test().privateCallSite(B, C, "m", "()I").throws_(IllegalAccessError.class).done()
700+
.test(). callSite(I, B, "m", "()I").returns(3).done()
701+
.test(). callSite(I, C, "m", "()I").returns(3).done()
702+
;
703+
698704
}
699705
}

0 commit comments

Comments
 (0)