Skip to content

Commit 3bd5b80

Browse files
author
Harold Seigel
committed
8243583: Change 'final' error checks to throw ICCE
Reviewed-by: lfoltan, dholmes
1 parent 1f00c3b commit 3bd5b80

File tree

4 files changed

+20
-29
lines changed

4 files changed

+20
-29
lines changed

src/hotspot/share/classfile/classFileParser.cpp

+7-16
Original file line numberDiff line numberDiff line change
@@ -4438,13 +4438,7 @@ void ClassFileParser::check_super_class_access(const InstanceKlass* this_klass,
44384438
const InstanceKlass* super_ik = InstanceKlass::cast(super);
44394439

44404440
if (super->is_final()) {
4441-
ResourceMark rm(THREAD);
4442-
Exceptions::fthrow(
4443-
THREAD_AND_LOCATION,
4444-
vmSymbols::java_lang_VerifyError(),
4445-
"class %s cannot inherit from final class %s",
4446-
this_klass->external_name(),
4447-
super_ik->external_name());
4441+
classfile_icce_error("class %s cannot inherit from final class %s", super_ik, THREAD);
44484442
return;
44494443
}
44504444

@@ -4589,15 +4583,12 @@ static void check_final_method_override(const InstanceKlass* this_klass, TRAPS)
45894583
if (can_access) {
45904584
// this class can access super final method and therefore override
45914585
ResourceMark rm(THREAD);
4592-
Exceptions::fthrow(THREAD_AND_LOCATION,
4593-
vmSymbols::java_lang_VerifyError(),
4594-
"class %s overrides final method %s.%s%s",
4595-
this_klass->external_name(),
4596-
super_m->method_holder()->external_name(),
4597-
name->as_C_string(),
4598-
signature->as_C_string()
4599-
);
4600-
return;
4586+
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
4587+
err_msg("class %s overrides final method %s.%s%s",
4588+
this_klass->external_name(),
4589+
super_m->method_holder()->external_name(),
4590+
name->as_C_string(),
4591+
signature->as_C_string()));
46014592
}
46024593
}
46034594

test/hotspot/jtreg/runtime/verifier/OverriderMsg.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -128,7 +128,7 @@ public static void main(String... args) throws Exception {
128128
ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "Overrider");
129129
OutputAnalyzer output = new OutputAnalyzer(pb.start());
130130
output.shouldContain(
131-
"java.lang.VerifyError: class Overrider overrides final method HasFinal.m(Ljava/lang/String;)V");
131+
"java.lang.IncompatibleClassChangeError: class Overrider overrides final method HasFinal.m(Ljava/lang/String;)V");
132132
output.shouldHaveExitValue(1);
133133
}
134134

test/hotspot/jtreg/vmTestbase/vm/mlvm/anonloader/func/finalSuperclass/TestDescription.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
* VM Testbase keywords: [feature_mlvm]
3131
* VM Testbase readme:
3232
* DESCRIPTION
33-
* Try to load anonymous class derived from java.lang.System. The verification
34-
* system (split verifier and system class loader) should reject such attempt and
35-
* throw VerifyError.
33+
* Try to load anonymous class derived from java.lang.System. The class file
34+
* loader should reject such attempt and throw IncompatibleClassChangeError
35+
* because java.lang.System is a final class.
3636
*
3737
* @library /vmTestbase
3838
* /test/lib
@@ -44,6 +44,6 @@
4444
* @run main/othervm
4545
* vm.mlvm.anonloader.share.ReplaceClassParentTest
4646
* -newParent java/lang/System
47-
* -requireExceptions java.lang.VerifyError
47+
* -requireExceptions java.lang.IncompatibleClassChangeError
4848
*/
4949

test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/ObjectMethodOverridesTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -123,7 +123,7 @@ public void testGetClass() throws Exception {
123123

124124
ConcreteClass C = b.clazz("C").implement(I).build();
125125

126-
b.test().loadClass(I).throws_(VerifyError.class).done()
126+
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
127127
.run();
128128
}
129129

@@ -158,7 +158,7 @@ public void testNotify() throws Exception {
158158

159159
ConcreteClass C = b.clazz("C").implement(I).build();
160160

161-
b.test().loadClass(I).throws_(VerifyError.class).done()
161+
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
162162
.run();
163163
}
164164

@@ -174,7 +174,7 @@ public void testNotifyAll() throws Exception {
174174

175175
ConcreteClass C = b.clazz("C").implement(I).build();
176176

177-
b.test().loadClass(I).throws_(VerifyError.class).done()
177+
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
178178
.run();
179179
}
180180

@@ -208,7 +208,7 @@ public void testWait() throws Exception {
208208

209209
ConcreteClass C = b.clazz("C").implement(I).build();
210210

211-
b.test().loadClass(I).throws_(VerifyError.class).done()
211+
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
212212
.run();
213213
}
214214

@@ -224,7 +224,7 @@ public void testTimedWait() throws Exception {
224224

225225
ConcreteClass C = b.clazz("C").implement(I).build();
226226

227-
b.test().loadClass(I).throws_(VerifyError.class).done()
227+
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
228228
.run();
229229
}
230230

@@ -240,7 +240,7 @@ public void testTimedWait1() throws Exception {
240240

241241
ConcreteClass C = b.clazz("C").implement(I).build();
242242

243-
b.test().loadClass(I).throws_(VerifyError.class).done()
243+
b.test().loadClass(I).throws_(IncompatibleClassChangeError.class).done()
244244
.run();
245245
}
246246
}

0 commit comments

Comments
 (0)