Skip to content
Permalink
Browse files
allow inline classes to have abstract supers
Reviewed-by: fparain
  • Loading branch information
Harold Seigel committed Apr 20, 2020
1 parent ff1b435 commit e4e93d77c81448ef1f752d79fb6320a091cf7e58
@@ -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
@@ -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);
@@ -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);
}
}
}

@@ -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");

0 comments on commit e4e93d7

Please sign in to comment.