Skip to content

Commit dd60744

Browse files
authored
Merge pull request #1869 from SAP/pr-jdk-11.0.26+2
Merge to tag jdk-11.0.26+2
2 parents 151fa83 + c99638d commit dd60744

File tree

9 files changed

+155
-118
lines changed

9 files changed

+155
-118
lines changed

make/autoconf/flags-cflags.m4

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS],
192192
DISABLE_WARNING_PREFIX="-Wno-"
193193
BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
194194
CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
195+
196+
WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2"
197+
WARNINGS_ENABLE_ADDITIONAL_JVM="-Wpointer-arith -Wsign-compare -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual -Wreturn-type"
198+
199+
DISABLED_WARNINGS="unused-parameter unused"
200+
195201
;;
196202
197203
clang)
@@ -200,7 +206,7 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS],
200206
CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
201207
202208
WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2"
203-
WARNINGS_ENABLE_ADDITIONAL_JVM="-Wpointer-arith -Wsign-compare -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual -Wreorder"
209+
WARNINGS_ENABLE_ADDITIONAL_JVM="-Wpointer-arith -Wsign-compare -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual"
204210
205211
DISABLED_WARNINGS="unused-parameter unused"
206212
;;

make/autoconf/hotspot.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
378378
fi
379379
else
380380
DISABLED_JVM_FEATURES="$DISABLED_JVM_FEATURES shenandoahgc"
381+
AC_MSG_RESULT([no, must be manually enabled --with-jvm-features=shenandoahgc])
381382
fi
382383
383384
# Only enable ZGC on supported platforms

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ javax/swing/JComboBox/8182031/ComboPopupTest.java 8196465 linux-all,macosx-all
710710
javax/swing/JFileChooser/6738668/bug6738668.java 8194946 generic-all
711711
javax/swing/JFileChooser/8062561/bug8062561.java 8196466 linux-all,macosx-all
712712
javax/swing/JInternalFrame/Test6325652.java 8196467 macosx-all
713-
javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java 8225045 linux-all
714713
javax/swing/JLabel/6596966/bug6596966.java 8040914 macosx-all
715714
javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all
716715
javax/swing/JSpinner/8223788/JSpinnerButtonFocusTest.java 8238085 macosx-all

