This commit is contained in:
Prasanta Sadhukhan 2018-10-04 14:17:59 +05:30
commit 88a48fe2a6
466 changed files with 5339 additions and 6165 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -505,7 +505,7 @@ class Invokers {
* => checkcast(A)* & MH.invokeBasic(a*) & checkcast(R)
* if a big adapter BA can be pulled out of (MT0,MT1)
* => BA.invokeBasic(MT0,MH,a*)
* if a local adapter LA can cached on static CS0 = new GICS(MT0)
* if a local adapter LA can be cached on static CS0 = new GICS(MT0)
* => CS0.LA.invokeBasic(MH,a*)
* else
* => MH.asType(MT0).invokeBasic(A*)

View file

@ -384,7 +384,7 @@ mh.invokeExact(System.out, "Hello, world.");
* A method handle can be obtained on a method, constructor, or field
* which is declared with Java generic types.
* As with the Core Reflection API, the type of the method handle
* will constructed from the erasure of the source-level type.
* will be constructed from the erasure of the source-level type.
* When a method handle is invoked, the types of its arguments
* or the return value cast type may be generic types or type instances.
* If this occurs, the compiler will replace those

View file

@ -4629,7 +4629,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
* <li>Examine and collect the suffixes of the step, pred, and fini parameter lists, after removing the iteration variable types.
* (They must have the form {@code (V... A*)}; collect the {@code (A*)} parts only.)
* <li>Do not collect suffixes from step, pred, and fini parameter lists that do not begin with all the iteration variable types.
* (These types will checked in step 2, along with all the clause function types.)
* (These types will be checked in step 2, along with all the clause function types.)
* <li>Omitted clause functions are ignored. (Equivalently, they are deemed to have empty parameter lists.)
* <li>All of the collected parameter lists must be effectively identical.
* <li>The longest parameter list (which is necessarily unique) is called the "external parameter list" ({@code (A...)}).

View file

@ -100,7 +100,7 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
* is {@code String}. The access mode type for {@code compareAndSet} on this
* VarHandle instance would be
* {@code (String[] c1, int c2, String expectedValue, String newValue)boolean}.
* Such a VarHandle instance may produced by the
* Such a VarHandle instance may be produced by the
* {@link MethodHandles#arrayElementVarHandle(Class) array factory method} and
* access array elements as follows:
* <pre> {@code

View file

@ -1414,7 +1414,7 @@ class ProxyGenerator {
* Generate code to invoke the Class.forName with the name of the given
* class to get its Class object at runtime. The code is written to
* the supplied stream. Note that the code generated by this method
* may caused the checked ClassNotFoundException to be thrown.
* may cause the checked ClassNotFoundException to be thrown.
*/
private void codeClassForName(Class<?> cl, DataOutputStream out)
throws IOException

View file

@ -80,8 +80,8 @@ import java.util.function.Consumer;
* <p> A key is added to its selector's cancelled-key set when it is cancelled,
* whether by closing its channel or by invoking its {@link SelectionKey#cancel
* cancel} method. Cancelling a key will cause its channel to be deregistered
* during the next selection operation, at which time the key will removed from
* all of the selector's key sets.
* during the next selection operation, at which time the key will be removed
* from all of the selector's key sets.
*
* <a id="sks"></a><p> Keys are added to the selected-key set by selection
* operations. A key may be removed directly from the selected-key set by

View file

@ -957,17 +957,17 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
@SuppressWarnings("serial")
static final class UniExceptionally<T> extends UniCompletion<T,T> {
Function<? super Throwable, ? extends T> fn;
UniExceptionally(CompletableFuture<T> dep, CompletableFuture<T> src,
UniExceptionally(Executor executor,
CompletableFuture<T> dep, CompletableFuture<T> src,
Function<? super Throwable, ? extends T> fn) {
super(null, dep, src); this.fn = fn;
super(executor, dep, src); this.fn = fn;
}
final CompletableFuture<T> tryFire(int mode) { // never ASYNC
// assert mode != ASYNC;
final CompletableFuture<T> tryFire(int mode) {
CompletableFuture<T> d; CompletableFuture<T> a;
Object r; Function<? super Throwable, ? extends T> f;
if ((d = dep) == null || (f = fn) == null
|| (a = src) == null || (r = a.result) == null
|| !d.uniExceptionally(r, f, this))
|| !d.uniExceptionally(r, f, mode > 0 ? null : this))
return null;
dep = null; src = null; fn = null;
return d.postFire(a, mode);
@ -980,11 +980,11 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
Throwable x;
if (result == null) {
try {
if (r instanceof AltResult && (x = ((AltResult)r).ex) != null) {
if (c != null && !c.claim())
return false;
if (c != null && !c.claim())
return false;
if (r instanceof AltResult && (x = ((AltResult)r).ex) != null)
completeValue(f.apply(x));
} else
else
internalComplete(r);
} catch (Throwable ex) {
completeThrowable(ex);
@ -994,14 +994,88 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
}
private CompletableFuture<T> uniExceptionallyStage(
Function<Throwable, ? extends T> f) {
Executor e, Function<Throwable, ? extends T> f) {
if (f == null) throw new NullPointerException();
CompletableFuture<T> d = newIncompleteFuture();
Object r;
if ((r = result) == null)
unipush(new UniExceptionally<T>(d, this, f));
else
unipush(new UniExceptionally<T>(e, d, this, f));
else if (e == null)
d.uniExceptionally(r, f, null);
else {
try {
e.execute(new UniExceptionally<T>(null, d, this, f));
} catch (Throwable ex) {
d.result = encodeThrowable(ex);
}
}
return d;
}
@SuppressWarnings("serial")
static final class UniComposeExceptionally<T> extends UniCompletion<T,T> {
Function<Throwable, ? extends CompletionStage<T>> fn;
UniComposeExceptionally(Executor executor, CompletableFuture<T> dep,
CompletableFuture<T> src,
Function<Throwable, ? extends CompletionStage<T>> fn) {
super(executor, dep, src); this.fn = fn;
}
final CompletableFuture<T> tryFire(int mode) {
CompletableFuture<T> d; CompletableFuture<T> a;
Function<Throwable, ? extends CompletionStage<T>> f;
Object r; Throwable x;
if ((d = dep) == null || (f = fn) == null
|| (a = src) == null || (r = a.result) == null)
return null;
if (d.result == null) {
if ((r instanceof AltResult) &&
(x = ((AltResult)r).ex) != null) {
try {
if (mode <= 0 && !claim())
return null;
CompletableFuture<T> g = f.apply(x).toCompletableFuture();
if ((r = g.result) != null)
d.completeRelay(r);
else {
g.unipush(new UniRelay<T,T>(d, g));
if (d.result == null)
return null;
}
} catch (Throwable ex) {
d.completeThrowable(ex);
}
}
else
d.internalComplete(r);
}
dep = null; src = null; fn = null;
return d.postFire(a, mode);
}
}
private CompletableFuture<T> uniComposeExceptionallyStage(
Executor e, Function<Throwable, ? extends CompletionStage<T>> f) {
if (f == null) throw new NullPointerException();
CompletableFuture<T> d = newIncompleteFuture();
Object r, s; Throwable x;
if ((r = result) == null)
unipush(new UniComposeExceptionally<T>(e, d, this, f));
else if (!(r instanceof AltResult) || (x = ((AltResult)r).ex) == null)
d.internalComplete(r);
else
try {
if (e != null)
e.execute(new UniComposeExceptionally<T>(null, d, this, f));
else {
CompletableFuture<T> g = f.apply(x).toCompletableFuture();
if ((s = g.result) != null)
d.result = encodeRelay(s);
else
g.unipush(new UniRelay<T,T>(d, g));
}
} catch (Throwable ex) {
d.result = encodeThrowable(ex);
}
return d;
}
@ -1093,7 +1167,7 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
Object r, s; Throwable x;
if ((r = result) == null)
unipush(new UniCompose<T,V>(e, d, this, f));
else if (e == null) {
else {
if (r instanceof AltResult) {
if ((x = ((AltResult)r).ex) != null) {
d.result = encodeThrowable(x, r);
@ -1102,23 +1176,20 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
r = null;
}
try {
@SuppressWarnings("unchecked") T t = (T) r;
CompletableFuture<V> g = f.apply(t).toCompletableFuture();
if ((s = g.result) != null)
d.result = encodeRelay(s);
if (e != null)
e.execute(new UniCompose<T,V>(null, d, this, f));
else {
g.unipush(new UniRelay<V,V>(d, g));
@SuppressWarnings("unchecked") T t = (T) r;
CompletableFuture<V> g = f.apply(t).toCompletableFuture();
if ((s = g.result) != null)
d.result = encodeRelay(s);
else
g.unipush(new UniRelay<V,V>(d, g));
}
} catch (Throwable ex) {
d.result = encodeThrowable(ex);
}
}
else
try {
e.execute(new UniCompose<T,V>(null, d, this, f));
} catch (Throwable ex) {
d.result = encodeThrowable(ex);
}
return d;
}
@ -1898,7 +1969,7 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
* Creates a new complete CompletableFuture with given encoded result.
*/
CompletableFuture(Object r) {
this.result = r;
RESULT.setRelease(this, r);
}
/**
@ -2285,28 +2356,36 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
return this;
}
// not in interface CompletionStage
/**
* Returns a new CompletableFuture that is completed when this
* CompletableFuture completes, with the result of the given
* function of the exception triggering this CompletableFuture's
* completion when it completes exceptionally; otherwise, if this
* CompletableFuture completes normally, then the returned
* CompletableFuture also completes normally with the same value.
* Note: More flexible versions of this functionality are
* available using methods {@code whenComplete} and {@code handle}.
*
* @param fn the function to use to compute the value of the
* returned CompletableFuture if this CompletableFuture completed
* exceptionally
* @return the new CompletableFuture
*/
public CompletableFuture<T> exceptionally(
Function<Throwable, ? extends T> fn) {
return uniExceptionallyStage(fn);
return uniExceptionallyStage(null, fn);
}
public CompletableFuture<T> exceptionallyAsync(
Function<Throwable, ? extends T> fn) {
return uniExceptionallyStage(defaultExecutor(), fn);
}
public CompletableFuture<T> exceptionallyAsync(
Function<Throwable, ? extends T> fn, Executor executor) {
return uniExceptionallyStage(screenExecutor(executor), fn);
}
public CompletableFuture<T> exceptionallyCompose(
Function<Throwable, ? extends CompletionStage<T>> fn) {
return uniComposeExceptionallyStage(null, fn);
}
public CompletableFuture<T> exceptionallyComposeAsync(
Function<Throwable, ? extends CompletionStage<T>> fn) {
return uniComposeExceptionallyStage(defaultExecutor(), fn);
}
public CompletableFuture<T> exceptionallyComposeAsync(
Function<Throwable, ? extends CompletionStage<T>> fn,
Executor executor) {
return uniComposeExceptionallyStage(screenExecutor(executor), fn);
}
/* ------------- Arbitrary-arity constructions -------------- */

View file

@ -850,6 +850,130 @@ public interface CompletionStage<T> {
public CompletionStage<T> exceptionally
(Function<Throwable, ? extends T> fn);
/**
* Returns a new CompletionStage that, when this stage completes
* exceptionally, is executed with this stage's exception as the
* argument to the supplied function, using this stage's default
* asynchronous execution facility. Otherwise, if this stage
* completes normally, then the returned stage also completes
* normally with the same value.
*
* @implSpec The default implementation invokes {@link #handle},
* relaying to {@link #handleAsync} on exception, then {@link
* #thenCompose} for result.
*
* @param fn the function to use to compute the value of the
* returned CompletionStage if this CompletionStage completed
* exceptionally
* @return the new CompletionStage
* @since 12
*/
public default CompletionStage<T> exceptionallyAsync
(Function<Throwable, ? extends T> fn) {
return handle((r, ex) -> (ex == null)
? this
: this.<T>handleAsync((r1, ex1) -> fn.apply(ex1)))
.thenCompose(Function.identity());
}
/**
* Returns a new CompletionStage that, when this stage completes
* exceptionally, is executed with this stage's exception as the
* argument to the supplied function, using the supplied Executor.
* Otherwise, if this stage completes normally, then the returned
* stage also completes normally with the same value.
*
* @implSpec The default implementation invokes {@link #handle},
* relaying to {@link #handleAsync} on exception, then {@link
* #thenCompose} for result.
*
* @param fn the function to use to compute the value of the
* returned CompletionStage if this CompletionStage completed
* exceptionally
* @param executor the executor to use for asynchronous execution
* @return the new CompletionStage
* @since 12
*/
public default CompletionStage<T> exceptionallyAsync
(Function<Throwable, ? extends T> fn, Executor executor) {
return handle((r, ex) -> (ex == null)
? this
: this.<T>handleAsync((r1, ex1) -> fn.apply(ex1), executor))
.thenCompose(Function.identity());
}
/**
* Returns a new CompletionStage that, when this stage completes
* exceptionally, is composed using the results of the supplied
* function applied to this stage's exception.
*
* @implSpec The default implementation invokes {@link #handle},
* invoking the given function on exception, then {@link
* #thenCompose} for result.
*
* @param fn the function to use to compute the returned
* CompletionStage if this CompletionStage completed exceptionally
* @return the new CompletionStage
* @since 12
*/
public default CompletionStage<T> exceptionallyCompose
(Function<Throwable, ? extends CompletionStage<T>> fn) {
return handle((r, ex) -> (ex == null)
? this
: fn.apply(ex))
.thenCompose(Function.identity());
}
/**
* Returns a new CompletionStage that, when this stage completes
* exceptionally, is composed using the results of the supplied
* function applied to this stage's exception, using this stage's
* default asynchronous execution facility.
*
* @implSpec The default implementation invokes {@link #handle},
* relaying to {@link #handleAsync} on exception, then {@link
* #thenCompose} for result.
*
* @param fn the function to use to compute the returned
* CompletionStage if this CompletionStage completed exceptionally
* @return the new CompletionStage
* @since 12
*/
public default CompletionStage<T> exceptionallyComposeAsync
(Function<Throwable, ? extends CompletionStage<T>> fn) {
return handle((r, ex) -> (ex == null)
? this
: this.handleAsync((r1, ex1) -> fn.apply(ex1))
.thenCompose(Function.identity()))
.thenCompose(Function.identity());
}
/**
* Returns a new CompletionStage that, when this stage completes
* exceptionally, is composed using the results of the supplied
* function applied to this stage's exception, using the
* supplied Executor.
*
* @implSpec The default implementation invokes {@link #handle},
* relaying to {@link #handleAsync} on exception, then {@link
* #thenCompose} for result.
*
* @param fn the function to use to compute the returned
* CompletionStage if this CompletionStage completed exceptionally
* @param executor the executor to use for asynchronous execution
* @return the new CompletionStage
* @since 12
*/
public default CompletionStage<T> exceptionallyComposeAsync
(Function<Throwable, ? extends CompletionStage<T>> fn,
Executor executor) {
return handle((r, ex) -> (ex == null)
? this
: this.handleAsync((r1, ex1) -> fn.apply(ex1), executor)
.thenCompose(Function.identity()))
.thenCompose(Function.identity());
}
/**
* Returns a {@link CompletableFuture} maintaining the same
* completion properties as this stage. If this stage is already a

View file

@ -1013,7 +1013,7 @@ public abstract class SSLEngine {
* an instance of this class, but before the {@code SSLSession} has
* been completely initialized and made available via {@code getSession}.
* For example, the list of valid signature algorithms may restrict
* the type of certificates that can used during TrustManager
* the type of certificates that can be used during TrustManager
* decisions, or the maximum TLS/DTLS fragment packet sizes can be
* resized to better support the network environment.
* <p>

View file

@ -421,7 +421,7 @@ public abstract class SSLSocket extends Socket
* an instance of this class, but before the {@code SSLSession} has
* been completely initialized and made available via {@code getSession}.
* For example, the list of valid signature algorithms may restrict
* the type of certificates that can used during TrustManager
* the type of certificates that can be used during TrustManager
* decisions, or the maximum TLS fragment packet sizes can be
* resized to better support the network environment.
* <p>

View file

@ -105,7 +105,7 @@ abstract class DSA extends SignatureSpi {
* Construct a blank DSA object that will use the specified
* signature format. {@code p1363Format} should be {@code true} to
* use the IEEE P1363 format. If {@code p1363Format} is {@code false},
* the DER-encoded ASN.1 format will used. The DSA object must be
* the DER-encoded ASN.1 format will be used. The DSA object must be
* initialized before being usable for signing or verifying.
*/
DSA(MessageDigest md, boolean p1363Format) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
@ -49,7 +49,7 @@ import javax.security.auth.x500.X500Principal;
* are as fast (or marginally faster) than for the standard
* CollectionCertStore. Certificate subjects and CRL issuers
* were found to be specified in most searches used internally by the
* CertPath provider. Additional attributes could indexed if there are
* CertPath provider. Additional attributes could be indexed if there are
* queries that justify the effort.
*
* <li>Changes to the specified Collection after construction time are

View file

@ -849,8 +849,7 @@ public final class SSLSocketImpl
*
* This implementation is somewhat less efficient than possible, but
* not badly so (redundant copy). We reuse the read() code to keep
* things simpler. Note that SKIP_ARRAY is static and may garbled by
* concurrent use, but we are not interested in the data anyway.
* things simpler.
*/
@Override
public synchronized long skip(long n) throws IOException {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 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
@ -38,8 +38,8 @@ import sun.security.util.*;
* lifetime of the responder's certificate. The CA does so by including
* the extension id-pkix-ocsp-nocheck. This SHOULD be a non-critical
* extension. The value of the extension should be NULL. CAs issuing
* such a certificate should realized that a compromise of the
* responder's key, is as serious as the compromise of a CA key used to
* such a certificate should realize that a compromise of the
* responder's key is as serious as the compromise of a CA key used to
* sign CRLs, at least for the validity period of this certificate. CA's
* may choose to issue this type of certificate with a very short
* lifetime and renew it frequently.

View file

@ -263,6 +263,8 @@ static char* nextToken(__ctx_args *pctx) {
}
JLI_List_addSubstring(pctx->parts, anchor, nextc - anchor);
pctx->state = IN_ESCAPE;
// anchor after backslash character
anchor = nextc + 1;
break;
case '\'':
case '"':

View file

@ -56,7 +56,7 @@ Java_java_io_Console_echo(JNIEnv *env,
JNU_ThrowIOExceptionWithLastError(env, "tcgetattr failed");
return !on;
}
old = (tio.c_lflag & ECHO);
old = (tio.c_lflag & ECHO) != 0;
if (on) {
tio.c_lflag |= ECHO;
} else {

View file

@ -170,6 +170,10 @@ getJavaIDFromLangID(LANGID langID)
return NULL;
}
for (index = 0; index < 5; index++) {
elems[index] = NULL;
}
if (SetupI18nProps(MAKELCID(langID, SORT_DEFAULT),
&(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]))) {
@ -183,15 +187,17 @@ getJavaIDFromLangID(LANGID langID)
strcat(ret, elems[index]);
}
}
for (index = 0; index < 5; index++) {
free(elems[index]);
}
} else {
free(ret);
ret = NULL;
}
for (index = 0; index < 5; index++) {
if (elems[index] != NULL) {
free(elems[index]);
}
}
return ret;
}