Skip to content

Commit 9a952be

Browse files
Matias Saavedra Silvaliach
andcommitted
8366743: [lworld]: Verifier adjustments for operations on 'uninitialized'
Co-authored-by: Chen Liang <[email protected]> Reviewed-by: fparain
1 parent 4da4927 commit 9a952be

File tree

13 files changed

+464
-8
lines changed

13 files changed

+464
-8
lines changed

src/hotspot/share/classfile/verifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,12 +1648,12 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
16481648
case Bytecodes::_if_acmpeq :
16491649
case Bytecodes::_if_acmpne :
16501650
current_frame.pop_stack(
1651-
VerificationType::reference_check(), CHECK_VERIFY(this));
1651+
object_type(), CHECK_VERIFY(this));
16521652
// fall through
16531653
case Bytecodes::_ifnull :
16541654
case Bytecodes::_ifnonnull :
16551655
current_frame.pop_stack(
1656-
VerificationType::reference_check(), CHECK_VERIFY(this));
1656+
object_type(), CHECK_VERIFY(this));
16571657
target = bcs.dest();
16581658
stackmap_table.check_jump_target
16591659
(&current_frame, target, CHECK_VERIFY(this));

src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,13 +1052,11 @@ void verify_method(VerificationWrapper.MethodWrapper m) {
10521052
no_control_flow = false; break;
10531053
case IF_ACMPEQ :
10541054
case IF_ACMPNE :
1055-
current_frame.pop_stack(
1056-
VerificationType.reference_check);
1055+
current_frame.pop_stack(object_type());
10571056
// fall through
10581057
case IFNULL :
10591058
case IFNONNULL :
1060-
current_frame.pop_stack(
1061-
VerificationType.reference_check);
1059+
current_frame.pop_stack(object_type());
10621060
target = bcs.dest();
10631061
stackmap_table.check_jump_target
10641062
(current_frame, target);

src/java.base/share/native/libverify/check_code.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,8 +2145,7 @@ pop_stack(context_type *context, unsigned int inumber, stack_info_type *new_stac
21452145
break;
21462146
if ( (GET_ITEM_TYPE(top_type) == ITEM_NewObject
21472147
|| (GET_ITEM_TYPE(top_type) == ITEM_InitObject))
2148-
&& ((opcode == JVM_OPC_astore) || (opcode == JVM_OPC_aload)
2149-
|| (opcode == JVM_OPC_ifnull) || (opcode == JVM_OPC_ifnonnull)))
2148+
&& ((opcode == JVM_OPC_astore) || (opcode == JVM_OPC_aload)))
21502149
break;
21512150
/* The 2nd edition VM of the specification allows field
21522151
* initializations before the superclass initializer,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
class UninitThisAcmp version 69:0
25+
{
26+
public Method "<init>":"()V"
27+
stack 2 locals 2
28+
{
29+
new class java/lang/Object;
30+
dup;
31+
invokespecial Method java/lang/Object."<init>":"()V";
32+
astore_1;
33+
aload_0;
34+
aload_1;
35+
if_acmpne L14;
36+
nop;
37+
L14: stack_frame_type append;
38+
locals_map class java/lang/Object;
39+
aload_0;
40+
invokespecial Method java/lang/Object."<init>":"()V";
41+
return;
42+
}
43+
} // end Class UninitThisAcmp
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
class UninitThisAcmpOld version 49:0
25+
{
26+
public Method "<init>":"()V"
27+
stack 2 locals 2
28+
{
29+
new class java/lang/Object;
30+
dup;
31+
invokespecial Method java/lang/Object."<init>":"()V";
32+
astore_1;
33+
aload_0;
34+
aload_1;
35+
if_acmpne L14;
36+
nop;
37+
L14: invokespecial Method java/lang/Object."<init>":"()V";
38+
return;
39+
}
40+
} // end Class UninitThisAcmpOld
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
class UninitThisIfNull version 69:0
25+
{
26+
public Method "<init>":"()V"
27+
stack 2 locals 2
28+
{
29+
new class java/lang/Object;
30+
dup;
31+
invokespecial Method java/lang/Object."<init>":"()V";
32+
astore_1;
33+
aload_0;
34+
ifnonnull L14;
35+
nop;
36+
L14: stack_frame_type append;
37+
locals_map class java/lang/Object;
38+
aload_0;
39+
invokespecial Method java/lang/Object."<init>":"()V";
40+
return;
41+
}
42+
} // end Class UninitThisIfNull
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
class UninitThisIfNullOld version 49:0
25+
{
26+
public Method "<init>":"()V"
27+
stack 2 locals 2
28+
{
29+
new class java/lang/Object;
30+
dup;
31+
invokespecial Method java/lang/Object."<init>":"()V";
32+
astore_1;
33+
aload_0;
34+
ifnonnull L14;
35+
nop;
36+
L14: aload_0;
37+
invokespecial Method java/lang/Object."<init>":"()V";
38+
return;
39+
}
40+
} // end Class UninitThisIfNullOld
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
class UninitializedAcmp version 69:0
25+
{
26+
Method "<init>":"()V"
27+
stack 5 locals 1
28+
{
29+
aload_0;
30+
invokespecial Method java/lang/Object."<init>":"()V";
31+
aload_0;
32+
L1: new class java/lang/Object;
33+
dup;
34+
dup;
35+
dup;
36+
if_acmpne L18;
37+
nop;
38+
L18: stack_frame_type full;
39+
locals_map class UninitializedAcmp;
40+
stack_map class UninitializedAcmp, at L1, at L1;
41+
invokespecial Method java/lang/Object."<init>":"()V";
42+
return;
43+
}
44+
} // end Class UninitializedAcmp
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
class UninitializedAcmpOld version 49:0
25+
{
26+
Method "<init>":"()V"
27+
stack 5 locals 1
28+
{
29+
aload_0;
30+
invokespecial Method java/lang/Object."<init>":"()V";
31+
aload_0;
32+
L1: new class java/lang/Object;
33+
dup;
34+
dup;
35+
dup;
36+
if_acmpne L18;
37+
nop;
38+
L18: invokespecial Method java/lang/Object."<init>":"()V";
39+
return;
40+
}
41+
} // end Class UninitializedAcmpOld
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
class UninitializedIfNull version 69:0
25+
{
26+
Method "<init>":"()V"
27+
stack 3 locals 1
28+
{
29+
aload_0;
30+
invokespecial Method java/lang/Object."<init>":"()V";
31+
L1: new class java/lang/Object;
32+
dup;
33+
dup;
34+
ifnonnull L18;
35+
nop;
36+
L18: stack_frame_type full;
37+
locals_map class UninitializedIfNull;
38+
stack_map at L1, at L1;
39+
invokespecial Method java/lang/Object."<init>":"()V";
40+
return;
41+
}
42+
} // end Class UninitializedIfNull

0 commit comments

Comments
 (0)