mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
Merge
This commit is contained in:
commit
4651ce7fc9
1115 changed files with 139491 additions and 66135 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2019, 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
|
||||
|
@ -26,6 +26,7 @@
|
|||
package java.io;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
/**
|
||||
* A <code>BufferedInputStream</code> adds
|
||||
|
@ -53,14 +54,6 @@ class BufferedInputStream extends FilterInputStream {
|
|||
|
||||
private static int DEFAULT_BUFFER_SIZE = 8192;
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate.
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
/**
|
||||
* As this class is used early during bootstrap, it's motivated to use
|
||||
* Unsafe.compareAndSetObject instead of AtomicReferenceFieldUpdater
|
||||
|
@ -220,7 +213,7 @@ class BufferedInputStream extends FilterInputStream {
|
|||
byte[] buffer = getBufIfOpen();
|
||||
if (markpos < 0)
|
||||
pos = 0; /* no mark: throw away the buffer */
|
||||
else if (pos >= buffer.length) /* no room left in buffer */
|
||||
else if (pos >= buffer.length) { /* no room left in buffer */
|
||||
if (markpos > 0) { /* can throw away early part of the buffer */
|
||||
int sz = pos - markpos;
|
||||
System.arraycopy(buffer, markpos, buffer, 0, sz);
|
||||
|
@ -229,11 +222,10 @@ class BufferedInputStream extends FilterInputStream {
|
|||
} else if (buffer.length >= marklimit) {
|
||||
markpos = -1; /* buffer got too big, invalidate mark */
|
||||
pos = 0; /* drop buffer contents */
|
||||
} else if (buffer.length >= MAX_BUFFER_SIZE) {
|
||||
throw new OutOfMemoryError("Required array size too large");
|
||||
} else { /* grow buffer */
|
||||
int nsz = (pos <= MAX_BUFFER_SIZE - pos) ?
|
||||
pos * 2 : MAX_BUFFER_SIZE;
|
||||
int nsz = ArraysSupport.newLength(pos,
|
||||
1, /* minimum growth */
|
||||
pos /* preferred growth */);
|
||||
if (nsz > marklimit)
|
||||
nsz = marklimit;
|
||||
byte[] nbuf = new byte[nsz];
|
||||
|
@ -248,6 +240,7 @@ class BufferedInputStream extends FilterInputStream {
|
|||
}
|
||||
buffer = nbuf;
|
||||
}
|
||||
}
|
||||
count = pos;
|
||||
int n = getInIfOpen().read(buffer, pos, buffer.length - pos);
|
||||
if (n > 0)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2019, 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
|
||||
|
@ -29,6 +29,8 @@ import java.nio.charset.Charset;
|
|||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
/**
|
||||
* This class implements an output stream in which the data is
|
||||
* written into a byte array. The buffer automatically grows as data
|
||||
|
@ -84,48 +86,20 @@ public class ByteArrayOutputStream extends OutputStream {
|
|||
* at least the number of elements specified by the minimum
|
||||
* capacity argument.
|
||||
*
|
||||
* @param minCapacity the desired minimum capacity
|
||||
* @throws OutOfMemoryError if {@code minCapacity < 0}. This is
|
||||
* interpreted as a request for the unsatisfiably large capacity
|
||||
* @param minCapacity the desired minimum capacity.
|
||||
* @throws OutOfMemoryError if {@code minCapacity < 0} and
|
||||
* {@code minCapacity - buf.length > 0}. This is interpreted as a
|
||||
* request for the unsatisfiably large capacity.
|
||||
* {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}.
|
||||
*/
|
||||
private void ensureCapacity(int minCapacity) {
|
||||
// overflow-conscious code
|
||||
if (minCapacity - buf.length > 0)
|
||||
grow(minCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate.
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
/**
|
||||
* Increases the capacity to ensure that it can hold at least the
|
||||
* number of elements specified by the minimum capacity argument.
|
||||
*
|
||||
* @param minCapacity the desired minimum capacity
|
||||
*/
|
||||
private void grow(int minCapacity) {
|
||||
// overflow-conscious code
|
||||
int oldCapacity = buf.length;
|
||||
int newCapacity = oldCapacity << 1;
|
||||
if (newCapacity - minCapacity < 0)
|
||||
newCapacity = minCapacity;
|
||||
if (newCapacity - MAX_ARRAY_SIZE > 0)
|
||||
newCapacity = hugeCapacity(minCapacity);
|
||||
buf = Arrays.copyOf(buf, newCapacity);
|
||||
}
|
||||
|
||||
private static int hugeCapacity(int minCapacity) {
|
||||
if (minCapacity < 0) // overflow
|
||||
throw new OutOfMemoryError();
|
||||
return (minCapacity > MAX_ARRAY_SIZE) ?
|
||||
Integer.MAX_VALUE :
|
||||
MAX_ARRAY_SIZE;
|
||||
int minGrowth = minCapacity - oldCapacity;
|
||||
if (minGrowth > 0) {
|
||||
buf = Arrays.copyOf(buf, ArraysSupport.newLength(oldCapacity,
|
||||
minGrowth, oldCapacity /* preferred growth */));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, 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
|
||||
|
@ -440,8 +440,8 @@ public final class FilePermission extends Permission implements Serializable {
|
|||
* <p>A pathname containing an empty string represents an empty path.
|
||||
*
|
||||
* @implNote In this implementation, the
|
||||
* {@code jdk.io.permissionsUseCanonicalPath} system property dictates how
|
||||
* the {@code path} argument is processed and stored.
|
||||
* {@systemProperty jdk.io.permissionsUseCanonicalPath} system property
|
||||
* dictates how the {@code path} argument is processed and stored.
|
||||
* <P>
|
||||
* If the value of the system property is set to {@code true}, {@code path}
|
||||
* is canonicalized and stored as a String object named {@code cpath}.
|
||||
|
|
|
@ -205,7 +205,7 @@ public interface ObjectInputFilter {
|
|||
* <p>
|
||||
* The filter is configured during the initialization of the {@code ObjectInputFilter.Config}
|
||||
* class. For example, by calling {@link #getSerialFilter() Config.getSerialFilter}.
|
||||
* If the system property {@code jdk.serialFilter} is defined, it is used
|
||||
* If the system property {@systemProperty jdk.serialFilter} is defined, it is used
|
||||
* to configure the filter.
|
||||
* If the system property is not defined, and the {@link java.security.Security}
|
||||
* property {@code jdk.serialFilter} is defined then it is used to configure the filter.
|
||||
|
@ -283,7 +283,7 @@ public interface ObjectInputFilter {
|
|||
/**
|
||||
* Current configured filter.
|
||||
*/
|
||||
private static ObjectInputFilter serialFilter = configuredFilter;
|
||||
private static volatile ObjectInputFilter serialFilter = configuredFilter;
|
||||
|
||||
/**
|
||||
* Returns the system-wide serialization filter or {@code null} if not configured.
|
||||
|
@ -291,9 +291,7 @@ public interface ObjectInputFilter {
|
|||
* @return the system-wide serialization filter or {@code null} if not configured
|
||||
*/
|
||||
public static ObjectInputFilter getSerialFilter() {
|
||||
synchronized (serialFilterLock) {
|
||||
return serialFilter;
|
||||
}
|
||||
return serialFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package java.lang;
|
||||
|
||||
import jdk.internal.math.FloatingDecimal;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Spliterator;
|
||||
import java.util.stream.IntStream;
|
||||
|
@ -685,10 +686,15 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
checkRange(start, end, s.length());
|
||||
int len = end - start;
|
||||
ensureCapacityInternal(count + len);
|
||||
appendChars(s, start, end);
|
||||
if (s instanceof String) {
|
||||
appendChars((String)s, start, end);
|
||||
} else {
|
||||
appendChars(s, start, end);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Appends the string representation of the {@code char} array
|
||||
* argument to this sequence.
|
||||
|
@ -1743,6 +1749,35 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
this.count = count + end - off;
|
||||
}
|
||||
|
||||
private final void appendChars(String s, int off, int end) {
|
||||
if (isLatin1()) {
|
||||
if (s.isLatin1()) {
|
||||
System.arraycopy(s.value(), off, this.value, this.count, end - off);
|
||||
} else {
|
||||
// We might need to inflate, but do it as late as possible since
|
||||
// the range of characters we're copying might all be latin1
|
||||
byte[] val = this.value;
|
||||
for (int i = off, j = count; i < end; i++) {
|
||||
char c = s.charAt(i);
|
||||
if (StringLatin1.canEncode(c)) {
|
||||
val[j++] = (byte) c;
|
||||
} else {
|
||||
count = j;
|
||||
inflate();
|
||||
System.arraycopy(s.value(), i << UTF16, this.value, j << UTF16, (end - i) << UTF16);
|
||||
count += end - i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (s.isLatin1()) {
|
||||
StringUTF16.putCharsSB(this.value, this.count, s, off, end);
|
||||
} else { // both UTF16
|
||||
System.arraycopy(s.value(), off << UTF16, this.value, this.count << UTF16, (end - off) << UTF16);
|
||||
}
|
||||
count += end - off;
|
||||
}
|
||||
|
||||
private final void appendChars(CharSequence s, int off, int end) {
|
||||
if (isLatin1()) {
|
||||
byte[] val = this.value;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, 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
|
||||
|
@ -356,7 +356,7 @@ public final class Byte extends Number implements Comparable<Byte> {
|
|||
/**
|
||||
* Returns the value of this {@code Byte} as a {@code short} after
|
||||
* a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public short shortValue() {
|
||||
return (short)value;
|
||||
|
@ -365,7 +365,7 @@ public final class Byte extends Number implements Comparable<Byte> {
|
|||
/**
|
||||
* Returns the value of this {@code Byte} as an {@code int} after
|
||||
* a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public int intValue() {
|
||||
return (int)value;
|
||||
|
@ -374,7 +374,7 @@ public final class Byte extends Number implements Comparable<Byte> {
|
|||
/**
|
||||
* Returns the value of this {@code Byte} as a {@code long} after
|
||||
* a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public long longValue() {
|
||||
return (long)value;
|
||||
|
@ -383,7 +383,7 @@ public final class Byte extends Number implements Comparable<Byte> {
|
|||
/**
|
||||
* Returns the value of this {@code Byte} as a {@code float} after
|
||||
* a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public float floatValue() {
|
||||
return (float)value;
|
||||
|
@ -392,7 +392,7 @@ public final class Byte extends Number implements Comparable<Byte> {
|
|||
/**
|
||||
* Returns the value of this {@code Byte} as a {@code double}
|
||||
* after a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public double doubleValue() {
|
||||
return (double)value;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -999,7 +999,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
*
|
||||
* @since 9
|
||||
* @spec JPMS
|
||||
* @jls 6.7 Fully Qualified Names
|
||||
* @jls 6.7 Fully Qualified Names
|
||||
*/
|
||||
public String getPackageName() {
|
||||
String pn = this.packageName;
|
||||
|
@ -3910,7 +3910,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* SecurityManager#checkPackageAccess s.checkPackageAccess()}
|
||||
* denies access to the package of the returned class
|
||||
* @since 11
|
||||
* @jvms 4.7.28 and 4.7.29 NestHost and NestMembers attributes
|
||||
* @jvms 4.7.28 The {@code NestHost} Attribute
|
||||
* @jvms 4.7.29 The {@code NestMembers} Attribute
|
||||
* @jvms 5.4.4 Access Control
|
||||
*/
|
||||
@CallerSensitive
|
||||
|
|
|
@ -222,7 +222,7 @@ import sun.security.util.SecurityConstants;
|
|||
* or a fully qualified name as defined by
|
||||
* <cite>The Java™ Language Specification</cite>.
|
||||
*
|
||||
* @jls 6.7 Fully Qualified Names
|
||||
* @jls 6.7 Fully Qualified Names
|
||||
* @jls 13.1 The Form of a Binary
|
||||
* @see #resolveClass(Class)
|
||||
* @since 1.0
|
||||
|
@ -2194,7 +2194,7 @@ public abstract class ClassLoader {
|
|||
* @revised 9
|
||||
* @spec JPMS
|
||||
*
|
||||
* @jvms 5.3 Run-time package
|
||||
* @jvms 5.3 Creation and Loading
|
||||
* @see <a href="{@docRoot}/../specs/jar/jar.html#package-sealing">
|
||||
* The JAR File Specification: Package Sealing</a>
|
||||
*/
|
||||
|
@ -2228,7 +2228,7 @@ public abstract class ClassLoader {
|
|||
* @throws NullPointerException
|
||||
* if {@code name} is {@code null}.
|
||||
*
|
||||
* @jvms 5.3 Run-time package
|
||||
* @jvms 5.3 Creation and Loading
|
||||
*
|
||||
* @since 9
|
||||
* @spec JPMS
|
||||
|
@ -2255,7 +2255,7 @@ public abstract class ClassLoader {
|
|||
* this class loader; or an zero length array if no package has been
|
||||
* defined by this class loader.
|
||||
*
|
||||
* @jvms 5.3 Run-time package
|
||||
* @jvms 5.3 Creation and Loading
|
||||
*
|
||||
* @since 9
|
||||
* @spec JPMS
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2019, 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
|
||||
|
@ -673,7 +673,7 @@ public final class Double extends Number
|
|||
*
|
||||
* @return the {@code double} value represented by this object
|
||||
* converted to type {@code byte}
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
* @since 1.1
|
||||
*/
|
||||
public byte byteValue() {
|
||||
|
@ -686,7 +686,7 @@ public final class Double extends Number
|
|||
*
|
||||
* @return the {@code double} value represented by this object
|
||||
* converted to type {@code short}
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
* @since 1.1
|
||||
*/
|
||||
public short shortValue() {
|
||||
|
@ -696,7 +696,7 @@ public final class Double extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Double} as an {@code int}
|
||||
* after a narrowing primitive conversion.
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*
|
||||
* @return the {@code double} value represented by this object
|
||||
* converted to type {@code int}
|
||||
|
@ -711,7 +711,7 @@ public final class Double extends Number
|
|||
*
|
||||
* @return the {@code double} value represented by this object
|
||||
* converted to type {@code long}
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public long longValue() {
|
||||
return (long)value;
|
||||
|
@ -723,7 +723,7 @@ public final class Double extends Number
|
|||
*
|
||||
* @return the {@code double} value represented by this object
|
||||
* converted to type {@code float}
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
* @since 1.0
|
||||
*/
|
||||
public float floatValue() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2019, 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
|
||||
|
@ -602,7 +602,7 @@ public final class Float extends Number
|
|||
*
|
||||
* @return the {@code float} value represented by this object
|
||||
* converted to type {@code byte}
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public byte byteValue() {
|
||||
return (byte)value;
|
||||
|
@ -614,7 +614,7 @@ public final class Float extends Number
|
|||
*
|
||||
* @return the {@code float} value represented by this object
|
||||
* converted to type {@code short}
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
* @since 1.1
|
||||
*/
|
||||
public short shortValue() {
|
||||
|
@ -627,7 +627,7 @@ public final class Float extends Number
|
|||
*
|
||||
* @return the {@code float} value represented by this object
|
||||
* converted to type {@code int}
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public int intValue() {
|
||||
return (int)value;
|
||||
|
@ -639,7 +639,7 @@ public final class Float extends Number
|
|||
*
|
||||
* @return the {@code float} value represented by this object
|
||||
* converted to type {@code long}
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public long longValue() {
|
||||
return (long)value;
|
||||
|
@ -661,7 +661,7 @@ public final class Float extends Number
|
|||
*
|
||||
* @return the {@code float} value represented by this
|
||||
* object converted to type {@code double}
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public double doubleValue() {
|
||||
return (double)value;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2019, 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
|
||||
|
@ -57,7 +57,7 @@ import java.lang.annotation.*;
|
|||
* regardless of whether or not a {@code FunctionalInterface}
|
||||
* annotation is present on the interface declaration.
|
||||
*
|
||||
* @jls 4.3.2. The Class Object
|
||||
* @jls 4.3.2 The Class Object
|
||||
* @jls 9.8 Functional Interfaces
|
||||
* @jls 9.4.3 Interface Method Body
|
||||
* @jls 9.6.4.9 @FunctionalInterface
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2019, 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
|
||||
|
@ -1120,7 +1120,7 @@ public final class Integer extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Integer} as a {@code byte}
|
||||
* after a narrowing primitive conversion.
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public byte byteValue() {
|
||||
return (byte)value;
|
||||
|
@ -1129,7 +1129,7 @@ public final class Integer extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Integer} as a {@code short}
|
||||
* after a narrowing primitive conversion.
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public short shortValue() {
|
||||
return (short)value;
|
||||
|
@ -1147,7 +1147,7 @@ public final class Integer extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Integer} as a {@code long}
|
||||
* after a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
* @see Integer#toUnsignedLong(int)
|
||||
*/
|
||||
public long longValue() {
|
||||
|
@ -1157,7 +1157,7 @@ public final class Integer extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Integer} as a {@code float}
|
||||
* after a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public float floatValue() {
|
||||
return (float)value;
|
||||
|
@ -1166,7 +1166,7 @@ public final class Integer extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Integer} as a {@code double}
|
||||
* after a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public double doubleValue() {
|
||||
return (double)value;
|
||||
|
|
|
@ -1339,7 +1339,7 @@ public final class Long extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Long} as a {@code byte} after
|
||||
* a narrowing primitive conversion.
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public byte byteValue() {
|
||||
return (byte)value;
|
||||
|
@ -1348,7 +1348,7 @@ public final class Long extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Long} as a {@code short} after
|
||||
* a narrowing primitive conversion.
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public short shortValue() {
|
||||
return (short)value;
|
||||
|
@ -1357,7 +1357,7 @@ public final class Long extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Long} as an {@code int} after
|
||||
* a narrowing primitive conversion.
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public int intValue() {
|
||||
return (int)value;
|
||||
|
@ -1375,7 +1375,7 @@ public final class Long extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Long} as a {@code float} after
|
||||
* a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public float floatValue() {
|
||||
return (float)value;
|
||||
|
@ -1384,7 +1384,7 @@ public final class Long extends Number
|
|||
/**
|
||||
* Returns the value of this {@code Long} as a {@code double}
|
||||
* after a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public double doubleValue() {
|
||||
return (double)value;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2019, 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
|
||||
|
@ -48,11 +48,16 @@ package java.lang;
|
|||
*
|
||||
* @author Lee Boynton
|
||||
* @author Arthur van Hoff
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class Number implements java.io.Serializable {
|
||||
/**
|
||||
* Constructor for subclasses to call.
|
||||
*/
|
||||
public Number() {super();}
|
||||
|
||||
/**
|
||||
* Returns the value of the specified number as an {@code int}.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, 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
|
||||
|
@ -108,7 +108,7 @@ import jdk.internal.reflect.Reflection;
|
|||
* <em>named modules</em>. Instead those packages are automatically defined
|
||||
* and have no specification and implementation versioning information.
|
||||
*
|
||||
* @jvms 5.3 Run-time package
|
||||
* @jvms 5.3 Creation and Loading
|
||||
* @see <a href="{@docRoot}/../specs/jar/jar.html#package-sealing">
|
||||
* The JAR File Specification: Package Sealing</a>
|
||||
* @see ClassLoader#definePackage(String, String, String, String, String, String, String, URL)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, 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
|
||||
|
@ -352,7 +352,7 @@ public final class Short extends Number implements Comparable<Short> {
|
|||
/**
|
||||
* Returns the value of this {@code Short} as a {@code byte} after
|
||||
* a narrowing primitive conversion.
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public byte byteValue() {
|
||||
return (byte)value;
|
||||
|
@ -370,7 +370,7 @@ public final class Short extends Number implements Comparable<Short> {
|
|||
/**
|
||||
* Returns the value of this {@code Short} as an {@code int} after
|
||||
* a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public int intValue() {
|
||||
return (int)value;
|
||||
|
@ -379,7 +379,7 @@ public final class Short extends Number implements Comparable<Short> {
|
|||
/**
|
||||
* Returns the value of this {@code Short} as a {@code long} after
|
||||
* a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public long longValue() {
|
||||
return (long)value;
|
||||
|
@ -388,7 +388,7 @@ public final class Short extends Number implements Comparable<Short> {
|
|||
/**
|
||||
* Returns the value of this {@code Short} as a {@code float}
|
||||
* after a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public float floatValue() {
|
||||
return (float)value;
|
||||
|
@ -397,7 +397,7 @@ public final class Short extends Number implements Comparable<Short> {
|
|||
/**
|
||||
* Returns the value of this {@code Short} as a {@code double}
|
||||
* after a widening primitive conversion.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public double doubleValue() {
|
||||
return (double)value;
|
||||
|
|
|
@ -2690,21 +2690,21 @@ public final class String
|
|||
|
||||
/**
|
||||
* Returns a string whose value is this string, with all leading
|
||||
* and trailing {@link Character#isWhitespace(int) white space}
|
||||
* and trailing {@linkplain Character#isWhitespace(int) white space}
|
||||
* removed.
|
||||
* <p>
|
||||
* If this {@code String} object represents an empty string,
|
||||
* or if all code points in this string are
|
||||
* {@link Character#isWhitespace(int) white space}, then an empty string
|
||||
* {@linkplain Character#isWhitespace(int) white space}, then an empty string
|
||||
* is returned.
|
||||
* <p>
|
||||
* Otherwise, returns a substring of this string beginning with the first
|
||||
* code point that is not a {@link Character#isWhitespace(int) white space}
|
||||
* code point that is not a {@linkplain Character#isWhitespace(int) white space}
|
||||
* up to and including the last code point that is not a
|
||||
* {@link Character#isWhitespace(int) white space}.
|
||||
* {@linkplain Character#isWhitespace(int) white space}.
|
||||
* <p>
|
||||
* This method may be used to strip
|
||||
* {@link Character#isWhitespace(int) white space} from
|
||||
* {@linkplain Character#isWhitespace(int) white space} from
|
||||
* the beginning and end of a string.
|
||||
*
|
||||
* @return a string whose value is this string, with all leading
|
||||
|
@ -2722,19 +2722,19 @@ public final class String
|
|||
|
||||
/**
|
||||
* Returns a string whose value is this string, with all leading
|
||||
* {@link Character#isWhitespace(int) white space} removed.
|
||||
* {@linkplain Character#isWhitespace(int) white space} removed.
|
||||
* <p>
|
||||
* If this {@code String} object represents an empty string,
|
||||
* or if all code points in this string are
|
||||
* {@link Character#isWhitespace(int) white space}, then an empty string
|
||||
* {@linkplain Character#isWhitespace(int) white space}, then an empty string
|
||||
* is returned.
|
||||
* <p>
|
||||
* Otherwise, returns a substring of this string beginning with the first
|
||||
* code point that is not a {@link Character#isWhitespace(int) white space}
|
||||
* code point that is not a {@linkplain Character#isWhitespace(int) white space}
|
||||
* up to and including the last code point of this string.
|
||||
* <p>
|
||||
* This method may be used to trim
|
||||
* {@link Character#isWhitespace(int) white space} from
|
||||
* {@linkplain Character#isWhitespace(int) white space} from
|
||||
* the beginning of a string.
|
||||
*
|
||||
* @return a string whose value is this string, with all leading white
|
||||
|
@ -2752,19 +2752,19 @@ public final class String
|
|||
|
||||
/**
|
||||
* Returns a string whose value is this string, with all trailing
|
||||
* {@link Character#isWhitespace(int) white space} removed.
|
||||
* {@linkplain Character#isWhitespace(int) white space} removed.
|
||||
* <p>
|
||||
* If this {@code String} object represents an empty string,
|
||||
* or if all characters in this string are
|
||||
* {@link Character#isWhitespace(int) white space}, then an empty string
|
||||
* {@linkplain Character#isWhitespace(int) white space}, then an empty string
|
||||
* is returned.
|
||||
* <p>
|
||||
* Otherwise, returns a substring of this string beginning with the first
|
||||
* code point of this string up to and including the last code point
|
||||
* that is not a {@link Character#isWhitespace(int) white space}.
|
||||
* that is not a {@linkplain Character#isWhitespace(int) white space}.
|
||||
* <p>
|
||||
* This method may be used to trim
|
||||
* {@link Character#isWhitespace(int) white space} from
|
||||
* {@linkplain Character#isWhitespace(int) white space} from
|
||||
* the end of a string.
|
||||
*
|
||||
* @return a string whose value is this string, with all trailing white
|
||||
|
@ -2782,11 +2782,11 @@ public final class String
|
|||
|
||||
/**
|
||||
* Returns {@code true} if the string is empty or contains only
|
||||
* {@link Character#isWhitespace(int) white space} codepoints,
|
||||
* {@linkplain Character#isWhitespace(int) white space} codepoints,
|
||||
* otherwise {@code false}.
|
||||
*
|
||||
* @return {@code true} if the string is empty or contains only
|
||||
* {@link Character#isWhitespace(int) white space} codepoints,
|
||||
* {@linkplain Character#isWhitespace(int) white space} codepoints,
|
||||
* otherwise {@code false}
|
||||
*
|
||||
* @see Character#isWhitespace(int)
|
||||
|
@ -2849,10 +2849,10 @@ public final class String
|
|||
* beginning of each line.
|
||||
* <p>
|
||||
* If {@code n < 0} then up to {@code n}
|
||||
* {@link Character#isWhitespace(int) white space characters} are removed
|
||||
* {@linkplain Character#isWhitespace(int) white space characters} are removed
|
||||
* from the beginning of each line. If a given line does not contain
|
||||
* sufficient white space then all leading
|
||||
* {@link Character#isWhitespace(int) white space characters} are removed.
|
||||
* {@linkplain Character#isWhitespace(int) white space characters} are removed.
|
||||
* Each white space character is treated as a single character. In
|
||||
* particular, the tab character {@code "\t"} (U+0009) is considered a
|
||||
* single character; it is not expanded.
|
||||
|
@ -2861,7 +2861,7 @@ public final class String
|
|||
* terminators are still normalized.
|
||||
*
|
||||
* @param n number of leading
|
||||
* {@link Character#isWhitespace(int) white space characters}
|
||||
* {@linkplain Character#isWhitespace(int) white space characters}
|
||||
* to add or remove
|
||||
*
|
||||
* @return string with indentation adjusted and line endings normalized
|
||||
|
@ -3386,7 +3386,7 @@ public final class String
|
|||
return value;
|
||||
}
|
||||
|
||||
private boolean isLatin1() {
|
||||
boolean isLatin1() {
|
||||
return COMPACT_STRINGS && coder == LATIN1;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.stream.IntStream;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
import static java.lang.String.LATIN1;
|
||||
import static java.lang.String.UTF16;
|
||||
|
@ -42,14 +43,6 @@ import static java.lang.String.checkOffset;
|
|||
|
||||
final class StringLatin1 {
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate (unless necessary).
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
public static char charAt(byte[] value, int index) {
|
||||
if (index < 0 || index >= value.length) {
|
||||
throw new StringIndexOutOfBoundsException(index);
|
||||
|
@ -353,15 +346,7 @@ final class StringLatin1 {
|
|||
i += targLen;
|
||||
while ((j = indexOf(value, valLen, targ, targLen, i)) > 0) {
|
||||
if (++p == pos.length) {
|
||||
int cap = p + (p >> 1);
|
||||
// overflow-conscious code
|
||||
if (cap - MAX_ARRAY_SIZE > 0) {
|
||||
if (p == MAX_ARRAY_SIZE) {
|
||||
throw new OutOfMemoryError();
|
||||
}
|
||||
cap = MAX_ARRAY_SIZE;
|
||||
}
|
||||
pos = Arrays.copyOf(pos, cap);
|
||||
pos = Arrays.copyOf(pos, ArraysSupport.newLength(p, 1, p >> 1));
|
||||
}
|
||||
pos[p] = j;
|
||||
i = j + targLen;
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.function.IntConsumer;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
import jdk.internal.vm.annotation.ForceInline;
|
||||
import jdk.internal.vm.annotation.DontInline;
|
||||
|
||||
|
@ -649,15 +650,7 @@ final class StringUTF16 {
|
|||
: indexOf(value, valLen, targ, targLen, i))) > 0)
|
||||
{
|
||||
if (++p == pos.length) {
|
||||
int cap = p + (p >> 1);
|
||||
// overflow-conscious code
|
||||
if (cap - MAX_ARRAY_SIZE > 0) {
|
||||
if (p == MAX_ARRAY_SIZE) {
|
||||
throw new OutOfMemoryError();
|
||||
}
|
||||
cap = MAX_ARRAY_SIZE;
|
||||
}
|
||||
pos = Arrays.copyOf(pos, cap);
|
||||
pos = Arrays.copyOf(pos, ArraysSupport.newLength(p, 1, p >> 1));
|
||||
}
|
||||
pos[p] = j;
|
||||
i = j + targLen;
|
||||
|
@ -1554,15 +1547,6 @@ final class StringUTF16 {
|
|||
|
||||
static final int MAX_LENGTH = Integer.MAX_VALUE >> 1;
|
||||
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate (unless necessary).
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
// Used by trusted callers. Assumes all necessary bounds checks have
|
||||
// been done by the caller.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2019, 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 static java.lang.annotation.ElementType.*;
|
|||
* @jls 4.8 Raw Types
|
||||
* @jls 4.12.2 Variables of Reference Type
|
||||
* @jls 5.1.9 Unchecked Conversion
|
||||
* @jls 5.5.2 Checked Casts and Unchecked Casts
|
||||
* @jls 5.5 Casting Contexts
|
||||
* @jls 9.6.4.5 @SuppressWarnings
|
||||
*/
|
||||
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, MODULE})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -59,7 +59,7 @@ import java.util.Optional;
|
|||
* method handles, but not necessarily those produced by method handle
|
||||
* combinators.)
|
||||
* @jvms 4.4 The Constant Pool
|
||||
* @jvms 4.4.10 The CONSTANT_InvokeDynamic_info Structure
|
||||
* @jvms 4.4.10 The {@code CONSTANT_Dynamic_info} and {@code CONSTANT_InvokeDynamic_info} Structures
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -97,6 +97,11 @@ public interface ConstantDesc {
|
|||
* @throws ReflectiveOperationException if a class, method, or field
|
||||
* could not be reflectively resolved in the course of resolution
|
||||
* @throws LinkageError if a linkage error occurs
|
||||
*
|
||||
* @apiNote {@linkplain MethodTypeDesc} can represent method type descriptors
|
||||
* that are not representable by {@linkplain MethodType}, such as methods with
|
||||
* more than 255 parameter slots, so attempts to resolve these may result in errors.
|
||||
*
|
||||
* @jvms 5.4.3 Resolution
|
||||
* @jvms 5.4.4 Access Control
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -70,6 +70,8 @@ public interface MethodHandleDesc
|
|||
* for a field or constructor
|
||||
* @return the {@linkplain MethodHandleDesc}
|
||||
* @throws NullPointerException if any of the non-ignored arguments are null
|
||||
* @throws IllegalArgumentException if the descriptor string is not a valid
|
||||
* method or field descriptor
|
||||
* @jvms 4.4.8 The CONSTANT_MethodHandle_info Structure
|
||||
* @jvms 4.2.2 Unqualified Names
|
||||
* @jvms 4.3.2 Field Descriptors
|
||||
|
@ -177,7 +179,7 @@ public interface MethodHandleDesc
|
|||
* @param paramTypes {@link ClassDesc}s describing the parameter types of
|
||||
* the constructor
|
||||
* @return the {@linkplain MethodHandleDesc}
|
||||
* @throws NullPointerException if any of the arguments are null
|
||||
* @throws NullPointerException if any argument or its contents is {@code null}
|
||||
*/
|
||||
static DirectMethodHandleDesc ofConstructor(ClassDesc owner,
|
||||
ClassDesc... paramTypes) {
|
||||
|
@ -191,6 +193,7 @@ public interface MethodHandleDesc
|
|||
*
|
||||
* @param type a {@link MethodHandleDesc} describing the new method type
|
||||
* @return a {@linkplain MethodHandleDesc} for the adapted method handle
|
||||
* @throws NullPointerException if the argument is {@code null}
|
||||
*/
|
||||
default MethodHandleDesc asType(MethodTypeDesc type) {
|
||||
return (invocationType().equals(type)) ? this : new AsTypeMethodHandleDesc(this, type);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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 @@ public interface MethodTypeDesc
|
|||
*
|
||||
* @param descriptor a method descriptor string
|
||||
* @return a {@linkplain MethodTypeDesc} describing the desired method type
|
||||
* @throws NullPointerException if any argument is {@code null}
|
||||
* @throws NullPointerException if the argument is {@code null}
|
||||
* @throws IllegalArgumentException if the descriptor string is not a valid
|
||||
* method descriptor
|
||||
* @jvms 4.3.3 Method Descriptors
|
||||
|
@ -65,7 +65,9 @@ public interface MethodTypeDesc
|
|||
* @param returnDesc a {@linkplain ClassDesc} describing the return type
|
||||
* @param paramDescs {@linkplain ClassDesc}s describing the argument types
|
||||
* @return a {@linkplain MethodTypeDesc} describing the desired method type
|
||||
* @throws NullPointerException if any argument is {@code null}
|
||||
* @throws NullPointerException if any argument or its contents are {@code null}
|
||||
* @throws IllegalArgumentException if any element of {@code paramDescs} is a
|
||||
* {@link ClassDesc} for {@code void}
|
||||
*/
|
||||
static MethodTypeDesc of(ClassDesc returnDesc, ClassDesc... paramDescs) {
|
||||
return new MethodTypeDescImpl(returnDesc, paramDescs);
|
||||
|
@ -116,7 +118,7 @@ public interface MethodTypeDesc
|
|||
*
|
||||
* @param returnType a {@link ClassDesc} describing the new return type
|
||||
* @return a {@linkplain MethodTypeDesc} describing the desired method type
|
||||
* @throws NullPointerException if any argument is {@code null}
|
||||
* @throws NullPointerException if the argument is {@code null}
|
||||
*/
|
||||
MethodTypeDesc changeReturnType(ClassDesc returnType);
|
||||
|
||||
|
@ -141,8 +143,8 @@ public interface MethodTypeDesc
|
|||
* @param end the index after the last parameter to remove
|
||||
* @return a {@linkplain MethodTypeDesc} describing the desired method type
|
||||
* @throws IndexOutOfBoundsException if {@code start} is outside the half-open
|
||||
* range {[0, parameterCount)}, or {@code end} is outside the closed range
|
||||
* {@code [0, parameterCount]}
|
||||
* range {@code [0, parameterCount)}, or {@code end} is outside the closed range
|
||||
* {@code [0, parameterCount]}, or if {@code start > end}
|
||||
*/
|
||||
MethodTypeDesc dropParameterTypes(int start, int end);
|
||||
|
||||
|
@ -154,9 +156,11 @@ public interface MethodTypeDesc
|
|||
* @param paramTypes {@link ClassDesc}s describing the new parameter types
|
||||
* to insert
|
||||
* @return a {@linkplain MethodTypeDesc} describing the desired method type
|
||||
* @throws NullPointerException if any argument is {@code null}
|
||||
* @throws NullPointerException if any argument or its contents are {@code null}
|
||||
* @throws IndexOutOfBoundsException if {@code pos} is outside the closed
|
||||
* range {[0, parameterCount]}
|
||||
* @throws IllegalArgumentException if any element of {@code paramTypes}
|
||||
* is a {@link ClassDesc} for {@code void}
|
||||
*/
|
||||
MethodTypeDesc insertParameterTypes(int pos, ClassDesc... paramTypes);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -111,10 +111,8 @@ final class MethodTypeDescImpl implements MethodTypeDesc {
|
|||
|
||||
@Override
|
||||
public MethodTypeDesc dropParameterTypes(int start, int end) {
|
||||
if (start < 0 || start >= argTypes.length || end < 0 || end > argTypes.length)
|
||||
if (start < 0 || start >= argTypes.length || end < 0 || end > argTypes.length || start > end)
|
||||
throw new IndexOutOfBoundsException();
|
||||
else if (start > end)
|
||||
throw new IllegalArgumentException(String.format("Range (%d, %d) not valid for size %d", start, end, argTypes.length));
|
||||
ClassDesc[] newArgs = new ClassDesc[argTypes.length - (end - start)];
|
||||
System.arraycopy(argTypes, 0, newArgs, 0, start);
|
||||
System.arraycopy(argTypes, end, newArgs, start, argTypes.length - end);
|
||||
|
|
|
@ -4980,8 +4980,10 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
|||
|
||||
// Step 1C: determine loop return type.
|
||||
// Step 1D: check other types.
|
||||
final Class<?> loopReturnType = fini.stream().filter(Objects::nonNull).map(MethodHandle::type).
|
||||
map(MethodType::returnType).findFirst().orElse(void.class);
|
||||
// local variable required here; see JDK-8223553
|
||||
Stream<Class<?>> cstream = fini.stream().filter(Objects::nonNull).map(MethodHandle::type)
|
||||
.map(MethodType::returnType);
|
||||
final Class<?> loopReturnType = cstream.findFirst().orElse(void.class);
|
||||
loopChecks1cd(pred, fini, loopReturnType);
|
||||
|
||||
// Step 2: determine parameter lists.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, 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
|
||||
|
@ -403,7 +403,7 @@ public final class Method extends Executable {
|
|||
* @return a string describing this {@code Method}
|
||||
*
|
||||
* @jls 8.4.3 Method Modifiers
|
||||
* @jls 9.4 Method Declarations
|
||||
* @jls 9.4 Method Declarations
|
||||
* @jls 9.6.1 Annotation Type Elements
|
||||
*/
|
||||
public String toString() {
|
||||
|
@ -474,7 +474,7 @@ public final class Method extends Executable {
|
|||
* @since 1.5
|
||||
*
|
||||
* @jls 8.4.3 Method Modifiers
|
||||
* @jls 9.4 Method Declarations
|
||||
* @jls 9.4 Method Declarations
|
||||
* @jls 9.6.1 Annotation Type Elements
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, 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
|
||||
|
@ -394,7 +394,7 @@ public class Modifier {
|
|||
|
||||
/**
|
||||
* The Java source modifiers that can be applied to a field.
|
||||
* @jls 8.3.1 Field Modifiers
|
||||
* @jls 8.3.1 Field Modifiers
|
||||
*/
|
||||
private static final int FIELD_MODIFIERS =
|
||||
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, 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 @@ import java.io.FileDescriptor;
|
|||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.net.ResourceManager;
|
||||
import sun.net.ext.ExtendedSocketOptions;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
|
@ -87,26 +89,6 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
return isReusePortAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of SocketOptions supported by this impl and by this impl's
|
||||
* socket (Socket or ServerSocket)
|
||||
*
|
||||
* @return a Set of SocketOptions
|
||||
*/
|
||||
@Override
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
Set<SocketOption<?>> options;
|
||||
if (isReusePortAvailable()) {
|
||||
options = new HashSet<>();
|
||||
options.addAll(super.supportedOptions());
|
||||
options.add(StandardSocketOptions.SO_REUSEPORT);
|
||||
options = Collections.unmodifiableSet(options);
|
||||
} else {
|
||||
options = super.supportedOptions();
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a datagram socket
|
||||
*/
|
||||
|
@ -400,6 +382,125 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
return result;
|
||||
}
|
||||
|
||||
static final ExtendedSocketOptions extendedOptions =
|
||||
ExtendedSocketOptions.getInstance();
|
||||
|
||||
private static final Set<SocketOption<?>> datagramSocketOptions = datagramSocketOptions();
|
||||
private static final Set<SocketOption<?>> multicastSocketOptions = multicastSocketOptions();
|
||||
|
||||
private static Set<SocketOption<?>> datagramSocketOptions() {
|
||||
HashSet<SocketOption<?>> options = new HashSet<>();
|
||||
options.add(StandardSocketOptions.SO_SNDBUF);
|
||||
options.add(StandardSocketOptions.SO_RCVBUF);
|
||||
options.add(StandardSocketOptions.SO_REUSEADDR);
|
||||
options.add(StandardSocketOptions.IP_TOS);
|
||||
if (isReusePortAvailable())
|
||||
options.add(StandardSocketOptions.SO_REUSEPORT);
|
||||
options.addAll(ExtendedSocketOptions.datagramSocketOptions());
|
||||
return Collections.unmodifiableSet(options);
|
||||
}
|
||||
|
||||
private static Set<SocketOption<?>> multicastSocketOptions() {
|
||||
HashSet<SocketOption<?>> options = new HashSet<>();
|
||||
options.add(StandardSocketOptions.SO_SNDBUF);
|
||||
options.add(StandardSocketOptions.SO_RCVBUF);
|
||||
options.add(StandardSocketOptions.SO_REUSEADDR);
|
||||
options.add(StandardSocketOptions.IP_TOS);
|
||||
options.add(StandardSocketOptions.IP_MULTICAST_IF);
|
||||
options.add(StandardSocketOptions.IP_MULTICAST_TTL);
|
||||
options.add(StandardSocketOptions.IP_MULTICAST_LOOP);
|
||||
if (isReusePortAvailable())
|
||||
options.add(StandardSocketOptions.SO_REUSEPORT);
|
||||
options.addAll(ExtendedSocketOptions.datagramSocketOptions());
|
||||
return Collections.unmodifiableSet(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
if (getDatagramSocket() instanceof MulticastSocket)
|
||||
return multicastSocketOptions;
|
||||
else
|
||||
return datagramSocketOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
if (!name.type().isInstance(value))
|
||||
throw new IllegalArgumentException("Invalid value '" + value + "'");
|
||||
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
if (name == StandardSocketOptions.SO_SNDBUF) {
|
||||
if (((Integer)value).intValue() < 0)
|
||||
throw new IllegalArgumentException("Invalid send buffer size:" + value);
|
||||
setOption(SocketOptions.SO_SNDBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
if (((Integer)value).intValue() < 0)
|
||||
throw new IllegalArgumentException("Invalid recv buffer size:" + value);
|
||||
setOption(SocketOptions.SO_RCVBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
setOption(SocketOptions.SO_REUSEADDR, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEPORT) {
|
||||
setOption(SocketOptions.SO_REUSEPORT, value);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
int i = ((Integer)value).intValue();
|
||||
if (i < 0 || i > 255)
|
||||
throw new IllegalArgumentException("Invalid IP_TOS value: " + value);
|
||||
setOption(SocketOptions.IP_TOS, value);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_IF ) {
|
||||
setOption(SocketOptions.IP_MULTICAST_IF2, value);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_TTL) {
|
||||
int i = ((Integer)value).intValue();
|
||||
if (i < 0 || i > 255)
|
||||
throw new IllegalArgumentException("Invalid TTL/hop value: " + value);
|
||||
setTimeToLive((Integer)value);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_LOOP) {
|
||||
setOption(SocketOptions.IP_MULTICAST_LOOP, value);
|
||||
} else if (extendedOptions.isOptionSupported(name)) {
|
||||
extendedOptions.setOption(fd, name, value);
|
||||
} else {
|
||||
throw new AssertionError("unknown option :" + name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T getOption(SocketOption<T> name) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
if (name == StandardSocketOptions.SO_SNDBUF) {
|
||||
return (T) getOption(SocketOptions.SO_SNDBUF);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
return (T) getOption(SocketOptions.SO_RCVBUF);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
return (T) getOption(SocketOptions.SO_REUSEADDR);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEPORT) {
|
||||
return (T) getOption(SocketOptions.SO_REUSEPORT);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
return (T) getOption(SocketOptions.IP_TOS);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_IF) {
|
||||
return (T) getOption(SocketOptions.IP_MULTICAST_IF2);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_TTL) {
|
||||
return (T) ((Integer) getTimeToLive());
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_LOOP) {
|
||||
return (T) getOption(SocketOptions.IP_MULTICAST_LOOP);
|
||||
} else if (extendedOptions.isOptionSupported(name)) {
|
||||
return (T) extendedOptions.getOption(fd, name);
|
||||
} else {
|
||||
throw new AssertionError("unknown option: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void datagramSocketCreate() throws SocketException;
|
||||
protected abstract void datagramSocketClose();
|
||||
protected abstract void socketSetOption(int opt, Object val)
|
||||
|
|
|
@ -35,12 +35,14 @@ import java.security.PrivilegedActionException;
|
|||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.net.ConnectionResetException;
|
||||
import sun.net.NetHooks;
|
||||
import sun.net.PlatformSocketImpl;
|
||||
import sun.net.ResourceManager;
|
||||
import sun.net.ext.ExtendedSocketOptions;
|
||||
import sun.net.util.SocketExceptions;
|
||||
|
||||
/**
|
||||
|
@ -84,6 +86,9 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
*/
|
||||
protected boolean stream;
|
||||
|
||||
/* whether this is a server or not */
|
||||
final boolean isServer;
|
||||
|
||||
/**
|
||||
* Load net library into runtime.
|
||||
*/
|
||||
|
@ -112,27 +117,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
}
|
||||
|
||||
AbstractPlainSocketImpl(boolean isServer) {
|
||||
super(isServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of SocketOptions supported by this impl and by this impl's
|
||||
* socket (Socket or ServerSocket)
|
||||
*
|
||||
* @return a Set of SocketOptions
|
||||
*/
|
||||
@Override
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
Set<SocketOption<?>> options;
|
||||
if (isReusePortAvailable()) {
|
||||
options = new HashSet<>();
|
||||
options.addAll(super.supportedOptions());
|
||||
options.add(StandardSocketOptions.SO_REUSEPORT);
|
||||
options = Collections.unmodifiableSet(options);
|
||||
} else {
|
||||
options = super.supportedOptions();
|
||||
}
|
||||
return options;
|
||||
this.isServer = isServer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -394,6 +379,121 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
|
|||
}
|
||||
}
|
||||
|
||||
static final ExtendedSocketOptions extendedOptions =
|
||||
ExtendedSocketOptions.getInstance();
|
||||
|
||||
private static final Set<SocketOption<?>> clientSocketOptions = clientSocketOptions();
|
||||
private static final Set<SocketOption<?>> serverSocketOptions = serverSocketOptions();
|
||||
|
||||
private static Set<SocketOption<?>> clientSocketOptions() {
|
||||
HashSet<SocketOption<?>> options = new HashSet<>();
|
||||
options.add(StandardSocketOptions.SO_KEEPALIVE);
|
||||
options.add(StandardSocketOptions.SO_SNDBUF);
|
||||
options.add(StandardSocketOptions.SO_RCVBUF);
|
||||
options.add(StandardSocketOptions.SO_REUSEADDR);
|
||||
options.add(StandardSocketOptions.SO_LINGER);
|
||||
options.add(StandardSocketOptions.IP_TOS);
|
||||
options.add(StandardSocketOptions.TCP_NODELAY);
|
||||
if (isReusePortAvailable())
|
||||
options.add(StandardSocketOptions.SO_REUSEPORT);
|
||||
options.addAll(ExtendedSocketOptions.clientSocketOptions());
|
||||
return Collections.unmodifiableSet(options);
|
||||
}
|
||||
|
||||
private static Set<SocketOption<?>> serverSocketOptions() {
|
||||
HashSet<SocketOption<?>> options = new HashSet<>();
|
||||
options.add(StandardSocketOptions.SO_RCVBUF);
|
||||
options.add(StandardSocketOptions.SO_REUSEADDR);
|
||||
options.add(StandardSocketOptions.IP_TOS);
|
||||
if (isReusePortAvailable())
|
||||
options.add(StandardSocketOptions.SO_REUSEPORT);
|
||||
options.addAll(ExtendedSocketOptions.serverSocketOptions());
|
||||
return Collections.unmodifiableSet(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
if (isServer)
|
||||
return serverSocketOptions;
|
||||
else
|
||||
return clientSocketOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
if (!name.type().isInstance(value))
|
||||
throw new IllegalArgumentException("Invalid value '" + value + "'");
|
||||
|
||||
if (isClosedOrPending())
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
if (name == StandardSocketOptions.SO_KEEPALIVE) {
|
||||
setOption(SocketOptions.SO_KEEPALIVE, value);
|
||||
} else if (name == StandardSocketOptions.SO_SNDBUF) {
|
||||
if (((Integer)value).intValue() < 0)
|
||||
throw new IllegalArgumentException("Invalid send buffer size:" + value);
|
||||
setOption(SocketOptions.SO_SNDBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
if (((Integer)value).intValue() < 0)
|
||||
throw new IllegalArgumentException("Invalid recv buffer size:" + value);
|
||||
setOption(SocketOptions.SO_RCVBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
setOption(SocketOptions.SO_REUSEADDR, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEPORT) {
|
||||
setOption(SocketOptions.SO_REUSEPORT, value);
|
||||
} else if (name == StandardSocketOptions.SO_LINGER ) {
|
||||
setOption(SocketOptions.SO_LINGER, value);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
int i = ((Integer)value).intValue();
|
||||
if (i < 0 || i > 255)
|
||||
throw new IllegalArgumentException("Invalid IP_TOS value: " + value);
|
||||
setOption(SocketOptions.IP_TOS, value);
|
||||
} else if (name == StandardSocketOptions.TCP_NODELAY) {
|
||||
setOption(SocketOptions.TCP_NODELAY, value);
|
||||
} else if (extendedOptions.isOptionSupported(name)) {
|
||||
extendedOptions.setOption(fd, name, value);
|
||||
} else {
|
||||
throw new AssertionError("unknown option: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T getOption(SocketOption<T> name) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
if (isClosedOrPending())
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
if (name == StandardSocketOptions.SO_KEEPALIVE) {
|
||||
return (T)getOption(SocketOptions.SO_KEEPALIVE);
|
||||
} else if (name == StandardSocketOptions.SO_SNDBUF) {
|
||||
return (T)getOption(SocketOptions.SO_SNDBUF);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
return (T)getOption(SocketOptions.SO_RCVBUF);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
return (T)getOption(SocketOptions.SO_REUSEADDR);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEPORT) {
|
||||
return (T)getOption(SocketOptions.SO_REUSEPORT);
|
||||
} else if (name == StandardSocketOptions.SO_LINGER) {
|
||||
return (T)getOption(SocketOptions.SO_LINGER);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
return (T)getOption(SocketOptions.IP_TOS);
|
||||
} else if (name == StandardSocketOptions.TCP_NODELAY) {
|
||||
return (T)getOption(SocketOptions.TCP_NODELAY);
|
||||
} else if (extendedOptions.isOptionSupported(name)) {
|
||||
return (T) extendedOptions.getOption(fd, name);
|
||||
} else {
|
||||
throw new AssertionError("unknown option: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The workhorse of the connection operation. Tries several times to
|
||||
* establish a connection to the given <host, port>. If unsuccessful,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2019, 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
|
||||
|
@ -29,6 +29,7 @@ import java.io.IOException;
|
|||
import java.nio.channels.DatagramChannel;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -1343,6 +1344,9 @@ class DatagramSocket implements java.io.Closeable {
|
|||
public <T> DatagramSocket setOption(SocketOption<T> name, T value)
|
||||
throws IOException
|
||||
{
|
||||
Objects.requireNonNull(name);
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket is closed");
|
||||
getImpl().setOption(name, value);
|
||||
return this;
|
||||
}
|
||||
|
@ -1371,6 +1375,9 @@ class DatagramSocket implements java.io.Closeable {
|
|||
* @since 9
|
||||
*/
|
||||
public <T> T getOption(SocketOption<T> name) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket is closed");
|
||||
return getImpl().getOption(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, 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
|
||||
|
@ -27,6 +27,7 @@ package java.net;
|
|||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -265,123 +266,69 @@ public abstract class DatagramSocketImpl implements SocketOptions {
|
|||
/**
|
||||
* Called to set a socket option.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method first checks that the given
|
||||
* socket option {code name} is not null, then throws {@code
|
||||
* UnsupportedOperationException}. Subclasses should override this method
|
||||
* with an appropriate implementation.
|
||||
*
|
||||
* @param <T> The type of the socket option value
|
||||
* @param name The socket option
|
||||
*
|
||||
* @param value The value of the socket option. A value of {@code null}
|
||||
* may be valid for some options.
|
||||
*
|
||||
* @throws UnsupportedOperationException if the DatagramSocketImpl does not
|
||||
* support the option
|
||||
*
|
||||
* @throws IllegalArgumentException if the value is not valid for
|
||||
* the option
|
||||
* @throws IOException if an I/O error occurs, or if the socket is closed
|
||||
* @throws NullPointerException if name is {@code null}
|
||||
* @throws IOException if an I/O problem occurs while attempting to set the option
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
|
||||
if (name == StandardSocketOptions.SO_SNDBUF) {
|
||||
setOption(SocketOptions.SO_SNDBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
setOption(SocketOptions.SO_RCVBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
setOption(SocketOptions.SO_REUSEADDR, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEPORT &&
|
||||
supportedOptions().contains(name)) {
|
||||
setOption(SocketOptions.SO_REUSEPORT, value);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
setOption(SocketOptions.IP_TOS, value);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_IF &&
|
||||
(getDatagramSocket() instanceof MulticastSocket)) {
|
||||
setOption(SocketOptions.IP_MULTICAST_IF2, value);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_TTL &&
|
||||
(getDatagramSocket() instanceof MulticastSocket)) {
|
||||
if (! (value instanceof Integer)) {
|
||||
throw new IllegalArgumentException("not an integer");
|
||||
}
|
||||
setTimeToLive((Integer)value);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_LOOP &&
|
||||
(getDatagramSocket() instanceof MulticastSocket)) {
|
||||
setOption(SocketOptions.IP_MULTICAST_LOOP, value);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
Objects.requireNonNull(name);
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to get a socket option.
|
||||
*
|
||||
* @return the socket option
|
||||
* @implSpec
|
||||
* The default implementation of this method first checks that the given
|
||||
* socket option {code name} is not null, then throws {@code
|
||||
* UnsupportedOperationException}. Subclasses should override this method
|
||||
* with an appropriate implementation.
|
||||
*
|
||||
* @param <T> The type of the socket option value
|
||||
* @param name The socket option
|
||||
* @return the socket option
|
||||
*
|
||||
* @throws UnsupportedOperationException if the DatagramSocketImpl does not
|
||||
* support the option
|
||||
*
|
||||
* @throws IOException if an I/O error occurs, or if the socket is closed
|
||||
* @throws NullPointerException if name is {@code null}
|
||||
* @throws IOException if an I/O problem occurs while attempting to set the option
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T getOption(SocketOption<T> name) throws IOException {
|
||||
if (name == StandardSocketOptions.SO_SNDBUF) {
|
||||
return (T) getOption(SocketOptions.SO_SNDBUF);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
return (T) getOption(SocketOptions.SO_RCVBUF);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
return (T) getOption(SocketOptions.SO_REUSEADDR);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEPORT &&
|
||||
supportedOptions().contains(name)) {
|
||||
return (T) getOption(SocketOptions.SO_REUSEPORT);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
return (T) getOption(SocketOptions.IP_TOS);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_IF &&
|
||||
(getDatagramSocket() instanceof MulticastSocket)) {
|
||||
return (T) getOption(SocketOptions.IP_MULTICAST_IF2);
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_TTL &&
|
||||
(getDatagramSocket() instanceof MulticastSocket)) {
|
||||
Integer ttl = getTimeToLive();
|
||||
return (T)ttl;
|
||||
} else if (name == StandardSocketOptions.IP_MULTICAST_LOOP &&
|
||||
(getDatagramSocket() instanceof MulticastSocket)) {
|
||||
return (T) getOption(SocketOptions.IP_MULTICAST_LOOP);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
}
|
||||
|
||||
private static final Set<SocketOption<?>> dgSocketOptions;
|
||||
|
||||
private static final Set<SocketOption<?>> mcSocketOptions;
|
||||
|
||||
static {
|
||||
dgSocketOptions = Set.of(StandardSocketOptions.SO_SNDBUF,
|
||||
StandardSocketOptions.SO_RCVBUF,
|
||||
StandardSocketOptions.SO_REUSEADDR,
|
||||
StandardSocketOptions.IP_TOS);
|
||||
|
||||
mcSocketOptions = Set.of(StandardSocketOptions.SO_SNDBUF,
|
||||
StandardSocketOptions.SO_RCVBUF,
|
||||
StandardSocketOptions.SO_REUSEADDR,
|
||||
StandardSocketOptions.IP_TOS,
|
||||
StandardSocketOptions.IP_MULTICAST_IF,
|
||||
StandardSocketOptions.IP_MULTICAST_TTL,
|
||||
StandardSocketOptions.IP_MULTICAST_LOOP);
|
||||
Objects.requireNonNull(name);
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of SocketOptions supported by this impl
|
||||
* and by this impl's socket (DatagramSocket or MulticastSocket)
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method returns an empty set.
|
||||
* Subclasses should override this method with an appropriate implementation.
|
||||
*
|
||||
* @return a Set of SocketOptions
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
if (getDatagramSocket() instanceof MulticastSocket) {
|
||||
return mcSocketOptions;
|
||||
} else {
|
||||
return dgSocketOptions;
|
||||
}
|
||||
return Set.of();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,13 @@ import static java.net.InetAddress.PREFER_SYSTEM_VALUE;
|
|||
* Package private implementation of InetAddressImpl for dual
|
||||
* IPv4/IPv6 stack.
|
||||
* <p>
|
||||
* If InetAddress.preferIPv6Address is true then anyLocalAddress(),
|
||||
* loopbackAddress(), and localHost() will return IPv6 addresses,
|
||||
* otherwise IPv4 addresses.
|
||||
* If InetAddress.preferIPv6Address is true then anyLocalAddress()
|
||||
* and localHost() will return IPv6 addresses, otherwise IPv4 addresses.
|
||||
*
|
||||
* loopbackAddress() will return the first valid loopback address in
|
||||
* [IPv6 loopback, IPv4 loopback] if InetAddress.preferIPv6Address is true,
|
||||
* else [IPv4 loopback, IPv6 loopback].
|
||||
* If neither are valid it will fallback to the first address tried.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
@ -103,15 +107,31 @@ class Inet6AddressImpl implements InetAddressImpl {
|
|||
|
||||
public synchronized InetAddress loopbackAddress() {
|
||||
if (loopbackAddress == null) {
|
||||
if (InetAddress.preferIPv6Address == PREFER_IPV6_VALUE ||
|
||||
InetAddress.preferIPv6Address == PREFER_SYSTEM_VALUE) {
|
||||
byte[] loopback =
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
|
||||
loopbackAddress = new Inet6Address("localhost", loopback);
|
||||
} else {
|
||||
loopbackAddress = (new Inet4AddressImpl()).loopbackAddress();
|
||||
}
|
||||
boolean preferIPv6Address =
|
||||
InetAddress.preferIPv6Address == PREFER_IPV6_VALUE ||
|
||||
InetAddress.preferIPv6Address == PREFER_SYSTEM_VALUE;
|
||||
InetAddress loopback4 = (new Inet4AddressImpl()).loopbackAddress();
|
||||
InetAddress loopback6 = new Inet6Address("localhost",
|
||||
new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01});
|
||||
// Order the candidate addresses by preference.
|
||||
InetAddress[] addresses = preferIPv6Address
|
||||
? new InetAddress[] {loopback6, loopback4}
|
||||
: new InetAddress[] {loopback4, loopback6};
|
||||
// In case of failure, default to the preferred address.
|
||||
loopbackAddress = addresses[0];
|
||||
// Pick the first candidate address that actually exists.
|
||||
for (InetAddress address : addresses) {
|
||||
try {
|
||||
if (NetworkInterface.getByInetAddress(address) == null) {
|
||||
continue;
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
continue;
|
||||
}
|
||||
loopbackAddress = address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return loopbackAddress;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.Arrays;
|
||||
|
||||
import jdk.internal.access.JavaNetInetAddressAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
|
@ -989,29 +990,28 @@ class InetAddress implements java.io.Serializable {
|
|||
String hostEntry;
|
||||
String host = null;
|
||||
|
||||
String addrString = addrToString(addr);
|
||||
try (Scanner hostsFileScanner = new Scanner(new File(hostsFile), "UTF-8")) {
|
||||
while (hostsFileScanner.hasNextLine()) {
|
||||
hostEntry = hostsFileScanner.nextLine();
|
||||
if (!hostEntry.startsWith("#")) {
|
||||
hostEntry = removeComments(hostEntry);
|
||||
if (hostEntry.contains(addrString)) {
|
||||
host = extractHost(hostEntry, addrString);
|
||||
if (host != null) {
|
||||
break;
|
||||
}
|
||||
String[] mapping = hostEntry.split("\\s+");
|
||||
if (mapping.length >= 2 &&
|
||||
Arrays.equals(addr, createAddressByteArray(mapping[0]))) {
|
||||
host = mapping[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new UnknownHostException("Unable to resolve address "
|
||||
+ addrString + " as hosts file " + hostsFile
|
||||
+ Arrays.toString(addr) + " as hosts file " + hostsFile
|
||||
+ " not found ");
|
||||
}
|
||||
|
||||
if ((host == null) || (host.isEmpty()) || (host.equals(" "))) {
|
||||
throw new UnknownHostException("Requested address "
|
||||
+ addrString
|
||||
+ Arrays.toString(addr)
|
||||
+ " resolves to an invalid entry in hosts file "
|
||||
+ hostsFile);
|
||||
}
|
||||
|
@ -1107,22 +1107,6 @@ class InetAddress implements java.io.Serializable {
|
|||
}
|
||||
return hostAddr;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address to host mapping
|
||||
* use first host alias in list
|
||||
*/
|
||||
private String extractHost(String hostEntry, String addrString) {
|
||||
String[] mapping = hostEntry.split("\\s+");
|
||||
String host = null;
|
||||
|
||||
if (mapping.length >= 2) {
|
||||
if (mapping[0].equalsIgnoreCase(addrString)) {
|
||||
host = mapping[1];
|
||||
}
|
||||
}
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
||||
static final InetAddressImpl impl;
|
||||
|
|
|
@ -817,7 +817,8 @@ class ServerSocket implements java.io.Closeable {
|
|||
* Returns the implementation address and implementation port of
|
||||
* this socket as a {@code String}.
|
||||
* <p>
|
||||
* If there is a security manager set, its {@code checkConnect} method is
|
||||
* If there is a security manager set, and this socket is
|
||||
* {@linkplain #isBound bound}, its {@code checkConnect} method is
|
||||
* called with the local address and {@code -1} as its arguments to see
|
||||
* if the operation is allowed. If the operation is not allowed,
|
||||
* an {@code InetAddress} representing the
|
||||
|
@ -831,7 +832,7 @@ class ServerSocket implements java.io.Closeable {
|
|||
return "ServerSocket[unbound]";
|
||||
InetAddress in;
|
||||
if (System.getSecurityManager() != null)
|
||||
in = InetAddress.getLoopbackAddress();
|
||||
in = getInetAddress();
|
||||
else
|
||||
in = impl.getInetAddress();
|
||||
return "ServerSocket[addr=" + in +
|
||||
|
@ -1025,6 +1026,9 @@ class ServerSocket implements java.io.Closeable {
|
|||
public <T> ServerSocket setOption(SocketOption<T> name, T value)
|
||||
throws IOException
|
||||
{
|
||||
Objects.requireNonNull(name);
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket is closed");
|
||||
getImpl().setOption(name, value);
|
||||
return this;
|
||||
}
|
||||
|
@ -1053,6 +1057,9 @@ class ServerSocket implements java.io.Closeable {
|
|||
* @since 9
|
||||
*/
|
||||
public <T> T getOption(SocketOption<T> name) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket is closed");
|
||||
return getImpl().getOption(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.lang.invoke.VarHandle;
|
|||
import java.nio.channels.SocketChannel;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -1786,6 +1787,9 @@ class Socket implements java.io.Closeable {
|
|||
* @since 9
|
||||
*/
|
||||
public <T> Socket setOption(SocketOption<T> name, T value) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket is closed");
|
||||
getImpl().setOption(name, value);
|
||||
return this;
|
||||
}
|
||||
|
@ -1815,6 +1819,9 @@ class Socket implements java.io.Closeable {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getOption(SocketOption<T> name) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
if (isClosed())
|
||||
throw new SocketException("Socket is closed");
|
||||
return getImpl().getOption(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,33 +25,63 @@
|
|||
|
||||
package java.net;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.FileDescriptor;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.net.NetProperties;
|
||||
import sun.net.PlatformSocketImpl;
|
||||
import sun.nio.ch.NioSocketImpl;
|
||||
|
||||
/**
|
||||
* The abstract class {@code SocketImpl} is a common superclass
|
||||
* of all classes that actually implement sockets. It is used to
|
||||
* create both client and server sockets.
|
||||
* <p>
|
||||
* A "plain" socket implements these methods exactly as
|
||||
* described, without attempting to go through a firewall or proxy.
|
||||
*
|
||||
* @implNote Client and server sockets created with the {@code Socket} and
|
||||
* {@code SocketServer} public constructors create a system-default
|
||||
* {@code SocketImpl}. The JDK historically used a {@code SocketImpl}
|
||||
* implementation type named "PlainSocketImpl" that has since been replaced by a
|
||||
* newer implementation. The JDK continues to ship with the older implementation
|
||||
* to allow code to run that depends on unspecified behavior that differs between
|
||||
* the old and new implementations. The old implementation will be used if the
|
||||
* Java virtual machine is started with the system property {@systemProperty
|
||||
* jdk.net.usePlainSocketImpl} set to use the old implementation. It may also be
|
||||
* set in the JDK's network configuration file, located in {@code
|
||||
* ${java.home}/conf/net.properties}. The value of the property is the string
|
||||
* representation of a boolean. If set without a value then it defaults to {@code
|
||||
* true}, hence running with {@code -Djdk.net.usePlainSocketImpl} or {@code
|
||||
* -Djdk.net.usePlainSocketImpl=true} will configure the Java virtual machine
|
||||
* to use the old implementation. The property and old implementation will be
|
||||
* removed in a future version.
|
||||
*
|
||||
* @author unascribed
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class SocketImpl implements SocketOptions {
|
||||
private static final boolean USE_PLAINSOCKETIMPL = usePlainSocketImpl();
|
||||
|
||||
private static boolean usePlainSocketImpl() {
|
||||
PrivilegedAction<String> pa = () -> NetProperties.get("jdk.net.usePlainSocketImpl");
|
||||
String s = AccessController.doPrivileged(pa);
|
||||
return (s != null) && !s.equalsIgnoreCase("false");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of platform's SocketImpl
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static <S extends SocketImpl & PlatformSocketImpl> S createPlatformSocketImpl(boolean server) {
|
||||
return (S) new PlainSocketImpl(server);
|
||||
if (USE_PLAINSOCKETIMPL) {
|
||||
return (S) new PlainSocketImpl(server);
|
||||
} else {
|
||||
return (S) new NioSocketImpl(server);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,22 +104,10 @@ public abstract class SocketImpl implements SocketOptions {
|
|||
*/
|
||||
protected int localport;
|
||||
|
||||
/**
|
||||
* Whether this is a server or not.
|
||||
*/
|
||||
final boolean isServer;
|
||||
|
||||
|
||||
SocketImpl(boolean isServer) {
|
||||
this.isServer = isServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new instance of this class
|
||||
*/
|
||||
public SocketImpl() {
|
||||
this.isServer = false;
|
||||
}
|
||||
public SocketImpl() { }
|
||||
|
||||
/**
|
||||
* Creates either a stream or a datagram socket.
|
||||
|
@ -376,79 +394,54 @@ public abstract class SocketImpl implements SocketOptions {
|
|||
/**
|
||||
* Called to set a socket option.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method first checks that the given
|
||||
* socket option {code name} is not null, then throws {@code
|
||||
* UnsupportedOperationException}. Subclasses should override this method
|
||||
* with an appropriate implementation.
|
||||
*
|
||||
* @param <T> The type of the socket option value
|
||||
* @param name The socket option
|
||||
*
|
||||
* @param value The value of the socket option. A value of {@code null}
|
||||
* may be valid for some options.
|
||||
*
|
||||
* @throws UnsupportedOperationException if the SocketImpl does not
|
||||
* support the option
|
||||
*
|
||||
* @throws IOException if an I/O error occurs, or if the socket is closed.
|
||||
* @throws IllegalArgumentException if the value is not valid for
|
||||
* the option
|
||||
* @throws IOException if an I/O error occurs, or if the socket is closed
|
||||
* @throws NullPointerException if name is {@code null}
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
|
||||
if (name == StandardSocketOptions.SO_KEEPALIVE && !isServer) {
|
||||
setOption(SocketOptions.SO_KEEPALIVE, value);
|
||||
} else if (name == StandardSocketOptions.SO_SNDBUF && !isServer) {
|
||||
setOption(SocketOptions.SO_SNDBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
setOption(SocketOptions.SO_RCVBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
setOption(SocketOptions.SO_REUSEADDR, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEPORT &&
|
||||
supportedOptions().contains(name)) {
|
||||
setOption(SocketOptions.SO_REUSEPORT, value);
|
||||
} else if (name == StandardSocketOptions.SO_LINGER && !isServer) {
|
||||
setOption(SocketOptions.SO_LINGER, value);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
setOption(SocketOptions.IP_TOS, value);
|
||||
} else if (name == StandardSocketOptions.TCP_NODELAY && !isServer) {
|
||||
setOption(SocketOptions.TCP_NODELAY, value);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
Objects.requireNonNull(name);
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to get a socket option.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method first checks that the given
|
||||
* socket option {code name} is not null, then throws {@code
|
||||
* UnsupportedOperationException}. Subclasses should override this method
|
||||
* with an appropriate implementation.
|
||||
*
|
||||
* @param <T> The type of the socket option value
|
||||
* @param name The socket option
|
||||
*
|
||||
* @return the value of the named option
|
||||
*
|
||||
* @throws UnsupportedOperationException if the SocketImpl does not
|
||||
* support the option.
|
||||
*
|
||||
* @throws IOException if an I/O error occurs, or if the socket is closed.
|
||||
* support the option
|
||||
* @throws IOException if an I/O error occurs, or if the socket is closed
|
||||
* @throws NullPointerException if name is {@code null}
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T getOption(SocketOption<T> name) throws IOException {
|
||||
if (name == StandardSocketOptions.SO_KEEPALIVE && !isServer) {
|
||||
return (T)getOption(SocketOptions.SO_KEEPALIVE);
|
||||
} else if (name == StandardSocketOptions.SO_SNDBUF && !isServer) {
|
||||
return (T)getOption(SocketOptions.SO_SNDBUF);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
return (T)getOption(SocketOptions.SO_RCVBUF);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
return (T)getOption(SocketOptions.SO_REUSEADDR);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEPORT &&
|
||||
supportedOptions().contains(name)) {
|
||||
return (T)getOption(SocketOptions.SO_REUSEPORT);
|
||||
} else if (name == StandardSocketOptions.SO_LINGER && !isServer) {
|
||||
return (T)getOption(SocketOptions.SO_LINGER);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
return (T)getOption(SocketOptions.IP_TOS);
|
||||
} else if (name == StandardSocketOptions.TCP_NODELAY && !isServer) {
|
||||
return (T)getOption(SocketOptions.TCP_NODELAY);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
Objects.requireNonNull(name);
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -464,37 +457,19 @@ public abstract class SocketImpl implements SocketOptions {
|
|||
} catch (IOException ignore) { }
|
||||
}
|
||||
|
||||
private static final Set<SocketOption<?>> socketOptions;
|
||||
|
||||
private static final Set<SocketOption<?>> serverSocketOptions;
|
||||
|
||||
static {
|
||||
socketOptions = Set.of(StandardSocketOptions.SO_KEEPALIVE,
|
||||
StandardSocketOptions.SO_SNDBUF,
|
||||
StandardSocketOptions.SO_RCVBUF,
|
||||
StandardSocketOptions.SO_REUSEADDR,
|
||||
StandardSocketOptions.SO_LINGER,
|
||||
StandardSocketOptions.IP_TOS,
|
||||
StandardSocketOptions.TCP_NODELAY);
|
||||
|
||||
serverSocketOptions = Set.of(StandardSocketOptions.SO_RCVBUF,
|
||||
StandardSocketOptions.SO_REUSEADDR,
|
||||
StandardSocketOptions.IP_TOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of SocketOptions supported by this impl
|
||||
* and by this impl's socket (Socket or ServerSocket)
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method returns an empty set.
|
||||
* Subclasses should override this method with an appropriate implementation.
|
||||
*
|
||||
* @return a Set of SocketOptions
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
if (!isServer) {
|
||||
return socketOptions;
|
||||
} else {
|
||||
return serverSocketOptions;
|
||||
}
|
||||
return Set.of();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,9 +76,15 @@ public abstract class URLStreamHandler {
|
|||
* support proxying will ignore the proxy parameter and make a
|
||||
* normal connection.
|
||||
*
|
||||
* Calling this method preempts the system's default
|
||||
* <p> Calling this method preempts the system's default
|
||||
* {@link java.net.ProxySelector ProxySelector} settings.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation of this method first checks that the given
|
||||
* {code URL} and {code Proxy} are not null, then throws {@code
|
||||
* UnsupportedOperationException}. Subclasses should override this method
|
||||
* with an appropriate implementation.
|
||||
*
|
||||
* @param u the URL that this connects to.
|
||||
* @param p the proxy through which the connection will be made.
|
||||
* If direct connection is desired, Proxy.NO_PROXY
|
||||
|
@ -93,6 +99,8 @@ public abstract class URLStreamHandler {
|
|||
* @since 1.5
|
||||
*/
|
||||
protected URLConnection openConnection(URL u, Proxy p) throws IOException {
|
||||
if (u == null || p == null)
|
||||
throw new IllegalArgumentException("null " + (u == null ? "url" : "proxy"));
|
||||
throw new UnsupportedOperationException("Method not implemented.");
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ public abstract class MappedByteBuffer
|
|||
private long mappingOffset(int index) {
|
||||
int ps = Bits.pageSize();
|
||||
long indexAddress = address + index;
|
||||
long baseAddress = (indexAddress & ~(ps-1));
|
||||
long baseAddress = alignDown(indexAddress, ps);
|
||||
return indexAddress - baseAddress;
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,12 @@ public abstract class MappedByteBuffer
|
|||
return length + mappingOffset;
|
||||
}
|
||||
|
||||
// align address down to page size
|
||||
private static long alignDown(long address, int pageSize) {
|
||||
// pageSize must be a power of 2
|
||||
return address & ~(pageSize - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not this buffer's content is resident in physical
|
||||
* memory.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2019, 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
|
||||
|
@ -70,7 +70,9 @@ import java.util.concurrent.TimeUnit;
|
|||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <th scope="row"> {@code java.nio.channels.DefaultThreadPool.threadFactory} </th>
|
||||
* <th scope="row">
|
||||
* {@systemProperty java.nio.channels.DefaultThreadPool.threadFactory}
|
||||
* </th>
|
||||
* <td> The value of this property is taken to be the fully-qualified name
|
||||
* of a concrete {@link java.util.concurrent.ThreadFactory ThreadFactory}
|
||||
* class. The class is loaded using the system class loader and instantiated.
|
||||
|
@ -81,7 +83,9 @@ import java.util.concurrent.TimeUnit;
|
|||
* construction of the default group. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th scope="row"> {@code java.nio.channels.DefaultThreadPool.initialSize} </th>
|
||||
* <th scope="row">
|
||||
* {@systemProperty java.nio.channels.DefaultThreadPool.initialSize}
|
||||
* </th>
|
||||
* <td> The value of the {@code initialSize} parameter for the default
|
||||
* group (see {@link #withCachedThreadPool withCachedThreadPool}).
|
||||
* The value of the property is taken to be the {@code String}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2019, 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
|
||||
|
@ -138,10 +138,10 @@ public abstract class AsynchronousChannelProvider {
|
|||
* <ol>
|
||||
*
|
||||
* <li><p> If the system property
|
||||
* {@code java.nio.channels.spi.AsynchronousChannelProvider} is defined
|
||||
* then it is taken to be the fully-qualified name of a concrete provider class.
|
||||
* The class is loaded and instantiated; if this process fails then an
|
||||
* unspecified error is thrown. </p></li>
|
||||
* {@systemProperty java.nio.channels.spi.AsynchronousChannelProvider} is
|
||||
* defined then it is taken to be the fully-qualified name of a concrete
|
||||
* provider class. The class is loaded and instantiated; if this process
|
||||
* fails then an unspecified error is thrown. </p></li>
|
||||
*
|
||||
* <li><p> If a provider class has been installed in a jar file that is
|
||||
* visible to the system class loader, and that jar file contains a
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, 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
|
||||
|
@ -143,10 +143,10 @@ public abstract class SelectorProvider {
|
|||
* <ol>
|
||||
*
|
||||
* <li><p> If the system property
|
||||
* {@code java.nio.channels.spi.SelectorProvider} is defined then it is
|
||||
* taken to be the fully-qualified name of a concrete provider class.
|
||||
* The class is loaded and instantiated; if this process fails then an
|
||||
* unspecified error is thrown. </p></li>
|
||||
* {@systemProperty java.nio.channels.spi.SelectorProvider} is defined
|
||||
* then it is taken to be the fully-qualified name of a concrete provider
|
||||
* class. The class is loaded and instantiated; if this process fails then
|
||||
* an unspecified error is thrown. </p></li>
|
||||
*
|
||||
* <li><p> If a provider class has been installed in a jar file that is
|
||||
* visible to the system class loader, and that jar file contains a
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, 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
|
||||
|
@ -67,8 +67,7 @@ import java.util.TreeMap;
|
|||
* concurrent threads.
|
||||
*
|
||||
*
|
||||
* <a id="names"></a><a id="charenc"></a>
|
||||
* <h2>Charset names</h2>
|
||||
* <h2><a id="names">Charset names</a></h2>
|
||||
*
|
||||
* <p> Charsets are named by strings composed of the following characters:
|
||||
*
|
||||
|
@ -138,12 +137,11 @@ import java.util.TreeMap;
|
|||
* previous canonical name be made into an alias.
|
||||
*
|
||||
*
|
||||
* <h2>Standard charsets</h2>
|
||||
* <h2><a id="standard">Standard charsets</a></h2>
|
||||
*
|
||||
*
|
||||
*
|
||||
* <p><a id="standard">Every implementation of the Java platform is required to support the
|
||||
* following standard charsets.</a> Consult the release documentation for your
|
||||
* <p> Every implementation of the Java platform is required to support the
|
||||
* following standard charsets. Consult the release documentation for your
|
||||
* implementation to see if any other charsets are supported. The behavior
|
||||
* of such optional charsets may differ between implementations.
|
||||
*
|
||||
|
@ -217,7 +215,7 @@ import java.util.TreeMap;
|
|||
* determined during virtual-machine startup and typically depends upon the
|
||||
* locale and charset being used by the underlying operating system. </p>
|
||||
*
|
||||
* <p>The {@link StandardCharsets} class defines constants for each of the
|
||||
* <p> The {@link StandardCharsets} class defines constants for each of the
|
||||
* standard charsets.
|
||||
*
|
||||
* <h2>Terminology</h2>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2019, 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
|
||||
|
@ -25,7 +25,7 @@
|
|||
package java.nio.charset;
|
||||
|
||||
/**
|
||||
* Constant definitions for the standard {@link Charset Charsets}. These
|
||||
* Constant definitions for the standard {@link Charset charsets}. These
|
||||
* charsets are guaranteed to be available on every implementation of the Java
|
||||
* platform.
|
||||
*
|
||||
|
@ -44,29 +44,34 @@ public final class StandardCharsets {
|
|||
}
|
||||
|
||||
/**
|
||||
* Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the
|
||||
* Unicode character set
|
||||
* Seven-bit ASCII, also known as ISO646-US, also known as the
|
||||
* Basic Latin block of the Unicode character set.
|
||||
*/
|
||||
public static final Charset US_ASCII = sun.nio.cs.US_ASCII.INSTANCE;
|
||||
|
||||
/**
|
||||
* ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1
|
||||
* ISO Latin Alphabet {@literal No. 1}, also known as ISO-LATIN-1.
|
||||
*/
|
||||
public static final Charset ISO_8859_1 = sun.nio.cs.ISO_8859_1.INSTANCE;
|
||||
|
||||
/**
|
||||
* Eight-bit UCS Transformation Format
|
||||
* Eight-bit UCS Transformation Format.
|
||||
*/
|
||||
public static final Charset UTF_8 = sun.nio.cs.UTF_8.INSTANCE;
|
||||
|
||||
/**
|
||||
* Sixteen-bit UCS Transformation Format, big-endian byte order
|
||||
* Sixteen-bit UCS Transformation Format, big-endian byte order.
|
||||
*/
|
||||
public static final Charset UTF_16BE = new sun.nio.cs.UTF_16BE();
|
||||
|
||||
/**
|
||||
* Sixteen-bit UCS Transformation Format, little-endian byte order
|
||||
* Sixteen-bit UCS Transformation Format, little-endian byte order.
|
||||
*/
|
||||
public static final Charset UTF_16LE = new sun.nio.cs.UTF_16LE();
|
||||
|
||||
/**
|
||||
* Sixteen-bit UCS Transformation Format, byte order identified by an
|
||||
* optional byte-order mark
|
||||
* optional byte-order mark.
|
||||
*/
|
||||
public static final Charset UTF_16 = new sun.nio.cs.UTF_16();
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ import java.util.function.BiPredicate;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
import sun.nio.fs.AbstractFileSystemProvider;
|
||||
|
||||
|
@ -3196,14 +3197,6 @@ public final class Files {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate.
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
private static final jdk.internal.access.JavaLangAccess JLA =
|
||||
jdk.internal.access.SharedSecrets.getJavaLangAccess();
|
||||
|
||||
|
@ -3240,13 +3233,10 @@ public final class Files {
|
|||
break;
|
||||
|
||||
// one more byte was read; need to allocate a larger buffer
|
||||
if (capacity <= MAX_BUFFER_SIZE - capacity) {
|
||||
capacity = Math.max(capacity << 1, BUFFER_SIZE);
|
||||
} else {
|
||||
if (capacity == MAX_BUFFER_SIZE)
|
||||
throw new OutOfMemoryError("Required array size too large");
|
||||
capacity = MAX_BUFFER_SIZE;
|
||||
}
|
||||
capacity = Math.max(ArraysSupport.newLength(capacity,
|
||||
1, /* minimum growth */
|
||||
capacity /* preferred growth */),
|
||||
BUFFER_SIZE);
|
||||
buf = Arrays.copyOf(buf, capacity);
|
||||
buf[nread++] = (byte)n;
|
||||
}
|
||||
|
@ -3283,7 +3273,7 @@ public final class Files {
|
|||
if (sbc instanceof FileChannelImpl)
|
||||
((FileChannelImpl) sbc).setUninterruptible();
|
||||
long size = sbc.size();
|
||||
if (size > (long) MAX_BUFFER_SIZE)
|
||||
if (size > (long) Integer.MAX_VALUE)
|
||||
throw new OutOfMemoryError("Required array size too large");
|
||||
return read(in, (int)size);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2019, 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
|
||||
|
@ -85,7 +85,7 @@ import sun.nio.ch.FileChannelImpl;
|
|||
* provides access to the file systems accessible to the Java virtual machine.
|
||||
* The {@link FileSystems} class defines how file system providers are located
|
||||
* and loaded. The default provider is typically a system-default provider but
|
||||
* may be overridden if the system property {@code
|
||||
* may be overridden if the system property {@systemProperty
|
||||
* java.nio.file.spi.DefaultFileSystemProvider} is set. In that case, the
|
||||
* provider has a one argument constructor whose formal parameter type is {@code
|
||||
* FileSystemProvider}. All other providers have a zero argument constructor
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2019, 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
|
||||
|
@ -399,7 +399,7 @@ final class Parsed implements TemporalAccessor {
|
|||
updateCheckConflict(AMPM_OF_DAY, HOUR_OF_DAY, Math.addExact(Math.multiplyExact(ap, 12), hap));
|
||||
} else { // STRICT or SMART
|
||||
AMPM_OF_DAY.checkValidValue(ap);
|
||||
HOUR_OF_AMPM.checkValidValue(ap);
|
||||
HOUR_OF_AMPM.checkValidValue(hap);
|
||||
updateCheckConflict(AMPM_OF_DAY, HOUR_OF_DAY, ap * 12 + hap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, 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
|
||||
|
@ -25,6 +25,8 @@
|
|||
|
||||
package java.util;
|
||||
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
/**
|
||||
* This class provides a skeletal implementation of the {@code Collection}
|
||||
* interface, to minimize the effort required to implement this interface. <p>
|
||||
|
@ -203,14 +205,6 @@ public abstract class AbstractCollection<E> implements Collection<E> {
|
|||
return it.hasNext() ? finishToArray(r, it) : r;
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate.
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
/**
|
||||
* Reallocates the array being used within toArray when the iterator
|
||||
* returned more elements than expected, and finishes filling it from
|
||||
|
@ -223,29 +217,19 @@ public abstract class AbstractCollection<E> implements Collection<E> {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T[] finishToArray(T[] r, Iterator<?> it) {
|
||||
int i = r.length;
|
||||
int len = r.length;
|
||||
int i = len;
|
||||
while (it.hasNext()) {
|
||||
int cap = r.length;
|
||||
if (i == cap) {
|
||||
int newCap = cap + (cap >> 1) + 1;
|
||||
// overflow-conscious code
|
||||
if (newCap - MAX_ARRAY_SIZE > 0)
|
||||
newCap = hugeCapacity(cap + 1);
|
||||
r = Arrays.copyOf(r, newCap);
|
||||
if (i == len) {
|
||||
len = ArraysSupport.newLength(len,
|
||||
1, /* minimum growth */
|
||||
(len >> 1) + 1 /* preferred growth */);
|
||||
r = Arrays.copyOf(r, len);
|
||||
}
|
||||
r[i++] = (T)it.next();
|
||||
}
|
||||
// trim if overallocated
|
||||
return (i == r.length) ? r : Arrays.copyOf(r, i);
|
||||
}
|
||||
|
||||
private static int hugeCapacity(int minCapacity) {
|
||||
if (minCapacity < 0) // overflow
|
||||
throw new OutOfMemoryError
|
||||
("Required array size too large");
|
||||
return (minCapacity > MAX_ARRAY_SIZE) ?
|
||||
Integer.MAX_VALUE :
|
||||
MAX_ARRAY_SIZE;
|
||||
return (i == len) ? r : Arrays.copyOf(r, i);
|
||||
}
|
||||
|
||||
// Modification Operations
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, 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
|
||||
|
@ -29,6 +29,7 @@ import java.util.function.Consumer;
|
|||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
/**
|
||||
* Resizable-array implementation of the {@code List} interface. Implements
|
||||
|
@ -218,14 +219,6 @@ public class ArrayList<E> extends AbstractList<E>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate (unless necessary).
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
/**
|
||||
* Increases the capacity to ensure that it can hold at least the
|
||||
* number of elements specified by the minimum capacity argument.
|
||||
|
@ -234,47 +227,21 @@ public class ArrayList<E> extends AbstractList<E>
|
|||
* @throws OutOfMemoryError if minCapacity is less than zero
|
||||
*/
|
||||
private Object[] grow(int minCapacity) {
|
||||
return elementData = Arrays.copyOf(elementData,
|
||||
newCapacity(minCapacity));
|
||||
int oldCapacity = elementData.length;
|
||||
if (oldCapacity > 0 || elementData != DEFAULTCAPACITY_EMPTY_ELEMENTDATA) {
|
||||
int newCapacity = ArraysSupport.newLength(oldCapacity,
|
||||
minCapacity - oldCapacity, /* minimum growth */
|
||||
oldCapacity >> 1 /* preferred growth */);
|
||||
return elementData = Arrays.copyOf(elementData, newCapacity);
|
||||
} else {
|
||||
return elementData = new Object[Math.max(DEFAULT_CAPACITY, minCapacity)];
|
||||
}
|
||||
}
|
||||
|
||||
private Object[] grow() {
|
||||
return grow(size + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a capacity at least as large as the given minimum capacity.
|
||||
* Returns the current capacity increased by 50% if that suffices.
|
||||
* Will not return a capacity greater than MAX_ARRAY_SIZE unless
|
||||
* the given minimum capacity is greater than MAX_ARRAY_SIZE.
|
||||
*
|
||||
* @param minCapacity the desired minimum capacity
|
||||
* @throws OutOfMemoryError if minCapacity is less than zero
|
||||
*/
|
||||
private int newCapacity(int minCapacity) {
|
||||
// overflow-conscious code
|
||||
int oldCapacity = elementData.length;
|
||||
int newCapacity = oldCapacity + (oldCapacity >> 1);
|
||||
if (newCapacity - minCapacity <= 0) {
|
||||
if (elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA)
|
||||
return Math.max(DEFAULT_CAPACITY, minCapacity);
|
||||
if (minCapacity < 0) // overflow
|
||||
throw new OutOfMemoryError();
|
||||
return minCapacity;
|
||||
}
|
||||
return (newCapacity - MAX_ARRAY_SIZE <= 0)
|
||||
? newCapacity
|
||||
: hugeCapacity(minCapacity);
|
||||
}
|
||||
|
||||
private static int hugeCapacity(int minCapacity) {
|
||||
if (minCapacity < 0) // overflow
|
||||
throw new OutOfMemoryError();
|
||||
return (minCapacity > MAX_ARRAY_SIZE)
|
||||
? Integer.MAX_VALUE
|
||||
: MAX_ARRAY_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this list.
|
||||
*
|
||||
|
@ -1729,6 +1696,7 @@ public class ArrayList<E> extends AbstractList<E>
|
|||
@Override
|
||||
public void replaceAll(UnaryOperator<E> operator) {
|
||||
replaceAllRange(operator, 0, size);
|
||||
// TODO(8203662): remove increment of modCount from ...
|
||||
modCount++;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2019, 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,6 +28,7 @@ package java.util;
|
|||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
/**
|
||||
* An unbounded priority {@linkplain Queue queue} based on a priority heap.
|
||||
|
@ -281,14 +282,6 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
|||
heapify();
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate.
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
/**
|
||||
* Increases the capacity of the array.
|
||||
*
|
||||
|
@ -297,23 +290,13 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
|||
private void grow(int minCapacity) {
|
||||
int oldCapacity = queue.length;
|
||||
// Double size if small; else grow by 50%
|
||||
int newCapacity = oldCapacity + ((oldCapacity < 64) ?
|
||||
(oldCapacity + 2) :
|
||||
(oldCapacity >> 1));
|
||||
// overflow-conscious code
|
||||
if (newCapacity - MAX_ARRAY_SIZE > 0)
|
||||
newCapacity = hugeCapacity(minCapacity);
|
||||
int newCapacity = ArraysSupport.newLength(oldCapacity,
|
||||
minCapacity - oldCapacity, /* minimum growth */
|
||||
oldCapacity < 64 ? oldCapacity + 2 : oldCapacity >> 1
|
||||
/* preferred growth */);
|
||||
queue = Arrays.copyOf(queue, newCapacity);
|
||||
}
|
||||
|
||||
private static int hugeCapacity(int minCapacity) {
|
||||
if (minCapacity < 0) // overflow
|
||||
throw new OutOfMemoryError();
|
||||
return (minCapacity > MAX_ARRAY_SIZE) ?
|
||||
Integer.MAX_VALUE :
|
||||
MAX_ARRAY_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the specified element into this priority queue.
|
||||
*
|
||||
|
|
|
@ -48,6 +48,7 @@ import java.util.function.Function;
|
|||
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
import jdk.internal.util.xml.PropertiesDefaultHandler;
|
||||
|
||||
/**
|
||||
|
@ -404,17 +405,15 @@ class Properties extends Hashtable<Object,Object> {
|
|||
load0(new LineReader(inStream));
|
||||
}
|
||||
|
||||
private void load0 (LineReader lr) throws IOException {
|
||||
char[] convtBuf = new char[1024];
|
||||
private void load0(LineReader lr) throws IOException {
|
||||
StringBuilder outBuffer = new StringBuilder();
|
||||
int limit;
|
||||
int keyLen;
|
||||
int valueStart;
|
||||
char c;
|
||||
boolean hasSep;
|
||||
boolean precedingBackslash;
|
||||
|
||||
while ((limit = lr.readLine()) >= 0) {
|
||||
c = 0;
|
||||
keyLen = 0;
|
||||
valueStart = limit;
|
||||
hasSep = false;
|
||||
|
@ -422,7 +421,7 @@ class Properties extends Hashtable<Object,Object> {
|
|||
//System.out.println("line=<" + new String(lineBuf, 0, limit) + ">");
|
||||
precedingBackslash = false;
|
||||
while (keyLen < limit) {
|
||||
c = lr.lineBuf[keyLen];
|
||||
char c = lr.lineBuf[keyLen];
|
||||
//need check if escaped.
|
||||
if ((c == '=' || c == ':') && !precedingBackslash) {
|
||||
valueStart = keyLen + 1;
|
||||
|
@ -440,7 +439,7 @@ class Properties extends Hashtable<Object,Object> {
|
|||
keyLen++;
|
||||
}
|
||||
while (valueStart < limit) {
|
||||
c = lr.lineBuf[valueStart];
|
||||
char c = lr.lineBuf[valueStart];
|
||||
if (c != ' ' && c != '\t' && c != '\f') {
|
||||
if (!hasSep && (c == '=' || c == ':')) {
|
||||
hasSep = true;
|
||||
|
@ -450,8 +449,8 @@ class Properties extends Hashtable<Object,Object> {
|
|||
}
|
||||
valueStart++;
|
||||
}
|
||||
String key = loadConvert(lr.lineBuf, 0, keyLen, convtBuf);
|
||||
String value = loadConvert(lr.lineBuf, valueStart, limit - valueStart, convtBuf);
|
||||
String key = loadConvert(lr.lineBuf, 0, keyLen, outBuffer);
|
||||
String value = loadConvert(lr.lineBuf, valueStart, limit - valueStart, outBuffer);
|
||||
put(key, value);
|
||||
}
|
||||
}
|
||||
|
@ -462,64 +461,56 @@ class Properties extends Hashtable<Object,Object> {
|
|||
* Method returns the char length of the "logical line" and stores
|
||||
* the line in "lineBuf".
|
||||
*/
|
||||
class LineReader {
|
||||
public LineReader(InputStream inStream) {
|
||||
private static class LineReader {
|
||||
LineReader(InputStream inStream) {
|
||||
this.inStream = inStream;
|
||||
inByteBuf = new byte[8192];
|
||||
}
|
||||
|
||||
public LineReader(Reader reader) {
|
||||
LineReader(Reader reader) {
|
||||
this.reader = reader;
|
||||
inCharBuf = new char[8192];
|
||||
}
|
||||
|
||||
byte[] inByteBuf;
|
||||
char[] inCharBuf;
|
||||
char[] lineBuf = new char[1024];
|
||||
int inLimit = 0;
|
||||
int inOff = 0;
|
||||
InputStream inStream;
|
||||
Reader reader;
|
||||
private byte[] inByteBuf;
|
||||
private char[] inCharBuf;
|
||||
private int inLimit = 0;
|
||||
private int inOff = 0;
|
||||
private InputStream inStream;
|
||||
private Reader reader;
|
||||
|
||||
int readLine() throws IOException {
|
||||
// use locals to optimize for interpreted performance
|
||||
int len = 0;
|
||||
char c = 0;
|
||||
int off = inOff;
|
||||
int limit = inLimit;
|
||||
|
||||
boolean skipWhiteSpace = true;
|
||||
boolean isCommentLine = false;
|
||||
boolean isNewLine = true;
|
||||
boolean appendedLineBegin = false;
|
||||
boolean precedingBackslash = false;
|
||||
boolean skipLF = false;
|
||||
boolean fromStream = inStream != null;
|
||||
byte[] byteBuf = inByteBuf;
|
||||
char[] charBuf = inCharBuf;
|
||||
char[] lineBuf = this.lineBuf;
|
||||
char c;
|
||||
|
||||
while (true) {
|
||||
if (inOff >= inLimit) {
|
||||
inLimit = (inStream==null)?reader.read(inCharBuf)
|
||||
:inStream.read(inByteBuf);
|
||||
inOff = 0;
|
||||
if (inLimit <= 0) {
|
||||
if (len == 0 || isCommentLine) {
|
||||
if (off >= limit) {
|
||||
inLimit = limit = fromStream ? inStream.read(byteBuf)
|
||||
: reader.read(charBuf);
|
||||
if (limit <= 0) {
|
||||
if (len == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (precedingBackslash) {
|
||||
len--;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
}
|
||||
if (inStream != null) {
|
||||
//The line below is equivalent to calling a
|
||||
//ISO8859-1 decoder.
|
||||
c = (char)(inByteBuf[inOff++] & 0xFF);
|
||||
} else {
|
||||
c = inCharBuf[inOff++];
|
||||
}
|
||||
if (skipLF) {
|
||||
skipLF = false;
|
||||
if (c == '\n') {
|
||||
continue;
|
||||
return precedingBackslash ? len - 1 : len;
|
||||
}
|
||||
off = 0;
|
||||
}
|
||||
|
||||
// (char)(byte & 0xFF) is equivalent to calling a ISO8859-1 decoder.
|
||||
c = (fromStream) ? (char)(byteBuf[off++] & 0xFF) : charBuf[off++];
|
||||
|
||||
if (skipWhiteSpace) {
|
||||
if (c == ' ' || c == '\t' || c == '\f') {
|
||||
continue;
|
||||
|
@ -529,81 +520,94 @@ class Properties extends Hashtable<Object,Object> {
|
|||
}
|
||||
skipWhiteSpace = false;
|
||||
appendedLineBegin = false;
|
||||
|
||||
}
|
||||
if (isNewLine) {
|
||||
isNewLine = false;
|
||||
if (len == 0) { // Still on a new logical line
|
||||
if (c == '#' || c == '!') {
|
||||
// Comment, quickly consume the rest of the line,
|
||||
// resume on line-break and backslash.
|
||||
if (inStream != null) {
|
||||
while (inOff < inLimit) {
|
||||
byte b = inByteBuf[inOff++];
|
||||
if (b == '\n' || b == '\r' || b == '\\') {
|
||||
c = (char)(b & 0xFF);
|
||||
break;
|
||||
// Comment, quickly consume the rest of the line
|
||||
|
||||
// When checking for new line characters a range check,
|
||||
// starting with the higher bound ('\r') means one less
|
||||
// branch in the common case.
|
||||
commentLoop: while (true) {
|
||||
if (fromStream) {
|
||||
byte b;
|
||||
while (off < limit) {
|
||||
b = byteBuf[off++];
|
||||
if (b <= '\r' && (b == '\r' || b == '\n'))
|
||||
break commentLoop;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (inOff < inLimit) {
|
||||
c = inCharBuf[inOff++];
|
||||
if (c == '\n' || c == '\r' || c == '\\') {
|
||||
break;
|
||||
if (off == limit) {
|
||||
inLimit = limit = inStream.read(byteBuf);
|
||||
if (limit <= 0) { // EOF
|
||||
return -1;
|
||||
}
|
||||
off = 0;
|
||||
}
|
||||
} else {
|
||||
while (off < limit) {
|
||||
c = charBuf[off++];
|
||||
if (c <= '\r' && (c == '\r' || c == '\n'))
|
||||
break commentLoop;
|
||||
}
|
||||
if (off == limit) {
|
||||
inLimit = limit = reader.read(charBuf);
|
||||
if (limit <= 0) { // EOF
|
||||
return -1;
|
||||
}
|
||||
off = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
isCommentLine = true;
|
||||
skipWhiteSpace = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (c != '\n' && c != '\r') {
|
||||
lineBuf[len++] = c;
|
||||
if (len == lineBuf.length) {
|
||||
int newLength = lineBuf.length * 2;
|
||||
if (newLength < 0) {
|
||||
newLength = Integer.MAX_VALUE;
|
||||
}
|
||||
char[] buf = new char[newLength];
|
||||
System.arraycopy(lineBuf, 0, buf, 0, lineBuf.length);
|
||||
lineBuf = buf;
|
||||
lineBuf = new char[ArraysSupport.newLength(len, 1, len)];
|
||||
System.arraycopy(this.lineBuf, 0, lineBuf, 0, len);
|
||||
this.lineBuf = lineBuf;
|
||||
}
|
||||
//flip the preceding backslash flag
|
||||
if (c == '\\') {
|
||||
precedingBackslash = !precedingBackslash;
|
||||
} else {
|
||||
precedingBackslash = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// flip the preceding backslash flag
|
||||
precedingBackslash = (c == '\\') ? !precedingBackslash : false;
|
||||
} else {
|
||||
// reached EOL
|
||||
if (isCommentLine || len == 0) {
|
||||
isCommentLine = false;
|
||||
isNewLine = true;
|
||||
if (len == 0) {
|
||||
skipWhiteSpace = true;
|
||||
len = 0;
|
||||
continue;
|
||||
}
|
||||
if (inOff >= inLimit) {
|
||||
inLimit = (inStream==null)
|
||||
?reader.read(inCharBuf)
|
||||
:inStream.read(inByteBuf);
|
||||
inOff = 0;
|
||||
if (inLimit <= 0) {
|
||||
if (precedingBackslash) {
|
||||
len--;
|
||||
}
|
||||
return len;
|
||||
if (off >= limit) {
|
||||
inLimit = limit = fromStream ? inStream.read(byteBuf)
|
||||
: reader.read(charBuf);
|
||||
off = 0;
|
||||
if (limit <= 0) { // EOF
|
||||
return precedingBackslash ? len - 1 : len;
|
||||
}
|
||||
}
|
||||
if (precedingBackslash) {
|
||||
// backslash at EOL is not part of the line
|
||||
len -= 1;
|
||||
//skip the leading whitespace characters in following line
|
||||
// skip leading whitespace characters in the following line
|
||||
skipWhiteSpace = true;
|
||||
appendedLineBegin = true;
|
||||
precedingBackslash = false;
|
||||
// take care not to include any subsequent \n
|
||||
if (c == '\r') {
|
||||
skipLF = true;
|
||||
if (fromStream) {
|
||||
if (byteBuf[off] == '\n') {
|
||||
off++;
|
||||
}
|
||||
} else {
|
||||
if (charBuf[off] == '\n') {
|
||||
off++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inOff = off;
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
@ -615,18 +619,24 @@ class Properties extends Hashtable<Object,Object> {
|
|||
* Converts encoded \uxxxx to unicode chars
|
||||
* and changes special saved chars to their original forms
|
||||
*/
|
||||
private String loadConvert (char[] in, int off, int len, char[] convtBuf) {
|
||||
if (convtBuf.length < len) {
|
||||
int newLen = len * 2;
|
||||
if (newLen < 0) {
|
||||
newLen = Integer.MAX_VALUE;
|
||||
}
|
||||
convtBuf = new char[newLen];
|
||||
}
|
||||
private String loadConvert(char[] in, int off, int len, StringBuilder out) {
|
||||
char aChar;
|
||||
char[] out = convtBuf;
|
||||
int outLen = 0;
|
||||
int end = off + len;
|
||||
int start = off;
|
||||
while (off < end) {
|
||||
aChar = in[off++];
|
||||
if (aChar == '\\') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (off == end) { // No backslash
|
||||
return new String(in, start, len);
|
||||
}
|
||||
|
||||
// backslash found at off - 1, reset the shared buffer, rewind offset
|
||||
out.setLength(0);
|
||||
off--;
|
||||
out.append(in, start, off - start);
|
||||
|
||||
while (off < end) {
|
||||
aChar = in[off++];
|
||||
|
@ -654,20 +664,20 @@ class Properties extends Hashtable<Object,Object> {
|
|||
throw new IllegalArgumentException(
|
||||
"Malformed \\uxxxx encoding.");
|
||||
}
|
||||
}
|
||||
out[outLen++] = (char)value;
|
||||
}
|
||||
out.append((char)value);
|
||||
} else {
|
||||
if (aChar == 't') aChar = '\t';
|
||||
else if (aChar == 'r') aChar = '\r';
|
||||
else if (aChar == 'n') aChar = '\n';
|
||||
else if (aChar == 'f') aChar = '\f';
|
||||
out[outLen++] = aChar;
|
||||
out.append(aChar);
|
||||
}
|
||||
} else {
|
||||
out[outLen++] = aChar;
|
||||
out.append(aChar);
|
||||
}
|
||||
}
|
||||
return new String (out, 0, outLen);
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2019, 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
|
||||
|
@ -32,6 +32,8 @@ import java.util.function.Consumer;
|
|||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
/**
|
||||
* The {@code Vector} class implements a growable array of
|
||||
* objects. Like an array, it contains components that can be
|
||||
|
@ -241,14 +243,6 @@ public class Vector<E>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum size of array to allocate (unless necessary).
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* OutOfMemoryError: Requested array size exceeds VM limit
|
||||
*/
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
/**
|
||||
* Increases the capacity to ensure that it can hold at least the
|
||||
* number of elements specified by the minimum capacity argument.
|
||||
|
@ -257,45 +251,18 @@ public class Vector<E>
|
|||
* @throws OutOfMemoryError if minCapacity is less than zero
|
||||
*/
|
||||
private Object[] grow(int minCapacity) {
|
||||
return elementData = Arrays.copyOf(elementData,
|
||||
newCapacity(minCapacity));
|
||||
int oldCapacity = elementData.length;
|
||||
int newCapacity = ArraysSupport.newLength(oldCapacity,
|
||||
minCapacity - oldCapacity, /* minimum growth */
|
||||
capacityIncrement > 0 ? capacityIncrement : oldCapacity
|
||||
/* preferred growth */);
|
||||
return elementData = Arrays.copyOf(elementData, newCapacity);
|
||||
}
|
||||
|
||||
private Object[] grow() {
|
||||
return grow(elementCount + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a capacity at least as large as the given minimum capacity.
|
||||
* Will not return a capacity greater than MAX_ARRAY_SIZE unless
|
||||
* the given minimum capacity is greater than MAX_ARRAY_SIZE.
|
||||
*
|
||||
* @param minCapacity the desired minimum capacity
|
||||
* @throws OutOfMemoryError if minCapacity is less than zero
|
||||
*/
|
||||
private int newCapacity(int minCapacity) {
|
||||
// overflow-conscious code
|
||||
int oldCapacity = elementData.length;
|
||||
int newCapacity = oldCapacity + ((capacityIncrement > 0) ?
|
||||
capacityIncrement : oldCapacity);
|
||||
if (newCapacity - minCapacity <= 0) {
|
||||
if (minCapacity < 0) // overflow
|
||||
throw new OutOfMemoryError();
|
||||
return minCapacity;
|
||||
}
|
||||
return (newCapacity - MAX_ARRAY_SIZE <= 0)
|
||||
? newCapacity
|
||||
: hugeCapacity(minCapacity);
|
||||
}
|
||||
|
||||
private static int hugeCapacity(int minCapacity) {
|
||||
if (minCapacity < 0) // overflow
|
||||
throw new OutOfMemoryError();
|
||||
return (minCapacity > MAX_ARRAY_SIZE) ?
|
||||
Integer.MAX_VALUE :
|
||||
MAX_ARRAY_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of this vector. If the new size is greater than the
|
||||
* current size, new {@code null} items are added to the end of
|
||||
|
@ -1402,6 +1369,7 @@ public class Vector<E>
|
|||
es[i] = operator.apply(elementAt(es, i));
|
||||
if (modCount != expectedModCount)
|
||||
throw new ConcurrentModificationException();
|
||||
// TODO(8203662): remove increment of modCount from ...
|
||||
modCount++;
|
||||
}
|
||||
|
||||
|
|
|
@ -1712,9 +1712,8 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
|
|||
Map<?,?> m = (Map<?,?>) o;
|
||||
try {
|
||||
Comparator<? super K> cmp = comparator;
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<Map.Entry<?,?>> it =
|
||||
(Iterator<Map.Entry<?,?>>)m.entrySet().iterator();
|
||||
// See JDK-8223553 for Iterator type wildcard rationale
|
||||
Iterator<? extends Map.Entry<?,?>> it = m.entrySet().iterator();
|
||||
if (m instanceof SortedMap &&
|
||||
((SortedMap<?,?>)m).comparator() == cmp) {
|
||||
Node<K,V> b, n;
|
||||
|
|
|
@ -867,8 +867,8 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
growArray(true);
|
||||
else {
|
||||
phase = 0; // full volatile unlock
|
||||
if (a[m & (s - 1)] == null)
|
||||
signal = true; // was empty
|
||||
if (((s - base) & ~1) == 0) // size 0 or 1
|
||||
signal = true;
|
||||
}
|
||||
}
|
||||
return signal;
|
||||
|
@ -2667,13 +2667,13 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an estimate of the total number of tasks stolen from
|
||||
* one thread's work queue by another. The reported value
|
||||
* underestimates the actual total number of steals when the pool
|
||||
* is not quiescent. This value may be useful for monitoring and
|
||||
* tuning fork/join programs: in general, steal counts should be
|
||||
* high enough to keep threads busy, but low enough to avoid
|
||||
* overhead and contention across threads.
|
||||
* Returns an estimate of the total number of completed tasks that
|
||||
* were executed by a thread other than their submitter. The
|
||||
* reported value underestimates the actual total number of steals
|
||||
* when the pool is not quiescent. This value may be useful for
|
||||
* monitoring and tuning fork/join programs: in general, steal
|
||||
* counts should be high enough to keep threads busy, but low
|
||||
* enough to avoid overhead and contention across threads.
|
||||
*
|
||||
* @return the number of steals
|
||||
*/
|
||||
|
|
|
@ -360,7 +360,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
|||
* Returns the current value of this {@code AtomicInteger} as a
|
||||
* {@code long} after a widening primitive conversion,
|
||||
* with memory effects as specified by {@link VarHandle#getVolatile}.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public long longValue() {
|
||||
return (long)get();
|
||||
|
@ -370,7 +370,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
|||
* Returns the current value of this {@code AtomicInteger} as a
|
||||
* {@code float} after a widening primitive conversion,
|
||||
* with memory effects as specified by {@link VarHandle#getVolatile}.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public float floatValue() {
|
||||
return (float)get();
|
||||
|
@ -380,7 +380,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
|||
* Returns the current value of this {@code AtomicInteger} as a
|
||||
* {@code double} after a widening primitive conversion,
|
||||
* with memory effects as specified by {@link VarHandle#getVolatile}.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public double doubleValue() {
|
||||
return (double)get();
|
||||
|
|
|
@ -364,7 +364,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
* Returns the current value of this {@code AtomicLong} as an {@code int}
|
||||
* after a narrowing primitive conversion,
|
||||
* with memory effects as specified by {@link VarHandle#getVolatile}.
|
||||
* @jls 5.1.3 Narrowing Primitive Conversions
|
||||
* @jls 5.1.3 Narrowing Primitive Conversion
|
||||
*/
|
||||
public int intValue() {
|
||||
return (int)get();
|
||||
|
@ -383,7 +383,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
* Returns the current value of this {@code AtomicLong} as a {@code float}
|
||||
* after a widening primitive conversion,
|
||||
* with memory effects as specified by {@link VarHandle#getVolatile}.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public float floatValue() {
|
||||
return (float)get();
|
||||
|
@ -393,7 +393,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
* Returns the current value of this {@code AtomicLong} as a {@code double}
|
||||
* after a widening primitive conversion,
|
||||
* with memory effects as specified by {@link VarHandle#getVolatile}.
|
||||
* @jls 5.1.2 Widening Primitive Conversions
|
||||
* @jls 5.1.2 Widening Primitive Conversion
|
||||
*/
|
||||
public double doubleValue() {
|
||||
return (double)get();
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2019, 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
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.util.regex;
|
||||
|
||||
/**
|
||||
* Holds data contained in the Unicode Technical Standard #51: Unicode
|
||||
* Emoji.
|
||||
*
|
||||
* Currently it is only used for the rule "GB11" in UAX #29 Unicode Text
|
||||
* Segmentation.
|
||||
*/
|
||||
final class EmojiData {
|
||||
/**
|
||||
* Returns whether the code point is an extended pictographic or not.
|
||||
*
|
||||
* @param cp code point to examine
|
||||
* @return true if {@code cp} is an extended pictographic
|
||||
*/
|
||||
static boolean isExtendedPictographic(int cp) {
|
||||
if (cp < 0x2000) {
|
||||
return
|
||||
%%%EXTPICT_LOW%%%
|
||||
} else {
|
||||
return isHigh(cp);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isHigh(int cp) {
|
||||
return
|
||||
%%%EXTPICT_HIGH%%%
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2019, 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
|
||||
|
@ -25,6 +25,8 @@
|
|||
|
||||
package java.util.regex;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
final class Grapheme {
|
||||
|
||||
/**
|
||||
|
@ -33,33 +35,86 @@ final class Grapheme {
|
|||
* <p>
|
||||
* See Unicode Standard Annex #29 Unicode Text Segmentation for the specification
|
||||
* for the extended grapheme cluster boundary rules
|
||||
* <p>
|
||||
* Note: this method does not take care of stateful breaking.
|
||||
*/
|
||||
static boolean isBoundary(int cp1, int cp2) {
|
||||
return rules[getType(cp1)][getType(cp2)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for the next extended grapheme cluster boundary in a CharSequence. It assumes
|
||||
* the start of the char sequence is a boundary.
|
||||
* <p>
|
||||
* See Unicode Standard Annex #29 Unicode Text Segmentation for the specification
|
||||
* for the extended grapheme cluster boundary rules. The following implementation
|
||||
* is based on version 12.0 of the annex.
|
||||
* (http://www.unicode.org/reports/tr29/tr29-35.html)
|
||||
*
|
||||
* @param src the {@code CharSequence} to be scanned
|
||||
* @param off offset to start looking for the next boundary in the src
|
||||
* @param limit limit offset in the src (exclusive)
|
||||
* @return the next possible boundary
|
||||
*/
|
||||
static int nextBoundary(CharSequence src, int off, int limit) {
|
||||
Objects.checkFromToIndex(off, limit, src.length());
|
||||
|
||||
int ch0 = Character.codePointAt(src, 0);
|
||||
int ret = Character.charCount(ch0);
|
||||
int ch1;
|
||||
// indicates whether gb11 or gb12 is underway
|
||||
int t0 = getGraphemeType(ch0);
|
||||
int riCount = t0 == RI ? 1 : 0;
|
||||
boolean gb11 = t0 == EXTENDED_PICTOGRAPHIC;
|
||||
while (ret < limit) {
|
||||
ch1 = Character.codePointAt(src, ret);
|
||||
int t1 = getGraphemeType(ch1);
|
||||
|
||||
if (gb11 && t0 == ZWJ && t1 == EXTENDED_PICTOGRAPHIC) {
|
||||
gb11 = false;
|
||||
} else if (riCount % 2 == 1 && t0 == RI && t1 == RI) {
|
||||
// continue for gb12
|
||||
} else if (rules[t0][t1]) {
|
||||
if (ret > off) {
|
||||
break;
|
||||
} else {
|
||||
gb11 = t1 == EXTENDED_PICTOGRAPHIC;
|
||||
riCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
riCount += (t1 == RI) ? 1 : 0;
|
||||
t0 = t1;
|
||||
|
||||
ret += Character.charCount(ch1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// types
|
||||
private static final int OTHER = 0;
|
||||
private static final int CR = 1;
|
||||
private static final int LF = 2;
|
||||
private static final int CONTROL = 3;
|
||||
private static final int EXTEND = 4;
|
||||
private static final int RI = 5;
|
||||
private static final int PREPEND = 6;
|
||||
private static final int SPACINGMARK = 7;
|
||||
private static final int L = 8;
|
||||
private static final int V = 9;
|
||||
private static final int T = 10;
|
||||
private static final int LV = 11;
|
||||
private static final int LVT = 12;
|
||||
private static final int ZWJ = 5;
|
||||
private static final int RI = 6;
|
||||
private static final int PREPEND = 7;
|
||||
private static final int SPACINGMARK = 8;
|
||||
private static final int L = 9;
|
||||
private static final int V = 10;
|
||||
private static final int T = 11;
|
||||
private static final int LV = 12;
|
||||
private static final int LVT = 13;
|
||||
private static final int EXTENDED_PICTOGRAPHIC = 14;
|
||||
|
||||
private static final int FIRST_TYPE = 0;
|
||||
private static final int LAST_TYPE = 12;
|
||||
private static final int LAST_TYPE = 14;
|
||||
|
||||
private static boolean[][] rules;
|
||||
static {
|
||||
rules = new boolean[LAST_TYPE + 1][LAST_TYPE + 1];
|
||||
// default, any + any
|
||||
// GB 999 Any + Any -> default
|
||||
for (int i = FIRST_TYPE; i <= LAST_TYPE; i++)
|
||||
for (int j = FIRST_TYPE; j <= LAST_TYPE; j++)
|
||||
rules[i][j] = true;
|
||||
|
@ -76,13 +131,12 @@ final class Grapheme {
|
|||
// GB 8 (LVT | T) x T
|
||||
rules[LVT][T] = false;
|
||||
rules[T][T] = false;
|
||||
// GB 8a RI x RI
|
||||
rules[RI][RI] = false;
|
||||
// GB 9 x Extend
|
||||
// GB 9 x (Extend|ZWJ)
|
||||
// GB 9a x Spacing Mark
|
||||
// GB 9b Prepend x
|
||||
for (int i = FIRST_TYPE; i <= LAST_TYPE; i++) {
|
||||
rules[i][EXTEND] = false;
|
||||
rules[i][ZWJ] = false;
|
||||
rules[i][SPACINGMARK] = false;
|
||||
rules[PREPEND][i] = false;
|
||||
}
|
||||
|
@ -95,7 +149,9 @@ final class Grapheme {
|
|||
}
|
||||
// GB 3 CR x LF
|
||||
rules[CR][LF] = false;
|
||||
// GB 10 Any + Any -> default
|
||||
// GB 11 Exended_Pictographic x (Extend|ZWJ)
|
||||
rules[EXTENDED_PICTOGRAPHIC][EXTEND] = false;
|
||||
rules[EXTENDED_PICTOGRAPHIC][ZWJ] = false;
|
||||
}
|
||||
|
||||
// Hangul syllables
|
||||
|
@ -121,39 +177,59 @@ final class Grapheme {
|
|||
cp == 0xAA7B || cp == 0xAA7D;
|
||||
}
|
||||
|
||||
private static int getGraphemeType(int cp) {
|
||||
if (cp < 0x007F) { // ASCII
|
||||
if (cp < 32) { // Control characters
|
||||
if (cp == 0x000D)
|
||||
return CR;
|
||||
if (cp == 0x000A)
|
||||
return LF;
|
||||
return CONTROL;
|
||||
}
|
||||
return OTHER;
|
||||
}
|
||||
return getType(cp);
|
||||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
private static int getType(int cp) {
|
||||
if (EmojiData.isExtendedPictographic(cp)) {
|
||||
return EXTENDED_PICTOGRAPHIC;
|
||||
}
|
||||
|
||||
int type = Character.getType(cp);
|
||||
switch(type) {
|
||||
case Character.CONTROL:
|
||||
if (cp == 0x000D)
|
||||
return CR;
|
||||
if (cp == 0x000A)
|
||||
return LF;
|
||||
return CONTROL;
|
||||
case Character.UNASSIGNED:
|
||||
case Character.UNASSIGNED:
|
||||
// NOTE: #tr29 lists "Unassigned and Default_Ignorable_Code_Point" as Control
|
||||
// but GraphemeBreakTest.txt lists u+0378/reserved-0378 as "Other"
|
||||
// so type it as "Other" to make the test happy
|
||||
if (cp == 0x0378)
|
||||
return OTHER;
|
||||
if (cp == 0x0378)
|
||||
return OTHER;
|
||||
|
||||
case Character.CONTROL:
|
||||
case Character.LINE_SEPARATOR:
|
||||
case Character.PARAGRAPH_SEPARATOR:
|
||||
case Character.SURROGATE:
|
||||
return CONTROL;
|
||||
case Character.FORMAT:
|
||||
if (cp == 0x200C || cp == 0x200D)
|
||||
if (cp == 0x200C ||
|
||||
cp >= 0xE0020 && cp <= 0xE007F)
|
||||
return EXTEND;
|
||||
if (cp == 0x200D)
|
||||
return ZWJ;
|
||||
if (cp >= 0x0600 && cp <= 0x0605 ||
|
||||
cp == 0x06DD || cp == 0x070F || cp == 0x08E2 ||
|
||||
cp == 0x110BD || cp == 0x110CD)
|
||||
return PREPEND;
|
||||
return CONTROL;
|
||||
case Character.NON_SPACING_MARK:
|
||||
case Character.ENCLOSING_MARK:
|
||||
// NOTE:
|
||||
// #tr29 "plus a few General_Category = Spacing_Mark needed for
|
||||
// canonical equivalence."
|
||||
// but for "extended grapheme clusters" support, there is no
|
||||
// need actually to diff "extend" and "spackmark" given GB9, GB9a
|
||||
return EXTEND;
|
||||
// NOTE:
|
||||
// #tr29 "plus a few General_Category = Spacing_Mark needed for
|
||||
// canonical equivalence."
|
||||
// but for "extended grapheme clusters" support, there is no
|
||||
// need actually to diff "extend" and "spackmark" given GB9, GB9a
|
||||
return EXTEND;
|
||||
case Character.COMBINING_SPACING_MARK:
|
||||
if (isExcludedSpacingMark(cp))
|
||||
return OTHER;
|
||||
|
@ -167,9 +243,11 @@ final class Grapheme {
|
|||
return RI;
|
||||
return OTHER;
|
||||
case Character.MODIFIER_LETTER:
|
||||
case Character.MODIFIER_SYMBOL:
|
||||
// WARNING:
|
||||
// not mentioned in #tr29 but listed in GraphemeBreakProperty.txt
|
||||
if (cp == 0xFF9E || cp == 0xFF9F)
|
||||
if (cp == 0xFF9E || cp == 0xFF9F ||
|
||||
cp >= 0x1F3FB && cp <= 0x1F3FF)
|
||||
return EXTEND;
|
||||
return OTHER;
|
||||
case Character.OTHER_LETTER:
|
||||
|
@ -199,6 +277,22 @@ final class Grapheme {
|
|||
return V;
|
||||
if (cp >= 0xD7CB && cp <= 0xD7FB)
|
||||
return T;
|
||||
|
||||
// Prepend
|
||||
switch (cp) {
|
||||
case 0x0D4E:
|
||||
case 0x111C2:
|
||||
case 0x111C3:
|
||||
case 0x11A3A:
|
||||
case 0x11A84:
|
||||
case 0x11A85:
|
||||
case 0x11A86:
|
||||
case 0x11A87:
|
||||
case 0x11A88:
|
||||
case 0x11A89:
|
||||
case 0x11D46:
|
||||
return PREPEND;
|
||||
}
|
||||
}
|
||||
return OTHER;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import java.util.function.Predicate;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
|
||||
/**
|
||||
* A compiled representation of a regular expression.
|
||||
|
@ -539,7 +540,7 @@ import java.util.stream.StreamSupport;
|
|||
* <p> This class is in conformance with Level 1 of <a
|
||||
* href="http://www.unicode.org/reports/tr18/"><i>Unicode Technical
|
||||
* Standard #18: Unicode Regular Expression</i></a>, plus RL2.1
|
||||
* Canonical Equivalents.
|
||||
* Canonical Equivalents and RL2.2 Extended Grapheme Clusters.
|
||||
* <p>
|
||||
* <b>Unicode escape sequences</b> such as <code>\u2014</code> in Java source code
|
||||
* are processed as described in section 3.3 of
|
||||
|
@ -1500,15 +1501,8 @@ public final class Pattern
|
|||
off++;
|
||||
continue;
|
||||
}
|
||||
int j = off + Character.charCount(ch0);
|
||||
int j = Grapheme.nextBoundary(src, off, limit);
|
||||
int ch1;
|
||||
while (j < limit) {
|
||||
ch1 = src.codePointAt(j);
|
||||
if (Grapheme.isBoundary(ch0, ch1))
|
||||
break;
|
||||
ch0 = ch1;
|
||||
j += Character.charCount(ch1);
|
||||
}
|
||||
String seq = src.substring(off, j);
|
||||
String nfd = Normalizer.normalize(seq, Normalizer.Form.NFD);
|
||||
off = j;
|
||||
|
@ -2315,13 +2309,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
}
|
||||
}
|
||||
|
||||
private void append(int ch, int len) {
|
||||
if (len >= buffer.length) {
|
||||
int[] tmp = new int[len+len];
|
||||
System.arraycopy(buffer, 0, tmp, 0, len);
|
||||
buffer = tmp;
|
||||
private void append(int ch, int index) {
|
||||
int len = buffer.length;
|
||||
if (index - len >= 0) {
|
||||
len = ArraysSupport.newLength(len,
|
||||
1 + index - len, /* minimum growth */
|
||||
len /* preferred growth */);
|
||||
buffer = Arrays.copyOf(buffer, len);
|
||||
}
|
||||
buffer[len] = ch;
|
||||
buffer[index] = ch;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3275,28 +3271,33 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
case '+':
|
||||
return curly(prev, 1);
|
||||
case '{':
|
||||
ch = temp[cursor+1];
|
||||
ch = skip();
|
||||
if (ASCII.isDigit(ch)) {
|
||||
skip();
|
||||
int cmin = 0;
|
||||
do {
|
||||
cmin = cmin * 10 + (ch - '0');
|
||||
} while (ASCII.isDigit(ch = read()));
|
||||
int cmax = cmin;
|
||||
if (ch == ',') {
|
||||
ch = read();
|
||||
cmax = MAX_REPS;
|
||||
if (ch != '}') {
|
||||
cmax = 0;
|
||||
while (ASCII.isDigit(ch)) {
|
||||
cmax = cmax * 10 + (ch - '0');
|
||||
ch = read();
|
||||
int cmin = 0, cmax;
|
||||
try {
|
||||
do {
|
||||
cmin = Math.addExact(Math.multiplyExact(cmin, 10),
|
||||
ch - '0');
|
||||
} while (ASCII.isDigit(ch = read()));
|
||||
cmax = cmin;
|
||||
if (ch == ',') {
|
||||
ch = read();
|
||||
cmax = MAX_REPS;
|
||||
if (ch != '}') {
|
||||
cmax = 0;
|
||||
while (ASCII.isDigit(ch)) {
|
||||
cmax = Math.addExact(Math.multiplyExact(cmax, 10),
|
||||
ch - '0');
|
||||
ch = read();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ArithmeticException ae) {
|
||||
throw error("Illegal repetition range");
|
||||
}
|
||||
if (ch != '}')
|
||||
throw error("Unclosed counted closure");
|
||||
if (((cmin) | (cmax) | (cmax - cmin)) < 0)
|
||||
if (cmax < cmin)
|
||||
throw error("Illegal repetition range");
|
||||
Curly curly;
|
||||
ch = peek();
|
||||
|
@ -3973,6 +3974,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
int ch0 = Character.codePointAt(seq, i);
|
||||
int n = Character.charCount(ch0);
|
||||
int j = i + n;
|
||||
// Fast check if it's necessary to call Normalizer;
|
||||
// testing Grapheme.isBoundary is enough for this case
|
||||
while (j < matcher.to) {
|
||||
int ch1 = Character.codePointAt(seq, j);
|
||||
if (Grapheme.isBoundary(ch0, ch1))
|
||||
|
@ -4018,15 +4021,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
static class XGrapheme extends Node {
|
||||
boolean match(Matcher matcher, int i, CharSequence seq) {
|
||||
if (i < matcher.to) {
|
||||
int ch0 = Character.codePointAt(seq, i);
|
||||
i += Character.charCount(ch0);
|
||||
while (i < matcher.to) {
|
||||
int ch1 = Character.codePointAt(seq, i);
|
||||
if (Grapheme.isBoundary(ch0, ch1))
|
||||
break;
|
||||
ch0 = ch1;
|
||||
i += Character.charCount(ch1);
|
||||
}
|
||||
i = Grapheme.nextBoundary(seq, i, matcher.to);
|
||||
return next.match(matcher, i, seq);
|
||||
}
|
||||
matcher.hitEnd = true;
|
||||
|
@ -4056,8 +4051,9 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
}
|
||||
if (i < endIndex) {
|
||||
if (Character.isSurrogatePair(seq.charAt(i-1), seq.charAt(i)) ||
|
||||
!Grapheme.isBoundary(Character.codePointBefore(seq, i),
|
||||
Character.codePointAt(seq, i))) {
|
||||
Grapheme.nextBoundary(seq,
|
||||
i - Character.charCount(Character.codePointBefore(seq, i)),
|
||||
i + Character.charCount(Character.codePointAt(seq, i))) > i) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, 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
|
||||
|
@ -50,6 +50,7 @@
|
|||
package javax.crypto;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.file.*;
|
||||
|
@ -84,11 +85,11 @@ final class JceSecurity {
|
|||
private static CryptoPermissions defaultPolicy = null;
|
||||
private static CryptoPermissions exemptPolicy = null;
|
||||
|
||||
// Map<Provider,?> of the providers we already have verified
|
||||
// value == PROVIDER_VERIFIED is successfully verified
|
||||
// value is failure cause Exception in error case
|
||||
private static final Map<Provider, Object> verificationResults =
|
||||
new IdentityHashMap<>();
|
||||
// Map of the providers we already have verified.
|
||||
// If verified ok, value == PROVIDER_VERIFIED, otherwise
|
||||
// the cause of verification failure is stored as value.
|
||||
private static final Map<IdentityWrapper, Object>
|
||||
verificationResults = new ConcurrentHashMap<>();
|
||||
|
||||
// Map<Provider,?> of the providers currently being verified
|
||||
private static final Map<Provider, Object> verifyingProviders =
|
||||
|
@ -199,31 +200,39 @@ final class JceSecurity {
|
|||
* JCE trusted CA.
|
||||
* Return null if ok, failure Exception if verification failed.
|
||||
*/
|
||||
static synchronized Exception getVerificationResult(Provider p) {
|
||||
Object o = verificationResults.get(p);
|
||||
if (o == PROVIDER_VERIFIED) {
|
||||
return null;
|
||||
} else if (o != null) {
|
||||
return (Exception)o;
|
||||
}
|
||||
if (verifyingProviders.get(p) != null) {
|
||||
// this method is static synchronized, must be recursion
|
||||
// return failure now but do not save the result
|
||||
return new NoSuchProviderException("Recursion during verification");
|
||||
}
|
||||
try {
|
||||
verifyingProviders.put(p, Boolean.FALSE);
|
||||
URL providerURL = getCodeBase(p.getClass());
|
||||
verifyProvider(providerURL, p);
|
||||
// Verified ok, cache result
|
||||
verificationResults.put(p, PROVIDER_VERIFIED);
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
verificationResults.put(p, e);
|
||||
return e;
|
||||
} finally {
|
||||
verifyingProviders.remove(p);
|
||||
static Exception getVerificationResult(Provider p) {
|
||||
IdentityWrapper pKey = new IdentityWrapper(p);
|
||||
Object o = verificationResults.get(pKey);
|
||||
// no mapping found
|
||||
if (o == null) {
|
||||
synchronized (JceSecurity.class) {
|
||||
// check cache again in case the result is now available
|
||||
o = verificationResults.get(pKey);
|
||||
if (o == null) {
|
||||
if (verifyingProviders.get(p) != null) {
|
||||
// recursion; return failure now
|
||||
return new NoSuchProviderException
|
||||
("Recursion during verification");
|
||||
}
|
||||
try {
|
||||
verifyingProviders.put(p, Boolean.FALSE);
|
||||
URL providerURL = getCodeBase(p.getClass());
|
||||
verifyProvider(providerURL, p);
|
||||
o = PROVIDER_VERIFIED;
|
||||
} catch (Exception e) {
|
||||
o = e;
|
||||
} finally {
|
||||
verifyingProviders.remove(p);
|
||||
}
|
||||
verificationResults.put(pKey, o);
|
||||
if (debug != null) {
|
||||
debug.println("Provider " + p.getName() +
|
||||
" verification result: " + o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (o == PROVIDER_VERIFIED? null : (Exception) o);
|
||||
}
|
||||
|
||||
// return whether this provider is properly signed and can be used by JCE
|
||||
|
@ -391,4 +400,29 @@ final class JceSecurity {
|
|||
static boolean isRestricted() {
|
||||
return isRestricted;
|
||||
}
|
||||
|
||||
private static final class IdentityWrapper {
|
||||
|
||||
final Provider obj;
|
||||
|
||||
IdentityWrapper(Provider obj) {
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof IdentityWrapper)) {
|
||||
return false;
|
||||
}
|
||||
return this.obj == ((IdentityWrapper)o).obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return System.identityHashCode(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,10 +190,11 @@ public final class JrtFileSystemProvider extends FileSystemProvider {
|
|||
throw new IllegalArgumentException("Fragment component present");
|
||||
}
|
||||
String path = uri.getPath();
|
||||
if (path == null || path.charAt(0) != '/') {
|
||||
if (path == null || path.charAt(0) != '/' || path.contains("..")) {
|
||||
throw new IllegalArgumentException("Invalid path component");
|
||||
}
|
||||
return getTheFileSystem().getPath(path);
|
||||
|
||||
return getTheFileSystem().getPath("/modules" + path);
|
||||
}
|
||||
|
||||
private FileSystem getTheFileSystem() {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package jdk.internal.jrtfs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOError;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -170,7 +171,16 @@ final class JrtPath implements Path {
|
|||
@Override
|
||||
public final URI toUri() {
|
||||
try {
|
||||
return new URI("jrt", toAbsolutePath().path, null);
|
||||
String p = toAbsolutePath().path;
|
||||
if (!p.startsWith("/modules") || p.contains("..")) {
|
||||
throw new IOError(new RuntimeException(p + " cannot be represented as URI"));
|
||||
}
|
||||
|
||||
p = p.substring("/modules".length());
|
||||
if (p.isEmpty()) {
|
||||
p = "/";
|
||||
}
|
||||
return new URI("jrt", p, null);
|
||||
} catch (URISyntaxException ex) {
|
||||
throw new AssertionError(ex);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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,7 +28,9 @@ import jdk.internal.HotSpotIntrinsicCandidate;
|
|||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* Utility methods to find a mismatch between two primitive arrays.
|
||||
* Utility methods to work with arrays. This includes a set of methods
|
||||
* to find a mismatch between two primitive arrays. Also included is
|
||||
* a method to calculate the new length of an array to be reallocated.
|
||||
*
|
||||
* <p>Array equality and lexicographical comparison can be built on top of
|
||||
* array mismatch functionality.
|
||||
|
@ -571,4 +573,54 @@ public class ArraysSupport {
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum length of array to allocate (unless necessary).
|
||||
* Some VMs reserve some header words in an array.
|
||||
* Attempts to allocate larger arrays may result in
|
||||
* {@code OutOfMemoryError: Requested array size exceeds VM limit}
|
||||
*/
|
||||
public static final int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - 8;
|
||||
|
||||
/**
|
||||
* Calculates a new array length given an array's current length, a preferred
|
||||
* growth value, and a minimum growth value. If the preferred growth value
|
||||
* is less than the minimum growth value, the minimum growth value is used in
|
||||
* its place. If the sum of the current length and the preferred growth
|
||||
* value does not exceed {@link #MAX_ARRAY_LENGTH}, that sum is returned.
|
||||
* If the sum of the current length and the minimum growth value does not
|
||||
* exceed {@code MAX_ARRAY_LENGTH}, then {@code MAX_ARRAY_LENGTH} is returned.
|
||||
* If the sum does not overflow an int, then {@code Integer.MAX_VALUE} is
|
||||
* returned. Otherwise, {@code OutOfMemoryError} is thrown.
|
||||
*
|
||||
* @param oldLength current length of the array (must be non negative)
|
||||
* @param minGrowth minimum required growth of the array length (must be
|
||||
* positive)
|
||||
* @param prefGrowth preferred growth of the array length (ignored, if less
|
||||
* then {@code minGrowth})
|
||||
* @return the new length of the array
|
||||
* @throws OutOfMemoryError if increasing {@code oldLength} by
|
||||
* {@code minGrowth} overflows.
|
||||
*/
|
||||
public static int newLength(int oldLength, int minGrowth, int prefGrowth) {
|
||||
// assert oldLength >= 0
|
||||
// assert minGrowth > 0
|
||||
|
||||
int newLength = Math.max(minGrowth, prefGrowth) + oldLength;
|
||||
if (newLength - MAX_ARRAY_LENGTH <= 0) {
|
||||
return newLength;
|
||||
}
|
||||
return hugeLength(oldLength, minGrowth);
|
||||
}
|
||||
|
||||
private static int hugeLength(int oldLength, int minGrowth) {
|
||||
int minLength = oldLength + minGrowth;
|
||||
if (minLength < 0) { // overflow
|
||||
throw new OutOfMemoryError("Required array length too large");
|
||||
}
|
||||
if (minLength <= MAX_ARRAY_LENGTH) {
|
||||
return MAX_ARRAY_LENGTH;
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
* {@link java.nio.file.FileSystems#newFileSystem
|
||||
* FileSystems.newFileSystem(URI.create("jrt:/"))}.
|
||||
* </dd>
|
||||
* <dt class="simpleTagLabel" style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif">Tool Guides:</dt>
|
||||
* <dd style="font-family:'DejaVu Sans', Arial, Helvetica, sans serif"> {@extLink java_tool_reference java launcher},
|
||||
* {@extLink keytool_tool_reference keytool}</dd>
|
||||
* </dl>
|
||||
*
|
||||
* @toolGuide java java launcher
|
||||
* @toolGuide keytool
|
||||
*
|
||||
* @provides java.nio.file.spi.FileSystemProvider
|
||||
*
|
||||
* @uses java.lang.System.LoggerFinder
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2007, 2019, 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
|
||||
|
@ -132,10 +132,15 @@ java.launcher.X.usage=\n\
|
|||
\ -Xdebug provided for backward compatibility\n\
|
||||
\ -Xdiag show additional diagnostic messages\n\
|
||||
\ -Xfuture enable strictest checks, anticipating future default\n\
|
||||
\ This option is deprecated and may be removed in a\n\
|
||||
\ future release.\n\
|
||||
\ -Xint interpreted mode execution only\n\
|
||||
\ -Xinternalversion\n\
|
||||
\ displays more detailed JVM version information than the\n\
|
||||
\ -version option\n\
|
||||
\ -Xlog:<opts> Configure or enable logging with the Java Virtual\n\
|
||||
\ Machine (JVM) unified logging framework. Use -Xlog:help\n\
|
||||
\ for details.\n\
|
||||
\ -Xloggc:<file> log GC status to a file with time stamps\n\
|
||||
\ -Xmixed mixed mode execution (default)\n\
|
||||
\ -Xmn<size> sets the initial and maximum size (in bytes) of the heap\n\
|
||||
|
@ -161,6 +166,8 @@ java.launcher.X.usage=\n\
|
|||
\ configuration and continue\n\
|
||||
\ -Xss<size> set java thread stack size\n\
|
||||
\ -Xverify sets the mode of the bytecode verifier\n\
|
||||
\ Note that option -Xverify:none is deprecated and\n\
|
||||
\ may be removed in a future release.\n\
|
||||
\ --add-reads <module>=<target-module>(,<target-module>)*\n\
|
||||
\ updates <module> to read <target-module>, regardless\n\
|
||||
\ of module declaration. \n\
|
||||
|
|
|
@ -222,6 +222,8 @@ class DatagramChannelImpl
|
|||
Objects.requireNonNull(name);
|
||||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
if (!name.type().isInstance(value))
|
||||
throw new IllegalArgumentException("Invalid value '" + value + "'");
|
||||
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
@ -236,8 +238,6 @@ class DatagramChannelImpl
|
|||
}
|
||||
|
||||
if (name == StandardSocketOptions.IP_MULTICAST_IF) {
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException("Cannot set IP_MULTICAST_IF to 'null'");
|
||||
NetworkInterface interf = (NetworkInterface)value;
|
||||
if (family == StandardProtocolFamily.INET6) {
|
||||
int index = interf.getIndex();
|
||||
|
|
1283
src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java
Normal file
1283
src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java
Normal file
File diff suppressed because it is too large
Load diff
|
@ -147,6 +147,9 @@ class ServerSocketChannelImpl
|
|||
Objects.requireNonNull(name);
|
||||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
if (!name.type().isInstance(value))
|
||||
throw new IllegalArgumentException("Invalid value '" + value + "'");
|
||||
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
||||
|
|
|
@ -218,6 +218,8 @@ class SocketChannelImpl
|
|||
Objects.requireNonNull(name);
|
||||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
if (!name.type().isInstance(value))
|
||||
throw new IllegalArgumentException("Invalid value '" + value + "'");
|
||||
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, 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
|
||||
|
@ -393,29 +393,22 @@ public final class AnnotatedTypeFactory {
|
|||
return (TypeVariable)getType();
|
||||
}
|
||||
|
||||
// For toString, the declaration of a type variable should
|
||||
// including information about its bounds, etc. However, the
|
||||
// The declaration of a type variable should
|
||||
// include information about its bounds, etc. However, the
|
||||
// use of a type variable should not. For that reason, it is
|
||||
// acceptable for the toString implementation of
|
||||
// acceptable for the toString and hashCode implementations of
|
||||
// AnnotatedTypeVariableImpl to use the inherited
|
||||
// implementation from AnnotatedTypeBaseImpl.
|
||||
// implementations from AnnotatedTypeBaseImpl.
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof AnnotatedTypeVariable) {
|
||||
AnnotatedTypeVariable that = (AnnotatedTypeVariable) o;
|
||||
return equalsTypeAndAnnotations(that) &&
|
||||
Arrays.equals(getAnnotatedBounds(), that.getAnnotatedBounds());
|
||||
return equalsTypeAndAnnotations(that);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return baseHashCode() ^
|
||||
Objects.hash((Object[])getAnnotatedBounds());
|
||||
}
|
||||
}
|
||||
|
||||
private static final class AnnotatedParameterizedTypeImpl extends AnnotatedTypeBaseImpl
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.security.GeneralSecurityException;
|
|||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
|
@ -42,6 +43,7 @@ import java.util.Map;
|
|||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.ShortBufferException;
|
||||
import javax.crypto.spec.GCMParameterSpec;
|
||||
|
@ -491,16 +493,31 @@ enum SSLCipher {
|
|||
|
||||
// availability of this bulk cipher
|
||||
//
|
||||
// We assume all supported ciphers are always available since they are
|
||||
// shipped with the SunJCE provider. However, AES/256 is unavailable
|
||||
// when the default JCE policy jurisdiction files are installed because
|
||||
// of key length restrictions.
|
||||
this.isAvailable = allowed && isUnlimited(keySize, transformation);
|
||||
// AES/256 is unavailable when the default JCE policy jurisdiction files
|
||||
// are installed because of key length restrictions.
|
||||
this.isAvailable = allowed && isUnlimited(keySize, transformation) &&
|
||||
isTransformationAvailable(transformation);
|
||||
|
||||
this.readCipherGenerators = readCipherGenerators;
|
||||
this.writeCipherGenerators = writeCipherGenerators;
|
||||
}
|
||||
|
||||
private static boolean isTransformationAvailable(String transformation) {
|
||||
if (transformation.equals("NULL")) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
Cipher.getInstance(transformation);
|
||||
return true;
|
||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
|
||||
SSLLogger.fine("Transformation " + transformation + " is" +
|
||||
" not available.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SSLReadCipher createReadCipher(Authenticator authenticator,
|
||||
ProtocolVersion protocolVersion,
|
||||
SecretKey key, IvParameterSpec iv,
|
||||
|
|
|
@ -379,7 +379,8 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
|
||||
boolean isSupported = false;
|
||||
for (ProtocolVersion protocol : protocols) {
|
||||
if (!suite.supports(protocol)) {
|
||||
if (!suite.supports(protocol) ||
|
||||
!suite.bulkCipher.isAvailable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,15 +43,20 @@ public class SecurityProperties {
|
|||
* @return the value of the system or security property
|
||||
*/
|
||||
public static String privilegedGetOverridable(String propName) {
|
||||
return AccessController.doPrivileged((PrivilegedAction<String>)
|
||||
() -> {
|
||||
String val = System.getProperty(propName);
|
||||
if (val == null) {
|
||||
return Security.getProperty(propName);
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
});
|
||||
if (System.getSecurityManager() == null) {
|
||||
return getOverridableProperty(propName);
|
||||
} else {
|
||||
return AccessController.doPrivileged((PrivilegedAction<String>) () -> getOverridableProperty(propName));
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOverridableProperty(String propName) {
|
||||
String val = System.getProperty(propName);
|
||||
if (val == null) {
|
||||
return Security.getProperty(propName);
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,501 @@
|
|||
/*
|
||||
* Copyright (c) 2019, 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
|
||||
* questions.
|
||||
*/
|
||||
// (c) 2018 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html#License
|
||||
|
||||
// created: 2018may10 Markus W. Scherer
|
||||
|
||||
package sun.text.normalizer;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* Abstract map from Unicode code points (U+0000..U+10FFFF) to integer values.
|
||||
* This does not implement java.util.Map.
|
||||
*
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public abstract class CodePointMap implements Iterable<CodePointMap.Range> {
|
||||
/**
|
||||
* Selectors for how getRange() should report value ranges overlapping with surrogates.
|
||||
* Most users should use NORMAL.
|
||||
*
|
||||
* @see #getRange
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public enum RangeOption {
|
||||
/**
|
||||
* getRange() enumerates all same-value ranges as stored in the map.
|
||||
* Most users should use this option.
|
||||
*
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
NORMAL,
|
||||
/**
|
||||
* getRange() enumerates all same-value ranges as stored in the map,
|
||||
* except that lead surrogates (U+D800..U+DBFF) are treated as having the
|
||||
* surrogateValue, which is passed to getRange() as a separate parameter.
|
||||
* The surrogateValue is not transformed via filter().
|
||||
* See {@link Character#isHighSurrogate}.
|
||||
*
|
||||
* <p>Most users should use NORMAL instead.
|
||||
*
|
||||
* <p>This option is useful for maps that map surrogate code *units* to
|
||||
* special values optimized for UTF-16 string processing
|
||||
* or for special error behavior for unpaired surrogates,
|
||||
* but those values are not to be associated with the lead surrogate code *points*.
|
||||
*
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
FIXED_LEAD_SURROGATES,
|
||||
/**
|
||||
* getRange() enumerates all same-value ranges as stored in the map,
|
||||
* except that all surrogates (U+D800..U+DFFF) are treated as having the
|
||||
* surrogateValue, which is passed to getRange() as a separate parameter.
|
||||
* The surrogateValue is not transformed via filter().
|
||||
* See {@link Character#isSurrogate}.
|
||||
*
|
||||
* <p>Most users should use NORMAL instead.
|
||||
*
|
||||
* <p>This option is useful for maps that map surrogate code *units* to
|
||||
* special values optimized for UTF-16 string processing
|
||||
* or for special error behavior for unpaired surrogates,
|
||||
* but those values are not to be associated with the lead surrogate code *points*.
|
||||
*
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
FIXED_ALL_SURROGATES
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function interface: Modifies a map value.
|
||||
* Optionally called by getRange().
|
||||
* The modified value will be returned by the getRange() function.
|
||||
*
|
||||
* <p>Can be used to ignore some of the value bits,
|
||||
* make a filter for one of several values,
|
||||
* return a value index computed from the map value, etc.
|
||||
*
|
||||
* @see #getRange
|
||||
* @see #iterator
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public interface ValueFilter {
|
||||
/**
|
||||
* Modifies the map value.
|
||||
*
|
||||
* @param value map value
|
||||
* @return modified value
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public int apply(int value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Range iteration result data.
|
||||
* Code points from start to end map to the same value.
|
||||
* The value may have been modified by {@link ValueFilter#apply(int)},
|
||||
* or it may be the surrogateValue if a RangeOption other than "normal" was used.
|
||||
*
|
||||
* @see #getRange
|
||||
* @see #iterator
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public static final class Range {
|
||||
private int start;
|
||||
private int end;
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Constructor. Sets start and end to -1 and value to 0.
|
||||
*
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public Range() {
|
||||
start = end = -1;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the start code point
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public int getStart() { return start; }
|
||||
/**
|
||||
* @return the (inclusive) end code point
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public int getEnd() { return end; }
|
||||
/**
|
||||
* @return the range value
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public int getValue() { return value; }
|
||||
/**
|
||||
* Sets the range. When using {@link #iterator()},
|
||||
* iteration will resume after the newly set end.
|
||||
*
|
||||
* @param start new start code point
|
||||
* @param end new end code point
|
||||
* @param value new value
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public void set(int start, int end, int value) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private final class RangeIterator implements Iterator<Range> {
|
||||
private Range range = new Range();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return -1 <= range.end && range.end < 0x10ffff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Range next() {
|
||||
if (getRange(range.end + 1, null, range)) {
|
||||
return range;
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over code points of a string and fetches map values.
|
||||
* This does not implement java.util.Iterator.
|
||||
*
|
||||
* <pre>
|
||||
* void onString(CodePointMap map, CharSequence s, int start) {
|
||||
* CodePointMap.StringIterator iter = map.stringIterator(s, start);
|
||||
* while (iter.next()) {
|
||||
* int end = iter.getIndex(); // code point from between start and end
|
||||
* useValue(s, start, end, iter.getCodePoint(), iter.getValue());
|
||||
* start = end;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>This class is not intended for public subclassing.
|
||||
*
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public class StringIterator {
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Deprecated
|
||||
protected CharSequence s;
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Deprecated
|
||||
protected int sIndex;
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Deprecated
|
||||
protected int c;
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Deprecated
|
||||
protected int value;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Deprecated
|
||||
protected StringIterator(CharSequence s, int sIndex) {
|
||||
this.s = s;
|
||||
this.sIndex = sIndex;
|
||||
c = -1;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the iterator to a new string and/or a new string index.
|
||||
*
|
||||
* @param s string to iterate over
|
||||
* @param sIndex string index where the iteration will start
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public void reset(CharSequence s, int sIndex) {
|
||||
this.s = s;
|
||||
this.sIndex = sIndex;
|
||||
c = -1;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the next code point, post-increments the string index,
|
||||
* and gets a value from the map.
|
||||
* Sets an implementation-defined error value if the code point is an unpaired surrogate.
|
||||
*
|
||||
* @return true if the string index was not yet at the end of the string;
|
||||
* otherwise the iterator did not advance
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public boolean next() {
|
||||
if (sIndex >= s.length()) {
|
||||
return false;
|
||||
}
|
||||
c = Character.codePointAt(s, sIndex);
|
||||
sIndex += Character.charCount(c);
|
||||
value = get(c);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the previous code point, pre-decrements the string index,
|
||||
* and gets a value from the map.
|
||||
* Sets an implementation-defined error value if the code point is an unpaired surrogate.
|
||||
*
|
||||
* @return true if the string index was not yet at the start of the string;
|
||||
* otherwise the iterator did not advance
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public boolean previous() {
|
||||
if (sIndex <= 0) {
|
||||
return false;
|
||||
}
|
||||
c = Character.codePointBefore(s, sIndex);
|
||||
sIndex -= Character.charCount(c);
|
||||
value = get(c);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @return the string index
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public final int getIndex() { return sIndex; }
|
||||
/**
|
||||
* @return the code point
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public final int getCodePoint() { return c; }
|
||||
/**
|
||||
* @return the map value,
|
||||
* or an implementation-defined error value if
|
||||
* the code point is an unpaired surrogate
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public final int getValue() { return value; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected no-args constructor.
|
||||
*
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
protected CodePointMap() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for a code point as stored in the map, with range checking.
|
||||
* Returns an implementation-defined error value if c is not in the range 0..U+10FFFF.
|
||||
*
|
||||
* @param c the code point
|
||||
* @return the map value,
|
||||
* or an implementation-defined error value if
|
||||
* the code point is not in the range 0..U+10FFFF
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public abstract int get(int c);
|
||||
|
||||
/**
|
||||
* Sets the range object to a range of code points beginning with the start parameter.
|
||||
* The range start is the same as the start input parameter
|
||||
* (even if there are preceding code points that have the same value).
|
||||
* The range end is the last code point such that
|
||||
* all those from start to there have the same value.
|
||||
* Returns false if start is not 0..U+10FFFF.
|
||||
* Can be used to efficiently iterate over all same-value ranges in a map.
|
||||
* (This is normally faster than iterating over code points and get()ting each value,
|
||||
* but may be much slower than a data structure that stores ranges directly.)
|
||||
*
|
||||
* <p>If the {@link ValueFilter} parameter is not null, then
|
||||
* the value to be delivered is passed through that filter, and the return value is the end
|
||||
* of the range where all values are modified to the same actual value.
|
||||
* The value is unchanged if that parameter is null.
|
||||
*
|
||||
* <p>Example:
|
||||
* <pre>
|
||||
* int start = 0;
|
||||
* CodePointMap.Range range = new CodePointMap.Range();
|
||||
* while (map.getRange(start, null, range)) {
|
||||
* int end = range.getEnd();
|
||||
* int value = range.getValue();
|
||||
* // Work with the range start..end and its value.
|
||||
* start = end + 1;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param start range start
|
||||
* @param filter an object that may modify the map data value,
|
||||
* or null if the values from the map are to be used unmodified
|
||||
* @param range the range object that will be set to the code point range and value
|
||||
* @return true if start is 0..U+10FFFF; otherwise no new range is fetched
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public abstract boolean getRange(int start, ValueFilter filter, Range range);
|
||||
|
||||
/**
|
||||
* Sets the range object to a range of code points beginning with the start parameter.
|
||||
* The range start is the same as the start input parameter
|
||||
* (even if there are preceding code points that have the same value).
|
||||
* The range end is the last code point such that
|
||||
* all those from start to there have the same value.
|
||||
* Returns false if start is not 0..U+10FFFF.
|
||||
*
|
||||
* <p>Same as the simpler {@link #getRange(int, ValueFilter, Range)} but optionally
|
||||
* modifies the range if it overlaps with surrogate code points.
|
||||
*
|
||||
* @param start range start
|
||||
* @param option defines whether surrogates are treated normally,
|
||||
* or as having the surrogateValue; usually {@link RangeOption#NORMAL}
|
||||
* @param surrogateValue value for surrogates; ignored if option=={@link RangeOption#NORMAL}
|
||||
* @param filter an object that may modify the map data value,
|
||||
* or null if the values from the map are to be used unmodified
|
||||
* @param range the range object that will be set to the code point range and value
|
||||
* @return true if start is 0..U+10FFFF; otherwise no new range is fetched
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public boolean getRange(int start, RangeOption option, int surrogateValue,
|
||||
ValueFilter filter, Range range) {
|
||||
assert option != null;
|
||||
if (!getRange(start, filter, range)) {
|
||||
return false;
|
||||
}
|
||||
if (option == RangeOption.NORMAL) {
|
||||
return true;
|
||||
}
|
||||
int surrEnd = option == RangeOption.FIXED_ALL_SURROGATES ? 0xdfff : 0xdbff;
|
||||
int end = range.end;
|
||||
if (end < 0xd7ff || start > surrEnd) {
|
||||
return true;
|
||||
}
|
||||
// The range overlaps with surrogates, or ends just before the first one.
|
||||
if (range.value == surrogateValue) {
|
||||
if (end >= surrEnd) {
|
||||
// Surrogates followed by a non-surrValue range,
|
||||
// or surrogates are part of a larger surrValue range.
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (start <= 0xd7ff) {
|
||||
range.end = 0xd7ff; // Non-surrValue range ends before surrValue surrogates.
|
||||
return true;
|
||||
}
|
||||
// Start is a surrogate with a non-surrValue code *unit* value.
|
||||
// Return a surrValue code *point* range.
|
||||
range.value = surrogateValue;
|
||||
if (end > surrEnd) {
|
||||
range.end = surrEnd; // Surrogate range ends before non-surrValue rest of range.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// See if the surrValue surrogate range can be merged with
|
||||
// an immediately following range.
|
||||
if (getRange(surrEnd + 1, filter, range) && range.value == surrogateValue) {
|
||||
range.start = start;
|
||||
return true;
|
||||
}
|
||||
range.start = start;
|
||||
range.end = surrEnd;
|
||||
range.value = surrogateValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience iterator over same-map-value code point ranges.
|
||||
* Same as looping over all ranges with {@link #getRange(int, ValueFilter, Range)}
|
||||
* without filtering.
|
||||
* Adjacent ranges have different map values.
|
||||
*
|
||||
* <p>The iterator always returns the same Range object.
|
||||
*
|
||||
* @return a Range iterator
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Range> iterator() {
|
||||
return new RangeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator (not a java.util.Iterator) over code points of a string
|
||||
* for fetching map values.
|
||||
*
|
||||
* @param s string to iterate over
|
||||
* @param sIndex string index where the iteration will start
|
||||
* @return the iterator
|
||||
* @draft ICU 63
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public StringIterator stringIterator(CharSequence s, int sIndex) {
|
||||
return new StringIterator(s, sIndex);
|
||||
}
|
||||
}
|
1310
src/java.base/share/classes/sun/text/normalizer/CodePointTrie.java
Normal file
1310
src/java.base/share/classes/sun/text/normalizer/CodePointTrie.java
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2019, 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
|
||||
|
@ -119,10 +119,7 @@ public final class ICUBinary {
|
|||
} else if (capacity < 0x4000) {
|
||||
capacity *= 2; // Grow faster until we reach 16kB.
|
||||
}
|
||||
// TODO Java 6 replace new byte[] and arraycopy(): bytes = Arrays.copyOf(bytes, capacity);
|
||||
byte[] newBytes = new byte[capacity];
|
||||
System.arraycopy(bytes, 0, newBytes, 0, length);
|
||||
bytes = newBytes;
|
||||
bytes = Arrays.copyOf(bytes, capacity);
|
||||
bytes[length++] = (byte) nextByte;
|
||||
}
|
||||
}
|
||||
|
@ -264,6 +261,36 @@ public final class ICUBinary {
|
|||
}
|
||||
}
|
||||
|
||||
public static byte[] getBytes(ByteBuffer bytes, int length, int additionalSkipLength) {
|
||||
byte[] dest = new byte[length];
|
||||
bytes.get(dest);
|
||||
if (additionalSkipLength > 0) {
|
||||
skipBytes(bytes, additionalSkipLength);
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
public static String getString(ByteBuffer bytes, int length, int additionalSkipLength) {
|
||||
CharSequence cs = bytes.asCharBuffer();
|
||||
String s = cs.subSequence(0, length).toString();
|
||||
skipBytes(bytes, length * 2 + additionalSkipLength);
|
||||
return s;
|
||||
}
|
||||
|
||||
public static char[] getChars(ByteBuffer bytes, int length, int additionalSkipLength) {
|
||||
char[] dest = new char[length];
|
||||
bytes.asCharBuffer().get(dest);
|
||||
skipBytes(bytes, length * 2 + additionalSkipLength);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public static int[] getInts(ByteBuffer bytes, int length, int additionalSkipLength) {
|
||||
int[] dest = new int[length];
|
||||
bytes.asIntBuffer().get(dest);
|
||||
skipBytes(bytes, length * 4 + additionalSkipLength);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a VersionInfo for the bytes in the compact version integer.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
|
@ -265,7 +265,7 @@ final class Norm2AllModes {
|
|||
private static final class Norm2AllModesSingleton {
|
||||
private Norm2AllModesSingleton(String name) {
|
||||
try {
|
||||
String DATA_FILE_NAME = "/sun/text/resources/" + name + ".icu";
|
||||
String DATA_FILE_NAME = "/sun/text/resources/" + name + ".nrm";
|
||||
NormalizerImpl impl=new NormalizerImpl().load(DATA_FILE_NAME);
|
||||
allModes=new Norm2AllModes(impl);
|
||||
} catch (RuntimeException e) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2019, 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
|
||||
|
@ -61,7 +61,7 @@ public final class NormalizerImpl {
|
|||
return 0<=c && c<HANGUL_COUNT && c%JAMO_T_COUNT==0;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decomposes c, which must be a Hangul syllable, into buffer
|
||||
* and returns the length of the decomposition (2 or 3).
|
||||
*/
|
||||
|
@ -145,8 +145,7 @@ public final class NormalizerImpl {
|
|||
insert(c, cc);
|
||||
}
|
||||
}
|
||||
// s must be in NFD, otherwise change the implementation.
|
||||
public void append(CharSequence s, int start, int limit,
|
||||
public void append(CharSequence s, int start, int limit, boolean isNFD,
|
||||
int leadCC, int trailCC) {
|
||||
if(start==limit) {
|
||||
return;
|
||||
|
@ -167,8 +166,11 @@ public final class NormalizerImpl {
|
|||
c=Character.codePointAt(s, start);
|
||||
start+=Character.charCount(c);
|
||||
if(start<limit) {
|
||||
// s must be in NFD, otherwise we need to use getCC().
|
||||
leadCC=getCCFromYesOrMaybe(impl.getNorm16(c));
|
||||
if (isNFD) {
|
||||
leadCC = getCCFromYesOrMaybe(impl.getNorm16(c));
|
||||
} else {
|
||||
leadCC = impl.getCC(impl.getNorm16(c));
|
||||
}
|
||||
} else {
|
||||
leadCC=trailCC;
|
||||
}
|
||||
|
@ -310,6 +312,12 @@ public final class NormalizerImpl {
|
|||
// TODO: Propose widening UTF16 methods that take char to take int.
|
||||
// TODO: Propose widening UTF16 methods that take String to take CharSequence.
|
||||
public static final class UTF16Plus {
|
||||
/**
|
||||
* Is this code point a lead surrogate (U+d800..U+dbff)?
|
||||
* @param c code unit or code point
|
||||
* @return true or false
|
||||
*/
|
||||
public static boolean isLeadSurrogate(int c) { return (c & 0xfffffc00) == 0xd800; }
|
||||
/**
|
||||
* Assuming c is a surrogate code point (UTF16.isSurrogate(c)),
|
||||
* is it a lead surrogate?
|
||||
|
@ -350,7 +358,7 @@ public final class NormalizerImpl {
|
|||
|
||||
private static final class IsAcceptable implements ICUBinary.Authenticate {
|
||||
public boolean isDataVersionAcceptable(byte version[]) {
|
||||
return version[0]==3;
|
||||
return version[0]==4;
|
||||
}
|
||||
}
|
||||
private static final IsAcceptable IS_ACCEPTABLE = new IsAcceptable();
|
||||
|
@ -387,8 +395,9 @@ public final class NormalizerImpl {
|
|||
// Read the normTrie.
|
||||
int offset=inIndexes[IX_NORM_TRIE_OFFSET];
|
||||
int nextOffset=inIndexes[IX_EXTRA_DATA_OFFSET];
|
||||
normTrie=Trie2_16.createFromSerialized(bytes);
|
||||
int trieLength=normTrie.getSerializedLength();
|
||||
int triePosition = bytes.position();
|
||||
normTrie = CodePointTrie.Fast16.fromBinary(bytes);
|
||||
int trieLength = bytes.position() - triePosition;
|
||||
if(trieLength>(nextOffset-offset)) {
|
||||
throw new InternalError("Normalizer2 data: not enough bytes for normTrie");
|
||||
}
|
||||
|
@ -398,13 +407,8 @@ public final class NormalizerImpl {
|
|||
offset=nextOffset;
|
||||
nextOffset=inIndexes[IX_SMALL_FCD_OFFSET];
|
||||
int numChars=(nextOffset-offset)/2;
|
||||
char[] chars;
|
||||
if(numChars!=0) {
|
||||
chars=new char[numChars];
|
||||
for(int i=0; i<numChars; ++i) {
|
||||
chars[i]=bytes.getChar();
|
||||
}
|
||||
maybeYesCompositions=new String(chars);
|
||||
maybeYesCompositions=ICUBinary.getString(bytes, numChars, 0);
|
||||
extraData=maybeYesCompositions.substring((MIN_NORMAL_MAYBE_YES-minMaybeYes)>>OFFSET_SHIFT);
|
||||
}
|
||||
|
||||
|
@ -422,8 +426,12 @@ public final class NormalizerImpl {
|
|||
return load(ICUBinary.getRequiredData(name));
|
||||
}
|
||||
|
||||
|
||||
public int getNorm16(int c) { return normTrie.get(c); }
|
||||
// The trie stores values for lead surrogate code *units*.
|
||||
// Surrogate code *points* are inert.
|
||||
public int getNorm16(int c) {
|
||||
return UTF16Plus.isLeadSurrogate(c) ? INERT : normTrie.get(c);
|
||||
}
|
||||
public int getRawNorm16(int c) { return normTrie.get(c); }
|
||||
public boolean isAlgorithmicNoNo(int norm16) { return limitNoNo<=norm16 && norm16<minMaybeYes; }
|
||||
public boolean isCompNo(int norm16) { return minNoNo<=norm16 && norm16<minMaybeYes; }
|
||||
public boolean isDecompYes(int norm16) { return norm16<minYesNo || minMaybeYes<=norm16; }
|
||||
|
@ -486,7 +494,7 @@ public final class NormalizerImpl {
|
|||
}
|
||||
// Maps to an isCompYesAndZeroCC.
|
||||
c=mapAlgorithmic(c, norm16);
|
||||
norm16=getNorm16(c);
|
||||
norm16=getRawNorm16(c);
|
||||
}
|
||||
}
|
||||
if(norm16<=minYesNo || isHangulLVT(norm16)) {
|
||||
|
@ -519,7 +527,7 @@ public final class NormalizerImpl {
|
|||
// Maps to an isCompYesAndZeroCC.
|
||||
decomp=c=mapAlgorithmic(c, norm16);
|
||||
// The mapping might decompose further.
|
||||
norm16 = getNorm16(c);
|
||||
norm16 = getRawNorm16(c);
|
||||
}
|
||||
if (norm16 < minYesNo) {
|
||||
if(decomp<0) {
|
||||
|
@ -641,27 +649,23 @@ public final class NormalizerImpl {
|
|||
// count code units below the minimum or with irrelevant data for the quick check
|
||||
for(prevSrc=src; src!=limit;) {
|
||||
if( (c=s.charAt(src))<minNoCP ||
|
||||
isMostDecompYesAndZeroCC(norm16=normTrie.getFromU16SingleLead((char)c))
|
||||
isMostDecompYesAndZeroCC(norm16=normTrie.bmpGet(c))
|
||||
) {
|
||||
++src;
|
||||
} else if(!UTF16.isSurrogate((char)c)) {
|
||||
} else if(!UTF16Plus.isLeadSurrogate(c)) {
|
||||
break;
|
||||
} else {
|
||||
char c2;
|
||||
if(UTF16Plus.isSurrogateLead(c)) {
|
||||
if((src+1)!=limit && Character.isLowSurrogate(c2=s.charAt(src+1))) {
|
||||
c=Character.toCodePoint((char)c, c2);
|
||||
if ((src + 1) != limit && Character.isLowSurrogate(c2 = s.charAt(src + 1))) {
|
||||
c = Character.toCodePoint((char)c, c2);
|
||||
norm16 = normTrie.suppGet(c);
|
||||
if (isMostDecompYesAndZeroCC(norm16)) {
|
||||
src += 2;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else /* trail surrogate */ {
|
||||
if(prevSrc<src && Character.isHighSurrogate(c2=s.charAt(src-1))) {
|
||||
--src;
|
||||
c=Character.toCodePoint(c2, (char)c);
|
||||
}
|
||||
}
|
||||
if(isMostDecompYesAndZeroCC(norm16=getNorm16(c))) {
|
||||
src+=Character.charCount(c);
|
||||
} else {
|
||||
break;
|
||||
++src; // unpaired lead surrogate: inert
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,7 +725,7 @@ public final class NormalizerImpl {
|
|||
c=Character.codePointAt(s, src);
|
||||
cc=getCC(getNorm16(c));
|
||||
};
|
||||
buffer.append(s, 0, src, firstCC, prevCC);
|
||||
buffer.append(s, 0, src, false, firstCC, prevCC);
|
||||
buffer.append(s, src, limit);
|
||||
}
|
||||
|
||||
|
@ -749,28 +753,22 @@ public final class NormalizerImpl {
|
|||
return true;
|
||||
}
|
||||
if( (c=s.charAt(src))<minNoMaybeCP ||
|
||||
isCompYesAndZeroCC(norm16=normTrie.getFromU16SingleLead((char)c))
|
||||
isCompYesAndZeroCC(norm16=normTrie.bmpGet(c))
|
||||
) {
|
||||
++src;
|
||||
} else {
|
||||
prevSrc = src++;
|
||||
if(!UTF16.isSurrogate((char)c)) {
|
||||
if (!UTF16Plus.isLeadSurrogate(c)) {
|
||||
break;
|
||||
} else {
|
||||
char c2;
|
||||
if(UTF16Plus.isSurrogateLead(c)) {
|
||||
if(src!=limit && Character.isLowSurrogate(c2=s.charAt(src))) {
|
||||
++src;
|
||||
c=Character.toCodePoint((char)c, c2);
|
||||
if (src != limit && Character.isLowSurrogate(c2 = s.charAt(src))) {
|
||||
++src;
|
||||
c = Character.toCodePoint((char)c, c2);
|
||||
norm16 = normTrie.suppGet(c);
|
||||
if (!isCompYesAndZeroCC(norm16)) {
|
||||
break;
|
||||
}
|
||||
} else /* trail surrogate */ {
|
||||
if(prevBoundary<prevSrc && Character.isHighSurrogate(c2=s.charAt(prevSrc-1))) {
|
||||
--prevSrc;
|
||||
c=Character.toCodePoint(c2, (char)c);
|
||||
}
|
||||
}
|
||||
if(!isCompYesAndZeroCC(norm16=getNorm16(c))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -991,28 +989,22 @@ public final class NormalizerImpl {
|
|||
return (src<<1)|qcResult; // "yes" or "maybe"
|
||||
}
|
||||
if( (c=s.charAt(src))<minNoMaybeCP ||
|
||||
isCompYesAndZeroCC(norm16=normTrie.getFromU16SingleLead((char)c))
|
||||
isCompYesAndZeroCC(norm16=normTrie.bmpGet(c))
|
||||
) {
|
||||
++src;
|
||||
} else {
|
||||
prevSrc = src++;
|
||||
if(!UTF16.isSurrogate((char)c)) {
|
||||
if (!UTF16Plus.isLeadSurrogate(c)) {
|
||||
break;
|
||||
} else {
|
||||
char c2;
|
||||
if(UTF16Plus.isSurrogateLead(c)) {
|
||||
if(src!=limit && Character.isLowSurrogate(c2=s.charAt(src))) {
|
||||
++src;
|
||||
c=Character.toCodePoint((char)c, c2);
|
||||
if (src != limit && Character.isLowSurrogate(c2 = s.charAt(src))) {
|
||||
++src;
|
||||
c = Character.toCodePoint((char)c, c2);
|
||||
norm16 = normTrie.suppGet(c);
|
||||
if (!isCompYesAndZeroCC(norm16)) {
|
||||
break;
|
||||
}
|
||||
} else /* trail surrogate */ {
|
||||
if(prevBoundary<prevSrc && Character.isHighSurrogate(c2=s.charAt(prevSrc-1))) {
|
||||
--prevSrc;
|
||||
c=Character.toCodePoint(c2, (char)c);
|
||||
}
|
||||
}
|
||||
if(!isCompYesAndZeroCC(norm16=getNorm16(c))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1134,17 +1126,10 @@ public final class NormalizerImpl {
|
|||
prevFCD16=0;
|
||||
++src;
|
||||
} else {
|
||||
if(UTF16.isSurrogate((char)c)) {
|
||||
if (UTF16Plus.isLeadSurrogate(c)) {
|
||||
char c2;
|
||||
if(UTF16Plus.isSurrogateLead(c)) {
|
||||
if((src+1)!=limit && Character.isLowSurrogate(c2=s.charAt(src+1))) {
|
||||
c=Character.toCodePoint((char)c, c2);
|
||||
}
|
||||
} else /* trail surrogate */ {
|
||||
if(prevSrc<src && Character.isHighSurrogate(c2=s.charAt(src-1))) {
|
||||
--src;
|
||||
c=Character.toCodePoint(c2, (char)c);
|
||||
}
|
||||
if ((src + 1) != limit && Character.isLowSurrogate(c2 = s.charAt(src + 1))) {
|
||||
c = Character.toCodePoint((char)c, c2);
|
||||
}
|
||||
}
|
||||
if((fcd16=getFCD16FromNormData(c))<=0xff) {
|
||||
|
@ -1430,7 +1415,7 @@ public final class NormalizerImpl {
|
|||
}
|
||||
// Maps to an isCompYesAndZeroCC.
|
||||
c=mapAlgorithmic(c, norm16);
|
||||
norm16=getNorm16(c);
|
||||
norm16=getRawNorm16(c);
|
||||
}
|
||||
if (norm16 < minYesNo) {
|
||||
// c does not decompose
|
||||
|
@ -1451,7 +1436,7 @@ public final class NormalizerImpl {
|
|||
leadCC=0;
|
||||
}
|
||||
++mapping; // skip over the firstUnit
|
||||
buffer.append(extraData, mapping, mapping+length, leadCC, trailCC);
|
||||
buffer.append(extraData, mapping, mapping+length, true, leadCC, trailCC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1643,7 +1628,7 @@ public final class NormalizerImpl {
|
|||
// Is the composite a starter that combines forward?
|
||||
if((compositeAndFwd&1)!=0) {
|
||||
compositionsList=
|
||||
getCompositionsListForComposite(getNorm16(composite));
|
||||
getCompositionsListForComposite(getRawNorm16(composite));
|
||||
} else {
|
||||
compositionsList=-1;
|
||||
}
|
||||
|
@ -2196,9 +2181,8 @@ public final class NormalizerImpl {
|
|||
private int centerNoNoDelta;
|
||||
private int minMaybeYes;
|
||||
|
||||
private Trie2_16 normTrie;
|
||||
private CodePointTrie.Fast16 normTrie;
|
||||
private String maybeYesCompositions;
|
||||
private String extraData; // mappings and/or compositions for yesYes, yesNo & noNo characters
|
||||
private byte[] smallFCD; // [0x100] one bit per 32 BMP code points, set if any FCD!=0
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
src/java.base/share/classes/sun/text/resources/nfkc.nrm
Normal file
BIN
src/java.base/share/classes/sun/text/resources/nfkc.nrm
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -257,11 +257,13 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
|
|||
return langtags;
|
||||
}
|
||||
|
||||
// Check if each string is unique, except null or empty strings,
|
||||
// as these strings are used for keys in the name-to-value map.
|
||||
private boolean hasDuplicates(String[] strings) {
|
||||
int len = strings.length;
|
||||
for (int i = 0; i < len - 1; i++) {
|
||||
String a = strings[i];
|
||||
if (a != null) {
|
||||
if (a != null && !a.isEmpty()) {
|
||||
for (int j = i + 1; j < len; j++) {
|
||||
if (a.equals(strings[j])) {
|
||||
return true;
|
||||
|
|
|
@ -1022,27 +1022,6 @@ jdk.xml.dsig.secureValidationPolicy=\
|
|||
# java.rmi.dgc.Lease;\
|
||||
# maxdepth=5;maxarray=10000
|
||||
|
||||
# CORBA ORBIorTypeCheckRegistryFilter
|
||||
# Type check enhancement for ORB::string_to_object processing
|
||||
#
|
||||
# An IOR type check filter, if configured, is used by an ORB during
|
||||
# an ORB::string_to_object invocation to check the veracity of the type encoded
|
||||
# in the ior string.
|
||||
#
|
||||
# The filter pattern consists of a semi-colon separated list of class names.
|
||||
# The configured list contains the binary class names of the IDL interface types
|
||||
# corresponding to the IDL stub class to be instantiated.
|
||||
# As such, a filter specifies a list of IDL stub classes that will be
|
||||
# allowed by an ORB when an ORB::string_to_object is invoked.
|
||||
# It is used to specify a white list configuration of acceptable
|
||||
# IDL stub types which may be contained in a stringified IOR
|
||||
# parameter passed as input to an ORB::string_to_object method.
|
||||
#
|
||||
# Note: This property is currently used by the JDK Reference implementation.
|
||||
# It is not guaranteed to be examined and used by other implementations.
|
||||
#
|
||||
#com.sun.CORBA.ORBIorTypeCheckRegistryFilter=binary_class_name;binary_class_name
|
||||
|
||||
#
|
||||
# JCEKS Encrypted Key Serial Filter
|
||||
#
|
||||
|
|
|
@ -1,38 +1,11 @@
|
|||
## International Components for Unicode (ICU4J) v62.1
|
||||
## International Components for Unicode (ICU4J) v64.2
|
||||
|
||||
### ICU4J License
|
||||
|
||||
```
|
||||
COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later)
|
||||
|
||||
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
|
||||
Unicode Data Files include all data files under the directories
|
||||
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
|
||||
http://www.unicode.org/cldr/data/,
|
||||
http://source.icu-project.org/repos/icu/, and
|
||||
http://www.unicode.org/utility/trac/browser/.
|
||||
|
||||
Unicode Data Files do not include PDF online code charts under the
|
||||
directory http://www.unicode.org/Public/.
|
||||
|
||||
Software includes any source code published in the Unicode Standard
|
||||
or under the directories
|
||||
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
|
||||
http://www.unicode.org/cldr/data/,
|
||||
http://source.icu-project.org/repos/icu/, and
|
||||
http://www.unicode.org/utility/trac/browser/.
|
||||
|
||||
NOTICE TO USER: Carefully read the following legal agreement.
|
||||
BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
|
||||
DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
|
||||
YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
|
||||
TERMS AND CONDITIONS OF THIS AGREEMENT.
|
||||
IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
|
||||
THE DATA FILES OR SOFTWARE.
|
||||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright © 1991-2018 Unicode, Inc. All rights reserved.
|
||||
Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
|
||||
Copyright © 1991-2019 Unicode, Inc. All rights reserved.
|
||||
Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Unicode data files and any associated documentation
|
||||
|
@ -63,4 +36,354 @@ shall not be used in advertising or otherwise to promote the sale,
|
|||
use or other dealings in these Data Files or Software without prior
|
||||
written authorization of the copyright holder.
|
||||
|
||||
```
|
||||
---------------------
|
||||
|
||||
Third-Party Software Licenses
|
||||
|
||||
This section contains third-party software notices and/or additional
|
||||
terms for licensed third-party software components included within ICU
|
||||
libraries.
|
||||
|
||||
1. ICU License - ICU 1.8.1 to ICU 57.1
|
||||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright (c) 1995-2016 International Business Machines Corporation and others
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, and/or sell copies of the Software, and to permit persons
|
||||
to whom the Software is furnished to do so, provided that the above
|
||||
copyright notice(s) and this permission notice appear in all copies of
|
||||
the Software and that both the above copyright notice(s) and this
|
||||
permission notice appear in supporting documentation.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of a copyright holder
|
||||
shall not be used in advertising or otherwise to promote the sale, use
|
||||
or other dealings in this Software without prior written authorization
|
||||
of the copyright holder.
|
||||
|
||||
All trademarks and registered trademarks mentioned herein are the
|
||||
property of their respective owners.
|
||||
|
||||
2. Chinese/Japanese Word Break Dictionary Data (cjdict.txt)
|
||||
|
||||
# The Google Chrome software developed by Google is licensed under
|
||||
# the BSD license. Other software included in this distribution is
|
||||
# provided under other licenses, as set forth below.
|
||||
#
|
||||
# The BSD License
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
# Copyright (C) 2006-2008, Google Inc.
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided with
|
||||
# the distribution.
|
||||
# Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#
|
||||
# The word list in cjdict.txt are generated by combining three word lists
|
||||
# listed below with further processing for compound word breaking. The
|
||||
# frequency is generated with an iterative training against Google web
|
||||
# corpora.
|
||||
#
|
||||
# * Libtabe (Chinese)
|
||||
# - https://sourceforge.net/project/?group_id=1519
|
||||
# - Its license terms and conditions are shown below.
|
||||
#
|
||||
# * IPADIC (Japanese)
|
||||
# - http://chasen.aist-nara.ac.jp/chasen/distribution.html
|
||||
# - Its license terms and conditions are shown below.
|
||||
#
|
||||
# ---------COPYING.libtabe ---- BEGIN--------------------
|
||||
#
|
||||
# /*
|
||||
# * Copyright (c) 1999 TaBE Project.
|
||||
# * Copyright (c) 1999 Pai-Hsiang Hsiao.
|
||||
# * All rights reserved.
|
||||
# *
|
||||
# * Redistribution and use in source and binary forms, with or without
|
||||
# * modification, are permitted provided that the following conditions
|
||||
# * are met:
|
||||
# *
|
||||
# * . Redistributions of source code must retain the above copyright
|
||||
# * notice, this list of conditions and the following disclaimer.
|
||||
# * . Redistributions in binary form must reproduce the above copyright
|
||||
# * notice, this list of conditions and the following disclaimer in
|
||||
# * the documentation and/or other materials provided with the
|
||||
# * distribution.
|
||||
# * . Neither the name of the TaBE Project nor the names of its
|
||||
# * contributors may be used to endorse or promote products derived
|
||||
# * from this software without specific prior written permission.
|
||||
# *
|
||||
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
# * OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# */
|
||||
#
|
||||
# /*
|
||||
# * Copyright (c) 1999 Computer Systems and Communication Lab,
|
||||
# * Institute of Information Science, Academia
|
||||
# * Sinica. All rights reserved.
|
||||
# *
|
||||
# * Redistribution and use in source and binary forms, with or without
|
||||
# * modification, are permitted provided that the following conditions
|
||||
# * are met:
|
||||
# *
|
||||
# * . Redistributions of source code must retain the above copyright
|
||||
# * notice, this list of conditions and the following disclaimer.
|
||||
# * . Redistributions in binary form must reproduce the above copyright
|
||||
# * notice, this list of conditions and the following disclaimer in
|
||||
# * the documentation and/or other materials provided with the
|
||||
# * distribution.
|
||||
# * . Neither the name of the Computer Systems and Communication Lab
|
||||
# * nor the names of its contributors may be used to endorse or
|
||||
# * promote products derived from this software without specific
|
||||
# * prior written permission.
|
||||
# *
|
||||
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
# * OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# */
|
||||
#
|
||||
# Copyright 1996 Chih-Hao Tsai @ Beckman Institute,
|
||||
# University of Illinois
|
||||
# c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4
|
||||
#
|
||||
# ---------------COPYING.libtabe-----END--------------------------------
|
||||
#
|
||||
#
|
||||
# ---------------COPYING.ipadic-----BEGIN-------------------------------
|
||||
#
|
||||
# Copyright 2000, 2001, 2002, 2003 Nara Institute of Science
|
||||
# and Technology. All Rights Reserved.
|
||||
#
|
||||
# Use, reproduction, and distribution of this software is permitted.
|
||||
# Any copy of this software, whether in its original form or modified,
|
||||
# must include both the above copyright notice and the following
|
||||
# paragraphs.
|
||||
#
|
||||
# Nara Institute of Science and Technology (NAIST),
|
||||
# the copyright holders, disclaims all warranties with regard to this
|
||||
# software, including all implied warranties of merchantability and
|
||||
# fitness, in no event shall NAIST be liable for
|
||||
# any special, indirect or consequential damages or any damages
|
||||
# whatsoever resulting from loss of use, data or profits, whether in an
|
||||
# action of contract, negligence or other tortuous action, arising out
|
||||
# of or in connection with the use or performance of this software.
|
||||
#
|
||||
# A large portion of the dictionary entries
|
||||
# originate from ICOT Free Software. The following conditions for ICOT
|
||||
# Free Software applies to the current dictionary as well.
|
||||
#
|
||||
# Each User may also freely distribute the Program, whether in its
|
||||
# original form or modified, to any third party or parties, PROVIDED
|
||||
# that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear
|
||||
# on, or be attached to, the Program, which is distributed substantially
|
||||
# in the same form as set out herein and that such intended
|
||||
# distribution, if actually made, will neither violate or otherwise
|
||||
# contravene any of the laws and regulations of the countries having
|
||||
# jurisdiction over the User or the intended distribution itself.
|
||||
#
|
||||
# NO WARRANTY
|
||||
#
|
||||
# The program was produced on an experimental basis in the course of the
|
||||
# research and development conducted during the project and is provided
|
||||
# to users as so produced on an experimental basis. Accordingly, the
|
||||
# program is provided without any warranty whatsoever, whether express,
|
||||
# implied, statutory or otherwise. The term "warranty" used herein
|
||||
# includes, but is not limited to, any warranty of the quality,
|
||||
# performance, merchantability and fitness for a particular purpose of
|
||||
# the program and the nonexistence of any infringement or violation of
|
||||
# any right of any third party.
|
||||
#
|
||||
# Each user of the program will agree and understand, and be deemed to
|
||||
# have agreed and understood, that there is no warranty whatsoever for
|
||||
# the program and, accordingly, the entire risk arising from or
|
||||
# otherwise connected with the program is assumed by the user.
|
||||
#
|
||||
# Therefore, neither ICOT, the copyright holder, or any other
|
||||
# organization that participated in or was otherwise related to the
|
||||
# development of the program and their respective officials, directors,
|
||||
# officers and other employees shall be held liable for any and all
|
||||
# damages, including, without limitation, general, special, incidental
|
||||
# and consequential damages, arising out of or otherwise in connection
|
||||
# with the use or inability to use the program or any product, material
|
||||
# or result produced or otherwise obtained by using the program,
|
||||
# regardless of whether they have been advised of, or otherwise had
|
||||
# knowledge of, the possibility of such damages at any time during the
|
||||
# project or thereafter. Each user will be deemed to have agreed to the
|
||||
# foregoing by his or her commencement of use of the program. The term
|
||||
# "use" as used herein includes, but is not limited to, the use,
|
||||
# modification, copying and distribution of the program and the
|
||||
# production of secondary products from the program.
|
||||
#
|
||||
# In the case where the program, whether in its original form or
|
||||
# modified, was distributed or delivered to or received by a user from
|
||||
# any person, organization or entity other than ICOT, unless it makes or
|
||||
# grants independently of ICOT any specific warranty to the user in
|
||||
# writing, such person, organization or entity, will also be exempted
|
||||
# from and not be held liable to the user for any such damages as noted
|
||||
# above as far as the program is concerned.
|
||||
#
|
||||
# ---------------COPYING.ipadic-----END----------------------------------
|
||||
|
||||
3. Lao Word Break Dictionary Data (laodict.txt)
|
||||
|
||||
# Copyright (c) 2013 International Business Machines Corporation
|
||||
# and others. All Rights Reserved.
|
||||
#
|
||||
# Project: http://code.google.com/p/lao-dictionary/
|
||||
# Dictionary: http://lao-dictionary.googlecode.com/git/Lao-Dictionary.txt
|
||||
# License: http://lao-dictionary.googlecode.com/git/Lao-Dictionary-LICENSE.txt
|
||||
# (copied below)
|
||||
#
|
||||
# This file is derived from the above dictionary, with slight
|
||||
# modifications.
|
||||
# ----------------------------------------------------------------------
|
||||
# Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer. Redistributions in
|
||||
# binary form must reproduce the above copyright notice, this list of
|
||||
# conditions and the following disclaimer in the documentation and/or
|
||||
# other materials provided with the distribution.
|
||||
#
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
# OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
4. Burmese Word Break Dictionary Data (burmesedict.txt)
|
||||
|
||||
# Copyright (c) 2014 International Business Machines Corporation
|
||||
# and others. All Rights Reserved.
|
||||
#
|
||||
# This list is part of a project hosted at:
|
||||
# github.com/kanyawtech/myanmar-karen-word-lists
|
||||
#
|
||||
# --------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, LeRoy Benjamin Sharon
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met: Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer. Redistributions in binary form must reproduce the
|
||||
# above copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# Neither the name Myanmar Karen Word Lists, nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
5. Time Zone Database
|
||||
|
||||
ICU uses the public domain data and code derived from Time Zone
|
||||
Database for its time zone support. The ownership of the TZ database
|
||||
is explained in BCP 175: Procedure for Maintaining the Time Zone
|
||||
Database section 7.
|
||||
|
||||
# 7. Database Ownership
|
||||
#
|
||||
# The TZ database itself is not an IETF Contribution or an IETF
|
||||
# document. Rather it is a pre-existing and regularly updated work
|
||||
# that is in the public domain, and is intended to remain in the
|
||||
# public domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do
|
||||
# not apply to the TZ Database or contributions that individuals make
|
||||
# to it. Should any claims be made and substantiated against the TZ
|
||||
# Database, the organization that is providing the IANA
|
||||
# Considerations defined in this RFC, under the memorandum of
|
||||
# understanding with the IETF, currently ICANN, may act in accordance
|
||||
# with all competent court orders. No ownership claims will be made
|
||||
# by ICANN or the IETF Trust on the database or the code. Any person
|
||||
# making a contribution to the database or code waives all rights to
|
||||
# future claims in that contribution or in the TZ Database.
|
||||
|
|
|
@ -1,25 +1,11 @@
|
|||
## The Unicode Standard, Unicode Character Database, Version 11.0.0
|
||||
|
||||
## The Unicode Standard, Unicode Character Database, Version 12.1.0
|
||||
|
||||
### Unicode Character Database
|
||||
|
||||
```
|
||||
|
||||
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
|
||||
Unicode Data Files include all data files under the directories
|
||||
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
|
||||
http://www.unicode.org/cldr/data/,
|
||||
http://source.icu-project.org/repos/icu/, and
|
||||
http://www.unicode.org/utility/trac/browser/.
|
||||
|
||||
Unicode Data Files do not include PDF online code charts under the
|
||||
directory http://www.unicode.org/Public/.
|
||||
|
||||
Software includes any source code published in the Unicode Standard
|
||||
or under the directories
|
||||
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
|
||||
http://www.unicode.org/cldr/data/,
|
||||
http://source.icu-project.org/repos/icu/, and
|
||||
http://www.unicode.org/utility/trac/browser/.
|
||||
See Terms of Use for definitions of Unicode Inc.'s
|
||||
Data Files and Software.
|
||||
|
||||
NOTICE TO USER: Carefully read the following legal agreement.
|
||||
BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
|
||||
|
@ -31,8 +17,8 @@ THE DATA FILES OR SOFTWARE.
|
|||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright © 1991-2018 Unicode, Inc. All rights reserved.
|
||||
Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
|
||||
Copyright © 1991-2019 Unicode, Inc. All rights reserved.
|
||||
Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Unicode data files and any associated documentation
|
||||
|
@ -62,5 +48,3 @@ Except as contained in this notice, the name of a copyright holder
|
|||
shall not be used in advertising or otherwise to promote the sale,
|
||||
use or other dealings in these Data Files or Software without prior
|
||||
written authorization of the copyright holder.
|
||||
|
||||
```
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -38,6 +38,7 @@
|
|||
|
||||
#define ARG_INFO_ENVVAR "NOTE: Picked up %s: %s"
|
||||
#define ARG_WARN "Warning: %s option is no longer supported."
|
||||
#define ARG_DEPRECATED "Warning: %s option is deprecated and may be removed in a future release."
|
||||
|
||||
#define ARG_ERROR1 "Error: %s requires class path specification"
|
||||
#define ARG_ERROR2 "Error: %s requires jar file specification"
|
||||
|
|
|
@ -1430,12 +1430,17 @@ ParseArguments(int *pargc, char ***pargv,
|
|||
} else if (JLI_StrCmp(arg, "-noclassgc") == 0) {
|
||||
AddOption("-Xnoclassgc", NULL);
|
||||
} else if (JLI_StrCmp(arg, "-Xfuture") == 0) {
|
||||
JLI_ReportErrorMessage(ARG_DEPRECATED, "-Xfuture");
|
||||
AddOption("-Xverify:all", NULL);
|
||||
} else if (JLI_StrCmp(arg, "-verify") == 0) {
|
||||
AddOption("-Xverify:all", NULL);
|
||||
} else if (JLI_StrCmp(arg, "-verifyremote") == 0) {
|
||||
AddOption("-Xverify:remote", NULL);
|
||||
} else if (JLI_StrCmp(arg, "-noverify") == 0) {
|
||||
/*
|
||||
* Note that no 'deprecated' message is needed here because the VM
|
||||
* issues 'deprecated' messages for -noverify and -Xverify:none.
|
||||
*/
|
||||
AddOption("-Xverify:none", NULL);
|
||||
} else if (JLI_StrCCmp(arg, "-ss") == 0 ||
|
||||
JLI_StrCCmp(arg, "-oss") == 0 ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue