Skip to content

Commit

Permalink
allow inline classes to have abstract supers
Browse files Browse the repository at this point in the history
Reviewed-by: fparain
  • Loading branch information
Harold Seigel committed Apr 20, 2020
1 parent ff1b435 commit e4e93d7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/hotspot/share/classfile/classFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6927,11 +6927,14 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st
return;
}

// For a value class, only java/lang/Object is an acceptable super class
// For an inline class, only java/lang/Object or special abstract classes
// are acceptable super classes.
if (_access_flags.get_flags() & JVM_ACC_VALUE) {
guarantee_property(_super_klass->name() == vmSymbols::java_lang_Object(),
"Inline type must have java.lang.Object as superclass in class file %s",
CHECK);
if (_super_klass->name() != vmSymbols::java_lang_Object()) {
guarantee_property(_super_klass->is_abstract(),
"Inline type must have java.lang.Object or an abstract class as its superclass, class file %s",
CHECK);
}
}

// Make sure super class is not final
Expand Down
14 changes: 12 additions & 2 deletions src/hotspot/share/classfile/verificationType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool VerificationType::is_ref_assignable_from_value_type(const VerificationType&
return true;
}

// Need to load 'this' to see if it is an interface.
// Need to load 'this' to see if it is an interface or supertype.
InstanceKlass* klass = context->current_class();
{
HandleMark hm(THREAD);
Expand All @@ -173,7 +173,17 @@ bool VerificationType::is_ref_assignable_from_value_type(const VerificationType&
if (log_is_enabled(Debug, class, resolve)) {
Verifier::trace_class_resolution(this_class, klass);
}
return (this_class->is_interface());
if (this_class->is_interface()) {
return true;
} else {
Klass* from_class = SystemDictionary::resolve_or_fail(
from.name(), Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false);
if (log_is_enabled(Debug, class, resolve)) {
Verifier::trace_class_resolution(from_class, klass);
}
return from_class->is_subclass_of(this_class);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public static void main(String[] args) throws Exception {
runTest("ValueMethodSynch",
"Method getInt in class ValueMethodSynch (an inline class) has illegal modifiers");

runTest("ValueSuperClass", "Inline type must have java.lang.Object as superclass");
runTest("ValueSuperClass",
"Inline type must have java.lang.Object or an abstract class as its superclass");

// Test that ClassCircularityError gets detected for instance fields.
System.out.println("Testing ClassCircularityError for instance fields");
Expand Down

0 comments on commit e4e93d7

Please sign in to comment.