test/jdk/java/net/httpclient/reactivestreams-tck/org/reactivestreams/tck/SubscriberWhiteboxVerification.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ public void required_spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCall
278278
@Override
279279
public void run(WhiteboxTestStage stage) throws InterruptedException {
280280
stage.puppet().triggerRequest(1);
281-
stage.puppet().signalCancel();
282281
stage.expectRequest();
282+
stage.puppet().signalCancel();
283+
stage.expectCancelling();
283284
stage.signalNext();
284285

285286
stage.puppet().triggerRequest(1);
@@ -824,11 +825,17 @@ public interface SubscriberPuppet {
824825
* Before sending any element to the subscriber, the TCK must wait for the subscriber to request that element, and
825826
* must be prepared for the subscriber to only request one element at a time, it is not enough for the TCK to
826827
* simply invoke this method before sending elements.
828+
* <p>
829+
* An invocation of {@link #signalCancel()} may be coalesced into any elements that have not yet been requested,
830+
* such that only a cancel signal is emitted.
827831
*/
828832
void triggerRequest(long elements);
829833

830834
/**
831-
* Trigger {@code cancel()} on your {@link Subscriber}
835+
* Trigger {@code cancel()} on your {@link Subscriber}.
836+
* <p>
837+
* An invocation of this method may be coalesced into any outstanding requests, as requested by
838+
*{@link #triggerRequest(long)}, such that only a cancel signal is emitted.
832839
*/
833840
void signalCancel();
834841
}

test/jdk/java/text/Format/DateFormat/DateFormatRegression.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2020, 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
@@ -1067,7 +1067,7 @@ public void Test4261506() {
10671067
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
10681068
SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN);
10691069
@SuppressWarnings("deprecation")
1070-
String result = fmt.format(new Date(1999, 0, 1));
1070+
String result = fmt.format(new Date(1999 - 1900, 0, 1));
10711071
logln("format()=>" + result);
10721072
if (!result.endsWith("PST")) {
10731073
errln("FAIL: SimpleDataFormat.format() did not retrun PST");

test/jdk/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, 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
@@ -180,7 +180,7 @@ Object[][] data_time() {
180180
@Test(dataProvider="time")
181181
public void test_time_print(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) {
182182
DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale);
183-
Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
183+
Date oldDate = new Date(1970 - 1900, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
184184
String text = old.format(oldDate);
185185

186186
DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale);
@@ -192,7 +192,7 @@ public void test_time_print(LocalTime time, FormatStyle timeStyle, int timeStyle
192192
@Test(dataProvider="time")
193193
public void test_time_parse(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) {
194194
DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale);
195-
Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
195+
Date oldDate = new Date(1970 - 1900, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
196196
String text = old.format(oldDate);
197197

198198
DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale);

test/jdk/java/util/Calendar/FieldStateTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2020, 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
@@ -147,7 +147,7 @@ public void TestFieldState() {
147147
+ "Then, getTime and set week of year to 43.");
148148

149149
@SuppressWarnings("deprecation")
150-
Date d = new Date(2003 - 1990, OCTOBER, 31);
150+
Date d = new Date(2003 - 1900, OCTOBER, 31);
151151
cal.setTime(d);
152152
cal.set(DAY_OF_WEEK, SUNDAY);
153153
cal.set(2003, OCTOBER, 31); // 2003/10/31 is Friday.
Lines changed: 120 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright 2012 Google, Inc. All Rights Reserved.
3+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
56
* This code is free software; you can redistribute it and/or modify it
@@ -24,124 +25,137 @@
2425
/**
2526
* @test
2627
* @bug 8056934
27-
* @summary Check ability to read zip files created by python zipfile
28-
* implementation, which fails to write optional (but recommended) data
29-
* descriptor signatures. Repro scenario is a Java -> Python -> Java round trip:
30-
* - ZipOutputStream creates zip file with DEFLATED entries and data
31-
* descriptors with optional signature "PK0x0708".
32-
* - Python reads those entries, preserving the 0x08 flag byte
33-
* - Python outputs those entries with data descriptors lacking the
34-
* optional signature.
35-
* - ZipInputStream cannot handle the missing signature
36-
*
28+
* @summary Verify the ability to read zip files whose local header
29+
* data descriptor is missing the optional signature
30+
* <p>
3731
* No way to adapt the technique in this test to get a ZIP64 zip file
3832
* without data descriptors was found.
39-
*
40-
* @ignore This test has brittle dependencies on an external working python.
33+
* @run junit DataDescriptorSignatureMissing
4134
*/
4235

36+
37+
import org.junit.jupiter.api.Test;
38+
4339
import java.io.*;
40+
import java.nio.ByteBuffer;
41+
import java.nio.ByteOrder;
42+
import java.nio.charset.StandardCharsets;
4443
import java.util.zip.*;
4544

46-
public class DataDescriptorSignatureMissing {
47-
void printStream(InputStream is) throws IOException {
48-
Reader r = new InputStreamReader(is);
49-
StringBuilder sb = new StringBuilder();
50-
char[] buf = new char[1024];
51-
int n;
52-
while ((n = r.read(buf)) > 0) {
53-
sb.append(buf, 0, n);
54-
}
55-
System.out.print(sb);
56-
}
45+
import static org.junit.jupiter.api.Assertions.*;
46+
47+
public class DataDescriptorSignatureMissing {
48+
49+
/**
50+
* Verify that ZipInputStream correctly parses a ZIP with a Data Descriptor without
51+
* the recommended but optional signature.
52+
*/
53+
@Test
54+
public void shouldParseSignaturelessDescriptor() throws IOException {
55+
// The ZIP with a signature-less descriptor
56+
byte[] zip = makeZipWithSignaturelessDescriptor();
5757

58-
int entryCount(File zipFile) throws IOException {
59-
try (FileInputStream fis = new FileInputStream(zipFile);
60-
ZipInputStream zis = new ZipInputStream(fis)) {
61-
for (int count = 0;; count++)
62-
if (zis.getNextEntry() == null)
63-
return count;
58+
// ZipInputStream should read the signature-less data descriptor
59+
try (ZipInputStream in = new ZipInputStream(
60+
new ByteArrayInputStream(zip))) {
61+
ZipEntry first = in.getNextEntry();
62+
assertNotNull(first, "Zip file is unexpectedly missing first entry");
63+
assertEquals("first", first.getName());
64+
assertArrayEquals("first".getBytes(StandardCharsets.UTF_8), in.readAllBytes());
65+
66+
ZipEntry second = in.getNextEntry();
67+
assertNotNull(second, "Zip file is unexpectedly missing second entry");
68+
assertEquals("second", second.getName());
69+
assertArrayEquals("second".getBytes(StandardCharsets.UTF_8), in.readAllBytes());
6470
}
71+
6572
}
6673

67-
void test(String[] args) throws Throwable {
68-
if (! new File("/usr/bin/python").canExecute())
69-
return;
70-
71-
// Create a java zip file with DEFLATED entries and data
72-
// descriptors with signatures.
73-
final File in = new File("in.zip");
74-
final File out = new File("out.zip");
75-
final int count = 3;
76-
try (FileOutputStream fos = new FileOutputStream(in);
77-
ZipOutputStream zos = new ZipOutputStream(fos)) {
78-
for (int i = 0; i < count; i++) {
79-
ZipEntry ze = new ZipEntry("hello.python" + i);
80-
ze.setMethod(ZipEntry.DEFLATED);
81-
zos.putNextEntry(ze);
82-
zos.write(new byte[10]);
83-
zos.closeEntry();
84-
}
74+
/**
75+
* The 'Data descriptor' record is used to facilitate ZIP streaming. If the size of an
76+
* entry is unknown at the time the LOC header is written, bit 3 of the General Purpose Bit Flag
77+
* is set, and the File data is immediately followed by the 'Data descriptor' record. This record
78+
* then contains the compressed and uncompressed sizes of the entry and also the CRC value.
79+
*
80+
* The 'Data descriptor' record is usually preceded by the recommended, but optional
81+
* signature value 0x08074b50.
82+
*
83+
* A ZIP entry in streaming mode has the following structure:
84+
*
85+
* ------ Local File Header ------
86+
* 000000 signature 0x04034b50
87+
* 000004 version 20
88+
* 000006 flags 0x0808 # Notice bit 3 is set
89+
* [..] Omitted for brevity
90+
*
91+
* ------ File Data ------
92+
* 000035 data 7 bytes
93+
*
94+
* ------ Data Descriptor ------
95+
* 000042 signature 0x08074b50
96+
* 000046 crc 0x3610a686
97+
* 000050 csize 7
98+
* 000054 size 5
99+
*
100+
* A signature-less data descriptor will look like the following:
101+
*
102+
* ------ Data Descriptor ------
103+
* 000042 crc 0x3610a686
104+
* 000046 csize 7
105+
* 000050 size 5
106+
*
107+
* This method produces a ZIP with two entries, where the first entry
108+
* is made signature-less.
109+
*/
110+
private static byte[] makeZipWithSignaturelessDescriptor() throws IOException {
111+
// Offset of the signed data descriptor
112+
int sigOffset;
113+
114+
ByteArrayOutputStream out = new ByteArrayOutputStream();
115+
try (ZipOutputStream zo = new ZipOutputStream(out)) {
116+
// Write a first entry
117+
zo.putNextEntry(new ZipEntry("first"));
118+
zo.write("first".getBytes(StandardCharsets.UTF_8));
119+
// Force the data descriptor to be written out
120+
zo.closeEntry();
121+
// Signed data descriptor starts 16 bytes before current offset
122+
sigOffset = out.size() - 4 * Integer.BYTES;
123+
// Add a second entry
124+
zo.putNextEntry(new ZipEntry("second"));
125+
zo.write("second".getBytes(StandardCharsets.UTF_8));
85126
}
86127

87-
// Copy the zip file using python's zipfile module
88-
String[] python_program_lines = {
89-
"import os",
90-
"import zipfile",
91-
"input_zip = zipfile.ZipFile('in.zip', mode='r')",
92-
"output_zip = zipfile.ZipFile('out.zip', mode='w')",
93-
"count08 = 0",
94-
"for input_info in input_zip.infolist():",
95-
" output_info = input_info",
96-
" if output_info.flag_bits & 0x08 == 0x08:",
97-
" count08 += 1",
98-
" output_zip.writestr(output_info, input_zip.read(input_info))",
99-
"output_zip.close()",
100-
"if count08 == 0:",
101-
" raise ValueError('Expected to see entries with 0x08 flag_bits set')",
102-
};
103-
StringBuilder python_program_builder = new StringBuilder();
104-
for (String line : python_program_lines)
105-
python_program_builder.append(line).append('\n');
106-
String python_program = python_program_builder.toString();
107-
String[] cmdline = { "/usr/bin/python", "-c", python_program };
108-
ProcessBuilder pb = new ProcessBuilder(cmdline);
109-
pb.redirectErrorStream(true);
110-
Process p = pb.start();
111-
printStream(p.getInputStream());
112-
p.waitFor();
113-
equal(p.exitValue(), 0);
114-
115-
File pythonZipFile = new File("out.zip");
116-
check(pythonZipFile.exists());
117-
118-
equal(entryCount(in),
119-
entryCount(out));
120-
121-
// We expect out to be identical to in, except for the removal of
122-
// the optional data descriptor signatures.
123-
final int SIG_LENGTH = 4; // length of a zip signature - PKxx
124-
equal(in.length(),
125-
out.length() + SIG_LENGTH * count);
126-
127-
in.delete();
128-
out.delete();
129-
}
128+
// The generated ZIP file with a signed data descriptor
129+
byte[] sigZip = out.toByteArray();
130+
131+
// The offset of the CRC immediately following the 4-byte signature
132+
int crcOffset = sigOffset + Integer.BYTES;
133+
134+
// Create a ZIP file with a signature-less data descriptor for the first entry
135+
ByteArrayOutputStream sigLess = new ByteArrayOutputStream();
136+
sigLess.write(sigZip, 0, sigOffset);
137+
// Skip the signature
138+
sigLess.write(sigZip, crcOffset, sigZip.length - crcOffset);
139+
140+
byte[] siglessZip = sigLess.toByteArray();
130141

131-
//--------------------- Infrastructure ---------------------------
132-
volatile int passed = 0, failed = 0;
133-
void pass() {passed++;}
134-
void fail() {failed++; Thread.dumpStack();}
135-
void fail(String msg) {System.err.println(msg); fail();}
136-
void unexpected(Throwable t) {failed++; t.printStackTrace();}
137-
void check(boolean cond) {if (cond) pass(); else fail();}
138-
void equal(Object x, Object y) {
139-
if (x == null ? y == null : x.equals(y)) pass();
140-
else fail(x + " not equal to " + y);}
141-
public static void main(String[] args) throws Throwable {
142-
new DataDescriptorSignatureMissing().instanceMain(args);}
143-
public void instanceMain(String[] args) throws Throwable {
144-
try {test(args);} catch (Throwable t) {unexpected(t);}
145-
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
146-
if (failed > 0) throw new AssertionError("Some tests failed");}
142+
// Adjust the CEN offset in the END header
143+
ByteBuffer buffer = ByteBuffer.wrap(siglessZip).order(ByteOrder.LITTLE_ENDIAN);
144+
// Reduce cenOffset by 4 bytes
145+
int cenOff = siglessZip.length - ZipFile.ENDHDR + ZipFile.ENDOFF;
146+
int realCenOff = buffer.getInt(cenOff) - Integer.BYTES;
147+
buffer.putInt(cenOff, realCenOff);
148+
149+
// Adjust the LOC offset in the second CEN header
150+
int cen = realCenOff;
151+
// Skip past the first CEN header
152+
int nlen = buffer.getShort(cen + ZipFile.CENNAM);
153+
cen += ZipFile.CENHDR + nlen;
154+
155+
// Reduce LOC offset by 4 bytes
156+
int locOff = cen + ZipFile.CENOFF;
157+
buffer.putInt(locOff, buffer.getInt(locOff) - Integer.BYTES);
158+
159+
return siglessZip;
160+
}
147161
}

0 commit comments

Comments
 (0)