This commit is contained in:
Jesper Wilhelmsson 2020-12-15 03:40:30 +00:00
commit 381021aebf
42 changed files with 720 additions and 230 deletions

View file

@ -2383,11 +2383,7 @@ public final class Class<T> implements java.io.Serializable,
if (!isRecord()) {
return null;
}
RecordComponent[] recordComponents = getRecordComponents0();
if (recordComponents == null) {
return new RecordComponent[0];
}
return recordComponents;
return getRecordComponents0();
}
/**
@ -3577,9 +3573,17 @@ public final class Class<T> implements java.io.Serializable,
private native Field[] getDeclaredFields0(boolean publicOnly);
private native Method[] getDeclaredMethods0(boolean publicOnly);
private native Constructor<T>[] getDeclaredConstructors0(boolean publicOnly);
private native Class<?>[] getDeclaredClasses0();
private native Class<?>[] getDeclaredClasses0();
/*
* Returns an array containing the components of the Record attribute,
* or null if the attribute is not present.
*
* Note that this method returns non-null array on a class with
* the Record attribute even if this class is not a record.
*/
private native RecordComponent[] getRecordComponents0();
private native boolean isRecord0();
private native boolean isRecord0();
/**
* Helper method to get the method name from arguments.
@ -3706,6 +3710,8 @@ public final class Class<T> implements java.io.Serializable,
* @since 16
*/
public boolean isRecord() {
// this superclass and final modifier check is not strictly necessary
// they are intrinsified and serve as a fast-path check
return getSuperclass() == java.lang.Record.class &&
(this.getModifiers() & Modifier.FINAL) != 0 &&
isRecord0();

View file

@ -111,15 +111,14 @@ public abstract class Record {
* <li> If the component is of a reference type, the component is
* considered equal if and only if {@link
* java.util.Objects#equals(Object,Object)
* Objects.equals(this.c(), r.c()} would return {@code true}.
* Objects.equals(this.c, r.c} would return {@code true}.
*
* <li> If the component is of a primitive type, using the
* corresponding primitive wrapper class {@code PW} (the
* corresponding wrapper class for {@code int} is {@code
* java.lang.Integer}, and so on), the component is considered
* equal if and only if {@code
* PW.valueOf(this.c()).equals(PW.valueOf(r.c()))} would return
* {@code true}.
* PW.compare(this.c, r.c)} would return {@code 0}.
*
* </ul>
*

View file

@ -1871,6 +1871,8 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
* interrupted.
*/
private Object waitingGet(boolean interruptible) {
if (interruptible && Thread.interrupted())
return null;
Signaller q = null;
boolean queued = false;
Object r;
@ -1882,25 +1884,25 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
}
else if (!queued)
queued = tryPushStack(q);
else if (interruptible && q.interrupted) {
q.thread = null;
cleanStack();
return null;
}
else {
try {
ForkJoinPool.managedBlock(q);
} catch (InterruptedException ie) { // currently cannot happen
q.interrupted = true;
}
if (q.interrupted && interruptible)
break;
}
}
if (q != null && queued) {
if (q != null) {
q.thread = null;
if (!interruptible && q.interrupted)
if (q.interrupted)
Thread.currentThread().interrupt();
if (r == null)
cleanStack();
}
if (r != null || (r = result) != null)
postComplete();
postComplete();
return r;
}