Skip to content

Commit a3cbfb9

Browse files
authored
Merge pull request SAP#1876 from SAP/pr-jdk-17.0.14+6
Merge to tag jdk-17.0.14+6
2 parents 960d5cc + bdc07d2 commit a3cbfb9

File tree

24 files changed

+872
-41
lines changed

24 files changed

+872
-41
lines changed

make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2024, 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
@@ -273,16 +273,16 @@ private void outputFile(Path dstFile, String version,
273273
// link version-region-rules
274274
out.writeShort(builtZones.size());
275275
for (Map.Entry<String, ZoneRules> entry : builtZones.entrySet()) {
276-
int regionIndex = Arrays.binarySearch(regionArray, entry.getKey());
276+
int regionIndex = findRegionIndex(regionArray, entry.getKey());
277277
int rulesIndex = rulesList.indexOf(entry.getValue());
278278
out.writeShort(regionIndex);
279279
out.writeShort(rulesIndex);
280280
}
281281
// alias-region
282282
out.writeShort(links.size());
283283
for (Map.Entry<String, String> entry : links.entrySet()) {
284-
int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey());
285-
int regionIndex = Arrays.binarySearch(regionArray, entry.getValue());
284+
int aliasIndex = findRegionIndex(regionArray, entry.getKey());
285+
int regionIndex = findRegionIndex(regionArray, entry.getValue());
286286
out.writeShort(aliasIndex);
287287
out.writeShort(regionIndex);
288288
}
@@ -294,6 +294,14 @@ private void outputFile(Path dstFile, String version,
294294
}
295295
}
296296

297+
private static int findRegionIndex(String[] regionArray, String region) {
298+
int index = Arrays.binarySearch(regionArray, region);
299+
if (index < 0) {
300+
throw new IllegalArgumentException("Unknown region: " + region);
301+
}
302+
return index;
303+
}
304+
297305
/** Whether to output verbose messages. */
298306
private boolean verbose;
299307

