mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
Merge
This commit is contained in:
commit
f52ea8839e
19 changed files with 223 additions and 107 deletions
1
.hgtags
1
.hgtags
|
@ -474,3 +474,4 @@ dfa46cfe56346884a61efdc30dc50f7505d66761 jdk-11+1
|
|||
663f20fc51091bd7f95d18448850ba091207b7bd jdk-10+44
|
||||
4f96cf952e71cb8a127334494faf28880c26181b jdk-10+45
|
||||
1fd4d6068f54561cfc67d54fc9ca84af7212c4f8 jdk-11+3
|
||||
e59941f7247d451fa7df9eaef3fce0f492f8420c jdk-11+4
|
||||
|
|
|
@ -48,6 +48,7 @@ $(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
|
|||
$(RM) -r $(INTERIM_IMAGE_DIR)
|
||||
$(JLINK_TOOL) \
|
||||
--output $(INTERIM_IMAGE_DIR) \
|
||||
--disable-plugin generate-jli-classes \
|
||||
--add-modules $(INTERIM_MODULES_LIST)
|
||||
$(TOUCH) $@
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ VS_MSVCR_2017=vcruntime140.dll
|
|||
VS_MSVCP_2017=msvcp140.dll
|
||||
VS_ENVVAR_2017="VS150COMNTOOLS"
|
||||
VS_VS_INSTALLDIR_2017="Microsoft Visual Studio/2017"
|
||||
VS_EDITIONS_2017="Community Professional Enterprise"
|
||||
VS_EDITIONS_2017="BuildTools Community Professional Enterprise"
|
||||
VS_SDK_INSTALLDIR_2017=
|
||||
VS_VS_PLATFORM_NAME_2017="v141"
|
||||
VS_SDK_PLATFORM_NAME_2017=
|
||||
|
|
|
@ -77,7 +77,6 @@ public class ResultSet {
|
|||
"line.separator",
|
||||
"file.separator",
|
||||
"file.encoding",
|
||||
"file.encoding.pkg",
|
||||
"java.class.path",
|
||||
"java.library.path",
|
||||
"java.io.tmpdir",
|
||||
|
|
|
@ -3590,7 +3590,8 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
*/
|
||||
public static UnicodeBlock of(int codePoint) {
|
||||
if (!isValidCodePoint(codePoint)) {
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Not a valid Unicode code point: 0x%X", codePoint));
|
||||
}
|
||||
|
||||
int top, bottom, current;
|
||||
|
@ -3649,7 +3650,8 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
public static final UnicodeBlock forName(String blockName) {
|
||||
UnicodeBlock block = map.get(blockName.toUpperCase(Locale.US));
|
||||
if (block == null) {
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException("Not a valid block name: "
|
||||
+ blockName);
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
@ -7394,7 +7396,8 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
*/
|
||||
public static UnicodeScript of(int codePoint) {
|
||||
if (!isValidCodePoint(codePoint))
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Not a valid Unicode code point: 0x%X", codePoint));
|
||||
int type = getType(codePoint);
|
||||
// leave SURROGATE and PRIVATE_USE for table lookup
|
||||
if (type == UNASSIGNED)
|
||||
|
@ -8088,7 +8091,8 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
toSurrogates(codePoint, dst, dstIndex);
|
||||
return 2;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Not a valid Unicode code point: 0x%X", codePoint));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8116,7 +8120,8 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
toSurrogates(codePoint, result, 0);
|
||||
return result;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Not a valid Unicode code point: 0x%X", codePoint));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10178,7 +10183,8 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
*/
|
||||
public static String getName(int codePoint) {
|
||||
if (!isValidCodePoint(codePoint)) {
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Not a valid Unicode code point: 0x%X", codePoint));
|
||||
}
|
||||
String name = CharacterName.getInstance().getName(codePoint);
|
||||
if (name != null)
|
||||
|
|
|
@ -3178,6 +3178,7 @@ public final class String
|
|||
return new String(StringUTF16.toBytesSupplementary(codePoint), UTF16);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Not a valid Unicode code point");
|
||||
throw new IllegalArgumentException(
|
||||
format("Not a valid Unicode code point: 0x%X", codePoint));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package java.lang.ref;
|
||||
|
||||
import jdk.internal.vm.annotation.DontInline;
|
||||
import jdk.internal.vm.annotation.ForceInline;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.JavaLangRefAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
@ -420,10 +420,12 @@ public abstract class Reference<T> {
|
|||
* @param ref the reference. If {@code null}, this method has no effect.
|
||||
* @since 9
|
||||
*/
|
||||
@DontInline
|
||||
@ForceInline
|
||||
public static void reachabilityFence(Object ref) {
|
||||
// Does nothing, because this method is annotated with @DontInline
|
||||
// HotSpot needs to retain the ref and not GC it before a call to this
|
||||
// method
|
||||
// Does nothing. This method is annotated with @ForceInline to eliminate
|
||||
// most of the overhead that using @DontInline would cause with the
|
||||
// HotSpot JVM, when this fence is used in a wide variety of situations.
|
||||
// HotSpot JVM retains the ref and does not GC it before a call to
|
||||
// this method, because the JIT-compilers do not have GC-only safepoints.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -32,24 +32,40 @@ class XXX {
|
|||
#if[rw]
|
||||
|
||||
private $type$ get$Type$(long a) {
|
||||
try {
|
||||
$memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian);
|
||||
return $fromBits$(x);
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
}
|
||||
|
||||
public $type$ get$Type$() {
|
||||
try {
|
||||
return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$)));
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
}
|
||||
|
||||
public $type$ get$Type$(int i) {
|
||||
try {
|
||||
return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)));
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
}
|
||||
|
||||
#end[rw]
|
||||
|
||||
private ByteBuffer put$Type$(long a, $type$ x) {
|
||||
#if[rw]
|
||||
try {
|
||||
$memtype$ y = $toBits$(x);
|
||||
UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian);
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
return this;
|
||||
#else[rw]
|
||||
throw new ReadOnlyBufferException();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -28,6 +28,7 @@
|
|||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.lang.ref.Reference;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.ref.Cleaner;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
@ -257,16 +258,28 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
}
|
||||
|
||||
public $type$ get() {
|
||||
try {
|
||||
return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(nextGetIndex()))));
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
}
|
||||
|
||||
public $type$ get(int i) {
|
||||
try {
|
||||
return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(checkIndex(i)))));
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
}
|
||||
|
||||
#if[streamableType]
|
||||
$type$ getUnchecked(int i) {
|
||||
try {
|
||||
return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(i))));
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
}
|
||||
#end[streamableType]
|
||||
|
||||
|
@ -282,6 +295,7 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
throw new BufferUnderflowException();
|
||||
|
||||
long dstOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
|
||||
try {
|
||||
#if[!byte]
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
UNSAFE.copySwapMemory(null,
|
||||
|
@ -297,6 +311,9 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
dst,
|
||||
dstOffset,
|
||||
(long)length << $LG_BYTES_PER_VALUE$);
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
|
@ -311,7 +328,11 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
|
||||
public $Type$Buffer put($type$ x) {
|
||||
#if[rw]
|
||||
try {
|
||||
UNSAFE.put$Swaptype$(ix(nextPutIndex()), $swap$($toBits$(x)));
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
return this;
|
||||
#else[rw]
|
||||
throw new ReadOnlyBufferException();
|
||||
|
@ -320,7 +341,11 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
|
||||
public $Type$Buffer put(int i, $type$ x) {
|
||||
#if[rw]
|
||||
try {
|
||||
UNSAFE.put$Swaptype$(ix(checkIndex(i)), $swap$($toBits$(x)));
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
return this;
|
||||
#else[rw]
|
||||
throw new ReadOnlyBufferException();
|
||||
|
@ -346,7 +371,12 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
try {
|
||||
UNSAFE.copyMemory(sb.ix(spos), ix(pos), (long)srem << $LG_BYTES_PER_VALUE$);
|
||||
} finally {
|
||||
Reference.reachabilityFence(sb);
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
@ -380,6 +410,7 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
throw new BufferOverflowException();
|
||||
|
||||
long srcOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
|
||||
try {
|
||||
#if[!byte]
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
UNSAFE.copySwapMemory(src,
|
||||
|
@ -395,6 +426,9 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
null,
|
||||
ix(pos),
|
||||
(long)length << $LG_BYTES_PER_VALUE$);
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
|
@ -411,8 +445,11 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
try {
|
||||
UNSAFE.copyMemory(ix(pos), ix(0), (long)rem << $LG_BYTES_PER_VALUE$);
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
|
@ -497,19 +534,6 @@ class Direct$Type$Buffer$RW$$BO$
|
|||
|
||||
|
||||
#if[byte]
|
||||
|
||||
byte _get(int i) { // package-private
|
||||
return UNSAFE.getByte(address + i);
|
||||
}
|
||||
|
||||
void _put(int i, byte b) { // package-private
|
||||
#if[rw]
|
||||
UNSAFE.putByte(address + i, b);
|
||||
#else[rw]
|
||||
throw new ReadOnlyBufferException();
|
||||
#end[rw]
|
||||
}
|
||||
|
||||
// #BIN
|
||||
//
|
||||
// Binary-data access methods for short, char, int, long, float,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.lang.ref.Reference;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
|
||||
|
@ -166,10 +167,16 @@ public abstract class MappedByteBuffer
|
|||
int count = Bits.pageCount(length);
|
||||
long a = mappingAddress(offset);
|
||||
byte x = 0;
|
||||
try {
|
||||
for (int i=0; i<count; i++) {
|
||||
// TODO consider changing to getByteOpaque thus avoiding
|
||||
// dead code elimination and the need to calculate a checksum
|
||||
x ^= unsafe.getByte(a);
|
||||
a += ps;
|
||||
}
|
||||
} finally {
|
||||
Reference.reachabilityFence(this);
|
||||
}
|
||||
if (unused != 0)
|
||||
unused = x;
|
||||
|
||||
|
|
|
@ -1749,11 +1749,6 @@ public abstract class $Type$Buffer
|
|||
|
||||
abstract ByteBuffer slice(int pos, int lim);
|
||||
|
||||
// Unchecked accessors, for use by ByteBufferAs-X-Buffer classes
|
||||
//
|
||||
abstract byte _get(int i); // package-private
|
||||
abstract void _put(int i, byte b); // package-private
|
||||
|
||||
// #BIN
|
||||
//
|
||||
// Binary-data access methods for short, char, int, long, float,
|
||||
|
|
|
@ -247,7 +247,6 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
|||
* user.language
|
||||
* user.script, user.country, user.variant (if user's environment specifies them)
|
||||
* file.encoding
|
||||
* file.encoding.pkg
|
||||
*/
|
||||
PUTPROP(props, "user.language", sprops->language);
|
||||
if (sprops->script) {
|
||||
|
@ -266,7 +265,6 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
|||
if (sprops->sun_stderr_encoding != NULL) {
|
||||
PUTPROP(props, "sun.stderr.encoding", sprops->sun_stderr_encoding);
|
||||
}
|
||||
PUTPROP(props, "file.encoding.pkg", "sun.io");
|
||||
|
||||
/* unicode_encoding specifies the default endianness */
|
||||
PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
|
||||
|
|
|
@ -629,7 +629,6 @@ GetJavaProperties(JNIEnv* env)
|
|||
* user.language
|
||||
* user.script, user.country, user.variant (if user's environment specifies them)
|
||||
* file.encoding
|
||||
* file.encoding.pkg
|
||||
*/
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -122,9 +122,11 @@ public class ReachabilityFenceTest {
|
|||
}
|
||||
}
|
||||
|
||||
Reference.reachabilityFence(o);
|
||||
|
||||
try {
|
||||
return finalized.get();
|
||||
} finally {
|
||||
Reference.reachabilityFence(o);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyFinalizeable {
|
||||
|
|
|
@ -30,23 +30,28 @@ import java.io.IOException;
|
|||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.OutputAnalyzer;
|
||||
import jdk.testlibrary.ProcessTools;
|
||||
import jdk.test.lib.JDKToolFinder;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8058520
|
||||
* @bug 8058520 8196748
|
||||
* @summary jar tf and jar xf should work on zip files with leading garbage
|
||||
* @library /lib/testlibrary
|
||||
* @library /test/lib
|
||||
* @run testng LeadingGarbage
|
||||
*/
|
||||
@Test
|
||||
public class LeadingGarbage {
|
||||
final String jar =
|
||||
Paths.get(System.getProperty("java.home"), "bin", "jar").toString();
|
||||
|
||||
final File[] files = { new File("a"), new File("b") };
|
||||
final File normalZip = new File("normal.zip");
|
||||
final File leadingGarbageZip = new File("leadingGarbage.zip");
|
||||
|
@ -74,12 +79,10 @@ public class LeadingGarbage {
|
|||
|
||||
void createNormalZip() throws Throwable {
|
||||
createFiles();
|
||||
String[] cmd = { jar, "c0Mf", "normal.zip", "a", "b" };
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd);
|
||||
OutputAnalyzer a = ProcessTools.executeProcess(pb);
|
||||
OutputAnalyzer a = jar("c0Mf", "normal.zip", "a", "b");
|
||||
a.shouldHaveExitValue(0);
|
||||
a.stdoutShouldMatch("\\A\\Z");
|
||||
a.stderrShouldMatch("\\A\\Z");
|
||||
a.stderrShouldMatchIgnoreVMWarnings("\\A\\Z");
|
||||
deleteFiles();
|
||||
}
|
||||
|
||||
|
@ -104,15 +107,13 @@ public class LeadingGarbage {
|
|||
}
|
||||
|
||||
void assertCanList(String zipFileName) throws Throwable {
|
||||
String[] cmd = { jar, "tf", zipFileName };
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd);
|
||||
OutputAnalyzer a = ProcessTools.executeProcess(pb);
|
||||
OutputAnalyzer a = jar("tf", zipFileName);
|
||||
a.shouldHaveExitValue(0);
|
||||
StringBuilder expected = new StringBuilder();
|
||||
for (File file : files)
|
||||
expected.append(file.getName()).append(System.lineSeparator());
|
||||
a.stdoutShouldMatch(expected.toString());
|
||||
a.stderrShouldMatch("\\A\\Z");
|
||||
a.stderrShouldMatchIgnoreVMWarnings("\\A\\Z");
|
||||
}
|
||||
|
||||
public void test_canExtract() throws Throwable {
|
||||
|
@ -126,13 +127,20 @@ public class LeadingGarbage {
|
|||
}
|
||||
|
||||
void assertCanExtract(String zipFileName) throws Throwable {
|
||||
String[] cmd = { jar, "xf", zipFileName };
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd);
|
||||
OutputAnalyzer a = ProcessTools.executeProcess(pb);
|
||||
OutputAnalyzer a = jar("xf", zipFileName);
|
||||
a.shouldHaveExitValue(0);
|
||||
a.stdoutShouldMatch("\\A\\Z");
|
||||
a.stderrShouldMatch("\\A\\Z");
|
||||
a.stderrShouldMatchIgnoreVMWarnings("\\A\\Z");
|
||||
assertFilesExist();
|
||||
}
|
||||
|
||||
OutputAnalyzer jar(String... args) throws Throwable {
|
||||
String jar = JDKToolFinder.getJDKTool("jar");
|
||||
List<String> cmds = new ArrayList<>();
|
||||
cmds.add(jar);
|
||||
cmds.addAll(Utils.getForwardVmOptions());
|
||||
Stream.of(args).forEach(x -> cmds.add(x));
|
||||
ProcessBuilder p = new ProcessBuilder(cmds);
|
||||
return ProcessTools.executeCommand(p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ import static java.lang.System.out;
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8167328 8171830 8165640 8174248 8176772
|
||||
* @bug 8167328 8171830 8165640 8174248 8176772 8196748
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler
|
||||
* jdk.jartool
|
||||
|
@ -155,6 +155,8 @@ public class Basic {
|
|||
} else if (line.startsWith("contains:")) {
|
||||
line = line.substring("contains:".length());
|
||||
conceals = stringToSet(line);
|
||||
} else if (line.contains("VM warning:")) {
|
||||
continue; // ignore server vm warning see#8196748
|
||||
} else {
|
||||
throw new AssertionError("Unknown value " + line);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
# @bug 8196748
|
||||
* @summary Tests for API validator.
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
|
@ -86,7 +87,7 @@ public class ApiValidatorTest extends MRTestBase {
|
|||
".");
|
||||
if (isAcceptable) {
|
||||
result.shouldHaveExitValue(SUCCESS)
|
||||
.shouldBeEmpty();
|
||||
.shouldBeEmptyIgnoreVMWarnings();
|
||||
} else {
|
||||
result.shouldNotHaveExitValue(SUCCESS)
|
||||
.shouldContain("contains a class with different api from earlier version");
|
||||
|
@ -417,4 +418,3 @@ public class ApiValidatorTest extends MRTestBase {
|
|||
javac(classes, sourceFiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
# @bug 8186087
|
||||
# @bug 8186087 8196748
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* jdk.compiler
|
||||
|
@ -127,7 +127,7 @@ public class Basic extends MRTestBase {
|
|||
jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
|
||||
"--release", release, "-C", classes.resolve("v10").toString(), ".")
|
||||
.shouldHaveExitValue(SUCCESS)
|
||||
.shouldBeEmpty();
|
||||
.shouldBeEmptyIgnoreVMWarnings();
|
||||
}
|
||||
// invalid
|
||||
for (String release : List.of("9.0", "8", "v9",
|
||||
|
@ -335,7 +335,7 @@ public class Basic extends MRTestBase {
|
|||
jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
|
||||
"--release", "9", "-C", classes.resolve("v9").toString(), ".")
|
||||
.shouldHaveExitValue(SUCCESS)
|
||||
.shouldBeEmpty();
|
||||
.shouldBeEmptyIgnoreVMWarnings();
|
||||
jar("uf", jarfile,
|
||||
"--release", "10", "-C", classes.resolve("v9").toString(), ".")
|
||||
.shouldHaveExitValue(SUCCESS)
|
||||
|
@ -417,7 +417,7 @@ public class Basic extends MRTestBase {
|
|||
"-C", classes.resolve("base").toString(), ".",
|
||||
"--release", "9", "-C", classes.resolve("v9").toString(), ".")
|
||||
.shouldNotHaveExitValue(SUCCESS)
|
||||
.asLines();
|
||||
.asLinesWithoutVMWarnings();
|
||||
|
||||
/* "META-INF/versions/9/version/Nested$nested.class" is really NOT isolated
|
||||
assertTrue(output.size() == 4);
|
||||
|
@ -516,7 +516,7 @@ public class Basic extends MRTestBase {
|
|||
"-C", classes.resolve("base").toString(), ".",
|
||||
"--release", "10", "-C", classes.resolve("v10").toString(), ".")
|
||||
.shouldHaveExitValue(SUCCESS)
|
||||
.shouldBeEmpty();
|
||||
.shouldBeEmptyIgnoreVMWarnings();
|
||||
|
||||
try (JarFile jf = new JarFile(new File(jarfile), true,
|
||||
ZipFile.OPEN_READ, JarFile.runtimeVersion())) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.io.IOException;
|
|||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -184,9 +185,9 @@ public final class OutputAnalyzer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Verify that the stdout and stderr contents of output buffer does not contain the string
|
||||
* Verify that the stdout and stderr contents of output buffer are empty
|
||||
*
|
||||
* @throws RuntimeException If the string was found
|
||||
* @throws RuntimeException If the stdout and stderr are not empty
|
||||
*/
|
||||
public OutputAnalyzer shouldBeEmpty() {
|
||||
if (!stdout.isEmpty()) {
|
||||
|
@ -271,6 +272,7 @@ public final class OutputAnalyzer {
|
|||
* @throws RuntimeException If the pattern was not found
|
||||
*/
|
||||
public OutputAnalyzer stderrShouldMatch(String pattern) {
|
||||
|
||||
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
||||
if (!matcher.find()) {
|
||||
reportDiagnosticSummary();
|
||||
|
@ -485,4 +487,57 @@ public final class OutputAnalyzer {
|
|||
private List<String> asLines(String buffer) {
|
||||
return Arrays.asList(buffer.split("(\\r\\n|\\n|\\r)"));
|
||||
}
|
||||
|
||||
|
||||
private static final String jvmwarningmsg = ".* VM warning:.*";
|
||||
|
||||
/**
|
||||
* Verifies that the stdout and stderr contents of output buffer are empty, after
|
||||
* filtering out the HotSpot warning messages.
|
||||
*
|
||||
* @throws RuntimeException If the stdout and stderr are not empty
|
||||
*/
|
||||
public OutputAnalyzer shouldBeEmptyIgnoreVMWarnings() {
|
||||
if (!stdout.isEmpty()) {
|
||||
reportDiagnosticSummary();
|
||||
throw new RuntimeException("stdout was not empty");
|
||||
}
|
||||
if (!stderr.replaceAll(jvmwarningmsg + "\\R", "").isEmpty()) {
|
||||
reportDiagnosticSummary();
|
||||
throw new RuntimeException("stderr was not empty");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the stderr contents of output buffer matches the pattern,
|
||||
* after filtering out the Hotespot warning messages
|
||||
*
|
||||
* @param pattern
|
||||
* @throws RuntimeException If the pattern was not found
|
||||
*/
|
||||
public OutputAnalyzer stderrShouldMatchIgnoreVMWarnings(String pattern) {
|
||||
String stderr = this.stderr.replaceAll(jvmwarningmsg + "\\R", "");
|
||||
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
||||
if (!matcher.find()) {
|
||||
reportDiagnosticSummary();
|
||||
throw new RuntimeException("'" + pattern
|
||||
+ "' missing from stderr \n");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of the output buffer (stdout and stderr), without those
|
||||
* JVM warning msgs, as list of strings. Output is split by newlines.
|
||||
*
|
||||
* @return Contents of the output buffer as list of strings
|
||||
*/
|
||||
public List<String> asLinesWithoutVMWarnings() {
|
||||
return Arrays.asList(getOutput().split("\\R"))
|
||||
.stream()
|
||||
.filter(Pattern.compile(jvmwarningmsg).asPredicate().negate())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue