Skip to content

Commit f50b223

Browse files
committed
Merge
2 parents 9da6dbd + c04c9ea commit f50b223

File tree

1,076 files changed

+47120
-41901
lines changed

Some content is hidden

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

1,076 files changed

+47120
-41901
lines changed

make/RunTests.gmk

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,9 @@ define SetupRunJtregTestBody
862862

863863
$$(eval $$(call SetupRunJtregTestCustom, $1))
864864

865-
clean-workdir-$1:
865+
clean-outputdirs-$1:
866866
$$(RM) -r $$($1_TEST_SUPPORT_DIR)
867+
$$(RM) -r $$($1_TEST_RESULTS_DIR)
867868

868869
$1_COMMAND_LINE := \
869870
$$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \
@@ -909,7 +910,7 @@ define SetupRunJtregTestBody
909910
done
910911
endif
911912

912-
run-test-$1: pre-run-test clean-workdir-$1
913+
run-test-$1: pre-run-test clean-outputdirs-$1
913914
$$(call LogWarn)
914915
$$(call LogWarn, Running test '$$($1_TEST)')
915916
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR) \
@@ -946,9 +947,9 @@ define SetupRunJtregTestBody
946947
$$(eval $1_TOTAL := 1) \
947948
)
948949

949-
$1: run-test-$1 parse-test-$1 clean-workdir-$1
950+
$1: run-test-$1 parse-test-$1 clean-outputdirs-$1
950951

951-
TARGETS += $1 run-test-$1 parse-test-$1 clean-workdir-$1
952+
TARGETS += $1 run-test-$1 parse-test-$1 clean-outputdirs-$1
952953
TEST_TARGETS += parse-test-$1
953954

954955
endef

make/ToolsJdk.gmk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ TOOL_GENERATECACERTS = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_class
7676
-Dkeystore.pkcs12.macAlgorithm=NONE \
7777
build.tools.generatecacerts.GenerateCacerts
7878

79-
TOOL_GENERATEEMOJIDATA = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
80-
build.tools.generateemojidata.GenerateEmojiData
79+
TOOL_GENERATEEXTRAPROPERTIES = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
80+
build.tools.generateextraproperties.GenerateExtraProperties
8181

8282
TOOL_MAKEZIPREPRODUCIBLE = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
8383
build.tools.makezipreproducible.MakeZipReproducible

make/autoconf/flags-cflags.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
818818
REPRODUCIBLE_CFLAGS=
819819
]
820820
)
821+
AC_SUBST(REPRODUCIBLE_CFLAGS)
821822
fi
822823
823824
# Prevent the __FILE__ macro from generating absolute paths into the built

make/autoconf/spec.gmk.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ LIBFFI_CFLAGS:=@LIBFFI_CFLAGS@
424424
ENABLE_LIBFFI_BUNDLING:=@ENABLE_LIBFFI_BUNDLING@
425425
LIBFFI_LIB_FILE:=@LIBFFI_LIB_FILE@
426426
FILE_MACRO_CFLAGS := @FILE_MACRO_CFLAGS@
427+
REPRODUCIBLE_CFLAGS := @REPRODUCIBLE_CFLAGS@
427428
BRANCH_PROTECTION_CFLAGS := @BRANCH_PROTECTION_CFLAGS@
428429

429430
STATIC_LIBS_CFLAGS := @STATIC_LIBS_CFLAGS@

make/common/NativeCompilation.gmk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,9 +1165,9 @@ define SetupNativeCompilationBody
11651165
$1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)`
11661166
endif
11671167

1168-
# If we are building static library, 'AR' on macosx may not support @-file.
1168+
# If we are building static library, 'AR' on macosx/aix may not support @-file.
11691169
ifeq ($$($1_TYPE), STATIC_LIBRARY)
1170-
ifeq ($(call isTargetOs, macosx), true)
1170+
ifeq ($(call isTargetOs, macosx aix), true)
11711171
$1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)`
11721172
endif
11731173
endif

make/hotspot/gensrc/GensrcAdlc.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ifeq ($(call check-jvm-feature, compiler2), true)
6262
ADLC_CFLAGS += -I$(TOPDIR)/src/hotspot/share
6363

6464
# Add file macro mappings
65-
ADLC_CFLAGS += $(FILE_MACRO_CFLAGS)
65+
ADLC_CFLAGS += $(FILE_MACRO_CFLAGS) $(REPRODUCIBLE_CFLAGS)
6666

6767
ifeq ($(UBSAN_ENABLED), true)
6868
ADLC_CFLAGS += $(UBSAN_CFLAGS)

make/jdk/src/classes/build/tools/compileproperties/CompileProperties.java

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

2626
package build.tools.compileproperties;
2727

