Merge
This commit is contained in:
commit
6e70c4d112
@ -557,7 +557,7 @@ final class StringLatin1 {
|
||||
|
||||
// inflatedCopy byte[] -> char[]
|
||||
@HotSpotIntrinsicCandidate
|
||||
private static void inflate(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
|
||||
public static void inflate(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
dst[dstOff++] = (char)(src[srcOff++] & 0xff);
|
||||
}
|
||||
@ -567,7 +567,7 @@ final class StringLatin1 {
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static void inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) {
|
||||
// We need a range check here because 'putChar' has no checks
|
||||
checkBoundsOffCount(dstOff, len, dst.length);
|
||||
checkBoundsOffCount(dstOff << 1, len << 1, dst.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
StringUTF16.putChar(dst, dstOff++, src[srcOff++] & 0xff);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ final class StringUTF16 {
|
||||
|
||||
// compressedCopy char[] -> byte[]
|
||||
@HotSpotIntrinsicCandidate
|
||||
private static int compress(char[] src, int srcOff, byte[] dst, int dstOff, int len) {
|
||||
public static int compress(char[] src, int srcOff, byte[] dst, int dstOff, int len) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = src[srcOff];
|
||||
if (c > 0xFF) {
|
||||
@ -162,7 +162,7 @@ final class StringUTF16 {
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static int compress(byte[] src, int srcOff, byte[] dst, int dstOff, int len) {
|
||||
// We need a range check here because 'getChar' has no checks
|
||||
checkBoundsOffCount(srcOff, len, src.length);
|
||||
checkBoundsOffCount(srcOff << 1, len << 1, src.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = getChar(src, srcOff);
|
||||
if (c > 0xFF) {
|
||||
@ -211,7 +211,9 @@ final class StringUTF16 {
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static void getChars(byte[] value, int srcBegin, int srcEnd, char dst[], int dstBegin) {
|
||||
// We need a range check here because 'getChar' has no checks
|
||||
checkBoundsOffCount(srcBegin, srcEnd - srcBegin, value.length);
|
||||
if (srcBegin < srcEnd) {
|
||||
checkBoundsOffCount(srcBegin << 1, (srcEnd - srcBegin) << 1, value.length);
|
||||
}
|
||||
for (int i = srcBegin; i < srcEnd; i++) {
|
||||
dst[dstBegin++] = getChar(value, i);
|
||||
}
|
||||
|
@ -237,24 +237,29 @@ public class ClassLoaders {
|
||||
int off = 0;
|
||||
int next;
|
||||
while ((next = cp.indexOf(File.pathSeparator, off)) != -1) {
|
||||
addURLToUCP(cp.substring(off, next), ucp);
|
||||
URL url = toFileURL(cp.substring(off, next));
|
||||
if (url != null)
|
||||
ucp.addURL(url);
|
||||
off = next + 1;
|
||||
}
|
||||
|
||||
// remaining
|
||||
addURLToUCP(cp.substring(off), ucp);
|
||||
URL url = toFileURL(cp.substring(off));
|
||||
if (url != null)
|
||||
ucp.addURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to convert to the given string to a file URL and adds it
|
||||
* to the given URLClassPath.
|
||||
* Attempts to convert the given string to a file URL.
|
||||
*
|
||||
* @apiNote This is called by the VM
|
||||
*/
|
||||
private static void addURLToUCP(String s, URLClassPath ucp) {
|
||||
private static URL toFileURL(String s) {
|
||||
try {
|
||||
URL url = Paths.get(s).toRealPath().toUri().toURL();
|
||||
ucp.addURL(url);
|
||||
return Paths.get(s).toRealPath().toUri().toURL();
|
||||
} catch (InvalidPathException | IOException ignore) {
|
||||
// malformed path string or class path element does not exist
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,8 @@ module java.base {
|
||||
jdk.scripting.nashorn,
|
||||
jdk.unsupported;
|
||||
exports jdk.internal.vm.annotation to
|
||||
jdk.unsupported;
|
||||
jdk.unsupported,
|
||||
jdk.vm.ci;
|
||||
exports jdk.internal.util.jar to
|
||||
jdk.jartool;
|
||||
exports jdk.internal.vm to
|
||||
|
@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
*/
|
||||
package java.net.http;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
// The purpose of this class is to separate charset-related tasks from the main
|
||||
// WebSocket logic, simplifying where possible.
|
||||
//
|
||||
// * Coders hide the differences between coding and flushing stages on the
|
||||
// API level
|
||||
// * Verifier abstracts the way the verification is performed
|
||||
// (spoiler: it's a decoding into a throw-away buffer)
|
||||
//
|
||||
// Coding methods throw exceptions instead of returning coding result denoting
|
||||
// errors, since any kind of handling and recovery is not expected.
|
||||
final class CharsetToolkit {
|
||||
|
||||
private CharsetToolkit() { }
|
||||
|
||||
static final class Verifier {
|
||||
|
||||
private final CharsetDecoder decoder = UTF_8.newDecoder();
|
||||
// A buffer used to check validity of UTF-8 byte stream by decoding it.
|
||||
// The contents of this buffer are never used.
|
||||
// The size is arbitrary, though it should probably be chosen from the
|
||||
// performance perspective since it affects the total number of calls to
|
||||
// decoder.decode() and amount of work in each of these calls
|
||||
private final CharBuffer blackHole = CharBuffer.allocate(1024);
|
||||
|
||||
void verify(ByteBuffer in, boolean endOfInput)
|
||||
throws CharacterCodingException {
|
||||
while (true) {
|
||||
// Since decoder.flush() cannot produce an error, it's not
|
||||
// helpful for verification. Therefore this step is skipped.
|
||||
CoderResult r = decoder.decode(in, blackHole, endOfInput);
|
||||
if (r.isOverflow()) {
|
||||
blackHole.clear();
|
||||
} else if (r.isUnderflow()) {
|
||||
break;
|
||||
} else if (r.isError()) {
|
||||
r.throwException();
|
||||
} else {
|
||||
// Should not happen
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Verifier reset() {
|
||||
decoder.reset();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
static final class Encoder {
|
||||
|
||||
private final CharsetEncoder encoder = UTF_8.newEncoder();
|
||||
private boolean coding = true;
|
||||
|
||||
CoderResult encode(CharBuffer in, ByteBuffer out, boolean endOfInput)
|
||||
throws CharacterCodingException {
|
||||
|
||||
if (coding) {
|
||||
CoderResult r = encoder.encode(in, out, endOfInput);
|
||||
if (r.isOverflow()) {
|
||||
return r;
|
||||
} else if (r.isUnderflow()) {
|
||||
if (endOfInput) {
|
||||
coding = false;
|
||||
} else {
|
||||
return r;
|
||||
}
|
||||
} else if (r.isError()) {
|
||||
r.throwException();
|
||||
} else {
|
||||
// Should not happen
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
assert !coding;
|
||||
return encoder.flush(out);
|
||||
}
|
||||
|
||||
Encoder reset() {
|
||||
coding = true;
|
||||
encoder.reset();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
static CharBuffer decode(ByteBuffer in) throws CharacterCodingException {
|
||||
return UTF_8.newDecoder().decode(in);
|
||||
}
|
||||
|
||||
static final class Decoder {
|
||||
|
||||
private final CharsetDecoder decoder = UTF_8.newDecoder();
|
||||
private boolean coding = true; // Either coding or flushing
|
||||
|
||||
CoderResult decode(ByteBuffer in, CharBuffer out, boolean endOfInput)
|
||||
throws CharacterCodingException {
|
||||
|
||||
if (coding) {
|
||||
CoderResult r = decoder.decode(in, out, endOfInput);
|
||||
if (r.isOverflow()) {
|
||||
return r;
|
||||
} else if (r.isUnderflow()) {
|
||||
if (endOfInput) {
|
||||
coding = false;
|
||||
} else {
|
||||
return r;
|
||||
}
|
||||
} else if (r.isError()) {
|
||||
r.throwException();
|
||||
} else {
|
||||
// Should not happen
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
assert !coding;
|
||||
return decoder.flush(out);
|
||||
}
|
||||
|
||||
Decoder reset() {
|
||||
coding = true;
|
||||
decoder.reset();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -131,11 +131,13 @@ killcmd=kill
|
||||
|
||||
# This can be increased if timing seems to be an issue.
|
||||
sleep_seconds=1
|
||||
if [ -n "$TIMEOUT_FACTOR" ] ; then
|
||||
sleep_seconds=$(echo $TIMEOUT_FACTOR $sleep_seconds | awk '{printf "%d\n", int($1 * $2)}')
|
||||
timeout_factor=1
|
||||
if [ -n "$TESTTIMEOUTFACTOR" ] ; then
|
||||
# convert float value to int
|
||||
timeout_factor=$(echo $TESTTIMEOUTFACTOR | awk '{printf "%d\n", int($1)}')
|
||||
fi
|
||||
|
||||
echo "ShellScaffold.sh: Version" >& 2
|
||||
echo "ShellScaffold.sh: Running with timeout_factor = $timeout_factor" >& 2
|
||||
topPid=$$
|
||||
|
||||
# Be careful to echo to >& in these general functions.
|
||||
@ -664,6 +666,7 @@ cmd()
|
||||
count=0
|
||||
desiredFileSize=`expr $fileSize + 4`
|
||||
msg1=`echo At start: cmd/size/waiting : $command / $fileSize / \`date\``
|
||||
timeLimit=`expr 60 * $timeout_factor`
|
||||
while [ 1 = 1 ] ; do
|
||||
newFileSize=`wc -c $jdbOutFile | awk '{ print $1 } '`
|
||||
#echo jj: desired = $desiredFileSize, new = $newFileSize >& 2
|
||||
@ -673,20 +676,17 @@ cmd()
|
||||
break
|
||||
fi
|
||||
sleep ${sleep_seconds}
|
||||
count=`expr $count + 1`
|
||||
if [ $count = 30 -o $count = 60 ] ; then
|
||||
count=`expr $count + ${sleep_seconds}`
|
||||
if [ $count -gt $timeLimit ] ; then
|
||||
# record some debug info.
|
||||
echo "--DEBUG: jdb $$ didn't responded to command in $count secs: $command" >& 2
|
||||
echo "--DEBUG: jdb $$ didn't respond to command in $count secs: $command" >& 2
|
||||
echo "--DEBUG:" $msg1 >& 2
|
||||
echo "--DEBUG: "done size/waiting : / $newFileSize / `date` >& 2
|
||||
echo "-- $jdbOutFile follows-------------------------------" >& 2
|
||||
cat $jdbOutFile >& 2
|
||||
echo "------------------------------------------" >& 2
|
||||
dojstack
|
||||
#$psCmd | sed -e '/com.sun.javatest/d' -e '/nsk/d' >& 2
|
||||
if [ $count = 60 ] ; then
|
||||
dofail "jdb never responded to command: $command"
|
||||
fi
|
||||
dofail "jdb never responded to command: $command"
|
||||
fi
|
||||
done
|
||||
# Note that this assumes just these chars in thread names.
|
||||
@ -734,7 +734,8 @@ waitForJdbMsg()
|
||||
nlines=$2
|
||||
allowExit="$3"
|
||||
myCount=0
|
||||
timeLimit=40 # wait a max of this many secs for a response from a jdb command
|
||||
timeLimit=`expr 40 * $timeout_factor` # wait a max of this many secs for a response from a jdb command
|
||||
|
||||
while [ 1 = 1 ] ; do
|
||||
if [ -r $jdbOutFile ] ; then
|
||||
# Something here causes jdb to complain about Unrecognized cmd on x86.
|
||||
@ -772,7 +773,7 @@ waitForJdbMsg()
|
||||
|
||||
myCount=`expr $myCount + ${sleep_seconds}`
|
||||
if [ $myCount -gt $timeLimit ] ; then
|
||||
echo "--Fail: waitForJdbMsg timed out after $timeLimit seconds, looking for /$1/, in $nlines lines; exitting" >> $failFile
|
||||
echo "--Fail: waitForJdbMsg timed out after $timeLimit seconds, looking for /$1/, in $nlines lines; exiting" >> $failFile
|
||||
echo "vv jdbOutFile vvvvvvvvvvvvvvvvvvvvvvvvvvvv" >& 2
|
||||
cat $jdbOutFile >& 2
|
||||
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >& 2
|
||||
|
@ -49,14 +49,26 @@ import jdk.testlibrary.Platform;
|
||||
|
||||
public class BasicLauncherTest {
|
||||
|
||||
private final static String toolName = "jhsdb";
|
||||
private static LingeredApp theApp = null;
|
||||
private static boolean useJavaLauncher = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return exit code of tool
|
||||
*/
|
||||
public static int launchCLHSDB()
|
||||
private static JDKToolLauncher createSALauncher() {
|
||||
JDKToolLauncher launcher = null;
|
||||
if (useJavaLauncher) {
|
||||
// Use java launcher if we need to pass additional parameters to VM
|
||||
// for debugging purpose
|
||||
// e.g. -Xlog:class+load=info:file=/tmp/BasicLauncherTest.log
|
||||
launcher = JDKToolLauncher.createUsingTestJDK("java");
|
||||
launcher.addToolArg("sun.jvm.hotspot.SALauncher");
|
||||
}
|
||||
else {
|
||||
launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
|
||||
}
|
||||
|
||||
return launcher;
|
||||
}
|
||||
|
||||
public static void launchCLHSDB()
|
||||
throws IOException {
|
||||
|
||||
System.out.println("Starting LingeredApp");
|
||||
@ -64,7 +76,7 @@ public class BasicLauncherTest {
|
||||
theApp = LingeredApp.startApp();
|
||||
|
||||
System.out.println("Starting clhsdb against " + theApp.getPid());
|
||||
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName);
|
||||
JDKToolLauncher launcher = createSALauncher();
|
||||
launcher.addToolArg("clhsdb");
|
||||
launcher.addToolArg("--pid=" + Long.toString(theApp.getPid()));
|
||||
|
||||
@ -84,7 +96,9 @@ public class BasicLauncherTest {
|
||||
|
||||
toolProcess.waitFor();
|
||||
|
||||
return toolProcess.exitValue();
|
||||
if (toolProcess.exitValue() != 0) {
|
||||
throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Test ERROR " + ex, ex);
|
||||
} finally {
|
||||
@ -104,8 +118,8 @@ public class BasicLauncherTest {
|
||||
try {
|
||||
theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m"));
|
||||
|
||||
System.out.println("Starting " + toolName + " " + toolArgs.get(0) + " against " + theApp.getPid());
|
||||
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName);
|
||||
System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid());
|
||||
JDKToolLauncher launcher = createSALauncher();
|
||||
|
||||
for (String cmd : toolArgs) {
|
||||
launcher.addToolArg(cmd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user