8243583: Change 'final' error checks to throw ICCE
Reviewed-by: lfoltan, dholmes
This commit is contained in:
parent
1f00c3b9ba
commit
3bd5b80761
src/hotspot/share/classfile
test/hotspot/jtreg
runtime/verifier
vmTestbase/vm
mlvm/anonloader/func/finalSuperclass
runtime/defmeth
@ -4438,13 +4438,7 @@ void ClassFileParser::check_super_class_access(const InstanceKlass* this_klass,
|
||||
const InstanceKlass* super_ik = InstanceKlass::cast(super);
|
||||
|
||||
if (super->is_final()) {
|
||||
ResourceMark rm(THREAD);
|
||||
Exceptions::fthrow(
|
||||
THREAD_AND_LOCATION,
|
||||
vmSymbols::java_lang_VerifyError(),
|
||||
"class %s cannot inherit from final class %s",
|
||||
this_klass->external_name(),
|
||||
super_ik->external_name());
|
||||
classfile_icce_error("class %s cannot inherit from final class %s", super_ik, THREAD);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4589,15 +4583,12 @@ static void check_final_method_override(const InstanceKlass* this_klass, TRAPS)
|
||||
if (can_access) {
|
||||
// this class can access super final method and therefore override
|
||||
ResourceMark rm(THREAD);
|
||||
Exceptions::fthrow(THREAD_AND_LOCATION,
|
||||
vmSymbols::java_lang_VerifyError(),
|
||||
"class %s overrides final method %s.%s%s",
|
||||
this_klass->external_name(),
|
||||
super_m->method_holder()->external_name(),
|
||||
name->as_C_string(),
|
||||
signature->as_C_string()
|
||||
);
|
||||
return;
|
||||
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
|
||||
err_msg("class %s overrides final method %s.%s%s",
|
||||
this_klass->external_name(),
|
||||
super_m->method_holder()->external_name(),
|
||||
name->as_C_string(),
|
||||
signature->as_C_string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -128,7 +128,7 @@ public class OverriderMsg {
|
||||
ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "Overrider");
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldContain(
|
||||
"java.lang.VerifyError: class Overrider overrides final method HasFinal.m(Ljava/lang/String;)V");
|
||||
"java.lang.IncompatibleClassChangeError: class Overrider overrides final method HasFinal.m(Ljava/lang/String;)V");
|
||||
output.shouldHaveExitValue(1);
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@
|
||||
* VM Testbase keywords: [feature_mlvm]
|
||||
* VM Testbase readme:
|
||||
* DESCRIPTION
|
||||
* Try to load anonymous class derived from java.lang.System. The verification
|
||||
* system (split verifier and system class loader) should reject such attempt and
|
||||
* throw VerifyError.
|
||||
* Try to load anonymous class derived from java.lang.System. The class file
|
||||
* loader should reject such attempt and throw IncompatibleClassChangeError
|
||||
* because java.lang.System is a final class.
|
||||
*
|
||||
* @library /vmTestbase
|
||||
* /test/lib
|
||||
@ -44,6 +44,6 @@
|
||||
* @run main/othervm
|
||||
* vm.mlvm.anonloader.share.ReplaceClassParentTest
|
||||
* -newParent java/lang/System
|
||||
* -requireExceptions java.lang.VerifyError
|
||||
* -requireExceptions java.lang.IncompatibleClassChangeError
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -123,7 +123,7 @@ public class ObjectMethodOverridesTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
b.test().loadClass(I).throws_(VerifyError.class).done()
|
||||
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ public class ObjectMethodOverridesTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
b.test().loadClass(I).throws_(VerifyError.class).done()
|
||||
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ public class ObjectMethodOverridesTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
b.test().loadClass(I).throws_(VerifyError.class).done()
|
||||
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ public class ObjectMethodOverridesTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
b.test().loadClass(I).throws_(VerifyError.class).done()
|
||||
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ public class ObjectMethodOverridesTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
b.test().loadClass(I).throws_(VerifyError.class).done()
|
||||
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ public class ObjectMethodOverridesTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
b.test().loadClass(I).throws_(VerifyError.class).done()
|
||||
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user