Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/klassVtable.cpp @ 18007:364b73402247
Merge
author | asaha |
---|---|
date | Thu, 22 May 2014 11:09:06 -0700 |
parents | 386dd1c71858 c02077c4b79c |
children | f73af4455d7d |
comparison
equal
deleted
inserted
replaced
17920:382a82b0a3e7 | 18007:364b73402247 |
---|---|
247 | 247 |
248 // Called for cases where a method does not override its superclass' vtable entry | 248 // Called for cases where a method does not override its superclass' vtable entry |
249 // For bytecodes not produced by javac together it is possible that a method does not override | 249 // For bytecodes not produced by javac together it is possible that a method does not override |
250 // the superclass's method, but might indirectly override a super-super class's vtable entry | 250 // the superclass's method, but might indirectly override a super-super class's vtable entry |
251 // If none found, return a null superk, else return the superk of the method this does override | 251 // If none found, return a null superk, else return the superk of the method this does override |
252 // For public and protected methods: if they override a superclass, they will | |
253 // also be overridden themselves appropriately. | |
254 // Private methods do not override and are not overridden. | |
255 // Package Private methods are trickier: | |
256 // e.g. P1.A, pub m | |
257 // P2.B extends A, package private m | |
258 // P1.C extends B, public m | |
259 // P1.C.m needs to override P1.A.m and can not override P2.B.m | |
260 // Therefore: all package private methods need their own vtable entries for | |
261 // them to be the root of an inheritance overriding decision | |
262 // Package private methods may also override other vtable entries | |
252 InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method, | 263 InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method, |
253 int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) { | 264 int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) { |
254 InstanceKlass* superk = initialsuper; | 265 InstanceKlass* superk = initialsuper; |
255 while (superk != NULL && superk->super() != NULL) { | 266 while (superk != NULL && superk->super() != NULL) { |
256 InstanceKlass* supersuperklass = InstanceKlass::cast(superk->super()); | 267 InstanceKlass* supersuperklass = InstanceKlass::cast(superk->super()); |
394 && ((super_klass = find_transitive_override(super_klass, | 405 && ((super_klass = find_transitive_override(super_klass, |
395 target_method, i, target_loader, | 406 target_method, i, target_loader, |
396 target_classname, THREAD)) | 407 target_classname, THREAD)) |
397 != (InstanceKlass*)NULL)))) | 408 != (InstanceKlass*)NULL)))) |
398 { | 409 { |
399 // overriding, so no new entry | 410 // Package private methods always need a new entry to root their own |
400 allocate_new = false; | 411 // overriding. They may also override other methods. |
412 if (!target_method()->is_package_private()) { | |
413 allocate_new = false; | |
414 } | |
401 | 415 |
402 if (checkconstraints) { | 416 if (checkconstraints) { |
403 // Override vtable entry if passes loader constraint check | 417 // Override vtable entry if passes loader constraint check |
404 // if loader constraint checking requested | 418 // if loader constraint checking requested |
405 // No need to visit his super, since he and his super | 419 // No need to visit his super, since he and his super |
539 Handle classloader, | 553 Handle classloader, |
540 Symbol* classname, | 554 Symbol* classname, |
541 AccessFlags class_flags, | 555 AccessFlags class_flags, |
542 TRAPS) { | 556 TRAPS) { |
543 if (class_flags.is_interface()) { | 557 if (class_flags.is_interface()) { |
544 // Interfaces do not use vtables, so there is no point to assigning | 558 // Interfaces do not use vtables, except for java.lang.Object methods, |
545 // a vtable index to any of their methods. If we refrain from doing this, | 559 // so there is no point to assigning |
560 // a vtable index to any of their local methods. If we refrain from doing this, | |
546 // we can use Method::_vtable_index to hold the itable index | 561 // we can use Method::_vtable_index to hold the itable index |
547 return false; | 562 return false; |
548 } | 563 } |
549 | 564 |
550 if (target_method->is_final_method(class_flags) || | 565 if (target_method->is_final_method(class_flags) || |
575 // private methods in classes always have a new entry in the vtable | 590 // private methods in classes always have a new entry in the vtable |
576 // specification interpretation since classic has | 591 // specification interpretation since classic has |
577 // private methods not overriding | 592 // private methods not overriding |
578 // JDK8 adds private methods in interfaces which require invokespecial | 593 // JDK8 adds private methods in interfaces which require invokespecial |
579 if (target_method()->is_private()) { | 594 if (target_method()->is_private()) { |
595 return true; | |
596 } | |
597 | |
598 // Package private methods always need a new entry to root their own | |
599 // overriding. This allows transitive overriding to work. | |
600 if (target_method()->is_package_private()) { | |
580 return true; | 601 return true; |
581 } | 602 } |
582 | 603 |
583 // search through the super class hierarchy to see if we need | 604 // search through the super class hierarchy to see if we need |
584 // a new entry | 605 // a new entry |