src/hotspot/os/bsd/os_bsd.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,13 +2091,12 @@ jint os::init_2(void) {
20912091

20922092
// On macOS according to setrlimit(2), OPEN_MAX must be used instead
20932093
// of RLIM_INFINITY, but testing on macOS >= 10.6, reveals that
2094-
// we can, in fact, use even RLIM_INFINITY, so try the max value
2095-
// that the system claims can be used first, same as other BSD OSes.
2096-
// However, some terminals (ksh) will internally use "int" type
2097-
// to store this value and since RLIM_INFINITY overflows an "int"
2098-
// we might end up with a negative value, so cap the system limit max
2099-
// at INT_MAX instead, just in case, for everyone.
2100-
nbr_files.rlim_cur = MIN(INT_MAX, nbr_files.rlim_max);
2094+
// we can, in fact, use even RLIM_INFINITY.
2095+
// However, we need to limit the value to 0x100000 (which is the max value
2096+
// allowed on Linux) so that any existing code that iterates over all allowed
2097+
// file descriptors, finishes in a reasonable time, without appearing
2098+
// to hang.
2099+
nbr_files.rlim_cur = MIN(0x100000, nbr_files.rlim_max);
21012100

21022101
status = setrlimit(RLIMIT_NOFILE, &nbr_files);
21032102
if (status != 0) {

src/hotspot/share/opto/node.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,8 @@ Node* Node::last_out(DUIterator_Last& i) const {
15151515
class SimpleDUIterator : public StackObj {
15161516
private:
15171517
Node* node;
1518-
DUIterator_Fast i;
15191518
DUIterator_Fast imax;
1519+
DUIterator_Fast i;
15201520
public:
15211521
SimpleDUIterator(Node* n): node(n), i(n->fast_outs(imax)) {}
15221522
bool has_next() { return i < imax; }

src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ void process(Main jartool, String opt, String arg) throws BadArgs {
212212
}
213213
},
214214

215+
// Extract options
216+
new Option(false, OptionType.EXTRACT, "--keep-old-files", "-k") {
217+
void process(Main jartool, String opt, String arg) {
218+
jartool.kflag = true;
219+
}
220+
},
221+
215222
// Hidden options
216223
new Option(false, OptionType.OTHER, "-P") {
217224
void process(Main jartool, String opt, String arg) {
@@ -254,6 +261,7 @@ enum OptionType {
254261
CREATE("create"),
255262
CREATE_UPDATE("create.update"),
256263
CREATE_UPDATE_INDEX("create.update.index"),
264+
EXTRACT("extract"),
257265
OTHER("other");
258266

259267
/** Resource lookup section prefix. */

src/jdk.jartool/share/classes/sun/tools/jar/Main.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ public int hashCode() {
155155
* nflag: Perform jar normalization at the end
156156
* pflag: preserve/don't strip leading slash and .. component from file name
157157
* dflag: print module descriptor
158+
* kflag: keep existing file
158159
*/
159-
boolean cflag, uflag, xflag, tflag, vflag, flag0, Mflag, iflag, pflag, dflag, validate;
160+
boolean cflag, uflag, xflag, tflag, vflag, flag0, Mflag, iflag, pflag, dflag, kflag, validate;
160161

161162
boolean suppressDeprecateMsg = false;
162163

@@ -581,6 +582,9 @@ boolean parseArgs(String args[]) {
581582
case '0':
582583
flag0 = true;
583584
break;
585+
case 'k':
586+
kflag = true;
587+
break;
584588
case 'i':
585589
if (cflag || uflag || xflag || tflag) {
586590
usageError(getMsg("error.multiple.main.operations"));
@@ -611,6 +615,9 @@ boolean parseArgs(String args[]) {
611615
usageError(getMsg("error.bad.option"));
612616
return false;
613617
}
618+
if (kflag && !xflag) {
619+
warn(formatMsg("warn.option.is.ignored", "--keep-old-files/-k/k"));
620+
}
614621

615622
/* parse file arguments */
616623
int n = args.length - count;
@@ -1451,6 +1458,12 @@ ZipEntry extractFile(InputStream is, ZipEntry e) throws IOException {
14511458
output(formatMsg("out.create", name));
14521459
}
14531460
} else {
1461+
if (f.exists() && kflag) {
1462+
if (vflag) {
1463+
output(formatMsg("out.kept", name));
1464+
}
1465+
return rc;
1466+
}
14541467
if (f.getParent() != null) {
14551468
File d = new File(f.getParent());
14561469
if (!d.exists() && !d.mkdirs() || !d.isDirectory()) {

src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ warn.release.unexpected.versioned.entry=\
137137
unexpected versioned entry {0}
138138
warn.flag.is.deprecated=\
139139
Warning: The {0} option is deprecated, and is planned for removal in a future JDK release\n
140+
warn.option.is.ignored=\
141+
Warning: The {0} option is not valid with current usage, will be ignored.
140142
out.added.manifest=\
141143
added manifest
142144
out.added.module-info=\
@@ -159,6 +161,8 @@ out.create=\
159161
\ \ created: {0}
160162
out.extracted=\
161163
extracted: {0}
164+
out.kept=\
165+
\ \ skipped: {0} exists
162166
out.inflated=\
163167
\ inflated: {0}
164168
out.size=\
@@ -236,7 +240,10 @@ main.help.opt.main.list=\
236240
main.help.opt.main.update=\
237241
\ -u, --update Update an existing jar archive
238242
main.help.opt.main.extract=\
239-
\ -x, --extract Extract named (or all) files from the archive
243+
\ -x, --extract Extract named (or all) files from the archive.\n\
244+
\ If a file with the same name appears more than once in\n\
245+
\ the archive, each copy will be extracted, with later copies\n\
246+
\ overwriting (replacing) earlier copies unless -k is specified.
240247
main.help.opt.main.describe-module=\
241248
\ -d, --describe-module Print the module descriptor, or automatic module name
242249
main.help.opt.main.validate=\
@@ -298,6 +305,15 @@ main.help.opt.create.update.index.date=\
298305
\ --date=TIMESTAMP The timestamp in ISO-8601 extended offset date-time with\n\
299306
\ optional time-zone format, to use for the timestamps of\n\
300307
\ entries, e.g. "2022-02-12T12:30:00-05:00"
308+
main.help.opt.extract=\
309+
\ Operation modifiers valid only in extract mode:\n
310+
main.help.opt.extract.keep-old-files=\
311+
\ -k, --keep-old-files Do not overwrite existing files.\n\
312+
\ If a Jar file entry with the same name exists in the target\n\
313+
\ directory, the existing file will not be overwritten.\n\
314+
\ As a result, if a file appears more than once in an\n\
315+
\ archive, later copies will not overwrite earlier copies.\n\
316+
\ Also note that some file system can be case insensitive.
301317
main.help.opt.other=\
302318
\ Other options:\n
303319
main.help.opt.other.help=\

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, 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
@@ -1696,6 +1696,9 @@ private String genSystemModulesMapClass(String allSystemModulesClassName,
16961696
ResourcePoolBuilder out) {
16971697
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS
16981698
+ ClassWriter.COMPUTE_FRAMES);
1699+
// sort the map of module name to the class name of the generated SystemModules class
1700+
List<Map.Entry<String, String>> systemModulesMap = map.entrySet()
1701+
.stream().sorted(Map.Entry.comparingByKey()).toList();
16991702
cw.visit(Opcodes.V1_8,
17001703
ACC_FINAL+ACC_SUPER,
17011704
SYSTEM_MODULES_MAP_CLASS,
@@ -1762,10 +1765,10 @@ private String genSystemModulesMapClass(String allSystemModulesClassName,
17621765
mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
17631766

17641767
int index = 0;
1765-
for (String moduleName : sorted(map.keySet())) {
1768+
for (Map.Entry<String,String> entry : systemModulesMap) {
17661769
mv.visitInsn(DUP); // arrayref
17671770
pushInt(mv, index);
1768-
mv.visitLdcInsn(moduleName);
1771+
mv.visitLdcInsn(entry.getKey());
17691772
mv.visitInsn(AASTORE);
17701773
index++;
17711774
}
@@ -1785,10 +1788,10 @@ private String genSystemModulesMapClass(String allSystemModulesClassName,
17851788
mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
17861789

17871790
index = 0;
1788-
for (String className : sorted(map.values())) {
1791+
for (Map.Entry<String,String> entry : systemModulesMap) {
17891792
mv.visitInsn(DUP); // arrayref
17901793
pushInt(mv, index);
1791-
mv.visitLdcInsn(className.replace('/', '.'));
1794+
mv.visitLdcInsn(entry.getValue().replace('/', '.'));
17921795
mv.visitInsn(AASTORE);
17931796
index++;
17941797
}

test/jdk/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2004, 2024, 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
@@ -91,7 +91,7 @@ ${COMPILEJAVA}${FILESEP}bin${FILESEP}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
9191
${TESTSRC}${FILESEP}provider${FILESEP}HashProvider.java
9292

9393
# run the test
94-
${TESTJAVA}${FILESEP}bin${FILESEP}java ${TESTVMOPTS} \
94+
${TESTJAVA}${FILESEP}bin${FILESEP}java ${TESTVMOPTS} ${TESTJAVAOPTS} \
9595
-classpath "${TESTCLASSES}${PATHSEP}${TESTSRC}${FILESEP}Deadlock.jar" \
9696
-Djava.awt.headless=true \
9797
ClassLoaderDeadlock

test/jdk/java/security/Security/ClassLoaderDeadlock/Deadlock.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
55
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
#
77
# This code is free software; you can redistribute it and/or modify it
@@ -62,5 +62,5 @@ esac
6262

6363
JAVA="${TESTJAVA}${FILESEP}bin${FILESEP}java"
6464

65-
${JAVA} ${TESTVMOPTS} -cp "${TESTCLASSES}${PATHSEP}${TESTSRC}${FILESEP}Deadlock.jar" Deadlock
65+
${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp "${TESTCLASSES}${PATHSEP}${TESTSRC}${FILESEP}Deadlock.jar" Deadlock
6666

test/jdk/java/security/cert/CertificateFactory/slowstream.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2010, 2024, 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
@@ -50,5 +50,5 @@ esac
5050

5151
${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
5252
${TESTSRC}${FS}SlowStream.java
53-
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Dtest.src=${TESTSRC} SlowStreamWriter | \
54-
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} SlowStreamReader
53+
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} -Dtest.src=${TESTSRC} SlowStreamWriter | \
54+
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} SlowStreamReader

0 commit comments

Comments
 (0)