Skip to content

Commit d01aec3

Browse files
author
Matias Saavedra Silva
committed
8352068: [lworld] test StrictFinalInstanceFieldsTest.java needs to be updated after fix for JDK-8351951
Reviewed-by: liach, heidinga
1 parent fdac9ab commit d01aec3

File tree

11 files changed

+1538
-263
lines changed

11 files changed

+1538
-263
lines changed

src/hotspot/share/classfile/stackMapTable.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,12 @@ StackMapFrame* StackMapReader::next_helper(TRAPS) {
259259
NameAndSig tmp(name, sig);
260260

261261
if (!_prev_frame->assert_unset_fields()->contains(tmp)) {
262-
ResourceMark rm(THREAD);
263-
log_info(verification)("Field %s%s is not found among initial strict instance fields", name->as_C_string(), sig->as_C_string());
262+
log_info(verification)("NameAndType %s%s(CP index: %d) is not found among initial strict instance fields", name->as_C_string(), sig->as_C_string(), index);
264263
StackMapFrame::print_strict_fields(_prev_frame->assert_unset_fields());
265264
_prev_frame->verifier()->verify_error(
266265
ErrorContext::bad_strict_fields(_prev_frame->offset(), _prev_frame),
267266
"Strict fields not a subset of initial strict instance fields: %s:%s", name->as_C_string(), sig->as_C_string());
267+
return nullptr;
268268
} else {
269269
new_fields->put(tmp, false);
270270
}
@@ -277,20 +277,23 @@ StackMapFrame* StackMapReader::next_helper(TRAPS) {
277277
_prev_frame->verifier()->verify_error(
278278
ErrorContext::bad_strict_fields(_prev_frame->offset(), _prev_frame),
279279
"Cannot have uninitialized strict fields after class initialization");
280+
return nullptr;
280281
}
281282

282283
// Continue reading frame data
283284
if (at_end()) {
284285
_prev_frame->verifier()->verify_error(
285286
ErrorContext::bad_strict_fields(_prev_frame->offset(), _prev_frame),
286287
"Early larval frame must be followed by a base frame");
288+
return nullptr;
287289
}
288290

289291
frame_type = _stream->get_u1(CHECK_NULL);
290292
if (frame_type == EARLY_LARVAL) {
291293
_prev_frame->verifier()->verify_error(
292294
ErrorContext::bad_strict_fields(_prev_frame->offset(), _prev_frame),
293295
"Early larval frame must be followed by a base frame");
296+
return nullptr;
294297
}
295298
}
296299

test/hotspot/jtreg/ProblemList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ containers/docker/TestJcmdWithSideCar.java 8341518 linux-x64
130130
# Valhalla
131131
runtime/AccModule/ConstModule.java 8294051 generic-all
132132
runtime/valhalla/inlinetypes/CircularityTest.java 8349037 generic-all
133+
runtime/valhalla/inlinetypes/verifier/StrictInstanceFieldsTest.java 8357141 generic-all
133134
compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java 8357785 generic-all
134135

