This commit is contained in:
Henry Jen 2020-01-15 01:54:35 +00:00
commit ae81cfa30f
175 changed files with 3335 additions and 1394 deletions

View file

@ -89,16 +89,15 @@ import sun.reflect.annotation.*;
import sun.reflect.misc.ReflectUtil;
/**
* Instances of the class {@code Class} represent classes and interfaces
* in a running Java application. An enum type is a kind of class and an
* annotation type is a kind of interface. Every array also
* belongs to a class that is reflected as a {@code Class} object
* that is shared by all arrays with the same element type and number
* of dimensions. The primitive Java types ({@code boolean},
* {@code byte}, {@code char}, {@code short},
* {@code int}, {@code long}, {@code float}, and
* {@code double}), and the keyword {@code void} are also
* represented as {@code Class} objects.
* Instances of the class {@code Class} represent classes and
* interfaces in a running Java application. An enum type and a record
* type are kinds of class; an annotation type is a kind of
* interface. Every array also belongs to a class that is reflected as
* a {@code Class} object that is shared by all arrays with the same
* element type and number of dimensions. The primitive Java types
* ({@code boolean}, {@code byte}, {@code char}, {@code short}, {@code
* int}, {@code long}, {@code float}, and {@code double}), and the
* keyword {@code void} are also represented as {@code Class} objects.
*
* <p> {@code Class} has no public constructor. Instead a {@code Class}
* object is constructed automatically by the Java Virtual Machine

View file

@ -71,7 +71,8 @@ package java.lang.annotation;
* @jls 4.1 The Kinds of Types and Values
*/
public enum ElementType {
/** Class, interface (including annotation type), or enum declaration */
/** Class, interface (including annotation type), enum, or record
* declaration */
TYPE,
/** Field declaration (includes enum constants) */

View file

@ -1451,7 +1451,7 @@ public class MethodHandles {
* <li>If the new lookup class is in the same module as the old lookup class,
* the new previous lookup class is the old previous lookup class.
* <li>If the new lookup class is in a different module from the old lookup class,
* the new previous lookup class is the the old lookup class.
* the new previous lookup class is the old lookup class.
*</ul>
* <p>
* The resulting lookup's capabilities for loading classes

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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
@ -1869,14 +1869,26 @@ public abstract class $Type$Buffer
/**
* Returns the memory address, pointing to the byte at the given index,
* modulus the given unit size.
*
* <p> A return value greater than zero indicates the address of the byte at
* the index is misaligned for the unit size, and the value's quantity
* indicates how much the index should be rounded up or down to locate a
* byte at an aligned address. Otherwise, a value of {@code 0} indicates
* that the address of the byte at the index is aligned for the unit size.
* modulo the given unit size.
*
* <p> The return value is non-negative, with {@code 0} indicating that the
* address of the byte at the index is aligned for the unit size, and a
* positive value that the address is misaligned for the unit size. If the
* address of the byte at the index is misaligned, the return value
* represents how much the index should be adjusted to locate a byte at an
* aligned address. Specifically, the index should either be decremented by
* the return value, or incremented by the unit size minus the return value.
* Therefore given
* <blockquote><pre>
* int value = alignmentOffset(index, unitSize)</pre></blockquote>
* then the identities
* <blockquote><pre>
* alignmentOffset(index - value, unitSize) == 0</pre></blockquote>
* and
* <blockquote><pre>
* alignmentOffset(index + (unitSize - value), unitSize) == 0</pre></blockquote>
* must hold.
*
* @apiNote
* This method may be utilized to determine if unit size bytes from an
* index can be accessed atomically, if supported by the native platform.
@ -1892,7 +1904,7 @@ public abstract class $Type$Buffer
* @param unitSize
* The unit size in bytes, must be a power of {@code 2}
*
* @return The indexed byte's memory address modulus the unit size
* @return The indexed byte's memory address modulo the unit size
*
* @throws IllegalArgumentException
* If the index is negative or the unit size is not a power of
@ -1918,7 +1930,7 @@ public abstract class $Type$Buffer
if (unitSize > 8 && !isDirect())
throw new UnsupportedOperationException("Unit size unsupported for non-direct buffers: " + unitSize);
return (int) ((address + index) % unitSize);
return (int) ((address + index) & (unitSize - 1));
}
/**

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, 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
@ -69,7 +69,7 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec {
* @param publicExponent the public exponent e
* @param privateExponent the private exponent d
* @param primeP the prime factor p of n
* @param primeQ the prime factor q of q
* @param primeQ the prime factor q of n
* @param primeExponentP this is d mod (p-1)
* @param primeExponentQ this is d mod (q-1)
* @param crtCoefficient the Chinese Remainder Theorem

View file

@ -1133,7 +1133,7 @@ public class ArrayList<E> extends AbstractList<E>
this.parent = parent;
this.offset = parent.offset + fromIndex;
this.size = toIndex - fromIndex;
this.modCount = root.modCount;
this.modCount = parent.modCount;
}
public E set(int index, E element) {
@ -1286,7 +1286,7 @@ public class ArrayList<E> extends AbstractList<E>
return new ListIterator<E>() {
int cursor = index;
int lastRet = -1;
int expectedModCount = root.modCount;
int expectedModCount = SubList.this.modCount;
public boolean hasNext() {
return cursor != SubList.this.size;
@ -1330,7 +1330,7 @@ public class ArrayList<E> extends AbstractList<E>
final Object[] es = root.elementData;
if (offset + i >= es.length)
throw new ConcurrentModificationException();
for (; i < size && modCount == expectedModCount; i++)
for (; i < size && root.modCount == expectedModCount; i++)
action.accept(elementAt(es, offset + i));
// update once at end to reduce heap write traffic
cursor = i;
@ -1356,7 +1356,7 @@ public class ArrayList<E> extends AbstractList<E>
SubList.this.remove(lastRet);
cursor = lastRet;
lastRet = -1;
expectedModCount = root.modCount;
expectedModCount = SubList.this.modCount;
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
}
@ -1382,7 +1382,7 @@ public class ArrayList<E> extends AbstractList<E>
SubList.this.add(i, e);
cursor = i + 1;
lastRet = -1;
expectedModCount = root.modCount;
expectedModCount = SubList.this.modCount;
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
}

View file

@ -27,8 +27,11 @@ package jdk.internal.misc;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.nio.channels.FileChannel.MapMode;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
/**
* JDK-specific map modes implemented in java.base.
@ -36,10 +39,11 @@ import java.nio.channels.FileChannel.MapMode;
public class ExtendedMapMode {
static final MethodHandle MAP_MODE_CONSTRUCTOR;
static {
try {
var lookup = MethodHandles.privateLookupIn(MapMode.class, MethodHandles.lookup());
PrivilegedExceptionAction<Lookup> pae = () ->
MethodHandles.privateLookupIn(MapMode.class, MethodHandles.lookup());
Lookup lookup = AccessController.doPrivileged(pae);
var methodType = MethodType.methodType(void.class, String.class);
MAP_MODE_CONSTRUCTOR = lookup.findConstructor(MapMode.class, methodType);
} catch (Exception e) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, 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,6 +49,7 @@ import jdk.internal.access.JavaNioAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.ExtendedMapMode;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.ref.Cleaner;
import jdk.internal.ref.CleanerFactory;
@ -1116,8 +1117,11 @@ public class FileChannelImpl
}
private boolean isSync(MapMode mode) {
return mode == ExtendedMapMode.READ_ONLY_SYNC ||
mode == ExtendedMapMode.READ_WRITE_SYNC;
// Do not want to initialize ExtendedMapMode until
// after the module system has been initialized
return !VM.isModuleSystemInited() ? false :
(mode == ExtendedMapMode.READ_ONLY_SYNC ||
mode == ExtendedMapMode.READ_WRITE_SYNC);
}
private int toProt(MapMode mode) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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,9 +28,11 @@ package sun.security.ssl;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.security.AlgorithmConstraints;
import java.security.CryptoPrimitive;
import java.security.GeneralSecurityException;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@ -434,7 +436,7 @@ final class ServerHello {
continue;
}
if (!ServerHandshakeContext.legacyAlgorithmConstraints.permits(
null, cs.name, null)) {
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), cs.name, null)) {
legacySuites.add(cs);
continue;
}
@ -723,7 +725,9 @@ final class ServerHello {
}
if ((legacySuite == null) &&
!legacyConstraints.permits(null, cs.name, null)) {
!legacyConstraints.permits(
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
cs.name, null)) {
legacySuite = cs;
continue;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020, 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
@ -128,6 +128,11 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
@Override
public final boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
if (primitives == null || primitives.isEmpty()) {
throw new IllegalArgumentException("The primitives cannot be null" +
" or empty.");
}
if (!checkAlgorithm(disabledAlgorithms, algorithm, decomposer)) {
return false;
}
@ -216,7 +221,11 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
private boolean checkConstraints(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
// check the key parameter, it cannot be null.
if (primitives == null || primitives.isEmpty()) {
throw new IllegalArgumentException("The primitives cannot be null" +
" or empty.");
}
if (key == null) {
throw new IllegalArgumentException("The key cannot be null");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -51,17 +51,29 @@ public class LegacyAlgorithmConstraints extends AbstractAlgorithmConstraints {
@Override
public final boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, AlgorithmParameters parameters) {
if (primitives == null || primitives.isEmpty()) {
throw new IllegalArgumentException("The primitives cannot be null" +
" or empty.");
}
return checkAlgorithm(legacyAlgorithms, algorithm, decomposer);
}
@Override
public final boolean permits(Set<CryptoPrimitive> primitives, Key key) {
if (primitives == null || primitives.isEmpty()) {
throw new IllegalArgumentException("The primitives cannot be null" +
" or empty.");
}
return true;
}
@Override
public final boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
if (primitives == null || primitives.isEmpty()) {
throw new IllegalArgumentException("The primitives cannot be null" +
" or empty.");
}
return checkAlgorithm(legacyAlgorithms, algorithm, decomposer);
}