28+
import java.io.BufferedReader;
2829
import java.io.BufferedWriter;
2930
import java.io.File;
3031
import java.io.FileInputStream;
@@ -33,6 +34,9 @@
3334
import java.io.IOException;
3435
import java.io.OutputStreamWriter;
3536
import java.io.Writer;
37+
import java.nio.charset.StandardCharsets;
38+
import java.nio.file.Files;
39+
import java.nio.file.Path;
3640
import java.text.MessageFormat;
3741
import java.util.ArrayList;
3842
import java.util.Collections;
@@ -220,8 +224,8 @@ private static boolean createFile(String propertiesPath, String outputPath,
220224
System.out.println("parsing: " + propertiesPath);
221225
}
222226
Properties p = new Properties();
223-
try {
224-
p.load(new FileInputStream(propertiesPath));
227+
try (BufferedReader input = Files.newBufferedReader(Path.of(propertiesPath))) {
228+
p.load(input);
225229
} catch ( FileNotFoundException e ) {
226230
ok = false;
227231
error("Cannot find file " + propertiesPath, e);
@@ -267,7 +271,7 @@ private static boolean createFile(String propertiesPath, String outputPath,
267271
Writer writer = null;
268272
try {
269273
writer = new BufferedWriter(
270-
new OutputStreamWriter(new FileOutputStream(outputPath), "8859_1"));
274+
new OutputStreamWriter(new FileOutputStream(outputPath), StandardCharsets.US_ASCII));
271275
MessageFormat format = new MessageFormat(FORMAT);
272276
writer.write(format.format(new Object[] { packageString, className, superClass, data }));
273277
} catch ( IOException e ) {

make/jdk/src/classes/build/tools/generatecharacter/PropList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private PropList(File file, int plane) throws IOException {
6464

6565
int i, j;
6666
BufferedReader sbfr = new BufferedReader(new FileReader(file));
67-
Matcher m = Pattern.compile("(\\p{XDigit}+)(?:\\.{2}(\\p{XDigit}+))?\\s*;\\s+(\\w+)\\s+#.*").matcher("");
67+
Matcher m = Pattern.compile("(\\p{XDigit}+)(?:\\.{2}(\\p{XDigit}+))?\\s*;\\s+(\\w+)[;\\s].*").matcher("");
6868
String line = null;
6969
int lineNo = 0;
7070
while ((line = sbfr.readLine()) != null) {
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/*
2+
* Copyright (c) 2023, 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. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package build.tools.generateextraproperties;
26+
27+
import java.io.IOException;
28+
import java.nio.file.Files;
29+
import java.nio.file.Paths;
30+
import java.nio.file.StandardOpenOption;
31+
import java.util.ArrayList;
32+
import java.util.Arrays;
33+
import java.util.HashMap;
34+
import java.util.List;
35+
import java.util.function.Predicate;
36+
import java.util.stream.Collectors;
37+
import java.util.stream.Stream;
38+
39+
/**
40+
* Parses extra properties files of UCD, and replaces the placeholders in
41+
* the given template source file with the generated conditions, then emits
42+
* .java files. For example, if the properties file has:
43+
* <blockquote>
44+
* 0009..000D ; Type (; Value)
45+
* 0020 ; Type (; Value)
46+
* 2000..200A ; Type (; Value)
47+
* </blockquote>
48+
* and the template file contains
49+
* <blockquote>
50+
* %%%Type(=Value)%%%
51+
* </blockquote>
52+
* then the generated .java file would have the following in place:
53+
* <blockquote>
54+
* (cp >= 0x0009 && cp <= 0x000D) ||
55+
* cp == 0x0020 ||
56+
* (cp >= 0x2000 && cp <= 0x200A);
57+
* </blockquote>
58+
* Note that those in parentheses in the properties file and the
59+
* template file are optional.
60+
*
61+
* Arguments to this utility:
62+
* args[0]: Full path string to the template file
63+
* args[1]: Full path string to the properties file
64+
* args[2]: Full path string to the generated .java file
65+
* args[3...]: Names of the property to generate the conditions
66+
*/
67+
public class GenerateExtraProperties {
68+
public static void main(String[] args) {
69+
var templateFile = Paths.get(args[0]);
70+
var propertiesFile = Paths.get(args[1]);
71+
var gensrcFile = Paths.get(args[2]);
72+
var propertyNames = Arrays.copyOfRange(args, 3, args.length);
73+
var replacementMap = new HashMap<String, String>();
74+
75+
try {
76+
for (var propertyName: propertyNames) {
77+
var pn = "; " + propertyName.replaceFirst("=", "; ");
78+
79+
List<Range> ranges = Files.lines(propertiesFile)
80+
.filter(Predicate.not(l -> l.startsWith("#") || l.isBlank()))
81+
.filter(l -> l.contains(pn))
82+
.map(l -> new Range(l.replaceFirst(" .*", "")))
83+
.sorted()
84+
.collect(ArrayList<Range>::new,
85+
(list, r) -> {
86+
// collapsing consecutive pictographic ranges
87+
int lastIndex = list.size() - 1;
88+
if (lastIndex >= 0) {
89+
Range lastRange = list.get(lastIndex);
90+
if (lastRange.last + 1 == r.start) {
91+
list.set(lastIndex, new Range(lastRange.start, r.last));
92+
return;
93+
}
94+
}
95+
list.add(r);
96+
},
97+
ArrayList<Range>::addAll);
98+
99+
100+
replacementMap.put("%%%" + propertyName + "%%%",
101+
ranges.stream()
102+
.map(GenerateExtraProperties::rangeToString)
103+
.collect(Collectors.joining(" ||\n", "", ";")));
104+
}
105+
106+
// Generate .java file
107+
Files.write(gensrcFile,
108+
Files.lines(templateFile)
109+
.flatMap(l -> Stream.of(replacementMap.getOrDefault(l.trim(), l)))
110+
.collect(Collectors.toList()),
111+
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
112+
} catch (IOException e) {
113+
e.printStackTrace();
114+
}
115+
}
116+
117+
static String rangeToString(Range r) {
118+
if (r.start == r.last) {
119+
return (" ".repeat(12) + "cp == 0x" + toHexString(r.start));
120+
} else if (r.start == r.last - 1) {
121+
return " ".repeat(12) + "cp == 0x" + toHexString(r.start) + " ||\n" +
122+
" ".repeat(12) + "cp == 0x" + toHexString(r.last);
123+
} else {
124+
return " ".repeat(11) + "(cp >= 0x" + toHexString(r.start) +
125+
" && cp <= 0x" + toHexString(r.last) + ")";
126+
}
127+
}
128+
129+
static int toInt(String hexStr) {
130+
return Integer.parseUnsignedInt(hexStr, 16);
131+
}
132+
133+
static String toHexString(int cp) {
134+
String ret = Integer.toUnsignedString(cp, 16).toUpperCase();
135+
if (ret.length() < 4) {
136+
ret = "0".repeat(4 - ret.length()) + ret;
137+
}
138+
return ret;
139+
}
140+
141+
static class Range implements Comparable<Range> {
142+
int start;
143+
int last;
144+
145+
Range (int start, int last) {
146+
this.start = start;
147+
this.last = last;
148+
}
149+
150+
Range (String input) {
151+
input = input.replaceFirst("\\s#.*", "");
152+
start = toInt(input.replaceFirst("[\\s\\.].*", ""));
153+
last = input.contains("..") ?
154+
toInt(input.replaceFirst(".*\\.\\.", "")
155+
.replaceFirst(";.*", "").trim())
156+
: start;
157+
}
158+
159+
@Override
160+
public String toString() {
161+
return "Start: " + toHexString(start) + ", Last: " + toHexString(last);
162+
}
163+
164+
@Override
165+
public int compareTo(Range other) {
166+
return Integer.compare(start, other.start);
167+
}
168+
}
169+
}

make/langtools/tools/compileproperties/CompileProperties.java

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

2626
package compileproperties;
2727

28+
import java.io.BufferedReader;
2829
import java.io.BufferedWriter;
2930
import java.io.File;
3031
import java.io.FileInputStream;
@@ -33,6 +34,9 @@
3334
import java.io.IOException;
3435
import java.io.OutputStreamWriter;
3536
import java.io.Writer;
37+
import java.nio.charset.StandardCharsets;
38+
import java.nio.file.Files;
39+
import java.nio.file.Path;
3640
import java.text.MessageFormat;
3741
import java.util.ArrayList;
3842
import java.util.Collections;
@@ -199,8 +203,8 @@ private boolean createFile(String propertiesPath, String outputPath,
199203
boolean ok = true;
200204
log.verbose("parsing: " + propertiesPath);
201205
Properties p = new Properties();
202-
try {
203-
p.load(new FileInputStream(propertiesPath));
206+
try (BufferedReader input = Files.newBufferedReader(Path.of(propertiesPath))) {
207+
p.load(input);
204208
} catch ( FileNotFoundException e ) {
205209
ok = false;
206210
log.error("Cannot find file " + propertiesPath, e);
@@ -246,7 +250,7 @@ private boolean createFile(String propertiesPath, String outputPath,
246250
Writer writer = null;
247251
try {
248252
writer = new BufferedWriter(
249-
new OutputStreamWriter(new FileOutputStream(outputPath), "8859_1"));
253+
new OutputStreamWriter(new FileOutputStream(outputPath), StandardCharsets.US_ASCII));
250254
MessageFormat format = new MessageFormat(FORMAT);
251255
writer.write(format.format(new Object[] { packageString, className, superClass, data }));
252256
} catch ( IOException e ) {

0 commit comments

Comments
 (0)