This commit is contained in:
Jayathirth D V 2018-10-16 14:26:22 +05:30
commit eb1b046a1d
866 changed files with 13210 additions and 11938 deletions

View file

@ -253,11 +253,10 @@ final class CipherCore {
return result;
}
/**
* Sets the padding mechanism of this cipher.
*
* @param padding the padding mechanism
* @param paddingScheme the padding mechanism
*
* @exception NoSuchPaddingException if the requested padding mechanism
* does not exist
@ -660,10 +659,7 @@ final class CipherCore {
* (e.g., has not been initialized)
*/
byte[] update(byte[] input, int inputOffset, int inputLen) {
if (requireReinit) {
throw new IllegalStateException
("Must use either different key or iv for GCM encryption");
}
checkReinit();
byte[] output = null;
try {
@ -711,10 +707,7 @@ final class CipherCore {
*/
int update(byte[] input, int inputOffset, int inputLen, byte[] output,
int outputOffset) throws ShortBufferException {
if (requireReinit) {
throw new IllegalStateException
("Must use either different key or iv for GCM encryption");
}
checkReinit();
// figure out how much can be sent to crypto function
int len = Math.addExact(buffered, inputLen);
@ -849,12 +842,20 @@ final class CipherCore {
*/
byte[] doFinal(byte[] input, int inputOffset, int inputLen)
throws IllegalBlockSizeException, BadPaddingException {
byte[] output = null;
try {
output = new byte[getOutputSizeByOperation(inputLen, true)];
int len = doFinal(input, inputOffset, inputLen, output, 0);
if (len < output.length) {
byte[] copy = Arrays.copyOf(output, len);
checkReinit();
byte[] output = new byte[getOutputSizeByOperation(inputLen, true)];
byte[] finalBuf = prepareInputBuffer(input, inputOffset,
inputLen, output, 0);
int finalOffset = (finalBuf == input) ? inputOffset : 0;
int finalBufLen = (finalBuf == input) ? inputLen : finalBuf.length;
int outLen = fillOutputBuffer(finalBuf, finalOffset, output, 0,
finalBufLen, input);
endDoFinal();
if (outLen < output.length) {
byte[] copy = Arrays.copyOf(output, outLen);
if (decrypting) {
// Zero out internal (ouput) array
Arrays.fill(output, (byte) 0x00);
@ -909,26 +910,81 @@ final class CipherCore {
int outputOffset)
throws IllegalBlockSizeException, ShortBufferException,
BadPaddingException {
if (requireReinit) {
throw new IllegalStateException
("Must use either different key or iv for GCM encryption");
}
checkReinit();
int estOutSize = getOutputSizeByOperation(inputLen, true);
// check output buffer capacity.
// if we are decrypting with padding applied, we can perform this
// check only after we have determined how many padding bytes there
// are.
int outputCapacity = output.length - outputOffset;
int minOutSize = (decrypting? (estOutSize - blockSize):estOutSize);
if ((output == null) || (outputCapacity < minOutSize)) {
throw new ShortBufferException("Output buffer must be "
+ "(at least) " + minOutSize + " bytes long");
}
int outputCapacity = checkOutputCapacity(output, outputOffset,
estOutSize);
int offset = decrypting ? 0 : outputOffset; // 0 for decrypting
byte[] finalBuf = prepareInputBuffer(input, inputOffset,
inputLen, output, outputOffset);
byte[] outWithPadding = null; // for decrypting only
int finalOffset = (finalBuf == input) ? inputOffset : 0;
int finalBufLen = (finalBuf == input) ? inputLen : finalBuf.length;
if (decrypting) {
// if the size of specified output buffer is less than
// the length of the cipher text, then the current
// content of cipher has to be preserved in order for
// users to retry the call with a larger buffer in the
// case of ShortBufferException.
if (outputCapacity < estOutSize) {
cipher.save();
}
// create temporary output buffer so that only "real"
// data bytes are passed to user's output buffer.
outWithPadding = new byte[estOutSize];
}
byte[] outBuffer = decrypting ? outWithPadding : output;
int outLen = fillOutputBuffer(finalBuf, finalOffset, outBuffer,
offset, finalBufLen, input);
if (decrypting) {
if (outputCapacity < outLen) {
// restore so users can retry with a larger buffer
cipher.restore();
throw new ShortBufferException("Output buffer too short: "
+ (outputCapacity)
+ " bytes given, " + outLen
+ " bytes needed");
}
// copy the result into user-supplied output buffer
System.arraycopy(outWithPadding, 0, output, outputOffset, outLen);
// decrypt mode. Zero out output data that's not required
Arrays.fill(outWithPadding, (byte) 0x00);
}
endDoFinal();
return outLen;
}
private void endDoFinal() {
buffered = 0;
diffBlocksize = blockSize;
if (cipherMode != ECB_MODE) {
cipher.reset();
}
}
private int unpad(int outLen, byte[] outWithPadding)
throws BadPaddingException {
int padStart = padding.unpad(outWithPadding, 0, outLen);
if (padStart < 0) {
throw new BadPaddingException("Given final block not " +
"properly padded. Such issues can arise if a bad key " +
"is used during decryption.");
}
outLen = padStart;
return outLen;
}
private byte[] prepareInputBuffer(byte[] input, int inputOffset,
int inputLen, byte[] output, int outputOffset)
throws IllegalBlockSizeException, ShortBufferException {
// calculate total input length
int len = Math.addExact(buffered, inputLen);
// calculate padding length
int totalLen = Math.addExact(len, cipher.getBufferedLength());
int paddingLen = 0;
@ -958,18 +1014,15 @@ final class CipherCore {
* - there are internally buffered bytes
* - doing encryption and padding is needed
*/
byte[] finalBuf = input;
int finalOffset = inputOffset;
int finalBufLen = inputLen;
if ((buffered != 0) || (!decrypting && padding != null) ||
((input == output)
&& (outputOffset - inputOffset < inputLen)
&& (inputOffset - outputOffset < buffer.length))) {
byte[] finalBuf;
if (decrypting || padding == null) {
paddingLen = 0;
}
finalBuf = new byte[Math.addExact(len, paddingLen)];
finalOffset = 0;
if (buffered != 0) {
System.arraycopy(buffer, 0, finalBuf, 0, buffered);
if (!decrypting) {
@ -980,56 +1033,31 @@ final class CipherCore {
}
if (inputLen != 0) {
System.arraycopy(input, inputOffset, finalBuf,
buffered, inputLen);
buffered, inputLen);
}
if (paddingLen != 0) {
padding.padWithLen(finalBuf, Math.addExact(buffered, inputLen), paddingLen);
}
finalBufLen = finalBuf.length;
return finalBuf;
}
int outLen = 0;
if (decrypting) {
// if the size of specified output buffer is less than
// the length of the cipher text, then the current
// content of cipher has to be preserved in order for
// users to retry the call with a larger buffer in the
// case of ShortBufferException.
if (outputCapacity < estOutSize) {
cipher.save();
}
// create temporary output buffer so that only "real"
// data bytes are passed to user's output buffer.
byte[] outWithPadding = new byte[estOutSize];
outLen = finalNoPadding(finalBuf, finalOffset, outWithPadding,
0, finalBufLen);
return input;
}
if (padding != null) {
int padStart = padding.unpad(outWithPadding, 0, outLen);
if (padStart < 0) {
throw new BadPaddingException("Given final block not " +
"properly padded. Such issues can arise if a bad key " +
"is used during decryption.");
}
outLen = padStart;
private int fillOutputBuffer(byte[] finalBuf, int finalOffset,
byte[] output, int outOfs, int finalBufLen,
byte[] input)
throws ShortBufferException, BadPaddingException,
IllegalBlockSizeException {
int len;
try {
len = finalNoPadding(finalBuf, finalOffset, output,
outOfs, finalBufLen);
if (decrypting && padding != null) {
len = unpad(len, output);
}
if (outputCapacity < outLen) {
// restore so users can retry with a larger buffer
cipher.restore();
throw new ShortBufferException("Output buffer too short: "
+ (outputCapacity)
+ " bytes given, " + outLen
+ " bytes needed");
}
// copy the result into user-supplied output buffer
System.arraycopy(outWithPadding, 0, output, outputOffset, outLen);
// decrypt mode. Zero out output data that's not required
Arrays.fill(outWithPadding, (byte) 0x00);
} else { // encrypting
try {
outLen = finalNoPadding(finalBuf, finalOffset, output,
outputOffset, finalBufLen);
} finally {
return len;
} finally {
if (!decrypting) {
// reset after doFinal() for GCM encryption
requireReinit = (cipherMode == GCM_MODE);
if (finalBuf != input) {
@ -1038,13 +1066,28 @@ final class CipherCore {
}
}
}
}
buffered = 0;
diffBlocksize = blockSize;
if (cipherMode != ECB_MODE) {
cipher.reset();
private int checkOutputCapacity(byte[] output, int outputOffset,
int estOutSize) throws ShortBufferException {
// check output buffer capacity.
// if we are decrypting with padding applied, we can perform this
// check only after we have determined how many padding bytes there
// are.
int outputCapacity = output.length - outputOffset;
int minOutSize = decrypting ? (estOutSize - blockSize) : estOutSize;
if ((output == null) || (outputCapacity < minOutSize)) {
throw new ShortBufferException("Output buffer must be "
+ "(at least) " + minOutSize + " bytes long");
}
return outputCapacity;
}
private void checkReinit() {
if (requireReinit) {
throw new IllegalStateException
("Must use either different key or iv for GCM encryption");
}
return outLen;
}
private int finalNoPadding(byte[] in, int inOfs, byte[] out, int outOfs,
@ -1177,10 +1220,7 @@ final class CipherCore {
* @since 1.8
*/
void updateAAD(byte[] src, int offset, int len) {
if (requireReinit) {
throw new IllegalStateException
("Must use either different key or iv for GCM encryption");
}
checkReinit();
cipher.updateAAD(src, offset, len);
}
}

View file

@ -71,7 +71,9 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
*/
private final String path;
private final AtomicBoolean closed = new AtomicBoolean(false);
private final Object closeLock = new Object();
private volatile boolean closed;
private static final int O_RDONLY = 1;
private static final int O_RDWR = 2;
@ -301,7 +303,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
if (fc == null) {
this.channel = fc = FileChannelImpl.open(fd, path, true,
rw, false, this);
if (closed.get()) {
if (closed) {
try {
fc.close();
} catch (IOException ioe) {
@ -638,14 +640,21 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @spec JSR-51
*/
public void close() throws IOException {
if (!closed.compareAndSet(false, true)) {
// if compareAndSet() returns false closed was already true
if (closed) {
return;
}
synchronized (closeLock) {
if (closed) {
return;
}
closed = true;
}
FileChannel fc = channel;
if (fc != null) {
fc.close();
// possible race with getChannel(), benign since
// FileChannel.close is final and idempotent
fc.close();
}
fd.closeAll(new Closeable() {

View file

@ -5385,7 +5385,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
0x3260, // 3260..327E; HANGUL
0x327F, // 327F..32CF; COMMON
0x32D0, // 32D0..32FE; KATAKANA
0x32FF, // 32FF ; UNKNOWN
0x32FF, // 32FF ; COMMON
0x3300, // 3300..3357; KATAKANA
0x3358, // 3358..33FF; COMMON
0x3400, // 3400..4DB5; HAN
@ -6902,7 +6902,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
HANGUL, // 3260..327E
COMMON, // 327F..32CF
KATAKANA, // 32D0..32FE
UNKNOWN, // 32FF
COMMON, // 32FF
KATAKANA, // 3300..3357
COMMON, // 3358..33FF
HAN, // 3400..4DB5

View file

@ -64,7 +64,6 @@ import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.loader.BootLoader;
import jdk.internal.loader.BuiltinClassLoader;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.module.Resources;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.ConstantPool;
@ -540,11 +539,9 @@ public final class Class<T> implements java.io.Serializable,
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false);
}
// NOTE: the following code may not be strictly correct under
// the current Java memory model.
// Constructor lookup
if (cachedConstructor == null) {
Constructor<T> tmpConstructor = cachedConstructor;
if (tmpConstructor == null) {
if (this == Class.class) {
throw new IllegalAccessException(
"Can not call newInstance() on the Class for java.lang.Class"
@ -555,9 +552,7 @@ public final class Class<T> implements java.io.Serializable,
final Constructor<T> c = getReflectionFactory().copyConstructor(
getConstructor0(empty, Member.DECLARED));
// Disable accessibility checks on the constructor
// since we have to do the security check here anyway
// (the stack depth is wrong for the Constructor's
// security check to work)
// access check is done with the true caller
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<>() {
public Void run() {
@ -565,32 +560,24 @@ public final class Class<T> implements java.io.Serializable,
return null;
}
});
cachedConstructor = c;
cachedConstructor = tmpConstructor = c;
} catch (NoSuchMethodException e) {
throw (InstantiationException)
new InstantiationException(getName()).initCause(e);
}
}
Constructor<T> tmpConstructor = cachedConstructor;
// Security check (same as in java.lang.reflect.Constructor)
Class<?> caller = Reflection.getCallerClass();
if (newInstanceCallerCache != caller) {
int modifiers = tmpConstructor.getModifiers();
Reflection.ensureMemberAccess(caller, this, this, modifiers);
newInstanceCallerCache = caller;
}
// Run constructor
try {
return tmpConstructor.newInstance((Object[])null);
Class<?> caller = Reflection.getCallerClass();
return getReflectionFactory().newInstance(tmpConstructor, null, caller);
} catch (InvocationTargetException e) {
Unsafe.getUnsafe().throwException(e.getTargetException());
// Not reached
return null;
}
}
private transient volatile Constructor<T> cachedConstructor;
private transient volatile Class<?> newInstanceCallerCache;
private transient volatile Constructor<T> cachedConstructor;
/**
* Determines if the specified {@code Object} is assignment-compatible

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -477,7 +477,7 @@ public final class Module implements AnnotatedElement {
*
* @see ModuleDescriptor#opens()
* @see #addOpens(String,Module)
* @see AccessibleObject#setAccessible(boolean)
* @see java.lang.reflect.AccessibleObject#setAccessible(boolean)
* @see java.lang.invoke.MethodHandles#privateLookupIn
*/
public boolean isOpen(String pn, Module other) {
@ -747,7 +747,7 @@ public final class Module implements AnnotatedElement {
* package to at least the caller's module
*
* @see #isOpen(String,Module)
* @see AccessibleObject#setAccessible(boolean)
* @see java.lang.reflect.AccessibleObject#setAccessible(boolean)
* @see java.lang.invoke.MethodHandles#privateLookupIn
*/
@CallerSensitive
@ -1061,7 +1061,10 @@ public final class Module implements AnnotatedElement {
* @return a map of module name to runtime {@code Module}
*
* @throws IllegalArgumentException
* If defining any of the modules to the VM fails
* If the function maps a module to the null or platform class loader
* @throws IllegalStateException
* If the module cannot be defined to the VM or its packages overlap
* with another module mapped to the same class loader
*/
static Map<String, Module> defineModules(Configuration cf,
Function<String, ClassLoader> clf,

View file

@ -28,7 +28,6 @@ package java.lang;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Exports;
import java.lang.module.ModuleDescriptor.Opens;
import java.lang.module.ModuleReference;
import java.lang.reflect.Member;
import java.io.FileDescriptor;
import java.io.File;
@ -47,9 +46,7 @@ import java.util.Objects;
import java.util.PropertyPermission;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import jdk.internal.module.ModuleBootstrap;
import jdk.internal.module.ModuleLoaderMap;
import jdk.internal.reflect.CallerSensitive;
import sun.security.util.SecurityConstants;
@ -81,10 +78,100 @@ import sun.security.util.SecurityConstants;
* throws a <code>SecurityException</code> if the operation is not
* permitted.
* <p>
* The current security manager is set by the
* <code>setSecurityManager</code> method in class
* <code>System</code>. The current security manager is obtained
* by the <code>getSecurityManager</code> method.
* Environments using a security manager will typically set the security
* manager at startup. In the JDK implementation, this is done by setting
* the system property {@code java.security.manager} on the command line to
* the class name of the security manager. It can also be set to the empty
* String ("") or the special token "{@code default}" to use the
* default {@code java.lang.SecurityManager}. If a class name is specified,
* it must be {@code java.lang.SecurityManager} or a public subclass and have
* a public no-arg constructor. The class is loaded by the
* {@linkplain ClassLoader#getSystemClassLoader() built-in system class loader}
* if it is not {@code java.lang.SecurityManager}. If the
* {@code java.security.manager} system property is not set, the default value
* is {@code null}, which means a security manager will not be set at startup.
* <p>
* The Java run-time may also allow, but is not required to allow, the security
* manager to be set dynamically by invoking the
* {@link System#setSecurityManager(SecurityManager) setSecurityManager} method.
* In the JDK implementation, if the Java virtual machine is started with
* the {@code java.security.manager} system property set to the special token
* "{@code disallow}" then a security manager will not be set at startup and
* cannot be set dynamically (the
* {@link System#setSecurityManager(SecurityManager) setSecurityManager}
* method will throw an {@code UnsupportedOperationException}). If the
* {@code java.security.manager} system property is not set or is set to the
* special token "{@code allow}", then a security manager will not be set at
* startup but can be set dynamically. Finally, if the
* {@code java.security.manager} system property is set to the class name of
* the security manager, or to the empty String ("") or the special token
* "{@code default}", then a security manager is set at startup (as described
* previously) and can also be subsequently replaced (or disabled) dynamically
* (subject to the policy of the currently installed security manager). The
* following table illustrates the behavior of the JDK implementation for the
* different settings of the {@code java.security.manager} system property:
* <table class="striped">
* <caption style="display:none">property value,
* the SecurityManager set at startup,
* can dynamically set a SecurityManager
* </caption>
* <thead>
* <tr>
* <th scope="col">Property Value</th>
* <th scope="col">The SecurityManager set at startup</th>
* <th scope="col">System.setSecurityManager run-time behavior</th>
* </tr>
* </thead>
* <tbody>
*
* <tr>
* <th scope="row">null</th>
* <td>None</td>
* <td>Success or throws {@code SecurityException} if not permitted by
* the currently installed security manager</td>
* </tr>
*
* <tr>
* <th scope="row">empty String ("")</th>
* <td>{@code java.lang.SecurityManager}</td>
* <td>Success or throws {@code SecurityException} if not permitted by
* the currently installed security manager</td>
* </tr>
*
* <tr>
* <th scope="row">"default"</th>
* <td>{@code java.lang.SecurityManager}</td>
* <td>Success or throws {@code SecurityException} if not permitted by
* the currently installed security manager</td>
* </tr>
*
* <tr>
* <th scope="row">"disallow"</th>
* <td>None</td>
* <td>Always throws {@code UnsupportedOperationException}</td>
* </tr>
*
* <tr>
* <th scope="row">"allow"</th>
* <td>None</td>
* <td>Success or throws {@code SecurityException} if not permitted by
* the currently installed security manager</td>
* </tr>
*
* <tr>
* <th scope="row">a class name</th>
* <td>the named class</td>
* <td>Success or throws {@code SecurityException} if not permitted by
* the currently installed security manager</td>
* </tr>
*
* </tbody>
* </table>
* <p> A future release of the JDK may change the default value of the
* {@code java.security.manager} system property to "{@code disallow}".
* <p>
* The current security manager is returned by the
* {@link System#getSecurityManager() getSecurityManager} method.
* <p>
* The special method
* {@link SecurityManager#checkPermission(java.security.Permission)}
@ -221,7 +308,6 @@ import sun.security.util.SecurityConstants;
* @see java.net.SocketPermission
* @see java.util.PropertyPermission
* @see java.lang.RuntimePermission
* @see java.awt.AWTPermission
* @see java.security.Policy Policy
* @see java.security.SecurityPermission SecurityPermission
* @see java.security.ProtectionDomain

View file

@ -72,6 +72,7 @@ import jdk.internal.misc.VM;
import jdk.internal.logger.LoggerFinderLoader;
import jdk.internal.logger.LazyLoggers;
import jdk.internal.logger.LocalizedLoggerWrapper;
import jdk.internal.vm.annotation.Stable;
import sun.reflect.annotation.AnnotationType;
import sun.nio.ch.Interruptible;
import sun.security.util.SecurityConstants;
@ -154,9 +155,18 @@ public final class System {
*/
public static final PrintStream err = null;
/* The security manager for the system.
*/
private static volatile SecurityManager security;
// indicates if a security manager is possible
private static final int NEVER = 1;
private static final int MAYBE = 2;
private static @Stable int allowSecurityManager;
// current security manager
private static volatile SecurityManager security; // read by VM
// return true if a security manager is allowed
private static boolean allowSecurityManager() {
return (allowSecurityManager != NEVER);
}
/**
* Reassigns the "standard" input stream.
@ -231,6 +241,7 @@ public final class System {
}
private static volatile Console cons;
/**
* Returns the unique {@link java.io.Console Console} object associated
* with the current Java virtual machine, if any.
@ -292,7 +303,7 @@ public final class System {
private static native void setErr0(PrintStream err);
/**
* Sets the System security.
* Sets the system-wide security manager.
*
* If there is a security manager already installed, this method first
* calls the security manager's {@code checkPermission} method
@ -306,27 +317,46 @@ public final class System {
* security manager has been established, then no action is taken and
* the method simply returns.
*
* @param s the security manager.
* @throws SecurityException if the security manager has already
* been set and its {@code checkPermission} method
* doesn't allow it to be replaced.
* @implNote In the JDK implementation, if the Java virtual machine is
* started with the system property {@code java.security.manager} set to
* the special token "{@code disallow}" then the {@code setSecurityManager}
* method cannot be used to set a security manager.
*
* @param sm the security manager or {@code null}
* @throws SecurityException
* if the security manager has already been set and its {@code
* checkPermission} method doesn't allow it to be replaced
* @throws UnsupportedOperationException
* if {@code sm} is non-null and a security manager is not allowed
* to be set dynamically
* @see #getSecurityManager
* @see SecurityManager#checkPermission
* @see java.lang.RuntimePermission
*/
public static void setSecurityManager(final SecurityManager s) {
if (security == null) {
// ensure image reader is initialized
Object.class.getResource("java/lang/ANY");
}
if (s != null) {
try {
s.checkPackageAccess("java.lang");
} catch (Exception e) {
// no-op
public static void setSecurityManager(SecurityManager sm) {
if (allowSecurityManager()) {
if (security == null) {
// ensure image reader is initialized
Object.class.getResource("java/lang/ANY");
}
if (sm != null) {
try {
// pre-populates the SecurityManager.packageAccess cache
// to avoid recursive permission checking issues with custom
// SecurityManager implementations
sm.checkPackageAccess("java.lang");
} catch (Exception e) {
// no-op
}
}
setSecurityManager0(sm);
} else {
// security manager not allowed
if (sm != null) {
throw new UnsupportedOperationException(
"Runtime configured to disallow security manager");
}
}
setSecurityManager0(s);
}
private static synchronized
@ -335,13 +365,12 @@ public final class System {
if (sm != null) {
// ask the currently installed security manager if we
// can replace it.
sm.checkPermission(new RuntimePermission
("setSecurityManager"));
sm.checkPermission(new RuntimePermission("setSecurityManager"));
}
if ((s != null) && (s.getClass().getClassLoader() != null)) {
// New security manager class is not on bootstrap classpath.
// Cause policy to get initialized before we install the new
// Force policy to get initialized before we install the new
// security manager, in order to prevent infinite loops when
// trying to initialize the policy (which usually involves
// accessing some security and/or system properties, which in turn
@ -361,7 +390,7 @@ public final class System {
}
/**
* Gets the system security interface.
* Gets the system-wide security manager.
*
* @return if a security manager has already been established for the
* current application, then that security manager is returned;
@ -369,7 +398,11 @@ public final class System {
* @see #setSecurityManager
*/
public static SecurityManager getSecurityManager() {
return security;
if (allowSecurityManager()) {
return security;
} else {
return null;
}
}
/**
@ -2028,35 +2061,48 @@ public final class System {
* 3. set TCCL
*
* This method must be called after the module system initialization.
* The security manager and system class loader may be custom class from
* The security manager and system class loader may be a custom class from
* the application classpath or modulepath.
*/
private static void initPhase3() {
// set security manager
String cn = System.getProperty("java.security.manager");
if (cn != null) {
if (cn.isEmpty() || "default".equals(cn)) {
System.setSecurityManager(new SecurityManager());
} else {
try {
Class<?> c = Class.forName(cn, false, ClassLoader.getBuiltinAppClassLoader());
Constructor<?> ctor = c.getConstructor();
// Must be a public subclass of SecurityManager with
// a public no-arg constructor
if (!SecurityManager.class.isAssignableFrom(c) ||
String smProp = System.getProperty("java.security.manager");
if (smProp != null) {
switch (smProp) {
case "disallow":
allowSecurityManager = NEVER;
break;
case "allow":
allowSecurityManager = MAYBE;
break;
case "":
case "default":
setSecurityManager(new SecurityManager());
allowSecurityManager = MAYBE;
break;
default:
try {
ClassLoader cl = ClassLoader.getBuiltinAppClassLoader();
Class<?> c = Class.forName(smProp, false, cl);
Constructor<?> ctor = c.getConstructor();
// Must be a public subclass of SecurityManager with
// a public no-arg constructor
if (!SecurityManager.class.isAssignableFrom(c) ||
!Modifier.isPublic(c.getModifiers()) ||
!Modifier.isPublic(ctor.getModifiers())) {
throw new Error("Could not create SecurityManager: " + ctor.toString());
throw new Error("Could not create SecurityManager: "
+ ctor.toString());
}
// custom security manager may be in non-exported package
ctor.setAccessible(true);
SecurityManager sm = (SecurityManager) ctor.newInstance();
setSecurityManager(sm);
} catch (Exception e) {
throw new InternalError("Could not create SecurityManager", e);
}
// custom security manager implementation may be in unnamed module
// or a named module but non-exported package
ctor.setAccessible(true);
SecurityManager sm = (SecurityManager) ctor.newInstance();
System.setSecurityManager(sm);
} catch (Exception e) {
throw new Error("Could not create SecurityManager", e);
}
allowSecurityManager = MAYBE;
}
} else {
allowSecurityManager = MAYBE;
}
// initializing the system class loader

View file

@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Value-based Classes</title>
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<h2 id="ValueBased">Value-based Classes</h2>

View file

@ -26,7 +26,7 @@
<html lang="en">
<head>
<title>Java Thread Primitive Deprecation</title>
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<h2>Java Thread Primitive Deprecation</h2>

View file

@ -37,7 +37,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -578,23 +577,17 @@ abstract class ClassSpecializer<T,K,S extends ClassSpecializer<T,K,S>.SpeciesDat
InvokerBytecodeGenerator.maybeDump(classBCName(className), classFile);
Class<?> speciesCode;
ClassLoader cl = topClass().getClassLoader();
ProtectionDomain pd = null;
if (cl != null) {
pd = AccessController.doPrivileged(
new PrivilegedAction<>() {
@Override
public ProtectionDomain run() {
return topClass().getProtectionDomain();
}
});
}
try {
speciesCode = UNSAFE.defineClass(className, classFile, 0, classFile.length, cl, pd);
} catch (Exception ex) {
throw newInternalError(ex);
}
MethodHandles.Lookup lookup = IMPL_LOOKUP.in(topClass());
speciesCode = AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Class<?> run() {
try {
return lookup.defineClass(classFile);
} catch (Exception ex) {
throw newInternalError(ex);
}
}
});
return speciesCode.asSubclass(topClass());
}

View file

@ -969,9 +969,6 @@ public class MethodHandles {
ProtectionDomain pd = (loader != null) ? lookupClassProtectionDomain() : null;
String source = "__Lookup_defineClass__";
Class<?> clazz = SharedSecrets.getJavaLangAccess().defineClass(loader, cn, bytes, pd, source);
assert clazz.getClassLoader() == lookupClass.getClassLoader()
&& clazz.getPackageName().equals(lookupClass.getPackageName())
&& protectionDomain(clazz) == lookupClassProtectionDomain();
return clazz;
}

View file

@ -27,6 +27,7 @@ package java.lang.reflect;
import java.lang.annotation.Annotation;
import java.lang.invoke.MethodHandle;
import java.lang.ref.WeakReference;
import java.security.AccessController;
import jdk.internal.misc.VM;
@ -567,21 +568,68 @@ public class AccessibleObject implements AnnotatedElement {
// Shared access checking logic.
// For non-public members or members in package-private classes,
// it is necessary to perform somewhat expensive security checks.
// If the security check succeeds for a given class, it will
// it is necessary to perform somewhat expensive access checks.
// If the access check succeeds for a given class, it will
// always succeed (it is not affected by the granting or revoking
// of permissions); we speed up the check in the common case by
// remembering the last Class for which the check succeeded.
//
// The simple security check for Constructor is to see if
// The simple access check for Constructor is to see if
// the caller has already been seen, verified, and cached.
// (See also Class.newInstance(), which uses a similar method.)
//
// A more complicated security check cache is needed for Method and Field
// The cache can be either null (empty cache), a 2-array of {caller,targetClass},
// A more complicated access check cache is needed for Method and Field
// The cache can be either null (empty cache), {caller,targetClass} pair,
// or a caller (with targetClass implicitly equal to memberClass).
// In the 2-array case, the targetClass is always different from the memberClass.
volatile Object securityCheckCache;
// In the {caller,targetClass} case, the targetClass is always different
// from the memberClass.
volatile Object accessCheckCache;
private static class Cache {
final WeakReference<Class<?>> callerRef;
final WeakReference<Class<?>> targetRef;
Cache(Class<?> caller, Class<?> target) {
this.callerRef = new WeakReference<>(caller);
this.targetRef = new WeakReference<>(target);
}
boolean isCacheFor(Class<?> caller, Class<?> refc) {
return callerRef.get() == caller && targetRef.get() == refc;
}
static Object protectedMemberCallerCache(Class<?> caller, Class<?> refc) {
return new Cache(caller, refc);
}
}
/*
* Returns true if the previous access check was verified for the
* given caller accessing a protected member with an instance of
* the given targetClass where the target class is different than
* the declaring member class.
*/
private boolean isAccessChecked(Class<?> caller, Class<?> targetClass) {
Object cache = accessCheckCache; // read volatile
if (cache instanceof Cache) {
return ((Cache) cache).isCacheFor(caller, targetClass);
}
return false;
}
/*
* Returns true if the previous access check was verified for the
* given caller accessing a static member or an instance member of
* the target class that is the same as the declaring member class.
*/
private boolean isAccessChecked(Class<?> caller) {
Object cache = accessCheckCache; // read volatile
if (cache instanceof WeakReference) {
@SuppressWarnings("unchecked")
WeakReference<Class<?>> ref = (WeakReference<Class<?>>) cache;
return ref.get() == caller;
}
return false;
}
final void checkAccess(Class<?> caller, Class<?> memberClass,
Class<?> targetClass, int modifiers)
@ -603,21 +651,13 @@ public class AccessibleObject implements AnnotatedElement {
if (caller == memberClass) { // quick check
return true; // ACCESS IS OK
}
Object cache = securityCheckCache; // read volatile
if (targetClass != null // instance member or constructor
&& Modifier.isProtected(modifiers)
&& targetClass != memberClass) {
// Must match a 2-list of { caller, targetClass }.
if (cache instanceof Class[]) {
Class<?>[] cache2 = (Class<?>[]) cache;
if (cache2[1] == targetClass &&
cache2[0] == caller) {
return true; // ACCESS IS OK
}
// (Test cache[1] first since range check for [1]
// subsumes range check for [0].)
if (isAccessChecked(caller, targetClass)) {
return true; // ACCESS IS OK
}
} else if (cache == caller) {
} else if (isAccessChecked(caller)) {
// Non-protected case (or targetClass == memberClass or static member).
return true; // ACCESS IS OK
}
@ -642,14 +682,9 @@ public class AccessibleObject implements AnnotatedElement {
Object cache = (targetClass != null
&& Modifier.isProtected(modifiers)
&& targetClass != memberClass)
? new Class<?>[] { caller, targetClass }
: caller;
// Note: The two cache elements are not volatile,
// but they are effectively final. The Java memory model
// guarantees that the initializing stores for the cache
// elements will occur before the volatile write.
securityCheckCache = cache; // write volatile
? Cache.protectedMemberCallerCache(caller, targetClass)
: new WeakReference<>(caller);
accessCheckCache = cache; // write volatile
return true;
}

View file

@ -476,18 +476,27 @@ public final class Constructor<T> extends Executable {
throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException
{
if (!override) {
Class<?> caller = Reflection.getCallerClass();
Class<?> caller = override ? null : Reflection.getCallerClass();
return newInstanceWithCaller(initargs, !override, caller);
}
/* package-private */
T newInstanceWithCaller(Object[] args, boolean checkAccess, Class<?> caller)
throws InstantiationException, IllegalAccessException,
InvocationTargetException
{
if (checkAccess)
checkAccess(caller, clazz, clazz, modifiers);
}
if ((clazz.getModifiers() & Modifier.ENUM) != 0)
throw new IllegalArgumentException("Cannot reflectively create enum objects");
ConstructorAccessor ca = constructorAccessor; // read volatile
if (ca == null) {
ca = acquireConstructorAccessor();
}
@SuppressWarnings("unchecked")
T inst = (T) ca.newInstance(initargs);
T inst = (T) ca.newInstance(args);
return inst;
}

View file

@ -39,12 +39,11 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.internal.loader.BootLoader;
import jdk.internal.misc.JavaLangAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.module.Modules;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
@ -468,7 +467,7 @@ public class Proxy implements java.io.Serializable {
* in which the proxy class will be defined.
*/
private static final class ProxyBuilder {
private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
// prefix for all proxy class names
private static final String proxyClassNamePrefix = "$Proxy";
@ -535,9 +534,8 @@ public class Proxy implements java.io.Serializable {
byte[] proxyClassFile = ProxyGenerator.generateProxyClass(
proxyName, interfaces.toArray(EMPTY_CLASS_ARRAY), accessFlags);
try {
Class<?> pc = UNSAFE.defineClass(proxyName, proxyClassFile,
0, proxyClassFile.length,
loader, null);
Class<?> pc = JLA.defineClass(loader, proxyName, proxyClassFile,
null, "__dynamic_proxy__");
reverseProxyCache.sub(pc).putIfAbsent(loader, Boolean.TRUE);
return pc;
} catch (ClassFormatError e) {

View file

@ -159,4 +159,10 @@ class ReflectAccess implements jdk.internal.reflect.LangReflectAccess {
public <T extends AccessibleObject> T getRoot(T obj) {
return (T) obj.getRoot();
}
public <T> T newInstance(Constructor<T> ctor, Object[] args, Class<?> caller)
throws IllegalAccessException, InstantiationException, InvocationTargetException
{
return ctor.newInstanceWithCaller(args, true, caller);
}
}

View file

@ -41,6 +41,7 @@ import java.util.concurrent.ThreadLocalRandom;
import jdk.internal.math.DoubleConsts;
import jdk.internal.math.FloatConsts;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
/**
* Immutable arbitrary-precision integers. All operations behave as if
@ -1219,8 +1220,10 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
* Initialize static constant array when class is loaded.
*/
private static final int MAX_CONSTANT = 16;
private static BigInteger posConst[] = new BigInteger[MAX_CONSTANT+1];
private static BigInteger negConst[] = new BigInteger[MAX_CONSTANT+1];
@Stable
private static final BigInteger[] posConst = new BigInteger[MAX_CONSTANT+1];
@Stable
private static final BigInteger[] negConst = new BigInteger[MAX_CONSTANT+1];
/**
* The cache of powers of each radix. This allows us to not have to

View file

@ -232,7 +232,11 @@ class SocketInputStream extends FileInputStream {
* @return the number of immediately available bytes
*/
public int available() throws IOException {
return impl.available();
if (eof) {
return 0;
} else {
return impl.available();
}
}
/**

View file

@ -1519,7 +1519,7 @@ public final class Duration
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(1); // identifies a Duration

View file

@ -1332,7 +1332,7 @@ public final class Instant
// -----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(2); // identifies an Instant

View file

@ -2189,7 +2189,7 @@ public final class LocalDate
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(3); // identifies a LocalDate

View file

@ -1975,12 +1975,12 @@ public final class LocalDateTime
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(5); // identifies a LocalDateTime
* // the <a href="../../serialized-form.html#java.time.LocalDate">date</a> excluding the one byte header
* // the <a href="../../serialized-form.html#java.time.LocalTime">time</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.LocalDate">date</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.LocalTime">time</a> excluding the one byte header
* </pre>
*
* @return the instance of {@code Ser}, not null

View file

@ -1645,7 +1645,7 @@ public final class LocalTime
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* A twos-complement value indicates the remaining values are not in the stream
* and should be set to zero.

View file

@ -754,7 +754,7 @@ public final class MonthDay
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(13); // identifies a MonthDay

View file

@ -1915,12 +1915,12 @@ public final class OffsetDateTime
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(10); // identifies an OffsetDateTime
* // the <a href="../../serialized-form.html#java.time.LocalDateTime">datetime</a> excluding the one byte header
* // the <a href="../../serialized-form.html#java.time.ZoneOffset">offset</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.LocalDateTime">datetime</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.ZoneOffset">offset</a> excluding the one byte header
* </pre>
*
* @return the instance of {@code Ser}, not null

View file

@ -1400,12 +1400,12 @@ public final class OffsetTime
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(9); // identifies an OffsetTime
* // the <a href="../../serialized-form.html#java.time.LocalTime">time</a> excluding the one byte header
* // the <a href="../../serialized-form.html#java.time.ZoneOffset">offset</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.LocalTime">time</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.ZoneOffset">offset</a> excluding the one byte header
* </pre>
*
* @return the instance of {@code Ser}, not null

View file

@ -1041,7 +1041,7 @@ public final class Period
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(14); // identifies a Period

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -139,20 +139,20 @@ final class Ser implements Externalizable {
* in the stream. Refer to each class {@code writeReplace}
* serialized form for the value of the type and sequence of values for the type.
* <ul>
* <li><a href="../../serialized-form.html#java.time.Duration">Duration.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.Instant">Instant.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.LocalDate">LocalDate.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.LocalDateTime">LocalDateTime.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.LocalTime">LocalTime.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.MonthDay">MonthDay.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.OffsetTime">OffsetTime.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.OffsetDateTime">OffsetDateTime.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.Period">Period.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.Year">Year.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.YearMonth">YearMonth.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.ZoneId">ZoneId.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.ZoneOffset">ZoneOffset.writeReplace</a>
* <li><a href="../../serialized-form.html#java.time.ZonedDateTime">ZonedDateTime.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.Duration">Duration.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.Instant">Instant.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.LocalDate">LocalDate.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.LocalDateTime">LocalDateTime.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.LocalTime">LocalTime.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.MonthDay">MonthDay.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.OffsetTime">OffsetTime.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.OffsetDateTime">OffsetDateTime.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.Period">Period.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.Year">Year.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.YearMonth">YearMonth.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.ZoneId">ZoneId.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.ZoneOffset">ZoneOffset.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.ZonedDateTime">ZonedDateTime.writeReplace</a>
* </ul>
*
* @param out the data stream to write to, not null
@ -223,20 +223,20 @@ final class Ser implements Externalizable {
* {@code Ser} object.
*
* <ul>
* <li><a href="../../serialized-form.html#java.time.Duration">Duration</a> - {@code Duration.ofSeconds(seconds, nanos);}
* <li><a href="../../serialized-form.html#java.time.Instant">Instant</a> - {@code Instant.ofEpochSecond(seconds, nanos);}
* <li><a href="../../serialized-form.html#java.time.LocalDate">LocalDate</a> - {@code LocalDate.of(year, month, day);}
* <li><a href="../../serialized-form.html#java.time.LocalDateTime">LocalDateTime</a> - {@code LocalDateTime.of(date, time);}
* <li><a href="../../serialized-form.html#java.time.LocalTime">LocalTime</a> - {@code LocalTime.of(hour, minute, second, nano);}
* <li><a href="../../serialized-form.html#java.time.MonthDay">MonthDay</a> - {@code MonthDay.of(month, day);}
* <li><a href="../../serialized-form.html#java.time.OffsetTime">OffsetTime</a> - {@code OffsetTime.of(time, offset);}
* <li><a href="../../serialized-form.html#java.time.OffsetDateTime">OffsetDateTime</a> - {@code OffsetDateTime.of(dateTime, offset);}
* <li><a href="../../serialized-form.html#java.time.Period">Period</a> - {@code Period.of(years, months, days);}
* <li><a href="../../serialized-form.html#java.time.Year">Year</a> - {@code Year.of(year);}
* <li><a href="../../serialized-form.html#java.time.YearMonth">YearMonth</a> - {@code YearMonth.of(year, month);}
* <li><a href="../../serialized-form.html#java.time.ZonedDateTime">ZonedDateTime</a> - {@code ZonedDateTime.ofLenient(dateTime, offset, zone);}
* <li><a href="../../serialized-form.html#java.time.ZoneId">ZoneId</a> - {@code ZoneId.of(id);}
* <li><a href="../../serialized-form.html#java.time.ZoneOffset">ZoneOffset</a> - {@code (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900));}
* <li><a href="{@docRoot}/serialized-form.html#java.time.Duration">Duration</a> - {@code Duration.ofSeconds(seconds, nanos);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.Instant">Instant</a> - {@code Instant.ofEpochSecond(seconds, nanos);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.LocalDate">LocalDate</a> - {@code LocalDate.of(year, month, day);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.LocalDateTime">LocalDateTime</a> - {@code LocalDateTime.of(date, time);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.LocalTime">LocalTime</a> - {@code LocalTime.of(hour, minute, second, nano);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.MonthDay">MonthDay</a> - {@code MonthDay.of(month, day);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.OffsetTime">OffsetTime</a> - {@code OffsetTime.of(time, offset);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.OffsetDateTime">OffsetDateTime</a> - {@code OffsetDateTime.of(dateTime, offset);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.Period">Period</a> - {@code Period.of(years, months, days);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.Year">Year</a> - {@code Year.of(year);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.YearMonth">YearMonth</a> - {@code YearMonth.of(year, month);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.ZonedDateTime">ZonedDateTime</a> - {@code ZonedDateTime.ofLenient(dateTime, offset, zone);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.ZoneId">ZoneId</a> - {@code ZoneId.of(id);}
* <li><a href="{@docRoot}/serialized-form.html#java.time.ZoneOffset">ZoneOffset</a> - {@code (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900));}
* </ul>
*
* @param in the data to read, not null

View file

@ -1088,7 +1088,7 @@ public final class Year
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(11); // identifies a Year

View file

@ -1212,7 +1212,7 @@ public final class YearMonth
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(12); // identifies a YearMonth

View file

@ -641,7 +641,7 @@ public abstract class ZoneId implements Serializable {
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(7); // identifies a ZoneId (not ZoneOffset)

View file

@ -750,7 +750,7 @@ public final class ZoneOffset
// -----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(8); // identifies a ZoneOffset

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -180,7 +180,7 @@ final class ZoneRegion extends ZoneId implements Serializable {
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(7); // identifies a ZoneId (not ZoneOffset)

View file

@ -2224,13 +2224,13 @@ public final class ZonedDateTime
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(6); // identifies a ZonedDateTime
* // the <a href="../../serialized-form.html#java.time.LocalDateTime">dateTime</a> excluding the one byte header
* // the <a href="../../serialized-form.html#java.time.ZoneOffset">offset</a> excluding the one byte header
* // the <a href="../../serialized-form.html#java.time.ZoneId">zone ID</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.LocalDateTime">dateTime</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.ZoneOffset">offset</a> excluding the one byte header
* // the <a href="{@docRoot}/serialized-form.html#java.time.ZoneId">zone ID</a> excluding the one byte header
* </pre>
*
* @return the instance of {@code Ser}, not null

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -721,7 +721,7 @@ public abstract class AbstractChronology implements Chronology {
//-----------------------------------------------------------------------
/**
* Writes the Chronology using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <pre>
* out.writeByte(1); // identifies this as a Chronology
* out.writeUTF(getId());

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -399,7 +399,7 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
//-----------------------------------------------------------------------
/**
* Writes the ChronoLocalDateTime using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(2); // identifies a ChronoLocalDateTime

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -355,7 +355,7 @@ final class ChronoPeriodImpl
//-----------------------------------------------------------------------
/**
* Writes the Chronology using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <pre>
* out.writeByte(12); // identifies this as a ChronoPeriodImpl
* out.writeUTF(getId()); // the chronology

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -322,7 +322,7 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
//-----------------------------------------------------------------------
/**
* Writes the ChronoZonedDateTime using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(3); // identifies a ChronoZonedDateTime

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1011,7 +1011,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
//-----------------------------------------------------------------------
/**
* Writes the Chronology using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(1); // identifies a Chronology

View file

@ -663,7 +663,7 @@ public final class HijrahDate
/**
* Writes the object using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(6); // identifies a HijrahDate

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -680,7 +680,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa
//-----------------------------------------------------------------------
/**
* Writes the Chronology using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(1); // identifies a Chronology

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -507,7 +507,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
//-----------------------------------------------------------------------
/**
* Writes the Chronology using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(1); // identifies a Chronology

View file

@ -725,7 +725,7 @@ public final class JapaneseDate
/**
* Writes the object using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(4); // identifies a JapaneseDate

View file

@ -395,7 +395,7 @@ public final class JapaneseEra
//-----------------------------------------------------------------------
/**
* Writes the object using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(5); // identifies a JapaneseEra

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -337,7 +337,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial
//-----------------------------------------------------------------------
/**
* Writes the Chronology using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(1); // identifies a Chronology

View file

@ -487,7 +487,7 @@ public final class MinguoDate
/**
* Writes the object using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(8); // identifies a MinguoDate

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -136,18 +136,18 @@ final class Ser implements Externalizable {
* in the stream. Refer to each class {@code writeReplace}
* serialized form for the value of the type and sequence of values for the type.
* <ul>
* <li><a href="../../../serialized-form.html#java.time.chrono.HijrahChronology">HijrahChronology.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.IsoChronology">IsoChronology.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.JapaneseChronology">JapaneseChronology.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.MinguoChronology">MinguoChronology.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.ThaiBuddhistChronology">ThaiBuddhistChronology.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.ChronoLocalDateTimeImpl">ChronoLocalDateTime.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.ChronoZonedDateTimeImpl">ChronoZonedDateTime.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.JapaneseDate">JapaneseDate.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.JapaneseEra">JapaneseEra.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.HijrahDate">HijrahDate.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.MinguoDate">MinguoDate.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.chrono.ThaiBuddhistDate">ThaiBuddhistDate.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.HijrahChronology">HijrahChronology.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.IsoChronology">IsoChronology.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.JapaneseChronology">JapaneseChronology.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.MinguoChronology">MinguoChronology.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.ThaiBuddhistChronology">ThaiBuddhistChronology.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.ChronoLocalDateTimeImpl">ChronoLocalDateTime.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.ChronoZonedDateTimeImpl">ChronoZonedDateTime.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.JapaneseDate">JapaneseDate.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.JapaneseEra">JapaneseEra.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.HijrahDate">HijrahDate.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.MinguoDate">MinguoDate.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.ThaiBuddhistDate">ThaiBuddhistDate.writeReplace</a>
* </ul>
*
* @param out the data stream to write to, not null
@ -202,18 +202,18 @@ final class Ser implements Externalizable {
* {@code Ser} object.
*
* <ul>
* <li><a href="../../../serialized-form.html#java.time.chrono.HijrahChronology">HijrahChronology</a> - Chronology.of(id)
* <li><a href="../../../serialized-form.html#java.time.chrono.IsoChronology">IsoChronology</a> - Chronology.of(id)
* <li><a href="../../../serialized-form.html#java.time.chrono.JapaneseChronology">JapaneseChronology</a> - Chronology.of(id)
* <li><a href="../../../serialized-form.html#java.time.chrono.MinguoChronology">MinguoChronology</a> - Chronology.of(id)
* <li><a href="../../../serialized-form.html#java.time.chrono.ThaiBuddhistChronology">ThaiBuddhistChronology</a> - Chronology.of(id)
* <li><a href="../../../serialized-form.html#java.time.chrono.ChronoLocalDateTimeImpl">ChronoLocalDateTime</a> - date.atTime(time)
* <li><a href="../../../serialized-form.html#java.time.chrono.ChronoZonedDateTimeImpl">ChronoZonedDateTime</a> - dateTime.atZone(offset).withZoneSameLocal(zone)
* <li><a href="../../../serialized-form.html#java.time.chrono.JapaneseDate">JapaneseDate</a> - JapaneseChronology.INSTANCE.date(year, month, dayOfMonth)
* <li><a href="../../../serialized-form.html#java.time.chrono.JapaneseEra">JapaneseEra</a> - JapaneseEra.of(eraValue)
* <li><a href="../../../serialized-form.html#java.time.chrono.HijrahDate">HijrahDate</a> - HijrahChronology chrono.date(year, month, dayOfMonth)
* <li><a href="../../../serialized-form.html#java.time.chrono.MinguoDate">MinguoDate</a> - MinguoChronology.INSTANCE.date(year, month, dayOfMonth)
* <li><a href="../../../serialized-form.html#java.time.chrono.ThaiBuddhistDate">ThaiBuddhistDate</a> - ThaiBuddhistChronology.INSTANCE.date(year, month, dayOfMonth)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.HijrahChronology">HijrahChronology</a> - Chronology.of(id)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.IsoChronology">IsoChronology</a> - Chronology.of(id)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.JapaneseChronology">JapaneseChronology</a> - Chronology.of(id)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.MinguoChronology">MinguoChronology</a> - Chronology.of(id)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.ThaiBuddhistChronology">ThaiBuddhistChronology</a> - Chronology.of(id)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.ChronoLocalDateTimeImpl">ChronoLocalDateTime</a> - date.atTime(time)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.ChronoZonedDateTimeImpl">ChronoZonedDateTime</a> - dateTime.atZone(offset).withZoneSameLocal(zone)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.JapaneseDate">JapaneseDate</a> - JapaneseChronology.INSTANCE.date(year, month, dayOfMonth)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.JapaneseEra">JapaneseEra</a> - JapaneseEra.of(eraValue)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.HijrahDate">HijrahDate</a> - HijrahChronology chrono.date(year, month, dayOfMonth)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.MinguoDate">MinguoDate</a> - MinguoChronology.INSTANCE.date(year, month, dayOfMonth)
* <li><a href="{@docRoot}/serialized-form.html#java.time.chrono.ThaiBuddhistDate">ThaiBuddhistDate</a> - ThaiBuddhistChronology.INSTANCE.date(year, month, dayOfMonth)
* </ul>
*
* @param in the data stream to read from, not null

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -374,7 +374,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements
//-----------------------------------------------------------------------
/**
* Writes the Chronology using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(1); // identifies a Chronology

View file

@ -487,7 +487,7 @@ public final class ThaiBuddhistDate
/**
* Writes the object using a
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
* @serialData
* <pre>
* out.writeByte(10); // identifies a ThaiBuddhistDate

View file

@ -1138,9 +1138,12 @@ public final class DateTimeFormatter {
* <p>
* This returns an immutable formatter capable of formatting and parsing
* the ISO-8601 instant format.
* When formatting, the second-of-minute is always output.
* When formatting, the instant will always be suffixed by 'Z' to indicate UTC.
* The second-of-minute is always output.
* The nano-of-second outputs zero, three, six or nine digits as necessary.
* When parsing, time to at least the seconds field is required.
* When parsing, the behaviour of {@link DateTimeFormatterBuilder#appendOffsetId()}
* will be used to parse the offset, converting the instant to UTC as necessary.
* The time to at least the seconds field is required.
* Fractional seconds from zero to nine are parsed.
* The localized decimal style is not used.
* <p>

View file

@ -837,6 +837,10 @@ public final class DateTimeFormatterBuilder {
* The leap-second time of '23:59:59' is handled to some degree, see
* {@link DateTimeFormatter#parsedLeapSecond()} for full details.
* <p>
* When formatting, the instant will always be suffixed by 'Z' to indicate UTC.
* When parsing, the behaviour of {@link DateTimeFormatterBuilder#appendOffsetId()}
* will be used to parse the offset, converting the instant to UTC as necessary.
* <p>
* An alternative to this method is to format/parse the instant as a single
* epoch-seconds value. That is achieved using {@code appendValue(INSTANT_SECONDS)}.
*
@ -3468,7 +3472,7 @@ public final class DateTimeFormatterBuilder {
.appendValue(MINUTE_OF_HOUR, 2).appendLiteral(':')
.appendValue(SECOND_OF_MINUTE, 2)
.appendFraction(NANO_OF_SECOND, minDigits, maxDigits, true)
.appendLiteral('Z')
.appendOffsetId()
.toFormatter().toPrinterParser(false);
DateTimeParseContext newContext = context.copy();
int pos = parser.parse(newContext, text, position);
@ -3486,6 +3490,7 @@ public final class DateTimeFormatterBuilder {
Long nanoVal = newContext.getParsed(NANO_OF_SECOND);
int sec = (secVal != null ? secVal.intValue() : 0);
int nano = (nanoVal != null ? nanoVal.intValue() : 0);
int offset = newContext.getParsed(OFFSET_SECONDS).intValue();
int days = 0;
if (hour == 24 && min == 0 && sec == 0 && nano == 0) {
hour = 0;
@ -3498,7 +3503,7 @@ public final class DateTimeFormatterBuilder {
long instantSecs;
try {
LocalDateTime ldt = LocalDateTime.of(year, month, day, hour, min, sec, 0).plusDays(days);
instantSecs = ldt.toEpochSecond(ZoneOffset.UTC);
instantSecs = ldt.toEpochSecond(ZoneOffset.ofTotalSeconds(offset));
instantSecs += Math.multiplyExact(yearParsed / 10_000L, SECONDS_PER_10000_YEARS);
} catch (RuntimeException ex) {
return ~position;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -125,9 +125,9 @@ final class Ser implements Externalizable {
* serialized form for the value of the type and sequence of values for the type.
*
* <ul>
* <li><a href="../../../serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.zone.ZoneOffsetTransition">ZoneOffsetTransition.writeReplace</a>
* <li><a href="../../../serialized-form.html#java.time.zone.ZoneOffsetTransitionRule">ZoneOffsetTransitionRule.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneOffsetTransition">ZoneOffsetTransition.writeReplace</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneOffsetTransitionRule">ZoneOffsetTransitionRule.writeReplace</a>
* </ul>
*
* @param out the data stream to write to, not null
@ -168,11 +168,11 @@ final class Ser implements Externalizable {
* {@code Ser} object.
*
* <ul>
* <li><a href="../../../serialized-form.html#java.time.zone.ZoneRules">ZoneRules</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneRules">ZoneRules</a>
* - {@code ZoneRules.of(standardTransitions, standardOffsets, savingsInstantTransitions, wallOffsets, lastRules);}
* <li><a href="../../../serialized-form.html#java.time.zone.ZoneOffsetTransition">ZoneOffsetTransition</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneOffsetTransition">ZoneOffsetTransition</a>
* - {@code ZoneOffsetTransition of(LocalDateTime.ofEpochSecond(epochSecond), offsetBefore, offsetAfter);}
* <li><a href="../../../serialized-form.html#java.time.zone.ZoneOffsetTransitionRule">ZoneOffsetTransitionRule</a>
* <li><a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneOffsetTransitionRule">ZoneOffsetTransitionRule</a>
* - {@code ZoneOffsetTransitionRule.of(month, dom, dow, time, timeEndOfDay, timeDefinition, standardOffset, offsetBefore, offsetAfter);}
* </ul>
* @param in the data to read, not null

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -190,10 +190,10 @@ public final class ZoneOffsetTransition
/**
* Writes the object using a
* <a href="../../../serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>.
* @serialData
* Refer to the serialized form of
* <a href="../../../serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a>
* <a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a>
* for the encoding of epoch seconds and offsets.
* <pre style="font-size:1.0em">{@code
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -249,10 +249,10 @@ public final class ZoneOffsetTransitionRule implements Serializable {
/**
* Writes the object using a
* <a href="../../../serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>.
* @serialData
* Refer to the serialized form of
* <a href="../../../serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a>
* <a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a>
* for the encoding of epoch seconds and offsets.
* <pre style="font-size:1.0em">{@code
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -327,7 +327,7 @@ public final class ZoneRules implements Serializable {
/**
* Writes the object using a
* <a href="../../../serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>.
* <a href="{@docRoot}/serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>.
* @serialData
* <pre style="font-size:1.0em">{@code
*

View file

@ -2246,22 +2246,26 @@ public final class Locale implements Cloneable, Serializable {
/**
* @serialField language String
* language subtag in lower case. (See <a href="java/util/Locale.html#getLanguage()">getLanguage()</a>)
* language subtag in lower case.
* (See <a href="java.base/java/util/Locale.html#getLanguage()">getLanguage()</a>)
* @serialField country String
* country subtag in upper case. (See <a href="java/util/Locale.html#getCountry()">getCountry()</a>)
* country subtag in upper case.
* (See <a href="java.base/java/util/Locale.html#getCountry()">getCountry()</a>)
* @serialField variant String
* variant subtags separated by LOWLINE characters. (See <a href="java/util/Locale.html#getVariant()">getVariant()</a>)
* variant subtags separated by LOWLINE characters.
* (See <a href="java.base/java/util/Locale.html#getVariant()">getVariant()</a>)
* @serialField hashcode int
* deprecated, for forward compatibility only
* @serialField script String
* script subtag in title case (See <a href="java/util/Locale.html#getScript()">getScript()</a>)
* script subtag in title case
* (See <a href="java.base/java/util/Locale.html#getScript()">getScript()</a>)
* @serialField extensions String
* canonical representation of extensions, that is,
* BCP47 extensions in alphabetical order followed by
* BCP47 private use subtags, all in lower case letters
* separated by HYPHEN-MINUS characters.
* (See <a href="java/util/Locale.html#getExtensionKeys()">getExtensionKeys()</a>,
* <a href="java/util/Locale.html#getExtension(char)">getExtension(char)</a>)
* (See <a href="java.base/java/util/Locale.html#getExtensionKeys()">getExtensionKeys()</a>,
* <a href="java.base/java/util/Locale.html#getExtension(char)">getExtension(char)</a>)
*/
private static final ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("language", String.class),

View file

@ -550,7 +550,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
* {@code Name} object for {@code Manifest-Version}
* manifest attribute. This attribute indicates the version number
* of the manifest standard to which a JAR file's manifest conforms.
* @see <a href="{@docRoot}/../specs/jar/jar.html#JAR_Manifest">
* @see <a href="{@docRoot}/../specs/jar/jar.html#jar-manifest">
* Manifest and Signature Specification</a>
*/
public static final Name MANIFEST_VERSION = new Name("Manifest-Version");
@ -558,7 +558,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
/**
* {@code Name} object for {@code Signature-Version}
* manifest attribute used when signing JAR files.
* @see <a href="{@docRoot}/../specs/jar/jar.html#JAR_Manifest">
* @see <a href="{@docRoot}/../specs/jar/jar.html#jar-manifest">
* Manifest and Signature Specification</a>
*/
public static final Name SIGNATURE_VERSION = new Name("Signature-Version");
@ -572,7 +572,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
/**
* {@code Name} object for {@code Class-Path}
* manifest attribute.
* @see <a href="{@docRoot}/../specs/jar/jar.html#classpath">
* @see <a href="{@docRoot}/../specs/jar/jar.html#class-path-attribute">
* JAR file specification</a>
*/
public static final Name CLASS_PATH = new Name("Class-Path");

View file

@ -556,7 +556,8 @@ class JarFile extends ZipFile {
return JUZFA.entryNameStream(this).map(this::getBasename)
.filter(Objects::nonNull)
.distinct()
.map(this::getJarEntry);
.map(this::getJarEntry)
.filter(Objects::nonNull);
}
return stream();
}

View file

@ -49,9 +49,6 @@ import sun.security.util.SecurityProperties;
*/
public class Manifest implements Cloneable {
private static final boolean jarInfoInExceptionText =
SecurityProperties.includedInExceptions("jar");
// manifest main attributes
private Attributes attr = new Attributes();
@ -203,10 +200,10 @@ public class Manifest implements Cloneable {
}
static String getErrorPosition(String filename, final int lineNumber) {
if (filename == null || !jarInfoInExceptionText) {
if (filename == null ||
!SecurityProperties.INCLUDE_JAR_NAME_IN_EXCEPTIONS) {
return "line " + lineNumber;
}
return "manifest of " + filename + ":" + lineNumber;
}

View file

@ -1433,10 +1433,10 @@ public final class Pattern
/**
* The pattern is converted to normalized form ({@link
* java.text.Normalizer.Form.NFC NFC}, canonical decomposition,
* java.text.Normalizer.Form#NFC NFC}, canonical decomposition,
* followed by canonical composition for the character class
* part, and {@link java.text.Normalizer.Form.NFD NFD},
* canonical decomposition) for the rest), and then a pure
* part, and {@link java.text.Normalizer.Form#NFD NFD},
* canonical decomposition for the rest), and then a pure
* group is constructed to match canonical equivalences of the
* characters.
*/

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,6 +35,7 @@ import java.io.UncheckedIOException;
import java.lang.ref.Cleaner.Cleanable;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.InvalidPathException;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.Files;
import java.util.ArrayDeque;
@ -1218,8 +1219,13 @@ class ZipFile implements ZipConstants, Closeable {
static Source get(File file, boolean toDelete) throws IOException {
Key key = new Key(file,
Files.readAttributes(file.toPath(), BasicFileAttributes.class));
final Key key;
try {
key = new Key(file,
Files.readAttributes(file.toPath(), BasicFileAttributes.class));
} catch (InvalidPathException ipe) {
throw new IOException(ipe);
}
Source src;
synchronized (files) {
src = files.get(key);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -198,7 +198,6 @@ public final class Loader extends SecureClassLoader {
this.acc = AccessController.getContext();
}
/**
* Completes initialization of this Loader. This method populates
* remotePackageToLoader with the packages of the remote modules, where
@ -253,25 +252,25 @@ public final class Loader extends SecureClassLoader {
}
// find the packages that are exported to the target module
String target = resolvedModule.name();
ModuleDescriptor descriptor = other.reference().descriptor();
for (ModuleDescriptor.Exports e : descriptor.exports()) {
boolean delegate;
if (e.isQualified()) {
// qualified export in same configuration
delegate = (other.configuration() == cf)
&& e.targets().contains(target);
} else {
// unqualified
delegate = true;
}
if (descriptor.isAutomatic()) {
ClassLoader l = loader;
descriptor.packages().forEach(pn -> remotePackage(pn, l));
} else {
String target = resolvedModule.name();
for (ModuleDescriptor.Exports e : descriptor.exports()) {
boolean delegate;
if (e.isQualified()) {
// qualified export in same configuration
delegate = (other.configuration() == cf)
&& e.targets().contains(target);
} else {
// unqualified
delegate = true;
}
if (delegate) {
String pn = e.source();
ClassLoader l = remotePackageToLoader.putIfAbsent(pn, loader);
if (l != null && l != loader) {
throw new IllegalArgumentException("Package "
+ pn + " cannot be imported from multiple loaders");
if (delegate) {
remotePackage(e.source(), loader);
}
}
}
@ -282,6 +281,22 @@ public final class Loader extends SecureClassLoader {
return this;
}
/**
* Adds to remotePackageToLoader so that an attempt to load a class in
* the package delegates to the given class loader.
*
* @throws IllegalStateException
* if the package is already mapped to a different class loader
*/
private void remotePackage(String pn, ClassLoader loader) {
ClassLoader l = remotePackageToLoader.putIfAbsent(pn, loader);
if (l != null && l != loader) {
throw new IllegalStateException("Package "
+ pn + " cannot be imported from multiple loaders");
}
}
/**
* Find the layer corresponding to the given configuration in the tree
* of layers rooted at the given parent.

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -46,7 +46,7 @@ public final class LoaderPool {
/**
* Creates a pool of class loaders. Each module in the given configuration
* will be loaded its own class loader in the pool. The class loader is
* is mapped to its own class loader in the pool. The class loader is
* created with the given parent class loader as its parent.
*/
public LoaderPool(Configuration cf,

View file

@ -27,14 +27,16 @@ package jdk.internal.reflect;
import java.security.AccessController;
import java.security.PrivilegedAction;
import jdk.internal.misc.Unsafe;
/** Utility class which assists in calling Unsafe.defineClass() by
import jdk.internal.misc.JavaLangAccess;
import jdk.internal.misc.SharedSecrets;
/** Utility class which assists in calling defineClass() by
creating a new class loader which delegates to the one needed in
order for proper resolution of the given bytecodes to occur. */
class ClassDefiner {
static final Unsafe unsafe = Unsafe.getUnsafe();
static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
/** <P> We define generated code into a new class loader which
delegates to the defining loader of the target class. It is
@ -60,7 +62,7 @@ class ClassDefiner {
return new DelegatingClassLoader(parentClassLoader);
}
});
return unsafe.defineClass(name, bytes, off, len, newLoader, null);
return JLA.defineClass(newLoader, name, bytes, null, "__ClassDefiner__");
}
}

View file

@ -118,4 +118,8 @@ public interface LangReflectAccess {
/** Gets the root of the given AccessibleObject object; null if arg is the root */
public <T extends AccessibleObject> T getRoot(T obj);
/** Returns a new instance created by the given constructor with access check */
public <T> T newInstance(Constructor<T> ctor, Object[] args, Class<?> caller)
throws IllegalAccessException, InstantiationException, InvocationTargetException;
}

View file

@ -398,6 +398,12 @@ public class ReflectionFactory {
return langReflectAccess().getExecutableSharedParameterTypes(ex);
}
public <T> T newInstance(Constructor<T> ctor, Object[] args, Class<?> caller)
throws IllegalAccessException, InstantiationException, InvocationTargetException
{
return langReflectAccess().newInstance(ctor, args, caller);
}
//--------------------------------------------------------------------------
//
// Routines used by serialization

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,6 +31,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.StringJoiner;
import static sun.reflect.annotation.TypeAnnotation.*;
@ -202,6 +204,68 @@ public final class AnnotatedTypeFactory {
}
@Override // java.lang.Object
public String toString() {
// Reusable toString implementation, but needs to be
// specialized for quirks of arrays.
return annotationsToString(getAnnotations(), false) + type.toString();
}
protected String annotationsToString(Annotation[] annotations, boolean leadingSpace) {
if (annotations != null && annotations.length > 0) {
StringJoiner sj = new StringJoiner(" ");
if (leadingSpace) {
sj.add(""); // Add a space
}
for (Annotation annotation : annotations) {
sj.add(annotation.toString());
}
if (!leadingSpace) {
sj.add("");
}
return sj.toString();
} else {
return "";
}
}
protected boolean equalsTypeAndAnnotations(AnnotatedType that) {
return getType().equals(that.getType()) &&
// Treat ordering of annotations as significant
Arrays.equals(getAnnotations(), that.getAnnotations()) &&
Objects.equals(getAnnotatedOwnerType(), that.getAnnotatedOwnerType());
}
int baseHashCode() {
return type.hashCode() ^
// Acceptable to use Objects.hash rather than
// Arrays.deepHashCode since the elements of the array
// are not themselves arrays.
Objects.hash((Object[])getAnnotations()) ^
Objects.hash(getAnnotatedOwnerType());
}
@Override
public boolean equals(Object o) {
if (o instanceof AnnotatedType &&
!(o instanceof AnnotatedArrayType) &&
!(o instanceof AnnotatedTypeVariable) &&
!(o instanceof AnnotatedParameterizedType) &&
!(o instanceof AnnotatedWildcardType)) {
AnnotatedType that = (AnnotatedType) o;
return equalsTypeAndAnnotations(that);
} else {
return false;
}
}
@Override
public int hashCode() {
return baseHashCode();
}
// Implementation details
final LocationInfo getLocation() {
return location;
@ -244,6 +308,52 @@ public final class AnnotatedTypeFactory {
}
return ((GenericArrayType)t).getGenericComponentType();
}
@Override
public String toString() {
// To annotate the full type of an array, the annotations
// are placed between the type and the brackets. For
// example, to annotate an array of Strings, the syntax used is
//
// String @TypeAnnotation []
//
// and *not*
//
// @TypeAnnotation String[].
//
// The toString output should strive to be reusable in
// source code. Therefore, the general logic of putting
// the annotations before a textual representation of the
// type need to be overridden for arrays.
StringBuilder sb = new StringBuilder();
AnnotatedType componentType = this;
while (componentType instanceof AnnotatedArrayType) {
AnnotatedArrayType annotatedArrayType = (AnnotatedArrayType) componentType;
sb.append(annotationsToString(annotatedArrayType.getAnnotations(), true) + "[]");
componentType = annotatedArrayType.getAnnotatedGenericComponentType();
}
sb.insert(0, componentType.toString());
return sb.toString();
}
@Override
public boolean equals(Object o) {
if (o instanceof AnnotatedArrayType) {
AnnotatedArrayType that = (AnnotatedArrayType) o;
return equalsTypeAndAnnotations(that) &&
Objects.equals(getAnnotatedGenericComponentType(),
that.getAnnotatedGenericComponentType());
} else {
return false;
}
}
@Override
public int hashCode() {
return baseHashCode() ^ getAnnotatedGenericComponentType().hashCode();
}
}
private static final class AnnotatedTypeVariableImpl extends AnnotatedTypeBaseImpl implements AnnotatedTypeVariable {
@ -266,6 +376,23 @@ public final class AnnotatedTypeFactory {
private TypeVariable<?> getTypeVariable() {
return (TypeVariable)getType();
}
@Override
public boolean equals(Object o) {
if (o instanceof AnnotatedTypeVariable) {
AnnotatedTypeVariable that = (AnnotatedTypeVariable) o;
return equalsTypeAndAnnotations(that) &&
Arrays.equals(getAnnotatedBounds(), that.getAnnotatedBounds());
} else {
return false;
}
}
@Override
public int hashCode() {
return baseHashCode() ^
Objects.hash((Object[])getAnnotatedBounds());
}
}
private static final class AnnotatedParameterizedTypeImpl extends AnnotatedTypeBaseImpl
@ -316,6 +443,23 @@ public final class AnnotatedTypeFactory {
private ParameterizedType getParameterizedType() {
return (ParameterizedType)getType();
}
@Override
public boolean equals(Object o) {
if (o instanceof AnnotatedParameterizedType) {
AnnotatedParameterizedType that = (AnnotatedParameterizedType) o;
return equalsTypeAndAnnotations(that) &&
Arrays.equals(getAnnotatedActualTypeArguments(), that.getAnnotatedActualTypeArguments());
} else {
return false;
}
}
@Override
public int hashCode() {
return baseHashCode() ^
Objects.hash((Object[])getAnnotatedActualTypeArguments());
}
}
private static final class AnnotatedWildcardTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedWildcardType {
@ -378,5 +522,26 @@ public final class AnnotatedTypeFactory {
private boolean hasUpperBounds() {
return hasUpperBounds;
}
@Override
public boolean equals(Object o) {
if (o instanceof AnnotatedWildcardType) {
AnnotatedWildcardType that = (AnnotatedWildcardType) o;
return equalsTypeAndAnnotations(that) &&
// Treats ordering as significant
Arrays.equals(getAnnotatedLowerBounds(), that.getAnnotatedLowerBounds()) &&
// Treats ordering as significant
Arrays.equals(getAnnotatedUpperBounds(), that.getAnnotatedUpperBounds());
} else {
return false;
}
}
@Override
public int hashCode() {
return baseHashCode() ^
Objects.hash((Object[])getAnnotatedLowerBounds()) ^
Objects.hash((Object[])getAnnotatedUpperBounds());
}
}
}

View file

@ -32,6 +32,9 @@ import java.security.Security;
public class SecurityProperties {
public static final boolean INCLUDE_JAR_NAME_IN_EXCEPTIONS
= includedInExceptions("jar");
/**
* Returns the value of the security property propName, which can be overridden
* by a system property of the same name

View file

@ -201,7 +201,7 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
}
}
JNIEXPORT void JNICALL
void
throwFileNotFoundException(JNIEnv *env, jstring path)
{
char buf[256];

View file

@ -54,8 +54,7 @@ void writeSingle(JNIEnv *env, jobject this, jint byte, jboolean append, jfieldID
void writeBytes(JNIEnv *env, jobject this, jbyteArray bytes, jint off,
jint len, jboolean append, jfieldID fid);
void fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags);
JNIEXPORT void JNICALL
throwFileNotFoundException(JNIEnv *env, jstring path);
void throwFileNotFoundException(JNIEnv *env, jstring path);
/*
* Macros for managing platform strings. The typical usage pattern is:

View file

@ -122,8 +122,6 @@ JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init(JNIEnv *env, jclass c
JNIEXPORT void JNICALL NET_ThrowNew(JNIEnv *env, int errorNum, char *msg);
int NET_GetError();
void NET_ThrowCurrent(JNIEnv *env, char *msg);
jfieldID NET_GetFileDescriptorID(JNIEnv *env);
@ -202,7 +200,6 @@ NET_EnableFastTcpLoopback(int fd);
unsigned short in_cksum(unsigned short *addr, int len);
JNIEXPORT jint JNICALL
NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
#endif /* NET_UTILS_H */

View file

@ -312,7 +312,7 @@ JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *
}
/* The three functions for the jvm to call into. */
void JVM_begin_signal_setting() {
JNIEXPORT void JVM_begin_signal_setting() {
signal_lock();
sigemptyset(&jvmsigs);
jvm_signal_installing = true;
@ -320,7 +320,7 @@ void JVM_begin_signal_setting() {
signal_unlock();
}
void JVM_end_signal_setting() {
JNIEXPORT void JVM_end_signal_setting() {
signal_lock();
jvm_signal_installed = true;
jvm_signal_installing = false;
@ -328,7 +328,7 @@ void JVM_end_signal_setting() {
signal_unlock();
}
struct sigaction *JVM_get_signal_action(int sig) {
JNIEXPORT struct sigaction *JVM_get_signal_action(int sig) {
allocate_sact();
/* Does race condition make sense here? */
if (sigismember(&jvmsigs, sig)) {

View file

@ -1546,7 +1546,7 @@ NET_Bind(int fd, SOCKETADDRESS *sa, int len)
* It returns the time left from the timeout (possibly 0), or -1 if it expired.
*/
JNIEXPORT jint JNICALL
jint
NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
{
jlong prevNanoTime = JVM_NanoTime(env, 0);

View file

@ -747,8 +747,7 @@ Java_sun_nio_ch_Net_pollconnValue(JNIEnv *env, jclass this)
/* Declared in nio_util.h */
JNIEXPORT jint JNICALL
handleSocketError(JNIEnv *env, jint errorValue)
jint handleSocketError(JNIEnv *env, jint errorValue)
{
char *xn;
switch (errorValue) {

View file

@ -62,5 +62,4 @@ jlong convertLongReturnVal(JNIEnv *env, jlong n, jboolean reading);
/* Defined in Net.c */
JNIEXPORT jint JNICALL
handleSocketError(JNIEnv *env, jint errorValue);
jint handleSocketError(JNIEnv *env, jint errorValue);

View file

@ -213,8 +213,7 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
return pathbuf;
}
JNIEXPORT FD JNICALL
winFileHandleOpen(JNIEnv *env, jstring path, int flags)
FD winFileHandleOpen(JNIEnv *env, jstring path, int flags)
{
const DWORD access =
(flags & O_WRONLY) ? GENERIC_WRITE :

View file

@ -56,8 +56,7 @@ handleLseek(FD fd, jlong offset, jint whence);
* Returns an opaque handle to file named by "path". If an error occurs,
* returns -1 and an exception is pending.
*/
JNIEXPORT FD JNICALL
winFileHandleOpen(JNIEnv *env, jstring path, int flags);
FD winFileHandleOpen(JNIEnv *env, jstring path, int flags);
/*
* Macros to set/get fd from the java.io.FileDescriptor.

View file

@ -903,7 +903,7 @@ NET_IsEqual(jbyte* caddr1, jbyte* caddr2) {
* It returns the time left from the timeout, or -1 if it expired.
*/
JNIEXPORT jint JNICALL
jint
NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
{
jlong prevTime = JVM_CurrentTimeMillis(env, 0);