提交 a09d112e 编写于 作者: L lana

Merge

......@@ -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 &lt;&lt; 8) | (b &amp; 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 &amp; 0xff) &lt;&lt; 8) | (b &amp; 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 &lt;&lt; 8) | (b &amp; 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 &amp; 0xff) &lt;&lt; 24) | ((b &amp; 0xff) &lt;&lt; 16) |
* &#32;((c &amp; 0xff) &lt;&lt; 8) | (d &amp; 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 &amp; 0xff) &lt;&lt; 56) |
* ((long)(b &amp; 0xff) &lt;&lt; 48) |
* ((long)(c &amp; 0xff) &lt;&lt; 40) |
* ((long)(d &amp; 0xff) &lt;&lt; 32) |
* ((long)(e &amp; 0xff) &lt;&lt; 24) |
* ((long)(f &amp; 0xff) &lt;&lt; 16) |
* ((long)(g &amp; 0xff) &lt;&lt; 8) |
* ((long)(h &amp; 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&amp; 0x1F) &lt;&lt; 6) | (b &amp; 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 &amp; 0x0F) &lt;&lt; 12) | ((b &amp; 0x3F) &lt;&lt; 6) | (c &amp; 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 &amp; (v &gt;&gt; 8))
* (byte)(0xff &amp; 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 &amp; (v &gt;&gt; 8))
* (byte)(0xff &amp; 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 &amp; (v &gt;&gt; 24))
* (byte)(0xff &amp; (v &gt;&gt; 16))
* (byte)(0xff &amp; (v &gt;&gt; &#32; &#32;8))
* (byte)(0xff &amp; 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 &amp; (v &gt;&gt; 56))
* (byte)(0xff &amp; (v &gt;&gt; 48))
* (byte)(0xff &amp; (v &gt;&gt; 40))
* (byte)(0xff &amp; (v &gt;&gt; 32))
* (byte)(0xff &amp; (v &gt;&gt; 24))
* (byte)(0xff &amp; (v &gt;&gt; 16))
* (byte)(0xff &amp; (v &gt;&gt; 8))
* (byte)(0xff &amp; 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>&#92;u0001</code> through
* <code>&#92;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>&#92;u0000</code>
* or is in the range <code>&#92;u0080</code>
* through <code>&#92;u07ff</code>, then it is
* represented by two bytes, to be written
* in the order shown:<p> <pre><code>
* (byte)(0xc0 | (0x1f &amp; (c &gt;&gt; 6)))
* (byte)(0x80 | (0x3f &amp; 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>&#92;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 &amp; (c &gt;&gt; 12)))
* (byte)(0x80 | (0x3f &amp; (c &gt;&gt; 6)))
* (byte)(0x80 | (0x3f &amp; 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 &lt;&lt; 56) + ((long)b2 &lt;&lt; 48)
* + ((long)b3 &lt;&lt; 40) + ((long)b4 &lt;&lt; 32)
* + ((long)b5 &lt;&lt; 24) + ((long)b6 &lt;&lt; 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,&nbsp;end)</pre></blockquote>
* <pre>{@code
* sb.subSequence(begin,&nbsp;end)}</pre>
*
* behaves in exactly the same way as the invocation
*
* <blockquote><pre>
* sb.substring(begin,&nbsp;end)</pre></blockquote>
* <pre>{@code
* sb.substring(begin,&nbsp;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
* '&#92;u00DF' '&#92;u00E0' '&#92;u00E1' '&#92;u00E2' '&#92;u00E3' '&#92;u00E4' '&#92;u00E5' '&#92;u00E6'
* '&#92;u00E7' '&#92;u00E8' '&#92;u00E9' '&#92;u00EA' '&#92;u00EB' '&#92;u00EC' '&#92;u00ED' '&#92;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
* '&#92;u00DF' '&#92;u00E0' '&#92;u00E1' '&#92;u00E2' '&#92;u00E3' '&#92;u00E4' '&#92;u00E5' '&#92;u00E6'
* '&#92;u00E7' '&#92;u00E8' '&#92;u00E9' '&#92;u00EA' '&#92;u00EB' '&#92;u00EC' '&#92;u00ED' '&#92;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
* '&#92;u00C0' '&#92;u00C1' '&#92;u00C2' '&#92;u00C3' '&#92;u00C4' '&#92;u00C5' '&#92;u00C6' '&#92;u00C7'
* '&#92;u00C8' '&#92;u00C9' '&#92;u00CA' '&#92;u00CB' '&#92;u00CC' '&#92;u00CD' '&#92;u00CE' '&#92;u00CF'
* '&#92;u00D0' '&#92;u00D1' '&#92;u00D2' '&#92;u00D3' '&#92;u00D4' '&#92;u00D5' '&#92;u00D6' '&#92;u00D8'
* '&#92;u00D9' '&#92;u00DA' '&#92;u00DB' '&#92;u00DC' '&#92;u00DD' '&#92;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
* '&#92;u00C0' '&#92;u00C1' '&#92;u00C2' '&#92;u00C3' '&#92;u00C4' '&#92;u00C5' '&#92;u00C6' '&#92;u00C7'
* '&#92;u00C8' '&#92;u00C9' '&#92;u00CA' '&#92;u00CB' '&#92;u00CC' '&#92;u00CD' '&#92;u00CE' '&#92;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&trade; 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, &nbsp;.&nbsp;.&nbsp;.&nbsp;);
......@@ -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
......
......@@ -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");
}
sign = -1;
cursor = 1;
} else if (index2 >= 0) {
if (index2 != 0) {
throw new NumberFormatException("Illegal embedded sign character");
}
if (index1 == 0)
sign = -1;
} else
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:}&nbsp;), 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 &quot;{@code a}&quot; through
* &quot;{@code z}&quot;, &quot;{@code A}&quot; 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 &quot;{@code a}&quot; through
* &quot;{@code z}&quot;, &quot;{@code A}&quot; 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>
......
/*
* 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
......
/*
* 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) {
......
/*
* 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. */
......
/*
* 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
......
<!--
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.
*
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册