< prev index next >
src/hotspot/share/oops/klassVtable.cpp
Print this page
*** 636,645 ****
--- 636,646 ----
Symbol* signature = target_method()->signature();
const Klass* k = super;
Method* super_method = NULL;
InstanceKlass *holder = NULL;
Method* recheck_method = NULL;
+ bool found_pkg_prvt_method = false;
while (k != NULL) {
// lookup through the hierarchy for a method with matching name and sign.
super_method = InstanceKlass::cast(k)->lookup_method(name, signature);
if (super_method == NULL) {
break; // we still have to search for a matching miranda method
*** 657,676 ****
--- 658,696 ----
(!super_method->is_private())) {
if (superk->is_override(super_method, classloader, classname, THREAD)) {
return false;
// else keep looking for transitive overrides
}
+ // If we get here then one of the super classes has a package private method
+ // that will not get overridden because it is in a different package. But,
+ // that package private method does "override" any matching methods in super
+ // interfaces, so there will be no miranda vtable entry created. So, set flag
+ // to TRUE for use below, in case there are no methods in super classes that
+ // this target method overrides.
+ assert(super_method->is_package_private(), "super_method must be package private");
+ assert(!superk->is_same_class_package(classloader(), classname),
+ "Must be different packages");
+ found_pkg_prvt_method = true;
}
// Start with lookup result and continue to search up, for versions supporting transitive override
if (major_version >= VTABLE_TRANSITIVE_OVERRIDE_VERSION) {
k = superk->super(); // haven't found an override match yet; continue to look
} else {
break;
}
}
+ // If found_pkg_prvt_method is set, then the ONLY matching method in the
+ // superclasses is package private in another package. That matching method will
+ // prevent a miranda vtable entry from being created. Because the target method can not
+ // override the package private method in another package, then it needs to be the root
+ // for its own vtable entry.
+ if (found_pkg_prvt_method) {
+ return true;
+ }
+
// if the target method is public or protected it may have a matching
// miranda method in the super, whose entry it should re-use.
// Actually, to handle cases that javac would not generate, we need
// this check for all access permissions.
const InstanceKlass *sk = InstanceKlass::cast(super);
< prev index next >