Skip to content

Commit 58cce4b

Browse files
committed
Merge branch 'master' into goetz_backport_8358764
2 parents bdb4707 + bd1728a commit 58cce4b

File tree

162 files changed

+3535
-1062
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+3535
-1062
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,6 @@ jobs:
293293
bootjdk-platform: linux-x64
294294
runs-on: ubuntu-22.04
295295

296-
test-macos-x64:
297-
name: macos-x64
298-
needs:
299-
- build-macos-x64
300-
uses: ./.github/workflows/test.yml
301-
with:
302-
platform: macos-x64
303-
bootjdk-platform: macos-x64
304-
runs-on: macos-13
305-
xcode-toolset-version: '14.3.1'
306-
307296
test-macos-aarch64:
308297
name: macos-aarch64
309298
needs:
@@ -325,46 +314,3 @@ jobs:
325314
bootjdk-platform: windows-x64
326315
runs-on: windows-2025
327316

328-
# Remove bundles so they are not misconstrued as binary distributions from the JDK project
329-
remove-bundles:
330-
name: 'Remove bundle artifacts'
331-
runs-on: ubuntu-22.04
332-
if: always()
333-
needs:
334-
- build-linux-x64
335-
- build-linux-x86-hs
336-
- build-linux-x64-hs-nopch
337-
- build-linux-x64-hs-zero
338-
- build-linux-x64-hs-minimal
339-
- build-linux-x64-hs-optimized
340-
- build-linux-cross-compile
341-
- build-macos-x64
342-
- build-macos-aarch64
343-
- build-windows-x64
344-
- build-windows-aarch64
345-
- test-linux-x64
346-
- test-macos-x64
347-
- test-macos-aarch64
348-
- test-windows-x64
349-
350-
steps:
351-
- name: 'Remove bundle artifacts'
352-
run: |
353-
# Find and remove all bundle artifacts
354-
# See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28
355-
ALL_ARTIFACT_IDS="$(curl -sL \
356-
-H 'Accept: application/vnd.github+json' \
357-
-H 'Authorization: Bearer ${{ github.token }}' \
358-
-H 'X-GitHub-Api-Version: 2022-11-28' \
359-
'${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts?per_page=100')"
360-
BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')"
361-
for id in $BUNDLE_ARTIFACT_IDS; do
362-
echo "Removing $id"
363-
curl -sL \
364-
-X DELETE \
365-
-H 'Accept: application/vnd.github+json' \
366-
-H 'Authorization: Bearer ${{ github.token }}' \
367-
-H 'X-GitHub-Api-Version: 2022-11-28' \
368-
"${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \
369-
|| echo "Failed to remove bundle"
370-
done

make/autoconf/flags-cflags.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
544544
TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced \
545545
-qalias=noansi -qstrict -qtls=default -qnortti -qnoeh -qignerrno -qstackprotect"
546546
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
547-
TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
548-
TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
547+
TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:strictStrings -MP"
548+
TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:strictStrings -Zc:wchar_t-"
549549
fi
550550
551551
# CFLAGS C language level for JDK sources (hotspot only uses C++)

src/hotspot/os/windows/os_windows.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4547,7 +4547,7 @@ static errno_t get_full_path(LPCWSTR unicode_path, LPWSTR* full_path) {
45474547
return ERROR_SUCCESS;
45484548
}
45494549

