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

@ -1997,6 +1997,10 @@ methodHandle ClassFileParser::parse_method(bool is_interface,
verify_legal_method_modifiers(flags, is_interface, name, CHECK_(nullHandle));
}
if (name == vmSymbols::object_initializer_name() && is_interface) {
classfile_parse_error("Interface cannot have a method named <init>, class file %s", CHECK_(nullHandle));
}
int args_size = -1; // only used when _need_verify is true
if (_need_verify) {
args_size = ((flags & JVM_ACC_STATIC) ? 0 : 1) +