135136
# Valhalla + COH
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
class BadChild extends Parent {
26+
@Strict int x;
27+
@Strict int y;
28+
29+
BadChild() {
30+
y = 1;
31+
super(); // FAIL: Strict field x must be set before this call
32+
x = 1;
33+
}
34+
}
35+
*/
36+
37+
identity class BadChild extends Parent version 69:65535
38+
{
39+
@-jdk/internal/vm/annotation/Strict { }
40+
strict Field x:I;
41+
@-jdk/internal/vm/annotation/Strict { }
42+
strict Field y:I;
43+
44+
Method "<init>":"()V"
45+
stack 4 locals 1
46+
{
47+
aload_0;
48+
aload_0;
49+
iconst_1;
50+
dup_x1;
51+
putfield Field y:"I";
52+
aload_0;
53+
invokespecial Method Parent."<init>":"()V"; // FAIL: Strict field x must be set before this call
54+
putfield Field x:"I";
55+
return;
56+
}
57+
58+
Method get_x:"()I"
59+
stack 1 locals 1
60+
{
61+
aload_0;
62+
getfield Field x:"I";
63+
ireturn;
64+
}
65+
66+
Method get_y:"()I"
67+
stack 1 locals 1
68+
{
69+
aload_0;
70+
getfield Field y:"I";
71+
ireturn;
72+
}
73+
} // end Class BadChild
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
class BadChild extends Parent {
26+
@Strict int x;
27+
@Strict int y;
28+
29+
BadChild() {
30+
x = 1;
31+
super(); // FAIL: Strict field y must be set before this call
32+
y = 1;
33+
}
34+
}
35+
*/
36+
37+
identity class BadChild1 extends Parent version 69:65535
38+
{
39+
@-jdk/internal/vm/annotation/Strict { }
40+
strict Field x:I;
41+
@-jdk/internal/vm/annotation/Strict { }
42+
strict Field y:I;
43+
44+
Method "<init>":"()V"
45+
stack 4 locals 1
46+
{
47+
aload_0;
48+
aload_0;
49+
iconst_1;
50+
dup_x1;
51+
putfield Field x:"I";
52+
aload_0;
53+
invokespecial Method Parent."<init>":"()V"; // FAIL: Strict field y must be set before this call
54+
putfield Field y:"I";
55+
return;
56+
}
57+
58+
Method get_x:"()I"
59+
stack 1 locals 1
60+
{
61+
aload_0;
62+
getfield Field x:"I";
63+
ireturn;
64+
}
65+
66+
Method get_y:"()I"
67+
stack 1 locals 1
68+
{
69+
aload_0;
70+
getfield Field y:"I";
71+
ireturn;
72+
}
73+
} // end Class BadChild1
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
class ControlFlowChild extends Parent {
26+
@Strict int x;
27+
@Strict int y;
28+
29+
ControlFlowChild(boolean a, boolean b) {
30+
if (a) { // FAIL: Strict field x never set on this path
31+
if (b) {
32+
y = 1;
33+
} else {
34+
y = 2;
35+
}
36+
} else {
37+
x = y = 3;
38+
}
39+
super(); //
40+
}
41+
}
42+
*/
43+
44+
identity class ControlFlowChildBad extends Parent version 69:65535
45+
{
46+
@-jdk/internal/vm/annotation/Strict { }
47+
strict Field x:I;
48+
@-jdk/internal/vm/annotation/Strict { }
49+
strict Field y:I;
50+
51+
Method "<init>":"(ZZ)V"
52+
stack 4 locals 3
53+
{
54+
iload_1;
55+
ifeq L29;
56+
aload_0;
57+
iconst_1;
58+
putfield Field y:"I";
59+
iload_2;
60+
ifeq L21;
61+
aload_0;
62+
iconst_1;
63+
putfield Field y:"I";
64+
goto L39;
65+
L21: stack_frame_type early_larval;
66+
unset_fields y:"I";
67+
frame_type same;
68+
aload_0;
69+
iconst_2;
70+
putfield Field y:"I";
71+
goto L39; // FAIL: Strict field x never set on this path
72+
L29: stack_frame_type early_larval;
73+
unset_fields x:"I",
74+
y:"I";
75+
frame_type same;
76+
aload_0;
77+
aload_0;
78+
iconst_3;
79+
dup_x1;
80+
putfield Field y:"I";
81+
putfield Field x:"I";
82+
L39: stack_frame_type early_larval;
83+
unset_fields;
84+
frame_type same;
85+
aload_0;
86+
invokespecial Method Parent."<init>":"()V";
87+
return;
88+
}
89+
90+
Method get_x:"()I"
91+
stack 1 locals 1
92+
{
93+
aload_0;
94+
getfield Field x:"I";
95+
ireturn;
96+
}
97+
98+
Method get_y:"()I"
99+
stack 1 locals 1
100+
{
101+
aload_0;
102+
getfield Field y:"I";
103+
ireturn;
104+
}
105+
} // end Class ControlFlowChildBad

0 commit comments

Comments
 (0)