Skip to content

8352068: [lworld] test StrictFinalInstanceFieldsTest.java needs to be updated after fix for JDK-8351951 #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/hotspot/share/classfile/stackMapTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ StackMapFrame* StackMapReader::next_helper(TRAPS) {
NameAndSig tmp(name, sig);

if (!_prev_frame->assert_unset_fields()->contains(tmp)) {
ResourceMark rm(THREAD);
log_info(verification)("Field %s%s is not found among initial strict instance fields", name->as_C_string(), sig->as_C_string());
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);
StackMapFrame::print_strict_fields(_prev_frame->assert_unset_fields());
_prev_frame->verifier()->verify_error(
ErrorContext::bad_strict_fields(_prev_frame->offset(), _prev_frame),
"Strict fields not a subset of initial strict instance fields: %s:%s", name->as_C_string(), sig->as_C_string());
return nullptr;
} else {
new_fields->put(tmp, false);
}
Expand All @@ -277,20 +277,23 @@ StackMapFrame* StackMapReader::next_helper(TRAPS) {
_prev_frame->verifier()->verify_error(
ErrorContext::bad_strict_fields(_prev_frame->offset(), _prev_frame),
"Cannot have uninitialized strict fields after class initialization");
return nullptr;
}

// Continue reading frame data
if (at_end()) {
_prev_frame->verifier()->verify_error(
ErrorContext::bad_strict_fields(_prev_frame->offset(), _prev_frame),
"Early larval frame must be followed by a base frame");
return nullptr;
}

frame_type = _stream->get_u1(CHECK_NULL);
if (frame_type == EARLY_LARVAL) {
_prev_frame->verifier()->verify_error(
ErrorContext::bad_strict_fields(_prev_frame->offset(), _prev_frame),
"Early larval frame must be followed by a base frame");
return nullptr;
}
}

Expand Down
1 change: 1 addition & 0 deletions test/hotspot/jtreg/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ containers/docker/TestJcmdWithSideCar.java 8341518 linux-x64
# Valhalla
runtime/AccModule/ConstModule.java 8294051 generic-all
runtime/valhalla/inlinetypes/CircularityTest.java 8349037 generic-all
runtime/valhalla/inlinetypes/verifier/StrictInstanceFieldsTest.java 8357141 generic-all
compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java 8357785 generic-all

# Valhalla + COH
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2025, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
class BadChild extends Parent {
@Strict int x;
@Strict int y;

BadChild() {
y = 1;
super(); // FAIL: Strict field x must be set before this call
x = 1;
}
}
*/

identity class BadChild extends Parent version 69:65535
{
@-jdk/internal/vm/annotation/Strict { }
strict Field x:I;
@-jdk/internal/vm/annotation/Strict { }
strict Field y:I;

Method "<init>":"()V"
stack 4 locals 1
{
aload_0;
aload_0;
iconst_1;
dup_x1;
putfield Field y:"I";
aload_0;
invokespecial Method Parent."<init>":"()V"; // FAIL: Strict field x must be set before this call
putfield Field x:"I";
return;
}

Method get_x:"()I"
stack 1 locals 1
{
aload_0;
getfield Field x:"I";
ireturn;
}

Method get_y:"()I"
stack 1 locals 1
{
aload_0;
getfield Field y:"I";
ireturn;
}
} // end Class BadChild
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2025, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
class BadChild extends Parent {
@Strict int x;
@Strict int y;

BadChild() {
x = 1;
super(); // FAIL: Strict field y must be set before this call
y = 1;
}
}
*/

identity class BadChild1 extends Parent version 69:65535
{
@-jdk/internal/vm/annotation/Strict { }
strict Field x:I;
@-jdk/internal/vm/annotation/Strict { }
strict Field y:I;

Method "<init>":"()V"
stack 4 locals 1
{
aload_0;
aload_0;
iconst_1;
dup_x1;
putfield Field x:"I";
aload_0;
invokespecial Method Parent."<init>":"()V"; // FAIL: Strict field y must be set before this call
putfield Field y:"I";
return;
}

Method get_x:"()I"
stack 1 locals 1
{
aload_0;
getfield Field x:"I";
ireturn;
}

Method get_y:"()I"
stack 1 locals 1
{
aload_0;
getfield Field y:"I";
ireturn;
}
} // end Class BadChild1
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2025, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
class ControlFlowChild extends Parent {
@Strict int x;
@Strict int y;

ControlFlowChild(boolean a, boolean b) {
if (a) { // FAIL: Strict field x never set on this path
if (b) {
y = 1;
} else {
y = 2;
}
} else {
x = y = 3;
}
super(); //
}
}
*/

identity class ControlFlowChildBad extends Parent version 69:65535
{
@-jdk/internal/vm/annotation/Strict { }
strict Field x:I;
@-jdk/internal/vm/annotation/Strict { }
strict Field y:I;

Method "<init>":"(ZZ)V"
stack 4 locals 3
{
iload_1;
ifeq L29;
aload_0;
iconst_1;
putfield Field y:"I";
iload_2;
ifeq L21;
aload_0;
iconst_1;
putfield Field y:"I";
goto L39;
L21: stack_frame_type early_larval;
unset_fields y:"I";
frame_type same;
aload_0;
iconst_2;
putfield Field y:"I";
goto L39; // FAIL: Strict field x never set on this path
L29: stack_frame_type early_larval;
unset_fields x:"I",
y:"I";
frame_type same;
aload_0;
aload_0;
iconst_3;
dup_x1;
putfield Field y:"I";
putfield Field x:"I";
L39: stack_frame_type early_larval;
unset_fields;
frame_type same;
aload_0;
invokespecial Method Parent."<init>":"()V";
return;
}

Method get_x:"()I"
stack 1 locals 1
{
aload_0;
getfield Field x:"I";
ireturn;
}

Method get_y:"()I"
stack 1 locals 1
{
aload_0;
getfield Field y:"I";
ireturn;
}
} // end Class ControlFlowChildBad
Loading