8139069: JVM should throw ClassFormatError for <init> methods in interfaces

If method being parsed is in an interface, throw ClassFormatError if its name is "<init>"

Reviewed-by: acorn, lfoltan
This commit is contained in:
Harold Seigel 2015-10-14 13:30:47 -04:00
parent 5659603602
commit df9b5759f7
5 changed files with 125 additions and 4 deletions

View file

@ -1579,11 +1579,9 @@ void ClassVerifier::verify_method(methodHandle m, TRAPS) {
return;
}
// Make sure "this" has been initialized if current method is an
// <init>. Note that "<init>" methods in interfaces are just
// normal methods. Interfaces cannot have ctors.
// <init>.
if (_method->name() == vmSymbols::object_initializer_name() &&
current_frame.flag_this_uninit() &&
!current_class()->is_interface()) {
current_frame.flag_this_uninit()) {
verify_error(ErrorContext::bad_code(bci),
"Constructor must call super() or this() "
"before return");