From 285d905e09d5f1dfeecad8270894e293848e5238 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Collet Date: Tue, 27 Jan 2009 11:36:28 +0100 Subject: [PATCH 01/10] 6790677: java.net.HttpCookie.parse(String) should ignore unrecognized attributes, RFC2965 Changed code not to throw an exception on unknown attributes Reviewed-by: chegar --- jdk/src/share/classes/java/net/HttpCookie.java | 3 +-- jdk/test/java/net/CookieHandler/TestHttpCookie.java | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/java/net/HttpCookie.java b/jdk/src/share/classes/java/net/HttpCookie.java index 1fcdd6c51da..85705543411 100644 --- a/jdk/src/share/classes/java/net/HttpCookie.java +++ b/jdk/src/share/classes/java/net/HttpCookie.java @@ -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 } } diff --git a/jdk/test/java/net/CookieHandler/TestHttpCookie.java b/jdk/test/java/net/CookieHandler/TestHttpCookie.java index 43d5484e27c..f1f89f8daab 100644 --- a/jdk/test/java/net/CookieHandler/TestHttpCookie.java +++ b/jdk/test/java/net/CookieHandler/TestHttpCookie.java @@ -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() { From 0c3562796059b4146a3daf15288868769a6b53a8 Mon Sep 17 00:00:00 2001 From: Jeremy Manson Date: Tue, 27 Jan 2009 15:04:30 -0800 Subject: [PATCH 02/10] 6797480: Remove synchronization bottleneck in logger Reviewed-by: swamyv --- .../classes/java/util/logging/Logger.java | 61 ++++++++----------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/jdk/src/share/classes/java/util/logging/Logger.java b/jdk/src/share/classes/java/util/logging/Logger.java index 155db02d9f1..28f942a0f2a 100644 --- a/jdk/src/share/classes/java/util/logging/Logger.java +++ b/jdk/src/share/classes/java/util/logging/Logger.java @@ -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 handlers; + private final CopyOnWriteArrayList handlers = + new CopyOnWriteArrayList(); 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> 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,10 +467,9 @@ public class Logger { if (record.getLevel().intValue() < levelValue || levelValue == offValue) { return; } - synchronized (this) { - if (filter != null && !filter.isLoggable(record)) { - return; - } + Filter theFilter = filter; + if (theFilter != null && !theFilter.isLoggable(record)) { + return; } // Post the LogRecord to all our Handlers, and then to @@ -476,12 +477,8 @@ public class Logger { 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(); - } 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 { *

* @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,9 +1342,12 @@ public class Logger { * @return nearest existing parent Logger */ public Logger getParent() { - synchronized (treeLock) { - return parent; - } + // 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; } /** From 79ec4bf8d376ca3bdf5318882e88a875be788758 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 28 Jan 2009 10:30:33 -0800 Subject: [PATCH 03/10] 6704655: Test test/java/lang/reflect/Generics/Probe.java fails under OpenJDK Reviewed-by: ksrini --- .../java/lang/reflect/Generics/Probe.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/lang/reflect/Generics/Probe.java b/jdk/test/java/lang/reflect/Generics/Probe.java index 79628a30bf6..30d6f21e5a3 100644 --- a/jdk/test/java/lang/reflect/Generics/Probe.java +++ b/jdk/test/java/lang/reflect/Generics/Probe.java @@ -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 names = + new ArrayList(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 } From 2f243ad8744dc8e85f218bfd747d1ea6c33c9550 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 28 Jan 2009 12:46:43 -0800 Subject: [PATCH 04/10] 6719182: update legal notice in java/lang/instrument/package.html Reviewed-by: jjh --- .../classes/java/lang/instrument/package.html | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jdk/src/share/classes/java/lang/instrument/package.html b/jdk/src/share/classes/java/lang/instrument/package.html index dde4dfd7ecd..f2835598f9e 100644 --- a/jdk/src/share/classes/java/lang/instrument/package.html +++ b/jdk/src/share/classes/java/lang/instrument/package.html @@ -1,3 +1,28 @@ + + From 40754a992428d023384977acaf0b160d349d815e Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Wed, 28 Jan 2009 14:13:37 -0800 Subject: [PATCH 05/10] 6798822: (process) Non-portable use of isdigit in src/solaris/native/java/lang/UNIXProcess_md.c Reviewed-by: alanb --- jdk/src/solaris/native/java/lang/UNIXProcess_md.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c index 8390a2baad5..9cfe22a1f16 100644 --- a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c +++ b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c @@ -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 (isdigit(dirp->d_name[0]) && + if (isAsciiDigit(dirp->d_name[0]) && (fd = strtol(dirp->d_name, NULL, 10)) >= from_fd + 2) close(fd); } From 3f450f06e269de09333630070cbde0d7e436cb32 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Thu, 29 Jan 2009 09:04:41 -0800 Subject: [PATCH 06/10] 6239194: Object.hashCode() should reference System.identityHashCode() Reviewed-by: emcmanus --- jdk/src/share/classes/java/lang/Object.java | 192 ++++++++++---------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/jdk/src/share/classes/java/lang/Object.java b/jdk/src/share/classes/java/lang/Object.java index d3a08de90aa..deb0e27a6c7 100644 --- a/jdk/src/share/classes/java/lang/Object.java +++ b/jdk/src/share/classes/java/lang/Object.java @@ -26,8 +26,8 @@ package java.lang; /** - * Class Object is the root of the class hierarchy. - * Every class has Object 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 - * java.util.Hashtable. + * supported for the benefit of hash tables such as those provided by + * {@link java.util.HashMap}. *

- * The general contract of hashCode is: + * The general contract of {@code hashCode} is: *

    *
  • Whenever it is invoked on the same object more than once during - * an execution of a Java application, the hashCode method + * an execution of a Java application, the {@code hashCode} method * must consistently return the same integer, provided no information - * used in equals 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. - *
  • If two objects are equal according to the equals(Object) - * method, then calling the hashCode method on each of + *
  • 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. *
  • It is not required that if two objects are unequal * according to the {@link java.lang.Object#equals(java.lang.Object)} - * method, then calling the hashCode 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. *
*

* As much as is reasonably practical, the hashCode method defined by - * class Object 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.Hashtable + * @see java.lang.System#identityHashCode */ public native int hashCode(); /** * Indicates whether some other object is "equal to" this one. *

- * The equals method implements an equivalence relation + * The {@code equals} method implements an equivalence relation * on non-null object references: *

    *
  • It is reflexive: for any non-null reference value - * x, x.equals(x) should return - * true. + * {@code x}, {@code x.equals(x)} should return + * {@code true}. *
  • It is symmetric: for any non-null reference values - * x and y, x.equals(y) - * should return true if and only if - * y.equals(x) returns true. + * {@code x} and {@code y}, {@code x.equals(y)} + * should return {@code true} if and only if + * {@code y.equals(x)} returns {@code true}. *
  • It is transitive: for any non-null reference values - * x, y, and z, if - * x.equals(y) returns true and - * y.equals(z) returns true, then - * x.equals(z) should return true. + * {@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}. *
  • It is consistent: for any non-null reference values - * x and y, multiple invocations of - * x.equals(y) consistently return true - * or consistently return false, provided no - * information used in equals 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. - *
  • For any non-null reference value x, - * x.equals(null) should return false. + *
  • For any non-null reference value {@code x}, + * {@code x.equals(null)} should return {@code false}. *
*

- * The equals method for class Object 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 x and - * y, this method returns true if and only - * if x and y refer to the same object - * (x == y has the value true). + * 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}). *

- * Note that it is generally necessary to override the hashCode + * 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 hashCode 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 true if this object is the same as the obj - * argument; false otherwise. + * @return {@code true} if this object is the same as the obj + * argument; {@code false} otherwise. * @see #hashCode() - * @see java.util.Hashtable + * @see java.util.HashMap */ 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 x, the expression: + * intent is that, for any object {@code x}, the expression: *

*
      * x.clone() != x
@@ -162,49 +162,49 @@ public class Object { *
*
      * x.clone().getClass() == x.getClass()
- * will be true, but these are not absolute requirements. + * will be {@code true}, but these are not absolute requirements. * While it is typically the case that: *
*
      * x.clone().equals(x)
- * will be true, this is not an absolute requirement. + * will be {@code true}, this is not an absolute requirement. *

* By convention, the returned object should be obtained by calling - * super.clone. If a class and all of its superclasses (except - * Object) obey this convention, it will be the case that - * x.clone().getClass() == x.getClass(). + * {@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()}. *

* 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 super.clone 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 super.clone + * the case that no fields in the object returned by {@code super.clone} * need to be modified. *

- * The method clone for class Object 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 Cloneable, then a - * CloneNotSupportedException is thrown. Note that all arrays - * are considered to implement the interface Cloneable. + * 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. *

- * The class Object does not itself implement the interface - * Cloneable, so calling the clone method on an object - * whose class is Object 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 Cloneable interface. Subclasses - * that override the clone 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 - * toString 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. *

- * The toString method for class Object + * 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 `@', 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 wait methods. + * monitor by calling one of the {@code wait} methods. *

* 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: *

    *
  • By executing a synchronized instance method of that object. - *
  • By executing the body of a synchronized statement + *
  • By executing the body of a {@code synchronized} statement * that synchronizes on the object. - *
  • For objects of type Class, by executing a + *
  • For objects of type {@code Class,} by executing a * synchronized static method of that class. *
*

@@ -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 - * wait methods. + * {@code wait} methods. *

* 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. *

* This method should only be called by a thread that is the owner - * of this object's monitor. See the notify 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: *

    - *
  • Some other thread invokes the notify method for this + *
  • Some other thread invokes the {@code notify} method for this * object and thread T happens to be arbitrarily chosen as * the thread to be awakened. - *
  • Some other thread invokes the notifyAll method for this + *
  • Some other thread invokes the {@code notifyAll} method for this * object. *
  • Some other thread {@linkplain Thread#interrupt() interrupts} * thread T. *
  • The specified amount of real time has elapsed, more or less. If - * timeout 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. *
* The thread T 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 wait + * ante - that is, to the situation as of the time that the {@code wait} * method was invoked. Thread T then returns from the - * invocation of the wait method. Thus, on return from the - * wait method, the synchronization state of the object and of - * thread T is exactly as it was when the wait 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. *

* A thread can also wake up without being notified, interrupted, or @@ -351,18 +351,18 @@ public class Object { * *

If the current thread is {@linkplain java.lang.Thread#interrupt() * interrupted} by any thread before or while it is waiting, then an - * InterruptedException 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. * *

- * Note that the wait 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. *

* This method should only be called by a thread that is the owner - * of this object's monitor. See the notify 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. *

- * This method is similar to the wait 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 { *

* In all other respects, this method does the same thing as the * method {@link #wait(long)} of one argument. In particular, - * wait(0, 0) means the same thing as wait(0). + * {@code wait(0, 0)} means the same thing as {@code wait(0)}. *

* 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: *

    *
  • Another thread notifies threads waiting on this object's monitor - * to wake up either through a call to the notify method - * or the notifyAll method. - *
  • The timeout period, specified by timeout - * milliseconds plus nanos nanoseconds arguments, has + * to wake up either through a call to the {@code notify} method + * or the {@code notifyAll} method. + *
  • The timeout period, specified by {@code timeout} + * milliseconds plus {@code nanos} nanoseconds arguments, has * elapsed. *
*

@@ -425,7 +425,7 @@ public class Object { * } * * This method should only be called by a thread that is the owner - * of this object's monitor. See the notify 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 wait(0). + * performs the call {@code wait(0)}. *

* 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 notify method or the - * notifyAll 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. *

* As in the one argument version, interrupts and spurious wakeups are @@ -484,7 +484,7 @@ public class Object { * } * * This method should only be called by a thread that is the owner - * of this object's monitor. See the notify 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 finalize method to dispose of + * A subclass overrides the {@code finalize} method to dispose of * system resources or to perform other cleanup. *

- * The general contract of finalize is that it is invoked + * The general contract of {@code finalize} is that it is invoked * if and when the JavaTM 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 finalize 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 finalize, 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. *

- * The finalize method of class Object performs no + * The {@code finalize} method of class {@code Object} performs no * special action; it simply returns normally. Subclasses of - * Object may override this definition. + * {@code Object} may override this definition. *

* The Java programming language does not guarantee which thread will - * invoke the finalize 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. *

- * After the finalize 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. *

- * The finalize 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. *

- * Any exception thrown by the finalize 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 Exception raised by this method + * @throws Throwable the {@code Exception} raised by this method */ protected void finalize() throws Throwable { } } From 0476ba59fbbf4bc5939e2858500bfae26538edd8 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Thu, 29 Jan 2009 13:04:44 -0800 Subject: [PATCH 07/10] 6327048: Enum javadoc could link to JLS 6653154: Exception message for bad Enum.valueOf has spurious "class" Reviewed-by: emcmanus --- jdk/src/share/classes/java/lang/Enum.java | 13 +- .../java/lang/annotation/Annotation.java | 6 +- jdk/test/java/lang/Enum/ValueOf.java | 224 ++++++++++++++++++ 3 files changed, 238 insertions(+), 5 deletions(-) create mode 100644 jdk/test/java/lang/Enum/ValueOf.java diff --git a/jdk/src/share/classes/java/lang/Enum.java b/jdk/src/share/classes/java/lang/Enum.java index 175b4021f59..e5f50f58793 100644 --- a/jdk/src/share/classes/java/lang/Enum.java +++ b/jdk/src/share/classes/java/lang/Enum.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-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 @@ -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 The Java™ Language + * Specification, Third Edition, §8.9. + * * @author Josh Bloch * @author Neal Gafter * @see Class#getEnumConstants() @@ -212,7 +217,7 @@ public abstract class Enum> if (name == null) throw new NullPointerException("Name is null"); throw new IllegalArgumentException( - "No enum const " + enumType +"." + name); + "No enum constant " + enumType.getCanonicalName() + "." + name); } /** @@ -225,10 +230,10 @@ public abstract class Enum> */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - throw new InvalidObjectException("can't deserialize enum"); + throw new InvalidObjectException("can't deserialize enum"); } private void readObjectNoData() throws ObjectStreamException { - throw new InvalidObjectException("can't deserialize enum"); + throw new InvalidObjectException("can't deserialize enum"); } } diff --git a/jdk/src/share/classes/java/lang/annotation/Annotation.java b/jdk/src/share/classes/java/lang/annotation/Annotation.java index b8f9c89f080..6b4dcdf4eea 100644 --- a/jdk/src/share/classes/java/lang/annotation/Annotation.java +++ b/jdk/src/share/classes/java/lang/annotation/Annotation.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-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 @@ -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 The + * Java™ Language Specification, Third Edition, §9.6. + * * @author Josh Bloch * @since 1.5 */ diff --git a/jdk/test/java/lang/Enum/ValueOf.java b/jdk/test/java/lang/Enum/ValueOf.java new file mode 100644 index 00000000000..6af4a9fd8e9 --- /dev/null +++ b/jdk/test/java/lang/Enum/ValueOf.java @@ -0,0 +1,224 @@ +/* + * 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 > void test(Class enumClass) throws Exception { + Set s = EnumSet.allOf(enumClass); + test(enumClass, s); + + // Delete half the elements from set at random + for (Iterator i = s.iterator(); i.hasNext(); ) { + i.next(); + if (rnd.nextBoolean()) + i.remove(); + } + + test(enumClass, s); + } + + static > void test(Class enumClass, Set s) + throws Exception + { + Method valueOf = enumClass.getDeclaredMethod("valueOf", String.class); + Set 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(); + }; + +} From 2b84dc567f09db062d3f0cab8a7e9e626ae758f8 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 30 Jan 2009 12:40:27 -0800 Subject: [PATCH 08/10] 6799343: (fmt) java.util.Formatter uses plainlink instead of linkplain Reviewed-by: alanb --- .../share/classes/java/util/Formatter.java | 892 +++++++++--------- 1 file changed, 446 insertions(+), 446 deletions(-) diff --git a/jdk/src/share/classes/java/util/Formatter.java b/jdk/src/share/classes/java/util/Formatter.java index 5100adbd27c..eb49ec9c5da 100644 --- a/jdk/src/share/classes/java/util/Formatter.java +++ b/jdk/src/share/classes/java/util/Formatter.java @@ -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 - * byte, {@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. * *

Formatted printing for the Java language is heavily inspired by C's - * printf. 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" * * - *

Like C's sprintf(3), Strings may be formatted using the static + *

Like C's {@code sprintf(3)}, Strings may be formatted using the static * method {@link String#format(String,Object...) String.format}: * *

@@ -157,16 +157,16 @@ import sun.misc.FormattedFloatingDecimal;
  *   String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c);
  * 
* - * This format string is the first argument to the format method. It - * contains three format specifiers "%1$tm", "%1$te", and - * "%1$tY" 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 "Dukes Birthday: " 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 c. + * consists of the {@link java.util.Calendar Calendar} object {@code c}. * *
    * @@ -179,7 +179,7 @@ import sun.misc.FormattedFloatingDecimal; * *

    The optional argument_index is a decimal integer indicating the * position of the argument in the argument list. The first argument is - * referenced by "1$", the second by "2$", etc. + * referenced by "{@code 1$}", the second by "{@code 2$}", etc. * *

    The optional flags 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. * *

    The required conversion is a two character sequence. The first - * character is 't' or 'T'. 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 date and POSIX - * strftime(3c). + * identical to those defined by GNU {@code date} and POSIX + * {@code strftime(3c)}. * *

  • The format specifiers which do not correspond to arguments have the * following syntax: @@ -235,31 +235,31 @@ import sun.misc.FormattedFloatingDecimal; * type * *
  • Character - may be applied to basic types which represent - * Unicode characters: char, {@link Character}, byte, {@link - * Byte}, short, and {@link Short}. This conversion may also be - * applied to the types int and {@link Integer} when {@link - * Character#isValidCodePoint} returns true + * 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} * *
  • Numeric * *
      * - *
    1. Integral - may be applied to Java integral types: byte, - * {@link Byte}, short, {@link Short}, int and {@link - * Integer}, long, {@link Long}, and {@link java.math.BigInteger + *
    2. Integral - 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} * *
    3. Floating Point - may be applied to Java floating-point types: - * float, {@link Float}, double, {@link Double}, and {@link + * {@code float}, {@link Float}, {@code double}, {@link Double}, and {@link * java.math.BigDecimal BigDecimal} * *
    * *
  • Date/Time - may be applied to Java types which are capable of - * encoding a date or time: long, {@link Long}, {@link Calendar}, and + * encoding a date or time: {@code long}, {@link Long}, {@link Calendar}, and * {@link Date}. * - *
  • Percent - produces a literal '%' + *
  • Percent - produces a literal {@code '%'} * ('\u0025') * *
  • Line Separator - produces the platform-specific line separator @@ -267,9 +267,9 @@ import sun.misc.FormattedFloatingDecimal; * * *

    The following table summarizes the supported conversions. Conversions - * denoted by an upper-case character (i.e. 'B', 'H', - * 'S', 'C', 'X', 'E', 'G', - * 'A', and 'T') 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; * Argument Category * Description * - * 'b', 'B' + * {@code 'b'}, {@code 'B'} * general - * If the argument arg is null, then the result is - * "false". If arg is a boolean or {@link + * If the argument arg is {@code null}, then the result is + * "{@code false}". If arg 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". * - * 'h', 'H' + * {@code 'h'}, {@code 'H'} * general - * If the argument arg is null, then the result is - * "null". Otherwise, the result is obtained by invoking - * Integer.toHexString(arg.hashCode()). + * If the argument arg is {@code null}, then the result is + * "{@code null}". Otherwise, the result is obtained by invoking + * {@code Integer.toHexString(arg.hashCode())}. * - * 's', 'S' + * {@code 's'}, {@code 'S'} * general - * If the argument arg is null, then the result is - * "null". If arg implements {@link Formattable}, then + * If the argument arg is {@code null}, then the result is + * "{@code null}". If arg implements {@link Formattable}, then * {@link Formattable#formatTo arg.formatTo} is invoked. Otherwise, the - * result is obtained by invoking arg.toString(). + * result is obtained by invoking {@code arg.toString()}. * - * 'c', 'C' + * {@code 'c'}, {@code 'C'} * character * The result is a Unicode character * - * 'd' + * {@code 'd'} * integral * The result is formatted as a decimal integer * - * 'o' + * {@code 'o'} * integral * The result is formatted as an octal integer * - * 'x', 'X' + * {@code 'x'}, {@code 'X'} * integral * The result is formatted as a hexadecimal integer * - * 'e', 'E' + * {@code 'e'}, {@code 'E'} * floating point * The result is formatted as a decimal number in computerized * scientific notation * - * 'f' + * {@code 'f'} * floating point * The result is formatted as a decimal number * - * 'g', 'G' + * {@code 'g'}, {@code 'G'} * floating point * The result is formatted using computerized scientific notation or * decimal format, depending on the precision and the value after rounding. * - * 'a', 'A' + * {@code 'a'}, {@code 'A'} * floating point * The result is formatted as a hexadecimal floating-point number with * a significand and an exponent * - * 't', 'T' + * {@code 't'}, {@code 'T'} * date/time * Prefix for date and time conversion characters. See Date/Time Conversions. * - * '%' + * {@code '%'} * percent - * The result is a literal '%' ('\u0025') + * The result is a literal {@code '%'} ('\u0025') * - * 'n' + * {@code 'n'} * line separator * The result is the platform-specific line separator * @@ -361,78 +361,78 @@ import sun.misc.FormattedFloatingDecimal; *

    Date/Time Conversions

    * *

    The following date and time conversion suffix characters are defined for - * the 't' and 'T' conversions. The types are similar to but - * not completely identical to those defined by GNU date and POSIX - * strftime(3c). Additional conversion types are provided to access - * Java-specific functionality (e.g. 'L' 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). * *

    The following conversion characters are used for formatting times: * * * - *
    'H' + *
    {@code 'H'} * Hour of the day for the 24-hour clock, formatted as two digits with - * a leading zero as necessary i.e. 00 - 23. + * a leading zero as necessary i.e. {@code 00 - 23}. * - *
    'I' + *
    {@code 'I'} * Hour for the 12-hour clock, formatted as two digits with a leading - * zero as necessary, i.e. 01 - 12. + * zero as necessary, i.e. {@code 01 - 12}. * - *
    'k' - * Hour of the day for the 24-hour clock, i.e. 0 - 23. + *
    {@code 'k'} + * Hour of the day for the 24-hour clock, i.e. {@code 0 - 23}. * - *
    'l' - * Hour for the 12-hour clock, i.e. 1 - 12. + *
    {@code 'l'} + * Hour for the 12-hour clock, i.e. {@code 1 - 12}. * - *
    'M' + *
    {@code 'M'} * Minute within the hour formatted as two digits with a leading zero - * as necessary, i.e. 00 - 59. + * as necessary, i.e. {@code 00 - 59}. * - *
    'S' + *
    {@code 'S'} * Seconds within the minute, formatted as two digits with a leading - * zero as necessary, i.e. 00 - 60 ("60" is a special + * zero as necessary, i.e. {@code 00 - 60} ("{@code 60}" is a special * value required to support leap seconds). * - *
    'L' + *
    {@code 'L'} * Millisecond within the second formatted as three digits with - * leading zeros as necessary, i.e. 000 - 999. + * leading zeros as necessary, i.e. {@code 000 - 999}. * - *
    'N' + *
    {@code 'N'} * Nanosecond within the second, formatted as nine digits with leading - * zeros as necessary, i.e. 000000000 - 999999999. + * zeros as necessary, i.e. {@code 000000000 - 999999999}. * - *
    'p' + *
    {@code 'p'} * Locale-specific {@linkplain * java.text.DateFormatSymbols#getAmPmStrings morning or afternoon} marker - * in lower case, e.g."am" or "pm". Use of the conversion - * prefix 'T' 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. * - *
    'z' + *
    {@code 'z'} * RFC 822 - * style numeric time zone offset from GMT, e.g. -0800. This + * style numeric time zone offset from GMT, e.g. {@code -0800}. This * value will be adjusted as necessary for Daylight Saving Time. For - * long, {@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. * - *
    'Z' + *
    {@code 'Z'} * A string representing the abbreviation for the time zone. This * value will be adjusted as necessary for Daylight Saving Time. For - * long, {@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). * - *
    's' + *
    {@code 's'} * Seconds since the beginning of the epoch starting at 1 January 1970 - * 00:00:00 UTC, i.e. Long.MIN_VALUE/1000 to - * Long.MAX_VALUE/1000. + * {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE/1000} to + * {@code Long.MAX_VALUE/1000}. * - *
    'Q' + *
    {@code 'Q'} * Milliseconds since the beginning of the epoch starting at 1 January - * 1970 00:00:00 UTC, i.e. Long.MIN_VALUE to - * Long.MAX_VALUE. + * 1970 {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE} to + * {@code Long.MAX_VALUE}. * *
    * @@ -440,55 +440,55 @@ import sun.misc.FormattedFloatingDecimal; * * * - *
    'B' + *
    {@code 'B'} * Locale-specific {@linkplain java.text.DateFormatSymbols#getMonths - * full month name}, e.g. "January", "February". + * full month name}, e.g. {@code "January"}, {@code "February"}. * - *
    'b' + *
    {@code 'b'} * Locale-specific {@linkplain * java.text.DateFormatSymbols#getShortMonths abbreviated month name}, - * e.g. "Jan", "Feb". + * e.g. {@code "Jan"}, {@code "Feb"}. * - *
    'h' - * Same as 'b'. + *
    {@code 'h'} + * Same as {@code 'b'}. * - *
    'A' + *
    {@code 'A'} * Locale-specific full name of the {@linkplain * java.text.DateFormatSymbols#getWeekdays day of the week}, - * e.g. "Sunday", "Monday" + * e.g. {@code "Sunday"}, {@code "Monday"} * - *
    'a' + *
    {@code 'a'} * Locale-specific short name of the {@linkplain * java.text.DateFormatSymbols#getShortWeekdays day of the week}, - * e.g. "Sun", "Mon" + * e.g. {@code "Sun"}, {@code "Mon"} * - *
    'C' - * Four-digit year divided by 100, formatted as two digits - * with leading zero as necessary, i.e. 00 - 99 + *
    {@code 'C'} + * Four-digit year divided by {@code 100}, formatted as two digits + * with leading zero as necessary, i.e. {@code 00 - 99} * - *
    'Y' + *
    {@code 'Y'} * Year, formatted as at least four digits with leading zeros as - * necessary, e.g. 0092 equals 92 CE for the Gregorian + * necessary, e.g. {@code 0092} equals {@code 92} CE for the Gregorian * calendar. * - *
    'y' + *
    {@code 'y'} * Last two digits of the year, formatted with leading zeros as - * necessary, i.e. 00 - 99. + * necessary, i.e. {@code 00 - 99}. * - *
    'j' + *
    {@code 'j'} * Day of year, formatted as three digits with leading zeros as - * necessary, e.g. 001 - 366 for the Gregorian calendar. + * necessary, e.g. {@code 001 - 366} for the Gregorian calendar. * - *
    'm' + *
    {@code 'm'} * Month, formatted as two digits with leading zeros as necessary, - * i.e. 01 - 13. + * i.e. {@code 01 - 13}. * - *
    'd' + *
    {@code 'd'} * Day of month, formatted as two digits with leading zeros as - * necessary, i.e. 01 - 31 + * necessary, i.e. {@code 01 - 31} * - *
    'e' - * Day of month, formatted as two digits, i.e. 1 - 31. + *
    {@code 'e'} + * Day of month, formatted as two digits, i.e. {@code 1 - 31}. * *
    * @@ -497,27 +497,27 @@ import sun.misc.FormattedFloatingDecimal; * * * - *
    'R' - * Time formatted for the 24-hour clock as "%tH:%tM" + *
    {@code 'R'} + * Time formatted for the 24-hour clock as {@code "%tH:%tM"} * - *
    'T' - * Time formatted for the 24-hour clock as "%tH:%tM:%tS". + *
    {@code 'T'} + * Time formatted for the 24-hour clock as {@code "%tH:%tM:%tS"}. * - *
    'r' - * Time formatted for the 12-hour clock as "%tI:%tM:%tS %Tp". - * The location of the morning or afternoon marker ('%Tp') may be + *
    {@code 'r'} + * 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. * - *
    'D' - * Date formatted as "%tm/%td/%ty". + *
    {@code 'D'} + * Date formatted as {@code "%tm/%td/%ty"}. * - *
    'F' + *
    {@code 'F'} * ISO 8601 - * complete date formatted as "%tY-%tm-%td". + * complete date formatted as {@code "%tY-%tm-%td"}. * - *
    'c' - * Date and time formatted as "%ta %tb %td %tT %tZ %tY", - * e.g. "Sun Jul 20 16:17:00 EDT 1969". + *
    {@code 'c'} + * Date and time formatted as {@code "%ta %tb %td %tT %tZ %tY"}, + * e.g. {@code "Sun Jul 20 16:17:00 EDT 1969"}. * *
    * @@ -591,18 +591,18 @@ import sun.misc.FormattedFloatingDecimal; * *

    1 Depends on the definition of {@link Formattable}. * - *

    2 For 'd' conversion only. + *

    2 For {@code 'd'} conversion only. * - *

    3 For 'o', 'x', and 'X' + *

    3 For {@code 'o'}, {@code 'x'}, and {@code 'X'} * conversions only. * - *

    4 For 'd', 'o', 'x', and - * 'X' conversions applied to {@link java.math.BigInteger BigInteger} - * or 'd' applied to byte, {@link Byte}, short, {@link - * Short}, int and {@link Integer}, long, and {@link Long}. + *

    4 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}. * - *

    5 For 'e', 'E', 'f', - * 'g', and 'G' conversions only. + *

    5 For {@code 'e'}, {@code 'E'}, {@code 'f'}, + * {@code 'g'}, and {@code 'G'} conversions only. * *

    Any characters not explicitly defined as flags are illegal and are * reserved for future extensions. @@ -618,11 +618,11 @@ import sun.misc.FormattedFloatingDecimal; *

    For general argument types, the precision is the maximum number of * characters to be written to the output. * - *

    For the floating-point conversions 'e', 'E', and - * 'f' the precision is the number of digits after the decimal - * separator. If the conversion is 'g' or 'G', then the + *

    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 'a' or 'A', then the + * rounding. If the conversion is {@code 'a'} or {@code 'A'}, then the * precision must not be specified. * *

    For character, integral, and date/time argument types and the percent @@ -633,10 +633,10 @@ import sun.misc.FormattedFloatingDecimal; * *

    The argument index is a decimal integer indicating the position of the * argument in the argument list. The first argument is referenced by - * "1$", the second by "2$", etc. + * "{@code 1$}", the second by "{@code 2$}", etc. * *

    Another way to reference arguments by position is to use the - * '<' ('\u003c') flag, which causes the argument for + * {@code '<'} ('\u003c') 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. * - *

    All specified exceptions may be thrown by any of the format - * methods of Formatter as well as by any format convenience + *

    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}. * - *

    Conversions denoted by an upper-case character (i.e. 'B', - * 'H', 'S', 'C', 'X', 'E', - * 'G', 'A', and 'T') are the same as those for the + *

    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; * * * - *
    'b' + *
    {@code 'b'} * '\u0062' - * Produces either "true" or "false" as returned by + * Produces either "{@code true}" or "{@code false}" as returned by * {@link Boolean#toString(boolean)}. * - *

    If the argument is null, then the result is - * "false". If the argument is a boolean or {@link + *

    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 - * "true". + * "{@code true}". * - *

    If the '#' flag is given, then a {@link + *

    If the {@code '#'} flag is given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

    'B' + *
    {@code 'B'} * '\u0042' - * The upper-case variant of 'b'. + * The upper-case variant of {@code 'b'}. * - *
    'h' + *
    {@code 'h'} * '\u0068' * Produces a string representing the hash code value of the object. * - *

    If the argument, arg is null, then the - * result is "null". Otherwise, the result is obtained - * by invoking Integer.toHexString(arg.hashCode()). + *

    If the argument, arg is {@code null}, then the + * result is "{@code null}". Otherwise, the result is obtained + * by invoking {@code Integer.toHexString(arg.hashCode())}. * - *

    If the '#' flag is given, then a {@link + *

    If the {@code '#'} flag is given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

    'H' + *
    {@code 'H'} * '\u0048' - * The upper-case variant of 'h'. + * The upper-case variant of {@code 'h'}. * - *
    's' + *
    {@code 's'} * '\u0073' * Produces a string. * - *

    If the argument is null, then the result is - * "null". If the argument implements {@link Formattable}, then + *

    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 - * toString() method. + * {@code toString()} method. * - *

    If the '#' flag is given and the argument is not a {@link + *

    If the {@code '#'} flag is given and the argument is not a {@link * Formattable} , then a {@link FormatFlagsConversionMismatchException} * will be thrown. * - *

    'S' + *
    {@code 'S'} * '\u0053' - * The upper-case variant of 's'. + * The upper-case variant of {@code 's'}. * *
    * @@ -749,7 +749,7 @@ import sun.misc.FormattedFloatingDecimal; * * * - *
    '-' + *
    {@code '-'} * '\u002d' * Left justifies the output. Spaces ('\u0020') 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. * - *
    '#' + *
    {@code '#'} * '\u0023' * 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; *

    The width 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 '  ' (\u0020') + * the output will be padded by '  ' ('\u0020') * until the total number of characters equals the width. The padding is on - * the left by default. If the '-' 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. * *

    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 precision 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. * *

    Character

    * - * This conversion may be applied to char and {@link Character}. It - * may also be applied to the types byte, {@link Byte}, - * short, and {@link Short}, int and {@link Integer} when - * {@link Character#isValidCodePoint} returns true. If it returns - * false 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. * * * - *
    'c' + *
    {@code 'c'} * '\u0063' * Formats the argument as a Unicode character as described in Unicode Character - * Representation. This may be more than one 16-bit char in + * Representation. This may be more than one 16-bit {@code char} in * the case where the argument represents a supplementary character. * - *

    If the '#' flag is given, then a {@link + *

    If the {@code '#'} flag is given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

    'C' + *
    {@code 'C'} * '\u0043' - * The upper-case variant of 'c'. + * The upper-case variant of {@code 'c'}. * *
    * - *

    The '-' flag defined for General - * conversions applies. If the '#' flag is given, then a {@link + *

    The {@code '-'} flag defined for General + * conversions applies. If the {@code '#'} flag is given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * *

    The width is defined as for General conversions. @@ -844,14 +844,14 @@ import sun.misc.FormattedFloatingDecimal; *

  • Each digit character d in the string is replaced by a * locale-specific digit computed relative to the current locale's * {@linkplain java.text.DecimalFormatSymbols#getZeroDigit() zero digit} - * z; that is d -  '0' + * z; that is d -  {@code '0'} *  + z. * *
  • If a decimal separator is present, a locale-specific {@linkplain * java.text.DecimalFormatSymbols#getDecimalSeparator decimal separator} is * substituted. * - *
  • If the ',' ('\u002c') + *
  • If the {@code ','} ('\u002c') * flag 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}. * - *
  • If the '0' flag is given, then the locale-specific {@linkplain + *
  • 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. * - *
  • If the value is negative and the '(' flag is given, then a - * '(' ('\u0028') is prepended and a ')' + *
  • If the value is negative and the {@code '('} flag is given, then a + * {@code '('} ('\u0028') is prepended and a {@code ')'} * ('\u0029') is appended. * *
  • If the value is negative (or floating-point negative zero) and - * '(' flag is not given, then a '-' ('\u002d') + * {@code '('} flag is not given, then a {@code '-'} ('\u002d') * is prepended. * - *
  • If the '+' flag is given and the value is positive or zero (or - * floating-point positive zero), then a '+' ('\u002b') + *
  • If the {@code '+'} flag is given and the value is positive or zero (or + * floating-point positive zero), then a {@code '+'} ('\u002b') * will be prepended. * * * *

    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 '(' 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. * *

    Byte, Short, Integer, and Long * - *

    The following conversions may be applied to byte, {@link Byte}, - * short, {@link Short}, int and {@link Integer}, - * long, and {@link Long}. + *

    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}. * * * - *
    'd' + *
    {@code 'd'} * '\u0054' * Formats the argument as a decimal integer. The localization algorithm is applied. * - *

    If the '0' flag is given and the value is negative, then + *

    If the {@code '0'} flag is given and the value is negative, then * the zero padding will occur after the sign. * - *

    If the '#' flag is given then a {@link + *

    If the {@code '#'} flag is given then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

    'o' + *
    {@code 'o'} * '\u006f' * Formats the argument as an integer in base eight. No localization * is applied. * *

    If x is negative then the result will be an unsigned value - * generated by adding 2n to the value where n is the - * number of bits in the type as returned by the static SIZE field + * generated by adding 2n 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. * - *

    If the '#' flag is given then the output will always begin - * with the radix indicator '0'. + *

    If the {@code '#'} flag is given then the output will always begin + * with the radix indicator {@code '0'}. * - *

    If the '0' flag is given then the output will be padded + *

    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. * - *

    If '(', '+', '  ', or ',' flags + *

    If {@code '('}, {@code '+'}, '  ', or {@code ','} flags * are given then a {@link FormatFlagsConversionMismatchException} will be * thrown. * - *

    'x' + *
    {@code 'x'} * '\u0078' * Formats the argument as an integer in base sixteen. No * localization is applied. * *

    If x is negative then the result will be an unsigned value - * generated by adding 2n to the value where n is the - * number of bits in the type as returned by the static SIZE field + * generated by adding 2n 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. * - *

    If the '#' flag is given then the output will always begin - * with the radix indicator "0x". + *

    If the {@code '#'} flag is given then the output will always begin + * with the radix indicator {@code "0x"}. * - *

    If the '0' flag is given then the output will be padded to + *

    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). * - *

    If '(', '  ', '+', or - * ',' flags are given then a {@link + *

    If {@code '('}, '  ', {@code '+'}, or + * {@code ','} flags are given then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

    'X' + *
    {@code 'X'} * '\u0058' - * The upper-case variant of 'x'. The entire string + * The upper-case variant of {@code 'x'}. The entire string * representing the number will be converted to {@linkplain - * String#toUpperCase upper case} including the 'x' (if any) and - * all hexadecimal digits 'a' - 'f' + * String#toUpperCase upper case} including the {@code 'x'} (if any) and + * all hexadecimal digits {@code 'a'} - {@code 'f'} * ('\u0061' - '\u0066'). * *
    * - *

    If the conversion is 'o', 'x', or 'X' and - * both the '#' and the '0' flags are given, then result will - * contain the radix indicator ('0' for octal and "0x" or - * "0X" for hexadecimal), some number of zeros (based on the width), + *

    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. * - *

    If the '-' flag is not given, then the space padding will occur + *

    If the {@code '-'} flag is not given, then the space padding will occur * before the sign. * *

    The following flags apply to numeric integral @@ -971,13 +971,13 @@ import sun.misc.FormattedFloatingDecimal; * * * - *
    '+' + *
    {@code '+'} * '\u002b' * 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. * - *

    If both the '+' and '  ' flags are given + *

    If both the {@code '+'} and '  ' flags are given * then an {@link IllegalFormatFlagsException} will be thrown. * *

    '  ' @@ -985,10 +985,10 @@ import sun.misc.FormattedFloatingDecimal; * Requires the output to include a single extra space * ('\u0020') for non-negative values. * - *

    If both the '+' and '  ' flags are given + *

    If both the {@code '+'} and '  ' flags are given * then an {@link IllegalFormatFlagsException} will be thrown. * - *

    '0' + *
    {@code '0'} * '\u0030' * 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. * - *

    If both the '-' and '0' flags are given then an + *

    If both the {@code '-'} and {@code '0'} flags are given then an * {@link IllegalFormatFlagsException} will be thrown. * - *

    ',' + *
    {@code ','} * '\u002c' * Requires the output to include the locale-specific {@linkplain * java.text.DecimalFormatSymbols#getGroupingSeparator group separators} as * described in the "group" section of the * localization algorithm. * - *
    '(' + *
    {@code '('} * '\u0028' - * Requires the output to prepend a '(' - * ('\u0028') and append a ')' + * Requires the output to prepend a {@code '('} + * ('\u0028') and append a {@code ')'} * ('\u0029') to negative values. * *
    @@ -1019,9 +1019,9 @@ import sun.misc.FormattedFloatingDecimal; * *

      * - *
    • The output is right-justified within the width + *
    • The output is right-justified within the {@code width} * - *
    • Negative numbers begin with a '-' ('\u002d') + *
    • Negative numbers begin with a {@code '-'} ('\u002d') * *
    • 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 ('\u0020') until the total number of characters equals - * width. The padding is on the left by default. If '-' 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; * * * - *
      'd' + *
      {@code 'd'} * '\u0054' * Requires the output to be formatted as a decimal integer. The localization algorithm is applied. * - *

      If the '#' flag is given {@link + *

      If the {@code '#'} flag is given {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

      'o' + *
      {@code 'o'} * '\u006f' * Requires the output to be formatted as an integer in base eight. * No localization is applied. * *

      If x is negative then the result will be a signed value - * beginning with '-' ('\u002d'). Signed output is + * beginning with {@code '-'} ('\u002d'). 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. * - *

      If x is positive or zero and the '+' flag is given - * then the result will begin with '+' ('\u002b'). + *

      If x is positive or zero and the {@code '+'} flag is given + * then the result will begin with {@code '+'} ('\u002b'). * - *

      If the '#' flag is given then the output will always begin - * with '0' prefix. + *

      If the {@code '#'} flag is given then the output will always begin + * with {@code '0'} prefix. * - *

      If the '0' flag is given then the output will be padded + *

      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. * - *

      If the ',' flag is given then a {@link + *

      If the {@code ','} flag is given then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

      'x' + *
      {@code 'x'} * '\u0078' * Requires the output to be formatted as an integer in base * sixteen. No localization is applied. * *

      If x is negative then the result will be a signed value - * beginning with '-' ('\u002d'). Signed output is + * beginning with {@code '-'} ('\u002d'). 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. * - *

      If x is positive or zero and the '+' flag is given - * then the result will begin with '+' ('\u002b'). + *

      If x is positive or zero and the {@code '+'} flag is given + * then the result will begin with {@code '+'} ('\u002b'). * - *

      If the '#' flag is given then the output will always begin - * with the radix indicator "0x". + *

      If the {@code '#'} flag is given then the output will always begin + * with the radix indicator {@code "0x"}. * - *

      If the '0' flag is given then the output will be padded to + *

      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). * - *

      If the ',' flag is given then a {@link + *

      If the {@code ','} flag is given then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

      'X' + *
      {@code 'X'} * '\u0058' - * The upper-case variant of 'x'. The entire string + * The upper-case variant of {@code 'x'}. The entire string * representing the number will be converted to {@linkplain - * String#toUpperCase upper case} including the 'x' (if any) and - * all hexadecimal digits 'a' - 'f' + * String#toUpperCase upper case} including the {@code 'x'} (if any) and + * all hexadecimal digits {@code 'a'} - {@code 'f'} * ('\u0061' - '\u0066'). * *
      * - *

      If the conversion is 'o', 'x', or 'X' and - * both the '#' and the '0' flags are given, then result will - * contain the base indicator ('0' for octal and "0x" or - * "0X" for hexadecimal), some number of zeros (based on the width), + *

      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. * - *

      If the '0' flag is given and the value is negative, then the + *

      If the {@code '0'} flag is given and the value is negative, then the * zero padding will occur after the sign. * - *

      If the '-' flag is not given, then the space padding will occur + *

      If the {@code '-'} flag is not given, then the space padding will occur * before the sign. * *

      All flags defined for Byte, Short, Integer, and @@ -1138,12 +1138,12 @@ import sun.misc.FormattedFloatingDecimal; * *

      Float and Double * - *

      The following conversions may be applied to float, {@link - * Float}, double and {@link Double}. + *

      The following conversions may be applied to {@code float}, {@link + * Float}, {@code double} and {@link Double}. * * * - *
      'e' + *
      {@code 'e'} * '\u0065' * Requires the output to be formatted using computerized scientific notation. The If m is positive-zero or negative-zero, then the exponent - * will be "+00". + * will be {@code "+00"}. * *

      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 <= a < 10. The magnitude is then represented as the * integer part of a, as a single decimal digit, followed by the * decimal separator followed by decimal digits representing the fractional - * part of a, followed by the exponent symbol 'e' + * part of a, followed by the exponent symbol {@code 'e'} * ('\u0065'), followed by the sign of the exponent, followed * by a representation of n 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; * *

      The number of digits in the result for the fractional part of * m or a is equal to the precision. If the precision is not - * specified then the default value is 6. 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. * - *

      If the ',' flag is given, then an {@link + *

      If the {@code ','} flag is given, then an {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

      'E' + *
      {@code 'E'} * '\u0045' - * The upper-case variant of 'e'. The exponent symbol - * will be 'E' ('\u0045'). + * The upper-case variant of {@code 'e'}. The exponent symbol + * will be {@code 'E'} ('\u0045'). * - *
      'g' + *
      {@code 'g'} * '\u0067' * Requires the output to be formatted in general scientific notation * as described below. The localization @@ -1215,17 +1215,17 @@ import sun.misc.FormattedFloatingDecimal; * *

      The total number of significant digits in m is equal to the * precision. If the precision is not specified, then the default value is - * 6. If the precision is 0, then it is taken to be - * 1. + * {@code 6}. If the precision is {@code 0}, then it is taken to be + * {@code 1}. * - *

      If the '#' flag is given then an {@link + *

      If the {@code '#'} flag is given then an {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

      'G' + *
      {@code 'G'} * '\u0047' - * The upper-case variant of 'g'. + * The upper-case variant of {@code 'g'}. * - *
      'f' + *
      {@code 'f'} * '\u0066' * Requires the output to be formatted using decimal * format. The localization algorithm is @@ -1247,7 +1247,7 @@ import sun.misc.FormattedFloatingDecimal; * *

      The number of digits in the result for the fractional part of * m or a is equal to the precision. If the precision is not - * specified then the default value is 6. 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. * - *

      'a' + *
      {@code 'a'} * '\u0061' * 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 x. * *

      If x is negative or a negative-zero value then the result - * will begin with '-' ('\u002d'). + * will begin with {@code '-'} ('\u002d'). * *

      If x is positive or a positive-zero value and the - * '+' flag is given then the result will begin with '+' + * {@code '+'} flag is given then the result will begin with {@code '+'} * ('\u002b'). * *

      The formatting of the magnitude m depends upon its value. @@ -1280,43 +1280,43 @@ import sun.misc.FormattedFloatingDecimal; * "Infinity", respectively, will be output. * *

    • If m is zero then it is represented by the string - * "0x0.0p0". + * {@code "0x0.0p0"}. * - *
    • If m is a double value with a normalized + *
    • If m 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 - * "0x1." 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 - * 'p' ('\u0070') followed by a decimal string of the + * {@code 'p'} ('\u0070') followed by a decimal string of the * unbiased exponent as if produced by invoking {@link * Integer#toString(int) Integer.toString} on the exponent value. * - *
    • If m is a double value with a subnormal + *
    • If m is a {@code double} value with a subnormal * representation then the significand is represented by the characters - * '0x0.' 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 - * 'p-1022'. 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. * * * - *

      If the '(' or ',' flags are given, then a {@link + *

      If the {@code '('} or {@code ','} flags are given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

    • 'A' + *
      {@code 'A'} * '\u0041' - * The upper-case variant of 'a'. The entire string + * The upper-case variant of {@code 'a'}. The entire string * representing the number will be converted to upper case including the - * 'x' ('\u0078') and 'p' - * ('\u0070' and all hexadecimal digits 'a' - - * 'f' ('\u0061' - '\u0066'). + * {@code 'x'} ('\u0078') and {@code 'p'} + * ('\u0070' and all hexadecimal digits {@code 'a'} - + * {@code 'f'} ('\u0061' - '\u0066'). * *
      * *

      All flags defined for Byte, Short, Integer, and * Long apply. * - *

      If the '#' flag is given, then the decimal separator will + *

      If the {@code '#'} flag is given, then the decimal separator will * always be present. * *

      If no flags are given the default formatting @@ -1324,9 +1324,9 @@ import sun.misc.FormattedFloatingDecimal; * *

        * - *
      • The output is right-justified within the width + *
      • The output is right-justified within the {@code width} * - *
      • Negative numbers begin with a '-' + *
      • Negative numbers begin with a {@code '-'} * *
      • 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 ('\u0020') until the total number of * characters equals width. The padding is on the left by default. If the - * '-' 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. * - *

        If the conversion is 'e', - * 'E' or 'f', then the precision is the number of digits + *

        If the conversion 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 6. + * assumed to be {@code 6}. * - *

        If the conversion is 'g' or 'G', then the precision is + *

        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 - * 6. If the precision is 0, then it is taken to be - * 1. + * {@code 6}. If the precision is {@code 0}, then it is taken to be + * {@code 1}. * - *

        If the conversion is 'a' or 'A', then the precision + *

        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; * * * - *
        'e' + *
        {@code 'e'} * '\u0065' * Requires the output to be formatted using computerized scientific notation. The The formatting of the magnitude m depends upon its value. * *

        If m is positive-zero or negative-zero, then the exponent - * will be "+00". + * will be {@code "+00"}. * *

        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 <= a < 10. The magnitude is then represented as the * integer part of a, as a single decimal digit, followed by the * decimal separator followed by decimal digits representing the fractional - * part of a, followed by the exponent symbol 'e' + * part of a, followed by the exponent symbol {@code 'e'} * ('\u0065'), followed by the sign of the exponent, followed * by a representation of n 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; * *

        The number of digits in the result for the fractional part of * m or a is equal to the precision. If the precision is not - * specified then the default value is 6. 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()}. * - *

        If the ',' flag is given, then an {@link + *

        If the {@code ','} flag is given, then an {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

        'E' + *
        {@code 'E'} * '\u0045' - * The upper-case variant of 'e'. The exponent symbol - * will be 'E' ('\u0045'). + * The upper-case variant of {@code 'e'}. The exponent symbol + * will be {@code 'E'} ('\u0045'). * - *
        'g' + *
        {@code 'g'} * '\u0067' * Requires the output to be formatted in general scientific notation * as described below. The localization @@ -1437,17 +1437,17 @@ import sun.misc.FormattedFloatingDecimal; * *

        The total number of significant digits in m is equal to the * precision. If the precision is not specified, then the default value is - * 6. If the precision is 0, then it is taken to be - * 1. + * {@code 6}. If the precision is {@code 0}, then it is taken to be + * {@code 1}. * - *

        If the '#' flag is given then an {@link + *

        If the {@code '#'} flag is given then an {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

        'G' + *
        {@code 'G'} * '\u0047' - * The upper-case variant of 'g'. + * The upper-case variant of {@code 'g'}. * - *
        'f' + *
        {@code 'f'} * '\u0066' * Requires the output to be formatted using decimal * format. The localization algorithm is @@ -1465,7 +1465,7 @@ import sun.misc.FormattedFloatingDecimal; * *

        The number of digits in the result for the fractional part of * m or a is equal to the precision. If the precision is not - * specified then the default value is 6. 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; *

        All flags defined for Byte, Short, Integer, and * Long apply. * - *

        If the '#' flag is given, then the decimal separator will + *

        If the {@code '#'} flag is given, then the decimal separator will * always be present. * *

        The default behavior when no flags are @@ -1491,114 +1491,114 @@ import sun.misc.FormattedFloatingDecimal; * *

        Date/Time

        * - *

        This conversion may be applied to long, {@link Long}, {@link + *

        This conversion may be applied to {@code long}, {@link Long}, {@link * Calendar}, and {@link Date}. * * * - *
        't' + *
        {@code 't'} * '\u0074' * Prefix for date and time conversion characters. - *
        'T' + *
        {@code 'T'} * '\u0054' - * The upper-case variant of 't'. + * The upper-case variant of {@code 't'}. * *
        * *

        The following date and time conversion character suffixes are defined - * for the 't' and 'T' conversions. The types are similar to - * but not completely identical to those defined by GNU date and - * POSIX strftime(3c). Additional conversion types are provided to - * access Java-specific functionality (e.g. 'L' 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). * *

        The following conversion characters are used for formatting times: * * * - *
        'H' + *
        {@code 'H'} * '\u0048' * Hour of the day for the 24-hour clock, formatted as two digits with - * a leading zero as necessary i.e. 00 - 23. 00 + * a leading zero as necessary i.e. {@code 00 - 23}. {@code 00} * corresponds to midnight. * - *
        'I' + *
        {@code 'I'} * '\u0049' * Hour for the 12-hour clock, formatted as two digits with a leading - * zero as necessary, i.e. 01 - 12. 01 corresponds to + * zero as necessary, i.e. {@code 01 - 12}. {@code 01} corresponds to * one o'clock (either morning or afternoon). * - *
        'k' + *
        {@code 'k'} * '\u006b' - * Hour of the day for the 24-hour clock, i.e. 0 - 23. - * 0 corresponds to midnight. + * Hour of the day for the 24-hour clock, i.e. {@code 0 - 23}. + * {@code 0} corresponds to midnight. * - *
        'l' + *
        {@code 'l'} * '\u006c' - * Hour for the 12-hour clock, i.e. 1 - 12. 1 + * Hour for the 12-hour clock, i.e. {@code 1 - 12}. {@code 1} * corresponds to one o'clock (either morning or afternoon). * - *
        'M' + *
        {@code 'M'} * '\u004d' * Minute within the hour formatted as two digits with a leading zero - * as necessary, i.e. 00 - 59. + * as necessary, i.e. {@code 00 - 59}. * - *
        'S' + *
        {@code 'S'} * '\u0053' * Seconds within the minute, formatted as two digits with a leading - * zero as necessary, i.e. 00 - 60 ("60" is a special + * zero as necessary, i.e. {@code 00 - 60} ("{@code 60}" is a special * value required to support leap seconds). * - *
        'L' + *
        {@code 'L'} * '\u004c' * Millisecond within the second formatted as three digits with - * leading zeros as necessary, i.e. 000 - 999. + * leading zeros as necessary, i.e. {@code 000 - 999}. * - *
        'N' + *
        {@code 'N'} * '\u004e' * Nanosecond within the second, formatted as nine digits with leading - * zeros as necessary, i.e. 000000000 - 999999999. 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. * - *
        'p' + *
        {@code 'p'} * '\u0070' * Locale-specific {@linkplain * java.text.DateFormatSymbols#getAmPmStrings morning or afternoon} marker - * in lower case, e.g."am" or "pm". Use of the - * conversion prefix 'T' forces this output to upper case. (Note - * that 'p' produces lower-case output. This is different from - * GNU date and POSIX strftime(3c) 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.) * - *
        'z' + *
        {@code 'z'} * '\u007a' * RFC 822 - * style numeric time zone offset from GMT, e.g. -0800. This + * style numeric time zone offset from GMT, e.g. {@code -0800}. This * value will be adjusted as necessary for Daylight Saving Time. For - * long, {@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. * - *
        'Z' + *
        {@code 'Z'} * A string representing the abbreviation for the time zone. This * value will be adjusted as necessary for Daylight Saving Time. For - * long, {@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). * - *
        's' + *
        {@code 's'} * '\u0073' * Seconds since the beginning of the epoch starting at 1 January 1970 - * 00:00:00 UTC, i.e. Long.MIN_VALUE/1000 to - * Long.MAX_VALUE/1000. + * {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE/1000} to + * {@code Long.MAX_VALUE/1000}. * - *
        'Q' + *
        {@code 'Q'} * '\u004f' * Milliseconds since the beginning of the epoch starting at 1 January - * 1970 00:00:00 UTC, i.e. Long.MIN_VALUE to - * Long.MAX_VALUE. 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. * *
        @@ -1607,71 +1607,71 @@ import sun.misc.FormattedFloatingDecimal; * * * - *
        'B' + *
        {@code 'B'} * '\u0042' * Locale-specific {@linkplain java.text.DateFormatSymbols#getMonths - * full month name}, e.g. "January", "February". + * full month name}, e.g. {@code "January"}, {@code "February"}. * - *
        'b' + *
        {@code 'b'} * '\u0062' * Locale-specific {@linkplain * java.text.DateFormatSymbols#getShortMonths abbreviated month name}, - * e.g. "Jan", "Feb". + * e.g. {@code "Jan"}, {@code "Feb"}. * - *
        'h' + *
        {@code 'h'} * '\u0068' - * Same as 'b'. + * Same as {@code 'b'}. * - *
        'A' + *
        {@code 'A'} * '\u0041' * Locale-specific full name of the {@linkplain * java.text.DateFormatSymbols#getWeekdays day of the week}, - * e.g. "Sunday", "Monday" + * e.g. {@code "Sunday"}, {@code "Monday"} * - *
        'a' + *
        {@code 'a'} * '\u0061' * Locale-specific short name of the {@linkplain * java.text.DateFormatSymbols#getShortWeekdays day of the week}, - * e.g. "Sun", "Mon" + * e.g. {@code "Sun"}, {@code "Mon"} * - *
        'C' + *
        {@code 'C'} * '\u0043' - * Four-digit year divided by 100, formatted as two digits - * with leading zero as necessary, i.e. 00 - 99 + * Four-digit year divided by {@code 100}, formatted as two digits + * with leading zero as necessary, i.e. {@code 00 - 99} * - *
        'Y' + *
        {@code 'Y'} * '\u0059' Year, formatted to at least - * four digits with leading zeros as necessary, e.g. 0092 equals - * 92 CE for the Gregorian calendar. + * four digits with leading zeros as necessary, e.g. {@code 0092} equals + * {@code 92} CE for the Gregorian calendar. * - *
        'y' + *
        {@code 'y'} * '\u0079' * Last two digits of the year, formatted with leading zeros as - * necessary, i.e. 00 - 99. + * necessary, i.e. {@code 00 - 99}. * - *
        'j' + *
        {@code 'j'} * '\u006a' * Day of year, formatted as three digits with leading zeros as - * necessary, e.g. 001 - 366 for the Gregorian calendar. - * 001 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. * - *
        'm' + *
        {@code 'm'} * '\u006d' * Month, formatted as two digits with leading zeros as necessary, - * i.e. 01 - 13, where "01" is the first month of the - * year and ("13" 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). * - *
        'd' + *
        {@code 'd'} * '\u0064' * Day of month, formatted as two digits with leading zeros as - * necessary, i.e. 01 - 31, where "01" is the first day + * necessary, i.e. {@code 01 - 31}, where "{@code 01}" is the first day * of the month. * - *
        'e' + *
        {@code 'e'} * '\u0065' - * Day of month, formatted as two digits, i.e. 1 - 31 where - * "1" is the first day of the month. + * Day of month, formatted as two digits, i.e. {@code 1 - 31} where + * "{@code 1}" is the first day of the month. * *
        * @@ -1680,45 +1680,45 @@ import sun.misc.FormattedFloatingDecimal; * * * - *
        'R' + *
        {@code 'R'} * '\u0052' - * Time formatted for the 24-hour clock as "%tH:%tM" + * Time formatted for the 24-hour clock as {@code "%tH:%tM"} * - *
        'T' + *
        {@code 'T'} * '\u0054' - * Time formatted for the 24-hour clock as "%tH:%tM:%tS". + * Time formatted for the 24-hour clock as {@code "%tH:%tM:%tS"}. * - *
        'r' + *
        {@code 'r'} * '\u0072' - * Time formatted for the 12-hour clock as "%tI:%tM:%tS - * %Tp". The location of the morning or afternoon marker - * ('%Tp') may be locale-dependent. + * 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. * - *
        'D' + *
        {@code 'D'} * '\u0044' - * Date formatted as "%tm/%td/%ty". + * Date formatted as {@code "%tm/%td/%ty"}. * - *
        'F' + *
        {@code 'F'} * '\u0046' * ISO 8601 - * complete date formatted as "%tY-%tm-%td". + * complete date formatted as {@code "%tY-%tm-%td"}. * - *
        'c' + *
        {@code 'c'} * '\u0063' - * Date and time formatted as "%ta %tb %td %tT %tZ %tY", - * e.g. "Sun Jul 20 16:17:00 EDT 1969". + * Date and time formatted as {@code "%ta %tb %td %tT %tZ %tY"}, + * e.g. {@code "Sun Jul 20 16:17:00 EDT 1969"}. * *
        * - *

        The '-' flag defined for General - * conversions applies. If the '#' flag is given, then a {@link + *

        The {@code '-'} flag defined for General + * conversions applies. If the {@code '#'} flag is given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * *

        The width 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 spaces + * the {@code width} then the output will be padded by spaces * ('\u0020') until the total number of characters equals width. - * The padding is on the left by default. If the '-' 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; * * * - *
        '%' - * The result is a literal '%' ('\u0025') + *
        {@code '%'} + * The result is a literal {@code '%'} ('\u0025') * *

        The width is the minimum number of characters to - * be written to the output including the '%'. If the length of the - * converted value is less than the width 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 ('\u0020') until the total number of * characters equals width. The padding is on the left. If width is not - * specified then just the '%' is output. + * specified then just the {@code '%'} is output. * - *

        The '-' flag defined for General + *

        The {@code '-'} flag defined for General * conversions applies. If any other flags are provided, then a * {@link FormatFlagsConversionMismatchException} will be thrown. * @@ -1756,7 +1756,7 @@ import sun.misc.FormattedFloatingDecimal; * * * - * * * + * + * + * + * + * + * * * diff --git a/jdk/src/share/classes/java/net/URLClassLoader.java b/jdk/src/share/classes/java/net/URLClassLoader.java index 9ffd0287c36..afb92b8c938 100644 --- a/jdk/src/share/classes/java/net/URLClassLoader.java +++ b/jdk/src/share/classes/java/net/URLClassLoader.java @@ -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. * *

        If there is a security manager, this method first - * calls the security manager's checkCreateClassLoader 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 - * checkCreateClassLoader 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. + *

        + * 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. + *

        + * 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. + *

        + * @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 cause + * of this IOException. + * + * @throws SecurityException if a security manager is set, and it denies + * {@link RuntimePermission}("closeClassLoader") + * + * @since 1.7 + */ + public void close() throws IOException { + SecurityManager security = System.getSecurityManager(); + if (security != null) { + security.checkPermission(new RuntimePermission("closeClassLoader")); + } + List 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. *

        * If the URL specified is null 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 URL for the resource, or null - * 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 Enumeration of URLs + * If the loader is closed, the Enumeration will be empty. */ public Enumeration findResources(final String name) throws IOException diff --git a/jdk/src/share/classes/sun/misc/URLClassPath.java b/jdk/src/share/classes/sun/misc/URLClassPath.java index 5e38c767135..28b4441d35d 100644 --- a/jdk/src/share/classes/sun/misc/URLClassPath.java +++ b/jdk/src/share/classes/sun/misc/URLClassPath.java @@ -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 closeLoaders() { + if (closed) { + return Collections.emptyList(); + } + List result = new LinkedList(); + 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 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; } diff --git a/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java b/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java new file mode 100644 index 00000000000..b0fdd577b42 --- /dev/null +++ b/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java @@ -0,0 +1,246 @@ +/* + * 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 Date: Fri, 30 Jan 2009 15:09:00 -0800 Subject: [PATCH 10/10] 6799462: Minor typo (wrong word) in JavaDoc for InputStream.read(byte[] b) method Reviewed-by: sherman, martin --- jdk/src/share/classes/java/io/InputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/io/InputStream.java b/jdk/src/share/classes/java/io/InputStream.java index 12da2bc9397..86922fe8b10 100644 --- a/jdk/src/share/classes/java/io/InputStream.java +++ b/jdk/src/share/classes/java/io/InputStream.java @@ -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 - * -1 is there is no more data because the end of + * -1 if 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

        'n' + *
        {@code 'n'} * the platform-specific line separator as returned by {@link * System#getProperty System.getProperty("line.separator")}. * @@ -1775,7 +1775,7 @@ import sun.misc.FormattedFloatingDecimal; *
      • Explicit indexing 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 "1$", the second by "2$", etc. An argument + * referenced by "{@code 1$}", the second by "{@code 2$}", etc. An argument * may be referenced more than once. * *

        For example: @@ -1787,7 +1787,7 @@ import sun.misc.FormattedFloatingDecimal; * * *

      • Relative indexing is used when the format specifier contains a - * '<' ('\u003c') flag which causes the argument for + * {@code '<'} ('\u003c') 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; * * *
      • Ordinary indexing is used when the format specifier contains - * neither an argument index nor a '<' 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; *

        If there are more arguments than format specifiers, the extra arguments * are ignored. * - *

        Unless otherwise specified, passing a null argument to any + *

        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 a is - * null 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 l is null 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 a is - * null 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 l is null 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 l is null 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 l is null 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 l is null 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 { *

        The {@link #format(java.util.Locale,String,Object...) format} method * for this object which has a locale argument does not change this value. * - * @return null 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 toString() 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 { *

              *     out().toString() 
        * - *

        Depending on the specification of toString for the {@link + *

        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 toString(), but streams cannot since the + * their contents in {@code toString()}, but streams cannot since the * data is discarded. * - * @return The result of invoking toString() 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 flush method will be invoked. + * java.io.Flushable} interface, its {@code flush} method will be invoked. * *

        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 close method will be invoked. + * java.io.Closeable} interface, its {@code close} method will be invoked. * *

        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 IOException last thrown by this formatter's {@link + * Returns the {@code IOException} last thrown by this formatter's {@link * Appendable}. * - *

        If the destination's append() method never throws - * IOException, then this method will always return null. + *

        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 null 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 l is null 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 Flags. + // Returns a string representation of the current {@code Flags}. public static String toString(Flags f) { return f.toString(); } From 71dfa4d2db4841be10b7b80bd70ae8da366bcb78 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Fri, 30 Jan 2009 22:05:30 +0000 Subject: [PATCH 09/10] 4167874: URL-downloaded jar files can consume all available file descriptors Added close method to URLClassLoader Reviewed-by: alanb --- .../classes/java/lang/RuntimePermission.java | 7 + .../classes/java/net/URLClassLoader.java | 69 ++++- .../share/classes/sun/misc/URLClassPath.java | 61 +++-- .../URLClassLoader/closetest/CloseTest.java | 246 ++++++++++++++++++ .../java/net/URLClassLoader/closetest/README | 24 ++ .../net/URLClassLoader/closetest/build.sh | 73 ++++++ .../closetest/serverRoot/Test.java | 28 ++ .../closetest/test1/com/foo/Resource1 | 1 + .../closetest/test1/com/foo/Resource2 | 1 + .../closetest/test1/com/foo/TestClass.java | 38 +++ .../closetest/test1/com/foo/TestClass1.java | 26 ++ .../closetest/test2/com/foo/Resource1 | 1 + .../closetest/test2/com/foo/Resource2 | 1 + .../closetest/test2/com/foo/TestClass.java | 38 +++ .../closetest/test2/com/foo/TestClass1.java | 26 ++ 15 files changed, 616 insertions(+), 24 deletions(-) create mode 100644 jdk/test/java/net/URLClassLoader/closetest/CloseTest.java create mode 100644 jdk/test/java/net/URLClassLoader/closetest/README create mode 100644 jdk/test/java/net/URLClassLoader/closetest/build.sh create mode 100644 jdk/test/java/net/URLClassLoader/closetest/serverRoot/Test.java create mode 100644 jdk/test/java/net/URLClassLoader/closetest/test1/com/foo/Resource1 create mode 100644 jdk/test/java/net/URLClassLoader/closetest/test1/com/foo/Resource2 create mode 100644 jdk/test/java/net/URLClassLoader/closetest/test1/com/foo/TestClass.java create mode 100644 jdk/test/java/net/URLClassLoader/closetest/test1/com/foo/TestClass1.java create mode 100644 jdk/test/java/net/URLClassLoader/closetest/test2/com/foo/Resource1 create mode 100644 jdk/test/java/net/URLClassLoader/closetest/test2/com/foo/Resource2 create mode 100644 jdk/test/java/net/URLClassLoader/closetest/test2/com/foo/TestClass.java create mode 100644 jdk/test/java/net/URLClassLoader/closetest/test2/com/foo/TestClass1.java diff --git a/jdk/src/share/classes/java/lang/RuntimePermission.java b/jdk/src/share/classes/java/lang/RuntimePermission.java index fce9e08f1a4..717444329f0 100644 --- a/jdk/src/share/classes/java/lang/RuntimePermission.java +++ b/jdk/src/share/classes/java/lang/RuntimePermission.java @@ -100,6 +100,13 @@ import java.util.StringTokenizer; *

      • closeClassLoaderClosing of a ClassLoaderGranting this permission allows code to close any URLClassLoader + * that it has a reference to.
        setSecurityManagerSetting of the security manager (possibly replacing an existing one) *