4550-
static void set_path_prefix(char* buf, LPWSTR* prefix, int* prefix_off, bool* needs_fullpath) {
4550+
static void set_path_prefix(char* buf, LPCWSTR* prefix, int* prefix_off, bool* needs_fullpath) {
45514551
*prefix_off = 0;
45524552
*needs_fullpath = true;
45534553

@@ -4583,7 +4583,7 @@ static wchar_t* wide_abs_unc_path(char const* path, errno_t & err, int additiona
45834583
strncpy(buf, path, buf_len);
45844584
os::native_path(buf);
45854585

4586-
LPWSTR prefix = NULL;
4586+
LPCWSTR prefix = NULL;
45874587
int prefix_off = 0;
45884588
bool needs_fullpath = true;
45894589
set_path_prefix(buf, &prefix, &prefix_off, &needs_fullpath);

src/hotspot/share/c1/c1_Canonicalizer.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2023, 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
@@ -40,10 +40,6 @@ class Canonicalizer: InstructionVisitor {
4040
void set_constant(jlong x) { set_canonical(new Constant(new LongConstant(x))); }
4141
void set_constant(jfloat x) { set_canonical(new Constant(new FloatConstant(x))); }
4242
void set_constant(jdouble x) { set_canonical(new Constant(new DoubleConstant(x))); }
43-
#ifdef _WINDOWS
44-
// jint is defined as long in jni_md.h, so convert from int to jint
45-
void set_constant(int x) { set_constant((jint)x); }
46-
#endif
4743
void move_const_to_right(Op2* x);
4844
void do_Op2(Op2* x);
4945
void do_UnsafeRawOp(UnsafeRawOp* x);

src/hotspot/share/classfile/stackMapTable.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,16 @@ bool StackMapTable::match_stackmap(
122122
}
123123

124124
void StackMapTable::check_jump_target(
125-
StackMapFrame* frame, int32_t target, TRAPS) const {
125+
StackMapFrame* frame, int bci, int offset, TRAPS) const {
126126
ErrorContext ctx;
127+
// Jump targets must be within the method and the method size is limited. See JVMS 4.11
128+
int min_offset = -1 * max_method_code_size;
129+
if (offset < min_offset || offset > max_method_code_size) {
130+
frame->verifier()->verify_error(ErrorContext::bad_stackmap(bci, frame),
131+
"Illegal target of jump or branch (bci %d + offset %d)", bci, offset);
132+
return;
133+
}
134+
int target = bci + offset;
127135
bool match = match_stackmap(
128136
frame, target, true, false, &ctx, CHECK_VERIFY(frame->verifier()));
129137
if (!match || (target < 0 || target >= _code_length)) {

src/hotspot/share/classfile/stackMapTable.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class StackMapTable : public StackObj {
6969

7070
// Check jump instructions. Make sure there are no uninitialized
7171
// instances on backward branch.
72-
void check_jump_target(StackMapFrame* frame, int32_t target, TRAPS) const;
72+
void check_jump_target(StackMapFrame* frame, int bci, int offset, TRAPS) const;
7373

7474
// The following methods are only used inside this class.
7575

src/hotspot/share/classfile/verifier.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
792792
// Merge with the next instruction
793793
{
794794
u2 index;
795-
int target;
796795
VerificationType type, type2;
797796
VerificationType atype;
798797

@@ -1608,9 +1607,8 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
16081607
case Bytecodes::_ifle:
16091608
current_frame.pop_stack(
16101609
VerificationType::integer_type(), CHECK_VERIFY(this));
1611-
target = bcs.dest();
16121610
stackmap_table.check_jump_target(
1613-
&current_frame, target, CHECK_VERIFY(this));
1611+
&current_frame, bcs.bci(), bcs.get_offset_s2(), CHECK_VERIFY(this));
16141612
no_control_flow = false; break;
16151613
case Bytecodes::_if_acmpeq :
16161614
case Bytecodes::_if_acmpne :
@@ -1621,19 +1619,16 @@ void ClassVerifier::verify_method(const methodHandle& m, TRAPS) {
16211619
case Bytecodes::_ifnonnull :
16221620
current_frame.pop_stack(
16231621
VerificationType::reference_check(), CHECK_VERIFY(this));
1624-
target = bcs.dest();
16251622
stackmap_table.check_jump_target
1626-
(&current_frame, target, CHECK_VERIFY(this));
1623+
(&current_frame, bcs.bci(), bcs.get_offset_s2(), CHECK_VERIFY(this));
16271624
no_control_flow = false; break;
16281625
case Bytecodes::_goto :
1629-
target = bcs.dest();
16301626
stackmap_table.check_jump_target(
1631-
&current_frame, target, CHECK_VERIFY(this));
1627+
&current_frame, bcs.bci(), bcs.get_offset_s2(), CHECK_VERIFY(this));
16321628
no_control_flow = true; break;
16331629
case Bytecodes::_goto_w :
1634-
target = bcs.dest_w();
16351630
stackmap_table.check_jump_target(
1636-
&current_frame, target, CHECK_VERIFY(this));
1631+
&current_frame, bcs.bci(), bcs.get_offset_s4(), CHECK_VERIFY(this));
16371632
no_control_flow = true; break;
16381633
case Bytecodes::_tableswitch :
16391634
case Bytecodes::_lookupswitch :
@@ -2283,15 +2278,14 @@ void ClassVerifier::verify_switch(
22832278
}
22842279
}
22852280
}
2286-
int target = bci + default_offset;
2287-
stackmap_table->check_jump_target(current_frame, target, CHECK_VERIFY(this));
2281+
stackmap_table->check_jump_target(current_frame, bci, default_offset, CHECK_VERIFY(this));
22882282
for (int i = 0; i < keys; i++) {
22892283
// Because check_jump_target() may safepoint, the bytecode could have
22902284
// moved, which means 'aligned_bcp' is no good and needs to be recalculated.
22912285
aligned_bcp = align_up(bcs->bcp() + 1, jintSize);
2292-
target = bci + (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize);
2286+
int offset = (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize);
22932287
stackmap_table->check_jump_target(
2294-
current_frame, target, CHECK_VERIFY(this));
2288+
current_frame, bci, offset, CHECK_VERIFY(this));
22952289
}
22962290
NOT_PRODUCT(aligned_bcp = NULL); // no longer valid at this point
22972291
}
@@ -2550,8 +2544,13 @@ bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) {
25502544
break;
25512545

25522546
case Bytecodes::_goto:
2553-
case Bytecodes::_goto_w:
2554-
target = (opcode == Bytecodes::_goto ? bcs.dest() : bcs.dest_w());
2547+
case Bytecodes::_goto_w: {
2548+
int offset = (opcode == Bytecodes::_goto ? bcs.get_offset_s2() : bcs.get_offset_s4());
2549+
int min_offset = -1 * max_method_code_size;
2550+
// Check offset for overflow
2551+
if (offset < min_offset || offset > max_method_code_size) return false;
2552+
2553+
target = bci + offset;
25552554
if (visited_branches->contains(bci)) {
25562555
if (bci_stack->is_empty()) {
25572556
if (handler_stack->is_empty()) {
@@ -2572,6 +2571,7 @@ bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) {
25722571
visited_branches->append(bci);
25732572
}
25742573
break;
2574+
}
25752575

25762576
// Check that all switch alternatives end in 'athrow' bytecodes. Since it
25772577
// is difficult to determine where each switch alternative ends, parse
@@ -2608,7 +2608,10 @@ bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) {
26082608

26092609
// Push the switch alternatives onto the stack.
26102610
for (int i = 0; i < keys; i++) {
2611-
u4 target = bci + (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize);
2611+
int min_offset = -1 * max_method_code_size;
2612+
int offset = (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize);
2613+
if (offset < min_offset || offset > max_method_code_size) return false;
2614+
u4 target = bci + offset;
26122615
if (target > code_length) return false;
26132616
bci_stack->push(target);
26142617
}

src/hotspot/share/interpreter/bytecodeStream.hpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,23 @@ class BaseBytecodeStream: StackObj {
100100
void set_next_bci(int bci) { assert(0 <= bci && bci <= method()->code_size(), "illegal bci"); _next_bci = bci; }
101101

102102
// Bytecode-specific attributes
103-
int dest() const { return bci() + bytecode().get_offset_s2(raw_code()); }
104-
int dest_w() const { return bci() + bytecode().get_offset_s4(raw_code()); }
103+
int get_offset_s2() const { return bytecode().get_offset_s2(raw_code()); }
104+
int get_offset_s4() const { return bytecode().get_offset_s4(raw_code()); }
105+
106+
// These methods are not safe to use before or during verification as they may
107+
// have large offsets and cause overflows
108+
int dest() const {
109+
int min_offset = -1 * max_method_code_size;
110+
int offset = bytecode().get_offset_s2(raw_code());
111+
guarantee(offset >= min_offset && offset <= max_method_code_size, "must be");
112+
return bci() + offset;
113+
}
114+
int dest_w() const {
115+
int min_offset = -1 * max_method_code_size;
116+
int offset = bytecode().get_offset_s4(raw_code());
117+
guarantee(offset >= min_offset && offset <= max_method_code_size, "must be");
118+
return bci() + offset;
119+
}
105120

106121
// One-byte indices.
107122
int get_index_u1() const { assert_raw_index_size(1); return *(jubyte*)(bcp()+1); }

src/hotspot/share/memory/guardedMemory.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,19 @@
4242
* |Offset | Content | Description |
4343
* |------------------------------------------------------------
4444
* |base_addr | 0xABABABABABABABAB | Head guard |
45-
* |+16 | <size_t:user_size> | User data size |
46-
* |+sizeof(uintptr_t) | <tag> | Tag word |
47-
* |+sizeof(uintptr_t) | <tag2> | Tag word |
45+
* |+GUARD_SIZE | <size_t:user_size> | User data size |
46+
* |+sizeof(size_t) | <tag> | Tag word |
47+
* |+sizeof(void*) | <tag2> | Tag word |
48+
* |+sizeof(void*) | <pad bytes> | Padding |
4849
* |+sizeof(void*) | 0xF1 <user_data> ( | User data |
4950
* |+user_size | 0xABABABABABABABAB | Tail guard |
5051
* -------------------------------------------------------------
5152
*
5253
* Where:
5354
* - guard padding uses "badResourceValue" (0xAB)
5455
* - tag word and tag2 word are general purpose
56+
* - padding is inserted as-needed by the compiler to ensure
57+
* the user data is aligned on a 16-byte boundary
5558
* - user data
5659
* -- initially padded with "uninitBlockPad" (0xF1),
5760
* -- to "freeBlockPad" (0xBA), when freed
@@ -132,12 +135,15 @@ class GuardedMemory : StackObj { // Wrapper on stack
132135

133136
/**
134137
* Header guard and size
138+
*
139+
* NB: the size and placement of the GuardHeader must be such that the
140+
* user-ptr is maximally aligned i.e. 16-byte alignment for x86 ABI for
141+
* stack alignment and use of vector (xmm) instructions. We use alignas
142+
* to achieve this.
135143
*/
136-
class GuardHeader : Guard {
144+
class alignas(16) GuardHeader : Guard {
137145
friend class GuardedMemory;
138146
protected:
139-
// Take care in modifying fields here, will effect alignment
140-
// e.g. x86 ABI 16 byte stack alignment
141147
union {
142148
uintptr_t __unused_full_word1;
143149
size_t _user_size;

src/java.base/share/classes/java/net/InMemoryCookieStore.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, 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
@@ -25,10 +25,6 @@
2525

2626
package java.net;
2727

28-
import java.net.URI;
29-
import java.net.CookieStore;
30-
import java.net.HttpCookie;
31-
import java.net.URISyntaxException;
3228
import java.util.List;
3329
import java.util.Map;
3430
import java.util.ArrayList;
@@ -72,6 +68,7 @@ public InMemoryCookieStore() {
7268
/**
7369
* Add one cookie into cookie store.
7470
*/
71+
@Override
7572
public void add(URI uri, HttpCookie cookie) {
7673
// pre-condition : argument can't be null
7774
if (cookie == null) {
@@ -109,6 +106,7 @@ public void add(URI uri, HttpCookie cookie) {
109106
* 3) not expired.
110107
* See RFC 2965 sec. 3.3.4 for more detail.
111108
*/
109+
@Override
112110
public List<HttpCookie> get(URI uri) {
113111
// argument can't be null
114112
if (uri == null) {
@@ -127,12 +125,13 @@ public List<HttpCookie> get(URI uri) {
127125
lock.unlock();
128126
}
129127

130-
return cookies;
128+
return Collections.unmodifiableList(cookies);
131129
}
132130

133131
/**
134132
* Get all cookies in cookie store, except those have expired
135133
*/
134+
@Override
136135
public List<HttpCookie> getCookies() {
137136
List<HttpCookie> rt;
138137

@@ -156,6 +155,7 @@ public List<HttpCookie> getCookies() {
156155
* Get all URIs, which are associated with at least one cookie
157156
* of this cookie store.
158157
*/
158+
@Override
159159
public List<URI> getURIs() {
160160
List<URI> uris = new ArrayList<>();
161161

@@ -165,7 +165,7 @@ public List<URI> getURIs() {
165165
while (it.hasNext()) {
166166
URI uri = it.next();
167167
List<HttpCookie> cookies = uriIndex.get(uri);
168-
if (cookies == null || cookies.size() == 0) {
168+
if (cookies == null || cookies.isEmpty()) {
169169
// no cookies list or an empty list associated with
170170
// this uri entry, delete it
171171
it.remove();
@@ -176,13 +176,14 @@ public List<URI> getURIs() {
176176
lock.unlock();
177177
}
178178

179-
return uris;
179+
return Collections.unmodifiableList(uris);
180180
}
181181

182182

183183
/**
184184
* Remove a cookie from store
185185
*/
186+
@Override
186187
public boolean remove(URI uri, HttpCookie ck) {
187188
// argument can't be null
188189
if (ck == null) {
@@ -204,6 +205,7 @@ public boolean remove(URI uri, HttpCookie ck) {
204205
/**
205206
* Remove all cookies in this cookie store.
206207
*/
208+
@Override
207209
public boolean removeAll() {
208210
lock.lock();
209211
try {

0 commit comments

Comments
 (0)