question on the classFileParser logic
Ivan Krylov
ivan at azulsystems.com
Mon Jun 9 10:54:18 UTC 2014
Hi,
I have a following question on the code in the classFileParser.
I am looking at the jdk9 hotspot, but the same was in 8 and 7.
The following comment suggests that by this point vtable may not be initialized and hence we are placing NULL into vtable:
klassVtable.cpp:239
// In class hierarchies where the accessibility is not increasing (i.e., going from private ->
// package_private -> public/protected), the vtable might actually be smaller than our initial
// calculation.
assert(initialized <= _length, "vtable initialization failed");
for(;initialized < _length; initialized++) {
put_method_at(NULL, initialized);
}
This is the put method: some diagnostic prints and a set method at the end.
klassVtable.cpp:509
void klassVtable::put_method_at(Method* m, int index) {
#ifndef PRODUCT
if (PrintVtables && Verbose) {
ResourceMark rm;
const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
tty->print("adding %s at index %d, flags: ", sig, index);
if (m != NULL) {
m->access_flags().print_on(tty);
if (m->is_default_method()) {
tty->print("default ");
}
if (m->is_overpass()) {
tty->print("overpass");
}
}
tty->cr();
}
#endif
table()[index].set(m);
}
Now the set method will assert on the NULL reference.
klassVtable.hpp:170
void set(Method* method) { assert(method != NULL, “use clear"); _method = method; }
My question is about the for loop above, how is this suppose to work if initialised < _length?
Should the assert above simply be like this: assert(initialised == _length, “vtable initialisation failed”) ?
Thanks,
Ivan
More information about the hotspot-runtime-dev
mailing list