mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-25 15:20:11 +00:00
8356941: AbstractMethodError in HotSpot Due to Incorrect Handling of Private Method
Reviewed-by: coleenp, heidinga
This commit is contained in:
parent
7d7d308d9a
commit
0385975f44
@ -658,13 +658,11 @@ static void find_empty_vtable_slots(GrowableArray<EmptyVtableSlot*>* slots,
|
||||
if (super->default_methods() != nullptr) {
|
||||
for (int i = 0; i < super->default_methods()->length(); ++i) {
|
||||
Method* m = super->default_methods()->at(i);
|
||||
// m is a method that would have been a miranda if not for the
|
||||
// default method processing that occurred on behalf of our superclass,
|
||||
// so it's a method we want to re-examine in this new context. That is,
|
||||
// unless we have a real implementation of it in the current class.
|
||||
if (!already_in_vtable_slots(slots, m)) {
|
||||
// m is a method that we need to re-examine, unless we have a valid concrete
|
||||
// implementation in the current class - see FindMethodsByErasedSig::visit.
|
||||
Method* impl = klass->lookup_method(m->name(), m->signature());
|
||||
if (impl == nullptr || impl->is_overpass() || impl->is_static()) {
|
||||
if (impl == nullptr || impl->is_overpass() || impl->is_static() || impl->is_private()) {
|
||||
slots->append(new EmptyVtableSlot(m));
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,6 +680,8 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
* public class C extends B { }
|
||||
*
|
||||
* TEST: { B b = new C(); b.m()I throws IllegalAccessError; }
|
||||
* TEST: { I b = new B(); b.m()I returns 3; }
|
||||
* TEST: { I c = new C(); c.m()I returns 3; }
|
||||
*/
|
||||
public void testPrivateSuperClassMethodDefaultMethodNoOverride(TestBuilder b) {
|
||||
ConcreteClass A = b.clazz("A")
|
||||
@ -694,6 +696,10 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").extend(B).build();
|
||||
|
||||
b.test().privateCallSite(B, C, "m", "()I").throws_(IllegalAccessError.class).done();
|
||||
b.test().privateCallSite(B, C, "m", "()I").throws_(IllegalAccessError.class).done()
|
||||
.test(). callSite(I, B, "m", "()I").returns(3).done()
|
||||
.test(). callSite(I, C, "m", "()I").returns(3).done()
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user