Merge
This commit is contained in:
commit
ac6386468f
jdk
make/tools/src/build/tools/tzdb
makefiles
src/share
back
classes
com/sun
java/swing/plaf/gtk/resources
jmx/snmp
java
io
ByteArrayInputStream.javaByteArrayOutputStream.javaCloseable.javaDataInput.javaDataOutput.javaFilePermission.javaFlushable.javaInputStream.javaObjectInputStream.javaPipedInputStream.javaPipedReader.javaRandomAccessFile.javaSerializable.javaSerializablePermission.java
lang
AbstractStringBuilder.javaArrayStoreException.javaAutoCloseable.javaByte.javaCharacter.javaClass.javaClassCastException.javaClassLoader.javaClassValue.javaComparable.javaConditionalSpecialCasing.javaDouble.javaFloat.javaInteger.javaIterable.javaLong.javaReadable.javaRuntimePermission.javaSecurityManager.javaShort.javaString.javaSystem.javaThread.java
invoke
AbstractValidatingLambdaMetafactory.javaInnerClassLambdaMetafactory.javaLambdaMetafactory.javaMethodHandleNatives.javaMethodHandles.javaSerializedLambda.javaTypeConvertingMethodAdapter.java
management
reflect
math
net
DatagramSocket.javaHttpCookie.javaInet6Address.javaMulticastSocket.javaNetPermission.javaProxy.javaSocket.javaSocketOptions.javaSocketPermission.javaURI.javaURLClassLoader.javaURLConnection.javaURLDecoder.javaURLEncoder.javaURLPermission.javapackage-info.java
nio
rmi
security
@ -618,6 +618,11 @@ public final class TzdbZoneRulesCompiler {
|
||||
// remove ROC, which is not supported in j.u.tz
|
||||
builtZones.remove("ROC");
|
||||
links.remove("ROC");
|
||||
// remove EST, HST and MST. They are supported via
|
||||
// the short-id mapping
|
||||
builtZones.remove("EST");
|
||||
builtZones.remove("HST");
|
||||
builtZones.remove("MST");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ DISABLE_WARNINGS := -Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,-
|
||||
|
||||
# To build with all warnings enabled, do the following:
|
||||
# make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
|
||||
JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,classfile,dep-ann,divzero,varargs -Werror
|
||||
JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,auxiliaryclass,classfile,dep-ann,divzero,empty,try,varargs -Werror
|
||||
|
||||
# Any java code executed during a JDK build to build other parts of the JDK must be
|
||||
# executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this
|
||||
|
@ -267,7 +267,8 @@ SUNWprivate_1.1 {
|
||||
Java_sun_misc_GC_maxObjectInspectionAge;
|
||||
Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0;
|
||||
Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
|
||||
Java_sun_reflect_Reflection_getCallerClass;
|
||||
Java_sun_reflect_Reflection_getCallerClass__;
|
||||
Java_sun_reflect_Reflection_getCallerClass__I;
|
||||
Java_sun_reflect_Reflection_getClassAccessFlags;
|
||||
Java_sun_misc_Version_getJdkVersionInfo;
|
||||
Java_sun_misc_Version_getJdkSpecialVersion;
|
||||
|
@ -27,7 +27,8 @@ text: .text%Java_java_io_FileInputStream_initIDs;
|
||||
text: .text%Java_java_io_FileDescriptor_initIDs;
|
||||
text: .text%Java_java_io_FileOutputStream_initIDs;
|
||||
text: .text%Java_java_lang_System_setIn0;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass__;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass__I;
|
||||
text: .text%Java_java_lang_Class_forName0;
|
||||
text: .text%Java_java_lang_Object_getClass;
|
||||
text: .text%Java_sun_reflect_Reflection_getClassAccessFlags;
|
||||
|
@ -26,7 +26,8 @@ text: .text%Java_java_io_FileInputStream_initIDs;
|
||||
text: .text%Java_java_io_FileDescriptor_initIDs;
|
||||
text: .text%Java_java_io_FileOutputStream_initIDs;
|
||||
text: .text%Java_java_lang_System_setIn0;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass__;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass__I;
|
||||
text: .text%Java_java_lang_Class_forName0;
|
||||
text: .text%Java_java_lang_String_intern;
|
||||
text: .text%Java_java_lang_Float_floatToIntBits;
|
||||
|
@ -28,7 +28,8 @@ text: .text%Java_java_io_FileInputStream_initIDs;
|
||||
text: .text%Java_java_io_FileDescriptor_initIDs;
|
||||
text: .text%Java_java_io_FileOutputStream_initIDs;
|
||||
text: .text%Java_java_lang_System_setIn0;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass__;
|
||||
text: .text%Java_sun_reflect_Reflection_getCallerClass__I;
|
||||
text: .text%Java_java_lang_Class_forName0;
|
||||
text: .text%Java_java_lang_String_intern;
|
||||
text: .text%Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0;
|
||||
|
@ -47,7 +47,7 @@ name(PacketInputStream *in, PacketOutputStream *out)
|
||||
|
||||
(void)memset(&info, 0, sizeof(info));
|
||||
threadGroupInfo(group, &info);
|
||||
(void)outStream_writeString(out, info.name);
|
||||
(void)outStream_writeString(out, info.name == NULL ? "" : info.name);
|
||||
if ( info.name != NULL )
|
||||
jvmtiDeallocate(info.name);
|
||||
|
||||
|
@ -298,17 +298,15 @@ jdwpError
|
||||
outStream_writeString(PacketOutputStream *stream, char *string)
|
||||
{
|
||||
jdwpError error;
|
||||
jint length;
|
||||
jint length = string != NULL ? (int)strlen(string) : 0;
|
||||
|
||||
/* Options utf8=y/n controls if we want Standard UTF-8 or Modified */
|
||||
if ( gdata->modifiedUtf8 ) {
|
||||
length = (int)strlen(string);
|
||||
(void)outStream_writeInt(stream, length);
|
||||
error = writeBytes(stream, (jbyte *)string, length);
|
||||
} else {
|
||||
jint new_length;
|
||||
|
||||
length = (int)strlen(string);
|
||||
new_length = (gdata->npt->utf8mToUtf8sLength)
|
||||
(gdata->npt->utf, (jbyte*)string, length);
|
||||
if ( new_length == length ) {
|
||||
|
@ -41,7 +41,7 @@ FileChooser.saveDialogTitle.textAndMnemonic=Speichern
|
||||
FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen
|
||||
FileChooser.pathLabel.textAndMnemonic=Aus&wahl:
|
||||
FileChooser.filterLabel.textAndMnemonic=Filter:
|
||||
FileChooser.foldersLabel.textAndMnemonic=Or&dner
|
||||
FileChooser.foldersLabel.textAndMnemonic=O&rdner
|
||||
FileChooser.filesLabel.textAndMnemonic=&Dateien
|
||||
|
||||
FileChooser.cancelButtonToolTip.textAndMnemonic=Dialogfeld f\u00FCr Dateiauswahl schlie\u00DFen.
|
||||
|
@ -130,7 +130,7 @@ public class SnmpString extends SnmpValue {
|
||||
* @return The value.
|
||||
*/
|
||||
public byte[] byteValue() {
|
||||
return value ;
|
||||
return value.clone() ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -476,8 +476,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable {
|
||||
rootOid[i++]= val.longValue();
|
||||
}
|
||||
}
|
||||
return rootOid;
|
||||
|
||||
return rootOid.clone();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -1248,7 +1248,7 @@ public abstract class CommunicatorServer
|
||||
"of this CommunicatorServer instance has changed.");
|
||||
}
|
||||
|
||||
return notifInfos;
|
||||
return notifInfos.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,7 +275,6 @@ class ByteArrayInputStream extends InputStream {
|
||||
* Closing a <tt>ByteArrayInputStream</tt> has no effect. The methods in
|
||||
* this class can be called after the stream has been closed without
|
||||
* generating an <tt>IOException</tt>.
|
||||
* <p>
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
}
|
||||
|
@ -263,8 +263,6 @@ public class ByteArrayOutputStream extends OutputStream {
|
||||
* Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in
|
||||
* this class can be called after the stream has been closed without
|
||||
* generating an <tt>IOException</tt>.
|
||||
* <p>
|
||||
*
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ import java.io.IOException;
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Closeable extends AutoCloseable {
|
||||
|
||||
/**
|
||||
|
@ -155,7 +155,7 @@ interface DataInput {
|
||||
* to the length of {@code b}.
|
||||
* <p>
|
||||
* This method blocks until one of the
|
||||
* following conditions occurs:<p>
|
||||
* following conditions occurs:
|
||||
* <ul>
|
||||
* <li>{@code b.length}
|
||||
* bytes of input data are available, in which
|
||||
@ -197,7 +197,7 @@ interface DataInput {
|
||||
* <p>
|
||||
* This method
|
||||
* blocks until one of the following conditions
|
||||
* occurs:<p>
|
||||
* occurs:
|
||||
* <ul>
|
||||
* <li>{@code len} bytes
|
||||
* of input data are available, in which case
|
||||
@ -316,8 +316,8 @@ interface DataInput {
|
||||
* be the second byte. The value
|
||||
* returned
|
||||
* is:
|
||||
* <p><pre><code>(short)((a << 8) | (b & 0xff))
|
||||
* </code></pre>
|
||||
* <pre>{@code (short)((a << 8) | (b & 0xff))
|
||||
* }</pre>
|
||||
* This method
|
||||
* is suitable for reading the bytes written
|
||||
* by the {@code writeShort} method of
|
||||
@ -337,8 +337,8 @@ interface DataInput {
|
||||
* be the first byte read and
|
||||
* {@code b}
|
||||
* be the second byte. The value returned is:
|
||||
* <p><pre><code>(((a & 0xff) << 8) | (b & 0xff))
|
||||
* </code></pre>
|
||||
* <pre>{@code (((a & 0xff) << 8) | (b & 0xff))
|
||||
* }</pre>
|
||||
* This method is suitable for reading the bytes
|
||||
* written by the {@code writeShort} method
|
||||
* of interface {@code DataOutput} if
|
||||
@ -359,8 +359,8 @@ interface DataInput {
|
||||
* be the first byte read and {@code b}
|
||||
* be the second byte. The value
|
||||
* returned is:
|
||||
* <p><pre><code>(char)((a << 8) | (b & 0xff))
|
||||
* </code></pre>
|
||||
* <pre>{@code (char)((a << 8) | (b & 0xff))
|
||||
* }</pre>
|
||||
* This method
|
||||
* is suitable for reading bytes written by
|
||||
* the {@code writeChar} method of interface
|
||||
@ -377,10 +377,10 @@ interface DataInput {
|
||||
* Reads four input bytes and returns an
|
||||
* {@code int} value. Let {@code a-d}
|
||||
* be the first through fourth bytes read. The value returned is:
|
||||
* <p><pre><code>
|
||||
* (((a & 0xff) << 24) | ((b & 0xff) << 16) |
|
||||
*  ((c & 0xff) << 8) | (d & 0xff))
|
||||
* </code></pre>
|
||||
* <pre>{@code
|
||||
* (((a & 0xff) << 24) | ((b & 0xff) << 16) |
|
||||
* ((c & 0xff) << 8) | (d & 0xff))
|
||||
* }</pre>
|
||||
* This method is suitable
|
||||
* for reading bytes written by the {@code writeInt}
|
||||
* method of interface {@code DataOutput}.
|
||||
@ -397,16 +397,16 @@ interface DataInput {
|
||||
* a {@code long} value. Let {@code a-h}
|
||||
* be the first through eighth bytes read.
|
||||
* The value returned is:
|
||||
* <p><pre><code>
|
||||
* (((long)(a & 0xff) << 56) |
|
||||
* ((long)(b & 0xff) << 48) |
|
||||
* ((long)(c & 0xff) << 40) |
|
||||
* ((long)(d & 0xff) << 32) |
|
||||
* ((long)(e & 0xff) << 24) |
|
||||
* ((long)(f & 0xff) << 16) |
|
||||
* ((long)(g & 0xff) << 8) |
|
||||
* ((long)(h & 0xff)))
|
||||
* </code></pre>
|
||||
* <pre>{@code
|
||||
* (((long)(a & 0xff) << 56) |
|
||||
* ((long)(b & 0xff) << 48) |
|
||||
* ((long)(c & 0xff) << 40) |
|
||||
* ((long)(d & 0xff) << 32) |
|
||||
* ((long)(e & 0xff) << 24) |
|
||||
* ((long)(f & 0xff) << 16) |
|
||||
* ((long)(g & 0xff) << 8) |
|
||||
* ((long)(h & 0xff)))
|
||||
* }</pre>
|
||||
* <p>
|
||||
* This method is suitable
|
||||
* for reading bytes written by the {@code writeLong}
|
||||
@ -540,9 +540,9 @@ interface DataInput {
|
||||
* not match the bit pattern {@code 10xxxxxx},
|
||||
* then a {@code UTFDataFormatException}
|
||||
* is thrown. Otherwise, the group is converted
|
||||
* to the character:<p>
|
||||
* <pre><code>(char)(((a& 0x1F) << 6) | (b & 0x3F))
|
||||
* </code></pre>
|
||||
* to the character:
|
||||
* <pre>{@code (char)(((a & 0x1F) << 6) | (b & 0x3F))
|
||||
* }</pre>
|
||||
* If the first byte of a group
|
||||
* matches the bit pattern {@code 1110xxxx},
|
||||
* then the group consists of that byte {@code a}
|
||||
@ -554,10 +554,10 @@ interface DataInput {
|
||||
* does not match the bit pattern {@code 10xxxxxx},
|
||||
* then a {@code UTFDataFormatException}
|
||||
* is thrown. Otherwise, the group is converted
|
||||
* to the character:<p>
|
||||
* <pre><code>
|
||||
* (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))
|
||||
* </code></pre>
|
||||
* to the character:
|
||||
* <pre>{@code
|
||||
* (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))
|
||||
* }</pre>
|
||||
* If the first byte of a group matches the
|
||||
* pattern {@code 1111xxxx} or the pattern
|
||||
* {@code 10xxxxxx}, then a {@code UTFDataFormatException}
|
||||
|
@ -134,11 +134,11 @@ interface DataOutput {
|
||||
* Writes two bytes to the output
|
||||
* stream to represent the value of the argument.
|
||||
* The byte values to be written, in the order
|
||||
* shown, are: <p>
|
||||
* <pre><code>
|
||||
* (byte)(0xff & (v >> 8))
|
||||
* (byte)(0xff & v)
|
||||
* </code> </pre> <p>
|
||||
* shown, are:
|
||||
* <pre>{@code
|
||||
* (byte)(0xff & (v >> 8))
|
||||
* (byte)(0xff & v)
|
||||
* }</pre> <p>
|
||||
* The bytes written by this method may be
|
||||
* read by the <code>readShort</code> method
|
||||
* of interface <code>DataInput</code> , which
|
||||
@ -156,10 +156,10 @@ interface DataOutput {
|
||||
* output stream.
|
||||
* The byte values to be written, in the order
|
||||
* shown, are:
|
||||
* <p><pre><code>
|
||||
* (byte)(0xff & (v >> 8))
|
||||
* (byte)(0xff & v)
|
||||
* </code></pre><p>
|
||||
* <pre>{@code
|
||||
* (byte)(0xff & (v >> 8))
|
||||
* (byte)(0xff & v)
|
||||
* }</pre><p>
|
||||
* The bytes written by this method may be
|
||||
* read by the <code>readChar</code> method
|
||||
* of interface <code>DataInput</code> , which
|
||||
@ -176,12 +176,12 @@ interface DataOutput {
|
||||
* comprised of four bytes, to the output stream.
|
||||
* The byte values to be written, in the order
|
||||
* shown, are:
|
||||
* <p><pre><code>
|
||||
* (byte)(0xff & (v >> 24))
|
||||
* (byte)(0xff & (v >> 16))
|
||||
* (byte)(0xff & (v >>    8))
|
||||
* (byte)(0xff & v)
|
||||
* </code></pre><p>
|
||||
* <pre>{@code
|
||||
* (byte)(0xff & (v >> 24))
|
||||
* (byte)(0xff & (v >> 16))
|
||||
* (byte)(0xff & (v >> 8))
|
||||
* (byte)(0xff & v)
|
||||
* }</pre><p>
|
||||
* The bytes written by this method may be read
|
||||
* by the <code>readInt</code> method of interface
|
||||
* <code>DataInput</code> , which will then
|
||||
@ -197,16 +197,16 @@ interface DataOutput {
|
||||
* comprised of eight bytes, to the output stream.
|
||||
* The byte values to be written, in the order
|
||||
* shown, are:
|
||||
* <p><pre><code>
|
||||
* (byte)(0xff & (v >> 56))
|
||||
* (byte)(0xff & (v >> 48))
|
||||
* (byte)(0xff & (v >> 40))
|
||||
* (byte)(0xff & (v >> 32))
|
||||
* (byte)(0xff & (v >> 24))
|
||||
* (byte)(0xff & (v >> 16))
|
||||
* (byte)(0xff & (v >> 8))
|
||||
* (byte)(0xff & v)
|
||||
* </code></pre><p>
|
||||
* <pre>{@code
|
||||
* (byte)(0xff & (v >> 56))
|
||||
* (byte)(0xff & (v >> 48))
|
||||
* (byte)(0xff & (v >> 40))
|
||||
* (byte)(0xff & (v >> 32))
|
||||
* (byte)(0xff & (v >> 24))
|
||||
* (byte)(0xff & (v >> 16))
|
||||
* (byte)(0xff & (v >> 8))
|
||||
* (byte)(0xff & v)
|
||||
* }</pre><p>
|
||||
* The bytes written by this method may be
|
||||
* read by the <code>readLong</code> method
|
||||
* of interface <code>DataInput</code> , which
|
||||
@ -314,24 +314,24 @@ interface DataOutput {
|
||||
* If a character <code>c</code>
|
||||
* is in the range <code>\u0001</code> through
|
||||
* <code>\u007f</code>, it is represented
|
||||
* by one byte:<p>
|
||||
* by one byte:
|
||||
* <pre>(byte)c </pre> <p>
|
||||
* If a character <code>c</code> is <code>\u0000</code>
|
||||
* or is in the range <code>\u0080</code>
|
||||
* through <code>\u07ff</code>, then it is
|
||||
* represented by two bytes, to be written
|
||||
* in the order shown:<p> <pre><code>
|
||||
* (byte)(0xc0 | (0x1f & (c >> 6)))
|
||||
* (byte)(0x80 | (0x3f & c))
|
||||
* </code></pre> <p> If a character
|
||||
* in the order shown: <pre>{@code
|
||||
* (byte)(0xc0 | (0x1f & (c >> 6)))
|
||||
* (byte)(0x80 | (0x3f & c))
|
||||
* }</pre> <p> If a character
|
||||
* <code>c</code> is in the range <code>\u0800</code>
|
||||
* through <code>uffff</code>, then it is
|
||||
* represented by three bytes, to be written
|
||||
* in the order shown:<p> <pre><code>
|
||||
* (byte)(0xe0 | (0x0f & (c >> 12)))
|
||||
* (byte)(0x80 | (0x3f & (c >> 6)))
|
||||
* (byte)(0x80 | (0x3f & c))
|
||||
* </code></pre> <p> First,
|
||||
* in the order shown: <pre>{@code
|
||||
* (byte)(0xe0 | (0x0f & (c >> 12)))
|
||||
* (byte)(0x80 | (0x3f & (c >> 6)))
|
||||
* (byte)(0x80 | (0x3f & c))
|
||||
* }</pre> <p> First,
|
||||
* the total number of bytes needed to represent
|
||||
* all the characters of <code>s</code> is
|
||||
* calculated. If this number is larger than
|
||||
|
@ -55,7 +55,7 @@ import sun.security.util.SecurityConstants;
|
||||
* a list of one or more comma-separated keywords. The possible keywords are
|
||||
* "read", "write", "execute", "delete", and "readlink". Their meaning is
|
||||
* defined as follows:
|
||||
* <P>
|
||||
*
|
||||
* <DL>
|
||||
* <DT> read <DD> read permission
|
||||
* <DT> write <DD> write permission
|
||||
@ -297,11 +297,11 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
/**
|
||||
* Checks if this FilePermission object "implies" the specified permission.
|
||||
* <P>
|
||||
* More specifically, this method returns true if:<p>
|
||||
* More specifically, this method returns true if:
|
||||
* <ul>
|
||||
* <li> <i>p</i> is an instanceof FilePermission,<p>
|
||||
* <li> <i>p</i> is an instanceof FilePermission,
|
||||
* <li> <i>p</i>'s actions are a proper subset of this
|
||||
* object's actions, and <p>
|
||||
* object's actions, and
|
||||
* <li> <i>p</i>'s pathname is implied by this object's
|
||||
* pathname. For example, "/tmp/*" implies "/tmp/foo", since
|
||||
* "/tmp/*" encompasses all files in the "/tmp" directory,
|
||||
|
@ -34,7 +34,6 @@ import java.io.IOException;
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Flushable {
|
||||
|
||||
/**
|
||||
|
@ -306,8 +306,7 @@ public abstract class InputStream implements Closeable {
|
||||
*
|
||||
* <p> The general contract of <code>reset</code> is:
|
||||
*
|
||||
* <p><ul>
|
||||
*
|
||||
* <ul>
|
||||
* <li> If the method <code>markSupported</code> returns
|
||||
* <code>true</code>, then:
|
||||
*
|
||||
|
@ -109,7 +109,7 @@ import sun.reflect.misc.ReflectUtil;
|
||||
*
|
||||
* <p>Serializable classes that require special handling during the
|
||||
* serialization and deserialization process should implement the following
|
||||
* methods:<p>
|
||||
* methods:
|
||||
*
|
||||
* <pre>
|
||||
* private void writeObject(java.io.ObjectOutputStream stream)
|
||||
|
@ -172,15 +172,14 @@ public class PipedInputStream extends InputStream {
|
||||
* unconnected piped output stream and <code>snk</code>
|
||||
* is an unconnected piped input stream, they
|
||||
* may be connected by either the call:
|
||||
* <p>
|
||||
*
|
||||
* <pre><code>snk.connect(src)</code> </pre>
|
||||
* <p>
|
||||
* or the call:
|
||||
* <p>
|
||||
*
|
||||
* <pre><code>src.connect(snk)</code> </pre>
|
||||
* <p>
|
||||
* The two
|
||||
* calls have the same effect.
|
||||
* The two calls have the same effect.
|
||||
*
|
||||
* @param src The piped output stream to connect to.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
|
@ -145,15 +145,14 @@ public class PipedReader extends Reader {
|
||||
* unconnected piped writer and <code>snk</code>
|
||||
* is an unconnected piped reader, they
|
||||
* may be connected by either the call:
|
||||
* <p>
|
||||
*
|
||||
* <pre><code>snk.connect(src)</code> </pre>
|
||||
* <p>
|
||||
* or the call:
|
||||
* <p>
|
||||
*
|
||||
* <pre><code>src.connect(snk)</code> </pre>
|
||||
* <p>
|
||||
* The two
|
||||
* calls have the same effect.
|
||||
* The two calls have the same effect.
|
||||
*
|
||||
* @param src The piped writer to connect to.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
|
@ -784,7 +784,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
* </pre></blockquote>
|
||||
* <p>
|
||||
* then the result is equal to:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* ((long)b1 << 56) + ((long)b2 << 48)
|
||||
* + ((long)b3 << 40) + ((long)b4 << 32)
|
||||
* + ((long)b5 << 24) + ((long)b6 << 16)
|
||||
|
@ -55,7 +55,7 @@ package java.io;
|
||||
*
|
||||
* Classes that require special handling during the serialization and
|
||||
* deserialization process must implement special methods with these exact
|
||||
* signatures: <p>
|
||||
* signatures:
|
||||
*
|
||||
* <PRE>
|
||||
* private void writeObject(java.io.ObjectOutputStream out)
|
||||
@ -101,7 +101,7 @@ package java.io;
|
||||
*
|
||||
* <p>Serializable classes that need to designate an alternative object to be
|
||||
* used when writing an object to the stream should implement this
|
||||
* special method with the exact signature: <p>
|
||||
* special method with the exact signature:
|
||||
*
|
||||
* <PRE>
|
||||
* ANY-ACCESS-MODIFIER Object writeReplace() throws ObjectStreamException;
|
||||
@ -115,7 +115,7 @@ package java.io;
|
||||
*
|
||||
* Classes that need to designate a replacement when an instance of it
|
||||
* is read from the stream should implement this special method with the
|
||||
* exact signature.<p>
|
||||
* exact signature.
|
||||
*
|
||||
* <PRE>
|
||||
* ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException;
|
||||
@ -133,7 +133,7 @@ package java.io;
|
||||
* deserialization will result in an {@link InvalidClassException}. A
|
||||
* serializable class can declare its own serialVersionUID explicitly by
|
||||
* declaring a field named <code>"serialVersionUID"</code> that must be static,
|
||||
* final, and of type <code>long</code>:<p>
|
||||
* final, and of type <code>long</code>:
|
||||
*
|
||||
* <PRE>
|
||||
* ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;
|
||||
|
@ -43,7 +43,6 @@ import java.util.StringTokenizer;
|
||||
* The following table lists all the possible SerializablePermission target names,
|
||||
* and for each provides a description of what the permission allows
|
||||
* and a discussion of the risks of granting code the permission.
|
||||
* <P>
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="Permission target name, what the permission allows, and associated risks">
|
||||
* <tr>
|
||||
|
@ -330,9 +330,9 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
||||
* characters to be copied is {@code srcEnd-srcBegin}. The
|
||||
* characters are copied into the subarray of {@code dst} starting
|
||||
* at index {@code dstBegin} and ending at index:
|
||||
* <p><blockquote><pre>
|
||||
* <pre>{@code
|
||||
* dstbegin + (srcEnd-srcBegin) - 1
|
||||
* </pre></blockquote>
|
||||
* }</pre>
|
||||
*
|
||||
* @param srcBegin start copying at this offset.
|
||||
* @param srcEnd stop copying at this offset.
|
||||
@ -859,16 +859,16 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
||||
*
|
||||
* <p> An invocation of this method of the form
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* sb.subSequence(begin, end)</pre></blockquote>
|
||||
* <pre>{@code
|
||||
* sb.subSequence(begin, end)}</pre>
|
||||
*
|
||||
* behaves in exactly the same way as the invocation
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* sb.substring(begin, end)</pre></blockquote>
|
||||
* <pre>{@code
|
||||
* sb.substring(begin, end)}</pre>
|
||||
*
|
||||
* This method is provided so that this class can
|
||||
* implement the {@link CharSequence} interface. </p>
|
||||
* implement the {@link CharSequence} interface.
|
||||
*
|
||||
* @param start the start index, inclusive.
|
||||
* @param end the end index, exclusive.
|
||||
@ -1287,9 +1287,9 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
||||
* Returns the index within this string of the first occurrence of the
|
||||
* specified substring. The integer returned is the smallest value
|
||||
* <i>k</i> such that:
|
||||
* <blockquote><pre>
|
||||
* <pre>{@code
|
||||
* this.toString().startsWith(str, <i>k</i>)
|
||||
* </pre></blockquote>
|
||||
* }</pre>
|
||||
* is {@code true}.
|
||||
*
|
||||
* @param str any string.
|
||||
@ -1306,10 +1306,10 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
||||
* Returns the index within this string of the first occurrence of the
|
||||
* specified substring, starting at the specified index. The integer
|
||||
* returned is the smallest value {@code k} for which:
|
||||
* <blockquote><pre>
|
||||
* <pre>{@code
|
||||
* k >= Math.min(fromIndex, this.length()) &&
|
||||
* this.toString().startsWith(str, k)
|
||||
* </pre></blockquote>
|
||||
* }</pre>
|
||||
* If no such value of <i>k</i> exists, then -1 is returned.
|
||||
*
|
||||
* @param str the substring for which to search.
|
||||
@ -1326,9 +1326,9 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
||||
* of the specified substring. The rightmost empty string "" is
|
||||
* considered to occur at the index value {@code this.length()}.
|
||||
* The returned index is the largest value <i>k</i> such that
|
||||
* <blockquote><pre>
|
||||
* <pre>{@code
|
||||
* this.toString().startsWith(str, k)
|
||||
* </pre></blockquote>
|
||||
* }</pre>
|
||||
* is true.
|
||||
*
|
||||
* @param str the substring to search for.
|
||||
@ -1345,10 +1345,10 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
||||
* Returns the index within this string of the last occurrence of the
|
||||
* specified substring. The integer returned is the largest value <i>k</i>
|
||||
* such that:
|
||||
* <blockquote><pre>
|
||||
* <pre>{@code
|
||||
* k <= Math.min(fromIndex, this.length()) &&
|
||||
* this.toString().startsWith(str, k)
|
||||
* </pre></blockquote>
|
||||
* }</pre>
|
||||
* If no such value of <i>k</i> exists, then -1 is returned.
|
||||
*
|
||||
* @param str the substring to search for.
|
||||
|
@ -29,7 +29,7 @@ package java.lang;
|
||||
* Thrown to indicate that an attempt has been made to store the
|
||||
* wrong type of object into an array of objects. For example, the
|
||||
* following code generates an <code>ArrayStoreException</code>:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* Object x[] = new String[3];
|
||||
* x[0] = new Integer(0);
|
||||
* </pre></blockquote>
|
||||
|
@ -48,7 +48,6 @@ package java.lang;
|
||||
* @author Josh Bloch
|
||||
* @since 1.7
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface AutoCloseable {
|
||||
/**
|
||||
* Closes this resource, relinquishing any underlying resources.
|
||||
|
@ -244,7 +244,7 @@ public final class Byte extends Number implements Comparable<Byte> {
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
|
||||
* <p>
|
||||
*
|
||||
* <dt><i>Sign:</i>
|
||||
* <dd>{@code -}
|
||||
* <dd>{@code +}
|
||||
|
@ -5394,7 +5394,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
||||
* Other_Lowercase as defined by the Unicode Standard.
|
||||
* <p>
|
||||
* The following are examples of lowercase characters:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* a b c d e f g h i j k l m n o p q r s t u v w x y z
|
||||
* '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
|
||||
* '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
|
||||
@ -5430,7 +5430,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
||||
* Other_Lowercase as defined by the Unicode Standard.
|
||||
* <p>
|
||||
* The following are examples of lowercase characters:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* a b c d e f g h i j k l m n o p q r s t u v w x y z
|
||||
* '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
|
||||
* '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
|
||||
@ -5461,14 +5461,14 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
||||
* or it has contributory property Other_Uppercase as defined by the Unicode Standard.
|
||||
* <p>
|
||||
* The following are examples of uppercase characters:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
|
||||
* '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
|
||||
* '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
|
||||
* '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
|
||||
* '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
|
||||
* </pre></blockquote>
|
||||
* <p> Many other Unicode characters are uppercase too.<p>
|
||||
* <p> Many other Unicode characters are uppercase too.
|
||||
*
|
||||
* <p><b>Note:</b> This method cannot handle <a
|
||||
* href="#supplementary"> supplementary characters</a>. To support
|
||||
@ -5496,7 +5496,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
||||
* or it has contributory property Other_Uppercase as defined by the Unicode Standard.
|
||||
* <p>
|
||||
* The following are examples of uppercase characters:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
|
||||
* '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
|
||||
* '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
|
||||
@ -5540,7 +5540,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
||||
* <li>{@code LATIN CAPITAL LETTER N WITH SMALL LETTER J}
|
||||
* <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z}
|
||||
* </ul>
|
||||
* <p> Many other Unicode characters are titlecase too.<p>
|
||||
* <p> Many other Unicode characters are titlecase too.
|
||||
*
|
||||
* <p><b>Note:</b> This method cannot handle <a
|
||||
* href="#supplementary"> supplementary characters</a>. To support
|
||||
|
@ -91,7 +91,7 @@ import sun.reflect.misc.ReflectUtil;
|
||||
* <p> The following example uses a {@code Class} object to print the
|
||||
* class name of an object:
|
||||
*
|
||||
* <p> <blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* void printClassName(Object obj) {
|
||||
* System.out.println("The class of " + obj +
|
||||
* " is " + obj.getClass().getName());
|
||||
@ -103,7 +103,7 @@ import sun.reflect.misc.ReflectUtil;
|
||||
* <cite>The Java™ Language Specification</cite>.
|
||||
* For example:
|
||||
*
|
||||
* <p> <blockquote>
|
||||
* <blockquote>
|
||||
* {@code System.out.println("The name of class Foo is: "+Foo.class.getName());}
|
||||
* </blockquote>
|
||||
*
|
||||
@ -1571,6 +1571,10 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* <p> If this {@code Class} object represents a primitive type or void,
|
||||
* then the returned array has length 0.
|
||||
*
|
||||
* <p> Static methods declared in superinterfaces of the class or interface
|
||||
* represented by this {@code Class} object are not considered members of
|
||||
* the class or interface.
|
||||
*
|
||||
* <p> The elements in the returned array are not sorted and are not in any
|
||||
* particular order.
|
||||
*
|
||||
@ -1729,6 +1733,10 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* <p> If this {@code Class} object represents an array type, then this
|
||||
* method does not find the {@code clone()} method.
|
||||
*
|
||||
* <p> Static methods declared in superinterfaces of the class or interface
|
||||
* represented by this {@code Class} object are not considered members of
|
||||
* the class or interface.
|
||||
*
|
||||
* @param name the name of the method
|
||||
* @param parameterTypes the list of parameters
|
||||
* @return the {@code Method} object that matches the specified
|
||||
@ -1752,7 +1760,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
public Method getMethod(String name, Class<?>... parameterTypes)
|
||||
throws NoSuchMethodException, SecurityException {
|
||||
checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
|
||||
Method method = getMethod0(name, parameterTypes);
|
||||
Method method = getMethod0(name, parameterTypes, true);
|
||||
if (method == null) {
|
||||
throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes));
|
||||
}
|
||||
@ -2727,6 +2735,14 @@ public final class Class<T> implements java.io.Serializable,
|
||||
}
|
||||
}
|
||||
|
||||
void addAllNonStatic(Method[] methods) {
|
||||
for (Method candidate : methods) {
|
||||
if (!Modifier.isStatic(candidate.getModifiers())) {
|
||||
add(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int length() {
|
||||
return length;
|
||||
}
|
||||
@ -2797,7 +2813,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
MethodArray inheritedMethods = new MethodArray();
|
||||
Class<?>[] interfaces = getInterfaces();
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
inheritedMethods.addAll(interfaces[i].privateGetPublicMethods());
|
||||
inheritedMethods.addAllNonStatic(interfaces[i].privateGetPublicMethods());
|
||||
}
|
||||
if (!isInterface()) {
|
||||
Class<?> c = getSuperclass();
|
||||
@ -2900,7 +2916,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
}
|
||||
|
||||
|
||||
private Method getMethod0(String name, Class<?>[] parameterTypes) {
|
||||
private Method getMethod0(String name, Class<?>[] parameterTypes, boolean includeStaticMethods) {
|
||||
// Note: the intent is that the search algorithm this routine
|
||||
// uses be equivalent to the ordering imposed by
|
||||
// privateGetPublicMethods(). It fetches only the declared
|
||||
@ -2913,25 +2929,23 @@ public final class Class<T> implements java.io.Serializable,
|
||||
if ((res = searchMethods(privateGetDeclaredMethods(true),
|
||||
name,
|
||||
parameterTypes)) != null) {
|
||||
return res;
|
||||
if (includeStaticMethods || !Modifier.isStatic(res.getModifiers()))
|
||||
return res;
|
||||
}
|
||||
// Search superclass's methods
|
||||
if (!isInterface()) {
|
||||
Class<? super T> c = getSuperclass();
|
||||
if (c != null) {
|
||||
if ((res = c.getMethod0(name, parameterTypes)) != null) {
|
||||
if ((res = c.getMethod0(name, parameterTypes, true)) != null) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Search superinterfaces' methods
|
||||
Class<?>[] interfaces = getInterfaces();
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
Class<?> c = interfaces[i];
|
||||
if ((res = c.getMethod0(name, parameterTypes)) != null) {
|
||||
for (Class<?> c : interfaces)
|
||||
if ((res = c.getMethod0(name, parameterTypes, false)) != null)
|
||||
return res;
|
||||
}
|
||||
}
|
||||
// Not found
|
||||
return null;
|
||||
}
|
||||
@ -3300,7 +3314,10 @@ public final class Class<T> implements java.io.Serializable,
|
||||
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass) {
|
||||
Objects.requireNonNull(annotationClass);
|
||||
|
||||
return AnnotationSupport.getMultipleAnnotations(annotationData().annotations, annotationClass);
|
||||
AnnotationData annotationData = annotationData();
|
||||
return AnnotationSupport.getAssociatedAnnotations(annotationData.declaredAnnotations,
|
||||
this,
|
||||
annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3330,7 +3347,8 @@ public final class Class<T> implements java.io.Serializable,
|
||||
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass) {
|
||||
Objects.requireNonNull(annotationClass);
|
||||
|
||||
return AnnotationSupport.getMultipleAnnotations(annotationData().declaredAnnotations, annotationClass);
|
||||
return AnnotationSupport.getDirectlyAndIndirectlyPresent(annotationData().declaredAnnotations,
|
||||
annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3424,6 +3442,10 @@ public final class Class<T> implements java.io.Serializable,
|
||||
return annotationType;
|
||||
}
|
||||
|
||||
Map<Class<? extends Annotation>, Annotation> getDeclaredAnnotationMap() {
|
||||
return annotationData().declaredAnnotations;
|
||||
}
|
||||
|
||||
/* Backing store of user-defined values pertaining to this class.
|
||||
* Maintained by the ClassValue class.
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ package java.lang;
|
||||
* Thrown to indicate that the code has attempted to cast an object
|
||||
* to a subclass of which it is not an instance. For example, the
|
||||
* following code generates a <code>ClassCastException</code>:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* Object x = new Integer(0);
|
||||
* System.out.println((String)x);
|
||||
* </pre></blockquote>
|
||||
|
@ -362,7 +362,7 @@ public abstract class ClassLoader {
|
||||
* default implementation of this method searches for classes in the
|
||||
* following order:
|
||||
*
|
||||
* <p><ol>
|
||||
* <ol>
|
||||
*
|
||||
* <li><p> Invoke {@link #findLoadedClass(String)} to check if the class
|
||||
* has already been loaded. </p></li>
|
||||
@ -488,7 +488,7 @@ public abstract class ClassLoader {
|
||||
final SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
if (ReflectUtil.isNonPublicProxyClass(cls)) {
|
||||
for (Class intf: cls.getInterfaces()) {
|
||||
for (Class<?> intf: cls.getInterfaces()) {
|
||||
checkPackageAccess(intf, pd);
|
||||
}
|
||||
return;
|
||||
|
@ -692,7 +692,7 @@ public abstract class ClassValue<T> {
|
||||
|
||||
/** Remove all stale entries, everywhere. */
|
||||
private void removeStaleEntries() {
|
||||
Entry[] cache = getCache();
|
||||
Entry<?>[] cache = getCache();
|
||||
removeStaleEntries(cache, 0, cache.length + PROBE_LIMIT - 1);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,6 @@ import java.util.*;
|
||||
* @see java.util.Comparator
|
||||
* @since 1.2
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Comparable<T> {
|
||||
/**
|
||||
* Compares this object with the specified object for order. Returns a
|
||||
|
@ -74,7 +74,6 @@ final class ConditionalSpecialCasing {
|
||||
new Entry(0x00CC, new char[]{0x0069, 0x0307, 0x0300}, new char[]{0x00CC}, "lt", 0), // # LATIN CAPITAL LETTER I WITH GRAVE
|
||||
new Entry(0x00CD, new char[]{0x0069, 0x0307, 0x0301}, new char[]{0x00CD}, "lt", 0), // # LATIN CAPITAL LETTER I WITH ACUTE
|
||||
new Entry(0x0128, new char[]{0x0069, 0x0307, 0x0303}, new char[]{0x0128}, "lt", 0), // # LATIN CAPITAL LETTER I WITH TILDE
|
||||
new Entry(0x0130, new char[]{0x0069, 0x0307}, new char[]{0x0130}, "lt", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
|
||||
|
||||
//# ================================================================================
|
||||
//# Turkish and Azeri
|
||||
@ -85,10 +84,7 @@ final class ConditionalSpecialCasing {
|
||||
new Entry(0x0049, new char[]{0x0131}, new char[]{0x0049}, "tr", NOT_BEFORE_DOT), // # LATIN CAPITAL LETTER I
|
||||
new Entry(0x0049, new char[]{0x0131}, new char[]{0x0049}, "az", NOT_BEFORE_DOT), // # LATIN CAPITAL LETTER I
|
||||
new Entry(0x0069, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN SMALL LETTER I
|
||||
new Entry(0x0069, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN SMALL LETTER I
|
||||
//# ================================================================================
|
||||
//# Other
|
||||
new Entry(0x0130, new char[]{0x0069, 0x0307}, new char[]{0x0130}, "en", 0), // # LATIN CAPITALLETTER I WITH DOT ABOVE
|
||||
new Entry(0x0069, new char[]{0x0069}, new char[]{0x0130}, "az", 0) // # LATIN SMALL LETTER I
|
||||
};
|
||||
|
||||
// A hash table that contains the above entries
|
||||
|
@ -361,15 +361,11 @@ public final class Double extends Number implements Comparable<Double> {
|
||||
* <dd><i>SignedInteger</i>
|
||||
* </dl>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><i>HexFloatingPointLiteral</i>:
|
||||
* <dd> <i>HexSignificand BinaryExponent FloatTypeSuffix<sub>opt</sub></i>
|
||||
* </dl>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><i>HexSignificand:</i>
|
||||
* <dd><i>HexNumeral</i>
|
||||
@ -380,15 +376,11 @@ public final class Double extends Number implements Comparable<Double> {
|
||||
* </i>{@code .} <i>HexDigits</i>
|
||||
* </dl>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><i>BinaryExponent:</i>
|
||||
* <dd><i>BinaryExponentIndicator SignedInteger</i>
|
||||
* </dl>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><i>BinaryExponentIndicator:</i>
|
||||
* <dd>{@code p}
|
||||
|
@ -321,15 +321,11 @@ public final class Float extends Number implements Comparable<Float> {
|
||||
* <dd><i>SignedInteger</i>
|
||||
* </dl>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><i>HexFloatingPointLiteral</i>:
|
||||
* <dd> <i>HexSignificand BinaryExponent FloatTypeSuffix<sub>opt</sub></i>
|
||||
* </dl>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><i>HexSignificand:</i>
|
||||
* <dd><i>HexNumeral</i>
|
||||
@ -340,15 +336,11 @@ public final class Float extends Number implements Comparable<Float> {
|
||||
* </i>{@code .} <i>HexDigits</i>
|
||||
* </dl>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><i>BinaryExponent:</i>
|
||||
* <dd><i>BinaryExponentIndicator SignedInteger</i>
|
||||
* </dl>
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><i>BinaryExponentIndicator:</i>
|
||||
* <dd>{@code p}
|
||||
|
@ -1123,7 +1123,7 @@ public final class Integer extends Number implements Comparable<Integer> {
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
|
||||
* <p>
|
||||
*
|
||||
* <dt><i>Sign:</i>
|
||||
* <dd>{@code -}
|
||||
* <dd>{@code +}
|
||||
|
@ -42,7 +42,6 @@ import java.util.function.Consumer;
|
||||
* @since 1.5
|
||||
* @jls 14.14.2 The enhanced for statement
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Iterable<T> {
|
||||
/**
|
||||
* Returns an iterator over elements of type {@code T}.
|
||||
@ -52,10 +51,12 @@ public interface Iterable<T> {
|
||||
Iterator<T> iterator();
|
||||
|
||||
/**
|
||||
* Performs the given action on the contents of the {@code Iterable}, in the
|
||||
* order elements occur when iterating, until all elements have been
|
||||
* processed or the action throws an exception. Errors or runtime
|
||||
* exceptions thrown by the action are relayed to the caller.
|
||||
* Performs the given action for each element of the {@code Iterable}
|
||||
* until all elements have been processed or the action throws an
|
||||
* exception. Unless otherwise specified by the implementing class,
|
||||
* actions are performed in the order of iteration (if an iteration order
|
||||
* is specified). Exceptions thrown by the action are relayed to the
|
||||
* caller.
|
||||
*
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
@ -100,4 +101,3 @@ public interface Iterable<T> {
|
||||
return Spliterators.spliteratorUnknownSize(iterator(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -853,7 +853,7 @@ public final class Long extends Number implements Comparable<Long> {
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
|
||||
* <p>
|
||||
*
|
||||
* <dt><i>Sign:</i>
|
||||
* <dd>{@code -}
|
||||
* <dd>{@code +}
|
||||
|
@ -34,7 +34,6 @@ import java.io.IOException;
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Readable {
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,6 @@ import java.util.StringTokenizer;
|
||||
* The following table lists all the possible RuntimePermission target names,
|
||||
* and for each provides a description of what the permission allows
|
||||
* and a discussion of the risks of granting code the permission.
|
||||
* <P>
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="permission target name,
|
||||
* what the target allows,and associated risks">
|
||||
|
@ -56,7 +56,7 @@ import sun.security.util.SecurityConstants;
|
||||
* are called by various methods in the Java libraries before those
|
||||
* methods perform certain potentially sensitive operations. The
|
||||
* invocation of such a <code>check</code> method typically looks like this:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* SecurityManager security = System.getSecurityManager();
|
||||
* if (security != null) {
|
||||
* security.check<i>XXX</i>(argument, . . . );
|
||||
@ -323,7 +323,7 @@ class SecurityManager {
|
||||
* by {@link ClassLoader#getSystemClassLoader}) or one of its ancestors.
|
||||
* <p>
|
||||
* This method will return
|
||||
* <code>null</code> in the following three cases:<p>
|
||||
* <code>null</code> in the following three cases:
|
||||
* <ol>
|
||||
* <li>All methods on the execution stack are from classes
|
||||
* defined using the system class loader or one of its ancestors.
|
||||
@ -370,7 +370,7 @@ class SecurityManager {
|
||||
* by {@link ClassLoader#getSystemClassLoader}) or one of its ancestors.
|
||||
* <p>
|
||||
* This method will return
|
||||
* <code>null</code> in the following three cases:<p>
|
||||
* <code>null</code> in the following three cases:
|
||||
* <ol>
|
||||
* <li>All methods on the execution stack are from classes
|
||||
* defined using the system class loader or one of its ancestors.
|
||||
@ -429,7 +429,7 @@ class SecurityManager {
|
||||
* by {@link ClassLoader#getSystemClassLoader}) or one of its ancestors.
|
||||
* <p>
|
||||
* This method will return
|
||||
* -1 in the following three cases:<p>
|
||||
* -1 in the following three cases:
|
||||
* <ol>
|
||||
* <li>All methods on the execution stack are from classes
|
||||
* defined using the system class loader or one of its ancestors.
|
||||
@ -1281,7 +1281,6 @@ class SecurityManager {
|
||||
* This method calls <code>checkPermission</code> with the
|
||||
* <code>PropertyPermission(key, "read")</code> permission.
|
||||
* <p>
|
||||
* <p>
|
||||
* If you override this method, then you should make a call to
|
||||
* <code>super.checkPropertyAccess</code>
|
||||
* at the point the overridden method would normally throw an
|
||||
@ -1714,7 +1713,7 @@ class SecurityManager {
|
||||
throw new NullPointerException("class can't be null");
|
||||
}
|
||||
if (which != Member.PUBLIC) {
|
||||
Class stack[] = getClassContext();
|
||||
Class<?> stack[] = getClassContext();
|
||||
/*
|
||||
* stack depth of 4 should be the caller of one of the
|
||||
* methods in java.lang.Class that invoke checkMember
|
||||
|
@ -249,7 +249,7 @@ public final class Short extends Number implements Comparable<Short> {
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
|
||||
* <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
|
||||
* <p>
|
||||
*
|
||||
* <dt><i>Sign:</i>
|
||||
* <dd>{@code -}
|
||||
* <dd>{@code +}
|
||||
|
@ -47,16 +47,16 @@ import java.util.regex.PatternSyntaxException;
|
||||
* Strings are constant; their values cannot be changed after they
|
||||
* are created. String buffers support mutable strings.
|
||||
* Because String objects are immutable they can be shared. For example:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* String str = "abc";
|
||||
* </pre></blockquote><p>
|
||||
* is equivalent to:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* char data[] = {'a', 'b', 'c'};
|
||||
* String str = new String(data);
|
||||
* </pre></blockquote><p>
|
||||
* Here are some more examples of how strings can be used:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* System.out.println("abc");
|
||||
* String cde = "cde";
|
||||
* System.out.println("abc" + cde);
|
||||
@ -786,7 +786,7 @@ public final class String
|
||||
* {@code srcEnd-srcBegin}). The characters are copied into the
|
||||
* subarray of {@code dst} starting at index {@code dstBegin}
|
||||
* and ending at index:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* dstbegin + (srcEnd-srcBegin) - 1
|
||||
* </pre></blockquote>
|
||||
*
|
||||
@ -2598,21 +2598,14 @@ public final class String
|
||||
}
|
||||
if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA
|
||||
lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale);
|
||||
} else if (srcChar == '\u0130') { // LATIN CAPITAL LETTER I DOT
|
||||
lowerChar = Character.ERROR;
|
||||
} else {
|
||||
lowerChar = Character.toLowerCase(srcChar);
|
||||
}
|
||||
if ((lowerChar == Character.ERROR)
|
||||
|| (lowerChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {
|
||||
if (lowerChar == Character.ERROR) {
|
||||
if (!localeDependent && srcChar == '\u0130') {
|
||||
lowerCharArray =
|
||||
ConditionalSpecialCasing.toLowerCaseCharArray(this, i, Locale.ENGLISH);
|
||||
} else {
|
||||
lowerCharArray =
|
||||
ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
|
||||
}
|
||||
lowerCharArray =
|
||||
ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
|
||||
} else if (srcCount == 2) {
|
||||
resultOffset += Character.toChars(lowerChar, result, i + resultOffset) - srcCount;
|
||||
continue;
|
||||
@ -2669,7 +2662,7 @@ public final class String
|
||||
* {@code String} may be a different length than the original {@code String}.
|
||||
* <p>
|
||||
* Examples of locale-sensitive and 1:M case mappings are in the following table.
|
||||
* <p>
|
||||
*
|
||||
* <table border="1" summary="Examples of locale-sensitive and 1:M case mappings. Shows Language code of locale, lower case, upper case, and description.">
|
||||
* <tr>
|
||||
* <th>Language Code of Locale</th>
|
||||
|
@ -26,10 +26,12 @@ package java.lang;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Executable;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.security.AccessControlContext;
|
||||
import java.util.Properties;
|
||||
import java.util.PropertyPermission;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Map;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.AllPermission;
|
||||
@ -1227,6 +1229,9 @@ public final class System {
|
||||
public AnnotationType getAnnotationType(Class<?> klass) {
|
||||
return klass.getAnnotationType();
|
||||
}
|
||||
public Map<Class<? extends Annotation>, Annotation> getDeclaredAnnotationMap(Class<?> klass) {
|
||||
return klass.getDeclaredAnnotationMap();
|
||||
}
|
||||
public byte[] getRawClassAnnotations(Class<?> klass) {
|
||||
return klass.getRawAnnotations();
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ import sun.security.util.SecurityConstants;
|
||||
* <code>Thread</code>. An instance of the subclass can then be
|
||||
* allocated and started. For example, a thread that computes primes
|
||||
* larger than a stated value could be written as follows:
|
||||
* <p><hr><blockquote><pre>
|
||||
* <hr><blockquote><pre>
|
||||
* class PrimeThread extends Thread {
|
||||
* long minPrime;
|
||||
* PrimeThread(long minPrime) {
|
||||
@ -91,7 +91,7 @@ import sun.security.util.SecurityConstants;
|
||||
* </pre></blockquote><hr>
|
||||
* <p>
|
||||
* The following code would then create a thread and start it running:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* PrimeThread p = new PrimeThread(143);
|
||||
* p.start();
|
||||
* </pre></blockquote>
|
||||
@ -102,7 +102,7 @@ import sun.security.util.SecurityConstants;
|
||||
* then be allocated, passed as an argument when creating
|
||||
* <code>Thread</code>, and started. The same example in this other
|
||||
* style looks like the following:
|
||||
* <p><hr><blockquote><pre>
|
||||
* <hr><blockquote><pre>
|
||||
* class PrimeRun implements Runnable {
|
||||
* long minPrime;
|
||||
* PrimeRun(long minPrime) {
|
||||
@ -117,7 +117,7 @@ import sun.security.util.SecurityConstants;
|
||||
* </pre></blockquote><hr>
|
||||
* <p>
|
||||
* The following code would then create a thread and start it running:
|
||||
* <p><blockquote><pre>
|
||||
* <blockquote><pre>
|
||||
* PrimeRun p = new PrimeRun(143);
|
||||
* new Thread(p).start();
|
||||
* </pre></blockquote>
|
||||
|
@ -101,7 +101,6 @@ import static sun.invoke.util.Wrapper.isWrapperType;
|
||||
* should implement.
|
||||
* @param additionalBridges Method types for additional signatures to be
|
||||
* bridged to the implementation method
|
||||
* @throws ReflectiveOperationException
|
||||
* @throws LambdaConversionException If any of the meta-factory protocol
|
||||
* invariants are violated
|
||||
*/
|
||||
@ -114,7 +113,7 @@ import static sun.invoke.util.Wrapper.isWrapperType;
|
||||
boolean isSerializable,
|
||||
Class<?>[] markerInterfaces,
|
||||
MethodType[] additionalBridges)
|
||||
throws ReflectiveOperationException, LambdaConversionException {
|
||||
throws LambdaConversionException {
|
||||
this.targetClass = caller.lookupClass();
|
||||
this.invokedType = invokedType;
|
||||
|
||||
@ -160,7 +159,7 @@ import static sun.invoke.util.Wrapper.isWrapperType;
|
||||
* @throws ReflectiveOperationException
|
||||
*/
|
||||
abstract CallSite buildCallSite()
|
||||
throws ReflectiveOperationException, LambdaConversionException;
|
||||
throws LambdaConversionException;
|
||||
|
||||
/**
|
||||
* Check the meta-factory arguments for errors
|
||||
|
@ -26,16 +26,19 @@
|
||||
package java.lang.invoke;
|
||||
|
||||
import jdk.internal.org.objectweb.asm.*;
|
||||
import sun.invoke.util.BytecodeDescriptor;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
import java.io.FilePermission;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.PropertyPermission;
|
||||
import java.util.Set;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
@ -50,14 +53,19 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
private static final int CLASSFILE_VERSION = 51;
|
||||
private static final String METHOD_DESCRIPTOR_VOID = Type.getMethodDescriptor(Type.VOID_TYPE);
|
||||
private static final String NAME_MAGIC_ACCESSOR_IMPL = "java/lang/invoke/MagicLambdaImpl";
|
||||
private static final String JAVA_LANG_OBJECT = "java/lang/Object";
|
||||
private static final String NAME_CTOR = "<init>";
|
||||
private static final String NAME_FACTORY = "get$Lambda";
|
||||
|
||||
//Serialization support
|
||||
private static final String NAME_SERIALIZED_LAMBDA = "java/lang/invoke/SerializedLambda";
|
||||
private static final String NAME_NOT_SERIALIZABLE_EXCEPTION = "java/io/NotSerializableException";
|
||||
private static final String DESCR_METHOD_WRITE_REPLACE = "()Ljava/lang/Object;";
|
||||
private static final String DESCR_METHOD_WRITE_OBJECT = "(Ljava/io/ObjectOutputStream;)V";
|
||||
private static final String DESCR_METHOD_READ_OBJECT = "(Ljava/io/ObjectInputStream;)V";
|
||||
private static final String NAME_METHOD_WRITE_REPLACE = "writeReplace";
|
||||
private static final String NAME_OBJECT = "java/lang/Object";
|
||||
private static final String NAME_METHOD_READ_OBJECT = "readObject";
|
||||
private static final String NAME_METHOD_WRITE_OBJECT = "writeObject";
|
||||
private static final String DESCR_CTOR_SERIALIZED_LAMBDA
|
||||
= MethodType.methodType(void.class,
|
||||
Class.class,
|
||||
@ -65,6 +73,12 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
int.class, String.class, String.class, String.class,
|
||||
String.class,
|
||||
Object[].class).toMethodDescriptorString();
|
||||
private static final String DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION
|
||||
= MethodType.methodType(void.class, String.class).toMethodDescriptorString();
|
||||
private static final String[] SER_HOSTILE_EXCEPTIONS = new String[] {NAME_NOT_SERIALIZABLE_EXCEPTION};
|
||||
|
||||
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
|
||||
// Used to ensure that each spun class name is unique
|
||||
private static final AtomicInteger counter = new AtomicInteger(0);
|
||||
@ -84,15 +98,12 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
private final String implMethodClassName; // Name of type containing implementation "CC"
|
||||
private final String implMethodName; // Name of implementation method "impl"
|
||||
private final String implMethodDesc; // Type descriptor for implementation methods "(I)Ljava/lang/String;"
|
||||
private final Type[] implMethodArgumentTypes; // ASM types for implementation method parameters
|
||||
private final Type implMethodReturnType; // ASM type for implementation method return type "Ljava/lang/String;"
|
||||
private final Class<?> implMethodReturnClass; // class for implementaion method return type "Ljava/lang/String;"
|
||||
private final MethodType constructorType; // Generated class constructor type "(CC)void"
|
||||
private final String constructorDesc; // Type descriptor for constructor "(LCC;)V"
|
||||
private final ClassWriter cw; // ASM class writer
|
||||
private final Type[] argTypes; // ASM types for the constructor arguments
|
||||
private final String[] argNames; // Generated names for the constructor arguments
|
||||
private final String[] argDescs; // Type descriptors for the constructor arguments
|
||||
private final String lambdaClassName; // Generated name for the generated class "X$$Lambda$1"
|
||||
private final Type[] instantiatedArgumentTypes; // ASM types for the functional interface arguments
|
||||
|
||||
/**
|
||||
* General meta-factory constructor, supporting both standard cases and
|
||||
@ -128,7 +139,6 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
* should implement.
|
||||
* @param additionalBridges Method types for additional signatures to be
|
||||
* bridged to the implementation method
|
||||
* @throws ReflectiveOperationException
|
||||
* @throws LambdaConversionException If any of the meta-factory protocol
|
||||
* invariants are violated
|
||||
*/
|
||||
@ -141,29 +151,30 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
boolean isSerializable,
|
||||
Class<?>[] markerInterfaces,
|
||||
MethodType[] additionalBridges)
|
||||
throws ReflectiveOperationException, LambdaConversionException {
|
||||
throws LambdaConversionException {
|
||||
super(caller, invokedType, samMethodName, samMethodType,
|
||||
implMethod, instantiatedMethodType,
|
||||
isSerializable, markerInterfaces, additionalBridges);
|
||||
implMethodClassName = implDefiningClass.getName().replace('.', '/');
|
||||
implMethodName = implInfo.getName();
|
||||
implMethodDesc = implMethodType.toMethodDescriptorString();
|
||||
Type implMethodAsmType = Type.getMethodType(implMethodDesc);
|
||||
implMethodArgumentTypes = implMethodAsmType.getArgumentTypes();
|
||||
implMethodReturnType = (implKind == MethodHandleInfo.REF_newInvokeSpecial)
|
||||
? Type.getObjectType(implMethodClassName)
|
||||
: implMethodAsmType.getReturnType();
|
||||
implMethodReturnClass = (implKind == MethodHandleInfo.REF_newInvokeSpecial)
|
||||
? implDefiningClass
|
||||
: implMethodType.returnType();
|
||||
constructorType = invokedType.changeReturnType(Void.TYPE);
|
||||
constructorDesc = constructorType.toMethodDescriptorString();
|
||||
lambdaClassName = targetClass.getName().replace('.', '/') + "$$Lambda$" + counter.incrementAndGet();
|
||||
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
argTypes = Type.getArgumentTypes(constructorDesc);
|
||||
argNames = new String[argTypes.length];
|
||||
for (int i = 0; i < argTypes.length; i++) {
|
||||
argNames[i] = "arg$" + (i + 1);
|
||||
int parameterCount = invokedType.parameterCount();
|
||||
if (parameterCount > 0) {
|
||||
argNames = new String[parameterCount];
|
||||
argDescs = new String[parameterCount];
|
||||
for (int i = 0; i < parameterCount; i++) {
|
||||
argNames[i] = "arg$" + (i + 1);
|
||||
argDescs[i] = BytecodeDescriptor.unparse(invokedType.parameterType(i));
|
||||
}
|
||||
} else {
|
||||
argNames = argDescs = EMPTY_STRING_ARRAY;
|
||||
}
|
||||
instantiatedArgumentTypes = Type.getArgumentTypes(
|
||||
instantiatedMethodType.toMethodDescriptorString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,36 +190,44 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
* is not found
|
||||
*/
|
||||
@Override
|
||||
CallSite buildCallSite() throws ReflectiveOperationException, LambdaConversionException {
|
||||
CallSite buildCallSite() throws LambdaConversionException {
|
||||
final Class<?> innerClass = spinInnerClass();
|
||||
if (invokedType.parameterCount() == 0) {
|
||||
final Constructor[] ctrs = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Constructor[]>() {
|
||||
@Override
|
||||
public Constructor[] run() {
|
||||
return innerClass.getDeclaredConstructors();
|
||||
Constructor<?>[] ctrs = innerClass.getDeclaredConstructors();
|
||||
if (ctrs.length == 1) {
|
||||
// The lambda implementing inner class constructor is private, set
|
||||
// it accessible (by us) before creating the constant sole instance
|
||||
ctrs[0].setAccessible(true);
|
||||
}
|
||||
return ctrs;
|
||||
}
|
||||
});
|
||||
});
|
||||
if (ctrs.length != 1) {
|
||||
throw new ReflectiveOperationException("Expected one lambda constructor for "
|
||||
throw new LambdaConversionException("Expected one lambda constructor for "
|
||||
+ innerClass.getCanonicalName() + ", got " + ctrs.length);
|
||||
}
|
||||
// The lambda implementing inner class constructor is private, set
|
||||
// it accessible (by us) before creating the constant sole instance
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
ctrs[0].setAccessible(true);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
Object inst = ctrs[0].newInstance();
|
||||
return new ConstantCallSite(MethodHandles.constant(samBase, inst));
|
||||
|
||||
try {
|
||||
Object inst = ctrs[0].newInstance();
|
||||
return new ConstantCallSite(MethodHandles.constant(samBase, inst));
|
||||
}
|
||||
catch (ReflectiveOperationException e) {
|
||||
throw new LambdaConversionException("Exception instantiating lambda object", e);
|
||||
}
|
||||
} else {
|
||||
return new ConstantCallSite(
|
||||
MethodHandles.Lookup.IMPL_LOOKUP
|
||||
.findConstructor(innerClass, constructorType)
|
||||
.asType(constructorType.changeReturnType(samBase)));
|
||||
try {
|
||||
UNSAFE.ensureClassInitialized(innerClass);
|
||||
return new ConstantCallSite(
|
||||
MethodHandles.Lookup.IMPL_LOOKUP
|
||||
.findStatic(innerClass, NAME_FACTORY, invokedType));
|
||||
}
|
||||
catch (ReflectiveOperationException e) {
|
||||
throw new LambdaConversionException("Exception finding constructor", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,44 +247,59 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
* is not found
|
||||
*/
|
||||
private Class<?> spinInnerClass() throws LambdaConversionException {
|
||||
String[] interfaces = new String[markerInterfaces.length + 1];
|
||||
interfaces[0] = samBase.getName().replace('.', '/');
|
||||
for (int i=0; i<markerInterfaces.length; i++) {
|
||||
interfaces[i+1] = markerInterfaces[i].getName().replace('.', '/');
|
||||
String[] interfaces;
|
||||
String samIntf = samBase.getName().replace('.', '/');
|
||||
boolean accidentallySerializable = !isSerializable && Serializable.class.isAssignableFrom(samBase);
|
||||
if (markerInterfaces.length == 0) {
|
||||
interfaces = new String[]{samIntf};
|
||||
} else {
|
||||
// Assure no duplicate interfaces (ClassFormatError)
|
||||
Set<String> itfs = new LinkedHashSet<>(markerInterfaces.length + 1);
|
||||
itfs.add(samIntf);
|
||||
for (Class<?> markerInterface : markerInterfaces) {
|
||||
itfs.add(markerInterface.getName().replace('.', '/'));
|
||||
accidentallySerializable |= !isSerializable && Serializable.class.isAssignableFrom(markerInterface);
|
||||
}
|
||||
interfaces = itfs.toArray(new String[itfs.size()]);
|
||||
}
|
||||
|
||||
cw.visit(CLASSFILE_VERSION, ACC_SUPER + ACC_FINAL + ACC_SYNTHETIC,
|
||||
lambdaClassName, null,
|
||||
NAME_MAGIC_ACCESSOR_IMPL, interfaces);
|
||||
JAVA_LANG_OBJECT, interfaces);
|
||||
|
||||
// Generate final fields to be filled in by constructor
|
||||
for (int i = 0; i < argTypes.length; i++) {
|
||||
for (int i = 0; i < argDescs.length; i++) {
|
||||
FieldVisitor fv = cw.visitField(ACC_PRIVATE + ACC_FINAL,
|
||||
argNames[i],
|
||||
argTypes[i].getDescriptor(),
|
||||
argDescs[i],
|
||||
null, null);
|
||||
fv.visitEnd();
|
||||
}
|
||||
|
||||
generateConstructor();
|
||||
|
||||
if (invokedType.parameterCount() != 0) {
|
||||
generateFactory();
|
||||
}
|
||||
|
||||
// Forward the SAM method
|
||||
String methodDescriptor = samMethodType.toMethodDescriptorString();
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, samMethodName,
|
||||
methodDescriptor, null, null);
|
||||
new ForwardingMethodGenerator(mv).generate(methodDescriptor);
|
||||
samMethodType.toMethodDescriptorString(), null, null);
|
||||
new ForwardingMethodGenerator(mv).generate(samMethodType);
|
||||
|
||||
// Forward the bridges
|
||||
if (additionalBridges != null) {
|
||||
for (MethodType mt : additionalBridges) {
|
||||
methodDescriptor = mt.toMethodDescriptorString();
|
||||
mv = cw.visitMethod(ACC_PUBLIC|ACC_BRIDGE, samMethodName,
|
||||
methodDescriptor, null, null);
|
||||
new ForwardingMethodGenerator(mv).generate(methodDescriptor);
|
||||
mt.toMethodDescriptorString(), null, null);
|
||||
new ForwardingMethodGenerator(mv).generate(mt);
|
||||
}
|
||||
}
|
||||
|
||||
if (isSerializable)
|
||||
generateWriteReplace();
|
||||
generateSerializationFriendlyMethods();
|
||||
else if (accidentallySerializable)
|
||||
generateSerializationHostileMethods();
|
||||
|
||||
cw.visitEnd();
|
||||
|
||||
@ -287,21 +321,27 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
new PropertyPermission("user.dir", "read"));
|
||||
}
|
||||
|
||||
ClassLoader loader = targetClass.getClassLoader();
|
||||
ProtectionDomain pd = (loader == null)
|
||||
? null
|
||||
: AccessController.doPrivileged(
|
||||
new PrivilegedAction<ProtectionDomain>() {
|
||||
@Override
|
||||
public ProtectionDomain run() {
|
||||
return targetClass.getProtectionDomain();
|
||||
}
|
||||
}
|
||||
);
|
||||
return UNSAFE.defineAnonymousClass(targetClass, classBytes, null);
|
||||
}
|
||||
|
||||
return UNSAFE.defineClass(lambdaClassName,
|
||||
classBytes, 0, classBytes.length,
|
||||
loader, pd);
|
||||
/**
|
||||
* Generate the factory method for the class
|
||||
*/
|
||||
private void generateFactory() {
|
||||
MethodVisitor m = cw.visitMethod(ACC_PRIVATE | ACC_STATIC, NAME_FACTORY, invokedType.toMethodDescriptorString(), null, null);
|
||||
m.visitCode();
|
||||
m.visitTypeInsn(NEW, lambdaClassName);
|
||||
m.visitInsn(Opcodes.DUP);
|
||||
int parameterCount = invokedType.parameterCount();
|
||||
for (int typeIndex = 0, varIndex = 0; typeIndex < parameterCount; typeIndex++) {
|
||||
Class<?> argType = invokedType.parameterType(typeIndex);
|
||||
m.visitVarInsn(getLoadOpcode(argType), varIndex);
|
||||
varIndex += getParameterSize(argType);
|
||||
}
|
||||
m.visitMethodInsn(INVOKESPECIAL, lambdaClassName, NAME_CTOR, constructorType.toMethodDescriptorString());
|
||||
m.visitInsn(ARETURN);
|
||||
m.visitMaxs(-1, -1);
|
||||
m.visitEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,18 +350,18 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
private void generateConstructor() {
|
||||
// Generate constructor
|
||||
MethodVisitor ctor = cw.visitMethod(ACC_PRIVATE, NAME_CTOR,
|
||||
constructorDesc, null, null);
|
||||
constructorType.toMethodDescriptorString(), null, null);
|
||||
ctor.visitCode();
|
||||
ctor.visitVarInsn(ALOAD, 0);
|
||||
ctor.visitMethodInsn(INVOKESPECIAL, NAME_MAGIC_ACCESSOR_IMPL, NAME_CTOR,
|
||||
ctor.visitMethodInsn(INVOKESPECIAL, JAVA_LANG_OBJECT, NAME_CTOR,
|
||||
METHOD_DESCRIPTOR_VOID);
|
||||
int lvIndex = 0;
|
||||
for (int i = 0; i < argTypes.length; i++) {
|
||||
int parameterCount = invokedType.parameterCount();
|
||||
for (int i = 0, lvIndex = 0; i < parameterCount; i++) {
|
||||
ctor.visitVarInsn(ALOAD, 0);
|
||||
ctor.visitVarInsn(argTypes[i].getOpcode(ILOAD), lvIndex + 1);
|
||||
lvIndex += argTypes[i].getSize();
|
||||
ctor.visitFieldInsn(PUTFIELD, lambdaClassName, argNames[i],
|
||||
argTypes[i].getDescriptor());
|
||||
Class<?> argType = invokedType.parameterType(i);
|
||||
ctor.visitVarInsn(getLoadOpcode(argType), lvIndex + 1);
|
||||
lvIndex += getParameterSize(argType);
|
||||
ctor.visitFieldInsn(PUTFIELD, lambdaClassName, argNames[i], argDescs[i]);
|
||||
}
|
||||
ctor.visitInsn(RETURN);
|
||||
// Maxs computed by ClassWriter.COMPUTE_MAXS, these arguments ignored
|
||||
@ -330,9 +370,9 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the writeReplace method (if needed for serialization)
|
||||
* Generate a writeReplace method that supports serialization
|
||||
*/
|
||||
private void generateWriteReplace() {
|
||||
private void generateSerializationFriendlyMethods() {
|
||||
TypeConvertingMethodAdapter mv
|
||||
= new TypeConvertingMethodAdapter(
|
||||
cw.visitMethod(ACC_PRIVATE + ACC_FINAL,
|
||||
@ -351,16 +391,14 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
mv.visitLdcInsn(implInfo.getName());
|
||||
mv.visitLdcInsn(implInfo.getMethodType().toMethodDescriptorString());
|
||||
mv.visitLdcInsn(instantiatedMethodType.toMethodDescriptorString());
|
||||
|
||||
mv.iconst(argTypes.length);
|
||||
mv.visitTypeInsn(ANEWARRAY, NAME_OBJECT);
|
||||
for (int i = 0; i < argTypes.length; i++) {
|
||||
mv.iconst(argDescs.length);
|
||||
mv.visitTypeInsn(ANEWARRAY, JAVA_LANG_OBJECT);
|
||||
for (int i = 0; i < argDescs.length; i++) {
|
||||
mv.visitInsn(DUP);
|
||||
mv.iconst(i);
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
mv.visitFieldInsn(GETFIELD, lambdaClassName, argNames[i],
|
||||
argTypes[i].getDescriptor());
|
||||
mv.boxIfTypePrimitive(argTypes[i]);
|
||||
mv.visitFieldInsn(GETFIELD, lambdaClassName, argNames[i], argDescs[i]);
|
||||
mv.boxIfTypePrimitive(Type.getType(argDescs[i]));
|
||||
mv.visitInsn(AASTORE);
|
||||
}
|
||||
mv.visitMethodInsn(INVOKESPECIAL, NAME_SERIALIZED_LAMBDA, NAME_CTOR,
|
||||
@ -371,6 +409,37 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a readObject/writeObject method that is hostile to serialization
|
||||
*/
|
||||
private void generateSerializationHostileMethods() {
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PRIVATE + ACC_FINAL,
|
||||
NAME_METHOD_WRITE_OBJECT, DESCR_METHOD_WRITE_OBJECT,
|
||||
null, SER_HOSTILE_EXCEPTIONS);
|
||||
mv.visitCode();
|
||||
mv.visitTypeInsn(NEW, NAME_NOT_SERIALIZABLE_EXCEPTION);
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitLdcInsn("Non-serializable lambda");
|
||||
mv.visitMethodInsn(INVOKESPECIAL, NAME_NOT_SERIALIZABLE_EXCEPTION, NAME_CTOR,
|
||||
DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION);
|
||||
mv.visitInsn(ATHROW);
|
||||
mv.visitMaxs(-1, -1);
|
||||
mv.visitEnd();
|
||||
|
||||
mv = cw.visitMethod(ACC_PRIVATE + ACC_FINAL,
|
||||
NAME_METHOD_READ_OBJECT, DESCR_METHOD_READ_OBJECT,
|
||||
null, SER_HOSTILE_EXCEPTIONS);
|
||||
mv.visitCode();
|
||||
mv.visitTypeInsn(NEW, NAME_NOT_SERIALIZABLE_EXCEPTION);
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitLdcInsn("Non-serializable lambda");
|
||||
mv.visitMethodInsn(INVOKESPECIAL, NAME_NOT_SERIALIZABLE_EXCEPTION, NAME_CTOR,
|
||||
DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION);
|
||||
mv.visitInsn(ATHROW);
|
||||
mv.visitMaxs(-1, -1);
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* This class generates a method body which calls the lambda implementation
|
||||
* method, converting arguments, as needed.
|
||||
@ -381,20 +450,19 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
super(mv);
|
||||
}
|
||||
|
||||
void generate(String methodDescriptor) {
|
||||
void generate(MethodType methodType) {
|
||||
visitCode();
|
||||
|
||||
if (implKind == MethodHandleInfo.REF_newInvokeSpecial) {
|
||||
visitTypeInsn(NEW, implMethodClassName);
|
||||
visitInsn(DUP);
|
||||
}
|
||||
for (int i = 0; i < argTypes.length; i++) {
|
||||
for (int i = 0; i < argNames.length; i++) {
|
||||
visitVarInsn(ALOAD, 0);
|
||||
visitFieldInsn(GETFIELD, lambdaClassName, argNames[i],
|
||||
argTypes[i].getDescriptor());
|
||||
visitFieldInsn(GETFIELD, lambdaClassName, argNames[i], argDescs[i]);
|
||||
}
|
||||
|
||||
convertArgumentTypes(Type.getArgumentTypes(methodDescriptor));
|
||||
convertArgumentTypes(methodType);
|
||||
|
||||
// Invoke the method we want to forward to
|
||||
visitMethodInsn(invocationOpcode(), implMethodClassName, implMethodName, implMethodDesc);
|
||||
@ -402,46 +470,36 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
// Convert the return value (if any) and return it
|
||||
// Note: if adapting from non-void to void, the 'return'
|
||||
// instruction will pop the unneeded result
|
||||
Type samReturnType = Type.getReturnType(methodDescriptor);
|
||||
convertType(implMethodReturnType, samReturnType, samReturnType);
|
||||
visitInsn(samReturnType.getOpcode(Opcodes.IRETURN));
|
||||
Class<?> samReturnClass = methodType.returnType();
|
||||
convertType(implMethodReturnClass, samReturnClass, samReturnClass);
|
||||
visitInsn(getReturnOpcode(samReturnClass));
|
||||
// Maxs computed by ClassWriter.COMPUTE_MAXS,these arguments ignored
|
||||
visitMaxs(-1, -1);
|
||||
visitEnd();
|
||||
}
|
||||
|
||||
private void convertArgumentTypes(Type[] samArgumentTypes) {
|
||||
private void convertArgumentTypes(MethodType samType) {
|
||||
int lvIndex = 0;
|
||||
boolean samIncludesReceiver = implIsInstanceMethod &&
|
||||
argTypes.length == 0;
|
||||
invokedType.parameterCount() == 0;
|
||||
int samReceiverLength = samIncludesReceiver ? 1 : 0;
|
||||
if (samIncludesReceiver) {
|
||||
// push receiver
|
||||
Type rcvrType = samArgumentTypes[0];
|
||||
Type instantiatedRcvrType = instantiatedArgumentTypes[0];
|
||||
|
||||
visitVarInsn(rcvrType.getOpcode(ILOAD), lvIndex + 1);
|
||||
lvIndex += rcvrType.getSize();
|
||||
convertType(rcvrType, Type.getType(implDefiningClass), instantiatedRcvrType);
|
||||
Class<?> rcvrType = samType.parameterType(0);
|
||||
visitVarInsn(getLoadOpcode(rcvrType), lvIndex + 1);
|
||||
lvIndex += getParameterSize(rcvrType);
|
||||
convertType(rcvrType, implDefiningClass, instantiatedMethodType.parameterType(0));
|
||||
}
|
||||
int argOffset = implMethodArgumentTypes.length - samArgumentTypes.length;
|
||||
for (int i = samReceiverLength; i < samArgumentTypes.length; i++) {
|
||||
Type argType = samArgumentTypes[i];
|
||||
Type targetType = implMethodArgumentTypes[argOffset + i];
|
||||
Type instantiatedArgType = instantiatedArgumentTypes[i];
|
||||
|
||||
visitVarInsn(argType.getOpcode(ILOAD), lvIndex + 1);
|
||||
lvIndex += argType.getSize();
|
||||
convertType(argType, targetType, instantiatedArgType);
|
||||
int samParametersLength = samType.parameterCount();
|
||||
int argOffset = implMethodType.parameterCount() - samParametersLength;
|
||||
for (int i = samReceiverLength; i < samParametersLength; i++) {
|
||||
Class<?> argType = samType.parameterType(i);
|
||||
visitVarInsn(getLoadOpcode(argType), lvIndex + 1);
|
||||
lvIndex += getParameterSize(argType);
|
||||
convertType(argType, implMethodType.parameterType(argOffset + i), instantiatedMethodType.parameterType(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void convertType(Type argType, Type targetType, Type functionalType) {
|
||||
convertType(argType.getDescriptor(),
|
||||
targetType.getDescriptor(),
|
||||
functionalType.getDescriptor());
|
||||
}
|
||||
|
||||
private int invocationOpcode() throws InternalError {
|
||||
switch (implKind) {
|
||||
case MethodHandleInfo.REF_invokeStatic:
|
||||
@ -459,4 +517,43 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int getParameterSize(Class<?> c) {
|
||||
if (c == Void.TYPE) {
|
||||
return 0;
|
||||
} else if (c == Long.TYPE || c == Double.TYPE) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int getLoadOpcode(Class<?> c) {
|
||||
if(c == Void.TYPE) {
|
||||
throw new InternalError("Unexpected void type of load opcode");
|
||||
}
|
||||
return ILOAD + getOpcodeOffset(c);
|
||||
}
|
||||
|
||||
static int getReturnOpcode(Class<?> c) {
|
||||
if(c == Void.TYPE) {
|
||||
return RETURN;
|
||||
}
|
||||
return IRETURN + getOpcodeOffset(c);
|
||||
}
|
||||
|
||||
private static int getOpcodeOffset(Class<?> c) {
|
||||
if (c.isPrimitive()) {
|
||||
if (c == Long.TYPE) {
|
||||
return 1;
|
||||
} else if (c == Float.TYPE) {
|
||||
return 2;
|
||||
} else if (c == Double.TYPE) {
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,88 +29,128 @@ import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>Bootstrap methods for converting lambda expressions and method references to functional interface objects.</p>
|
||||
* <p>Methods to facilitate the creation of simple "function objects" that
|
||||
* implement one or more interfaces by delegation to a provided {@link MethodHandle},
|
||||
* possibly after type adaptation and partial evaluation of arguments. These
|
||||
* methods are typically used as <em>bootstrap methods</em> for {@code invokedynamic}
|
||||
* call sites, to support the <em>lambda expression</em> and <em>method
|
||||
* reference expression</em> features of the Java Programming Language.
|
||||
*
|
||||
* <p>For every lambda expressions or method reference in the source code, there is a target type which is a
|
||||
* functional interface. Evaluating a lambda expression produces an object of its target type. The mechanism for
|
||||
* evaluating lambda expressions is to invoke an invokedynamic call site, which takes arguments describing the sole
|
||||
* method of the functional interface and the implementation method, and returns an object (the lambda object) that
|
||||
* implements the target type. Methods of the lambda object invoke the implementation method. For method
|
||||
* references, the implementation method is simply the referenced method; for lambda expressions, the
|
||||
* implementation method is produced by the compiler based on the body of the lambda expression. The methods in
|
||||
* this file are the bootstrap methods for those invokedynamic call sites, called lambda factories, and the
|
||||
* bootstrap methods responsible for linking the lambda factories are called lambda meta-factories.
|
||||
*
|
||||
* <p>The bootstrap methods in this class take the information about the functional interface, the implementation
|
||||
* method, and the static types of the captured lambda arguments, and link a call site which, when invoked,
|
||||
* produces the lambda object.
|
||||
*
|
||||
* <p>When parameterized types are used, the instantiated type of the functional interface method may be different
|
||||
* from that in the functional interface. For example, consider
|
||||
* {@code interface I<T> { int m(T x); }} if this functional interface type is used in a lambda
|
||||
* {@code I<Byte>; v = ...}, we need both the actual functional interface method which has the signature
|
||||
* {@code (Object)int} and the erased instantiated type of the functional interface method (or simply
|
||||
* <I>instantiated method type</I>), which has signature
|
||||
* {@code (Byte)int}.
|
||||
*
|
||||
* <p>The argument list of the implementation method and the argument list of the functional interface method(s)
|
||||
* may differ in several ways. The implementation methods may have additional arguments to accommodate arguments
|
||||
* captured by the lambda expression; there may also be differences resulting from permitted adaptations of
|
||||
* arguments, such as casting, boxing, unboxing, and primitive widening. They may also differ because of var-args,
|
||||
* but this is expected to be handled by the compiler.
|
||||
*
|
||||
* <p>Invokedynamic call sites have two argument lists: a static argument list and a dynamic argument list. The
|
||||
* static argument list lives in the constant pool; the dynamic argument list lives on the operand stack at
|
||||
* invocation time. The bootstrap method has access to the entire static argument list (which in this case,
|
||||
* contains method handles describing the implementation method and the canonical functional interface method),
|
||||
* as well as a method signature describing the number and static types (but not the values) of the dynamic
|
||||
* arguments, and the static return type of the invokedynamic site.
|
||||
*
|
||||
* <p>The implementation method is described with a method handle. In theory, any method handle could be used.
|
||||
* Currently supported are method handles representing invocation of virtual, interface, constructor and static
|
||||
* methods.
|
||||
*
|
||||
* <p>Assume:
|
||||
* <p>Indirect access to the behavior specified by the provided {@code MethodHandle}
|
||||
* proceeds in order through three phases:
|
||||
* <ul>
|
||||
* <li>the functional interface method has N arguments, of types (U1, U2, ... Un) and return type Ru</li>
|
||||
* <li>then the instantiated method type also has N arguments, of types (T1, T2, ... Tn) and return type Rt</li>
|
||||
* <li>the implementation method has M arguments, of types (A1..Am) and return type Ra,</li>
|
||||
* <li>the dynamic argument list has K arguments of types (D1..Dk), and the invokedynamic return site has
|
||||
* type Rd</li>
|
||||
* <li>the functional interface type is F</li>
|
||||
* <li><em>Linkage</em> occurs when the methods in this class are invoked.
|
||||
* They take as arguments an interface to be implemented (typically a
|
||||
* <em>functional interface</em>, one with a single abstract method), a
|
||||
* name and signature of a method from that interface to be implemented, a
|
||||
* method handle describing the desired implementation behavior
|
||||
* for that method, and possibly other additional metadata, and produce a
|
||||
* {@link CallSite} whose target can be used to create suitable function
|
||||
* objects. Linkage may involve dynamically loading a new class that
|
||||
* implements the target interface. The {@code CallSite} can be considered a
|
||||
* "factory" for function objects and so these linkage methods are referred
|
||||
* to as "metafactories".</li>
|
||||
*
|
||||
* <li><em>Capture</em> occurs when the {@code CallSite}'s target is
|
||||
* invoked, typically through an {@code invokedynamic} call site,
|
||||
* producing a function object. This may occur many times for
|
||||
* a single factory {@code CallSite}. Capture may involve allocation of a
|
||||
* new function object, or may return an existing function object. The
|
||||
* behavior {@code MethodHandle} may have additional parameters beyond those
|
||||
* of the specified interface method; these are referred to as <em>captured
|
||||
* parameters</em>, which must be provided as arguments to the
|
||||
* {@code CallSite} target, and which may be early-bound to the behavior
|
||||
* {@code MethodHandle}. The number of captured parameters and their types
|
||||
* are determined during linkage.</li>
|
||||
*
|
||||
* <li><em>Invocation</em> occurs when an implemented interface method
|
||||
* is invoked on a function object. This may occur many times for a single
|
||||
* function object. The method referenced by the behavior {@code MethodHandle}
|
||||
* is invoked with the captured arguments and any additional arguments
|
||||
* provided on invocation, as if by {@link MethodHandle#invoke(Object...)}.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>The following signature invariants must hold:
|
||||
* <p>It is sometimes useful to restrict the set of inputs or results permitted
|
||||
* at invocation. For example, when the generic interface {@code Predicate<T>}
|
||||
* is parameterized as {@code Predicate<String>}, the input must be a
|
||||
* {@code String}, even though the method to implement allows any {@code Object}.
|
||||
* At linkage time, an additional {@link MethodType} parameter describes the
|
||||
* "instantiated" method type; on invocation, the arguments and eventual result
|
||||
* are checked against this {@code MethodType}.
|
||||
*
|
||||
* <p>This class provides two forms of linkage methods: a standard version
|
||||
* ({@link #metafactory(MethodHandles.Lookup, String, MethodType, MethodType, MethodHandle, MethodType)})
|
||||
* using an optimized protocol, and an alternate version
|
||||
* {@link #altMetafactory(MethodHandles.Lookup, String, MethodType, Object...)}).
|
||||
* The alternate version is a generalization of the standard version, providing
|
||||
* additional control over the behavior of the generated function objects via
|
||||
* flags and additional arguments. The alternate version adds the ability to
|
||||
* manage the following attributes of function objects:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Rd is a subtype of F</li>
|
||||
* <li>For i=1..N, Ti is a subtype of Ui</li>
|
||||
* <li>Either Rt and Ru are primitive and are the same type, or both are reference types and
|
||||
* Rt is a subtype of Ru</li>
|
||||
* <li>If the implementation method is a static method:
|
||||
* <ul>
|
||||
* <li>K + N = M</li>
|
||||
* <li>For i=1..K, Di = Ai</li>
|
||||
* <li>For i=1..N, Ti is adaptable to Aj, where j=i+k</li>
|
||||
* </ul></li>
|
||||
* <li>If the implementation method is an instance method:
|
||||
* <ul>
|
||||
* <li>K + N = M + 1</li>
|
||||
* <li>D1 must be a subtype of the enclosing class for the implementation method</li>
|
||||
* <li>For i=2..K, Di = Aj, where j=i-1</li>
|
||||
* <li>For i=1..N, Ti is adaptable to Aj, where j=i+k-1</li>
|
||||
* </ul></li>
|
||||
* <li>The return type Rt is void, or the return type Ra is not void and is adaptable to Rt</li>
|
||||
* <li><em>Bridging.</em> It is sometimes useful to implement multiple
|
||||
* variations of the method signature, involving argument or return type
|
||||
* adaptation. This occurs when multiple distinct VM signatures for a method
|
||||
* are logically considered to be the same method by the language. The
|
||||
* flag {@code FLAG_BRIDGES} indicates that a list of additional
|
||||
* {@code MethodType}s will be provided, each of which will be implemented
|
||||
* by the resulting function object. These methods will share the same
|
||||
* name and instantiated type.</li>
|
||||
*
|
||||
* <li><em>Multiple interfaces.</em> If needed, more than one interface
|
||||
* can be implemented by the function object. (These additional interfaces
|
||||
* are typically marker interfaces with no methods.) The flag {@code FLAG_MARKERS}
|
||||
* indicates that a list of additional interfaces will be provided, each of
|
||||
* which should be implemented by the resulting function object.</li>
|
||||
*
|
||||
* <li><em>Serializability.</em> The generated function objects do not
|
||||
* generally support serialization. If desired, {@code FLAG_SERIALIZABLE}
|
||||
* can be used to indicate that the function objects should be serializable.
|
||||
* Serializable function objects will use, as their serialized form,
|
||||
* instances of the class {@code SerializedLambda}, which requires additional
|
||||
* assistance from the capturing class (the class described by the
|
||||
* {@link MethodHandles.Lookup} parameter {@code caller}); see
|
||||
* {@link SerializedLambda} for details.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Note that the potentially parameterized implementation return type provides the value for the SAM. Whereas
|
||||
* the completely known instantiated return type is adapted to the implementation arguments. Because the
|
||||
* instantiated type of the implementation method is not available, the adaptability of return types cannot be
|
||||
* checked as precisely at link-time as the arguments can be checked. Thus a loose version of link-time checking is
|
||||
* done on return type, while a strict version is applied to arguments.
|
||||
* <p>Assume the linkage arguments are as follows:
|
||||
* <ul>
|
||||
* <li>{@code invokedType} (describing the {@code CallSite} signature) has
|
||||
* K parameters of types (D1..Dk) and return type Rd;</li>
|
||||
* <li>{@code samMethodType} (describing the implemented method type) has N
|
||||
* parameters, of types (U1..Un) and return type Ru;</li>
|
||||
* <li>{@code implMethod} (the {@code MethodHandle} providing the
|
||||
* implementation has M parameters, of types (A1..Am) and return type Ra
|
||||
* (if the method describes an instance method, the method type of this
|
||||
* method handle already includes an extra first argument corresponding to
|
||||
* the receiver);</li>
|
||||
* <li>{@code instantiatedMethodType} (allowing restrictions on invocation)
|
||||
* has N parameters, of types (T1..Tn) and return type Rt.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Then the following linkage invariants must hold:
|
||||
* <ul>
|
||||
* <li>Rd is an interface</li>
|
||||
* <li>{@code implMethod} is a <em>direct method handle</em></li>
|
||||
* <li>{@code samMethodType} and {@code instantiatedMethodType} have the same
|
||||
* arity N, and for i=1..N, Ti and Ui are the same type, or Ti and Ui are
|
||||
* both reference types and Ti is a subtype of Ui</li>
|
||||
* <li>Either Rt and Ru are the same type, or both are reference types and
|
||||
* Rt is a subtype of Ru</li>
|
||||
* <li>K + N = M</li>
|
||||
* <li>For i=1..K, Di = Ai</li>
|
||||
* <li>For i=1..N, Ti is adaptable to Aj, where j=i+k</li>
|
||||
* <li>The return type Rt is void, or the return type Ra is not void and is
|
||||
* adaptable to Rt</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Further, at capture time, if {@code implMethod} corresponds to an instance
|
||||
* method, and there are any capture arguments ({@code K > 0}), then the first
|
||||
* capture argument (corresponding to the receiver) must be non-null.
|
||||
*
|
||||
* <p>A type Q is considered adaptable to S as follows:
|
||||
* <table summary="adaptable types">
|
||||
* <tr><th>Q</th><th>S</th><th>Link-time checks</th><th>Capture-time checks</th></tr>
|
||||
* <tr><th>Q</th><th>S</th><th>Link-time checks</th><th>Invocation-time checks</th></tr>
|
||||
* <tr>
|
||||
* <td>Primitive</td><td>Primitive</td>
|
||||
* <td>Q can be converted to S via a primitive widening conversion</td>
|
||||
@ -123,27 +163,59 @@ import java.util.Arrays;
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Reference</td><td>Primitive</td>
|
||||
* <td>strict: Q is a primitive wrapper and Primitive(Q) can be widened to S
|
||||
* <br>loose: If Q is a primitive wrapper, check that Primitive(Q) can be widened to S</td>
|
||||
* <td>If Q is not a primitive wrapper, cast Q to the base Wrapper(S); for example Number for numeric types</td>
|
||||
* <td>for parameter types: Q is a primitive wrapper and Primitive(Q)
|
||||
* can be widened to S
|
||||
* <br>for return types: If Q is a primitive wrapper, check that
|
||||
* Primitive(Q) can be widened to S</td>
|
||||
* <td>If Q is not a primitive wrapper, cast Q to the base Wrapper(S);
|
||||
* for example Number for numeric types</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Reference</td><td>Reference</td>
|
||||
* <td>strict: S is a supertype of Q
|
||||
* <br>loose: none</td>
|
||||
* <td>for parameter types: S is a supertype of Q
|
||||
* <br>for return types: none</td>
|
||||
* <td>Cast from Q to S</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* The default bootstrap ({@link #metafactory}) represents the common cases and uses an optimized protocol.
|
||||
* Alternate bootstraps (e.g., {@link #altMetafactory}) exist to support uncommon cases such as serialization
|
||||
* or additional marker superinterfaces.
|
||||
* @apiNote These linkage methods are designed to support the evaluation
|
||||
* of <em>lambda expressions</em> and <em>method references</em> in the Java
|
||||
* Language. For every lambda expressions or method reference in the source code,
|
||||
* there is a target type which is a functional interface. Evaluating a lambda
|
||||
* expression produces an object of its target type. The recommended mechanism
|
||||
* for evaluating lambda expressions is to desugar the lambda body to a method,
|
||||
* invoke an invokedynamic call site whose static argument list describes the
|
||||
* sole method of the functional interface and the desugared implementation
|
||||
* method, and returns an object (the lambda object) that implements the target
|
||||
* type. (For method references, the implementation method is simply the
|
||||
* referenced method; no desugaring is needed.)
|
||||
*
|
||||
* <p>The argument list of the implementation method and the argument list of
|
||||
* the interface method(s) may differ in several ways. The implementation
|
||||
* methods may have additional arguments to accommodate arguments captured by
|
||||
* the lambda expression; there may also be differences resulting from permitted
|
||||
* adaptations of arguments, such as casting, boxing, unboxing, and primitive
|
||||
* widening. (Varargs adaptations are not handled by the metafactories; these are
|
||||
* expected to be handled by the caller.)
|
||||
*
|
||||
* <p>Invokedynamic call sites have two argument lists: a static argument list
|
||||
* and a dynamic argument list. The static argument list is stored in the
|
||||
* constant pool; the dynamic argument is pushed on the operand stack at capture
|
||||
* time. The bootstrap method has access to the entire static argument list
|
||||
* (which in this case, includes information describing the implementation method,
|
||||
* the target interface, and the target interface method(s)), as well as a
|
||||
* method signature describing the number and static types (but not the values)
|
||||
* of the dynamic arguments and the static return type of the invokedynamic site.
|
||||
*
|
||||
* @implNote The implementation method is described with a method handle. In
|
||||
* theory, any method handle could be used. Currently supported are direct method
|
||||
* handles representing invocation of virtual, interface, constructor and static
|
||||
* methods.
|
||||
*/
|
||||
public class LambdaMetafactory {
|
||||
|
||||
/** Flag for alternate metafactories indicating the lambda object is
|
||||
* must to be serializable */
|
||||
/** Flag for alternate metafactories indicating the lambda object
|
||||
* must be serializable */
|
||||
public static final int FLAG_SERIALIZABLE = 1 << 0;
|
||||
|
||||
/**
|
||||
@ -163,41 +235,58 @@ public class LambdaMetafactory {
|
||||
private static final MethodType[] EMPTY_MT_ARRAY = new MethodType[0];
|
||||
|
||||
/**
|
||||
* Standard meta-factory for conversion of lambda expressions or method
|
||||
* references to functional interfaces.
|
||||
* Facilitates the creation of simple "function objects" that implement one
|
||||
* or more interfaces by delegation to a provided {@link MethodHandle},
|
||||
* after appropriate type adaptation and partial evaluation of arguments.
|
||||
* Typically used as a <em>bootstrap method</em> for {@code invokedynamic}
|
||||
* call sites, to support the <em>lambda expression</em> and <em>method
|
||||
* reference expression</em> features of the Java Programming Language.
|
||||
*
|
||||
* @param caller Stacked automatically by VM; represents a lookup context
|
||||
* with the accessibility privileges of the caller.
|
||||
* @param invokedName Stacked automatically by VM; the name of the invoked
|
||||
* method as it appears at the call site.
|
||||
* Used as the name of the functional interface method
|
||||
* to which the lambda or method reference is being
|
||||
* converted.
|
||||
* @param invokedType Stacked automatically by VM; the signature of the
|
||||
* invoked method, which includes the expected static
|
||||
* type of the returned lambda object, and the static
|
||||
* types of the captured arguments for the lambda.
|
||||
* <p>This is the standard, streamlined metafactory; additional flexibility
|
||||
* is provided by {@link #altMetafactory(MethodHandles.Lookup, String, MethodType, Object...)}.
|
||||
* A general description of the behavior of this method is provided
|
||||
* {@link LambdaMetafactory above}.
|
||||
*
|
||||
* <p>When the target of the {@code CallSite} returned from this method is
|
||||
* invoked, the resulting function objects are instances of a class which
|
||||
* implements the interface named by the return type of {@code invokedType},
|
||||
* declares a method with the name given by {@code invokedName} and the
|
||||
* signature given by {@code samMethodType}. It may also override additional
|
||||
* methods from {@code Object}.
|
||||
*
|
||||
* @param caller Represents a lookup context with the accessibility
|
||||
* privileges of the caller. When used with {@code invokedynamic},
|
||||
* this is stacked automatically by the VM.
|
||||
* @param invokedName The name of the method to implement. When used with
|
||||
* {@code invokedynamic}, this is provided by the
|
||||
* {@code NameAndType} of the {@code InvokeDynamic}
|
||||
* structure and is stacked automatically by the VM.
|
||||
* @param invokedType The expected signature of the {@code CallSite}. The
|
||||
* parameter types represent the types of capture variables;
|
||||
* the return type is the interface to implement. When
|
||||
* used with {@code invokedynamic}, this is provided by
|
||||
* the {@code NameAndType} of the {@code InvokeDynamic}
|
||||
* structure and is stacked automatically by the VM.
|
||||
* In the event that the implementation method is an
|
||||
* instance method, the first argument in the invocation
|
||||
* signature will correspond to the receiver.
|
||||
* @param samMethodType MethodType of the method in the functional interface
|
||||
* to which the lambda or method reference is being
|
||||
* converted, represented as a MethodType.
|
||||
* @param implMethod The implementation method which should be called
|
||||
* (with suitable adaptation of argument types, return
|
||||
* types, and adjustment for captured arguments) when
|
||||
* methods of the resulting functional interface instance
|
||||
* are invoked.
|
||||
* @param instantiatedMethodType The signature of the primary functional
|
||||
* interface method after type variables
|
||||
* are substituted with their instantiation
|
||||
* from the capture site
|
||||
* @return a CallSite, which, when invoked, will return an instance of the
|
||||
* functional interface
|
||||
* @throws ReflectiveOperationException if the caller is not able to
|
||||
* reconstruct one of the method handles
|
||||
* @throws LambdaConversionException If any of the meta-factory protocol
|
||||
* invariants are violated
|
||||
* instance method and this signature has any parameters,
|
||||
* the first parameter in the invocation signature must
|
||||
* correspond to the receiver.
|
||||
* @param samMethodType Signature and return type of method to be implemented
|
||||
* by the function object.
|
||||
* @param implMethod A direct method handle describing the implementation
|
||||
* method which should be called (with suitable adaptation
|
||||
* of argument types, return types, and with captured
|
||||
* arguments prepended to the invocation arguments) at
|
||||
* invocation time.
|
||||
* @param instantiatedMethodType The signature and return type that should
|
||||
* be enforced dynamically at invocation time.
|
||||
* This may be the same as {@code samMethodType},
|
||||
* or may be a specialization of it.
|
||||
* @return a CallSite whose target can be used to perform capture, generating
|
||||
* instances of the interface named by {@code invokedType}
|
||||
* @throws LambdaConversionException If any of the linkage invariants
|
||||
* described {@link LambdaMetafactory above}
|
||||
* are violated
|
||||
*/
|
||||
public static CallSite metafactory(MethodHandles.Lookup caller,
|
||||
String invokedName,
|
||||
@ -205,7 +294,7 @@ public class LambdaMetafactory {
|
||||
MethodType samMethodType,
|
||||
MethodHandle implMethod,
|
||||
MethodType instantiatedMethodType)
|
||||
throws ReflectiveOperationException, LambdaConversionException {
|
||||
throws LambdaConversionException {
|
||||
AbstractValidatingLambdaMetafactory mf;
|
||||
mf = new InnerClassLambdaMetafactory(caller, invokedType,
|
||||
invokedName, samMethodType,
|
||||
@ -216,60 +305,128 @@ public class LambdaMetafactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Alternate meta-factory for conversion of lambda expressions or method
|
||||
* references to functional interfaces, which supports serialization and
|
||||
* other uncommon options.
|
||||
* Facilitates the creation of simple "function objects" that implement one
|
||||
* or more interfaces by delegation to a provided {@link MethodHandle},
|
||||
* after appropriate type adaptation and partial evaluation of arguments.
|
||||
* Typically used as a <em>bootstrap method</em> for {@code invokedynamic}
|
||||
* call sites, to support the <em>lambda expression</em> and <em>method
|
||||
* reference expression</em> features of the Java Programming Language.
|
||||
*
|
||||
* The declared argument list for this method is:
|
||||
* <p>This is the general, more flexible metafactory; a streamlined version
|
||||
* is provided by {@link #altMetafactory(MethodHandles.Lookup, String, MethodType, Object...)}.
|
||||
* A general description of the behavior of this method is provided
|
||||
* {@link LambdaMetafactory above}.
|
||||
*
|
||||
* <p>The argument list for this method includes three fixed parameters,
|
||||
* corresponding to the parameters automatically stacked by the VM for the
|
||||
* bootstrap method in an {@code invokedynamic} invocation, and an {@code Object[]}
|
||||
* parameter that contains additional parameters. The declared argument
|
||||
* list for this method is:
|
||||
*
|
||||
* <pre>{@code
|
||||
* CallSite altMetafactory(MethodHandles.Lookup caller,
|
||||
* String invokedName,
|
||||
* MethodType invokedType,
|
||||
* Object... args)
|
||||
* }</pre>
|
||||
*
|
||||
* but it behaves as if the argument list is:
|
||||
* <p>but it behaves as if the argument list is as follows:
|
||||
*
|
||||
* <pre>{@code
|
||||
* CallSite altMetafactory(MethodHandles.Lookup caller,
|
||||
* String invokedName,
|
||||
* MethodType invokedType,
|
||||
* MethodType samMethodType
|
||||
* MethodType samMethodType,
|
||||
* MethodHandle implMethod,
|
||||
* MethodType instantiatedMethodType,
|
||||
* int flags,
|
||||
* int markerInterfaceCount, // IF flags has MARKERS set
|
||||
* Class... markerInterfaces // IF flags has MARKERS set
|
||||
* int bridgeCount, // IF flags has BRIDGES set
|
||||
* MethodType... bridges // IF flags has BRIDGES set
|
||||
* int markerInterfaceCount, // IF flags has MARKERS set
|
||||
* Class... markerInterfaces, // IF flags has MARKERS set
|
||||
* int bridgeCount, // IF flags has BRIDGES set
|
||||
* MethodType... bridges // IF flags has BRIDGES set
|
||||
* )
|
||||
* }</pre>
|
||||
*
|
||||
* <p>Arguments that appear in the argument list for
|
||||
* {@link #metafactory(MethodHandles.Lookup, String, MethodType, MethodType, MethodHandle, MethodType)}
|
||||
* have the same specification as in that method. The additional arguments
|
||||
* are interpreted as follows:
|
||||
* <ul>
|
||||
* <li>{@code flags} indicates additional options; this is a bitwise
|
||||
* OR of desired flags. Defined flags are {@link #FLAG_BRIDGES},
|
||||
* {@link #FLAG_MARKERS}, and {@link #FLAG_SERIALIZABLE}.</li>
|
||||
* <li>{@code markerInterfaceCount} is the number of additional interfaces
|
||||
* the function object should implement, and is present if and only if the
|
||||
* {@code FLAG_MARKERS} flag is set.</li>
|
||||
* <li>{@code markerInterfaces} is a variable-length list of additional
|
||||
* interfaces to implement, whose length equals {@code markerInterfaceCount},
|
||||
* and is present if and only if the {@code FLAG_MARKERS} flag is set.</li>
|
||||
* <li>{@code bridgeCount} is the number of additional method signatures
|
||||
* the function object should implement, and is present if and only if
|
||||
* the {@code FLAG_BRIDGES} flag is set.</li>
|
||||
* <li>{@code bridges} is a variable-length list of additional
|
||||
* methods signatures to implement, whose length equals {@code bridgeCount},
|
||||
* and is present if and only if the {@code FLAG_BRIDGES} flag is set.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param caller Stacked automatically by VM; represents a lookup context
|
||||
* with the accessibility privileges of the caller.
|
||||
* @param invokedName Stacked automatically by VM; the name of the invoked
|
||||
* method as it appears at the call site.
|
||||
* Used as the name of the functional interface method
|
||||
* to which the lambda or method reference is being
|
||||
* converted.
|
||||
* @param invokedType Stacked automatically by VM; the signature of the
|
||||
* invoked method, which includes the expected static
|
||||
* type of the returned lambda object, and the static
|
||||
* types of the captured arguments for the lambda.
|
||||
* <p>Each class named by {@code markerInterfaces} is subject to the same
|
||||
* restrictions as {@code Rd}, the return type of {@code invokedType},
|
||||
* as described {@link LambdaMetafactory above}. Each {@code MethodType}
|
||||
* named by {@code bridges} is subject to the same restrictions as
|
||||
* {@code samMethodType}, as described {@link LambdaMetafactory above}.
|
||||
*
|
||||
* <p>When FLAG_SERIALIZABLE is set in {@code flags}, the function objects
|
||||
* will implement {@code Serializable}, and will have a {@code writeReplace}
|
||||
* method that returns an appropriate {@link SerializedLambda}. The
|
||||
* {@code caller} class must have an appropriate {@code $deserializeLambda$}
|
||||
* method, as described in {@link SerializedLambda}.
|
||||
*
|
||||
* <p>When the target of the {@code CallSite} returned from this method is
|
||||
* invoked, the resulting function objects are instances of a class with
|
||||
* the following properties:
|
||||
* <ul>
|
||||
* <li>The class implements the interface named by the return type
|
||||
* of {@code invokedType} and any interfaces named by {@code markerInterfaces}</li>
|
||||
* <li>The class declares methods with the name given by {@code invokedName},
|
||||
* and the signature given by {@code samMethodType} and additional signatures
|
||||
* given by {@code bridges}</li>
|
||||
* <li>The class may override methods from {@code Object}, and may
|
||||
* implement methods related to serialization.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param caller Represents a lookup context with the accessibility
|
||||
* privileges of the caller. When used with {@code invokedynamic},
|
||||
* this is stacked automatically by the VM.
|
||||
* @param invokedName The name of the method to implement. When used with
|
||||
* {@code invokedynamic}, this is provided by the
|
||||
* {@code NameAndType} of the {@code InvokeDynamic}
|
||||
* structure and is stacked automatically by the VM.
|
||||
* @param invokedType The expected signature of the {@code CallSite}. The
|
||||
* parameter types represent the types of capture variables;
|
||||
* the return type is the interface to implement. When
|
||||
* used with {@code invokedynamic}, this is provided by
|
||||
* the {@code NameAndType} of the {@code InvokeDynamic}
|
||||
* structure and is stacked automatically by the VM.
|
||||
* In the event that the implementation method is an
|
||||
* instance method, the first argument in the invocation
|
||||
* signature will correspond to the receiver.
|
||||
* @param args flags and optional arguments, as described above
|
||||
* @return a CallSite, which, when invoked, will return an instance of the
|
||||
* functional interface
|
||||
* @throws ReflectiveOperationException if the caller is not able to
|
||||
* reconstruct one of the method handles
|
||||
* @throws LambdaConversionException If any of the meta-factory protocol
|
||||
* invariants are violated
|
||||
* instance method and this signature has any parameters,
|
||||
* the first parameter in the invocation signature must
|
||||
* correspond to the receiver.
|
||||
* @param args An {@code Object[]} array containing the required
|
||||
* arguments {@code samMethodType}, {@code implMethod},
|
||||
* {@code instantiatedMethodType}, {@code flags}, and any
|
||||
* optional arguments, as described
|
||||
* {@link #altMetafactory(MethodHandles.Lookup, String, MethodType, Object...)} above}
|
||||
* @return a CallSite whose target can be used to perform capture, generating
|
||||
* instances of the interface named by {@code invokedType}
|
||||
* @throws LambdaConversionException If any of the linkage invariants
|
||||
* described {@link LambdaMetafactory above}
|
||||
* are violated
|
||||
*/
|
||||
public static CallSite altMetafactory(MethodHandles.Lookup caller,
|
||||
String invokedName,
|
||||
MethodType invokedType,
|
||||
Object... args)
|
||||
throws ReflectiveOperationException, LambdaConversionException {
|
||||
throws LambdaConversionException {
|
||||
MethodType samMethodType = (MethodType)args[0];
|
||||
MethodHandle implMethod = (MethodHandle)args[1];
|
||||
MethodType instantiatedMethodType = (MethodType)args[2];
|
||||
@ -294,15 +451,15 @@ public class LambdaMetafactory {
|
||||
else
|
||||
bridges = EMPTY_MT_ARRAY;
|
||||
|
||||
boolean foundSerializableSupertype = Serializable.class.isAssignableFrom(invokedType.returnType());
|
||||
for (Class<?> c : markerInterfaces)
|
||||
foundSerializableSupertype |= Serializable.class.isAssignableFrom(c);
|
||||
boolean isSerializable = ((flags & LambdaMetafactory.FLAG_SERIALIZABLE) != 0)
|
||||
|| foundSerializableSupertype;
|
||||
|
||||
if (isSerializable && !foundSerializableSupertype) {
|
||||
markerInterfaces = Arrays.copyOf(markerInterfaces, markerInterfaces.length + 1);
|
||||
markerInterfaces[markerInterfaces.length-1] = Serializable.class;
|
||||
boolean isSerializable = ((flags & FLAG_SERIALIZABLE) != 0);
|
||||
if (isSerializable) {
|
||||
boolean foundSerializableSupertype = Serializable.class.isAssignableFrom(invokedType.returnType());
|
||||
for (Class<?> c : markerInterfaces)
|
||||
foundSerializableSupertype |= Serializable.class.isAssignableFrom(c);
|
||||
if (!foundSerializableSupertype) {
|
||||
markerInterfaces = Arrays.copyOf(markerInterfaces, markerInterfaces.length + 1);
|
||||
markerInterfaces[markerInterfaces.length-1] = Serializable.class;
|
||||
}
|
||||
}
|
||||
|
||||
AbstractValidatingLambdaMetafactory mf
|
||||
|
@ -441,8 +441,13 @@ class MethodHandleNatives {
|
||||
assert(refKindIsValid(refKind));
|
||||
return lookup.linkMethodHandleConstant((byte) refKind, defc, name, type);
|
||||
} catch (IllegalAccessException ex) {
|
||||
Error err = new IllegalAccessError(ex.getMessage());
|
||||
throw initCauseFrom(err, ex);
|
||||
Throwable cause = ex.getCause();
|
||||
if (cause instanceof AbstractMethodError) {
|
||||
throw (AbstractMethodError) cause;
|
||||
} else {
|
||||
Error err = new IllegalAccessError(ex.getMessage());
|
||||
throw initCauseFrom(err, ex);
|
||||
}
|
||||
} catch (NoSuchMethodException ex) {
|
||||
Error err = new NoSuchMethodError(ex.getMessage());
|
||||
throw initCauseFrom(err, ex);
|
||||
|
@ -1716,6 +1716,13 @@ return mh1;
|
||||
checkSymbolicClass(defc);
|
||||
return mh;
|
||||
}
|
||||
// Treat MethodHandle.invoke and invokeExact specially.
|
||||
if (defc == MethodHandle.class && refKind == REF_invokeVirtual) {
|
||||
mh = findVirtualForMH(member.getName(), member.getMethodType());
|
||||
if (mh != null) {
|
||||
return mh;
|
||||
}
|
||||
}
|
||||
MemberName resolved = resolveOrFail(refKind, member);
|
||||
mh = getDirectMethodForConstant(refKind, defc, resolved);
|
||||
if (mh instanceof DirectMethodHandle
|
||||
@ -1768,12 +1775,6 @@ return mh1;
|
||||
if (MethodHandleNatives.refKindIsField(refKind)) {
|
||||
return getDirectFieldNoSecurityManager(refKind, defc, member);
|
||||
} else if (MethodHandleNatives.refKindIsMethod(refKind)) {
|
||||
if (defc == MethodHandle.class && refKind == REF_invokeVirtual) {
|
||||
MethodHandle mh = findVirtualForMH(member.getName(), member.getMethodType());
|
||||
if (mh != null) {
|
||||
return mh;
|
||||
}
|
||||
}
|
||||
return getDirectMethodNoSecurityManager(refKind, defc, member, lookupClass);
|
||||
} else if (refKind == REF_newInvokeSpecial) {
|
||||
return getDirectConstructorNoSecurityManager(defc, member);
|
||||
|
@ -32,9 +32,26 @@ import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Serialized form of a lambda expression. The properties of this class represent the information that is present
|
||||
* at the lambda factory site, including the identity of the primary functional interface method, the identity of the
|
||||
* implementation method, and any variables captured from the local environment at the time of lambda capture.
|
||||
* Serialized form of a lambda expression. The properties of this class
|
||||
* represent the information that is present at the lambda factory site, including
|
||||
* static metafactory arguments such as the identity of the primary functional
|
||||
* interface method and the identity of the implementation method, as well as
|
||||
* dynamic metafactory arguments such as values captured from the lexical scope
|
||||
* at the time of lambda capture.
|
||||
*
|
||||
* <p>Implementors of serializable lambdas, such as compilers or language
|
||||
* runtime libraries, are expected to ensure that instances deserialize properly.
|
||||
* One means to do so is to ensure that the {@code writeReplace} method returns
|
||||
* an instance of {@code SerializedLambda}, rather than allowing default
|
||||
* serialization to proceed.
|
||||
*
|
||||
* <p>{@code SerializedLambda} has a {@code readResolve} method that looks for
|
||||
* a (possibly private) static method called
|
||||
* {@code $deserializeLambda$(SerializedLambda)} in the capturing class, invokes
|
||||
* that with itself as the first argument, and returns the result. Lambda classes
|
||||
* implementing {@code $deserializeLambda$} are responsible for validating
|
||||
* that the properties of the {@code SerializedLambda} are consistent with a
|
||||
* lambda actually captured by that class.
|
||||
*
|
||||
* @see LambdaMetafactory
|
||||
*/
|
||||
|
@ -28,6 +28,7 @@ package java.lang.invoke;
|
||||
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
||||
import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
import jdk.internal.org.objectweb.asm.Type;
|
||||
import sun.invoke.util.BytecodeDescriptor;
|
||||
import sun.invoke.util.Wrapper;
|
||||
import static sun.invoke.util.Wrapper.*;
|
||||
|
||||
@ -204,27 +205,27 @@ class TypeConvertingMethodAdapter extends MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an argument of type 'argType' to be passed to 'targetType' assuring that it is 'functionalType'.
|
||||
* Convert an argument of type 'arg' to be passed to 'target' assuring that it is 'functional'.
|
||||
* Insert the needed conversion instructions in the method code.
|
||||
* @param argType
|
||||
* @param targetType
|
||||
* @param functionalType
|
||||
* @param arg
|
||||
* @param target
|
||||
* @param functional
|
||||
*/
|
||||
void convertType(String dArg, String dTarget, String dFunctional) {
|
||||
if (dArg.equals(dTarget)) {
|
||||
void convertType(Class<?> arg, Class<?> target, Class<?> functional) {
|
||||
if (arg.equals(target)) {
|
||||
return;
|
||||
}
|
||||
Wrapper wArg = toWrapper(dArg);
|
||||
Wrapper wTarget = toWrapper(dTarget);
|
||||
if (wArg == VOID || wTarget == VOID) {
|
||||
if (arg == Void.TYPE || target == Void.TYPE) {
|
||||
return;
|
||||
}
|
||||
if (isPrimitive(wArg)) {
|
||||
if (isPrimitive(wTarget)) {
|
||||
if (arg.isPrimitive()) {
|
||||
Wrapper wArg = Wrapper.forPrimitiveType(arg);
|
||||
if (target.isPrimitive()) {
|
||||
// Both primitives: widening
|
||||
widen(wArg, wTarget);
|
||||
widen(wArg, Wrapper.forPrimitiveType(target));
|
||||
} else {
|
||||
// Primitive argument to reference target
|
||||
String dTarget = BytecodeDescriptor.unparse(target);
|
||||
Wrapper wPrimTarget = wrapperOrNullFromDescriptor(dTarget);
|
||||
if (wPrimTarget != null) {
|
||||
// The target is a boxed primitive type, widen to get there before boxing
|
||||
@ -237,16 +238,18 @@ class TypeConvertingMethodAdapter extends MethodVisitor {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String dArg = BytecodeDescriptor.unparse(arg);
|
||||
String dSrc;
|
||||
Wrapper wFunctional = toWrapper(dFunctional);
|
||||
if (isPrimitive(wFunctional)) {
|
||||
if (functional.isPrimitive()) {
|
||||
dSrc = dArg;
|
||||
} else {
|
||||
// Cast to convert to possibly more specific type, and generate CCE for invalid arg
|
||||
dSrc = dFunctional;
|
||||
cast(dArg, dFunctional);
|
||||
dSrc = BytecodeDescriptor.unparse(functional);
|
||||
cast(dArg, dSrc);
|
||||
}
|
||||
if (isPrimitive(wTarget)) {
|
||||
String dTarget = BytecodeDescriptor.unparse(target);
|
||||
if (target.isPrimitive()) {
|
||||
Wrapper wTarget = toWrapper(dTarget);
|
||||
// Reference argument to primitive target
|
||||
Wrapper wps = wrapperOrNullFromDescriptor(dSrc);
|
||||
if (wps != null) {
|
||||
|
@ -60,7 +60,7 @@ import sun.management.ManagementFactoryHelper;
|
||||
* one or more <i>platform MXBeans</i> representing
|
||||
* the management interface of a component of the Java virtual
|
||||
* machine.
|
||||
* <p>
|
||||
*
|
||||
* <h3><a name="MXBean">Platform MXBeans</a></h3>
|
||||
* <p>
|
||||
* A platform MXBean is a <i>managed bean</i> that
|
||||
|
@ -33,10 +33,8 @@ package java.lang.management;
|
||||
* The following table
|
||||
* provides a summary description of what the permission allows,
|
||||
* and discusses the risks of granting code the permission.
|
||||
* <P>
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="Table shows permission target name, wh
|
||||
at the permission allows, and associated risks">
|
||||
* <table border=1 cellpadding=5 summary="Table shows permission target name, what the permission allows, and associated risks">
|
||||
* <tr>
|
||||
* <th>Permission Target Name</th>
|
||||
* <th>What the Permission Allows</th>
|
||||
|
@ -79,7 +79,7 @@ import sun.management.MemoryUsageCompositeData;
|
||||
* </table>
|
||||
*
|
||||
* Below is a picture showing an example of a memory pool:
|
||||
* <p>
|
||||
*
|
||||
* <pre>
|
||||
* +----------------------------------------------+
|
||||
* +//////////////// | +
|
||||
@ -250,7 +250,7 @@ public class MemoryUsage {
|
||||
* Returns a <tt>MemoryUsage</tt> object represented by the
|
||||
* given <tt>CompositeData</tt>. The given <tt>CompositeData</tt>
|
||||
* must contain the following attributes:
|
||||
* <p>
|
||||
*
|
||||
* <blockquote>
|
||||
* <table border summary="The attributes and the types the given CompositeData contains">
|
||||
* <tr>
|
||||
|
@ -82,7 +82,7 @@ Java virtual machine and the runtime in the following ways:
|
||||
<b>1. Direct access to an MXBean interface</b>
|
||||
<p>
|
||||
<ul>
|
||||
<li>Get an MXBean instance locally in the running Java virtual machine:<p>
|
||||
<li>Get an MXBean instance locally in the running Java virtual machine:
|
||||
<pre>
|
||||
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
|
||||
|
||||
@ -103,7 +103,7 @@ Java virtual machine and the runtime in the following ways:
|
||||
<p>
|
||||
</li>
|
||||
<li>Construct an MXBean proxy instance that forwards the
|
||||
method calls to a given MBeanServer:<p>
|
||||
method calls to a given MBeanServer:
|
||||
<pre>
|
||||
MBeanServerConnection mbs;
|
||||
|
||||
|
@ -27,6 +27,15 @@ package java.lang.reflect;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.AnnotationFormatError;
|
||||
import java.lang.annotation.Repeatable;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import sun.reflect.annotation.AnnotationSupport;
|
||||
import sun.reflect.annotation.AnnotationType;
|
||||
|
||||
/**
|
||||
* Represents an annotated element of the program currently running in this
|
||||
@ -222,6 +231,18 @@ public interface AnnotatedElement {
|
||||
* The caller of this method is free to modify the returned array; it will
|
||||
* have no effect on the arrays returned to other callers.
|
||||
*
|
||||
* @implSpec The default implementation first calls {@link
|
||||
* #getDeclaredAnnotationsByType(Class)} passing {@code
|
||||
* annotationClass} as the argument. If the returned array has
|
||||
* length greater than zero, the array is returned. If the returned
|
||||
* array is zero-length and this {@code AnnotatedElement} is a
|
||||
* class and the argument type is an inheritable annotation type,
|
||||
* and the superclass of this {@code AnnotatedElement} is non-null,
|
||||
* then the returned result is the result of calling {@link
|
||||
* #getAnnotationsByType(Class)} on the superclass with {@code
|
||||
* annotationClass} as the argument. Otherwise, a zero-length
|
||||
* array is returned.
|
||||
*
|
||||
* @param <T> the type of the annotation to query for and return if present
|
||||
* @param annotationClass the Class object corresponding to the
|
||||
* annotation type
|
||||
@ -230,7 +251,29 @@ public interface AnnotatedElement {
|
||||
* @throws NullPointerException if the given annotation class is null
|
||||
* @since 1.8
|
||||
*/
|
||||
<T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass);
|
||||
default <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
|
||||
/*
|
||||
* Definition of associated: directly or indirectly present OR
|
||||
* neither directly nor indirectly present AND the element is
|
||||
* a Class, the annotation type is inheritable, and the
|
||||
* annotation type is associated with the superclass of the
|
||||
* element.
|
||||
*/
|
||||
T[] result = getDeclaredAnnotationsByType(annotationClass);
|
||||
|
||||
if (result.length == 0 && // Neither directly nor indirectly present
|
||||
this instanceof Class && // the element is a class
|
||||
AnnotationType.getInstance(annotationClass).isInherited()) { // Inheritable
|
||||
Class<?> superClass = ((Class<?>) this).getSuperclass();
|
||||
if (superClass != null) {
|
||||
// Determine if the annotation is associated with the
|
||||
// superclass
|
||||
result = superClass.getAnnotationsByType(annotationClass);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this element's annotation for the specified type if
|
||||
@ -239,6 +282,11 @@ public interface AnnotatedElement {
|
||||
* This method ignores inherited annotations. (Returns null if no
|
||||
* annotations are directly present on this element.)
|
||||
*
|
||||
* @implSpec The default implementation first performs a null check
|
||||
* and then loops over the results of {@link
|
||||
* #getDeclaredAnnotations} returning the first annotation whose
|
||||
* annotation type matches the argument type.
|
||||
*
|
||||
* @param <T> the type of the annotation to query for and return if directly present
|
||||
* @param annotationClass the Class object corresponding to the
|
||||
* annotation type
|
||||
@ -247,7 +295,18 @@ public interface AnnotatedElement {
|
||||
* @throws NullPointerException if the given annotation class is null
|
||||
* @since 1.8
|
||||
*/
|
||||
<T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass);
|
||||
default <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
|
||||
Objects.requireNonNull(annotationClass);
|
||||
// Loop over all directly-present annotations looking for a matching one
|
||||
for (Annotation annotation : getDeclaredAnnotations()) {
|
||||
if (annotationClass.equals(annotation.annotationType())) {
|
||||
// More robust to do a dynamic cast at runtime instead
|
||||
// of compile-time only.
|
||||
return annotationClass.cast(annotation);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this element's annotation(s) for the specified type if
|
||||
@ -268,6 +327,22 @@ public interface AnnotatedElement {
|
||||
* The caller of this method is free to modify the returned array; it will
|
||||
* have no effect on the arrays returned to other callers.
|
||||
*
|
||||
* @implSpec The default implementation may call {@link
|
||||
* #getDeclaredAnnotation(Class)} one or more times to find a
|
||||
* directly present annotation and, if the annotation type is
|
||||
* repeatable, to find a container annotation. If annotations of
|
||||
* the annotation type {@code annotationClass} are found to be both
|
||||
* directly and indirectly present, then {@link
|
||||
* #getDeclaredAnnotations()} will get called to determine the
|
||||
* order of the elements in the returned array.
|
||||
*
|
||||
* <p>Alternatively, the default implementation may call {@link
|
||||
* #getDeclaredAnnotations()} a single time and the returned array
|
||||
* examined for both directly and indirectly present
|
||||
* annotations. The results of calling {@link
|
||||
* #getDeclaredAnnotations()} are assumed to be consistent with the
|
||||
* results of calling {@link #getDeclaredAnnotation(Class)}.
|
||||
*
|
||||
* @param <T> the type of the annotation to query for and return
|
||||
* if directly or indirectly present
|
||||
* @param annotationClass the Class object corresponding to the
|
||||
@ -277,7 +352,16 @@ public interface AnnotatedElement {
|
||||
* @throws NullPointerException if the given annotation class is null
|
||||
* @since 1.8
|
||||
*/
|
||||
<T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass);
|
||||
default <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
|
||||
Objects.requireNonNull(annotationClass);
|
||||
return AnnotationSupport.
|
||||
getDirectlyAndIndirectlyPresent(Arrays.stream(getDeclaredAnnotations()).
|
||||
collect(Collectors.toMap(Annotation::annotationType,
|
||||
Function.identity(),
|
||||
((first,second) -> first),
|
||||
LinkedHashMap::new)),
|
||||
annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns annotations that are <em>directly present</em> on this element.
|
||||
|
@ -28,6 +28,8 @@ package java.lang.reflect;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.ConstructorAccessor;
|
||||
import sun.reflect.Reflection;
|
||||
import sun.reflect.annotation.TypeAnnotation;
|
||||
import sun.reflect.annotation.TypeAnnotationParser;
|
||||
import sun.reflect.generics.repository.ConstructorRepository;
|
||||
import sun.reflect.generics.factory.CoreReflectionFactory;
|
||||
import sun.reflect.generics.factory.GenericsFactory;
|
||||
@ -534,4 +536,22 @@ public final class Constructor<T> extends Executable {
|
||||
public AnnotatedType getAnnotatedReturnType() {
|
||||
return getAnnotatedReturnType0(getDeclaringClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.8
|
||||
*/
|
||||
@Override
|
||||
public AnnotatedType getAnnotatedReceiverType() {
|
||||
if (getDeclaringClass().getEnclosingClass() == null)
|
||||
return super.getAnnotatedReceiverType();
|
||||
|
||||
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
getDeclaringClass().getEnclosingClass(),
|
||||
TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
|
||||
}
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ public abstract class Executable extends AccessibleObject
|
||||
private transient volatile Parameter[] parameters;
|
||||
|
||||
private native Parameter[] getParameters0();
|
||||
private native byte[] getTypeAnnotationBytes0();
|
||||
native byte[] getTypeAnnotationBytes0();
|
||||
|
||||
// Needed by reflectaccess
|
||||
byte[] getTypeAnnotationBytes() {
|
||||
@ -527,7 +527,7 @@ public abstract class Executable extends AccessibleObject
|
||||
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
|
||||
Objects.requireNonNull(annotationClass);
|
||||
|
||||
return AnnotationSupport.getMultipleAnnotations(declaredAnnotations(), annotationClass);
|
||||
return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1123,7 +1123,7 @@ class Field extends AccessibleObject implements Member {
|
||||
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
|
||||
Objects.requireNonNull(annotationClass);
|
||||
|
||||
return AnnotationSupport.getMultipleAnnotations(declaredAnnotations(), annotationClass);
|
||||
return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,7 +295,7 @@ public final class Parameter implements AnnotatedElement {
|
||||
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
|
||||
Objects.requireNonNull(annotationClass);
|
||||
|
||||
return AnnotationSupport.getMultipleAnnotations(declaredAnnotations(), annotationClass);
|
||||
return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,6 @@ package java.lang.reflect;
|
||||
* The following table
|
||||
* provides a summary description of what the permission allows,
|
||||
* and discusses the risks of granting code the permission.
|
||||
* <P>
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="Table shows permission target name, what the permission allows, and associated risks">
|
||||
* <tr>
|
||||
|
@ -97,6 +97,21 @@ import sun.misc.FloatConsts;
|
||||
* {@code NullPointerException} when passed
|
||||
* a null object reference for any input parameter.
|
||||
*
|
||||
* BigInteger must support values in the range
|
||||
* -2<sup>{@code Integer.MAX_VALUE}</sup> (exclusive) to
|
||||
* +2<sup>{@code Integer.MAX_VALUE}</sup> (exclusive)
|
||||
* and may support values outside of that range.
|
||||
*
|
||||
* The range of probable prime values is limited and may be less than
|
||||
* the full supported positive range of {@code BigInteger}.
|
||||
* The range must be at least 1 to 2<sup>500000000</sup>.
|
||||
*
|
||||
* @implNote
|
||||
* BigInteger constructors and operations throw {@code ArithmeticException} when
|
||||
* the result is out of the supported range of
|
||||
* -2<sup>{@code Integer.MAX_VALUE}</sup> (exclusive) to
|
||||
* +2<sup>{@code Integer.MAX_VALUE}</sup> (exclusive).
|
||||
*
|
||||
* @see BigDecimal
|
||||
* @author Josh Bloch
|
||||
* @author Michael McCloskey
|
||||
@ -182,6 +197,18 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
*/
|
||||
final static long LONG_MASK = 0xffffffffL;
|
||||
|
||||
/**
|
||||
* This constant limits {@code mag.length} of BigIntegers to the supported
|
||||
* range.
|
||||
*/
|
||||
private static final int MAX_MAG_LENGTH = Integer.MAX_VALUE / Integer.SIZE + 1; // (1 << 26)
|
||||
|
||||
/**
|
||||
* Bit lengths larger than this constant can cause overflow in searchLen
|
||||
* calculation and in BitSieve.singleSearch method.
|
||||
*/
|
||||
private static final int PRIME_SEARCH_BIT_LENGTH_LIMIT = 500000000;
|
||||
|
||||
/**
|
||||
* The threshold value for using Karatsuba multiplication. If the number
|
||||
* of ints in both mag arrays are greater than this number, then
|
||||
@ -256,6 +283,9 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
mag = stripLeadingZeroBytes(val);
|
||||
signum = (mag.length == 0 ? 0 : 1);
|
||||
}
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,6 +305,9 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
mag = trustedStripLeadingZeroInts(val);
|
||||
signum = (mag.length == 0 ? 0 : 1);
|
||||
}
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,6 +339,9 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
throw(new NumberFormatException("signum-magnitude mismatch"));
|
||||
this.signum = signum;
|
||||
}
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,6 +363,9 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
throw(new NumberFormatException("signum-magnitude mismatch"));
|
||||
this.signum = signum;
|
||||
}
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -359,17 +398,20 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
int sign = 1;
|
||||
int index1 = val.lastIndexOf('-');
|
||||
int index2 = val.lastIndexOf('+');
|
||||
if ((index1 + index2) <= -1) {
|
||||
// No leading sign character or at most one leading sign character
|
||||
if (index1 == 0 || index2 == 0) {
|
||||
cursor = 1;
|
||||
if (len == 1)
|
||||
throw new NumberFormatException("Zero length BigInteger");
|
||||
if (index1 >= 0) {
|
||||
if (index1 != 0 || index2 >= 0) {
|
||||
throw new NumberFormatException("Illegal embedded sign character");
|
||||
}
|
||||
if (index1 == 0)
|
||||
sign = -1;
|
||||
} else
|
||||
throw new NumberFormatException("Illegal embedded sign character");
|
||||
sign = -1;
|
||||
cursor = 1;
|
||||
} else if (index2 >= 0) {
|
||||
if (index2 != 0) {
|
||||
throw new NumberFormatException("Illegal embedded sign character");
|
||||
}
|
||||
cursor = 1;
|
||||
}
|
||||
if (cursor == len)
|
||||
throw new NumberFormatException("Zero length BigInteger");
|
||||
|
||||
// Skip leading zeros and compute number of digits in magnitude
|
||||
while (cursor < len &&
|
||||
@ -388,8 +430,11 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
|
||||
// Pre-allocate array of expected size. May be too large but can
|
||||
// never be too small. Typically exact.
|
||||
int numBits = (int)(((numDigits * bitsPerDigit[radix]) >>> 10) + 1);
|
||||
int numWords = (numBits + 31) >>> 5;
|
||||
long numBits = ((numDigits * bitsPerDigit[radix]) >>> 10) + 1;
|
||||
if (numBits + 31 >= (1L << 32)) {
|
||||
reportOverflow();
|
||||
}
|
||||
int numWords = (int) (numBits + 31) >>> 5;
|
||||
int[] magnitude = new int[numWords];
|
||||
|
||||
// Process first (potentially short) digit group
|
||||
@ -413,6 +458,9 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
}
|
||||
// Required for cases where the array was overallocated.
|
||||
mag = trustedStripLeadingZeroInts(magnitude);
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -439,8 +487,11 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
if (len < 10) {
|
||||
numWords = 1;
|
||||
} else {
|
||||
int numBits = (int)(((numDigits * bitsPerDigit[10]) >>> 10) + 1);
|
||||
numWords = (numBits + 31) >>> 5;
|
||||
long numBits = ((numDigits * bitsPerDigit[10]) >>> 10) + 1;
|
||||
if (numBits + 31 >= (1L << 32)) {
|
||||
reportOverflow();
|
||||
}
|
||||
numWords = (int) (numBits + 31) >>> 5;
|
||||
}
|
||||
int[] magnitude = new int[numWords];
|
||||
|
||||
@ -456,6 +507,9 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
destructiveMulAdd(magnitude, intRadix[10], groupVal);
|
||||
}
|
||||
mag = trustedStripLeadingZeroInts(magnitude);
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
}
|
||||
|
||||
// Create an integer with the digits between the two indexes
|
||||
@ -575,7 +629,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
* this constructor is proportional to the value of this parameter.
|
||||
* @param rnd source of random bits used to select candidates to be
|
||||
* tested for primality.
|
||||
* @throws ArithmeticException {@code bitLength < 2}.
|
||||
* @throws ArithmeticException {@code bitLength < 2} or {@code bitLength} is too large.
|
||||
* @see #bitLength()
|
||||
*/
|
||||
public BigInteger(int bitLength, int certainty, Random rnd) {
|
||||
@ -607,7 +661,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
* @param rnd source of random bits used to select candidates to be
|
||||
* tested for primality.
|
||||
* @return a BigInteger of {@code bitLength} bits that is probably prime
|
||||
* @throws ArithmeticException {@code bitLength < 2}.
|
||||
* @throws ArithmeticException {@code bitLength < 2} or {@code bitLength} is too large.
|
||||
* @see #bitLength()
|
||||
* @since 1.4
|
||||
*/
|
||||
@ -677,7 +731,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
p.mag[p.mag.length-1] &= 0xfffffffe;
|
||||
|
||||
// Use a sieve length likely to contain the next prime number
|
||||
int searchLen = (bitLength / 20) * 64;
|
||||
int searchLen = getPrimeSearchLen(bitLength);
|
||||
BitSieve searchSieve = new BitSieve(p, searchLen);
|
||||
BigInteger candidate = searchSieve.retrieve(p, certainty, rnd);
|
||||
|
||||
@ -701,7 +755,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
*
|
||||
* @return the first integer greater than this {@code BigInteger} that
|
||||
* is probably prime.
|
||||
* @throws ArithmeticException {@code this < 0}.
|
||||
* @throws ArithmeticException {@code this < 0} or {@code this} is too large.
|
||||
* @since 1.5
|
||||
*/
|
||||
public BigInteger nextProbablePrime() {
|
||||
@ -750,7 +804,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
result = result.subtract(ONE);
|
||||
|
||||
// Looking for the next large prime
|
||||
int searchLen = (result.bitLength() / 20) * 64;
|
||||
int searchLen = getPrimeSearchLen(result.bitLength());
|
||||
|
||||
while (true) {
|
||||
BitSieve searchSieve = new BitSieve(result, searchLen);
|
||||
@ -762,6 +816,13 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
}
|
||||
}
|
||||
|
||||
private static int getPrimeSearchLen(int bitLength) {
|
||||
if (bitLength > PRIME_SEARCH_BIT_LENGTH_LIMIT + 1) {
|
||||
throw new ArithmeticException("Prime search implementation restriction on bitLength");
|
||||
}
|
||||
return bitLength / 20 * 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this BigInteger is probably prime,
|
||||
* {@code false} if it's definitely composite.
|
||||
@ -965,6 +1026,9 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
BigInteger(int[] magnitude, int signum) {
|
||||
this.signum = (magnitude.length == 0 ? 0 : signum);
|
||||
this.mag = magnitude;
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -974,6 +1038,25 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
private BigInteger(byte[] magnitude, int signum) {
|
||||
this.signum = (magnitude.length == 0 ? 0 : signum);
|
||||
this.mag = stripLeadingZeroBytes(magnitude);
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an {@code ArithmeticException} if the {@code BigInteger} would be
|
||||
* out of the supported range.
|
||||
*
|
||||
* @throws ArithmeticException if {@code this} exceeds the supported range.
|
||||
*/
|
||||
private void checkRange() {
|
||||
if (mag.length > MAX_MAG_LENGTH || mag.length == MAX_MAG_LENGTH && mag[0] < 0) {
|
||||
reportOverflow();
|
||||
}
|
||||
}
|
||||
|
||||
private static void reportOverflow() {
|
||||
throw new ArithmeticException("BigInteger would overflow supported range");
|
||||
}
|
||||
|
||||
//Static Factory Methods
|
||||
@ -2073,6 +2156,10 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
// The remaining part can then be exponentiated faster. The
|
||||
// powers of two will be multiplied back at the end.
|
||||
int powersOfTwo = partToSquare.getLowestSetBit();
|
||||
long bitsToShift = (long)powersOfTwo * exponent;
|
||||
if (bitsToShift > Integer.MAX_VALUE) {
|
||||
reportOverflow();
|
||||
}
|
||||
|
||||
int remainingBits;
|
||||
|
||||
@ -2126,11 +2213,10 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
|
||||
// Multiply back the powers of two (quickly, by shifting left)
|
||||
if (powersOfTwo > 0) {
|
||||
int bitsToShift = powersOfTwo*exponent;
|
||||
if (bitsToShift + scaleFactor <= 62) { // Fits in long?
|
||||
return valueOf((result << bitsToShift) * newSign);
|
||||
} else {
|
||||
return valueOf(result*newSign).shiftLeft(bitsToShift);
|
||||
return valueOf(result*newSign).shiftLeft((int) bitsToShift);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -2375,8 +2461,17 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
BigInteger y1 = m2.modInverse(m1);
|
||||
BigInteger y2 = m1.modInverse(m2);
|
||||
|
||||
result = a1.multiply(m2).multiply(y1).add
|
||||
(a2.multiply(m1).multiply(y2)).mod(m);
|
||||
if (m.mag.length < MAX_MAG_LENGTH / 2) {
|
||||
result = a1.multiply(m2).multiply(y1).add(a2.multiply(m1).multiply(y2)).mod(m);
|
||||
} else {
|
||||
MutableBigInteger t1 = new MutableBigInteger();
|
||||
new MutableBigInteger(a1.multiply(m2)).multiply(new MutableBigInteger(y1), t1);
|
||||
MutableBigInteger t2 = new MutableBigInteger();
|
||||
new MutableBigInteger(a2.multiply(m1)).multiply(new MutableBigInteger(y2), t2);
|
||||
t1.add(t2);
|
||||
MutableBigInteger q = new MutableBigInteger();
|
||||
result = t1.divide(new MutableBigInteger(m), q).toBigInteger();
|
||||
}
|
||||
}
|
||||
|
||||
return (invertResult ? result.modInverse(m) : result);
|
||||
@ -2797,27 +2892,31 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
*
|
||||
* @param n shift distance, in bits.
|
||||
* @return {@code this << n}
|
||||
* @throws ArithmeticException if the shift distance is {@code
|
||||
* Integer.MIN_VALUE}.
|
||||
* @see #shiftRight
|
||||
*/
|
||||
public BigInteger shiftLeft(int n) {
|
||||
if (signum == 0)
|
||||
return ZERO;
|
||||
if (n == 0)
|
||||
if (n > 0) {
|
||||
return new BigInteger(shiftLeft(mag, n), signum);
|
||||
} else if (n == 0) {
|
||||
return this;
|
||||
if (n < 0) {
|
||||
if (n == Integer.MIN_VALUE) {
|
||||
throw new ArithmeticException("Shift distance of Integer.MIN_VALUE not supported.");
|
||||
} else {
|
||||
return shiftRight(-n);
|
||||
}
|
||||
} else {
|
||||
// Possible int overflow in (-n) is not a trouble,
|
||||
// because shiftRightImpl considers its argument unsigned
|
||||
return shiftRightImpl(-n);
|
||||
}
|
||||
int[] newMag = shiftLeft(mag, n);
|
||||
|
||||
return new BigInteger(newMag, signum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a magnitude array whose value is {@code (mag << n)}.
|
||||
* The shift distance, {@code n}, is considered unnsigned.
|
||||
* (Computes <tt>this * 2<sup>n</sup></tt>.)
|
||||
*
|
||||
* @param mag magnitude, the most-significant int ({@code mag[0]}) must be non-zero.
|
||||
* @param n unsigned shift distance, in bits.
|
||||
* @return {@code mag << n}
|
||||
*/
|
||||
private static int[] shiftLeft(int[] mag, int n) {
|
||||
int nInts = n >>> 5;
|
||||
int nBits = n & 0x1f;
|
||||
@ -2853,21 +2952,31 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
*
|
||||
* @param n shift distance, in bits.
|
||||
* @return {@code this >> n}
|
||||
* @throws ArithmeticException if the shift distance is {@code
|
||||
* Integer.MIN_VALUE}.
|
||||
* @see #shiftLeft
|
||||
*/
|
||||
public BigInteger shiftRight(int n) {
|
||||
if (n == 0)
|
||||
if (signum == 0)
|
||||
return ZERO;
|
||||
if (n > 0) {
|
||||
return shiftRightImpl(n);
|
||||
} else if (n == 0) {
|
||||
return this;
|
||||
if (n < 0) {
|
||||
if (n == Integer.MIN_VALUE) {
|
||||
throw new ArithmeticException("Shift distance of Integer.MIN_VALUE not supported.");
|
||||
} else {
|
||||
return shiftLeft(-n);
|
||||
}
|
||||
} else {
|
||||
// Possible int overflow in {@code -n} is not a trouble,
|
||||
// because shiftLeft considers its argument unsigned
|
||||
return new BigInteger(shiftLeft(mag, -n), signum);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a BigInteger whose value is {@code (this >> n)}. The shift
|
||||
* distance, {@code n}, is considered unsigned.
|
||||
* (Computes <tt>floor(this * 2<sup>-n</sup>)</tt>.)
|
||||
*
|
||||
* @param n unsigned shift distance, in bits.
|
||||
* @return {@code this >> n}
|
||||
*/
|
||||
private BigInteger shiftRightImpl(int n) {
|
||||
int nInts = n >>> 5;
|
||||
int nBits = n & 0x1f;
|
||||
int magLen = mag.length;
|
||||
@ -3899,7 +4008,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
;
|
||||
|
||||
int extraByte = (k == byteLength) ? 1 : 0;
|
||||
int intLength = ((byteLength - keep + extraByte) + 3)/4;
|
||||
int intLength = ((byteLength - keep + extraByte) + 3) >>> 2;
|
||||
int result[] = new int[intLength];
|
||||
|
||||
/* Copy one's complement of input into output, leaving extra
|
||||
@ -4135,7 +4244,8 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
message = "BigInteger: Signum not present in stream";
|
||||
throw new java.io.StreamCorruptedException(message);
|
||||
}
|
||||
if ((magnitude.length == 0) != (sign == 0)) {
|
||||
int[] mag = stripLeadingZeroBytes(magnitude);
|
||||
if ((mag.length == 0) != (sign == 0)) {
|
||||
String message = "BigInteger: signum-magnitude mismatch";
|
||||
if (fields.defaulted("magnitude"))
|
||||
message = "BigInteger: Magnitude not present in stream";
|
||||
@ -4146,7 +4256,14 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
UnsafeHolder.putSign(this, sign);
|
||||
|
||||
// Calculate mag field from magnitude and discard magnitude
|
||||
UnsafeHolder.putMag(this, stripLeadingZeroBytes(magnitude));
|
||||
UnsafeHolder.putMag(this, mag);
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
try {
|
||||
checkRange();
|
||||
} catch (ArithmeticException e) {
|
||||
throw new java.io.StreamCorruptedException("BigInteger: Out of the supported range");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Support for resetting final fields while deserializing
|
||||
|
@ -1257,14 +1257,14 @@ class MutableBigInteger {
|
||||
|
||||
int j = (s+m-1) / m; // step 2a: j = ceil(s/m)
|
||||
int n = j * m; // step 2b: block length in 32-bit units
|
||||
int n32 = 32 * n; // block length in bits
|
||||
int sigma = Math.max(0, n32 - b.bitLength()); // step 3: sigma = max{T | (2^T)*B < beta^n}
|
||||
long n32 = 32L * n; // block length in bits
|
||||
int sigma = (int) Math.max(0, n32 - b.bitLength()); // step 3: sigma = max{T | (2^T)*B < beta^n}
|
||||
MutableBigInteger bShifted = new MutableBigInteger(b);
|
||||
bShifted.safeLeftShift(sigma); // step 4a: shift b so its length is a multiple of n
|
||||
safeLeftShift(sigma); // step 4b: shift this by the same amount
|
||||
|
||||
// step 5: t is the number of blocks needed to accommodate this plus one additional bit
|
||||
int t = (bitLength()+n32) / n32;
|
||||
int t = (int) ((bitLength()+n32) / n32);
|
||||
if (t < 2) {
|
||||
t = 2;
|
||||
}
|
||||
@ -1421,10 +1421,10 @@ class MutableBigInteger {
|
||||
}
|
||||
|
||||
/** @see BigInteger#bitLength() */
|
||||
int bitLength() {
|
||||
long bitLength() {
|
||||
if (intLen == 0)
|
||||
return 0;
|
||||
return intLen*32 - Integer.numberOfLeadingZeros(value[offset]);
|
||||
return intLen*32L - Integer.numberOfLeadingZeros(value[offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,7 +196,7 @@ class DatagramSocket implements java.io.Closeable {
|
||||
* socket address.
|
||||
* <p>
|
||||
* If, if the address is {@code null}, creates an unbound socket.
|
||||
* <p>
|
||||
*
|
||||
* <p>If there is a security manager,
|
||||
* its {@code checkListen} method is first called
|
||||
* with the port from the socket address
|
||||
@ -1109,7 +1109,7 @@ class DatagramSocket implements java.io.Closeable {
|
||||
* represent the value of the TOS octet in IP packets sent by
|
||||
* the socket.
|
||||
* RFC 1349 defines the TOS values as follows:
|
||||
* <p>
|
||||
*
|
||||
* <UL>
|
||||
* <LI><CODE>IPTOS_LOWCOST (0x02)</CODE></LI>
|
||||
* <LI><CODE>IPTOS_RELIABILITY (0x04)</CODE></LI>
|
||||
|
@ -761,7 +761,7 @@ public final class HttpCookie implements Cloneable {
|
||||
// from RFC 2068, token special case characters
|
||||
//
|
||||
// private static final String tspecials = "()<>@,;:\\\"/[]?={} \t";
|
||||
private static final String tspecials = ",;";
|
||||
private static final String tspecials = ",; "; // deliberately includes space
|
||||
|
||||
/*
|
||||
* Tests a string and returns true if the string counts as a token.
|
||||
|
@ -133,7 +133,7 @@ import java.util.Arrays;
|
||||
* representation. However, it will be converted into an IPv4
|
||||
* address.</td></tr>
|
||||
* </table></blockquote>
|
||||
* <p>
|
||||
*
|
||||
* <h4><A NAME="scoped">Textual representation of IPv6 scoped addresses</a></h4>
|
||||
*
|
||||
* <p> The textual representation of IPv6 addresses as described above can be
|
||||
@ -150,11 +150,11 @@ import java.util.Arrays;
|
||||
*
|
||||
* <p> The general format for specifying the <i>scope_id</i> is the following:
|
||||
*
|
||||
* <p><blockquote><i>IPv6-address</i>%<i>scope_id</i></blockquote>
|
||||
* <blockquote><i>IPv6-address</i>%<i>scope_id</i></blockquote>
|
||||
* <p> The IPv6-address is a literal IPv6 address as described above.
|
||||
* The <i>scope_id</i> refers to an interface on the local system, and it can be
|
||||
* specified in two ways.
|
||||
* <p><ol><li><i>As a numeric identifier.</i> This must be a positive integer
|
||||
* <ol><li><i>As a numeric identifier.</i> This must be a positive integer
|
||||
* that identifies the particular interface and scope as understood by the
|
||||
* system. Usually, the numeric values can be determined through administration
|
||||
* tools on the system. Each interface may have multiple values, one for each
|
||||
|
@ -140,7 +140,7 @@ class MulticastSocket extends DatagramSocket {
|
||||
* Create a MulticastSocket bound to the specified socket address.
|
||||
* <p>
|
||||
* Or, if the address is {@code null}, create an unbound socket.
|
||||
* <p>
|
||||
*
|
||||
* <p>If there is a security manager,
|
||||
* its {@code checkListen} method is first called
|
||||
* with the SocketAddress port as its argument to ensure the operation is allowed.
|
||||
|
@ -46,7 +46,6 @@ import java.util.StringTokenizer;
|
||||
* The following table lists all the possible NetPermission target names,
|
||||
* and for each provides a description of what the permission allows
|
||||
* and a discussion of the risks of granting code the permission.
|
||||
* <P>
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="Permission target name, what the permission allows, and associated risks">
|
||||
* <tr>
|
||||
|
@ -66,8 +66,8 @@ public class Proxy {
|
||||
* Used, for instance, to create sockets bypassing any other global
|
||||
* proxy settings (like SOCKS):
|
||||
* <P>
|
||||
* {@code Socket s = new Socket(Proxy.NO_PROXY);}<br>
|
||||
* <P>
|
||||
* {@code Socket s = new Socket(Proxy.NO_PROXY);}
|
||||
*
|
||||
*/
|
||||
public final static Proxy NO_PROXY = new Proxy();
|
||||
|
||||
|
@ -1230,13 +1230,13 @@ class Socket implements java.io.Closeable {
|
||||
* Generally, the window size can be modified at any time when a socket is
|
||||
* connected. However, if a receive window larger than 64K is required then
|
||||
* this must be requested <B>before</B> the socket is connected to the
|
||||
* remote peer. There are two cases to be aware of:<p>
|
||||
* remote peer. There are two cases to be aware of:
|
||||
* <ol>
|
||||
* <li>For sockets accepted from a ServerSocket, this must be done by calling
|
||||
* {@link ServerSocket#setReceiveBufferSize(int)} before the ServerSocket
|
||||
* is bound to a local address.<p></li>
|
||||
* <li>For client sockets, setReceiveBufferSize() must be called before
|
||||
* connecting the socket to its remote peer.<p></li></ol>
|
||||
* connecting the socket to its remote peer.</li></ol>
|
||||
* @param size the size to which to set the receive buffer
|
||||
* size. This value must be greater than 0.
|
||||
*
|
||||
@ -1329,7 +1329,7 @@ class Socket implements java.io.Closeable {
|
||||
* represent the value of the TOS octet in IP packets sent by
|
||||
* the socket.
|
||||
* RFC 1349 defines the TOS values as follows:
|
||||
* <p>
|
||||
*
|
||||
* <UL>
|
||||
* <LI><CODE>IPTOS_LOWCOST (0x02)</CODE></LI>
|
||||
* <LI><CODE>IPTOS_RELIABILITY (0x04)</CODE></LI>
|
||||
|
@ -134,7 +134,7 @@ public interface SocketOptions {
|
||||
* previously written data.
|
||||
*<P>
|
||||
* Valid for TCP only: SocketImpl.
|
||||
* <P>
|
||||
*
|
||||
* @see Socket#setTcpNoDelay
|
||||
* @see Socket#getTcpNoDelay
|
||||
*/
|
||||
@ -155,7 +155,7 @@ public interface SocketOptions {
|
||||
* This option <B>must</B> be specified in the constructor.
|
||||
* <P>
|
||||
* Valid for: SocketImpl, DatagramSocketImpl
|
||||
* <P>
|
||||
*
|
||||
* @see Socket#getLocalAddress
|
||||
* @see DatagramSocket#getLocalAddress
|
||||
*/
|
||||
@ -186,7 +186,7 @@ public interface SocketOptions {
|
||||
* want to use other than the system default. Takes/returns an InetAddress.
|
||||
* <P>
|
||||
* Valid for Multicast: DatagramSocketImpl
|
||||
* <P>
|
||||
*
|
||||
* @see MulticastSocket#setInterface(InetAddress)
|
||||
* @see MulticastSocket#getInterface()
|
||||
*/
|
||||
|
@ -779,27 +779,27 @@ public final class SocketPermission extends Permission
|
||||
* specified permission.
|
||||
* <P>
|
||||
* More specifically, this method first ensures that all of the following
|
||||
* are true (and returns false if any of them are not):<p>
|
||||
* are true (and returns false if any of them are not):
|
||||
* <ul>
|
||||
* <li> <i>p</i> is an instanceof SocketPermission,<p>
|
||||
* <li> <i>p</i> is an instanceof SocketPermission,
|
||||
* <li> <i>p</i>'s actions are a proper subset of this
|
||||
* object's actions, and<p>
|
||||
* object's actions, and
|
||||
* <li> <i>p</i>'s port range is included in this port range. Note:
|
||||
* port range is ignored when p only contains the action, 'resolve'.<p>
|
||||
* port range is ignored when p only contains the action, 'resolve'.
|
||||
* </ul>
|
||||
*
|
||||
* Then {@code implies} checks each of the following, in order,
|
||||
* and for each returns true if the stated condition is true:<p>
|
||||
* and for each returns true if the stated condition is true:
|
||||
* <ul>
|
||||
* <li> If this object was initialized with a single IP address and one of <i>p</i>'s
|
||||
* IP addresses is equal to this object's IP address.<p>
|
||||
* IP addresses is equal to this object's IP address.
|
||||
* <li>If this object is a wildcard domain (such as *.sun.com), and
|
||||
* <i>p</i>'s canonical name (the name without any preceding *)
|
||||
* ends with this object's canonical host name. For example, *.sun.com
|
||||
* implies *.eng.sun.com..<p>
|
||||
* implies *.eng.sun.com.
|
||||
* <li>If this object was not initialized with a single IP address, and one of this
|
||||
* object's IP addresses equals one of <i>p</i>'s IP addresses.<p>
|
||||
* <li>If this canonical name equals <i>p</i>'s canonical name.<p>
|
||||
* object's IP addresses equals one of <i>p</i>'s IP addresses.
|
||||
* <li>If this canonical name equals <i>p</i>'s canonical name.
|
||||
* </ul>
|
||||
*
|
||||
* If none of the above are true, {@code implies} returns false.
|
||||
|
@ -389,20 +389,20 @@ import java.lang.NullPointerException; // for javadoc
|
||||
* colon following a host name but no port (as in
|
||||
* {@code http://java.sun.com:} ), and that does not encode characters
|
||||
* except those that must be quoted, the following identities also hold:
|
||||
* <p><pre>
|
||||
* <pre>
|
||||
* new URI(<i>u</i>.getScheme(),
|
||||
* <i>u</i>.getSchemeSpecificPart(),
|
||||
* <i>u</i>.getFragment())
|
||||
* .equals(<i>u</i>)</pre>
|
||||
* in all cases,
|
||||
* <p><pre>
|
||||
* <pre>
|
||||
* new URI(<i>u</i>.getScheme(),
|
||||
* <i>u</i>.getUserInfo(), <i>u</i>.getAuthority(),
|
||||
* <i>u</i>.getPath(), <i>u</i>.getQuery(),
|
||||
* <i>u</i>.getFragment())
|
||||
* .equals(<i>u</i>)</pre>
|
||||
* if <i>u</i> is hierarchical, and
|
||||
* <p><pre>
|
||||
* <pre>
|
||||
* new URI(<i>u</i>.getScheme(),
|
||||
* <i>u</i>.getUserInfo(), <i>u</i>.getHost(), <i>u</i>.getPort(),
|
||||
* <i>u</i>.getPath(), <i>u</i>.getQuery(),
|
||||
|
@ -25,21 +25,30 @@
|
||||
|
||||
package java.net;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Attributes.Name;
|
||||
import java.security.CodeSigner;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.AccessController;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FilePermission;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.SecureClassLoader;
|
||||
import java.security.AccessController;
|
||||
import java.security.CodeSigner;
|
||||
import java.security.CodeSource;
|
||||
import java.security.Permission;
|
||||
import java.security.PermissionCollection;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.SecureClassLoader;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Attributes.Name;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
import sun.misc.Resource;
|
||||
import sun.misc.URLClassPath;
|
||||
import sun.net.www.ParseUtil;
|
||||
@ -84,6 +93,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* {@code checkCreateClassLoader} method doesn't allow
|
||||
* creation of a class loader.
|
||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
||||
* @see SecurityManager#checkCreateClassLoader
|
||||
*/
|
||||
public URLClassLoader(URL[] urls, ClassLoader parent) {
|
||||
@ -127,6 +137,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* {@code checkCreateClassLoader} method doesn't allow
|
||||
* creation of a class loader.
|
||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
||||
* @see SecurityManager#checkCreateClassLoader
|
||||
*/
|
||||
public URLClassLoader(URL[] urls) {
|
||||
@ -169,6 +180,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* {@code checkCreateClassLoader} method doesn't allow
|
||||
* creation of a class loader.
|
||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
||||
* @see SecurityManager#checkCreateClassLoader
|
||||
*/
|
||||
public URLClassLoader(URL[] urls, ClassLoader parent,
|
||||
@ -260,13 +272,13 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* and errors are not caught. Calling close on an already closed
|
||||
* loader has no effect.
|
||||
* <p>
|
||||
* @throws IOException if closing any file opened by this class loader
|
||||
* @exception IOException if closing any file opened by this class loader
|
||||
* resulted in an IOException. Any such exceptions are caught internally.
|
||||
* If only one is caught, then it is re-thrown. If more than one exception
|
||||
* is caught, then the second and following exceptions are added
|
||||
* as suppressed exceptions of the first one caught, which is then re-thrown.
|
||||
*
|
||||
* @throws SecurityException if a security manager is set, and it denies
|
||||
* @exception SecurityException if a security manager is set, and it denies
|
||||
* {@link RuntimePermission}{@code ("closeClassLoader")}
|
||||
*
|
||||
* @since 1.7
|
||||
@ -339,6 +351,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* @return the resulting class
|
||||
* @exception ClassNotFoundException if the class could not be found,
|
||||
* or if the loader is closed.
|
||||
* @exception NullPointerException if {@code name} is {@code null}.
|
||||
*/
|
||||
protected Class<?> findClass(final String name)
|
||||
throws ClassNotFoundException
|
||||
@ -621,6 +634,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* If the protocol is not "file", then permission
|
||||
* to connect to and accept connections from the URL's host is granted.
|
||||
* @param codesource the codesource
|
||||
* @exception NullPointerException if {@code codesource} is {@code null}.
|
||||
* @return the permissions granted to the codesource
|
||||
*/
|
||||
protected PermissionCollection getPermissions(CodeSource codesource)
|
||||
@ -700,6 +714,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
*
|
||||
* @param urls the URLs to search for classes and resources
|
||||
* @param parent the parent class loader for delegation
|
||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
||||
* @return the resulting class loader
|
||||
*/
|
||||
public static URLClassLoader newInstance(final URL[] urls,
|
||||
@ -725,6 +740,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* loading the class.
|
||||
*
|
||||
* @param urls the URLs to search for classes and resources
|
||||
* @exception NullPointerException if {@code urls} is {@code null}.
|
||||
* @return the resulting class loader
|
||||
*/
|
||||
public static URLClassLoader newInstance(final URL[] urls) {
|
||||
|
@ -45,7 +45,7 @@ import sun.net.www.MessageHeader;
|
||||
* application and a URL. Instances of this class can be used both to
|
||||
* read from and to write to the resource referenced by the URL. In
|
||||
* general, creating a connection to a URL is a multistep process:
|
||||
* <p>
|
||||
*
|
||||
* <center><table border=2 summary="Describes the process of creating a connection to a URL: openConnection() and connect() over time.">
|
||||
* <tr><th>{@code openConnection()}</th>
|
||||
* <th>{@code connect()}</th></tr>
|
||||
|
@ -43,7 +43,7 @@ import java.io.*;
|
||||
* as the start of a special escaped sequence.
|
||||
* <p>
|
||||
* The following rules are applied in the conversion:
|
||||
* <p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>The alphanumeric characters "{@code a}" through
|
||||
* "{@code z}", "{@code A}" through
|
||||
|
@ -49,7 +49,6 @@ import sun.security.action.GetPropertyAction;
|
||||
* <p>
|
||||
* When encoding a String, the following rules apply:
|
||||
*
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>The alphanumeric characters "{@code a}" through
|
||||
* "{@code z}", "{@code A}" through
|
||||
|
@ -45,7 +45,7 @@ import java.security.Permission;
|
||||
* </pre>
|
||||
* <i>scheme</i> will typically be http or https, but is not restricted by this
|
||||
* class.
|
||||
* <i>authority</i> is specified as:<p>
|
||||
* <i>authority</i> is specified as:
|
||||
* <pre>
|
||||
* authority = hostrange [ : portrange ]
|
||||
* portrange = portnumber | -portnumber | portnumber-[portnumber] | *
|
||||
@ -223,7 +223,7 @@ public final class URLPermission extends Permission {
|
||||
* Checks if this URLPermission implies the given permission.
|
||||
* Specifically, the following checks are done as if in the
|
||||
* following sequence:
|
||||
* <p><ul>
|
||||
* <ul>
|
||||
* <li>if 'p' is not an instance of URLPermission return false</li>
|
||||
* <li>if any of p's methods are not in this's method list, and if
|
||||
* this's method list is not equal to "*", then return false.</li>
|
||||
@ -242,7 +242,7 @@ public final class URLPermission extends Permission {
|
||||
* <li>otherwise, return false</li>
|
||||
* </ul>
|
||||
* <p>Some examples of how paths are matched are shown below:
|
||||
* <p><table border>
|
||||
* <table border>
|
||||
* <caption>Examples of Path Matching</caption>
|
||||
* <tr><th>this's path</th><th>p's path</th><th>match</th></tr>
|
||||
* <tr><td>/a/b</td><td>/a/b</td><td>yes</td></tr>
|
||||
@ -353,7 +353,7 @@ public final class URLPermission extends Permission {
|
||||
return getActions().hashCode()
|
||||
+ scheme.hashCode()
|
||||
+ authority.hashCode()
|
||||
+ path == null ? 0 : path.hashCode();
|
||||
+ (path == null ? 0 : path.hashCode());
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,9 +127,9 @@
|
||||
* resources, then convert it into a {@link java.net.URL} when it is time to
|
||||
* access the resource. From that URL, you can either get the
|
||||
* {@link java.net.URLConnection} for fine control, or get directly the
|
||||
* InputStream.<p>
|
||||
* InputStream.
|
||||
* <p>Here is an example:</p>
|
||||
* <p><pre>
|
||||
* <pre>
|
||||
* URI uri = new URI("http://java.sun.com/");
|
||||
* URL url = uri.toURL();
|
||||
* InputStream in = url.openStream();
|
||||
@ -147,7 +147,7 @@
|
||||
* the {@code java.protocol.handler.pkgs} system property. For instance if
|
||||
* it is set to {@code myapp.protocols}, then the URL code will try, in the
|
||||
* case of http, first to load {@code myapp.protocols.http.Handler}, then,
|
||||
* if this fails, {@code http.Handler} from the default location.<p>
|
||||
* if this fails, {@code http.Handler} from the default location.
|
||||
* <p>Note that the Handler class <b>has to</b> be a subclass of the abstract
|
||||
* class {@link java.net.URLStreamHandler}.</p>
|
||||
* <h2>Additional Specification</h2>
|
||||
|
@ -1129,7 +1129,7 @@ public abstract class $Type$Buffer
|
||||
*
|
||||
* <p> Two $type$ buffers are equal if, and only if,
|
||||
*
|
||||
* <p><ol>
|
||||
* <ol>
|
||||
*
|
||||
* <li><p> They have the same element type, </p></li>
|
||||
*
|
||||
|
@ -355,7 +355,7 @@ public abstract class FileSystem
|
||||
*
|
||||
* <p> The following rules are used to interpret glob patterns:
|
||||
*
|
||||
* <p> <ul>
|
||||
* <ul>
|
||||
* <li><p> The {@code *} character matches zero or more {@link Character
|
||||
* characters} of a {@link Path#getName(int) name} component without
|
||||
* crossing directory boundaries. </p></li>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,35 +28,38 @@ package java.rmi;
|
||||
import java.security.*;
|
||||
|
||||
/**
|
||||
* A subclass of {@link SecurityManager} used by RMI applications that use
|
||||
* downloaded code. RMI's class loader will not download any classes from
|
||||
* remote locations if no security manager has been set.
|
||||
* <code>RMISecurityManager</code> does not apply to applets, which run
|
||||
* under the protection of their browser's security manager.
|
||||
* {@code RMISecurityManager} implements a policy identical to the policy
|
||||
* implemented by {@link SecurityManager}. RMI applications
|
||||
* should use the {@code SecurityManager} class or another appropriate
|
||||
* {@code SecurityManager} implementation instead of this class. RMI's class
|
||||
* loader will download classes from remote locations only if a security
|
||||
* manager has been set.
|
||||
*
|
||||
* <code>RMISecurityManager</code> implements a policy that
|
||||
* is no different than the policy implemented by {@link SecurityManager}.
|
||||
* Therefore an RMI application should use the <code>SecurityManager</code>
|
||||
* class or another application-specific <code>SecurityManager</code>
|
||||
* implementation instead of this class.
|
||||
* @implNote
|
||||
* <p>Applets typically run in a container that already has a security
|
||||
* manager, so there is generally no need for applets to set a security
|
||||
* manager. If you have a standalone application, you might need to set a
|
||||
* {@code SecurityManager} in order to enable class downloading. This can be
|
||||
* done by adding the following to your code. (It needs to be executed before
|
||||
* RMI can download code from remote hosts, so it most likely needs to appear
|
||||
* in the {@code main} method of your application.)
|
||||
*
|
||||
* <p>To use a <code>SecurityManager</code> in your application, add
|
||||
* the following statement to your code (it needs to be executed before RMI
|
||||
* can download code from remote hosts, so it most likely needs to appear
|
||||
* in the <code>main</code> method of your application):
|
||||
*
|
||||
* <pre>
|
||||
* System.setSecurityManager(new SecurityManager());
|
||||
* </pre>
|
||||
* <pre>{@code
|
||||
* if (System.getSecurityManager() == null) {
|
||||
* System.setSecurityManager(new SecurityManager());
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* @author Roger Riggs
|
||||
* @author Peter Jones
|
||||
* @since JDK1.1
|
||||
**/
|
||||
* @deprecated Use {@link SecurityManager} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class RMISecurityManager extends SecurityManager {
|
||||
|
||||
/**
|
||||
* Constructs a new <code>RMISecurityManager</code>.
|
||||
* Constructs a new {@code RMISecurityManager}.
|
||||
* @since JDK1.1
|
||||
*/
|
||||
public RMISecurityManager() {
|
||||
|
@ -74,7 +74,7 @@ import sun.security.action.GetIntegerAction;
|
||||
* <code>ActivationGroup</code> will override the system properties
|
||||
* with the properties requested when its
|
||||
* <code>ActivationGroupDesc</code> was created, and will set a
|
||||
* <code>java.rmi.RMISecurityManager</code> as the default system
|
||||
* {@link SecurityManager} as the default system
|
||||
* security manager. If your application requires specific properties
|
||||
* to be set when objects are activated in the group, the application
|
||||
* should create a special <code>Properties</code> object containing
|
||||
@ -84,7 +84,7 @@ import sun.security.action.GetIntegerAction;
|
||||
* <code>ActivationDesc</code>s (before the default
|
||||
* <code>ActivationGroupDesc</code> is created). If your application
|
||||
* requires the use of a security manager other than
|
||||
* <code>java.rmi.RMISecurityManager</code>, in the
|
||||
* {@link SecurityManager}, in the
|
||||
* ActivativationGroupDescriptor properties list you can set
|
||||
* <code>java.security.manager</code> property to the name of the security
|
||||
* manager you would like to install.
|
||||
@ -154,21 +154,21 @@ public abstract class ActivationGroup
|
||||
* active). If the object does not call
|
||||
* <code>Activatable.inactive</code> when it deactivates, the
|
||||
* object will never be garbage collected since the group keeps
|
||||
* strong references to the objects it creates. <p>
|
||||
* strong references to the objects it creates.
|
||||
*
|
||||
* <p>The group's <code>inactiveObject</code> method unexports the
|
||||
* remote object from the RMI runtime so that the object can no
|
||||
* longer receive incoming RMI calls. An object will only be unexported
|
||||
* if the object has no pending or executing calls.
|
||||
* The subclass of <code>ActivationGroup</code> must override this
|
||||
* method and unexport the object. <p>
|
||||
* method and unexport the object.
|
||||
*
|
||||
* <p>After removing the object from the RMI runtime, the group
|
||||
* must inform its <code>ActivationMonitor</code> (via the monitor's
|
||||
* <code>inactiveObject</code> method) that the remote object is
|
||||
* not currently active so that the remote object will be
|
||||
* re-activated by the activator upon a subsequent activation
|
||||
* request.<p>
|
||||
* request.
|
||||
*
|
||||
* <p>This method simply informs the group's monitor that the object
|
||||
* is inactive. It is up to the concrete subclass of ActivationGroup
|
||||
@ -235,7 +235,7 @@ public abstract class ActivationGroup
|
||||
* <p>Note that if your application creates its own custom
|
||||
* activation group, a security manager must be set for that
|
||||
* group. Otherwise objects cannot be activated in the group.
|
||||
* <code>java.rmi.RMISecurityManager</code> is set by default.
|
||||
* {@link SecurityManager} is set by default.
|
||||
*
|
||||
* <p>If a security manager is already set in the group VM, this
|
||||
* method first calls the security manager's
|
||||
|
@ -67,7 +67,7 @@ public final class VMID implements java.io.Serializable {
|
||||
* conditions: a) the conditions for uniqueness for objects of
|
||||
* the class <code>java.rmi.server.UID</code> are satisfied, and b) an
|
||||
* address can be obtained for this host that is unique and constant
|
||||
* for the lifetime of this object. <p>
|
||||
* for the lifetime of this object.
|
||||
*/
|
||||
public VMID() {
|
||||
addr = randomBytes;
|
||||
|
@ -41,7 +41,15 @@ import java.net.*;
|
||||
* (due to a firewall), the runtime uses HTTP with the explicit port
|
||||
* number of the server. If the firewall does not allow this type of
|
||||
* communication, then HTTP to a cgi-bin script on the server is used
|
||||
* to POST the RMI call.
|
||||
* to POST the RMI call. The HTTP tunneling mechanisms are disabled by
|
||||
* default. This behavior is controlled by the {@code java.rmi.server.disableHttp}
|
||||
* property, whose default value is {@code true}. Setting this property's
|
||||
* value to {@code false} will enable the HTTP tunneling mechanisms.
|
||||
*
|
||||
* <p><strong>Deprecated: HTTP Tunneling.</strong> <em>The HTTP tunneling mechanisms
|
||||
* described above, specifically HTTP with an explicit port and HTTP to a
|
||||
* cgi-bin script, are deprecated. These HTTP tunneling mechanisms are
|
||||
* subject to removal in a future release of the platform.</em>
|
||||
*
|
||||
* <p>The default socket factory implementation creates server sockets that
|
||||
* are bound to the wildcard address, which accepts requests from all network
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,8 @@
|
||||
package java.rmi.server;
|
||||
|
||||
/**
|
||||
* The <code>RemoteStub</code> class is the common superclass to client
|
||||
* The {@code RemoteStub} class is the common superclass of
|
||||
* statically generated client
|
||||
* stubs and provides the framework to support a wide range of remote
|
||||
* reference semantics. Stub objects are surrogates that support
|
||||
* exactly the same set of remote interfaces defined by the actual
|
||||
@ -33,21 +34,26 @@ package java.rmi.server;
|
||||
*
|
||||
* @author Ann Wollrath
|
||||
* @since JDK1.1
|
||||
*
|
||||
* @deprecated Statically generated stubs are deprecated, since
|
||||
* stubs are generated dynamically. See {@link UnicastRemoteObject}
|
||||
* for information about dynamic stub generation.
|
||||
*/
|
||||
@Deprecated
|
||||
abstract public class RemoteStub extends RemoteObject {
|
||||
|
||||
/** indicate compatibility with JDK 1.1.x version of class */
|
||||
private static final long serialVersionUID = -1585587260594494182L;
|
||||
|
||||
/**
|
||||
* Constructs a <code>RemoteStub</code>.
|
||||
* Constructs a {@code RemoteStub}.
|
||||
*/
|
||||
protected RemoteStub() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>RemoteStub</code>, with the specified remote
|
||||
* Constructs a {@code RemoteStub} with the specified remote
|
||||
* reference.
|
||||
*
|
||||
* @param ref the remote reference
|
||||
@ -58,14 +64,17 @@ abstract public class RemoteStub extends RemoteObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the remote reference inside the remote stub.
|
||||
* Throws {@link UnsupportedOperationException}.
|
||||
*
|
||||
* @param stub the remote stub
|
||||
* @param ref the remote reference
|
||||
* @throws UnsupportedOperationException always
|
||||
* @since JDK1.1
|
||||
* @deprecated no replacement. The <code>setRef</code> method
|
||||
* is not needed since <code>RemoteStub</code>s can be created with
|
||||
* the <code>RemoteStub(RemoteRef)</code> constructor.
|
||||
* @deprecated No replacement. The {@code setRef} method
|
||||
* was intended for setting the remote reference of a remote
|
||||
* stub. This is unnecessary, since {@code RemoteStub}s can be created
|
||||
* and initialized with a remote reference through use of
|
||||
* the {@link #RemoteStub(RemoteRef)} constructor.
|
||||
*/
|
||||
@Deprecated
|
||||
protected static void setRef(RemoteStub stub, RemoteRef ref) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2013, 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
|
||||
@ -33,7 +33,9 @@ import java.rmi.*;
|
||||
*
|
||||
* @author Ann Wollrath
|
||||
* @since JDK1.1
|
||||
* @deprecated No replacement. This interface is unused and is obsolete.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ServerRef extends RemoteRef {
|
||||
|
||||
/** indicate compatibility with JDK 1.1.x version of class. */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2013, 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
|
||||
@ -30,7 +30,9 @@ package java.rmi.server;
|
||||
*
|
||||
* @author Ann Wollrath
|
||||
* @since JDK1.1
|
||||
**/
|
||||
* @deprecated This class is obsolete. Use {@link ExportException} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class SocketSecurityException extends ExportException {
|
||||
|
||||
/* indicate compatibility with JDK 1.1.x version of class */
|
||||
|
@ -30,52 +30,88 @@ import sun.rmi.server.UnicastServerRef2;
|
||||
|
||||
/**
|
||||
* Used for exporting a remote object with JRMP and obtaining a stub
|
||||
* that communicates to the remote object.
|
||||
* that communicates to the remote object. Stubs are either generated
|
||||
* at runtime using dynamic proxy objects, or they are generated statically
|
||||
* at build time, typically using the {@code rmic} tool.
|
||||
*
|
||||
* <p>For the constructors and static <code>exportObject</code> methods
|
||||
* below, the stub for a remote object being exported is obtained as
|
||||
* follows:
|
||||
* <p><strong>Deprecated: Static Stubs.</strong> <em>Support for statically
|
||||
* generated stubs is deprecated. This includes the API in this class that
|
||||
* requires the use of static stubs, as well as the runtime support for
|
||||
* loading static stubs. Generating stubs dynamically is preferred, using one
|
||||
* of the five non-deprecated ways of exporting objects as listed below. Do
|
||||
* not run {@code rmic} to generate static stub classes. It is unnecessary, and
|
||||
* it is also deprecated.</em>
|
||||
*
|
||||
* <p><ul>
|
||||
* <p>There are six ways to export remote objects:
|
||||
*
|
||||
* <ol>
|
||||
*
|
||||
* <li>Subclassing {@code UnicastRemoteObject} and calling the
|
||||
* {@link #UnicastRemoteObject()} constructor.
|
||||
*
|
||||
* <li>Subclassing {@code UnicastRemoteObject} and calling the
|
||||
* {@link #UnicastRemoteObject(int) UnicastRemoteObject(port)} constructor.
|
||||
*
|
||||
* <li>Subclassing {@code UnicastRemoteObject} and calling the
|
||||
* {@link #UnicastRemoteObject(int, RMIClientSocketFactory, RMIServerSocketFactory)
|
||||
* UnicastRemoteObject(port, csf, ssf)} constructor.
|
||||
*
|
||||
* <li>Calling the
|
||||
* {@link #exportObject(Remote) exportObject(Remote)} method.
|
||||
* <strong>Deprecated.</strong>
|
||||
*
|
||||
* <li>Calling the
|
||||
* {@link #exportObject(Remote, int) exportObject(Remote, port)} method.
|
||||
*
|
||||
* <li>Calling the
|
||||
* {@link #exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory)
|
||||
* exportObject(Remote, port, csf, ssf)} method.
|
||||
*
|
||||
* </ol>
|
||||
*
|
||||
* <p>The fourth technique, {@link #exportObject(Remote)},
|
||||
* always uses statically generated stubs and is deprecated.
|
||||
*
|
||||
* <p>The other five techniques all use the following approach: if the
|
||||
* {@code java.rmi.server.ignoreStubClasses} property is {@code true}
|
||||
* (case insensitive) or if a static stub cannot be found, stubs are generated
|
||||
* dynamically using {@link java.lang.reflect.Proxy Proxy} objects. Otherwise,
|
||||
* static stubs are used.
|
||||
*
|
||||
* <p>The default value of the
|
||||
* {@code java.rmi.server.ignoreStubClasses} property is {@code false}.
|
||||
*
|
||||
* <p>Statically generated stubs are typically pregenerated from the
|
||||
* remote object's class using the {@code rmic} tool. A static stub is
|
||||
* loaded and an instance of that stub class is constructed as described
|
||||
* below.
|
||||
*
|
||||
* <li>If the remote object is exported using the {@link
|
||||
* #exportObject(Remote) UnicastRemoteObject.exportObject(Remote)} method,
|
||||
* a stub class (typically pregenerated from the remote object's class
|
||||
* using the <code>rmic</code> tool) is loaded and an instance of that stub
|
||||
* class is constructed as follows.
|
||||
* <ul>
|
||||
*
|
||||
* <li>A "root class" is determined as follows: if the remote object's
|
||||
* <li>A "root class" is determined as follows: if the remote object's
|
||||
* class directly implements an interface that extends {@link Remote}, then
|
||||
* the remote object's class is the root class; otherwise, the root class is
|
||||
* the most derived superclass of the remote object's class that directly
|
||||
* implements an interface that extends <code>Remote</code>.
|
||||
* implements an interface that extends {@code Remote}.
|
||||
*
|
||||
* <li>The name of the stub class to load is determined by concatenating
|
||||
* the binary name of the root class with the suffix <code>"_Stub"</code>.
|
||||
* the binary name of the root class with the suffix {@code _Stub}.
|
||||
*
|
||||
* <li>The stub class is loaded by name using the class loader of the root
|
||||
* class. The stub class must extend {@link RemoteStub} and must have a
|
||||
* public constructor that has one parameter, of type {@link RemoteRef}.
|
||||
* class. The stub class must extend {@link RemoteStub} and must have a
|
||||
* public constructor that has one parameter of type {@link RemoteRef}.
|
||||
*
|
||||
* <li>Finally, an instance of the stub class is constructed with a
|
||||
* {@link RemoteRef}.
|
||||
* </ul>
|
||||
*
|
||||
* <li>If the appropriate stub class could not be found, or the stub class
|
||||
* could not be loaded, or a problem occurs creating the stub instance, a
|
||||
* <li>If the appropriate stub class could not be found, or if the stub class
|
||||
* could not be loaded, or if a problem occurs creating the stub instance, a
|
||||
* {@link StubNotFoundException} is thrown.
|
||||
*
|
||||
* <p>
|
||||
* <li>For all other means of exporting:
|
||||
* <p><ul>
|
||||
* </ul>
|
||||
*
|
||||
* <li>If the remote object's stub class (as defined above) could not be
|
||||
* loaded or the system property
|
||||
* <code>java.rmi.server.ignoreStubClasses</code> is set to
|
||||
* <code>"true"</code> (case insensitive), a {@link
|
||||
* java.lang.reflect.Proxy} instance is constructed with the following
|
||||
* properties:
|
||||
* <p>Stubs are dynamically generated by constructing an instance of
|
||||
* a {@link java.lang.reflect.Proxy Proxy} with the following characteristics:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
@ -91,29 +127,13 @@ import sun.rmi.server.UnicastServerRef2;
|
||||
*
|
||||
* <li>If the proxy could not be created, a {@link StubNotFoundException}
|
||||
* will be thrown.
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* <li>Otherwise, an instance of the remote object's stub class (as
|
||||
* described above) is used as the stub.
|
||||
*
|
||||
* </ul>
|
||||
* </ul>
|
||||
*
|
||||
* <p>If an object is exported with the
|
||||
* {@link #exportObject(Remote) exportObject(Remote)}
|
||||
* or
|
||||
* {@link #exportObject(Remote, int) exportObject(Remote, port)}
|
||||
* methods, or if a subclass constructor invokes one of the
|
||||
* {@link #UnicastRemoteObject()}
|
||||
* or
|
||||
* {@link #UnicastRemoteObject(int) UnicastRemoteObject(port)}
|
||||
* constructors, the object is exported with a server socket created using the
|
||||
* {@link RMISocketFactory}
|
||||
* class.
|
||||
*
|
||||
* @implNote
|
||||
* <p>By default, server sockets created by the {@link RMISocketFactory} class
|
||||
* Depending upon which constructor or static method is used for exporting an
|
||||
* object, {@link RMISocketFactory} may be used for creating sockets.
|
||||
* By default, server sockets created by {@link RMISocketFactory}
|
||||
* listen on all network interfaces. See the
|
||||
* {@link RMISocketFactory} class and the section
|
||||
* <a href="{@docRoot}/../platform/rmi/spec/rmi-server29.html">RMI Socket Factories</a>
|
||||
@ -148,6 +168,10 @@ public class UnicastRemoteObject extends RemoteServer {
|
||||
/**
|
||||
* Creates and exports a new UnicastRemoteObject object using an
|
||||
* anonymous port.
|
||||
*
|
||||
* <p>The object is exported with a server socket
|
||||
* created using the {@link RMISocketFactory} class.
|
||||
*
|
||||
* @throws RemoteException if failed to export object
|
||||
* @since JDK1.1
|
||||
*/
|
||||
@ -159,6 +183,10 @@ public class UnicastRemoteObject extends RemoteServer {
|
||||
/**
|
||||
* Creates and exports a new UnicastRemoteObject object using the
|
||||
* particular supplied port.
|
||||
*
|
||||
* <p>The object is exported with a server socket
|
||||
* created using the {@link RMISocketFactory} class.
|
||||
*
|
||||
* @param port the port number on which the remote object receives calls
|
||||
* (if <code>port</code> is zero, an anonymous port is chosen)
|
||||
* @throws RemoteException if failed to export object
|
||||
@ -173,6 +201,11 @@ public class UnicastRemoteObject extends RemoteServer {
|
||||
/**
|
||||
* Creates and exports a new UnicastRemoteObject object using the
|
||||
* particular supplied port and socket factories.
|
||||
*
|
||||
* <p>Either socket factory may be {@code null}, in which case
|
||||
* the corresponding client or server socket creation method of
|
||||
* {@link RMISocketFactory} is used instead.
|
||||
*
|
||||
* @param port the port number on which the remote object receives calls
|
||||
* (if <code>port</code> is zero, an anonymous port is chosen)
|
||||
* @param csf the client-side socket factory for making calls to the
|
||||
@ -238,12 +271,23 @@ public class UnicastRemoteObject extends RemoteServer {
|
||||
|
||||
/**
|
||||
* Exports the remote object to make it available to receive incoming
|
||||
* calls using an anonymous port.
|
||||
* calls using an anonymous port. This method will always return a
|
||||
* statically generated stub.
|
||||
*
|
||||
* <p>The object is exported with a server socket
|
||||
* created using the {@link RMISocketFactory} class.
|
||||
*
|
||||
* @param obj the remote object to be exported
|
||||
* @return remote object stub
|
||||
* @exception RemoteException if export fails
|
||||
* @since JDK1.1
|
||||
* @deprecated This method is deprecated because it supports only static stubs.
|
||||
* Use {@link #exportObject(Remote, int) exportObject(Remote, port)} or
|
||||
* {@link #exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory)
|
||||
* exportObject(Remote, port, csf, ssf)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static RemoteStub exportObject(Remote obj)
|
||||
throws RemoteException
|
||||
{
|
||||
@ -260,6 +304,10 @@ public class UnicastRemoteObject extends RemoteServer {
|
||||
/**
|
||||
* Exports the remote object to make it available to receive incoming
|
||||
* calls, using the particular supplied port.
|
||||
*
|
||||
* <p>The object is exported with a server socket
|
||||
* created using the {@link RMISocketFactory} class.
|
||||
*
|
||||
* @param obj the remote object to be exported
|
||||
* @param port the port to export the object on
|
||||
* @return remote object stub
|
||||
@ -275,6 +323,11 @@ public class UnicastRemoteObject extends RemoteServer {
|
||||
/**
|
||||
* Exports the remote object to make it available to receive incoming
|
||||
* calls, using a transport specified by the given socket factory.
|
||||
*
|
||||
* <p>Either socket factory may be {@code null}, in which case
|
||||
* the corresponding client or server socket creation method of
|
||||
* {@link RMISocketFactory} is used instead.
|
||||
*
|
||||
* @param obj the remote object to be exported
|
||||
* @param port the port to export the object on
|
||||
* @param csf the client-side socket factory for making calls to the
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,27 @@ side of RMI. A group of classes are used by the stubs and skeletons
|
||||
generated by the rmic stub compiler. Another group of classes
|
||||
implements the RMI Transport protocol and HTTP tunneling.
|
||||
|
||||
<p><strong>Deprecated: HTTP Tunneling.</strong> <em>The HTTP tunneling
|
||||
mechanism has been deprecated. See {@link java.rmi.server.RMISocketFactory} for
|
||||
further information.</em>
|
||||
|
||||
<p><strong>Deprecated: Skeletons and Static Stubs.</strong>
|
||||
|
||||
<em>Skeletons and statically generated stubs are deprecated. This
|
||||
includes the APIs in this package that require the use of skeletons
|
||||
or static stubs, the runtime support for them, and the use of the
|
||||
{@code rmic} stub compiler to generate them. Support for skeletons
|
||||
and static stubs may be removed in a future release of the
|
||||
platform. Skeletons are unnecessary, as server-side method dispatching
|
||||
is handled directly by the RMI runtime. Statically generated stubs are
|
||||
unnecessary, as stubs are generated dynamically using {@link
|
||||
java.lang.reflect.Proxy Proxy} objects. See {@link
|
||||
java.rmi.server.UnicastRemoteObject UnicastRemoteObject} for
|
||||
information about dynamic stub generation. Generation of skeletons and
|
||||
static stubs was typically performed as part of an application's build
|
||||
process by calling the {@code rmic} tool. This is unnecessary, and
|
||||
calls to {@code rmic} can simply be omitted.</em>
|
||||
|
||||
<!--
|
||||
<h2>Package Specification</h2>
|
||||
|
||||
|
@ -350,6 +350,10 @@ public final class AccessControlContext {
|
||||
return combiner;
|
||||
}
|
||||
|
||||
boolean isAuthorized() {
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the access request indicated by the
|
||||
* specified permission should be allowed or denied, based on
|
||||
|
@ -39,9 +39,9 @@ import sun.reflect.Reflection;
|
||||
* <ul>
|
||||
* <li> to decide whether an access to a critical system
|
||||
* resource is to be allowed or denied, based on the security policy
|
||||
* currently in effect,<p>
|
||||
* currently in effect,
|
||||
* <li>to mark code as being "privileged", thus affecting subsequent
|
||||
* access determinations, and<p>
|
||||
* access determinations, and
|
||||
* <li>to obtain a "snapshot" of the current calling context so
|
||||
* access-control decisions from a different context can be made with
|
||||
* respect to the saved context. </ul>
|
||||
@ -344,9 +344,10 @@ public final class AccessController {
|
||||
* If the action's {@code run} method throws an (unchecked) exception,
|
||||
* it will propagate through this method.
|
||||
* <p>
|
||||
* If a security manager is installed and the {@code AccessControlContext}
|
||||
* was not created by system code and the caller's {@code ProtectionDomain}
|
||||
* has not been granted the {@literal "createAccessControlContext"}
|
||||
* If a security manager is installed and the specified
|
||||
* {@code AccessControlContext} was not created by system code and the
|
||||
* caller's {@code ProtectionDomain} has not been granted the
|
||||
* {@literal "createAccessControlContext"}
|
||||
* {@link java.security.SecurityPermission}, then the action is performed
|
||||
* with no permissions.
|
||||
*
|
||||
@ -384,6 +385,13 @@ public final class AccessController {
|
||||
* <p>
|
||||
* If the action's {@code run} method throws an (unchecked) exception,
|
||||
* it will propagate through this method.
|
||||
* <p>
|
||||
* If a security manager is installed and the specified
|
||||
* {@code AccessControlContext} was not created by system code and the
|
||||
* caller's {@code ProtectionDomain} has not been granted the
|
||||
* {@literal "createAccessControlContext"}
|
||||
* {@link java.security.SecurityPermission}, then the action is performed
|
||||
* with no permissions.
|
||||
*
|
||||
* @param <T> the type of the value returned by the PrivilegedAction's
|
||||
* {@code run} method.
|
||||
@ -438,6 +446,13 @@ public final class AccessController {
|
||||
*
|
||||
* <p> This method preserves the current AccessControlContext's
|
||||
* DomainCombiner (which may be null) while the action is performed.
|
||||
* <p>
|
||||
* If a security manager is installed and the specified
|
||||
* {@code AccessControlContext} was not created by system code and the
|
||||
* caller's {@code ProtectionDomain} has not been granted the
|
||||
* {@literal "createAccessControlContext"}
|
||||
* {@link java.security.SecurityPermission}, then the action is performed
|
||||
* with no permissions.
|
||||
*
|
||||
* @param <T> the type of the value returned by the PrivilegedAction's
|
||||
* {@code run} method.
|
||||
@ -571,8 +586,18 @@ public final class AccessController {
|
||||
AccessControlContext parent, AccessControlContext context,
|
||||
Permission[] perms)
|
||||
{
|
||||
return new AccessControlContext(getCallerPD(caller), combiner, parent,
|
||||
context, perms);
|
||||
ProtectionDomain callerPD = getCallerPD(caller);
|
||||
// check if caller is authorized to create context
|
||||
if (context != null && !context.isAuthorized() &&
|
||||
System.getSecurityManager() != null &&
|
||||
!callerPD.impliesCreateAccessControlContext())
|
||||
{
|
||||
ProtectionDomain nullPD = new ProtectionDomain(null, null);
|
||||
return new AccessControlContext(new ProtectionDomain[] { nullPD });
|
||||
} else {
|
||||
return new AccessControlContext(callerPD, combiner, parent,
|
||||
context, perms);
|
||||
}
|
||||
}
|
||||
|
||||
private static ProtectionDomain getCallerPD(final Class <?> caller) {
|
||||
@ -597,9 +622,10 @@ public final class AccessController {
|
||||
* If the action's {@code run} method throws an <i>unchecked</i>
|
||||
* exception, it will propagate through this method.
|
||||
* <p>
|
||||
* If a security manager is installed and the {@code AccessControlContext}
|
||||
* was not created by system code and the caller's {@code ProtectionDomain}
|
||||
* has not been granted the {@literal "createAccessControlContext"}
|
||||
* If a security manager is installed and the specified
|
||||
* {@code AccessControlContext} was not created by system code and the
|
||||
* caller's {@code ProtectionDomain} has not been granted the
|
||||
* {@literal "createAccessControlContext"}
|
||||
* {@link java.security.SecurityPermission}, then the action is performed
|
||||
* with no permissions.
|
||||
*
|
||||
@ -641,6 +667,13 @@ public final class AccessController {
|
||||
* <p>
|
||||
* If the action's {@code run} method throws an (unchecked) exception,
|
||||
* it will propagate through this method.
|
||||
* <p>
|
||||
* If a security manager is installed and the specified
|
||||
* {@code AccessControlContext} was not created by system code and the
|
||||
* caller's {@code ProtectionDomain} has not been granted the
|
||||
* {@literal "createAccessControlContext"}
|
||||
* {@link java.security.SecurityPermission}, then the action is performed
|
||||
* with no permissions.
|
||||
*
|
||||
* @param <T> the type of the value returned by the
|
||||
* PrivilegedExceptionAction's {@code run} method.
|
||||
@ -697,6 +730,13 @@ public final class AccessController {
|
||||
*
|
||||
* <p> This method preserves the current AccessControlContext's
|
||||
* DomainCombiner (which may be null) while the action is performed.
|
||||
* <p>
|
||||
* If a security manager is installed and the specified
|
||||
* {@code AccessControlContext} was not created by system code and the
|
||||
* caller's {@code ProtectionDomain} has not been granted the
|
||||
* {@literal "createAccessControlContext"}
|
||||
* {@link java.security.SecurityPermission}, then the action is performed
|
||||
* with no permissions.
|
||||
*
|
||||
* @param <T> the type of the value returned by the
|
||||
* PrivilegedExceptionAction's {@code run} method.
|
||||
|
@ -48,7 +48,7 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
* of the prime modulus (in bits).
|
||||
* When using this approach, algorithm-specific parameter generation
|
||||
* values - if any - default to some standard values, unless they can be
|
||||
* derived from the specified size.<P>
|
||||
* derived from the specified size.
|
||||
*
|
||||
* <li>The other approach initializes a parameter generator object
|
||||
* using algorithm-specific semantics, which are represented by a set of
|
||||
|
@ -57,7 +57,6 @@ import java.io.IOException;
|
||||
* Subclasses may implement actions on top of BasicPermission,
|
||||
* if desired.
|
||||
* <p>
|
||||
* <P>
|
||||
* @see java.security.Permission
|
||||
* @see java.security.Permissions
|
||||
* @see java.security.PermissionCollection
|
||||
@ -153,9 +152,9 @@ public abstract class BasicPermission extends Permission
|
||||
* Checks if the specified permission is "implied" by
|
||||
* this object.
|
||||
* <P>
|
||||
* More specifically, this method returns true if:<p>
|
||||
* More specifically, this method returns true if:
|
||||
* <ul>
|
||||
* <li> <i>p</i>'s class is the same as this object's class, and<p>
|
||||
* <li> <i>p</i>'s class is the same as this object's class, and
|
||||
* <li> <i>p</i>'s name equals or (in the case of wildcards)
|
||||
* is implied by this object's
|
||||
* name. For example, "a.b.*" implies "a.b.c".
|
||||
|
@ -234,7 +234,7 @@ public class CodeSource implements java.io.Serializable {
|
||||
* Returns true if this CodeSource object "implies" the specified CodeSource.
|
||||
* <p>
|
||||
* More specifically, this method makes the following checks.
|
||||
* If any fail, it returns false. If they all succeed, it returns true.<p>
|
||||
* If any fail, it returns false. If they all succeed, it returns true.
|
||||
* <ul>
|
||||
* <li> <i>codesource</i> must not be null.
|
||||
* <li> If this object's certificates are not null, then all
|
||||
@ -242,7 +242,7 @@ public class CodeSource implements java.io.Serializable {
|
||||
* certificates.
|
||||
* <li> If this object's location (getLocation()) is not null, then the
|
||||
* following checks are made against this object's location and
|
||||
* <i>codesource</i>'s:<p>
|
||||
* <i>codesource</i>'s:
|
||||
* <ul>
|
||||
* <li> <i>codesource</i>'s location must not be null.
|
||||
*
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user