This commit is contained in:
Lana Steuck 2017-05-31 18:33:35 +00:00
commit 594a034cbb
29 changed files with 348 additions and 283 deletions

View File

@ -423,3 +423,4 @@ ef9954f6896bb0b95ac62bf769f68b59a7a56ccd jdk-9+170
cbd65760a005766610583949b3b5c9ace92e74b3 jdk-10+7
f0adc10ed8316e6cf316e3208c5ecf6835d22bc4 jdk-10+8
b9409a7daa6c793dd631e52fe6ef79d08a3b337a jdk-10+9
29bbedd4cce8e14742bdb22118c057b877c02f0f jdk-9+171

View File

@ -116,11 +116,11 @@ caption {
margin-bottom:10px;
}
tr:nth-child(even) {
tr:nth-child(even), tr:nth-child(even) th[scope=row] {
background: #DDD;
}
tr:nth-child(odd) {
tr:nth-child(odd), tr:nth-child(odd) th[scope=row] {
background: #FFF;
}

View File

@ -31,18 +31,23 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static java.util.stream.Collectors.*;
/**
* Build tool to generate the docs bundle index page.
@ -104,59 +109,33 @@ public class GenDocsBundlePage {
}
private static final String HEADER_TITLE = "@HEADER_TITLE@";
final Path outputfile;
final String title;
final Map<String, String> moduleGroups;
final Map<String, Set<ModuleDescriptor>> moduleGroups = new HashMap<>();
GenDocsBundlePage(String title, Path outputfile) throws IOException
{
this.outputfile = outputfile;
this.title = title;
this.moduleGroups = moduleGroups();
}
static Map<String, String> moduleGroups() throws IOException {
// read module groups
ModuleFinder finder = ModuleFinder.ofSystem();
Map<String, String> groups = new HashMap<>();
try (InputStream in = GenDocsBundlePage.class.getResourceAsStream(MODULE_GROUPS_PROPS)) {
Properties props = new Properties();
props.load(in);
for (String key: props.stringPropertyNames()) {
Set<String> mods = Stream.of(props.getProperty(key).split("\\s+"))
.filter(mn -> finder.find(mn).isPresent())
.map(String::trim)
.collect(Collectors.toSet());
Set<ModuleDescriptor> mods =
Stream.of(props.getProperty(key).split("\\s+"))
.map(String::trim)
.flatMap(mn -> finder.find(mn).stream())
.map(ModuleReference::descriptor)
.collect(toSet());
// divide into 3 columns: Java SE, JDK, JavaFX
StringBuilder sb = new StringBuilder();
sb.append(mods.stream()
.filter(mn -> mn.startsWith("java."))
.sorted()
.map(GenDocsBundlePage::toHRef)
.collect(Collectors.joining("\n")));
sb.append("</td>\n<td>")
.append(mods.stream()
.filter(mn -> mn.startsWith("jdk."))
.sorted()
.map(GenDocsBundlePage::toHRef)
.collect(Collectors.joining("\n")));
sb.append("</td>\n<td>");
if (mods.stream().anyMatch(mn -> mn.startsWith("javafx."))) {
sb.append(mods.stream()
.filter(mn -> mn.startsWith("javafx."))
.sorted()
.map(GenDocsBundlePage::toHRef)
.collect(Collectors.joining("\n")));
}
String name = "@" + key.toUpperCase(Locale.ENGLISH) + "@";
groups.put(name, sb.toString());
}
moduleGroups.put(name, mods);
};
}
return groups;
}
static String toHRef(String mn) {
return String.format("<a href=\"api/%s-summary.html\">%s</a><br>", mn, mn);
}
void run(BufferedReader reader) throws IOException {
@ -174,13 +153,95 @@ public class GenDocsBundlePage {
if (line.contains(HEADER_TITLE)) {
line = line.replace(HEADER_TITLE, title);
}
if (line.contains("@")) {
for (Map.Entry<String,String> e: moduleGroups.entrySet()) {
if (line.contains(e.getKey())) {
line = line.replace(e.getKey(), e.getValue());
}
int i = line.indexOf('@');
int j = line.indexOf('@', i+1);
if (i >= 0 && i < j) {
String name = line.substring(i, j+1);
if (moduleGroups.containsKey(name)) {
line = line.replace(name, formatModuleGroup(name));
}
}
return line;
}
String toHRef(ModuleDescriptor md) {
String mn = md.name();
String formattedName;
if (hasExportedAPIs(md)) {
// has exported APIs
formattedName = mn;
} else if (!md.provides().isEmpty()) {
// a provider
formattedName = "<i>" + mn + "</i>";
} else {
// a tool
formattedName = "<i>" + mn + "</i>";
}
return String.format("<a href=\"api/%s-summary.html\">%s</a>",
mn, formattedName);
}
String formatModuleGroup(String groupName) {
StringBuilder sb = new StringBuilder();
// organize in Java SE, JDK, JavaFX, JCP groups
Set<ModuleDescriptor> modules = moduleGroups.get(groupName);
Arrays.stream(ModuleGroup.values())
.forEach(g -> {
Set<ModuleDescriptor> mods = modules.stream()
.filter(md -> g.predicate.test(md.name()))
.collect(toSet());
if (!mods.isEmpty()) {
sb.append("<div class=" + g.cssClass + ">\n");
// modules with exported API
mods.stream()
.filter(this::hasExportedAPIs)
.sorted(Comparator.comparing(ModuleDescriptor::name))
.map(this::toHRef)
.forEach(m -> sb.append(m).append("\n"));
// tools and providers
mods.stream()
.filter(md -> !hasExportedAPIs(md))
.sorted(Comparator.comparing(ModuleDescriptor::name))
.map(this::toHRef)
.forEach(m -> sb.append(m).append("\n"));
sb.append("</div>");
}
});
return sb.toString();
}
private boolean hasExportedAPIs(ModuleDescriptor md) {
if (md.exports().stream().anyMatch(e -> !e.isQualified())) {
return true;
}
// this should check if any indirect exports
// checking requires transitive would be sufficient for JDK modules
if (md.requires().stream()
.map(ModuleDescriptor.Requires::modifiers)
.anyMatch(mods -> mods.contains(ModuleDescriptor.Requires.Modifier.TRANSITIVE))) {
return true;
}
return false;
}
private static final Set<String> NON_JAVA_SE_MODULES =
Set.of("java.jnlp", "java.smartcardio");
/**
* CSS class names are defined in docs-bundle-page.html
*/
enum ModuleGroup {
JAVA_SE("javase", mn -> mn.startsWith("java.") && !NON_JAVA_SE_MODULES.contains(mn)),
JDK("jdk", mn -> mn.startsWith("jdk.")),
JAVAFX("javafx", mn -> mn.startsWith("javafx.")),
NON_JAVA_SE("jcp", NON_JAVA_SE_MODULES::contains);
final String cssClass;
final Predicate<String> predicate;
ModuleGroup(String cssClass, Predicate<String> predicate) {
this.cssClass = cssClass;
this.predicate = predicate;
}
}
}

View File

@ -26,121 +26,146 @@ questions.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html;" charset="utf-8">
<style type="text/css">
table {
border-collapse: collapse;
}
table {
border: 1px solid black;
}
th ,td {
border: 0px solid black;
}
thead th {
background-color: #DDD;
}
tbody > tr:nth-child(even) {
background-color: #EEE
}
tbody > tr:nth-child(odd) {
background-color: #FFF
}
th, td {
font-family: sans-serif; /* could eventually be DejaVu */
font-size: small;
padding: 5px 10px;
vertical-align:top;
}
td a {
text-decoration: none;
}
tr th {
text-align:left;
}
caption {
font-size: smaller;
font-weight: bold;
}
</style>
<title>@HEADER_TITLE@</title>
<meta http-equiv="content-type" content="text/html;" charset="utf-8">
<link rel="stylesheet" href="resources/jdk-default.css" type="text/css" />
<style type="text/css">
table a { text-decoration: none }
table { border: none }
th, td { border: 2px solid white; }
thead th { background-color: #DDD }
tbody th { background-color: #EEE }
table div.javase, ul.key span.javase { background-color: #C6E7F3 }
table div.jdk, ul.key span.jdk { background-color: #ECE1C5 }
table div.javafx, ul.key span.javafx { background-color: #ECEDCC }
table div.jcp, ul.key span.jcp { background-color: #E9E9E9 }
td div { padding: 3px 5px; color: blue }
table tbody td div a { padding: 0 .5em; margin: 0: 1em; }
table tbody td div a:link { color: black }
table tbody td div a:visited { color: black }
table tbody td div a[href]:hover { color: black; text-decoration: underline }
td { padding: 0 }
table tbody td div a { padding: 0 .5em; margin: 0: 1em }
.key { font-size: smaller; }
ul.key li { display:inline-block; padding: 0 1em }
ul.key span {
border: 1px solid black;
font-family: DejaVu Sans Mono, monospace;
}
ul.key span:before { content: " " }
ul.key span:after { content: " " }
caption {
text-align: center;
}
tr:nth-child(even), tr:nth-child(even) th[scope=row] {
background-color: #EEE;
}
tr:nth-child(odd), tr:nth-child(odd) th[scope=row] {
background-color: #EEE;
}
</style>
</head>
<body>
<h1>@HEADER_TITLE@</h1>
<ul>
<li><a href="api/index.html">JDK API Specification</a></li>
<li>Java Language Specification</li>
<li>Java Virtual Machine Specification</li>
<li><a href="https://docs.oracle.com/javase/specs/">
Java Language and Virtual Machine Specifications</a></li>
<li><a href="https://www.oracle.com/pls/topic/lookup?ctx=javase9&id=tools_reference_overview">
Tools Reference</a></li>
</ul>
<table>
<caption>Modules</caption>
<caption style="display:none">JDK Modules</caption>
<thead>
<tr>
<th scope="col">Group</th>
<th scope="col">Java SE</th>
<th scope="col">JDK</th>
<th scope="col">JavaFX</th>
<th scope="col">Modules</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Foundation</th>
<td>@CORE_MODULES@</td>
<td>@JAVA_BASE@</td>
</tr>
<tr>
<th scope="row">Security</th>
<td>@SECURITY_MODULES@</td>
</tr>
<tr>
<th scope="row">Instrumentation and<br>Management</th>
<td>@INSTRUMENT_MGMT_MODULES@</td>
</tr>
<tr>
<th scope="row">Integration</th>
<th scope="row">Integration</th>
<td>@INTEGRATION_MODULES@</td>
</tr>
<tr>
<th scope="row">User Interface</th>
<td>@UI_TOOLKITS_MODULES@</td>
<td>@UI_MODULES@</td>
</tr>
<tr>
<th scope="row">Compiler and Scripting</th>
<td>@COMPILER_SCRIPTING_MODULES@</td>
<th scope="row">Compilation</th>
<td>@COMPILER_MODULES@</td>
</tr>
<tr>
<th scope="row">Debugging</th>
<td>@DEBUG_MODULES@</td>
<th scope="row">Scripting</th>
<td>@SCRIPTING_MODULES@</td>
</tr>
<tr>
<th scope="row">Tools and Tool APIs</th>
<td>@TOOL_MODULES@</td>
<th scope="row">Security</th>
<td>@SECURITY_MODULES@</td>
</tr>
<tr>
<th scope="row">Incubating Features</th>
<th scope="row">Management</th>
<td>@MANAGEMENT_MODULES@</td>
</tr>
<tr>
<th scope="row">Instrumentation</th>
<td>@INSTRUMENT_MODULES@</td>
</tr>
<tr>
<th scope="row">Serviceability</th>
<td>@SVC_MODULES@</td>
</tr>
<tr>
<th scope="row">Packaging</th>
<td>@PACKAGING_MODULES@</td>
</tr>
<tr>
<th scope="row">Incubator</th>
<td>@INCUBATOR_MODULES@</td>
</tr>
<tr>
<th scope="row">Non-Java SE</th>
<td>@OTHER_MODULES@</td>
</tr>
<tr>
<th scope="row">Java EE</th>
<td>@JAVA_EE_MODULES@</td>
</tr>
<tr>
<th scope="row"></th>
<th scope="row">Outside Java SE</th>
<th scope="row">JDK</th>
<th scope="row">JavaFX</th>
</tr>
<tr>
<th scope="row">Others</th>
<td>@OTHER_MODULES@</td>
<th scope="row">Aggregator</th>
<td>@AGGREGATOR_MODULES@</td>
</tr>
</tbody>
</table>
<p class="key">Key:
<ul class="key">
<li><span class="javase">&nbsp;</span>&nbsp; Java SE
<li><span class="jdk">&nbsp;</span>&nbsp; JDK
<li><span class="javafx">&nbsp;</span>&nbsp; JavaFX
<li><span class="jcp">&nbsp;</span>&nbsp; Non-Java SE
<li><i>italic</i> No Exported API (e.g. a tool or provider)</li>
</ul>
<p>
<hr/>
<a href="legal/cpyr.html">Copyright</a>&copy; 1993, 2017, Oracle and/or its affiliates. All rights reserved.</p>
<hr>
<a href="legal/cpyr.html">Copyright</a> &copy 1993, 2017, Oracle and/or its affiliates. All rights reserved.</p>
</body>
</html>

View File

@ -1,13 +1,8 @@
# Module Grouping for the docs bundle page
#
core_modules=\
java.base \
jdk.charsets \
jdk.localedata \
jdk.net \
jdk.sctp \
jdk.zipfs
java_base=\
java.base
java_ee_modules=\
java.activation \
@ -17,6 +12,10 @@ java.xml.bind \
java.xml.ws \
java.xml.ws.annotation
aggregator_modules=\
java.se \
java.se.ee
security_modules=\
java.security.jgss \
java.security.sasl \
@ -26,18 +25,22 @@ jdk.security.jgss \
jdk.crypto.cryptoki \
jdk.crypto.ec \
jdk.crypto.mscapi \
jdk.crypto.ucrypto
jdk.crypto.ucrypto \
jdk.policytool
instrument_mgmt_modules=\
java.instrument \
instrument_modules=\
java.instrument
management_modules=\
java.management \
java.management.rmi \
jdk.jfr \
jdk.management \
jdk.management.agent \
jdk.management.cmm \
jdk.management.jfr \
jdk.management.resource \
jdk.snmp \
jdk.jconsole
integration_modules=\
java.logging \
@ -47,11 +50,18 @@ java.rmi \
java.sql \
java.sql.rowset \
java.xml \
jdk.charsets \
jdk.localedata \
jdk.net \
jdk.sctp \
jdk.jsobject \
jdk.httpserver \
jdk.naming.dns \
jdk.naming.rmi
jdk.naming.rmi \
jdk.xml.dom \
jdk.zipfs
ui_toolkits_modules=\
ui_modules=\
java.datatransfer \
java.desktop \
javafx.base \
@ -63,39 +73,40 @@ javafx.swing \
javafx.web \
jdk.accessibility
other_modules=\
java.jnlp \
java.smartcardio \
jdk.jsobject \
jdk.xml.dom
debug_modules=\
jdk.jdi \
jdk.jdwp.agent
tool_modules=\
svc_modules=\
jdk.jfr \
jdk.attach \
jdk.editpad \
jdk.jartool \
jdk.javadoc \
jdk.jcmd \
jdk.jconsole \
jdk.jdeps \
jdk.jlink \
jdk.jshell \
jdk.jdi \
jdk.jdwp.agent \
jdk.jstatd \
jdk.hotspot.agent
packaging_modules=\
jdk.jartool \
jdk.jlink \
jdk.pack \
jdk.policytool \
jdk.packager.services \
jdk.packager.services
compiler_modules=\
java.compiler \
jdk.compiler \
jdk.javadoc \
jdk.jdeps \
jdk.editpad \
jdk.jshell \
jdk.rmic
compiler_scripting_modules=\
java.compiler \
scripting_modules=\
java.scripting \
jdk.compiler \
jdk.dynalink \
jdk.scripting.nashorn \
jdk.scripting.nashorn.shell
other_modules=\
java.jnlp \
java.smartcardio
incubator_modules=\
jdk.incubator.httpclient

View File

@ -56,7 +56,7 @@ public class ExtLink implements Taglet {
static final String TAG_NAME = "extLink";
static final String URL = "https://www.oracle.com/pls/topic/lookup?ctx=javase9&id=";
static final String URL = "https://www.oracle.com/pls/topic/lookup?ctx=javase9&amp;id=";
static final Pattern TAG_PATTERN = Pattern.compile("(\\s*)(?<name>\\w+)(\\s+)(?<desc>.*)");

View File

@ -421,10 +421,8 @@ int NET_ReadV(int s, const struct iovec * vector, int count) {
}
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, int *fromlen) {
socklen_t socklen = *fromlen;
BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, &socklen) );
*fromlen = socklen;
struct sockaddr *from, socklen_t *fromlen) {
BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
}
int NET_Send(int s, void *msg, int len, unsigned int flags) {
@ -440,10 +438,8 @@ int NET_SendTo(int s, const void *msg, int len, unsigned int
BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
}
int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
socklen_t socklen = *addrlen;
BLOCKING_IO_RETURN_INT( s, accept(s, addr, &socklen) );
*addrlen = socklen;
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) );
}
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {

View File

@ -923,6 +923,12 @@ public class File
* java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
* Files.readAttributes} method may be used.
*
* @apiNote
* While the unit of time of the return value is milliseconds,
* the granularity of the value depends on the underlying
* file system and may be larger. For example, some
* file systems use time stamps in units of seconds.
*
* @return A <code>long</code> value representing the time the file was
* last modified, measured in milliseconds since the epoch
* (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the

View File

@ -137,6 +137,7 @@ import sun.security.jca.*;
* <li>{@code AES/CBC/PKCS5Padding} (128)</li>
* <li>{@code AES/ECB/NoPadding} (128)</li>
* <li>{@code AES/ECB/PKCS5Padding} (128)</li>
* <li>{@code AES/GCM/NoPadding} (128)</li>
* <li>{@code DES/CBC/NoPadding} (56)</li>
* <li>{@code DES/CBC/PKCS5Padding} (56)</li>
* <li>{@code DES/ECB/NoPadding} (56)</li>

View File

@ -456,6 +456,11 @@ jboolean JLI_AddArgsFromEnvVar(JLI_List args, const char *var_name) {
env++;
}
// Trailing space
if (*env == '\0') {
break;
}
arg = p;
while (*env != '\0' && !isspace(*env)) {
if (*env == '"' || *env == '\'') {

View File

@ -36,7 +36,7 @@
#define JNI_ERROR "Error: A JNI error has occurred, please check your installation and try again"
#define JNI_ERROR1 "Error: can't find JNI interfaces in: %s"
#define ARG_INFO_ENVVAR "NOTE: Picked up the following options via %s:\n %s"
#define ARG_INFO_ENVVAR "NOTE: Picked up %s: %s"
#define ARG_WARN "Warning: %s option is no longer supported."
#define ARG_ERROR1 "Error: %s requires class path specification"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -189,11 +189,6 @@ class AsyncSSLConnection extends HttpConnection
throw new UnsupportedOperationException("Not supported.");
}
@Override
protected int readImpl(ByteBuffer buffer) throws IOException {
throw new UnsupportedOperationException("Not supported.");
}
@Override
CompletableFuture<Void> whenReceivingResponse() {
throw new UnsupportedOperationException("Not supported.");

View File

@ -33,7 +33,6 @@ import java.net.SocketPermission;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLPermission;
import java.nio.ByteBuffer;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
@ -76,9 +75,6 @@ final class Exchange<T> {
boolean upgrading; // to HTTP/2
final PushGroup<?,T> pushGroup;
// buffer for receiving response headers
private volatile ByteBuffer rxBuffer;
Exchange(HttpRequestImpl request, MultiExchange<?,T> multi) {
this.request = request;
this.upgrading = false;
@ -121,17 +117,6 @@ final class Exchange<T> {
return client;
}
ByteBuffer getBuffer() {
if(rxBuffer == null) {
synchronized (this) {
if(rxBuffer == null) {
rxBuffer = Utils.getExchangeBuffer();
}
}
}
return rxBuffer;
}
public Response response() throws IOException, InterruptedException {
return responseImpl(null);
}

View File

@ -55,7 +55,7 @@ class Http1Exchange<T> extends ExchangeImpl<T> {
final HttpConnection connection;
final HttpClientImpl client;
final Executor executor;
final ByteBuffer buffer; // used for receiving
volatile ByteBuffer buffer; // used for receiving
@Override
public String toString() {
@ -74,7 +74,7 @@ class Http1Exchange<T> extends ExchangeImpl<T> {
this.client = exchange.client();
this.executor = exchange.executor();
this.operations = new LinkedList<>();
this.buffer = exchange.getBuffer();
this.buffer = Utils.EMPTY_BYTEBUFFER;
if (connection != null) {
this.connection = connection;
} else {
@ -157,7 +157,9 @@ class Http1Exchange<T> extends ExchangeImpl<T> {
try {
response = new Http1Response<>(connection, this);
response.readHeaders();
return response.response();
Response r = response.response();
buffer = response.getBuffer();
return r;
} catch (Throwable t) {
connection.close();
throw t;
@ -213,7 +215,9 @@ class Http1Exchange<T> extends ExchangeImpl<T> {
return MinimalFuture.supply( () -> {
response = new Http1Response<>(connection, Http1Exchange.this);
response.readHeaders();
return response.response();
Response r = response.response();
buffer = response.getBuffer();
return r;
}, executor);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -44,7 +44,7 @@ class Http1Response<T> {
private final HttpConnection connection;
private ResponseHeaders headers;
private int responseCode;
private final ByteBuffer buffer; // same buffer used for reading status line and headers
private ByteBuffer buffer;
private final Http1Exchange<T> exchange;
private final boolean redirecting; // redirecting
private boolean return2Cache; // return connection to cache when finished
@ -96,6 +96,10 @@ class Http1Response<T> {
return finished;
}
ByteBuffer getBuffer() {
return buffer;
}
int fixupContentLen(int clen) {
if (request.method().equalsIgnoreCase("HEAD")) {
return 0;
@ -194,12 +198,15 @@ class Http1Response<T> {
static final char CR = '\r';
static final char LF = '\n';
private int getBuffer() throws IOException {
private int obtainBuffer() throws IOException {
int n = buffer.remaining();
if (n == 0) {
buffer.clear();
return connection.read(buffer);
buffer = connection.read();
if (buffer == null) {
return -1;
}
n = buffer.remaining();
}
return n;
}
@ -207,18 +214,17 @@ class Http1Response<T> {
String readStatusLine() throws IOException {
boolean cr = false;
StringBuilder statusLine = new StringBuilder(128);
ByteBuffer b = buffer;
while (getBuffer() != -1) {
byte[] buf = b.array();
int offset = b.position();
int len = b.limit() - offset;
while ((obtainBuffer()) != -1) {
byte[] buf = buffer.array();
int offset = buffer.position();
int len = buffer.limit() - offset;
for (int i = 0; i < len; i++) {
char c = (char) buf[i+offset];
if (cr) {
if (c == LF) {
b.position(i + 1 + offset);
buffer.position(i + 1 + offset);
return statusLine.toString();
} else {
throw new IOException("invalid status line");
@ -231,7 +237,7 @@ class Http1Response<T> {
}
}
// unlikely, but possible, that multiple reads required
b.position(b.limit());
buffer.position(buffer.limit());
}
return null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -323,12 +323,9 @@ abstract class HttpConnection implements Closeable {
}
}
final int read(ByteBuffer buffer) throws IOException {
return readImpl(buffer);
}
final ByteBuffer read() throws IOException {
return readImpl();
ByteBuffer b = readImpl();
return b;
}
/*
@ -337,9 +334,6 @@ abstract class HttpConnection implements Closeable {
*/
protected abstract ByteBuffer readImpl() throws IOException;
/** Reads as much as possible into given buffer and returns amount read. */
protected abstract int readImpl(ByteBuffer buffer) throws IOException;
@Override
public String toString() {
return "HttpConnection: " + channel().toString();

View File

@ -311,8 +311,7 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection {
}
}
@Override
protected int readImpl(ByteBuffer buf) throws IOException {
private int readImpl(ByteBuffer buf) throws IOException {
int mark = buf.position();
int n;
// FIXME: this hack works in conjunction with the corresponding change

View File

@ -156,11 +156,6 @@ class PlainTunnelingConnection extends HttpConnection {
return delegate.readImpl();
}
@Override
protected int readImpl(ByteBuffer buffer) throws IOException {
return delegate.readImpl(buffer);
}
@Override
boolean isSecure() {
return false;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -148,11 +148,7 @@ class ResponseContent {
// make sure we have at least 1 byte to look at
private void getHunk() throws IOException {
if (chunkbuf == null || !chunkbuf.hasRemaining()) {
if (chunkbuf == null) {
chunkbuf = Utils.getBuffer();
}
chunkbuf.clear();
connection.read(chunkbuf);
chunkbuf = connection.read();
}
}
@ -256,7 +252,6 @@ class ResponseContent {
private void pushBodyFixed(ByteBuffer b) throws IOException {
int remaining = contentLength;
//lastBufferUsed = b;
while (b.hasRemaining() && remaining > 0) {
ByteBuffer buffer = Utils.getBuffer();
int amount = Math.min(b.remaining(), remaining);
@ -265,22 +260,14 @@ class ResponseContent {
buffer.flip();
dataConsumer.accept(Optional.of(buffer));
}
//client.returnBuffer(b);
while (remaining > 0) {
ByteBuffer buffer = Utils.getBuffer();
int xx = connection.read(buffer);
if (xx == -1)
ByteBuffer buffer = connection.read();
if (buffer == null)
throw new IOException("connection closed");
int bytesread = buffer.remaining();
// assume for now that pipelining not implemented
if (bytesread > remaining) {
System.err.println("xx = " + xx);
System.err.println("bytesread = " + bytesread);
System.err.println("remaining = " + remaining);
for (int i=0; i<remaining; i++) {
System.err.printf("%x ", buffer.get());
}
throw new IOException("too many bytes read");
}
remaining -= bytesread;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -72,7 +72,7 @@ final class ResponseHeaders implements HttpHeaders {
static final class InputStreamWrapper extends InputStream {
final HttpConnection connection;
final ByteBuffer buffer;
ByteBuffer buffer;
int lastRead = -1; // last byte read from the buffer
int consumed = 0; // number of bytes consumed.
InputStreamWrapper(HttpConnection connection, ByteBuffer buffer) {
@ -83,9 +83,8 @@ final class ResponseHeaders implements HttpHeaders {
@Override
public int read() throws IOException {
if (!buffer.hasRemaining()) {
buffer.clear();
int n = connection.read(buffer);
if (n == -1) {
buffer = connection.read();
if (buffer == null) {
return lastRead = -1;
}
}
@ -97,6 +96,16 @@ final class ResponseHeaders implements HttpHeaders {
}
}
private static void display(Map<String, List<String>> map) {
map.forEach((k,v) -> {
System.out.print (k + ": ");
for (String val : v) {
System.out.print(val + ", ");
}
System.out.println("");
});
}
private Map<String, List<String>> parse(InputStreamWrapper input)
throws IOException
{
@ -114,7 +123,6 @@ final class ResponseHeaders implements HttpHeaders {
// finds is CR. This only happens if there are no headers, and
// only one byte will be consumed from the buffer. In this case
// the next byte MUST be LF
//System.err.println("Last character read is: " + (byte)lastRead);
if (input.read() != LF) {
throw new IOException("Unexpected byte sequence when no headers: "
+ ((int)CR) + " " + input.lastRead

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -162,10 +162,11 @@ class SSLConnection extends HttpConnection {
@Override
protected ByteBuffer readImpl() throws IOException {
ByteBuffer dst = ByteBuffer.allocate(8192);
int n = readImpl(dst);
WrapperResult r = sslDelegate.recvData(ByteBuffer.allocate(8192));
// TODO: check for closure
int n = r.result.bytesProduced();
if (n > 0) {
return dst;
return r.buf;
} else if (n == 0) {
return Utils.EMPTY_BYTEBUFFER;
} else {
@ -173,19 +174,6 @@ class SSLConnection extends HttpConnection {
}
}
@Override
protected int readImpl(ByteBuffer buf) throws IOException {
// TODO: need to ensure that buf is big enough for application data
WrapperResult r = sslDelegate.recvData(buf);
// TODO: check for closure
String s = "Receive) ";
//debugPrint(s, r.buf);
if (r.result.bytesProduced() > 0) {
assert buf == r.buf;
}
return r.result.bytesProduced();
}
@Override
boolean connected() {
return delegate.connected();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -104,9 +104,7 @@ class SSLDelegate {
}
SSLEngineResult result;
/* if passed in buffer was not big enough then the a reallocated buffer
* is returned here */
ByteBuffer buf;
ByteBuffer buf; // buffer containing result data
}
int app_buf_size;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, 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
@ -164,19 +164,10 @@ class SSLTunnelConnection extends HttpConnection {
@Override
protected ByteBuffer readImpl() throws IOException {
return sslDelegate.recvData(Utils.EMPTY_BYTEBUFFER).buf; // fix this, make the read normal
}
ByteBuffer buf = Utils.getBuffer();
@Override
protected int readImpl(ByteBuffer buf) throws IOException {
WrapperResult r = sslDelegate.recvData(buf);
// TODO: check for closure
String s = "Receive) ";
//debugPrint(s, r.buf);
if (r.result.bytesProduced() > 0) {
assert buf == r.buf;
}
return r.result.bytesProduced();
return r.buf;
}
@Override

View File

@ -28,7 +28,7 @@
* @run main/othervm Assert
* @summary Test the assertion facility
* @author Mike McCloskey
* @key randomness intermittent
* @key randomness
*/
import package1.*;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
@ -214,10 +214,6 @@ public class ResponseHeadersTest {
protected ByteBuffer readImpl() throws IOException {
throw new AssertionError("Bad test assumption: should not have reached here!");
}
@Override
protected int readImpl(ByteBuffer buffer) throws IOException {
throw new AssertionError("Bad test assumption: should not have reached here!");
}
}
public static HttpHeaders createResponseHeaders(ByteBuffer buffer)

View File

@ -23,7 +23,6 @@
/* @test
* @bug 5004077
* @key intermittent
* @summary Check blocking of select and close
*/

View File

@ -24,7 +24,6 @@
/* @test
* @bug 6524172
* @summary Invoking wakeup on closed Selector can throw NPE if close resets interrupt status
* @key intermittent
*/
import java.io.IOException;

View File

@ -36,6 +36,7 @@ import javax.sound.sampled.Mixer;
* @bug 4946913
* @summary DirectClip doesn't kill the thread correctly, sometimes
* @run main/othervm ClipCloseLoss
* @key intermittent
*/
public class ClipCloseLoss {
static int frameCount = 441000; // lets say 10 seconds

View File

@ -23,7 +23,7 @@
/**
* @test
* @bug 8170832
* @bug 8170832 8180447
* @summary Arguments passed in environment variable
* @build TestHelper
* @run main ArgsEnvVar
@ -224,6 +224,21 @@ public class ArgsEnvVar extends TestHelper {
verifyOptions(List.of("-p", "?", "-jar", "test.jar", "one", "two"), tr);
}
@Test
public void testTrailingSpaces() {
env.put(JDK_JAVA_OPTIONS, "--add-exports java.base/jdk.internal.misc=ALL-UNNAMED ");
TestResult tr = doExec(env, javaCmd, "-jar", "test.jar");
verifyOptions(List.of("--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED", "-jar", "test.jar"), tr);
env.put(JDK_JAVA_OPTIONS, "--class-path ' '");
tr = doExec(env, javaCmd, "-jar", "test.jar");
verifyOptions(List.of("--class-path", " ", "-jar", "test.jar"), tr);
env.put(JDK_JAVA_OPTIONS, " --add-exports java.base/jdk.internal.misc=ALL-UNNAMED ");
tr = doExec(env, javaCmd, "-jar", "test.jar");
verifyOptions(List.of("--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED", "-jar", "test.jar"), tr);
}
public static void main(String... args) throws Exception {
init();
ArgsEnvVar a = new ArgsEnvVar();
@ -236,4 +251,3 @@ public class ArgsEnvVar extends TestHelper {
}
}
}