Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a7cb2d41
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a7cb2d41
编写于
1月 30, 2009
作者:
T
tbell
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
400aca47
0e496345
变更
27
显示空白变更内容
内联
并排
Showing
27 changed file
with
1477 addition
and
619 deletion
+1477
-619
src/share/classes/java/io/InputStream.java
src/share/classes/java/io/InputStream.java
+1
-1
src/share/classes/java/lang/Enum.java
src/share/classes/java/lang/Enum.java
+9
-4
src/share/classes/java/lang/Object.java
src/share/classes/java/lang/Object.java
+96
-96
src/share/classes/java/lang/RuntimePermission.java
src/share/classes/java/lang/RuntimePermission.java
+7
-0
src/share/classes/java/lang/annotation/Annotation.java
src/share/classes/java/lang/annotation/Annotation.java
+5
-1
src/share/classes/java/lang/instrument/package.html
src/share/classes/java/lang/instrument/package.html
+25
-0
src/share/classes/java/net/HttpCookie.java
src/share/classes/java/net/HttpCookie.java
+1
-2
src/share/classes/java/net/URLClassLoader.java
src/share/classes/java/net/URLClassLoader.java
+63
-6
src/share/classes/java/util/Formatter.java
src/share/classes/java/util/Formatter.java
+446
-446
src/share/classes/java/util/logging/Logger.java
src/share/classes/java/util/logging/Logger.java
+26
-35
src/share/classes/sun/misc/URLClassPath.java
src/share/classes/sun/misc/URLClassPath.java
+43
-18
src/solaris/native/java/lang/UNIXProcess_md.c
src/solaris/native/java/lang/UNIXProcess_md.c
+7
-1
test/java/lang/Enum/ValueOf.java
test/java/lang/Enum/ValueOf.java
+224
-0
test/java/lang/reflect/Generics/Probe.java
test/java/lang/reflect/Generics/Probe.java
+17
-4
test/java/net/CookieHandler/TestHttpCookie.java
test/java/net/CookieHandler/TestHttpCookie.java
+4
-5
test/java/net/URLClassLoader/closetest/CloseTest.java
test/java/net/URLClassLoader/closetest/CloseTest.java
+246
-0
test/java/net/URLClassLoader/closetest/README
test/java/net/URLClassLoader/closetest/README
+24
-0
test/java/net/URLClassLoader/closetest/build.sh
test/java/net/URLClassLoader/closetest/build.sh
+73
-0
test/java/net/URLClassLoader/closetest/serverRoot/Test.java
test/java/net/URLClassLoader/closetest/serverRoot/Test.java
+28
-0
test/java/net/URLClassLoader/closetest/test1/com/foo/Resource1
...java/net/URLClassLoader/closetest/test1/com/foo/Resource1
+1
-0
test/java/net/URLClassLoader/closetest/test1/com/foo/Resource2
...java/net/URLClassLoader/closetest/test1/com/foo/Resource2
+1
-0
test/java/net/URLClassLoader/closetest/test1/com/foo/TestClass.java
...net/URLClassLoader/closetest/test1/com/foo/TestClass.java
+38
-0
test/java/net/URLClassLoader/closetest/test1/com/foo/TestClass1.java
...et/URLClassLoader/closetest/test1/com/foo/TestClass1.java
+26
-0
test/java/net/URLClassLoader/closetest/test2/com/foo/Resource1
...java/net/URLClassLoader/closetest/test2/com/foo/Resource1
+1
-0
test/java/net/URLClassLoader/closetest/test2/com/foo/Resource2
...java/net/URLClassLoader/closetest/test2/com/foo/Resource2
+1
-0
test/java/net/URLClassLoader/closetest/test2/com/foo/TestClass.java
...net/URLClassLoader/closetest/test2/com/foo/TestClass.java
+38
-0
test/java/net/URLClassLoader/closetest/test2/com/foo/TestClass1.java
...et/URLClassLoader/closetest/test2/com/foo/TestClass1.java
+26
-0
未找到文件。
src/share/classes/java/io/InputStream.java
浏览文件 @
a7cb2d41
...
...
@@ -90,7 +90,7 @@ public abstract class InputStream implements Closeable {
*
* @param b the buffer into which the data is read.
* @return the total number of bytes read into the buffer, or
* <code>-1</code> i
s
there is no more data because the end of
* <code>-1</code> i
f
there is no more data because the end of
* the stream has been reached.
* @exception IOException If the first byte cannot be read for any reason
* other than the end of the file, if the input stream has been closed, or
...
...
src/share/classes/java/lang/Enum.java
浏览文件 @
a7cb2d41
/*
* Copyright 2003-200
7
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-200
9
Sun Microsystems, Inc. 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
...
...
@@ -34,6 +34,11 @@ import java.io.ObjectStreamException;
/**
* This is the common base class of all Java language enumeration types.
*
* More information about enums, including implicit methods synthesised
* by the compiler, can be found in <i>The Java™ Language
* Specification, Third Edition</i>, <a
* href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.9">§8.9</a>.
*
* @author Josh Bloch
* @author Neal Gafter
* @see Class#getEnumConstants()
...
...
@@ -212,7 +217,7 @@ public abstract class Enum<E extends Enum<E>>
if
(
name
==
null
)
throw
new
NullPointerException
(
"Name is null"
);
throw
new
IllegalArgumentException
(
"No enum const
"
+
enumType
+
"."
+
name
);
"No enum const
ant "
+
enumType
.
getCanonicalName
()
+
"."
+
name
);
}
/**
...
...
src/share/classes/java/lang/Object.java
浏览文件 @
a7cb2d41
...
...
@@ -26,8 +26,8 @@
package
java.lang
;
/**
* Class
<code>Object</code>
is the root of the class hierarchy.
* Every class has
<code>Object</code>
as a superclass. All objects,
* Class
{@code Object}
is the root of the class hierarchy.
* Every class has
{@code Object}
as a superclass. All objects,
* including arrays, implement the methods of this class.
*
* @author unascribed
...
...
@@ -66,30 +66,30 @@ public class Object {
/**
* Returns a hash code value for the object. This method is
* supported for the benefit of hashtables such as those provided by
*
<code>java.util.Hashtable</code>
.
* supported for the benefit of hash
tables such as those provided by
*
{@link java.util.HashMap}
.
* <p>
* The general contract of
<code>hashCode</code>
is:
* The general contract of
{@code hashCode}
is:
* <ul>
* <li>Whenever it is invoked on the same object more than once during
* an execution of a Java application, the
<tt>hashCode</tt>
method
* an execution of a Java application, the
{@code hashCode}
method
* must consistently return the same integer, provided no information
* used in
<tt>equals</tt>
comparisons on the object is modified.
* used in
{@code equals}
comparisons on the object is modified.
* This integer need not remain consistent from one execution of an
* application to another execution of the same application.
* <li>If two objects are equal according to the
<tt>equals(Object)</tt>
* method, then calling the
<code>hashCode</code>
method on each of
* <li>If two objects are equal according to the
{@code equals(Object)}
* method, then calling the
{@code hashCode}
method on each of
* the two objects must produce the same integer result.
* <li>It is <em>not</em> required that if two objects are unequal
* according to the {@link java.lang.Object#equals(java.lang.Object)}
* method, then calling the
<tt>hashCode</tt>
method on each of the
* method, then calling the
{@code hashCode}
method on each of the
* two objects must produce distinct integer results. However, the
* programmer should be aware that producing distinct integer results
* for unequal objects may improve the performance of hashtables.
* for unequal objects may improve the performance of hash
tables.
* </ul>
* <p>
* As much as is reasonably practical, the hashCode method defined by
* class
<tt>Object</tt>
does return distinct integers for distinct
* class
{@code Object}
does return distinct integers for distinct
* objects. (This is typically implemented by converting the internal
* address of the object into an integer, but this implementation
* technique is not required by the
...
...
@@ -97,55 +97,55 @@ public class Object {
*
* @return a hash code value for this object.
* @see java.lang.Object#equals(java.lang.Object)
* @see java.
util.Hashtabl
e
* @see java.
lang.System#identityHashCod
e
*/
public
native
int
hashCode
();
/**
* Indicates whether some other object is "equal to" this one.
* <p>
* The
<code>equals</code>
method implements an equivalence relation
* The
{@code equals}
method implements an equivalence relation
* on non-null object references:
* <ul>
* <li>It is <i>reflexive</i>: for any non-null reference value
*
<code>x</code>, <code>x.equals(x)</code>
should return
*
<code>true</code>
.
*
{@code x}, {@code x.equals(x)}
should return
*
{@code true}
.
* <li>It is <i>symmetric</i>: for any non-null reference values
*
<code>x</code> and <code>y</code>, <code>x.equals(y)</code>
* should return
<code>true</code>
if and only if
*
<code>y.equals(x)</code> returns <code>true</code>
.
*
{@code x} and {@code y}, {@code x.equals(y)}
* should return
{@code true}
if and only if
*
{@code y.equals(x)} returns {@code true}
.
* <li>It is <i>transitive</i>: for any non-null reference values
*
<code>x</code>, <code>y</code>, and <code>z</code>
, if
*
<code>x.equals(y)</code> returns <code>true</code>
and
*
<code>y.equals(z)</code> returns <code>true</code>
, then
*
<code>x.equals(z)</code> should return <code>true</code>
.
*
{@code x}, {@code y}, and {@code z}
, if
*
{@code x.equals(y)} returns {@code true}
and
*
{@code y.equals(z)} returns {@code true}
, then
*
{@code x.equals(z)} should return {@code true}
.
* <li>It is <i>consistent</i>: for any non-null reference values
*
<code>x</code> and <code>y</code>
, multiple invocations of
*
<tt>x.equals(y)</tt> consistently return <code>true</code>
* or consistently return
<code>false</code>
, provided no
* information used in
<code>equals</code>
comparisons on the
*
{@code x} and {@code y}
, multiple invocations of
*
{@code x.equals(y)} consistently return {@code true}
* or consistently return
{@code false}
, provided no
* information used in
{@code equals}
comparisons on the
* objects is modified.
* <li>For any non-null reference value
<code>x</code>
,
*
<code>x.equals(null)</code> should return <code>false</code>
.
* <li>For any non-null reference value
{@code x}
,
*
{@code x.equals(null)} should return {@code false}
.
* </ul>
* <p>
* The
<tt>equals</tt> method for class <code>Object</code>
implements
* The
{@code equals} method for class {@code Object}
implements
* the most discriminating possible equivalence relation on objects;
* that is, for any non-null reference values
<code>x</code>
and
*
<code>y</code>, this method returns <code>true</code>
if and only
* if
<code>x</code> and <code>y</code>
refer to the same object
* (
<code>x == y</code> has the value <code>true</code>
).
* that is, for any non-null reference values
{@code x}
and
*
{@code y}, this method returns {@code true}
if and only
* if
{@code x} and {@code y}
refer to the same object
* (
{@code x == y} has the value {@code true}
).
* <p>
* Note that it is generally necessary to override the
<tt>hashCode</tt>
* Note that it is generally necessary to override the
{@code hashCode}
* method whenever this method is overridden, so as to maintain the
* general contract for the
<tt>hashCode</tt>
method, which states
* general contract for the
{@code hashCode}
method, which states
* that equal objects must have equal hash codes.
*
* @param obj the reference object with which to compare.
* @return
<code>true</code>
if this object is the same as the obj
* argument;
<code>false</code>
otherwise.
* @return
{@code true}
if this object is the same as the obj
* argument;
{@code false}
otherwise.
* @see #hashCode()
* @see java.util.Hash
table
* @see java.util.Hash
Map
*/
public
boolean
equals
(
Object
obj
)
{
return
(
this
==
obj
);
...
...
@@ -154,7 +154,7 @@ public class Object {
/**
* Creates and returns a copy of this object. The precise meaning
* of "copy" may depend on the class of the object. The general
* intent is that, for any object
<tt>x</tt>
, the expression:
* intent is that, for any object
{@code x}
, the expression:
* <blockquote>
* <pre>
* x.clone() != x</pre></blockquote>
...
...
@@ -162,49 +162,49 @@ public class Object {
* <blockquote>
* <pre>
* x.clone().getClass() == x.getClass()</pre></blockquote>
* will be
<tt>true</tt>
, but these are not absolute requirements.
* will be
{@code true}
, but these are not absolute requirements.
* While it is typically the case that:
* <blockquote>
* <pre>
* x.clone().equals(x)</pre></blockquote>
* will be
<tt>true</tt>
, this is not an absolute requirement.
* will be
{@code true}
, this is not an absolute requirement.
* <p>
* By convention, the returned object should be obtained by calling
*
<tt>super.clone</tt>
. If a class and all of its superclasses (except
*
<tt>Object</tt>
) obey this convention, it will be the case that
*
<tt>x.clone().getClass() == x.getClass()</tt>
.
*
{@code super.clone}
. If a class and all of its superclasses (except
*
{@code Object}
) obey this convention, it will be the case that
*
{@code x.clone().getClass() == x.getClass()}
.
* <p>
* By convention, the object returned by this method should be independent
* of this object (which is being cloned). To achieve this independence,
* it may be necessary to modify one or more fields of the object returned
* by
<tt>super.clone</tt>
before returning it. Typically, this means
* by
{@code super.clone}
before returning it. Typically, this means
* copying any mutable objects that comprise the internal "deep structure"
* of the object being cloned and replacing the references to these
* objects with references to the copies. If a class contains only
* primitive fields or references to immutable objects, then it is usually
* the case that no fields in the object returned by
<tt>super.clone</tt>
* the case that no fields in the object returned by
{@code super.clone}
* need to be modified.
* <p>
* The method
<tt>clone</tt> for class <tt>Object</tt>
performs a
* The method
{@code clone} for class {@code Object}
performs a
* specific cloning operation. First, if the class of this object does
* not implement the interface
<tt>Cloneable</tt>
, then a
*
<tt>CloneNotSupportedException</tt>
is thrown. Note that all arrays
* are considered to implement the interface
<tt>Cloneable</tt>
.
* not implement the interface
{@code Cloneable}
, then a
*
{@code CloneNotSupportedException}
is thrown. Note that all arrays
* are considered to implement the interface
{@code Cloneable}
.
* Otherwise, this method creates a new instance of the class of this
* object and initializes all its fields with exactly the contents of
* the corresponding fields of this object, as if by assignment; the
* contents of the fields are not themselves cloned. Thus, this method
* performs a "shallow copy" of this object, not a "deep copy" operation.
* <p>
* The class
<tt>Object</tt>
does not itself implement the interface
*
<tt>Cloneable</tt>, so calling the <tt>clone</tt>
method on an object
* whose class is
<tt>Object</tt>
will result in throwing an
* The class
{@code Object}
does not itself implement the interface
*
{@code Cloneable}, so calling the {@code clone}
method on an object
* whose class is
{@code Object}
will result in throwing an
* exception at run time.
*
* @return a clone of this instance.
* @exception CloneNotSupportedException if the object's class does not
* support the
<code>Cloneable</code>
interface. Subclasses
* that override the
<code>clone</code>
method can also
* support the
{@code Cloneable}
interface. Subclasses
* that override the
{@code clone}
method can also
* throw this exception to indicate that an instance cannot
* be cloned.
* @see java.lang.Cloneable
...
...
@@ -213,15 +213,15 @@ public class Object {
/**
* Returns a string representation of the object. In general, the
*
<code>toString</code>
method returns a string that
*
{@code toString}
method returns a string that
* "textually represents" this object. The result should
* be a concise but informative representation that is easy for a
* person to read.
* It is recommended that all subclasses override this method.
* <p>
* The
<code>toString</code> method for class <code>Object</code>
* The
{@code toString} method for class {@code Object}
* returns a string consisting of the name of the class of which the
* object is an instance, the at-sign character `
<code>@</code>
', and
* object is an instance, the at-sign character `
{@code @}
', and
* the unsigned hexadecimal representation of the hash code of the
* object. In other words, this method returns a string equal to the
* value of:
...
...
@@ -241,7 +241,7 @@ public class Object {
* monitor. If any threads are waiting on this object, one of them
* is chosen to be awakened. The choice is arbitrary and occurs at
* the discretion of the implementation. A thread waits on an object's
* monitor by calling one of the
<code>wait</code>
methods.
* monitor by calling one of the
{@code wait}
methods.
* <p>
* The awakened thread will not be able to proceed until the current
* thread relinquishes the lock on this object. The awakened thread will
...
...
@@ -255,9 +255,9 @@ public class Object {
* object's monitor in one of three ways:
* <ul>
* <li>By executing a synchronized instance method of that object.
* <li>By executing the body of a
<code>synchronized</code>
statement
* <li>By executing the body of a
{@code synchronized}
statement
* that synchronizes on the object.
* <li>For objects of type
<code>Class,</code>
by executing a
* <li>For objects of type
{@code Class,}
by executing a
* synchronized static method of that class.
* </ul>
* <p>
...
...
@@ -273,7 +273,7 @@ public class Object {
/**
* Wakes up all threads that are waiting on this object's monitor. A
* thread waits on an object's monitor by calling one of the
*
<code>wait</code>
methods.
*
{@code wait}
methods.
* <p>
* The awakened threads will not be able to proceed until the current
* thread relinquishes the lock on this object. The awakened threads
...
...
@@ -283,7 +283,7 @@ public class Object {
* being the next thread to lock this object.
* <p>
* This method should only be called by a thread that is the owner
* of this object's monitor. See the
<code>notify</code>
method for a
* of this object's monitor. See the
{@code notify}
method for a
* description of the ways in which a thread can become the owner of
* a monitor.
*
...
...
@@ -308,15 +308,15 @@ public class Object {
* becomes disabled for thread scheduling purposes and lies dormant
* until one of four things happens:
* <ul>
* <li>Some other thread invokes the
<tt>notify</tt>
method for this
* <li>Some other thread invokes the
{@code notify}
method for this
* object and thread <var>T</var> happens to be arbitrarily chosen as
* the thread to be awakened.
* <li>Some other thread invokes the
<tt>notifyAll</tt>
method for this
* <li>Some other thread invokes the
{@code notifyAll}
method for this
* object.
* <li>Some other thread {@linkplain Thread#interrupt() interrupts}
* thread <var>T</var>.
* <li>The specified amount of real time has elapsed, more or less. If
*
<tt>timeout</tt>
is zero, however, then real time is not taken into
*
{@code timeout}
is zero, however, then real time is not taken into
* consideration and the thread simply waits until notified.
* </ul>
* The thread <var>T</var> is then removed from the wait set for this
...
...
@@ -324,11 +324,11 @@ public class Object {
* usual manner with other threads for the right to synchronize on the
* object; once it has gained control of the object, all its
* synchronization claims on the object are restored to the status quo
* ante - that is, to the situation as of the time that the
<tt>wait</tt>
* ante - that is, to the situation as of the time that the
{@code wait}
* method was invoked. Thread <var>T</var> then returns from the
* invocation of the
<tt>wait</tt>
method. Thus, on return from the
*
<tt>wait</tt>
method, the synchronization state of the object and of
* thread
<tt>T</tt> is exactly as it was when the <tt>wait</tt>
method
* invocation of the
{@code wait}
method. Thus, on return from the
*
{@code wait}
method, the synchronization state of the object and of
* thread
{@code T} is exactly as it was when the {@code wait}
method
* was invoked.
* <p>
* A thread can also wake up without being notified, interrupted, or
...
...
@@ -351,18 +351,18 @@ public class Object {
*
* <p>If the current thread is {@linkplain java.lang.Thread#interrupt()
* interrupted} by any thread before or while it is waiting, then an
*
<tt>InterruptedException</tt>
is thrown. This exception is not
*
{@code InterruptedException}
is thrown. This exception is not
* thrown until the lock status of this object has been restored as
* described above.
*
* <p>
* Note that the
<tt>wait</tt>
method, as it places the current thread
* Note that the
{@code wait}
method, as it places the current thread
* into the wait set for this object, unlocks only this object; any
* other objects on which the current thread may be synchronized remain
* locked while the thread waits.
* <p>
* This method should only be called by a thread that is the owner
* of this object's monitor. See the
<code>notify</code>
method for a
* of this object's monitor. See the
{@code notify}
method for a
* description of the ways in which a thread can become the owner of
* a monitor.
*
...
...
@@ -388,7 +388,7 @@ public class Object {
* some other thread interrupts the current thread, or a certain
* amount of real time has elapsed.
* <p>
* This method is similar to the
<code>wait</code>
method of one
* This method is similar to the
{@code wait}
method of one
* argument, but it allows finer control over the amount of time to
* wait for a notification before giving up. The amount of real time,
* measured in nanoseconds, is given by:
...
...
@@ -398,17 +398,17 @@ public class Object {
* <p>
* In all other respects, this method does the same thing as the
* method {@link #wait(long)} of one argument. In particular,
*
<tt>wait(0, 0)</tt> means the same thing as <tt>wait(0)</tt>
.
*
{@code wait(0, 0)} means the same thing as {@code wait(0)}
.
* <p>
* The current thread must own this object's monitor. The thread
* releases ownership of this monitor and waits until either of the
* following two conditions has occurred:
* <ul>
* <li>Another thread notifies threads waiting on this object's monitor
* to wake up either through a call to the
<code>notify</code>
method
* or the
<code>notifyAll</code>
method.
* <li>The timeout period, specified by
<code>timeout</code>
* milliseconds plus
<code>nanos</code>
nanoseconds arguments, has
* to wake up either through a call to the
{@code notify}
method
* or the
{@code notifyAll}
method.
* <li>The timeout period, specified by
{@code timeout}
* milliseconds plus
{@code nanos}
nanoseconds arguments, has
* elapsed.
* </ul>
* <p>
...
...
@@ -425,7 +425,7 @@ public class Object {
* }
* </pre>
* This method should only be called by a thread that is the owner
* of this object's monitor. See the
<code>notify</code>
method for a
* of this object's monitor. See the
{@code notify}
method for a
* description of the ways in which a thread can become the owner of
* a monitor.
*
...
...
@@ -465,13 +465,13 @@ public class Object {
* {@link java.lang.Object#notify()} method or the
* {@link java.lang.Object#notifyAll()} method for this object.
* In other words, this method behaves exactly as if it simply
* performs the call
<tt>wait(0)</tt>
.
* performs the call
{@code wait(0)}
.
* <p>
* The current thread must own this object's monitor. The thread
* releases ownership of this monitor and waits until another thread
* notifies threads waiting on this object's monitor to wake up
* either through a call to the
<code>notify</code>
method or the
*
<code>notifyAll</code>
method. The thread then waits until it can
* either through a call to the
{@code notify}
method or the
*
{@code notifyAll}
method. The thread then waits until it can
* re-obtain ownership of the monitor and resumes execution.
* <p>
* As in the one argument version, interrupts and spurious wakeups are
...
...
@@ -484,7 +484,7 @@ public class Object {
* }
* </pre>
* This method should only be called by a thread that is the owner
* of this object's monitor. See the
<code>notify</code>
method for a
* of this object's monitor. See the
{@code notify}
method for a
* description of the ways in which a thread can become the owner of
* a monitor.
*
...
...
@@ -505,49 +505,49 @@ public class Object {
/**
* Called by the garbage collector on an object when garbage collection
* determines that there are no more references to the object.
* A subclass overrides the
<code>finalize</code>
method to dispose of
* A subclass overrides the
{@code finalize}
method to dispose of
* system resources or to perform other cleanup.
* <p>
* The general contract of
<tt>finalize</tt>
is that it is invoked
* The general contract of
{@code finalize}
is that it is invoked
* if and when the Java<font size="-2"><sup>TM</sup></font> virtual
* machine has determined that there is no longer any
* means by which this object can be accessed by any thread that has
* not yet died, except as a result of an action taken by the
* finalization of some other object or class which is ready to be
* finalized. The
<tt>finalize</tt>
method may take any action, including
* finalized. The
{@code finalize}
method may take any action, including
* making this object available again to other threads; the usual purpose
* of
<tt>finalize</tt>
, however, is to perform cleanup actions before
* of
{@code finalize}
, however, is to perform cleanup actions before
* the object is irrevocably discarded. For example, the finalize method
* for an object that represents an input/output connection might perform
* explicit I/O transactions to break the connection before the object is
* permanently discarded.
* <p>
* The
<tt>finalize</tt> method of class <tt>Object</tt>
performs no
* The
{@code finalize} method of class {@code Object}
performs no
* special action; it simply returns normally. Subclasses of
*
<tt>Object</tt>
may override this definition.
*
{@code Object}
may override this definition.
* <p>
* The Java programming language does not guarantee which thread will
* invoke the
<tt>finalize</tt>
method for any given object. It is
* invoke the
{@code finalize}
method for any given object. It is
* guaranteed, however, that the thread that invokes finalize will not
* be holding any user-visible synchronization locks when finalize is
* invoked. If an uncaught exception is thrown by the finalize method,
* the exception is ignored and finalization of that object terminates.
* <p>
* After the
<tt>finalize</tt>
method has been invoked for an object, no
* After the
{@code finalize}
method has been invoked for an object, no
* further action is taken until the Java virtual machine has again
* determined that there is no longer any means by which this object can
* be accessed by any thread that has not yet died, including possible
* actions by other objects or classes which are ready to be finalized,
* at which point the object may be discarded.
* <p>
* The
<tt>finalize</tt>
method is never invoked more than once by a Java
* The
{@code finalize}
method is never invoked more than once by a Java
* virtual machine for any given object.
* <p>
* Any exception thrown by the
<code>finalize</code>
method causes
* Any exception thrown by the
{@code finalize}
method causes
* the finalization of this object to be halted, but is otherwise
* ignored.
*
* @throws Throwable the
<code>Exception</code>
raised by this method
* @throws Throwable the
{@code Exception}
raised by this method
*/
protected
void
finalize
()
throws
Throwable
{
}
}
src/share/classes/java/lang/RuntimePermission.java
浏览文件 @
a7cb2d41
...
...
@@ -100,6 +100,13 @@ import java.util.StringTokenizer;
* </tr>
*
* <tr>
* <td>closeClassLoader</td>
* <td>Closing of a ClassLoader</td>
* <td>Granting this permission allows code to close any URLClassLoader
* that it has a reference to.</td>
* </tr>
*
* <tr>
* <td>setSecurityManager</td>
* <td>Setting of the security manager (possibly replacing an existing one)
* </td>
...
...
src/share/classes/java/lang/annotation/Annotation.java
浏览文件 @
a7cb2d41
/*
* Copyright 2003-200
4
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-200
9
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -31,6 +31,10 @@ package java.lang.annotation;
* an annotation type. Also note that this interface does not itself
* define an annotation type.
*
* More information about annotation types can be found in <i>The
* Java™ Language Specification, Third Edition</i>, <a
* href="http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.6">§9.6</a>.
*
* @author Josh Bloch
* @since 1.5
*/
...
...
src/share/classes/java/lang/instrument/package.html
浏览文件 @
a7cb2d41
<!--
Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation. Sun designates this
particular file as subject to the "Classpath" exception as provided
by Sun in the LICENSE file that accompanied this code.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
CA 95054 USA or visit www.sun.com if you need additional information or
have any questions.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
...
...
src/share/classes/java/net/HttpCookie.java
浏览文件 @
a7cb2d41
...
...
@@ -1058,8 +1058,7 @@ public final class HttpCookie implements Cloneable {
if
(
assignor
!=
null
)
{
assignor
.
assign
(
cookie
,
attrName
,
attrValue
);
}
else
{
// must be an error
throw
new
IllegalArgumentException
(
"Illegal cookie attribute"
);
// Ignore the attribute as per RFC 2965
}
}
...
...
src/share/classes/java/net/URLClassLoader.java
浏览文件 @
a7cb2d41
...
...
@@ -31,10 +31,12 @@ import java.io.File;
import
java.io.FilePermission
;
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.io.Closeable
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLStreamHandlerFactory
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.NoSuchElementException
;
import
java.util.StringTokenizer
;
import
java.util.jar.Manifest
;
...
...
@@ -70,7 +72,7 @@ import sun.security.util.SecurityConstants;
* @author David Connelly
* @since 1.2
*/
public
class
URLClassLoader
extends
SecureClassLoader
{
public
class
URLClassLoader
extends
SecureClassLoader
implements
Closeable
{
/* The search path for classes and resources */
URLClassPath
ucp
;
...
...
@@ -85,13 +87,13 @@ public class URLClassLoader extends SecureClassLoader {
* to refer to a JAR file which will be downloaded and opened as needed.
*
* <p>If there is a security manager, this method first
* calls the security manager's
<code>checkCreateClassLoader</code>
method
* calls the security manager's
{@code checkCreateClassLoader}
method
* to ensure creation of a class loader is allowed.
*
* @param urls the URLs from which to load classes and resources
* @param parent the parent class loader for delegation
* @exception SecurityException if a security manager exists and its
*
<code>checkCreateClassLoader</code>
method doesn't allow
*
{@code checkCreateClassLoader}
method doesn't allow
* creation of a class loader.
* @see SecurityManager#checkCreateClassLoader
*/
...
...
@@ -169,12 +171,65 @@ public class URLClassLoader extends SecureClassLoader {
acc
=
AccessController
.
getContext
();
}
/**
* Closes this URLClassLoader, so that it can no longer be used to load
* new classes or resources that are defined by this loader.
* Classes and resources defined by any of this loader's parents in the
* delegation hierarchy are still accessible. Also, any classes or resources
* that are already loaded, are still accessible.
* <p>
* In the case of jar: and file: URLs, it also closes any class files,
* or JAR files that were opened by it. If another thread is loading a
* class when the {@code close} method is invoked, then the result of
* that load is undefined.
* <p>
* The method makes a best effort attempt to close all opened files,
* by catching {@link IOException}s internally. Unchecked exceptions
* 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
* resulted in an IOException. Any such exceptions are caught, and a
* single IOException is thrown after the last file has been closed.
* If only one exception was thrown, it will be set as the <i>cause</i>
* of this IOException.
*
* @throws SecurityException if a security manager is set, and it denies
* {@link RuntimePermission}<tt>("closeClassLoader")</tt>
*
* @since 1.7
*/
public
void
close
()
throws
IOException
{
SecurityManager
security
=
System
.
getSecurityManager
();
if
(
security
!=
null
)
{
security
.
checkPermission
(
new
RuntimePermission
(
"closeClassLoader"
));
}
List
<
IOException
>
errors
=
ucp
.
closeLoaders
();
if
(
errors
.
isEmpty
())
{
return
;
}
if
(
errors
.
size
()
==
1
)
{
throw
new
IOException
(
"Error closing URLClassLoader resource"
,
errors
.
get
(
0
)
);
}
// Several exceptions. So, just combine the error messages
String
errormsg
=
"Error closing resources: "
;
for
(
IOException
error:
errors
)
{
errormsg
=
errormsg
+
"["
+
error
.
toString
()
+
"] "
;
}
throw
new
IOException
(
errormsg
);
}
/**
* Appends the specified URL to the list of URLs to search for
* classes and resources.
* <p>
* If the URL specified is <code>null</code> or is already in the
* list of URLs, then invoking this method has no effect.
* list of URLs, or if this loader is closed, then invoking this
* method has no effect.
*
* @param url the URL to be added to the search path of URLs
*/
...
...
@@ -199,7 +254,8 @@ public class URLClassLoader extends SecureClassLoader {
*
* @param name the name of the class
* @return the resulting class
* @exception ClassNotFoundException if the class could not be found
* @exception ClassNotFoundException if the class could not be found,
* or if the loader is closed.
*/
protected
Class
<?>
findClass
(
final
String
name
)
throws
ClassNotFoundException
...
...
@@ -370,7 +426,7 @@ public class URLClassLoader extends SecureClassLoader {
*
* @param name the name of the resource
* @return a <code>URL</code> for the resource, or <code>null</code>
* if the resource could not be found.
* if the resource could not be found
, or if the loader is closed
.
*/
public
URL
findResource
(
final
String
name
)
{
/*
...
...
@@ -393,6 +449,7 @@ public class URLClassLoader extends SecureClassLoader {
* @param name the resource name
* @exception IOException if an I/O exception occurs
* @return an <code>Enumeration</code> of <code>URL</code>s
* If the loader is closed, the Enumeration will be empty.
*/
public
Enumeration
<
URL
>
findResources
(
final
String
name
)
throws
IOException
...
...
src/share/classes/java/util/Formatter.java
浏览文件 @
a7cb2d41
...
...
@@ -59,7 +59,7 @@ import sun.misc.FormattedFloatingDecimal;
* An interpreter for printf-style format strings. This class provides support
* for layout justification and alignment, common formats for numeric, string,
* and date/time data, and locale-specific output. Common Java types such as
*
<tt>byte</tt>
, {@link java.math.BigDecimal BigDecimal}, and {@link Calendar}
*
{@code byte}
, {@link java.math.BigDecimal BigDecimal}, and {@link Calendar}
* are supported. Limited formatting customization for arbitrary user types is
* provided through the {@link Formattable} interface.
*
...
...
@@ -68,7 +68,7 @@ import sun.misc.FormattedFloatingDecimal;
* class.
*
* <p> Formatted printing for the Java language is heavily inspired by C's
*
<tt>printf</tt>
. Although the format strings are similar to C, some
*
{@code printf}
. Although the format strings are similar to C, some
* customizations have been made to accommodate the Java language and exploit
* some of its features. Also, Java formatting is more strict than C's; for
* example, if a conversion is incompatible with a flag, an exception will be
...
...
@@ -115,7 +115,7 @@ import sun.misc.FormattedFloatingDecimal;
* // -> "Unable to open file 'food': No such file or directory"
* </pre></blockquote>
*
* <p> Like C's
<tt>sprintf(3)</tt>
, Strings may be formatted using the static
* <p> Like C's
{@code sprintf(3)}
, Strings may be formatted using the static
* method {@link String#format(String,Object...) String.format}:
*
* <blockquote><pre>
...
...
@@ -157,16 +157,16 @@ import sun.misc.FormattedFloatingDecimal;
* String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c);
* </pre></blockquote>
*
* This format string is the first argument to the
<tt>format</tt>
method. It
* contains three format specifiers "
<tt>%1$tm</tt>", "<tt>%1$te</tt>
", and
* "
<tt>%1$tY</tt>
" which indicate how the arguments should be processed and
* This format string is the first argument to the
{@code format}
method. It
* contains three format specifiers "
{@code %1$tm}", "{@code %1$te}
", and
* "
{@code %1$tY}
" which indicate how the arguments should be processed and
* where they should be inserted in the text. The remaining portions of the
* format string are fixed text including
<tt>"Dukes Birthday: "</tt>
and any
* format string are fixed text including
{@code "Dukes Birthday: "}
and any
* other spaces or punctuation.
*
* The argument list consists of all arguments passed to the method after the
* format string. In the above example, the argument list is of size one and
* consists of the {@link java.util.Calendar Calendar} object
<tt>c</tt>
.
* consists of the {@link java.util.Calendar Calendar} object
{@code c}
.
*
* <ul>
*
...
...
@@ -179,7 +179,7 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> The optional <i>argument_index</i> is a decimal integer indicating the
* position of the argument in the argument list. The first argument is
* referenced by "
<tt>1$</tt>", the second by "<tt>2$</tt>
", etc.
* referenced by "
{@code 1$}", the second by "{@code 2$}
", etc.
*
* <p> The optional <i>flags</i> is a set of characters that modify the output
* format. The set of valid flags depends on the conversion.
...
...
@@ -206,10 +206,10 @@ import sun.misc.FormattedFloatingDecimal;
* defined as above.
*
* <p> The required <i>conversion</i> is a two character sequence. The first
* character is
<tt>'t'</tt> or <tt>'T'</tt>
. The second character indicates
* character is
{@code 't'} or {@code 'T'}
. The second character indicates
* the format to be used. These characters are similar to but not completely
* identical to those defined by GNU
<tt>date</tt>
and POSIX
*
<tt>strftime(3c)</tt>
.
* identical to those defined by GNU
{@code date}
and POSIX
*
{@code strftime(3c)}
.
*
* <li> The format specifiers which do not correspond to arguments have the
* following syntax:
...
...
@@ -235,31 +235,31 @@ import sun.misc.FormattedFloatingDecimal;
* type
*
* <li> <b>Character</b> - may be applied to basic types which represent
* Unicode characters:
<tt>char</tt>, {@link Character}, <tt>byte</tt>
, {@link
* Byte},
<tt>short</tt>
, and {@link Short}. This conversion may also be
* applied to the types
<tt>int</tt>
and {@link Integer} when {@link
* Character#isValidCodePoint} returns
<tt>true</tt>
* Unicode characters:
{@code char}, {@link Character}, {@code byte}
, {@link
* Byte},
{@code short}
, and {@link Short}. This conversion may also be
* applied to the types
{@code int}
and {@link Integer} when {@link
* Character#isValidCodePoint} returns
{@code true}
*
* <li> <b>Numeric</b>
*
* <ol>
*
* <li> <b>Integral</b> - may be applied to Java integral types:
<tt>byte</tt>
,
* {@link Byte},
<tt>short</tt>, {@link Short}, <tt>int</tt>
and {@link
* Integer},
<tt>long</tt>
, {@link Long}, and {@link java.math.BigInteger
* <li> <b>Integral</b> - may be applied to Java integral types:
{@code byte}
,
* {@link Byte},
{@code short}, {@link Short}, {@code int}
and {@link
* Integer},
{@code long}
, {@link Long}, and {@link java.math.BigInteger
* BigInteger}
*
* <li><b>Floating Point</b> - may be applied to Java floating-point types:
*
<tt>float</tt>, {@link Float}, <tt>double</tt>
, {@link Double}, and {@link
*
{@code float}, {@link Float}, {@code double}
, {@link Double}, and {@link
* java.math.BigDecimal BigDecimal}
*
* </ol>
*
* <li> <b>Date/Time</b> - may be applied to Java types which are capable of
* encoding a date or time:
<tt>long</tt>
, {@link Long}, {@link Calendar}, and
* encoding a date or time:
{@code long}
, {@link Long}, {@link Calendar}, and
* {@link Date}.
*
* <li> <b>Percent</b> - produces a literal
<tt>'%'</tt>
* <li> <b>Percent</b> - produces a literal
{@code '%'}
* (<tt>'\u0025'</tt>)
*
* <li> <b>Line Separator</b> - produces the platform-specific line separator
...
...
@@ -267,9 +267,9 @@ import sun.misc.FormattedFloatingDecimal;
* </ol>
*
* <p> The following table summarizes the supported conversions. Conversions
* denoted by an upper-case character (i.e.
<tt>'B'</tt>, <tt>'H'</tt>
,
*
<tt>'S'</tt>, <tt>'C'</tt>, <tt>'X'</tt>, <tt>'E'</tt>, <tt>'G'</tt>
,
*
<tt>'A'</tt>, and <tt>'T'</tt>
) are the same as those for the corresponding
* denoted by an upper-case character (i.e.
{@code 'B'}, {@code 'H'}
,
*
{@code 'S'}, {@code 'C'}, {@code 'X'}, {@code 'E'}, {@code 'G'}
,
*
{@code 'A'}, and {@code 'T'}
) are the same as those for the corresponding
* lower-case conversion characters except that the result is converted to
* upper case according to the rules of the prevailing {@link java.util.Locale
* Locale}. The result is equivalent to the following invocation of {@link
...
...
@@ -284,72 +284,72 @@ import sun.misc.FormattedFloatingDecimal;
* <th valign="bottom"> Argument Category
* <th valign="bottom"> Description
*
* <tr><td valign="top">
<tt>'b'</tt>, <tt>'B'</tt>
* <tr><td valign="top">
{@code 'b'}, {@code 'B'}
* <td valign="top"> general
* <td> If the argument <i>arg</i> is
<tt>null</tt>
, then the result is
* "
<tt>false</tt>". If <i>arg</i> is a <tt>boolean</tt>
or {@link
* <td> If the argument <i>arg</i> is
{@code null}
, then the result is
* "
{@code false}". If <i>arg</i> is a {@code boolean}
or {@link
* Boolean}, then the result is the string returned by {@link
* String#valueOf(boolean) String.valueOf(arg)}. Otherwise, the result is
* "true".
*
* <tr><td valign="top">
<tt>'h'</tt>, <tt>'H'</tt>
* <tr><td valign="top">
{@code 'h'}, {@code 'H'}
* <td valign="top"> general
* <td> If the argument <i>arg</i> is
<tt>null</tt>
, then the result is
* "
<tt>null</tt>
". Otherwise, the result is obtained by invoking
*
<tt>Integer.toHexString(arg.hashCode())</tt>
.
* <td> If the argument <i>arg</i> is
{@code null}
, then the result is
* "
{@code null}
". Otherwise, the result is obtained by invoking
*
{@code Integer.toHexString(arg.hashCode())}
.
*
* <tr><td valign="top">
<tt>'s'</tt>, <tt>'S'</tt>
* <tr><td valign="top">
{@code 's'}, {@code 'S'}
* <td valign="top"> general
* <td> If the argument <i>arg</i> is
<tt>null</tt>
, then the result is
* "
<tt>null</tt>
". If <i>arg</i> implements {@link Formattable}, then
* <td> If the argument <i>arg</i> is
{@code null}
, then the result is
* "
{@code null}
". If <i>arg</i> implements {@link Formattable}, then
* {@link Formattable#formatTo arg.formatTo} is invoked. Otherwise, the
* result is obtained by invoking
<tt>arg.toString()</tt>
.
* result is obtained by invoking
{@code arg.toString()}
.
*
* <tr><td valign="top">
<tt>'c'</tt>, <tt>'C'</tt>
* <tr><td valign="top">
{@code 'c'}, {@code 'C'}
* <td valign="top"> character
* <td> The result is a Unicode character
*
* <tr><td valign="top">
<tt>'d'</tt>
* <tr><td valign="top">
{@code 'd'}
* <td valign="top"> integral
* <td> The result is formatted as a decimal integer
*
* <tr><td valign="top">
<tt>'o'</tt>
* <tr><td valign="top">
{@code 'o'}
* <td valign="top"> integral
* <td> The result is formatted as an octal integer
*
* <tr><td valign="top">
<tt>'x'</tt>, <tt>'X'</tt>
* <tr><td valign="top">
{@code 'x'}, {@code 'X'}
* <td valign="top"> integral
* <td> The result is formatted as a hexadecimal integer
*
* <tr><td valign="top">
<tt>'e'</tt>, <tt>'E'</tt>
* <tr><td valign="top">
{@code 'e'}, {@code 'E'}
* <td valign="top"> floating point
* <td> The result is formatted as a decimal number in computerized
* scientific notation
*
* <tr><td valign="top">
<tt>'f'</tt>
* <tr><td valign="top">
{@code 'f'}
* <td valign="top"> floating point
* <td> The result is formatted as a decimal number
*
* <tr><td valign="top">
<tt>'g'</tt>, <tt>'G'</tt>
* <tr><td valign="top">
{@code 'g'}, {@code 'G'}
* <td valign="top"> floating point
* <td> The result is formatted using computerized scientific notation or
* decimal format, depending on the precision and the value after rounding.
*
* <tr><td valign="top">
<tt>'a'</tt>, <tt>'A'</tt>
* <tr><td valign="top">
{@code 'a'}, {@code 'A'}
* <td valign="top"> floating point
* <td> The result is formatted as a hexadecimal floating-point number with
* a significand and an exponent
*
* <tr><td valign="top">
<tt>'t'</tt>, <tt>'T'</tt>
* <tr><td valign="top">
{@code 't'}, {@code 'T'}
* <td valign="top"> date/time
* <td> Prefix for date and time conversion characters. See <a
* href="#dt">Date/Time Conversions</a>.
*
* <tr><td valign="top">
<tt>'%'</tt>
* <tr><td valign="top">
{@code '%'}
* <td valign="top"> percent
* <td> The result is a literal
<tt>'%'</tt>
(<tt>'\u0025'</tt>)
* <td> The result is a literal
{@code '%'}
(<tt>'\u0025'</tt>)
*
* <tr><td valign="top">
<tt>'n'</tt>
* <tr><td valign="top">
{@code 'n'}
* <td valign="top"> line separator
* <td> The result is the platform-specific line separator
*
...
...
@@ -361,78 +361,78 @@ import sun.misc.FormattedFloatingDecimal;
* <h4><a name="dt">Date/Time Conversions</a></h4>
*
* <p> The following date and time conversion suffix characters are defined for
* the
<tt>'t'</tt> and <tt>'T'</tt>
conversions. The types are similar to but
* not completely identical to those defined by GNU
<tt>date</tt>
and POSIX
*
<tt>strftime(3c)</tt>
. Additional conversion types are provided to access
* Java-specific functionality (e.g.
<tt>'L'</tt>
for milliseconds within the
* the
{@code 't'} and {@code 'T'}
conversions. The types are similar to but
* not completely identical to those defined by GNU
{@code date}
and POSIX
*
{@code strftime(3c)}
. Additional conversion types are provided to access
* Java-specific functionality (e.g.
{@code 'L'}
for milliseconds within the
* second).
*
* <p> The following conversion characters are used for formatting times:
*
* <table cellpadding=5 summary="time">
*
* <tr><td valign="top">
<tt>'H'</tt>
* <tr><td valign="top">
{@code 'H'}
* <td> Hour of the day for the 24-hour clock, formatted as two digits with
* a leading zero as necessary i.e.
<tt>00 - 23</tt>
.
* a leading zero as necessary i.e.
{@code 00 - 23}
.
*
* <tr><td valign="top">
<tt>'I'</tt>
* <tr><td valign="top">
{@code 'I'}
* <td> Hour for the 12-hour clock, formatted as two digits with a leading
* zero as necessary, i.e.
<tt>01 - 12</tt>
.
* zero as necessary, i.e.
{@code 01 - 12}
.
*
* <tr><td valign="top">
<tt>'k'</tt>
* <td> Hour of the day for the 24-hour clock, i.e.
<tt>0 - 23</tt>
.
* <tr><td valign="top">
{@code 'k'}
* <td> Hour of the day for the 24-hour clock, i.e.
{@code 0 - 23}
.
*
* <tr><td valign="top">
<tt>'l'</tt>
* <td> Hour for the 12-hour clock, i.e.
<tt>1 - 12</tt>
.
* <tr><td valign="top">
{@code 'l'}
* <td> Hour for the 12-hour clock, i.e.
{@code 1 - 12}
.
*
* <tr><td valign="top">
<tt>'M'</tt>
* <tr><td valign="top">
{@code 'M'}
* <td> Minute within the hour formatted as two digits with a leading zero
* as necessary, i.e.
<tt>00 - 59</tt>
.
* as necessary, i.e.
{@code 00 - 59}
.
*
* <tr><td valign="top">
<tt>'S'</tt>
* <tr><td valign="top">
{@code 'S'}
* <td> Seconds within the minute, formatted as two digits with a leading
* zero as necessary, i.e.
<tt>00 - 60</tt> ("<tt>60</tt>
" is a special
* zero as necessary, i.e.
{@code 00 - 60} ("{@code 60}
" is a special
* value required to support leap seconds).
*
* <tr><td valign="top">
<tt>'L'</tt>
* <tr><td valign="top">
{@code 'L'}
* <td> Millisecond within the second formatted as three digits with
* leading zeros as necessary, i.e.
<tt>000 - 999</tt>
.
* leading zeros as necessary, i.e.
{@code 000 - 999}
.
*
* <tr><td valign="top">
<tt>'N'</tt>
* <tr><td valign="top">
{@code 'N'}
* <td> Nanosecond within the second, formatted as nine digits with leading
* zeros as necessary, i.e.
<tt>000000000 - 999999999</tt>
.
* zeros as necessary, i.e.
{@code 000000000 - 999999999}
.
*
* <tr><td valign="top">
<tt>'p'</tt>
* <tr><td valign="top">
{@code 'p'}
* <td> Locale-specific {@linkplain
* java.text.DateFormatSymbols#getAmPmStrings morning or afternoon} marker
* in lower case, e.g."
<tt>am</tt>" or "<tt>pm</tt>
". Use of the conversion
* prefix
<tt>'T'</tt>
forces this output to upper case.
* in lower case, e.g."
{@code am}" or "{@code pm}
". Use of the conversion
* prefix
{@code 'T'}
forces this output to upper case.
*
* <tr><td valign="top">
<tt>'z'</tt>
* <tr><td valign="top">
{@code 'z'}
* <td> <a href="http://www.ietf.org/rfc/rfc0822.txt">RFC 822</a>
* style numeric time zone offset from GMT, e.g.
<tt>-0800</tt>
. This
* style numeric time zone offset from GMT, e.g.
{@code -0800}
. This
* value will be adjusted as necessary for Daylight Saving Time. For
*
<tt>long</tt>
, {@link Long}, and {@link Date} the time zone used is
* the {@
plainlink
TimeZone#getDefault() default time zone} for this
*
{@code long}
, {@link Long}, and {@link Date} the time zone used is
* the {@
linkplain
TimeZone#getDefault() default time zone} for this
* instance of the Java virtual machine.
*
* <tr><td valign="top">
<tt>'Z'</tt>
* <tr><td valign="top">
{@code 'Z'}
* <td> A string representing the abbreviation for the time zone. This
* value will be adjusted as necessary for Daylight Saving Time. For
*
<tt>long</tt>
, {@link Long}, and {@link Date} the time zone used is
* the {@
plainlink
TimeZone#getDefault() default time zone} for this
*
{@code long}
, {@link Long}, and {@link Date} the time zone used is
* the {@
linkplain
TimeZone#getDefault() default time zone} for this
* instance of the Java virtual machine. The Formatter's locale will
* supersede the locale of the argument (if any).
*
* <tr><td valign="top">
<tt>'s'</tt>
* <tr><td valign="top">
{@code 's'}
* <td> Seconds since the beginning of the epoch starting at 1 January 1970
*
<tt>00:00:00</tt> UTC, i.e. <tt>Long.MIN_VALUE/1000</tt>
to
*
<tt>Long.MAX_VALUE/1000</tt>
.
*
{@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE/1000}
to
*
{@code Long.MAX_VALUE/1000}
.
*
* <tr><td valign="top">
<tt>'Q'</tt>
* <tr><td valign="top">
{@code 'Q'}
* <td> Milliseconds since the beginning of the epoch starting at 1 January
* 1970
<tt>00:00:00</tt> UTC, i.e. <tt>Long.MIN_VALUE</tt>
to
*
<tt>Long.MAX_VALUE</tt>
.
* 1970
{@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE}
to
*
{@code Long.MAX_VALUE}
.
*
* </table>
*
...
...
@@ -440,55 +440,55 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="date">
*
* <tr><td valign="top">
<tt>'B'</tt>
* <tr><td valign="top">
{@code 'B'}
* <td> Locale-specific {@linkplain java.text.DateFormatSymbols#getMonths
* full month name}, e.g.
<tt>"January"</tt>, <tt>"February"</tt>
.
* full month name}, e.g.
{@code "January"}, {@code "February"}
.
*
* <tr><td valign="top">
<tt>'b'</tt>
* <tr><td valign="top">
{@code 'b'}
* <td> Locale-specific {@linkplain
* java.text.DateFormatSymbols#getShortMonths abbreviated month name},
* e.g.
<tt>"Jan"</tt>, <tt>"Feb"</tt>
.
* e.g.
{@code "Jan"}, {@code "Feb"}
.
*
* <tr><td valign="top">
<tt>'h'</tt>
* <td> Same as
<tt>'b'</tt>
.
* <tr><td valign="top">
{@code 'h'}
* <td> Same as
{@code 'b'}
.
*
* <tr><td valign="top">
<tt>'A'</tt>
* <tr><td valign="top">
{@code 'A'}
* <td> Locale-specific full name of the {@linkplain
* java.text.DateFormatSymbols#getWeekdays day of the week},
* e.g.
<tt>"Sunday"</tt>, <tt>"Monday"</tt>
* e.g.
{@code "Sunday"}, {@code "Monday"}
*
* <tr><td valign="top">
<tt>'a'</tt>
* <tr><td valign="top">
{@code 'a'}
* <td> Locale-specific short name of the {@linkplain
* java.text.DateFormatSymbols#getShortWeekdays day of the week},
* e.g.
<tt>"Sun"</tt>, <tt>"Mon"</tt>
* e.g.
{@code "Sun"}, {@code "Mon"}
*
* <tr><td valign="top">
<tt>'C'</tt>
* <td> Four-digit year divided by
<tt>100</tt>
, formatted as two digits
* with leading zero as necessary, i.e.
<tt>00 - 99</tt>
* <tr><td valign="top">
{@code 'C'}
* <td> Four-digit year divided by
{@code 100}
, formatted as two digits
* with leading zero as necessary, i.e.
{@code 00 - 99}
*
* <tr><td valign="top">
<tt>'Y'</tt>
* <tr><td valign="top">
{@code 'Y'}
* <td> Year, formatted as at least four digits with leading zeros as
* necessary, e.g.
<tt>0092</tt> equals <tt>92</tt>
CE for the Gregorian
* necessary, e.g.
{@code 0092} equals {@code 92}
CE for the Gregorian
* calendar.
*
* <tr><td valign="top">
<tt>'y'</tt>
* <tr><td valign="top">
{@code 'y'}
* <td> Last two digits of the year, formatted with leading zeros as
* necessary, i.e.
<tt>00 - 99</tt>
.
* necessary, i.e.
{@code 00 - 99}
.
*
* <tr><td valign="top">
<tt>'j'</tt>
* <tr><td valign="top">
{@code 'j'}
* <td> Day of year, formatted as three digits with leading zeros as
* necessary, e.g.
<tt>001 - 366</tt>
for the Gregorian calendar.
* necessary, e.g.
{@code 001 - 366}
for the Gregorian calendar.
*
* <tr><td valign="top">
<tt>'m'</tt>
* <tr><td valign="top">
{@code 'm'}
* <td> Month, formatted as two digits with leading zeros as necessary,
* i.e.
<tt>01 - 13</tt>
.
* i.e.
{@code 01 - 13}
.
*
* <tr><td valign="top">
<tt>'d'</tt>
* <tr><td valign="top">
{@code 'd'}
* <td> Day of month, formatted as two digits with leading zeros as
* necessary, i.e.
<tt>01 - 31</tt>
* necessary, i.e.
{@code 01 - 31}
*
* <tr><td valign="top">
<tt>'e'</tt>
* <td> Day of month, formatted as two digits, i.e.
<tt>1 - 31</tt>
.
* <tr><td valign="top">
{@code 'e'}
* <td> Day of month, formatted as two digits, i.e.
{@code 1 - 31}
.
*
* </table>
*
...
...
@@ -497,27 +497,27 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="composites">
*
* <tr><td valign="top">
<tt>'R'</tt>
* <td> Time formatted for the 24-hour clock as
<tt>"%tH:%tM"</tt>
* <tr><td valign="top">
{@code 'R'}
* <td> Time formatted for the 24-hour clock as
{@code "%tH:%tM"}
*
* <tr><td valign="top">
<tt>'T'</tt>
* <td> Time formatted for the 24-hour clock as
<tt>"%tH:%tM:%tS"</tt>
.
* <tr><td valign="top">
{@code 'T'}
* <td> Time formatted for the 24-hour clock as
{@code "%tH:%tM:%tS"}
.
*
* <tr><td valign="top">
<tt>'r'</tt>
* <td> Time formatted for the 12-hour clock as
<tt>"%tI:%tM:%tS %Tp"</tt>
.
* The location of the morning or afternoon marker (
<tt>'%Tp'</tt>
) may be
* <tr><td valign="top">
{@code 'r'}
* <td> Time formatted for the 12-hour clock as
{@code "%tI:%tM:%tS %Tp"}
.
* The location of the morning or afternoon marker (
{@code '%Tp'}
) may be
* locale-dependent.
*
* <tr><td valign="top">
<tt>'D'</tt>
* <td> Date formatted as
<tt>"%tm/%td/%ty"</tt>
.
* <tr><td valign="top">
{@code 'D'}
* <td> Date formatted as
{@code "%tm/%td/%ty"}
.
*
* <tr><td valign="top">
<tt>'F'</tt>
* <tr><td valign="top">
{@code 'F'}
* <td> <a href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a>
* complete date formatted as
<tt>"%tY-%tm-%td"</tt>
.
* complete date formatted as
{@code "%tY-%tm-%td"}
.
*
* <tr><td valign="top">
<tt>'c'</tt>
* <td> Date and time formatted as
<tt>"%ta %tb %td %tT %tZ %tY"</tt>
,
* e.g.
<tt>"Sun Jul 20 16:17:00 EDT 1969"</tt>
.
* <tr><td valign="top">
{@code 'c'}
* <td> Date and time formatted as
{@code "%ta %tb %td %tT %tZ %tY"}
,
* e.g.
{@code "Sun Jul 20 16:17:00 EDT 1969"}
.
*
* </table>
*
...
...
@@ -591,18 +591,18 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> <sup>1</sup> Depends on the definition of {@link Formattable}.
*
* <p> <sup>2</sup> For
<tt>'d'</tt>
conversion only.
* <p> <sup>2</sup> For
{@code 'd'}
conversion only.
*
* <p> <sup>3</sup> For
<tt>'o'</tt>, <tt>'x'</tt>, and <tt>'X'</tt>
* <p> <sup>3</sup> For
{@code 'o'}, {@code 'x'}, and {@code 'X'}
* conversions only.
*
* <p> <sup>4</sup> For
<tt>'d'</tt>, <tt>'o'</tt>, <tt>'x'</tt>
, and
*
<tt>'X'</tt>
conversions applied to {@link java.math.BigInteger BigInteger}
* or
<tt>'d'</tt> applied to <tt>byte</tt>, {@link Byte}, <tt>short</tt>
, {@link
* Short},
<tt>int</tt> and {@link Integer}, <tt>long</tt>
, and {@link Long}.
* <p> <sup>4</sup> For
{@code 'd'}, {@code 'o'}, {@code 'x'}
, and
*
{@code 'X'}
conversions applied to {@link java.math.BigInteger BigInteger}
* or
{@code 'd'} applied to {@code byte}, {@link Byte}, {@code short}
, {@link
* Short},
{@code int} and {@link Integer}, {@code long}
, and {@link Long}.
*
* <p> <sup>5</sup> For
<tt>'e'</tt>, <tt>'E'</tt>, <tt>'f'</tt>
,
*
<tt>'g'</tt>, and <tt>'G'</tt>
conversions only.
* <p> <sup>5</sup> For
{@code 'e'}, {@code 'E'}, {@code 'f'}
,
*
{@code 'g'}, and {@code 'G'}
conversions only.
*
* <p> Any characters not explicitly defined as flags are illegal and are
* reserved for future extensions.
...
...
@@ -618,11 +618,11 @@ import sun.misc.FormattedFloatingDecimal;
* <p> For general argument types, the precision is the maximum number of
* characters to be written to the output.
*
* <p> For the floating-point conversions
<tt>'e'</tt>, <tt>'E'</tt>
, and
*
<tt>'f'</tt>
the precision is the number of digits after the decimal
* separator. If the conversion is
<tt>'g'</tt> or <tt>'G'</tt>
, then the
* <p> For the floating-point conversions
{@code 'e'}, {@code 'E'}
, and
*
{@code 'f'}
the precision is the number of digits after the decimal
* separator. If the conversion is
{@code 'g'} or {@code 'G'}
, then the
* precision is the total number of digits in the resulting magnitude after
* rounding. If the conversion is
<tt>'a'</tt> or <tt>'A'</tt>
, then the
* rounding. If the conversion is
{@code 'a'} or {@code 'A'}
, then the
* precision must not be specified.
*
* <p> For character, integral, and date/time argument types and the percent
...
...
@@ -633,10 +633,10 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> The argument index is a decimal integer indicating the position of the
* argument in the argument list. The first argument is referenced by
* "
<tt>1$</tt>", the second by "<tt>2$</tt>
", etc.
* "
{@code 1$}", the second by "{@code 2$}
", etc.
*
* <p> Another way to reference arguments by position is to use the
*
<tt>'<'</tt>
(<tt>'\u003c'</tt>) flag, which causes the argument for
*
{@code '<'}
(<tt>'\u003c'</tt>) flag, which causes the argument for
* the previous format specifier to be re-used. For example, the following two
* statements would produce identical strings:
*
...
...
@@ -670,14 +670,14 @@ import sun.misc.FormattedFloatingDecimal;
* applicable to the corresponding argument, then an {@link
* IllegalFormatConversionException} will be thrown.
*
* <p> All specified exceptions may be thrown by any of the
<tt>format</tt>
* methods of
<tt>Formatter</tt> as well as by any <tt>format</tt>
convenience
* <p> All specified exceptions may be thrown by any of the
{@code format}
* methods of
{@code Formatter} as well as by any {@code format}
convenience
* methods such as {@link String#format(String,Object...) String.format} and
* {@link java.io.PrintStream#printf(String,Object...) PrintStream.printf}.
*
* <p> Conversions denoted by an upper-case character (i.e.
<tt>'B'</tt>
,
*
<tt>'H'</tt>, <tt>'S'</tt>, <tt>'C'</tt>, <tt>'X'</tt>, <tt>'E'</tt>
,
*
<tt>'G'</tt>, <tt>'A'</tt>, and <tt>'T'</tt>
) are the same as those for the
* <p> Conversions denoted by an upper-case character (i.e.
{@code 'B'}
,
*
{@code 'H'}, {@code 'S'}, {@code 'C'}, {@code 'X'}, {@code 'E'}
,
*
{@code 'G'}, {@code 'A'}, and {@code 'T'}
) are the same as those for the
* corresponding lower-case conversion characters except that the result is
* converted to upper case according to the rules of the prevailing {@link
* java.util.Locale Locale}. The result is equivalent to the following
...
...
@@ -692,56 +692,56 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="dgConv">
*
* <tr><td valign="top">
<tt>'b'</tt>
* <tr><td valign="top">
{@code 'b'}
* <td valign="top"> <tt>'\u0062'</tt>
* <td> Produces either "
<tt>true</tt>" or "<tt>false</tt>
" as returned by
* <td> Produces either "
{@code true}" or "{@code false}
" as returned by
* {@link Boolean#toString(boolean)}.
*
* <p> If the argument is
<tt>null</tt>
, then the result is
* "
<tt>false</tt>". If the argument is a <tt>boolean</tt>
or {@link
* <p> If the argument is
{@code null}
, then the result is
* "
{@code false}". If the argument is a {@code boolean}
or {@link
* Boolean}, then the result is the string returned by {@link
* String#valueOf(boolean) String.valueOf()}. Otherwise, the result is
* "
<tt>true</tt>
".
* "
{@code true}
".
*
* <p> If the
<tt>'#'</tt>
flag is given, then a {@link
* <p> If the
{@code '#'}
flag is given, then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'B'</tt>
* <tr><td valign="top">
{@code 'B'}
* <td valign="top"> <tt>'\u0042'</tt>
* <td> The upper-case variant of
<tt>'b'</tt>
.
* <td> The upper-case variant of
{@code 'b'}
.
*
* <tr><td valign="top">
<tt>'h'</tt>
* <tr><td valign="top">
{@code 'h'}
* <td valign="top"> <tt>'\u0068'</tt>
* <td> Produces a string representing the hash code value of the object.
*
* <p> If the argument, <i>arg</i> is
<tt>null</tt>
, then the
* result is "
<tt>null</tt>
". Otherwise, the result is obtained
* by invoking
<tt>Integer.toHexString(arg.hashCode())</tt>
.
* <p> If the argument, <i>arg</i> is
{@code null}
, then the
* result is "
{@code null}
". Otherwise, the result is obtained
* by invoking
{@code Integer.toHexString(arg.hashCode())}
.
*
* <p> If the
<tt>'#'</tt>
flag is given, then a {@link
* <p> If the
{@code '#'}
flag is given, then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'H'</tt>
* <tr><td valign="top">
{@code 'H'}
* <td valign="top"> <tt>'\u0048'</tt>
* <td> The upper-case variant of
<tt>'h'</tt>
.
* <td> The upper-case variant of
{@code 'h'}
.
*
* <tr><td valign="top">
<tt>'s'</tt>
* <tr><td valign="top">
{@code 's'}
* <td valign="top"> <tt>'\u0073'</tt>
* <td> Produces a string.
*
* <p> If the argument is
<tt>null</tt>
, then the result is
* "
<tt>null</tt>
". If the argument implements {@link Formattable}, then
* <p> If the argument is
{@code null}
, then the result is
* "
{@code null}
". If the argument implements {@link Formattable}, then
* its {@link Formattable#formatTo formatTo} method is invoked.
* Otherwise, the result is obtained by invoking the argument's
*
<tt>toString()</tt>
method.
*
{@code toString()}
method.
*
* <p> If the
<tt>'#'</tt>
flag is given and the argument is not a {@link
* <p> If the
{@code '#'}
flag is given and the argument is not a {@link
* Formattable} , then a {@link FormatFlagsConversionMismatchException}
* will be thrown.
*
* <tr><td valign="top">
<tt>'S'</tt>
* <tr><td valign="top">
{@code 'S'}
* <td valign="top"> <tt>'\u0053'</tt>
* <td> The upper-case variant of
<tt>'s'</tt>
.
* <td> The upper-case variant of
{@code 's'}
.
*
* </table>
*
...
...
@@ -749,7 +749,7 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="dFlags">
*
* <tr><td valign="top">
<tt>'-'</tt>
* <tr><td valign="top">
{@code '-'}
* <td valign="top"> <tt>'\u002d'</tt>
* <td> Left justifies the output. Spaces (<tt>'\u0020'</tt>) will be
* added at the end of the converted value as required to fill the minimum
...
...
@@ -757,7 +757,7 @@ import sun.misc.FormattedFloatingDecimal;
* MissingFormatWidthException} will be thrown. If this flag is not given
* then the output will be right-justified.
*
* <tr><td valign="top">
<tt>'#'</tt>
* <tr><td valign="top">
{@code '#'}
* <td valign="top"> <tt>'\u0023'</tt>
* <td> Requires the output use an alternate form. The definition of the
* form is specified by the conversion.
...
...
@@ -767,47 +767,47 @@ import sun.misc.FormattedFloatingDecimal;
* <p> The <a name="genWidth">width</a> is the minimum number of characters to
* be written to the
* output. If the length of the converted value is less than the width then
* the output will be padded by <tt>' '</tt> (<tt>\u0020'</tt>)
* the output will be padded by <tt>' '</tt> (<tt>
'
\u0020'</tt>)
* until the total number of characters equals the width. The padding is on
* the left by default. If the
<tt>'-'</tt>
flag is given, then the padding
* the left by default. If the
{@code '-'}
flag is given, then the padding
* will be on the right. If the width is not specified then there is no
* minimum.
*
* <p> The precision is the maximum number of characters to be written to the
* output. The precision is applied before the width, thus the output will be
* truncated to
<tt>precision</tt>
characters even if the width is greater than
* truncated to
{@code precision}
characters even if the width is greater than
* the precision. If the precision is not specified then there is no explicit
* limit on the number of characters.
*
* <h4><a name="dchar">Character</a></h4>
*
* This conversion may be applied to
<tt>char</tt>
and {@link Character}. It
* may also be applied to the types
<tt>byte</tt>
, {@link Byte},
*
<tt>short</tt>, and {@link Short}, <tt>int</tt>
and {@link Integer} when
* {@link Character#isValidCodePoint} returns
<tt>true</tt>
. If it returns
*
<tt>false</tt>
then an {@link IllegalFormatCodePointException} will be
* This conversion may be applied to
{@code char}
and {@link Character}. It
* may also be applied to the types
{@code byte}
, {@link Byte},
*
{@code short}, and {@link Short}, {@code int}
and {@link Integer} when
* {@link Character#isValidCodePoint} returns
{@code true}
. If it returns
*
{@code false}
then an {@link IllegalFormatCodePointException} will be
* thrown.
*
* <table cellpadding=5 summary="charConv">
*
* <tr><td valign="top">
<tt>'c'</tt>
* <tr><td valign="top">
{@code 'c'}
* <td valign="top"> <tt>'\u0063'</tt>
* <td> Formats the argument as a Unicode character as described in <a
* href="../lang/Character.html#unicode">Unicode Character
* Representation</a>. This may be more than one 16-bit
<tt>char</tt>
in
* Representation</a>. This may be more than one 16-bit
{@code char}
in
* the case where the argument represents a supplementary character.
*
* <p> If the
<tt>'#'</tt>
flag is given, then a {@link
* <p> If the
{@code '#'}
flag is given, then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'C'</tt>
* <tr><td valign="top">
{@code 'C'}
* <td valign="top"> <tt>'\u0043'</tt>
* <td> The upper-case variant of
<tt>'c'</tt>
.
* <td> The upper-case variant of
{@code 'c'}
.
*
* </table>
*
* <p> The
<tt>'-'</tt>
flag defined for <a href="#dFlags">General
* conversions</a> applies. If the
<tt>'#'</tt>
flag is given, then a {@link
* <p> The
{@code '-'}
flag defined for <a href="#dFlags">General
* conversions</a> applies. If the
{@code '#'}
flag is given, then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <p> The width is defined as for <a href="#genWidth">General conversions</a>.
...
...
@@ -844,14 +844,14 @@ import sun.misc.FormattedFloatingDecimal;
* <li> Each digit character <i>d</i> in the string is replaced by a
* locale-specific digit computed relative to the current locale's
* {@linkplain java.text.DecimalFormatSymbols#getZeroDigit() zero digit}
* <i>z</i>; that is <i>d - </i>
<tt>'0'</tt>
* <i>z</i>; that is <i>d - </i>
{@code '0'}
* <i> + z</i>.
*
* <li> If a decimal separator is present, a locale-specific {@linkplain
* java.text.DecimalFormatSymbols#getDecimalSeparator decimal separator} is
* substituted.
*
* <li> If the
<tt>','</tt>
(<tt>'\u002c'</tt>)
* <li> If the
{@code ','}
(<tt>'\u002c'</tt>)
* <a name="l10n group">flag</a> is given, then the locale-specific {@linkplain
* java.text.DecimalFormatSymbols#getGroupingSeparator grouping separator} is
* inserted by scanning the integer part of the string from least significant
...
...
@@ -859,111 +859,111 @@ import sun.misc.FormattedFloatingDecimal;
* the locale's {@linkplain java.text.DecimalFormat#getGroupingSize() grouping
* size}.
*
* <li> If the
<tt>'0'</tt>
flag is given, then the locale-specific {@linkplain
* <li> If the
{@code '0'}
flag is given, then the locale-specific {@linkplain
* java.text.DecimalFormatSymbols#getZeroDigit() zero digits} are inserted
* after the sign character, if any, and before the first non-zero digit, until
* the length of the string is equal to the requested field width.
*
* <li> If the value is negative and the
<tt>'('</tt>
flag is given, then a
*
<tt>'('</tt> (<tt>'\u0028'</tt>) is prepended and a <tt>')'</tt>
* <li> If the value is negative and the
{@code '('}
flag is given, then a
*
{@code '('} (<tt>'\u0028'</tt>) is prepended and a {@code ')'}
* (<tt>'\u0029'</tt>) is appended.
*
* <li> If the value is negative (or floating-point negative zero) and
*
<tt>'('</tt> flag is not given, then a <tt>'-'</tt>
(<tt>'\u002d'</tt>)
*
{@code '('} flag is not given, then a {@code '-'}
(<tt>'\u002d'</tt>)
* is prepended.
*
* <li> If the
<tt>'+'</tt>
flag is given and the value is positive or zero (or
* floating-point positive zero), then a
<tt>'+'</tt>
(<tt>'\u002b'</tt>)
* <li> If the
{@code '+'}
flag is given and the value is positive or zero (or
* floating-point positive zero), then a
{@code '+'}
(<tt>'\u002b'</tt>)
* will be prepended.
*
* </ol>
*
* <p> If the value is NaN or positive infinity the literal strings "NaN" or
* "Infinity" respectively, will be output. If the value is negative infinity,
* then the output will be "(Infinity)" if the
<tt>'('</tt>
flag is given
* then the output will be "(Infinity)" if the
{@code '('}
flag is given
* otherwise the output will be "-Infinity". These values are not localized.
*
* <p><a name="dnint"><b> Byte, Short, Integer, and Long </b></a>
*
* <p> The following conversions may be applied to
<tt>byte</tt>
, {@link Byte},
*
<tt>short</tt>, {@link Short}, <tt>int</tt>
and {@link Integer},
*
<tt>long</tt>
, and {@link Long}.
* <p> The following conversions may be applied to
{@code byte}
, {@link Byte},
*
{@code short}, {@link Short}, {@code int}
and {@link Integer},
*
{@code long}
, and {@link Long}.
*
* <table cellpadding=5 summary="IntConv">
*
* <tr><td valign="top">
<tt>'d'</tt>
* <tr><td valign="top">
{@code 'd'}
* <td valign="top"> <tt>'\u0054'</tt>
* <td> Formats the argument as a decimal integer. The <a
* href="#l10n algorithm">localization algorithm</a> is applied.
*
* <p> If the
<tt>'0'</tt>
flag is given and the value is negative, then
* <p> If the
{@code '0'}
flag is given and the value is negative, then
* the zero padding will occur after the sign.
*
* <p> If the
<tt>'#'</tt>
flag is given then a {@link
* <p> If the
{@code '#'}
flag is given then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'o'</tt>
* <tr><td valign="top">
{@code 'o'}
* <td valign="top"> <tt>'\u006f'</tt>
* <td> Formats the argument as an integer in base eight. No localization
* is applied.
*
* <p> If <i>x</i> is negative then the result will be an unsigned value
* generated by adding 2<sup>n</sup> to the value where
<tt>n</tt>
is the
* number of bits in the type as returned by the static
<tt>SIZE</tt>
field
* generated by adding 2<sup>n</sup> to the value where
{@code n}
is the
* number of bits in the type as returned by the static
{@code SIZE}
field
* in the {@linkplain Byte#SIZE Byte}, {@linkplain Short#SIZE Short},
* {@linkplain Integer#SIZE Integer}, or {@linkplain Long#SIZE Long}
* classes as appropriate.
*
* <p> If the
<tt>'#'</tt>
flag is given then the output will always begin
* with the radix indicator
<tt>'0'</tt>
.
* <p> If the
{@code '#'}
flag is given then the output will always begin
* with the radix indicator
{@code '0'}
.
*
* <p> If the
<tt>'0'</tt>
flag is given then the output will be padded
* <p> If the
{@code '0'}
flag is given then the output will be padded
* with leading zeros to the field width following any indication of sign.
*
* <p> If
<tt>'('</tt>, <tt>'+'</tt>, '  ', or <tt>','</tt>
flags
* <p> If
{@code '('}, {@code '+'}, '  ', or {@code ','}
flags
* are given then a {@link FormatFlagsConversionMismatchException} will be
* thrown.
*
* <tr><td valign="top">
<tt>'x'</tt>
* <tr><td valign="top">
{@code 'x'}
* <td valign="top"> <tt>'\u0078'</tt>
* <td> Formats the argument as an integer in base sixteen. No
* localization is applied.
*
* <p> If <i>x</i> is negative then the result will be an unsigned value
* generated by adding 2<sup>n</sup> to the value where
<tt>n</tt>
is the
* number of bits in the type as returned by the static
<tt>SIZE</tt>
field
* generated by adding 2<sup>n</sup> to the value where
{@code n}
is the
* number of bits in the type as returned by the static
{@code SIZE}
field
* in the {@linkplain Byte#SIZE Byte}, {@linkplain Short#SIZE Short},
* {@linkplain Integer#SIZE Integer}, or {@linkplain Long#SIZE Long}
* classes as appropriate.
*
* <p> If the
<tt>'#'</tt>
flag is given then the output will always begin
* with the radix indicator
<tt>"0x"</tt>
.
* <p> If the
{@code '#'}
flag is given then the output will always begin
* with the radix indicator
{@code "0x"}
.
*
* <p> If the
<tt>'0'</tt>
flag is given then the output will be padded to
* <p> If the
{@code '0'}
flag is given then the output will be padded to
* the field width with leading zeros after the radix indicator or sign (if
* present).
*
* <p> If
<tt>'('</tt>, <tt>' '</tt>, <tt>'+'</tt>
, or
*
<tt>','</tt>
flags are given then a {@link
* <p> If
{@code '('}, <tt>' '</tt>, {@code '+'}
, or
*
{@code ','}
flags are given then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'X'</tt>
* <tr><td valign="top">
{@code 'X'}
* <td valign="top"> <tt>'\u0058'</tt>
* <td> The upper-case variant of
<tt>'x'</tt>
. The entire string
* <td> The upper-case variant of
{@code 'x'}
. The entire string
* representing the number will be converted to {@linkplain
* String#toUpperCase upper case} including the
<tt>'x'</tt>
(if any) and
* all hexadecimal digits
<tt>'a'</tt> - <tt>'f'</tt>
* String#toUpperCase upper case} including the
{@code 'x'}
(if any) and
* all hexadecimal digits
{@code 'a'} - {@code 'f'}
* (<tt>'\u0061'</tt> - <tt>'\u0066'</tt>).
*
* </table>
*
* <p> If the conversion is
<tt>'o'</tt>, <tt>'x'</tt>, or <tt>'X'</tt>
and
* both the
<tt>'#'</tt> and the <tt>'0'</tt>
flags are given, then result will
* contain the radix indicator (
<tt>'0'</tt> for octal and <tt>"0x"</tt>
or
*
<tt>"0X"</tt>
for hexadecimal), some number of zeros (based on the width),
* <p> If the conversion is
{@code 'o'}, {@code 'x'}, or {@code 'X'}
and
* both the
{@code '#'} and the {@code '0'}
flags are given, then result will
* contain the radix indicator (
{@code '0'} for octal and {@code "0x"}
or
*
{@code "0X"}
for hexadecimal), some number of zeros (based on the width),
* and the value.
*
* <p> If the
<tt>'-'</tt>
flag is not given, then the space padding will occur
* <p> If the
{@code '-'}
flag is not given, then the space padding will occur
* before the sign.
*
* <p> The following <a name="intFlags">flags</a> apply to numeric integral
...
...
@@ -971,13 +971,13 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="intFlags">
*
* <tr><td valign="top">
<tt>'+'</tt>
* <tr><td valign="top">
{@code '+'}
* <td valign="top"> <tt>'\u002b'</tt>
* <td> Requires the output to include a positive sign for all positive
* numbers. If this flag is not given then only negative values will
* include a sign.
*
* <p> If both the
<tt>'+'</tt>
and <tt>' '</tt> flags are given
* <p> If both the
{@code '+'}
and <tt>' '</tt> flags are given
* then an {@link IllegalFormatFlagsException} will be thrown.
*
* <tr><td valign="top"> <tt>' '</tt>
...
...
@@ -985,10 +985,10 @@ import sun.misc.FormattedFloatingDecimal;
* <td> Requires the output to include a single extra space
* (<tt>'\u0020'</tt>) for non-negative values.
*
* <p> If both the
<tt>'+'</tt>
and <tt>' '</tt> flags are given
* <p> If both the
{@code '+'}
and <tt>' '</tt> flags are given
* then an {@link IllegalFormatFlagsException} will be thrown.
*
* <tr><td valign="top">
<tt>'0'</tt>
* <tr><td valign="top">
{@code '0'}
* <td valign="top"> <tt>'\u0030'</tt>
* <td> Requires the output to be padded with leading {@linkplain
* java.text.DecimalFormatSymbols#getZeroDigit zeros} to the minimum field
...
...
@@ -996,20 +996,20 @@ import sun.misc.FormattedFloatingDecimal;
* or infinity. If the width is not provided, then a {@link
* MissingFormatWidthException} will be thrown.
*
* <p> If both the
<tt>'-'</tt> and <tt>'0'</tt>
flags are given then an
* <p> If both the
{@code '-'} and {@code '0'}
flags are given then an
* {@link IllegalFormatFlagsException} will be thrown.
*
* <tr><td valign="top">
<tt>','</tt>
* <tr><td valign="top">
{@code ','}
* <td valign="top"> <tt>'\u002c'</tt>
* <td> Requires the output to include the locale-specific {@linkplain
* java.text.DecimalFormatSymbols#getGroupingSeparator group separators} as
* described in the <a href="#l10n group">"group" section</a> of the
* localization algorithm.
*
* <tr><td valign="top">
<tt>'('</tt>
* <tr><td valign="top">
{@code '('}
* <td valign="top"> <tt>'\u0028'</tt>
* <td> Requires the output to prepend a
<tt>'('</tt>
* (<tt>'\u0028'</tt>) and append a
<tt>')'</tt>
* <td> Requires the output to prepend a
{@code '('}
* (<tt>'\u0028'</tt>) and append a
{@code ')'}
* (<tt>'\u0029'</tt>) to negative values.
*
* </table>
...
...
@@ -1019,9 +1019,9 @@ import sun.misc.FormattedFloatingDecimal;
*
* <ul>
*
* <li> The output is right-justified within the
<tt>width</tt>
* <li> The output is right-justified within the
{@code width}
*
* <li> Negative numbers begin with a
<tt>'-'</tt>
(<tt>'\u002d'</tt>)
* <li> Negative numbers begin with a
{@code '-'}
(<tt>'\u002d'</tt>)
*
* <li> Positive numbers and zero do not include a sign or extra leading
* space
...
...
@@ -1035,7 +1035,7 @@ import sun.misc.FormattedFloatingDecimal;
* separators, radix indicator, and parentheses. If the length of the
* converted value is less than the width then the output will be padded by
* spaces (<tt>'\u0020'</tt>) until the total number of characters equals
* width. The padding is on the left by default. If
<tt>'-'</tt>
flag is
* width. The padding is on the left by default. If
{@code '-'}
flag is
* given then the padding will be on the right. If width is not specified then
* there is no minimum.
*
...
...
@@ -1049,81 +1049,81 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="BIntConv">
*
* <tr><td valign="top">
<tt>'d'</tt>
* <tr><td valign="top">
{@code 'd'}
* <td valign="top"> <tt>'\u0054'</tt>
* <td> Requires the output to be formatted as a decimal integer. The <a
* href="#l10n algorithm">localization algorithm</a> is applied.
*
* <p> If the
<tt>'#'</tt>
flag is given {@link
* <p> If the
{@code '#'}
flag is given {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'o'</tt>
* <tr><td valign="top">
{@code 'o'}
* <td valign="top"> <tt>'\u006f'</tt>
* <td> Requires the output to be formatted as an integer in base eight.
* No localization is applied.
*
* <p> If <i>x</i> is negative then the result will be a signed value
* beginning with
<tt>'-'</tt>
(<tt>'\u002d'</tt>). Signed output is
* beginning with
{@code '-'}
(<tt>'\u002d'</tt>). Signed output is
* allowed for this type because unlike the primitive types it is not
* possible to create an unsigned equivalent without assuming an explicit
* data-type size.
*
* <p> If <i>x</i> is positive or zero and the
<tt>'+'</tt>
flag is given
* then the result will begin with
<tt>'+'</tt>
(<tt>'\u002b'</tt>).
* <p> If <i>x</i> is positive or zero and the
{@code '+'}
flag is given
* then the result will begin with
{@code '+'}
(<tt>'\u002b'</tt>).
*
* <p> If the
<tt>'#'</tt>
flag is given then the output will always begin
* with
<tt>'0'</tt>
prefix.
* <p> If the
{@code '#'}
flag is given then the output will always begin
* with
{@code '0'}
prefix.
*
* <p> If the
<tt>'0'</tt>
flag is given then the output will be padded
* <p> If the
{@code '0'}
flag is given then the output will be padded
* with leading zeros to the field width following any indication of sign.
*
* <p> If the
<tt>','</tt>
flag is given then a {@link
* <p> If the
{@code ','}
flag is given then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'x'</tt>
* <tr><td valign="top">
{@code 'x'}
* <td valign="top"> <tt>'\u0078'</tt>
* <td> Requires the output to be formatted as an integer in base
* sixteen. No localization is applied.
*
* <p> If <i>x</i> is negative then the result will be a signed value
* beginning with
<tt>'-'</tt>
(<tt>'\u002d'</tt>). Signed output is
* beginning with
{@code '-'}
(<tt>'\u002d'</tt>). Signed output is
* allowed for this type because unlike the primitive types it is not
* possible to create an unsigned equivalent without assuming an explicit
* data-type size.
*
* <p> If <i>x</i> is positive or zero and the
<tt>'+'</tt>
flag is given
* then the result will begin with
<tt>'+'</tt>
(<tt>'\u002b'</tt>).
* <p> If <i>x</i> is positive or zero and the
{@code '+'}
flag is given
* then the result will begin with
{@code '+'}
(<tt>'\u002b'</tt>).
*
* <p> If the
<tt>'#'</tt>
flag is given then the output will always begin
* with the radix indicator
<tt>"0x"</tt>
.
* <p> If the
{@code '#'}
flag is given then the output will always begin
* with the radix indicator
{@code "0x"}
.
*
* <p> If the
<tt>'0'</tt>
flag is given then the output will be padded to
* <p> If the
{@code '0'}
flag is given then the output will be padded to
* the field width with leading zeros after the radix indicator or sign (if
* present).
*
* <p> If the
<tt>','</tt>
flag is given then a {@link
* <p> If the
{@code ','}
flag is given then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'X'</tt>
* <tr><td valign="top">
{@code 'X'}
* <td valign="top"> <tt>'\u0058'</tt>
* <td> The upper-case variant of
<tt>'x'</tt>
. The entire string
* <td> The upper-case variant of
{@code 'x'}
. The entire string
* representing the number will be converted to {@linkplain
* String#toUpperCase upper case} including the
<tt>'x'</tt>
(if any) and
* all hexadecimal digits
<tt>'a'</tt> - <tt>'f'</tt>
* String#toUpperCase upper case} including the
{@code 'x'}
(if any) and
* all hexadecimal digits
{@code 'a'} - {@code 'f'}
* (<tt>'\u0061'</tt> - <tt>'\u0066'</tt>).
*
* </table>
*
* <p> If the conversion is
<tt>'o'</tt>, <tt>'x'</tt>, or <tt>'X'</tt>
and
* both the
<tt>'#'</tt> and the <tt>'0'</tt>
flags are given, then result will
* contain the base indicator (
<tt>'0'</tt> for octal and <tt>"0x"</tt>
or
*
<tt>"0X"</tt>
for hexadecimal), some number of zeros (based on the width),
* <p> If the conversion is
{@code 'o'}, {@code 'x'}, or {@code 'X'}
and
* both the
{@code '#'} and the {@code '0'}
flags are given, then result will
* contain the base indicator (
{@code '0'} for octal and {@code "0x"}
or
*
{@code "0X"}
for hexadecimal), some number of zeros (based on the width),
* and the value.
*
* <p> If the
<tt>'0'</tt>
flag is given and the value is negative, then the
* <p> If the
{@code '0'}
flag is given and the value is negative, then the
* zero padding will occur after the sign.
*
* <p> If the
<tt>'-'</tt>
flag is not given, then the space padding will occur
* <p> If the
{@code '-'}
flag is not given, then the space padding will occur
* before the sign.
*
* <p> All <a href="#intFlags">flags</a> defined for Byte, Short, Integer, and
...
...
@@ -1138,12 +1138,12 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p><a name="dndec"><b> Float and Double</b></a>
*
* <p> The following conversions may be applied to
<tt>float</tt>
, {@link
* Float},
<tt>double</tt>
and {@link Double}.
* <p> The following conversions may be applied to
{@code float}
, {@link
* Float},
{@code double}
and {@link Double}.
*
* <table cellpadding=5 summary="floatConv">
*
* <tr><td valign="top">
<tt>'e'</tt>
* <tr><td valign="top">
{@code 'e'}
* <td valign="top"> <tt>'\u0065'</tt>
* <td> Requires the output to be formatted using <a
* name="scientific">computerized scientific notation</a>. The <a
...
...
@@ -1156,7 +1156,7 @@ import sun.misc.FormattedFloatingDecimal;
* localized.
*
* <p> If <i>m</i> is positive-zero or negative-zero, then the exponent
* will be
<tt>"+00"</tt>
.
* will be
{@code "+00"}
.
*
* <p> Otherwise, the result is a string that represents the sign and
* magnitude (absolute value) of the argument. The formatting of the sign
...
...
@@ -1170,7 +1170,7 @@ import sun.misc.FormattedFloatingDecimal;
* that 1 <= <i>a</i> < 10. The magnitude is then represented as the
* integer part of <i>a</i>, as a single decimal digit, followed by the
* decimal separator followed by decimal digits representing the fractional
* part of <i>a</i>, followed by the exponent symbol
<tt>'e'</tt>
* part of <i>a</i>, followed by the exponent symbol
{@code 'e'}
* (<tt>'\u0065'</tt>), followed by the sign of the exponent, followed
* by a representation of <i>n</i> as a decimal integer, as produced by the
* method {@link Long#toString(long, int)}, and zero-padded to include at
...
...
@@ -1178,7 +1178,7 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> The number of digits in the result for the fractional part of
* <i>m</i> or <i>a</i> is equal to the precision. If the precision is not
* specified then the default value is
<tt>6</tt>
. If the precision is less
* specified then the default value is
{@code 6}
. If the precision is less
* than the number of digits which would appear after the decimal point in
* the string returned by {@link Float#toString(float)} or {@link
* Double#toString(double)} respectively, then the value will be rounded
...
...
@@ -1188,15 +1188,15 @@ import sun.misc.FormattedFloatingDecimal;
* Float#toString(float)} or {@link Double#toString(double)} as
* appropriate.
*
* <p>If the
<tt>','</tt>
flag is given, then an {@link
* <p>If the
{@code ','}
flag is given, then an {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'E'</tt>
* <tr><td valign="top">
{@code 'E'}
* <td valign="top"> <tt>'\u0045'</tt>
* <td> The upper-case variant of
<tt>'e'</tt>
. The exponent symbol
* will be
<tt>'E'</tt>
(<tt>'\u0045'</tt>).
* <td> The upper-case variant of
{@code 'e'}
. The exponent symbol
* will be
{@code 'E'}
(<tt>'\u0045'</tt>).
*
* <tr><td valign="top">
<tt>'g'</tt>
* <tr><td valign="top">
{@code 'g'}
* <td valign="top"> <tt>'\u0067'</tt>
* <td> Requires the output to be formatted in general scientific notation
* as described below. The <a href="#l10n algorithm">localization
...
...
@@ -1215,17 +1215,17 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> The total number of significant digits in <i>m</i> is equal to the
* precision. If the precision is not specified, then the default value is
*
<tt>6</tt>. If the precision is <tt>0</tt>
, then it is taken to be
*
<tt>1</tt>
.
*
{@code 6}. If the precision is {@code 0}
, then it is taken to be
*
{@code 1}
.
*
* <p> If the
<tt>'#'</tt>
flag is given then an {@link
* <p> If the
{@code '#'}
flag is given then an {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'G'</tt>
* <tr><td valign="top">
{@code 'G'}
* <td valign="top"> <tt>'\u0047'</tt>
* <td> The upper-case variant of
<tt>'g'</tt>
.
* <td> The upper-case variant of
{@code 'g'}
.
*
* <tr><td valign="top">
<tt>'f'</tt>
* <tr><td valign="top">
{@code 'f'}
* <td valign="top"> <tt>'\u0066'</tt>
* <td> Requires the output to be formatted using <a name="decimal">decimal
* format</a>. The <a href="#l10n algorithm">localization algorithm</a> is
...
...
@@ -1247,7 +1247,7 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> The number of digits in the result for the fractional part of
* <i>m</i> or <i>a</i> is equal to the precision. If the precision is not
* specified then the default value is
<tt>6</tt>
. If the precision is less
* specified then the default value is
{@code 6}
. If the precision is less
* than the number of digits which would appear after the decimal point in
* the string returned by {@link Float#toString(float)} or {@link
* Double#toString(double)} respectively, then the value will be rounded
...
...
@@ -1257,7 +1257,7 @@ import sun.misc.FormattedFloatingDecimal;
* Float#toString(float)} or {@link Double#toString(double)} as
* appropriate.
*
* <tr><td valign="top">
<tt>'a'</tt>
* <tr><td valign="top">
{@code 'a'}
* <td valign="top"> <tt>'\u0061'</tt>
* <td> Requires the output to be formatted in hexadecimal exponential
* form. No localization is applied.
...
...
@@ -1266,10 +1266,10 @@ import sun.misc.FormattedFloatingDecimal;
* (absolute value) of the argument <i>x</i>.
*
* <p> If <i>x</i> is negative or a negative-zero value then the result
* will begin with
<tt>'-'</tt>
(<tt>'\u002d'</tt>).
* will begin with
{@code '-'}
(<tt>'\u002d'</tt>).
*
* <p> If <i>x</i> is positive or a positive-zero value and the
*
<tt>'+'</tt> flag is given then the result will begin with <tt>'+'</tt>
*
{@code '+'} flag is given then the result will begin with {@code '+'}
* (<tt>'\u002b'</tt>).
*
* <p> The formatting of the magnitude <i>m</i> depends upon its value.
...
...
@@ -1280,43 +1280,43 @@ import sun.misc.FormattedFloatingDecimal;
* "Infinity", respectively, will be output.
*
* <li> If <i>m</i> is zero then it is represented by the string
*
<tt>"0x0.0p0"</tt>
.
*
{@code "0x0.0p0"}
.
*
* <li> If <i>m</i> is a
<tt>double</tt>
value with a normalized
* <li> If <i>m</i> is a
{@code double}
value with a normalized
* representation then substrings are used to represent the significand and
* exponent fields. The significand is represented by the characters
*
<tt>"0x1."</tt>
followed by the hexadecimal representation of the rest
*
{@code "0x1."}
followed by the hexadecimal representation of the rest
* of the significand as a fraction. The exponent is represented by
*
<tt>'p'</tt>
(<tt>'\u0070'</tt>) followed by a decimal string of the
*
{@code 'p'}
(<tt>'\u0070'</tt>) followed by a decimal string of the
* unbiased exponent as if produced by invoking {@link
* Integer#toString(int) Integer.toString} on the exponent value.
*
* <li> If <i>m</i> is a
<tt>double</tt>
value with a subnormal
* <li> If <i>m</i> is a
{@code double}
value with a subnormal
* representation then the significand is represented by the characters
*
<tt>'0x0.'</tt>
followed by the hexadecimal representation of the rest
*
{@code '0x0.'}
followed by the hexadecimal representation of the rest
* of the significand as a fraction. The exponent is represented by
*
<tt>'p-1022'</tt>
. Note that there must be at least one nonzero digit
*
{@code 'p-1022'}
. Note that there must be at least one nonzero digit
* in a subnormal significand.
*
* </ul>
*
* <p> If the
<tt>'('</tt> or <tt>','</tt>
flags are given, then a {@link
* <p> If the
{@code '('} or {@code ','}
flags are given, then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'A'</tt>
* <tr><td valign="top">
{@code 'A'}
* <td valign="top"> <tt>'\u0041'</tt>
* <td> The upper-case variant of
<tt>'a'</tt>
. The entire string
* <td> The upper-case variant of
{@code 'a'}
. The entire string
* representing the number will be converted to upper case including the
*
<tt>'x'</tt> (<tt>'\u0078'</tt>) and <tt>'p'</tt>
* (<tt>'\u0070'</tt> and all hexadecimal digits
<tt>'a'</tt>
-
*
<tt>'f'</tt>
(<tt>'\u0061'</tt> - <tt>'\u0066'</tt>).
*
{@code 'x'} (<tt>'\u0078'</tt>) and {@code 'p'}
* (<tt>'\u0070'</tt> and all hexadecimal digits
{@code 'a'}
-
*
{@code 'f'}
(<tt>'\u0061'</tt> - <tt>'\u0066'</tt>).
*
* </table>
*
* <p> All <a href="#intFlags">flags</a> defined for Byte, Short, Integer, and
* Long apply.
*
* <p> If the
<tt>'#'</tt>
flag is given, then the decimal separator will
* <p> If the
{@code '#'}
flag is given, then the decimal separator will
* always be present.
*
* <p> If no <a name="floatdFlags">flags</a> are given the default formatting
...
...
@@ -1324,9 +1324,9 @@ import sun.misc.FormattedFloatingDecimal;
*
* <ul>
*
* <li> The output is right-justified within the
<tt>width</tt>
* <li> The output is right-justified within the
{@code width}
*
* <li> Negative numbers begin with a
<tt>'-'</tt>
* <li> Negative numbers begin with a
{@code '-'}
*
* <li> Positive numbers and positive zero do not include a sign or extra
* leading space
...
...
@@ -1344,21 +1344,21 @@ import sun.misc.FormattedFloatingDecimal;
* the length of the converted value is less than the width then the output
* will be padded by spaces (<tt>'\u0020'</tt>) until the total number of
* characters equals width. The padding is on the left by default. If the
*
<tt>'-'</tt>
flag is given then the padding will be on the right. If width
*
{@code '-'}
flag is given then the padding will be on the right. If width
* is not specified then there is no minimum.
*
* <p> If the <a name="floatDPrec">conversion</a> is
<tt>'e'</tt>
,
*
<tt>'E'</tt> or <tt>'f'</tt>
, then the precision is the number of digits
* <p> If the <a name="floatDPrec">conversion</a> is
{@code 'e'}
,
*
{@code 'E'} or {@code 'f'}
, then the precision is the number of digits
* after the decimal separator. If the precision is not specified, then it is
* assumed to be
<tt>6</tt>
.
* assumed to be
{@code 6}
.
*
* <p> If the conversion is
<tt>'g'</tt> or <tt>'G'</tt>
, then the precision is
* <p> If the conversion is
{@code 'g'} or {@code 'G'}
, then the precision is
* the total number of significant digits in the resulting magnitude after
* rounding. If the precision is not specified, then the default value is
*
<tt>6</tt>. If the precision is <tt>0</tt>
, then it is taken to be
*
<tt>1</tt>
.
*
{@code 6}. If the precision is {@code 0}
, then it is taken to be
*
{@code 1}
.
*
* <p> If the conversion is
<tt>'a'</tt> or <tt>'A'</tt>
, then the precision
* <p> If the conversion is
{@code 'a'} or {@code 'A'}
, then the precision
* is the number of hexadecimal digits after the decimal separator. If the
* precision is not provided, then all of the digits as returned by {@link
* Double#toHexString(double)} will be output.
...
...
@@ -1370,7 +1370,7 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="floatConv">
*
* <tr><td valign="top">
<tt>'e'</tt>
* <tr><td valign="top">
{@code 'e'}
* <td valign="top"> <tt>'\u0065'</tt>
* <td> Requires the output to be formatted using <a
* name="scientific">computerized scientific notation</a>. The <a
...
...
@@ -1379,7 +1379,7 @@ import sun.misc.FormattedFloatingDecimal;
* <p> The formatting of the magnitude <i>m</i> depends upon its value.
*
* <p> If <i>m</i> is positive-zero or negative-zero, then the exponent
* will be
<tt>"+00"</tt>
.
* will be
{@code "+00"}
.
*
* <p> Otherwise, the result is a string that represents the sign and
* magnitude (absolute value) of the argument. The formatting of the sign
...
...
@@ -1393,7 +1393,7 @@ import sun.misc.FormattedFloatingDecimal;
* that 1 <= <i>a</i> < 10. The magnitude is then represented as the
* integer part of <i>a</i>, as a single decimal digit, followed by the
* decimal separator followed by decimal digits representing the fractional
* part of <i>a</i>, followed by the exponent symbol
<tt>'e'</tt>
* part of <i>a</i>, followed by the exponent symbol
{@code 'e'}
* (<tt>'\u0065'</tt>), followed by the sign of the exponent, followed
* by a representation of <i>n</i> as a decimal integer, as produced by the
* method {@link Long#toString(long, int)}, and zero-padded to include at
...
...
@@ -1401,7 +1401,7 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> The number of digits in the result for the fractional part of
* <i>m</i> or <i>a</i> is equal to the precision. If the precision is not
* specified then the default value is
<tt>6</tt>
. If the precision is
* specified then the default value is
{@code 6}
. If the precision is
* less than the number of digits which would appear after the decimal
* point in the string returned by {@link Float#toString(float)} or {@link
* Double#toString(double)} respectively, then the value will be rounded
...
...
@@ -1410,15 +1410,15 @@ import sun.misc.FormattedFloatingDecimal;
* For a canonical representation of the value, use {@link
* BigDecimal#toString()}.
*
* <p> If the
<tt>','</tt>
flag is given, then an {@link
* <p> If the
{@code ','}
flag is given, then an {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'E'</tt>
* <tr><td valign="top">
{@code 'E'}
* <td valign="top"> <tt>'\u0045'</tt>
* <td> The upper-case variant of
<tt>'e'</tt>
. The exponent symbol
* will be
<tt>'E'</tt>
(<tt>'\u0045'</tt>).
* <td> The upper-case variant of
{@code 'e'}
. The exponent symbol
* will be
{@code 'E'}
(<tt>'\u0045'</tt>).
*
* <tr><td valign="top">
<tt>'g'</tt>
* <tr><td valign="top">
{@code 'g'}
* <td valign="top"> <tt>'\u0067'</tt>
* <td> Requires the output to be formatted in general scientific notation
* as described below. The <a href="#l10n algorithm">localization
...
...
@@ -1437,17 +1437,17 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> The total number of significant digits in <i>m</i> is equal to the
* precision. If the precision is not specified, then the default value is
*
<tt>6</tt>. If the precision is <tt>0</tt>
, then it is taken to be
*
<tt>1</tt>
.
*
{@code 6}. If the precision is {@code 0}
, then it is taken to be
*
{@code 1}
.
*
* <p> If the
<tt>'#'</tt>
flag is given then an {@link
* <p> If the
{@code '#'}
flag is given then an {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <tr><td valign="top">
<tt>'G'</tt>
* <tr><td valign="top">
{@code 'G'}
* <td valign="top"> <tt>'\u0047'</tt>
* <td> The upper-case variant of
<tt>'g'</tt>
.
* <td> The upper-case variant of
{@code 'g'}
.
*
* <tr><td valign="top">
<tt>'f'</tt>
* <tr><td valign="top">
{@code 'f'}
* <td valign="top"> <tt>'\u0066'</tt>
* <td> Requires the output to be formatted using <a name="decimal">decimal
* format</a>. The <a href="#l10n algorithm">localization algorithm</a> is
...
...
@@ -1465,7 +1465,7 @@ import sun.misc.FormattedFloatingDecimal;
*
* <p> The number of digits in the result for the fractional part of
* <i>m</i> or <i>a</i> is equal to the precision. If the precision is not
* specified then the default value is
<tt>6</tt>
. If the precision is
* specified then the default value is
{@code 6}
. If the precision is
* less than the number of digits which would appear after the decimal
* point in the string returned by {@link Float#toString(float)} or {@link
* Double#toString(double)} respectively, then the value will be rounded
...
...
@@ -1479,7 +1479,7 @@ import sun.misc.FormattedFloatingDecimal;
* <p> All <a href="#intFlags">flags</a> defined for Byte, Short, Integer, and
* Long apply.
*
* <p> If the
<tt>'#'</tt>
flag is given, then the decimal separator will
* <p> If the
{@code '#'}
flag is given, then the decimal separator will
* always be present.
*
* <p> The <a href="#floatdFlags">default behavior</a> when no flags are
...
...
@@ -1491,114 +1491,114 @@ import sun.misc.FormattedFloatingDecimal;
*
* <h4><a name="ddt">Date/Time</a></h4>
*
* <p> This conversion may be applied to
<tt>long</tt>
, {@link Long}, {@link
* <p> This conversion may be applied to
{@code long}
, {@link Long}, {@link
* Calendar}, and {@link Date}.
*
* <table cellpadding=5 summary="DTConv">
*
* <tr><td valign="top">
<tt>'t'</tt>
* <tr><td valign="top">
{@code 't'}
* <td valign="top"> <tt>'\u0074'</tt>
* <td> Prefix for date and time conversion characters.
* <tr><td valign="top">
<tt>'T'</tt>
* <tr><td valign="top">
{@code 'T'}
* <td valign="top"> <tt>'\u0054'</tt>
* <td> The upper-case variant of
<tt>'t'</tt>
.
* <td> The upper-case variant of
{@code 't'}
.
*
* </table>
*
* <p> The following date and time conversion character suffixes are defined
* for the
<tt>'t'</tt> and <tt>'T'</tt>
conversions. The types are similar to
* but not completely identical to those defined by GNU
<tt>date</tt>
and
* POSIX
<tt>strftime(3c)</tt>
. Additional conversion types are provided to
* access Java-specific functionality (e.g.
<tt>'L'</tt>
for milliseconds
* for the
{@code 't'} and {@code 'T'}
conversions. The types are similar to
* but not completely identical to those defined by GNU
{@code date}
and
* POSIX
{@code strftime(3c)}
. Additional conversion types are provided to
* access Java-specific functionality (e.g.
{@code 'L'}
for milliseconds
* within the second).
*
* <p> The following conversion characters are used for formatting times:
*
* <table cellpadding=5 summary="time">
*
* <tr><td valign="top">
<tt>'H'</tt>
* <tr><td valign="top">
{@code 'H'}
* <td valign="top"> <tt>'\u0048'</tt>
* <td> Hour of the day for the 24-hour clock, formatted as two digits with
* a leading zero as necessary i.e.
<tt>00 - 23</tt>. <tt>00</tt>
* a leading zero as necessary i.e.
{@code 00 - 23}. {@code 00}
* corresponds to midnight.
*
* <tr><td valign="top">
<tt>'I'</tt>
* <tr><td valign="top">
{@code 'I'}
* <td valign="top"> <tt>'\u0049'</tt>
* <td> Hour for the 12-hour clock, formatted as two digits with a leading
* zero as necessary, i.e.
<tt>01 - 12</tt>. <tt>01</tt>
corresponds to
* zero as necessary, i.e.
{@code 01 - 12}. {@code 01}
corresponds to
* one o'clock (either morning or afternoon).
*
* <tr><td valign="top">
<tt>'k'</tt>
* <tr><td valign="top">
{@code 'k'}
* <td valign="top"> <tt>'\u006b'</tt>
* <td> Hour of the day for the 24-hour clock, i.e.
<tt>0 - 23</tt>
.
*
<tt>0</tt>
corresponds to midnight.
* <td> Hour of the day for the 24-hour clock, i.e.
{@code 0 - 23}
.
*
{@code 0}
corresponds to midnight.
*
* <tr><td valign="top">
<tt>'l'</tt>
* <tr><td valign="top">
{@code 'l'}
* <td valign="top"> <tt>'\u006c'</tt>
* <td> Hour for the 12-hour clock, i.e.
<tt>1 - 12</tt>. <tt>1</tt>
* <td> Hour for the 12-hour clock, i.e.
{@code 1 - 12}. {@code 1}
* corresponds to one o'clock (either morning or afternoon).
*
* <tr><td valign="top">
<tt>'M'</tt>
* <tr><td valign="top">
{@code 'M'}
* <td valign="top"> <tt>'\u004d'</tt>
* <td> Minute within the hour formatted as two digits with a leading zero
* as necessary, i.e.
<tt>00 - 59</tt>
.
* as necessary, i.e.
{@code 00 - 59}
.
*
* <tr><td valign="top">
<tt>'S'</tt>
* <tr><td valign="top">
{@code 'S'}
* <td valign="top"> <tt>'\u0053'</tt>
* <td> Seconds within the minute, formatted as two digits with a leading
* zero as necessary, i.e.
<tt>00 - 60</tt> ("<tt>60</tt>
" is a special
* zero as necessary, i.e.
{@code 00 - 60} ("{@code 60}
" is a special
* value required to support leap seconds).
*
* <tr><td valign="top">
<tt>'L'</tt>
* <tr><td valign="top">
{@code 'L'}
* <td valign="top"> <tt>'\u004c'</tt>
* <td> Millisecond within the second formatted as three digits with
* leading zeros as necessary, i.e.
<tt>000 - 999</tt>
.
* leading zeros as necessary, i.e.
{@code 000 - 999}
.
*
* <tr><td valign="top">
<tt>'N'</tt>
* <tr><td valign="top">
{@code 'N'}
* <td valign="top"> <tt>'\u004e'</tt>
* <td> Nanosecond within the second, formatted as nine digits with leading
* zeros as necessary, i.e.
<tt>000000000 - 999999999</tt>
. The precision
* zeros as necessary, i.e.
{@code 000000000 - 999999999}
. The precision
* of this value is limited by the resolution of the underlying operating
* system or hardware.
*
* <tr><td valign="top">
<tt>'p'</tt>
* <tr><td valign="top">
{@code 'p'}
* <td valign="top"> <tt>'\u0070'</tt>
* <td> Locale-specific {@linkplain
* java.text.DateFormatSymbols#getAmPmStrings morning or afternoon} marker
* in lower case, e.g."
<tt>am</tt>" or "<tt>pm</tt>
". Use of the
* conversion prefix
<tt>'T'</tt>
forces this output to upper case. (Note
* that
<tt>'p'</tt>
produces lower-case output. This is different from
* GNU
<tt>date</tt> and POSIX <tt>strftime(3c)</tt>
which produce
* in lower case, e.g."
{@code am}" or "{@code pm}
". Use of the
* conversion prefix
{@code 'T'}
forces this output to upper case. (Note
* that
{@code 'p'}
produces lower-case output. This is different from
* GNU
{@code date} and POSIX {@code strftime(3c)}
which produce
* upper-case output.)
*
* <tr><td valign="top">
<tt>'z'</tt>
* <tr><td valign="top">
{@code 'z'}
* <td valign="top"> <tt>'\u007a'</tt>
* <td> <a href="http://www.ietf.org/rfc/rfc0822.txt">RFC 822</a>
* style numeric time zone offset from GMT, e.g.
<tt>-0800</tt>
. This
* style numeric time zone offset from GMT, e.g.
{@code -0800}
. This
* value will be adjusted as necessary for Daylight Saving Time. For
*
<tt>long</tt>
, {@link Long}, and {@link Date} the time zone used is
* the {@
plainlink
TimeZone#getDefault() default time zone} for this
*
{@code long}
, {@link Long}, and {@link Date} the time zone used is
* the {@
linkplain
TimeZone#getDefault() default time zone} for this
* instance of the Java virtual machine.
*
* <tr><td valign="top">
<tt>'Z'</tt>
* <tr><td valign="top">
{@code 'Z'}
* <td> A string representing the abbreviation for the time zone. This
* value will be adjusted as necessary for Daylight Saving Time. For
*
<tt>long</tt>
, {@link Long}, and {@link Date} the time zone used is
* the {@
plainlink
TimeZone#getDefault() default time zone} for this
*
{@code long}
, {@link Long}, and {@link Date} the time zone used is
* the {@
linkplain
TimeZone#getDefault() default time zone} for this
* instance of the Java virtual machine. The Formatter's locale will
* supersede the locale of the argument (if any).
*
* <tr><td valign="top">
<tt>'s'</tt>
* <tr><td valign="top">
{@code 's'}
* <td valign="top"> <tt>'\u0073'</tt>
* <td> Seconds since the beginning of the epoch starting at 1 January 1970
*
<tt>00:00:00</tt> UTC, i.e. <tt>Long.MIN_VALUE/1000</tt>
to
*
<tt>Long.MAX_VALUE/1000</tt>
.
*
{@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE/1000}
to
*
{@code Long.MAX_VALUE/1000}
.
*
* <tr><td valign="top">
<tt>'Q'</tt>
* <tr><td valign="top">
{@code 'Q'}
* <td valign="top"> <tt>'\u004f'</tt>
* <td> Milliseconds since the beginning of the epoch starting at 1 January
* 1970
<tt>00:00:00</tt> UTC, i.e. <tt>Long.MIN_VALUE</tt>
to
*
<tt>Long.MAX_VALUE</tt>
. The precision of this value is limited by
* 1970
{@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE}
to
*
{@code Long.MAX_VALUE}
. The precision of this value is limited by
* the resolution of the underlying operating system or hardware.
*
* </table>
...
...
@@ -1607,71 +1607,71 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="date">
*
* <tr><td valign="top">
<tt>'B'</tt>
* <tr><td valign="top">
{@code 'B'}
* <td valign="top"> <tt>'\u0042'</tt>
* <td> Locale-specific {@linkplain java.text.DateFormatSymbols#getMonths
* full month name}, e.g.
<tt>"January"</tt>, <tt>"February"</tt>
.
* full month name}, e.g.
{@code "January"}, {@code "February"}
.
*
* <tr><td valign="top">
<tt>'b'</tt>
* <tr><td valign="top">
{@code 'b'}
* <td valign="top"> <tt>'\u0062'</tt>
* <td> Locale-specific {@linkplain
* java.text.DateFormatSymbols#getShortMonths abbreviated month name},
* e.g.
<tt>"Jan"</tt>, <tt>"Feb"</tt>
.
* e.g.
{@code "Jan"}, {@code "Feb"}
.
*
* <tr><td valign="top">
<tt>'h'</tt>
* <tr><td valign="top">
{@code 'h'}
* <td valign="top"> <tt>'\u0068'</tt>
* <td> Same as
<tt>'b'</tt>
.
* <td> Same as
{@code 'b'}
.
*
* <tr><td valign="top">
<tt>'A'</tt>
* <tr><td valign="top">
{@code 'A'}
* <td valign="top"> <tt>'\u0041'</tt>
* <td> Locale-specific full name of the {@linkplain
* java.text.DateFormatSymbols#getWeekdays day of the week},
* e.g.
<tt>"Sunday"</tt>, <tt>"Monday"</tt>
* e.g.
{@code "Sunday"}, {@code "Monday"}
*
* <tr><td valign="top">
<tt>'a'</tt>
* <tr><td valign="top">
{@code 'a'}
* <td valign="top"> <tt>'\u0061'</tt>
* <td> Locale-specific short name of the {@linkplain
* java.text.DateFormatSymbols#getShortWeekdays day of the week},
* e.g.
<tt>"Sun"</tt>, <tt>"Mon"</tt>
* e.g.
{@code "Sun"}, {@code "Mon"}
*
* <tr><td valign="top">
<tt>'C'</tt>
* <tr><td valign="top">
{@code 'C'}
* <td valign="top"> <tt>'\u0043'</tt>
* <td> Four-digit year divided by
<tt>100</tt>
, formatted as two digits
* with leading zero as necessary, i.e.
<tt>00 - 99</tt>
* <td> Four-digit year divided by
{@code 100}
, formatted as two digits
* with leading zero as necessary, i.e.
{@code 00 - 99}
*
* <tr><td valign="top">
<tt>'Y'</tt>
* <tr><td valign="top">
{@code 'Y'}
* <td valign="top"> <tt>'\u0059'</tt> <td> Year, formatted to at least
* four digits with leading zeros as necessary, e.g.
<tt>0092</tt>
equals
*
<tt>92</tt>
CE for the Gregorian calendar.
* four digits with leading zeros as necessary, e.g.
{@code 0092}
equals
*
{@code 92}
CE for the Gregorian calendar.
*
* <tr><td valign="top">
<tt>'y'</tt>
* <tr><td valign="top">
{@code 'y'}
* <td valign="top"> <tt>'\u0079'</tt>
* <td> Last two digits of the year, formatted with leading zeros as
* necessary, i.e.
<tt>00 - 99</tt>
.
* necessary, i.e.
{@code 00 - 99}
.
*
* <tr><td valign="top">
<tt>'j'</tt>
* <tr><td valign="top">
{@code 'j'}
* <td valign="top"> <tt>'\u006a'</tt>
* <td> Day of year, formatted as three digits with leading zeros as
* necessary, e.g.
<tt>001 - 366</tt>
for the Gregorian calendar.
*
<tt>001</tt>
corresponds to the first day of the year.
* necessary, e.g.
{@code 001 - 366}
for the Gregorian calendar.
*
{@code 001}
corresponds to the first day of the year.
*
* <tr><td valign="top">
<tt>'m'</tt>
* <tr><td valign="top">
{@code 'm'}
* <td valign="top"> <tt>'\u006d'</tt>
* <td> Month, formatted as two digits with leading zeros as necessary,
* i.e.
<tt>01 - 13</tt>, where "<tt>01</tt>
" is the first month of the
* year and ("
<tt>13</tt>
" is a special value required to support lunar
* i.e.
{@code 01 - 13}, where "{@code 01}
" is the first month of the
* year and ("
{@code 13}
" is a special value required to support lunar
* calendars).
*
* <tr><td valign="top">
<tt>'d'</tt>
* <tr><td valign="top">
{@code 'd'}
* <td valign="top"> <tt>'\u0064'</tt>
* <td> Day of month, formatted as two digits with leading zeros as
* necessary, i.e.
<tt>01 - 31</tt>, where "<tt>01</tt>
" is the first day
* necessary, i.e.
{@code 01 - 31}, where "{@code 01}
" is the first day
* of the month.
*
* <tr><td valign="top">
<tt>'e'</tt>
* <tr><td valign="top">
{@code 'e'}
* <td valign="top"> <tt>'\u0065'</tt>
* <td> Day of month, formatted as two digits, i.e.
<tt>1 - 31</tt>
where
* "
<tt>1</tt>
" is the first day of the month.
* <td> Day of month, formatted as two digits, i.e.
{@code 1 - 31}
where
* "
{@code 1}
" is the first day of the month.
*
* </table>
*
...
...
@@ -1680,45 +1680,45 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="composites">
*
* <tr><td valign="top">
<tt>'R'</tt>
* <tr><td valign="top">
{@code 'R'}
* <td valign="top"> <tt>'\u0052'</tt>
* <td> Time formatted for the 24-hour clock as
<tt>"%tH:%tM"</tt>
* <td> Time formatted for the 24-hour clock as
{@code "%tH:%tM"}
*
* <tr><td valign="top">
<tt>'T'</tt>
* <tr><td valign="top">
{@code 'T'}
* <td valign="top"> <tt>'\u0054'</tt>
* <td> Time formatted for the 24-hour clock as
<tt>"%tH:%tM:%tS"</tt>
.
* <td> Time formatted for the 24-hour clock as
{@code "%tH:%tM:%tS"}
.
*
* <tr><td valign="top">
<tt>'r'</tt>
* <tr><td valign="top">
{@code 'r'}
* <td valign="top"> <tt>'\u0072'</tt>
* <td> Time formatted for the 12-hour clock as
<tt>
"%tI:%tM:%tS
* %Tp"
</tt>
. The location of the morning or afternoon marker
* (
<tt>'%Tp'</tt>
) may be locale-dependent.
* <td> Time formatted for the 12-hour clock as
{@code
"%tI:%tM:%tS
* %Tp"
}
. The location of the morning or afternoon marker
* (
{@code '%Tp'}
) may be locale-dependent.
*
* <tr><td valign="top">
<tt>'D'</tt>
* <tr><td valign="top">
{@code 'D'}
* <td valign="top"> <tt>'\u0044'</tt>
* <td> Date formatted as
<tt>"%tm/%td/%ty"</tt>
.
* <td> Date formatted as
{@code "%tm/%td/%ty"}
.
*
* <tr><td valign="top">
<tt>'F'</tt>
* <tr><td valign="top">
{@code 'F'}
* <td valign="top"> <tt>'\u0046'</tt>
* <td> <a href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a>
* complete date formatted as
<tt>"%tY-%tm-%td"</tt>
.
* complete date formatted as
{@code "%tY-%tm-%td"}
.
*
* <tr><td valign="top">
<tt>'c'</tt>
* <tr><td valign="top">
{@code 'c'}
* <td valign="top"> <tt>'\u0063'</tt>
* <td> Date and time formatted as
<tt>"%ta %tb %td %tT %tZ %tY"</tt>
,
* e.g.
<tt>"Sun Jul 20 16:17:00 EDT 1969"</tt>
.
* <td> Date and time formatted as
{@code "%ta %tb %td %tT %tZ %tY"}
,
* e.g.
{@code "Sun Jul 20 16:17:00 EDT 1969"}
.
*
* </table>
*
* <p> The
<tt>'-'</tt>
flag defined for <a href="#dFlags">General
* conversions</a> applies. If the
<tt>'#'</tt>
flag is given, then a {@link
* <p> The
{@code '-'}
flag defined for <a href="#dFlags">General
* conversions</a> applies. If the
{@code '#'}
flag is given, then a {@link
* FormatFlagsConversionMismatchException} will be thrown.
*
* <p> The <a name="dtWidth">width</a> is the minimum number of characters to
* be written to the output. If the length of the converted value is less than
* the
<tt>width</tt>
then the output will be padded by spaces
* the
{@code width}
then the output will be padded by spaces
* (<tt>'\u0020'</tt>) until the total number of characters equals width.
* The padding is on the left by default. If the
<tt>'-'</tt>
flag is given
* The padding is on the left by default. If the
{@code '-'}
flag is given
* then the padding will be on the right. If width is not specified then there
* is no minimum.
*
...
...
@@ -1731,17 +1731,17 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="DTConv">
*
* <tr><td valign="top">
<tt>'%'</tt>
* <td> The result is a literal
<tt>'%'</tt>
(<tt>'\u0025'</tt>)
* <tr><td valign="top">
{@code '%'}
* <td> The result is a literal
{@code '%'}
(<tt>'\u0025'</tt>)
*
* <p> The <a name="dtWidth">width</a> is the minimum number of characters to
* be written to the output including the
<tt>'%'</tt>
. If the length of the
* converted value is less than the
<tt>width</tt>
then the output will be
* be written to the output including the
{@code '%'}
. If the length of the
* converted value is less than the
{@code width}
then the output will be
* padded by spaces (<tt>'\u0020'</tt>) until the total number of
* characters equals width. The padding is on the left. If width is not
* specified then just the
<tt>'%'</tt>
is output.
* specified then just the
{@code '%'}
is output.
*
* <p> The
<tt>'-'</tt>
flag defined for <a href="#dFlags">General
* <p> The
{@code '-'}
flag defined for <a href="#dFlags">General
* conversions</a> applies. If any other flags are provided, then a
* {@link FormatFlagsConversionMismatchException} will be thrown.
*
...
...
@@ -1756,7 +1756,7 @@ import sun.misc.FormattedFloatingDecimal;
*
* <table cellpadding=5 summary="DTConv">
*
* <tr><td valign="top">
<tt>'n'</tt>
* <tr><td valign="top">
{@code 'n'}
* <td> the platform-specific line separator as returned by {@link
* System#getProperty System.getProperty("line.separator")}.
*
...
...
@@ -1775,7 +1775,7 @@ import sun.misc.FormattedFloatingDecimal;
* <li> <i>Explicit indexing</i> is used when the format specifier contains an
* argument index. The argument index is a decimal integer indicating the
* position of the argument in the argument list. The first argument is
* referenced by "
<tt>1$</tt>", the second by "<tt>2$</tt>
", etc. An argument
* referenced by "
{@code 1$}", the second by "{@code 2$}
", etc. An argument
* may be referenced more than once.
*
* <p> For example:
...
...
@@ -1787,7 +1787,7 @@ import sun.misc.FormattedFloatingDecimal;
* </pre></blockquote>
*
* <li> <i>Relative indexing</i> is used when the format specifier contains a
*
<tt>'<'</tt>
(<tt>'\u003c'</tt>) flag which causes the argument for
*
{@code '<'}
(<tt>'\u003c'</tt>) flag which causes the argument for
* the previous format specifier to be re-used. If there is no previous
* argument, then a {@link MissingFormatArgumentException} is thrown.
*
...
...
@@ -1798,7 +1798,7 @@ import sun.misc.FormattedFloatingDecimal;
* </pre></blockquote>
*
* <li> <i>Ordinary indexing</i> is used when the format specifier contains
* neither an argument index nor a
<tt>'<'</tt>
flag. Each format specifier
* neither an argument index nor a
{@code '<'}
flag. Each format specifier
* which uses ordinary indexing is assigned a sequential implicit index into
* argument list which is independent of the indices used by explicit or
* relative indexing.
...
...
@@ -1828,7 +1828,7 @@ import sun.misc.FormattedFloatingDecimal;
* <p> If there are more arguments than format specifiers, the extra arguments
* are ignored.
*
* <p> Unless otherwise specified, passing a
<tt>null</tt>
argument to any
* <p> Unless otherwise specified, passing a
{@code null}
argument to any
* method or constructor in this class will cause a {@link
* NullPointerException} to be thrown.
*
...
...
@@ -1876,8 +1876,8 @@ public final class Formatter implements Closeable, Flushable {
* locale} for this instance of the Java virtual machine.
*
* @param a
* Destination for the formatted output. If
<tt>a</tt>
is
*
<tt>null</tt>
then a {@link StringBuilder} will be created.
* Destination for the formatted output. If
{@code a}
is
*
{@code null}
then a {@link StringBuilder} will be created.
*/
public
Formatter
(
Appendable
a
)
{
if
(
a
==
null
)
...
...
@@ -1895,7 +1895,7 @@ public final class Formatter implements Closeable, Flushable {
*
* @param l
* The {@linkplain java.util.Locale locale} to apply during
* formatting. If
<tt>l</tt> is <tt>null</tt>
then no localization
* formatting. If
{@code l} is {@code null}
then no localization
* is applied.
*/
public
Formatter
(
Locale
l
)
{
...
...
@@ -1906,12 +1906,12 @@ public final class Formatter implements Closeable, Flushable {
* Constructs a new formatter with the specified destination and locale.
*
* @param a
* Destination for the formatted output. If
<tt>a</tt>
is
*
<tt>null</tt>
then a {@link StringBuilder} will be created.
* Destination for the formatted output. If
{@code a}
is
*
{@code null}
then a {@link StringBuilder} will be created.
*
* @param l
* The {@linkplain java.util.Locale locale} to apply during
* formatting. If
<tt>l</tt> is <tt>null</tt>
then no localization
* formatting. If
{@code l} is {@code null}
then no localization
* is applied.
*/
public
Formatter
(
Appendable
a
,
Locale
l
)
{
...
...
@@ -2004,7 +2004,7 @@ public final class Formatter implements Closeable, Flushable {
*
* @param l
* The {@linkplain java.util.Locale locale} to apply during
* formatting. If
<tt>l</tt> is <tt>null</tt>
then no localization
* formatting. If
{@code l} is {@code null}
then no localization
* is applied.
*
* @throws FileNotFoundException
...
...
@@ -2112,7 +2112,7 @@ public final class Formatter implements Closeable, Flushable {
*
* @param l
* The {@linkplain java.util.Locale locale} to apply during
* formatting. If
<tt>l</tt> is <tt>null</tt>
then no localization
* formatting. If
{@code l} is {@code null}
then no localization
* is applied.
*
* @throws FileNotFoundException
...
...
@@ -2212,7 +2212,7 @@ public final class Formatter implements Closeable, Flushable {
*
* @param l
* The {@linkplain java.util.Locale locale} to apply during
* formatting. If
<tt>l</tt> is <tt>null</tt>
then no localization
* formatting. If
{@code l} is {@code null}
then no localization
* is applied.
*
* @throws UnsupportedEncodingException
...
...
@@ -2237,7 +2237,7 @@ public final class Formatter implements Closeable, Flushable {
* <p> The {@link #format(java.util.Locale,String,Object...) format} method
* for this object which has a locale argument does not change this value.
*
* @return
<tt>null</tt>
if no localization is applied, otherwise a
* @return
{@code null}
if no localization is applied, otherwise a
* locale
*
* @throws FormatterClosedException
...
...
@@ -2264,7 +2264,7 @@ public final class Formatter implements Closeable, Flushable {
}
/**
* Returns the result of invoking
<tt>toString()</tt>
on the destination
* Returns the result of invoking
{@code toString()}
on the destination
* for the output. For example, the following code formats text into a
* {@link StringBuilder} then retrieves the resultant string:
*
...
...
@@ -2281,13 +2281,13 @@ public final class Formatter implements Closeable, Flushable {
* <pre>
* out().toString() </pre>
*
* <p> Depending on the specification of
<tt>toString</tt>
for the {@link
* <p> Depending on the specification of
{@code toString}
for the {@link
* Appendable}, the returned string may or may not contain the characters
* written to the destination. For instance, buffers typically return
* their contents in
<tt>toString()</tt>
, but streams cannot since the
* their contents in
{@code toString()}
, but streams cannot since the
* data is discarded.
*
* @return The result of invoking
<tt>toString()</tt>
on the destination
* @return The result of invoking
{@code toString()}
on the destination
* for the output
*
* @throws FormatterClosedException
...
...
@@ -2301,7 +2301,7 @@ public final class Formatter implements Closeable, Flushable {
/**
* Flushes this formatter. If the destination implements the {@link
* java.io.Flushable} interface, its
<tt>flush</tt>
method will be invoked.
* java.io.Flushable} interface, its
{@code flush}
method will be invoked.
*
* <p> Flushing a formatter writes any buffered output in the destination
* to the underlying stream.
...
...
@@ -2323,7 +2323,7 @@ public final class Formatter implements Closeable, Flushable {
/**
* Closes this formatter. If the destination implements the {@link
* java.io.Closeable} interface, its
<tt>close</tt>
method will be invoked.
* java.io.Closeable} interface, its
{@code close}
method will be invoked.
*
* <p> Closing a formatter allows it to release resources it may be holding
* (such as open files). If the formatter is already closed, then invoking
...
...
@@ -2352,13 +2352,13 @@ public final class Formatter implements Closeable, Flushable {
}
/**
* Returns the
<tt>IOException</tt>
last thrown by this formatter's {@link
* Returns the
{@code IOException}
last thrown by this formatter's {@link
* Appendable}.
*
* <p> If the destination's
<tt>append()</tt>
method never throws
*
<tt>IOException</tt>, then this method will always return <tt>null</tt>
.
* <p> If the destination's
{@code append()}
method never throws
*
{@code IOException}, then this method will always return {@code null}
.
*
* @return The last exception thrown by the Appendable or
<tt>null</tt>
if
* @return The last exception thrown by the Appendable or
{@code null}
if
* no such exception exists.
*/
public
IOException
ioException
()
{
...
...
@@ -2406,7 +2406,7 @@ public final class Formatter implements Closeable, Flushable {
*
* @param l
* The {@linkplain java.util.Locale locale} to apply during
* formatting. If
<tt>l</tt> is <tt>null</tt>
then no localization
* formatting. If
{@code l} is {@code null}
then no localization
* is applied. This does not change this object's locale that was
* set during construction.
*
...
...
@@ -4196,7 +4196,7 @@ public final class Formatter implements Closeable, Flushable {
}
}
// Returns a string representation of the current
<tt>Flags</tt>
.
// Returns a string representation of the current
{@code Flags}
.
public
static
String
toString
(
Flags
f
)
{
return
f
.
toString
();
}
...
...
src/share/classes/java/util/logging/Logger.java
浏览文件 @
a7cb2d41
...
...
@@ -27,6 +27,7 @@
package
java.util.logging
;
import
java.util.*
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.security.*
;
import
java.lang.ref.WeakReference
;
...
...
@@ -165,10 +166,11 @@ public class Logger {
private
static
final
int
offValue
=
Level
.
OFF
.
intValue
();
private
LogManager
manager
;
private
String
name
;
private
ArrayList
<
Handler
>
handlers
;
private
final
CopyOnWriteArrayList
<
Handler
>
handlers
=
new
CopyOnWriteArrayList
<
Handler
>();
private
String
resourceBundleName
;
private
boolean
useParentHandlers
=
true
;
private
Filter
filter
;
private
volatile
boolean
useParentHandlers
=
true
;
private
volatile
Filter
filter
;
private
boolean
anonymous
;
private
ResourceBundle
catalog
;
// Cached resource bundle
...
...
@@ -180,9 +182,9 @@ public class Logger {
private
static
Object
treeLock
=
new
Object
();
// We keep weak references from parents to children, but strong
// references from children to parents.
private
Logger
parent
;
// our nearest parent.
private
volatile
Logger
parent
;
// our nearest parent.
private
ArrayList
<
WeakReference
<
Logger
>>
kids
;
// WeakReferences to loggers that have us as parent
private
Level
levelObject
;
private
volatile
Level
levelObject
;
private
volatile
int
levelValue
;
// current effective level value
/**
...
...
@@ -438,7 +440,7 @@ public class Logger {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
public
synchronized
void
setFilter
(
Filter
newFilter
)
throws
SecurityException
{
public
void
setFilter
(
Filter
newFilter
)
throws
SecurityException
{
checkAccess
();
filter
=
newFilter
;
}
...
...
@@ -448,7 +450,7 @@ public class Logger {
*
* @return a filter object (may be null)
*/
public
synchronized
Filter
getFilter
()
{
public
Filter
getFilter
()
{
return
filter
;
}
...
...
@@ -465,23 +467,18 @@ public class Logger {
if
(
record
.
getLevel
().
intValue
()
<
levelValue
||
levelValue
==
offValue
)
{
return
;
}
synchronized
(
this
)
{
if
(
filter
!=
null
&&
!
f
ilter
.
isLoggable
(
record
))
{
Filter
theFilter
=
filter
;
if
(
theFilter
!=
null
&&
!
theF
ilter
.
isLoggable
(
record
))
{
return
;
}
}
// Post the LogRecord to all our Handlers, and then to
// our parents' handlers, all the way up the tree.
Logger
logger
=
this
;
while
(
logger
!=
null
)
{
Handler
targets
[]
=
logger
.
getHandlers
();
if
(
targets
!=
null
)
{
for
(
int
i
=
0
;
i
<
targets
.
length
;
i
++)
{
targets
[
i
].
publish
(
record
);
}
for
(
Handler
handler
:
logger
.
handlers
)
{
handler
.
publish
(
record
);
}
if
(!
logger
.
getUseParentHandlers
())
{
...
...
@@ -1182,13 +1179,10 @@ public class Logger {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
public
synchronized
void
addHandler
(
Handler
handler
)
throws
SecurityException
{
public
void
addHandler
(
Handler
handler
)
throws
SecurityException
{
// Check for null handler
handler
.
getClass
();
checkAccess
();
if
(
handlers
==
null
)
{
handlers
=
new
ArrayList
<
Handler
>();
}
handlers
.
add
(
handler
);
}
...
...
@@ -1201,14 +1195,11 @@ public class Logger {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
public
synchronized
void
removeHandler
(
Handler
handler
)
throws
SecurityException
{
public
void
removeHandler
(
Handler
handler
)
throws
SecurityException
{
checkAccess
();
if
(
handler
==
null
)
{
return
;
}
if
(
handlers
==
null
)
{
return
;
}
handlers
.
remove
(
handler
);
}
...
...
@@ -1217,11 +1208,8 @@ public class Logger {
* <p>
* @return an array of all registered Handlers
*/
public
synchronized
Handler
[]
getHandlers
()
{
if
(
handlers
==
null
)
{
return
emptyHandlers
;
}
return
handlers
.
toArray
(
new
Handler
[
handlers
.
size
()]);
public
Handler
[]
getHandlers
()
{
return
handlers
.
toArray
(
emptyHandlers
);
}
/**
...
...
@@ -1235,7 +1223,7 @@ public class Logger {
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*/
public
synchronized
void
setUseParentHandlers
(
boolean
useParentHandlers
)
{
public
void
setUseParentHandlers
(
boolean
useParentHandlers
)
{
checkAccess
();
this
.
useParentHandlers
=
useParentHandlers
;
}
...
...
@@ -1246,7 +1234,7 @@ public class Logger {
*
* @return true if output is to be sent to the logger's parent
*/
public
synchronized
boolean
getUseParentHandlers
()
{
public
boolean
getUseParentHandlers
()
{
return
useParentHandlers
;
}
...
...
@@ -1354,10 +1342,13 @@ public class Logger {
* @return nearest existing parent Logger
*/
public
Logger
getParent
()
{
synchronized
(
treeLock
)
{
// Note: this used to be synchronized on treeLock. However, this only
// provided memory semantics, as there was no guarantee that the caller
// would synchronize on treeLock (in fact, there is no way for external
// callers to so synchronize). Therefore, we have made parent volatile
// instead.
return
parent
;
}
}
/**
* Set the parent for this Logger. This method is used by
...
...
src/share/classes/sun/misc/URLClassPath.java
浏览文件 @
a7cb2d41
...
...
@@ -25,17 +25,7 @@
package
sun.misc
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.Hashtable
;
import
java.util.NoSuchElementException
;
import
java.util.Stack
;
import
java.util.Set
;
import
java.util.HashSet
;
import
java.util.StringTokenizer
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.*
;
import
java.util.jar.JarFile
;
import
sun.misc.JarIndex
;
import
sun.misc.InvalidJarIndexException
;
...
...
@@ -52,12 +42,7 @@ import java.net.URLConnection;
import
java.net.HttpURLConnection
;
import
java.net.URLStreamHandler
;
import
java.net.URLStreamHandlerFactory
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.io.*
;
import
java.security.AccessController
;
import
java.security.AccessControlException
;
import
java.security.CodeSigner
;
...
...
@@ -100,6 +85,9 @@ public class URLClassPath {
/* The jar protocol handler to use when creating new URLs */
private
URLStreamHandler
jarHandler
;
/* Whether this URLClassLoader has been closed yet */
private
boolean
closed
=
false
;
/**
* Creates a new URLClassPath for the given URLs. The URLs will be
* searched in the order specified for classes and resources. A URL
...
...
@@ -124,6 +112,22 @@ public class URLClassPath {
this
(
urls
,
null
);
}
public
synchronized
List
<
IOException
>
closeLoaders
()
{
if
(
closed
)
{
return
Collections
.
emptyList
();
}
List
<
IOException
>
result
=
new
LinkedList
<
IOException
>();
for
(
Loader
loader
:
loaders
)
{
try
{
loader
.
close
();
}
catch
(
IOException
e
)
{
result
.
add
(
e
);
}
}
closed
=
true
;
return
result
;
}
/**
* Appends the specified URL to the search path of directory and JAR
* file URLs from which to load classes and resources.
...
...
@@ -293,6 +297,9 @@ public class URLClassPath {
* if the specified index is out of range.
*/
private
synchronized
Loader
getLoader
(
int
index
)
{
if
(
closed
)
{
return
null
;
}
// Expand URL search path until the request can be satisfied
// or the URL stack is empty.
while
(
loaders
.
size
()
<
index
+
1
)
{
...
...
@@ -453,7 +460,7 @@ public class URLClassPath {
* Inner class used to represent a loader of resources and classes
* from a base URL.
*/
private
static
class
Loader
{
private
static
class
Loader
implements
Closeable
{
private
final
URL
base
;
/*
...
...
@@ -544,6 +551,12 @@ public class URLClassPath {
return
getResource
(
name
,
true
);
}
/*
* close this loader and release all resources
* method overridden in sub-classes
*/
public
void
close
()
throws
IOException
{}
/*
* Returns the local class path for this loader, or null if none.
*/
...
...
@@ -562,6 +575,7 @@ public class URLClassPath {
private
MetaIndex
metaIndex
;
private
URLStreamHandler
handler
;
private
HashMap
<
URL
,
Loader
>
lmap
;
private
boolean
closed
=
false
;
/*
* Creates a new JarLoader for the specified URL referring to
...
...
@@ -604,6 +618,17 @@ public class URLClassPath {
}
}
@Override
public
void
close
()
throws
IOException
{
// closing is synchronized at higher level
if
(!
closed
)
{
closed
=
true
;
// in case not already open.
ensureOpen
();
jar
.
close
();
}
}
JarFile
getJarFile
()
{
return
jar
;
}
...
...
src/solaris/native/java/lang/UNIXProcess_md.c
浏览文件 @
a7cb2d41
...
...
@@ -259,6 +259,12 @@ Java_java_lang_UNIXProcess_waitForProcessExit(JNIEnv* env,
}
}
static
int
isAsciiDigit
(
char
c
)
{
return
c
>=
'0'
&&
c
<=
'9'
;
}
static
int
closeDescriptors
(
void
)
{
...
...
@@ -284,7 +290,7 @@ closeDescriptors(void)
*/
while
((
dirp
=
readdir64
(
dp
))
!=
NULL
)
{
int
fd
;
if
(
is
d
igit
(
dirp
->
d_name
[
0
])
&&
if
(
is
AsciiD
igit
(
dirp
->
d_name
[
0
])
&&
(
fd
=
strtol
(
dirp
->
d_name
,
NULL
,
10
))
>=
from_fd
+
2
)
close
(
fd
);
}
...
...
test/java/lang/Enum/ValueOf.java
0 → 100644
浏览文件 @
a7cb2d41
/*
* Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4984908 5058132 6653154
* @summary Basic test of valueOf(String)
* @author Josh Bloch
*
* @compile ValueOf.java
* @run main ValueOf
*/
import
java.util.*
;
import
java.lang.reflect.Method
;
public
class
ValueOf
{
static
Random
rnd
=
new
Random
();
public
static
void
main
(
String
[]
args
)
throws
Exception
{
test
(
Silly0
.
class
);
test
(
Silly1
.
class
);
test
(
Silly31
.
class
);
test
(
Silly32
.
class
);
test
(
Silly33
.
class
);
test
(
Silly63
.
class
);
test
(
Silly64
.
class
);
test
(
Silly65
.
class
);
test
(
Silly127
.
class
);
test
(
Silly128
.
class
);
test
(
Silly129
.
class
);
test
(
Silly500
.
class
);
test
(
Specialized
.
class
);
testMissingException
();
}
static
<
T
extends
Enum
<
T
>>
void
test
(
Class
<
T
>
enumClass
)
throws
Exception
{
Set
<
T
>
s
=
EnumSet
.
allOf
(
enumClass
);
test
(
enumClass
,
s
);
// Delete half the elements from set at random
for
(
Iterator
<
T
>
i
=
s
.
iterator
();
i
.
hasNext
();
)
{
i
.
next
();
if
(
rnd
.
nextBoolean
())
i
.
remove
();
}
test
(
enumClass
,
s
);
}
static
<
T
extends
Enum
<
T
>>
void
test
(
Class
<
T
>
enumClass
,
Set
<
T
>
s
)
throws
Exception
{
Method
valueOf
=
enumClass
.
getDeclaredMethod
(
"valueOf"
,
String
.
class
);
Set
<
T
>
copy
=
EnumSet
.
noneOf
(
enumClass
);
for
(
T
e
:
s
)
copy
.
add
((
T
)
valueOf
.
invoke
(
null
,
e
.
name
()));
if
(!
copy
.
equals
(
s
))
throw
new
Exception
(
copy
+
" != "
+
s
);
}
static
void
testMissingException
()
{
try
{
Enum
.
valueOf
(
Specialized
.
class
,
"BAZ"
);
throw
new
RuntimeException
(
"Expected IllegalArgumentException not thrown."
);
}
catch
(
IllegalArgumentException
iae
)
{
String
message
=
iae
.
getMessage
();
if
(!
"No enum constant ValueOf.Specialized.BAZ"
.
equals
(
message
))
throw
new
RuntimeException
(
"Unexpected detail message: ``"
+
message
+
"''."
);
}
}
enum
Silly0
{
};
enum
Silly1
{
e1
}
enum
Silly31
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
}
enum
Silly32
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
}
enum
Silly33
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
,
e32
}
enum
Silly63
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
,
e32
,
e33
,
e34
,
e35
,
e36
,
e37
,
e38
,
e39
,
e40
,
e41
,
e42
,
e43
,
e44
,
e45
,
e46
,
e47
,
e48
,
e49
,
e50
,
e51
,
e52
,
e53
,
e54
,
e55
,
e56
,
e57
,
e58
,
e59
,
e60
,
e61
,
e62
}
enum
Silly64
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
,
e32
,
e33
,
e34
,
e35
,
e36
,
e37
,
e38
,
e39
,
e40
,
e41
,
e42
,
e43
,
e44
,
e45
,
e46
,
e47
,
e48
,
e49
,
e50
,
e51
,
e52
,
e53
,
e54
,
e55
,
e56
,
e57
,
e58
,
e59
,
e60
,
e61
,
e62
,
e63
}
enum
Silly65
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
,
e32
,
e33
,
e34
,
e35
,
e36
,
e37
,
e38
,
e39
,
e40
,
e41
,
e42
,
e43
,
e44
,
e45
,
e46
,
e47
,
e48
,
e49
,
e50
,
e51
,
e52
,
e53
,
e54
,
e55
,
e56
,
e57
,
e58
,
e59
,
e60
,
e61
,
e62
,
e63
,
e64
}
enum
Silly127
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
,
e32
,
e33
,
e34
,
e35
,
e36
,
e37
,
e38
,
e39
,
e40
,
e41
,
e42
,
e43
,
e44
,
e45
,
e46
,
e47
,
e48
,
e49
,
e50
,
e51
,
e52
,
e53
,
e54
,
e55
,
e56
,
e57
,
e58
,
e59
,
e60
,
e61
,
e62
,
e63
,
e64
,
e65
,
e66
,
e67
,
e68
,
e69
,
e70
,
e71
,
e72
,
e73
,
e74
,
e75
,
e76
,
e77
,
e78
,
e79
,
e80
,
e81
,
e82
,
e83
,
e84
,
e85
,
e86
,
e87
,
e88
,
e89
,
e90
,
e91
,
e92
,
e93
,
e94
,
e95
,
e96
,
e97
,
e98
,
e99
,
e100
,
e101
,
e102
,
e103
,
e104
,
e105
,
e106
,
e107
,
e108
,
e109
,
e110
,
e111
,
e112
,
e113
,
e114
,
e115
,
e116
,
e117
,
e118
,
e119
,
e120
,
e121
,
e122
,
e123
,
e124
,
e125
,
e126
}
enum
Silly128
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
,
e32
,
e33
,
e34
,
e35
,
e36
,
e37
,
e38
,
e39
,
e40
,
e41
,
e42
,
e43
,
e44
,
e45
,
e46
,
e47
,
e48
,
e49
,
e50
,
e51
,
e52
,
e53
,
e54
,
e55
,
e56
,
e57
,
e58
,
e59
,
e60
,
e61
,
e62
,
e63
,
e64
,
e65
,
e66
,
e67
,
e68
,
e69
,
e70
,
e71
,
e72
,
e73
,
e74
,
e75
,
e76
,
e77
,
e78
,
e79
,
e80
,
e81
,
e82
,
e83
,
e84
,
e85
,
e86
,
e87
,
e88
,
e89
,
e90
,
e91
,
e92
,
e93
,
e94
,
e95
,
e96
,
e97
,
e98
,
e99
,
e100
,
e101
,
e102
,
e103
,
e104
,
e105
,
e106
,
e107
,
e108
,
e109
,
e110
,
e111
,
e112
,
e113
,
e114
,
e115
,
e116
,
e117
,
e118
,
e119
,
e120
,
e121
,
e122
,
e123
,
e124
,
e125
,
e126
,
e127
}
enum
Silly129
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
,
e32
,
e33
,
e34
,
e35
,
e36
,
e37
,
e38
,
e39
,
e40
,
e41
,
e42
,
e43
,
e44
,
e45
,
e46
,
e47
,
e48
,
e49
,
e50
,
e51
,
e52
,
e53
,
e54
,
e55
,
e56
,
e57
,
e58
,
e59
,
e60
,
e61
,
e62
,
e63
,
e64
,
e65
,
e66
,
e67
,
e68
,
e69
,
e70
,
e71
,
e72
,
e73
,
e74
,
e75
,
e76
,
e77
,
e78
,
e79
,
e80
,
e81
,
e82
,
e83
,
e84
,
e85
,
e86
,
e87
,
e88
,
e89
,
e90
,
e91
,
e92
,
e93
,
e94
,
e95
,
e96
,
e97
,
e98
,
e99
,
e100
,
e101
,
e102
,
e103
,
e104
,
e105
,
e106
,
e107
,
e108
,
e109
,
e110
,
e111
,
e112
,
e113
,
e114
,
e115
,
e116
,
e117
,
e118
,
e119
,
e120
,
e121
,
e122
,
e123
,
e124
,
e125
,
e126
,
e127
,
e128
}
enum
Silly500
{
e0
,
e1
,
e2
,
e3
,
e4
,
e5
,
e6
,
e7
,
e8
,
e9
,
e10
,
e11
,
e12
,
e13
,
e14
,
e15
,
e16
,
e17
,
e18
,
e19
,
e20
,
e21
,
e22
,
e23
,
e24
,
e25
,
e26
,
e27
,
e28
,
e29
,
e30
,
e31
,
e32
,
e33
,
e34
,
e35
,
e36
,
e37
,
e38
,
e39
,
e40
,
e41
,
e42
,
e43
,
e44
,
e45
,
e46
,
e47
,
e48
,
e49
,
e50
,
e51
,
e52
,
e53
,
e54
,
e55
,
e56
,
e57
,
e58
,
e59
,
e60
,
e61
,
e62
,
e63
,
e64
,
e65
,
e66
,
e67
,
e68
,
e69
,
e70
,
e71
,
e72
,
e73
,
e74
,
e75
,
e76
,
e77
,
e78
,
e79
,
e80
,
e81
,
e82
,
e83
,
e84
,
e85
,
e86
,
e87
,
e88
,
e89
,
e90
,
e91
,
e92
,
e93
,
e94
,
e95
,
e96
,
e97
,
e98
,
e99
,
e100
,
e101
,
e102
,
e103
,
e104
,
e105
,
e106
,
e107
,
e108
,
e109
,
e110
,
e111
,
e112
,
e113
,
e114
,
e115
,
e116
,
e117
,
e118
,
e119
,
e120
,
e121
,
e122
,
e123
,
e124
,
e125
,
e126
,
e127
,
e128
,
e129
,
e130
,
e131
,
e132
,
e133
,
e134
,
e135
,
e136
,
e137
,
e138
,
e139
,
e140
,
e141
,
e142
,
e143
,
e144
,
e145
,
e146
,
e147
,
e148
,
e149
,
e150
,
e151
,
e152
,
e153
,
e154
,
e155
,
e156
,
e157
,
e158
,
e159
,
e160
,
e161
,
e162
,
e163
,
e164
,
e165
,
e166
,
e167
,
e168
,
e169
,
e170
,
e171
,
e172
,
e173
,
e174
,
e175
,
e176
,
e177
,
e178
,
e179
,
e180
,
e181
,
e182
,
e183
,
e184
,
e185
,
e186
,
e187
,
e188
,
e189
,
e190
,
e191
,
e192
,
e193
,
e194
,
e195
,
e196
,
e197
,
e198
,
e199
,
e200
,
e201
,
e202
,
e203
,
e204
,
e205
,
e206
,
e207
,
e208
,
e209
,
e210
,
e211
,
e212
,
e213
,
e214
,
e215
,
e216
,
e217
,
e218
,
e219
,
e220
,
e221
,
e222
,
e223
,
e224
,
e225
,
e226
,
e227
,
e228
,
e229
,
e230
,
e231
,
e232
,
e233
,
e234
,
e235
,
e236
,
e237
,
e238
,
e239
,
e240
,
e241
,
e242
,
e243
,
e244
,
e245
,
e246
,
e247
,
e248
,
e249
,
e250
,
e251
,
e252
,
e253
,
e254
,
e255
,
e256
,
e257
,
e258
,
e259
,
e260
,
e261
,
e262
,
e263
,
e264
,
e265
,
e266
,
e267
,
e268
,
e269
,
e270
,
e271
,
e272
,
e273
,
e274
,
e275
,
e276
,
e277
,
e278
,
e279
,
e280
,
e281
,
e282
,
e283
,
e284
,
e285
,
e286
,
e287
,
e288
,
e289
,
e290
,
e291
,
e292
,
e293
,
e294
,
e295
,
e296
,
e297
,
e298
,
e299
,
e300
,
e301
,
e302
,
e303
,
e304
,
e305
,
e306
,
e307
,
e308
,
e309
,
e310
,
e311
,
e312
,
e313
,
e314
,
e315
,
e316
,
e317
,
e318
,
e319
,
e320
,
e321
,
e322
,
e323
,
e324
,
e325
,
e326
,
e327
,
e328
,
e329
,
e330
,
e331
,
e332
,
e333
,
e334
,
e335
,
e336
,
e337
,
e338
,
e339
,
e340
,
e341
,
e342
,
e343
,
e344
,
e345
,
e346
,
e347
,
e348
,
e349
,
e350
,
e351
,
e352
,
e353
,
e354
,
e355
,
e356
,
e357
,
e358
,
e359
,
e360
,
e361
,
e362
,
e363
,
e364
,
e365
,
e366
,
e367
,
e368
,
e369
,
e370
,
e371
,
e372
,
e373
,
e374
,
e375
,
e376
,
e377
,
e378
,
e379
,
e380
,
e381
,
e382
,
e383
,
e384
,
e385
,
e386
,
e387
,
e388
,
e389
,
e390
,
e391
,
e392
,
e393
,
e394
,
e395
,
e396
,
e397
,
e398
,
e399
,
e400
,
e401
,
e402
,
e403
,
e404
,
e405
,
e406
,
e407
,
e408
,
e409
,
e410
,
e411
,
e412
,
e413
,
e414
,
e415
,
e416
,
e417
,
e418
,
e419
,
e420
,
e421
,
e422
,
e423
,
e424
,
e425
,
e426
,
e427
,
e428
,
e429
,
e430
,
e431
,
e432
,
e433
,
e434
,
e435
,
e436
,
e437
,
e438
,
e439
,
e440
,
e441
,
e442
,
e443
,
e444
,
e445
,
e446
,
e447
,
e448
,
e449
,
e450
,
e451
,
e452
,
e453
,
e454
,
e455
,
e456
,
e457
,
e458
,
e459
,
e460
,
e461
,
e462
,
e463
,
e464
,
e465
,
e466
,
e467
,
e468
,
e469
,
e470
,
e471
,
e472
,
e473
,
e474
,
e475
,
e476
,
e477
,
e478
,
e479
,
e480
,
e481
,
e482
,
e483
,
e484
,
e485
,
e486
,
e487
,
e488
,
e489
,
e490
,
e491
,
e492
,
e493
,
e494
,
e495
,
e496
,
e497
,
e498
,
e499
}
enum
Specialized
{
FOO
{
public
void
foo
()
{}
};
abstract
public
void
foo
();
};
}
test/java/lang/reflect/Generics/Probe.java
浏览文件 @
a7cb2d41
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 5003916
* @bug 5003916
6704655
* @summary Testing parsing of signatures attributes of nested classes
* @author Joseph D. Darcy
* @compile -source 1.5 Probe.java
...
...
@@ -32,8 +32,10 @@
import
java.lang.reflect.*
;
import
java.lang.annotation.*
;
import
java.util.*
;
import
static
java
.
util
.
Arrays
.*;
@Classes
({
@Classes
(
value
=
{
"java.util.concurrent.FutureTask"
,
"java.util.concurrent.ConcurrentHashMap$EntryIterator"
,
"java.util.concurrent.ConcurrentHashMap$KeyIterator"
,
...
...
@@ -56,7 +58,9 @@ import java.lang.annotation.*;
"java.util.HashMap$ValueIterator"
,
"java.util.LinkedHashMap$EntryIterator"
,
"java.util.LinkedHashMap$KeyIterator"
,
"java.util.LinkedHashMap$ValueIterator"
,
"java.util.LinkedHashMap$ValueIterator"
},
sunClasses
={
"javax.crypto.SunJCE_c"
,
"javax.crypto.SunJCE_e"
,
"javax.crypto.SunJCE_f"
,
...
...
@@ -66,7 +70,15 @@ import java.lang.annotation.*;
})
public
class
Probe
{
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
String
[]
names
=
(
Probe
.
class
).
getAnnotation
(
Classes
.
class
).
value
();
Classes
classesAnnotation
=
(
Probe
.
class
).
getAnnotation
(
Classes
.
class
);
List
<
String
>
names
=
new
ArrayList
<
String
>(
asList
(
classesAnnotation
.
value
()));
if
(
System
.
getProperty
(
"java.runtime.name"
).
startsWith
(
"Java(TM)"
))
{
// Sun production JDK; test crypto classes too
for
(
String
name:
classesAnnotation
.
sunClasses
())
names
.
add
(
name
);
}
int
errs
=
0
;
for
(
String
name:
names
)
{
...
...
@@ -140,4 +152,5 @@ public class Probe {
@Retention
(
RetentionPolicy
.
RUNTIME
)
@interface
Classes
{
String
[]
value
();
// list of classes to probe
String
[]
sunClasses
();
// list of Sun-production JDK specific classes to probe
}
test/java/net/CookieHandler/TestHttpCookie.java
浏览文件 @
a7cb2d41
...
...
@@ -24,7 +24,7 @@
/**
* @test
* @summary Unit test for java.net.HttpCookie
* @bug 6244040 6277796 6277801 6277808 6294071 6692802
* @bug 6244040 6277796 6277801 6277808 6294071 6692802
6790677
* @author Edward Wang
*/
...
...
@@ -278,10 +278,6 @@ public class TestHttpCookie {
.
c
(
"this is a coyote"
).
cu
(
"http://www.coyote.org"
).
dsc
(
true
)
.
d
(
".coyote.org"
).
a
(
3600
).
port
(
"80"
);
// illegal characters in set-cookie header
test
(
"Set-Cookie2:Customer=;Version#=\"1\";Path=&\"/acme\""
)
.
nil
();
// empty set-cookie string
test
(
""
).
nil
();
...
...
@@ -311,6 +307,9 @@ public class TestHttpCookie {
test
(
"Set-Cookie2:C1=\"V1\";Domain=\".sun1.com\";path=\"/www1\";Max-Age=\"100\",C2=\"V2\";Domain=\".sun2.com\";path=\"/www2\";Max-Age=\"200\""
)
.
n
(
0
,
"C1"
).
v
(
0
,
"V1"
).
p
(
0
,
"/www1"
).
a
(
0
,
100
).
d
(
0
,
".sun1.com"
)
.
n
(
1
,
"C2"
).
v
(
1
,
"V2"
).
p
(
1
,
"/www2"
).
a
(
1
,
200
).
d
(
1
,
".sun2.com"
);
// Bug 6790677: Should ignore bogus attributes
test
(
"Set-Cookie2:C1=\"V1\";foobar"
).
n
(
0
,
"C1"
).
v
(
0
,
"V1"
);
}
static
void
netscape
()
{
...
...
test/java/net/URLClassLoader/closetest/CloseTest.java
0 → 100644
浏览文件 @
a7cb2d41
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 4167874
* @library ../../../../com/sun/net/httpserver
* @build FileServerHandler
* @run shell build.sh
* @run main/othervm CloseTest
* @summary URL-downloaded jar files can consume all available file descriptors
*/
import
java.io.*
;
import
java.net.*
;
import
java.lang.reflect.*
;
import
java.util.concurrent.*
;
import
com.sun.net.httpserver.*
;
public
class
CloseTest
{
static
void
copyFile
(
String
src
,
String
dst
)
{
copyFile
(
new
File
(
src
),
new
File
(
dst
));
}
static
void
copyDir
(
String
src
,
String
dst
)
{
copyDir
(
new
File
(
src
),
new
File
(
dst
));
}
static
void
copyFile
(
File
src
,
File
dst
)
{
try
{
if
(!
src
.
isFile
())
{
throw
new
RuntimeException
(
"File not found: "
+
src
.
toString
());
}
dst
.
delete
();
dst
.
createNewFile
();
FileInputStream
i
=
new
FileInputStream
(
src
);
FileOutputStream
o
=
new
FileOutputStream
(
dst
);
byte
[]
buf
=
new
byte
[
1024
];
int
count
;
while
((
count
=
i
.
read
(
buf
))
>=
0
)
{
o
.
write
(
buf
,
0
,
count
);
}
i
.
close
();
o
.
close
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
static
void
rm_minus_rf
(
File
path
)
{
if
(!
path
.
exists
())
{
return
;
}
if
(
path
.
isFile
())
{
if
(!
path
.
delete
())
{
throw
new
RuntimeException
(
"Could not delete "
+
path
);
}
}
else
if
(
path
.
isDirectory
())
{
String
[]
names
=
path
.
list
();
File
[]
files
=
path
.
listFiles
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
rm_minus_rf
(
new
File
(
path
,
names
[
i
]));
}
if
(!
path
.
delete
())
{
throw
new
RuntimeException
(
"Could not delete "
+
path
);
}
}
else
{
throw
new
RuntimeException
(
"Trying to delete something that isn't a file or a directory"
);
}
}
static
void
copyDir
(
File
src
,
File
dst
)
{
if
(!
src
.
isDirectory
())
{
throw
new
RuntimeException
(
"Dir not found: "
+
src
.
toString
());
}
if
(
dst
.
exists
())
{
throw
new
RuntimeException
(
"Dir exists: "
+
dst
.
toString
());
}
dst
.
mkdir
();
String
[]
names
=
src
.
list
();
File
[]
files
=
src
.
listFiles
();
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
String
f
=
names
[
i
];
if
(
files
[
i
].
isDirectory
())
{
copyDir
(
files
[
i
],
new
File
(
dst
,
f
));
}
else
{
copyFile
(
new
File
(
src
,
f
),
new
File
(
dst
,
f
));
}
assert
false
;
}
}
/* expect is true if you expect to find it, false if you expect not to */
static
Class
loadClass
(
String
name
,
URLClassLoader
loader
,
boolean
expect
){
try
{
Class
clazz
=
Class
.
forName
(
name
,
true
,
loader
);
if
(!
expect
)
{
throw
new
RuntimeException
(
"loadClass: "
+
name
+
" unexpected"
);
}
return
clazz
;
}
catch
(
ClassNotFoundException
e
)
{
if
(
expect
)
{
throw
new
RuntimeException
(
"loadClass: "
+
name
+
" not found"
);
}
}
return
null
;
}
//
// needs two jar files test1.jar and test2.jar with following structure
//
// com/foo/TestClass
// com/foo/TestClass1
// com/foo/Resource1
// com/foo/Resource2
//
// and a directory hierarchy with the same structure/contents
public
static
void
main
(
String
args
[])
throws
Exception
{
String
workdir
=
System
.
getProperty
(
"test.classes"
);
if
(
workdir
==
null
)
{
workdir
=
args
[
0
];
}
if
(!
workdir
.
endsWith
(
"/"
))
{
workdir
=
workdir
+
"/"
;
}
startHttpServer
(
workdir
+
"serverRoot/"
);
String
testjar
=
workdir
+
"test.jar"
;
copyFile
(
workdir
+
"test1.jar"
,
testjar
);
test
(
testjar
,
1
);
// repeat test with different implementation
// of test.jar (whose TestClass.getValue() returns 2
copyFile
(
workdir
+
"test2.jar"
,
testjar
);
test
(
testjar
,
2
);
// repeat test using a directory of files
String
testdir
=
workdir
+
"testdir/"
;
rm_minus_rf
(
new
File
(
testdir
));
copyDir
(
workdir
+
"test1/"
,
testdir
);
test
(
testdir
,
1
);
testdir
=
workdir
+
"testdir/"
;
rm_minus_rf
(
new
File
(
testdir
));
copyDir
(
workdir
+
"test2/"
,
testdir
);
test
(
testdir
,
2
);
getHttpServer
().
stop
(
3
);
}
// create a loader on jarfile (or directory), plus a http loader
// load a class , then look for a resource
// also load a class from http loader
// then close the loader
// check further new classes/resources cannot be loaded
// check jar (or dir) can be deleted
// check existing classes can be loaded
// check boot classes can be loaded
static
void
test
(
String
name
,
int
expectedValue
)
throws
Exception
{
URL
url
=
new
URL
(
"file"
,
null
,
name
);
URL
url2
=
getServerURL
();
System
.
out
.
println
(
"Doing tests with URL: "
+
url
+
" and "
+
url2
);
URL
[]
urls
=
new
URL
[
2
];
urls
[
0
]
=
url
;
urls
[
1
]
=
url2
;
URLClassLoader
loader
=
new
URLClassLoader
(
urls
);
Class
testclass
=
loadClass
(
"com.foo.TestClass"
,
loader
,
true
);
Class
class2
=
loadClass
(
"Test"
,
loader
,
true
);
// from http
class2
.
newInstance
();
Object
test
=
testclass
.
newInstance
();
Method
method
=
testclass
.
getDeclaredMethods
()[
0
];
// int getValue();
int
res
=
(
Integer
)
method
.
invoke
(
test
);
if
(
res
!=
expectedValue
)
{
throw
new
RuntimeException
(
"wrong value from getValue() ["
+
res
+
"/"
+
expectedValue
+
"]"
);
}
// should find /resource1
URL
u1
=
loader
.
findResource
(
"com/foo/Resource1"
);
if
(
u1
==
null
)
{
throw
new
RuntimeException
(
"can't find com/foo/Resource1 in test1.jar"
);
}
loader
.
close
();
// should NOT find /resource2 even though it is in jar
URL
u2
=
loader
.
findResource
(
"com/foo/Resource2"
);
if
(
u2
!=
null
)
{
throw
new
RuntimeException
(
"com/foo/Resource2 unexpected in test1.jar"
);
}
// load tests
loadClass
(
"com.foo.TestClass1"
,
loader
,
false
);
loadClass
(
"com.foo.TestClass"
,
loader
,
true
);
loadClass
(
"java.awt.Button"
,
loader
,
true
);
// now check we can delete the path
rm_minus_rf
(
new
File
(
name
));
System
.
out
.
println
(
" ... OK"
);
}
static
HttpServer
httpServer
;
static
HttpServer
getHttpServer
()
{
return
httpServer
;
}
static
URL
getServerURL
()
throws
Exception
{
int
port
=
httpServer
.
getAddress
().
getPort
();
String
s
=
"http://127.0.0.1:"
+
port
+
"/"
;
return
new
URL
(
s
);
}
static
void
startHttpServer
(
String
docroot
)
throws
Exception
{
httpServer
=
HttpServer
.
create
(
new
InetSocketAddress
(
0
),
10
);
HttpContext
ctx
=
httpServer
.
createContext
(
"/"
,
new
FileServerHandler
(
docroot
)
);
httpServer
.
start
();
}
}
test/java/net/URLClassLoader/closetest/README
0 → 100644
浏览文件 @
a7cb2d41
test1 and test2 contain two different implementations of the same
classes. They are compiled and placed into two different target directories
and two jar files test1.jar and test2.jar.
The same class is in both jars/directories, but returns a different result
from the TestClass.getValue() method. The test does the following
1. copy test1.jar to a working directory and call it test.jar
2. load class and invoke method (checking result)
3. close the loader
4. delete test.jar (check delete succeeds)
5. copy test2.jar to same dir and repeat the test
6. The two tests are then repeated by copying the directories
test1 and test2.
The loader also includes a http:// URL in its search path and a http
server is used to serve the required class.
serverRoot is used as the root directory for the http server.
test/java/net/URLClassLoader/closetest/build.sh
0 → 100644
浏览文件 @
a7cb2d41
#!/bin/sh
#
# Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#
#
# This script builds the test files for the test
# but not the actual test sources themselves.
#
if
[
"
${
TESTSRC
}
"
=
""
]
then
echo
"TESTSRC not set. Test cannot execute. Failed."
exit
1
fi
echo
"TESTSRC=
${
TESTSRC
}
"
if
[
"
${
TESTJAVA
}
"
=
""
]
then
echo
"TESTJAVA not set. Test cannot execute. Failed."
exit
1
fi
echo
"TESTJAVA=
${
TESTJAVA
}
"
if
[
"
${
TESTCLASSES
}
"
=
""
]
then
echo
"TESTCLASSES not set. Test cannot execute. Failed."
exit
1
fi
JAVAC
=
"
${
TESTJAVA
}
/bin/javac"
JAR
=
"
${
TESTJAVA
}
/bin/jar"
rm
-rf
${
TESTCLASSES
}
/test1
rm
-rf
${
TESTCLASSES
}
/test2
rm
-rf
${
TESTCLASSES
}
/serverRoot
mkdir
-p
${
TESTCLASSES
}
/test1/com/foo
mkdir
-p
${
TESTCLASSES
}
/test2/com/foo
mkdir
-p
${
TESTCLASSES
}
/serverRoot
cd
${
TESTSRC
}
/test1/com/foo
cp
*
${
TESTCLASSES
}
/test1/com/foo
cd
${
TESTCLASSES
}
/test1
${
JAVAC
}
com/foo/
*
.java
${
JAR
}
cvf ../test1.jar com/foo/
*
.class com/foo/Resource
*
cd
${
TESTSRC
}
/test2/com/foo
cp
*
${
TESTCLASSES
}
/test2/com/foo
cd
${
TESTCLASSES
}
/test2
${
JAVAC
}
com/foo/
*
.java
${
JAR
}
cvf ../test2.jar com/foo/
*
.class com/foo/Resource
*
cp
${
TESTSRC
}
/serverRoot/Test.java
${
TESTCLASSES
}
/serverRoot
cd
${
TESTCLASSES
}
/serverRoot
${
JAVAC
}
Test.java
test/java/net/URLClassLoader/closetest/serverRoot/Test.java
0 → 100644
浏览文件 @
a7cb2d41
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
public
class
Test
{
public
Test
()
{
System
.
out
.
println
(
"Test created"
);
}
}
test/java/net/URLClassLoader/closetest/test1/com/foo/Resource1
0 → 100644
浏览文件 @
a7cb2d41
Hello World
test/java/net/URLClassLoader/closetest/test1/com/foo/Resource2
0 → 100644
浏览文件 @
a7cb2d41
Hello World Again
test/java/net/URLClassLoader/closetest/test1/com/foo/TestClass.java
0 → 100644
浏览文件 @
a7cb2d41
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
com.foo
;
public
class
TestClass
{
public
int
getValue
()
{
return
1
;
}
}
/*
public class TestClass {
public int getValue () {
return 2;
}
}
*/
test/java/net/URLClassLoader/closetest/test1/com/foo/TestClass1.java
0 → 100644
浏览文件 @
a7cb2d41
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
com.foo
;
public
class
TestClass1
{}
test/java/net/URLClassLoader/closetest/test2/com/foo/Resource1
0 → 100644
浏览文件 @
a7cb2d41
Hello World
test/java/net/URLClassLoader/closetest/test2/com/foo/Resource2
0 → 100644
浏览文件 @
a7cb2d41
Hello World Again
test/java/net/URLClassLoader/closetest/test2/com/foo/TestClass.java
0 → 100644
浏览文件 @
a7cb2d41
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
com.foo
;
/*
public class TestClass {
public int getValue () {
return 1;
}
}
*/
public
class
TestClass
{
public
int
getValue
()
{
return
2
;
}
}
test/java/net/URLClassLoader/closetest/test2/com/foo/TestClass1.java
0 → 100644
浏览文件 @
a7cb2d41
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
com.foo
;
public
class
TestClass1
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录