# HG changeset patch # User jjg # Date 1503511091 25200 # Node ID e92e67ed12b4b9db04811f5ea617fc41363c5a34 # Parent ea81af6257b36fc7dc43e6ca56e7f76a3d183e32 8186466: Fix accessibility and other minor issues in java.base Reviewed-by: mchung, naoto, martin diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/lang/String.java --- a/jdk/src/java.base/share/classes/java/lang/String.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/lang/String.java Wed Aug 23 10:58:11 2017 -0700 @@ -2488,12 +2488,8 @@ *
Thread.stop
deprecated?Because it is inherently unsafe. Stopping a thread causes it to unlock all the monitors that it has locked. (The monitors are @@ -45,7 +45,7 @@ no warning that his program may be corrupted. The corruption can manifest itself at any time after the actual damage occurs, even hours or days in the future.
-ThreadDeath
exception
and fix the damaged object?In theory, perhaps, but it would vastly complicate the @@ -61,7 +61,7 @@ it succeeded. The code to ensure this would be quite complex. In sum, it just isn't practical. -
Thread.stop(Throwable)
?In addition to all of the problems noted above, this method may be used to generate exceptions that its target thread is unprepared @@ -76,7 +76,7 @@ Thread.currentThread().stop(t); } -
Thread.stop
?Most uses of stop
should be replaced by code that
simply modifies some variable to indicate that the target thread
@@ -84,7 +84,7 @@
regularly, and return from its run method in an orderly fashion if
the variable indicates that it is to stop running. To ensure prompt
communication of the stop-request, the variable must be
-volatile (or access to the variable must be
+volatile
(or access to the variable must be
synchronized).
For example, suppose your applet contains the following
start
, stop
and run
@@ -131,7 +131,7 @@
}
}
-
That's what the Thread.interrupt
method is for. The
@@ -159,7 +159,7 @@
This ensures that the Thread will reraise the
InterruptedException
as soon as it is able.
-
Thread.interrupt
?In some cases, you can use application specific tricks. For @@ -172,7 +172,7 @@ cases include deliberate denial-of-service attacks, and I/O operations for which thread.stop and thread.interrupt do not work properly.
-Thread.suspend
and
Thread.resume
deprecated?Thread.suspend
is inherently deadlock-prone. If the
@@ -182,7 +182,7 @@
would resume the target thread attempts to lock this monitor prior
to calling resume
, deadlock results. Such deadlocks
typically manifest themselves as "frozen" processes.
Thread.suspend
and
Thread.resume
?As with Thread.stop
, the prudent approach is to
@@ -274,7 +274,7 @@
}
In the absence of explicit synchronization,
-threadSuspended must be made volatile to ensure
+threadSuspended
must be made volatile
to ensure
prompt communication of the suspend-request.
run
method is:
@@ -302,17 +302,17 @@ be safely "stopped" or "suspended"? Yes, it's reasonably straightforward. The one subtlety is that the target thread may already be suspended at the time that another -thread tries to stop it. If the stop method merely sets -the state variable (blinker) to null, the target thread +thread tries to stop it. If thestop
method merely sets +the state variable (blinker
) to null, the target thread will remain suspended (waiting on the monitor), rather than exiting gracefully as it should. If the applet is restarted, multiple threads could end up waiting on the monitor at the same time, resulting in erratic behavior. -To rectify this situation, the stop method must ensure +
To rectify this situation, the
+stop
method must ensure that the target thread resumes immediately if it is suspended. Once the target thread resumes, it must recognize immediately that it has been stopped, and exit gracefully. Here's how the resulting -run and stop methods look:run
andstop
methods look:public void run() { Thread thisThread = Thread.currentThread(); @@ -335,18 +335,18 @@ notify(); }-If the stop method calls Thread.interrupt, as -described above, it needn't call notify as well, but it +If thestop
method callsThread.interrupt
, as +described above, it needn't callnotify
as well, but it still must be synchronized. This ensures that the target thread won't miss an interrupt due to a race condition. -
+
What about
Thread.destroy
?Thread.destroy
was never implemented and has been deprecated. If it were implemented, it would be deadlock-prone in the manner ofThread.suspend
. (In fact, it is roughly equivalent toThread.suspend
without the possibility of a subsequentThread.resume
.) -
+
Why is
Because it is inherently unsafe. It may result in finalizers being diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/lang/doc-files/upsilon.gif Binary file jdk/src/java.base/share/classes/java/lang/doc-files/upsilon.gif has changed diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java --- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Wed Aug 23 10:58:11 2017 -0700 @@ -223,7 +223,7 @@ *Runtime.runFinalizersOnExit
deprecated?* *{@link #ISO_OFFSET_DATE_TIME} *Date Time with Offset - * 2011-12-03T10:15:30+01:00' + *'2011-12-03T10:15:30+01:00' ** {@link #ISO_ZONED_DATE_TIME} @@ -243,7 +243,7 @@ ** + *{@link #ISO_WEEK_DATE} *Year and Week - *2012-W48-6' '2012-W48-6' ** {@link #ISO_INSTANT} *Date and Time of an Instant diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/Deque.java --- a/jdk/src/java.base/share/classes/java/util/Deque.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/Deque.java Wed Aug 23 10:58:11 2017 -0700 @@ -56,41 +56,44 @@ *The twelve methods described above are summarized in the * following table: * - *
+ *
*
* *Summary of Deque methods + * *- * *- * First Element (Head) - *Last Element (Tail) + *+ * First Element (Head) + *Last Element (Tail) *- * + * + * *- * Throws exception - *Special value - *Throws exception - *Special value + *Throws exception + *Special value + *Throws exception + *Special value *- * *Insert + *Insert *{@link #addFirst(Object) addFirst(e)} *{@link #offerFirst(Object) offerFirst(e)} *{@link #addLast(Object) addLast(e)} *{@link #offerLast(Object) offerLast(e)} *- * *Remove + *Remove *{@link #removeFirst() removeFirst()} *{@link #pollFirst() pollFirst()} *{@link #removeLast() removeLast()} *{@link #pollLast() pollLast()} *- * + * *Examine + *Examine *{@link #getFirst() getFirst()} *{@link #peekFirst() peekFirst()} *{@link #getLast() getLast()} *{@link #peekLast() peekLast()} *This interface extends the {@link Queue} interface. When a deque is @@ -99,36 +102,40 @@ * inherited from the {@code Queue} interface are precisely equivalent to * {@code Deque} methods as indicated in the following table: * - *
+ *
*
* *Comparison of Queue and Deque methods + * *- * + * + * *{@code Queue} Method - *Equivalent {@code Deque} Method + *{@code Queue} Method + *Equivalent {@code Deque} Method *- * *{@link #add(Object) add(e)} + *{@link #add(Object) add(e)} *{@link #addLast(Object) addLast(e)} *- * *{@link #offer(Object) offer(e)} + *{@link #offer(Object) offer(e)} *{@link #offerLast(Object) offerLast(e)} *- * *{@link #remove() remove()} + *{@link #remove() remove()} *{@link #removeFirst() removeFirst()} *- * *{@link #poll() poll()} + *{@link #poll() poll()} *{@link #pollFirst() pollFirst()} *- * *{@link #element() element()} + *{@link #element() element()} *{@link #getFirst() getFirst()} *- * + * *{@link #peek() peek()} + *{@link #peek() peek()} *{@link #peekFirst() peekFirst()} *Deques can also be used as LIFO (Last-In-First-Out) stacks. This @@ -137,24 +144,28 @@ * beginning of the deque. Stack methods are precisely equivalent to * {@code Deque} methods as indicated in the table below: * - *
+ *
*
* *Comparison of Stack and Deque methods + * *- * + * + * *Stack Method - *Equivalent {@code Deque} Method + *Stack Method + *Equivalent {@code Deque} Method *- * *{@link #push(Object) push(e)} + *{@link #push(Object) push(e)} *{@link #addFirst(Object) addFirst(e)} *- * *{@link #pop() pop()} + *{@link #pop() pop()} *{@link #removeFirst() removeFirst()} *- * + * *{@link #peek() peek()} + *{@link #peek() peek()} *{@link #peekFirst() peekFirst()} *Note that the {@link #peek peek} method works equally well when diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/Queue.java --- a/jdk/src/java.base/share/classes/java/util/Queue.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/Queue.java Wed Aug 23 10:58:11 2017 -0700 @@ -46,28 +46,32 @@ * use with capacity-restricted {@code Queue} implementations; in most * implementations, insert operations cannot fail. * - *
+ *
* diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java Wed Aug 23 10:58:11 2017 -0700 @@ -113,21 +113,21 @@ **
* *Summary of Queue methods + * ** + * + * *- * Throws exception - *Returns special value + *Throws exception + *Returns special value *- * *Insert + *Insert *{@link #add(Object) add(e)} *{@link #offer(Object) offer(e)} *- * *Remove + *Remove *{@link #remove() remove()} *{@link #poll() poll()} *- * + * *Examine + *Examine *{@link #element() element()} *{@link #peek() peek()} *Queues typically, but do not necessarily, order elements in a diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/ResourceBundle.java --- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Wed Aug 23 10:58:11 2017 -0700 @@ -1210,15 +1210,15 @@ * Example: *
* The following class and property files are provided: - *
- * MyResources.class - * MyResources.properties - * MyResources_fr.properties - * MyResources_fr_CH.class - * MyResources_fr_CH.properties - * MyResources_en.properties - * MyResources_es_ES.class - *+ *+ *
* * The contents of all files are valid (that is, public non-abstract * subclasses of- MyResources.class + *
- MyResources.properties + *
- MyResources_fr.properties + *
- MyResources_fr_CH.class + *
- MyResources_fr_CH.properties + *
- MyResources_en.properties + *
- MyResources_es_ES.class + *
ResourceBundle
for the ".class" files, @@ -1228,14 +1228,17 @@ *Calling
getBundle
with the locale arguments below will * instantiate resource bundles as follows: * - *+ *
@@ -3453,15 +3455,15 @@ } /** - * Converts the given*
* @@ -1324,42 +1327,41 @@ * + * + * * *+ * * - * Locale Resource bundle - * Locale("fr", "CH") MyResources_fr_CH.class, parent MyResources_fr.properties, parent MyResources.class - * Locale("fr", "FR") MyResources_fr.properties, parent MyResources.class - * Locale("de", "DE") MyResources_en.properties, parent MyResources.class - * Locale("en", "US") MyResources_en.properties, parent MyResources.class + * Locale("es", "ES") MyResources_es_ES.class, parent MyResources.class + * Locale("fr", "CH") MyResources_fr_CH.class, parent MyResources_fr.properties, parent MyResources.class + * Locale("fr", "FR") MyResources_fr.properties, parent MyResources.class + * Locale("de", "DE") MyResources_en.properties, parent MyResources.class + * Locale("en", "US") MyResources_en.properties, parent MyResources.class * * Locale("es", "ES") MyResources_es_ES.class, parent MyResources.class - * * * *- * Locale
- *+ * format
- *Index + *+ * Locale
* format
- * *- * Locale("de", "DE")
- *+ * java.class
- *1 + *+ * Locale("de", "DE")
* java.class
- * *- * Locale("de", "DE")
+ * java.properties
- *2 + *+ * Locale("de", "DE")
* java.properties
- * - *- * Locale("de")
- * java.class
- * *- * Locale("de")
+ * java.properties
3 + *+ * Locale("de")
* java.class
- * *- * Locale("")
- *+ * java.class
4 + *+ * Locale("de")
* java.properties
- * + *- * Locale("")
+ * java.properties
5 + *+ * Locale("")
+ * java.class
+ * * *6 + *+ * Locale("")
* java.properties
bundleName
to the form required + * Converts the given {@code bundleName} to the form required * by the {@link ClassLoader#getResource ClassLoader.getResource} - * method by replacing all occurrences of'.'
in - *bundleName
with'/'
and appending a - *'.'
and the given filesuffix
. For - * example, ifbundleName
is - *"foo.bar.MyResources_ja_JP"
andsuffix
- * is"properties"
, then - *"foo/bar/MyResources_ja_JP.properties"
is returned. + * method by replacing all occurrences of {@code '.'} in + * {@code bundleName} with {@code '/'} and appending a + * {@code '.'} and the given file {@code suffix}. For + * example, if {@code bundleName} is + * {@code "foo.bar.MyResources_ja_JP"} and {@code suffix} + * is {@code "properties"}, then + * {@code "foo/bar/MyResources_ja_JP.properties"} is returned. * * @param bundleName * the bundle name @@ -3469,8 +3471,8 @@ * the file type suffix * @return the converted resource name * @exception NullPointerException - * ifbundleName
orsuffix
- * isnull
+ * if {@code bundleName} or {@code suffix} + * is {@code null} */ public final String toResourceName(String bundleName, String suffix) { StringBuilder sb = new StringBuilder(bundleName.length() + 1 + suffix.length()); diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java --- a/jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java Wed Aug 23 10:58:11 2017 -0700 @@ -56,66 +56,66 @@ **
* @@ -131,57 +131,52 @@ *Summary of BlockingDeque methods *- * *First Element (Head) + *First Element (Head) ** *- * Throws exception - *Special value - *Blocks - *Times out + *Throws exception + *Special value + *Blocks + *Times out *- * *Insert - *{@link #addFirst(Object) addFirst(e)} - *{@link #offerFirst(Object) offerFirst(e)} - *{@link #putFirst(Object) putFirst(e)} - *{@link #offerFirst(Object, long, TimeUnit) offerFirst(e, time, unit)} + *Insert + *{@link #addFirst(Object) addFirst(e)} + *{@link #offerFirst(Object) offerFirst(e)} + *{@link #putFirst(Object) putFirst(e)} + *{@link #offerFirst(Object, long, TimeUnit) offerFirst(e, time, unit)} *- * *Remove - *{@link #removeFirst() removeFirst()} - *{@link #pollFirst() pollFirst()} - *{@link #takeFirst() takeFirst()} - *{@link #pollFirst(long, TimeUnit) pollFirst(time, unit)} + *Remove + *{@link #removeFirst() removeFirst()} + *{@link #pollFirst() pollFirst()} + *{@link #takeFirst() takeFirst()} + *{@link #pollFirst(long, TimeUnit) pollFirst(time, unit)} *- * *Examine - *{@link #getFirst() getFirst()} - *{@link #peekFirst() peekFirst()} - *not applicable - *not applicable + *Examine + *{@link #getFirst() getFirst()} + *{@link #peekFirst() peekFirst()} + *not applicable + *not applicable *- * *Last Element (Tail) + *Last Element (Tail) ** *- * Throws exception - *Special value - *Blocks - *Times out + *Throws exception + *Special value + *Blocks + *Times out *- * *Insert - *{@link #addLast(Object) addLast(e)} - *{@link #offerLast(Object) offerLast(e)} - *{@link #putLast(Object) putLast(e)} - *{@link #offerLast(Object, long, TimeUnit) offerLast(e, time, unit)} + *Insert + *{@link #addLast(Object) addLast(e)} + *{@link #offerLast(Object) offerLast(e)} + *{@link #putLast(Object) putLast(e)} + *{@link #offerLast(Object, long, TimeUnit) offerLast(e, time, unit)} *- * *Remove - *{@link #removeLast() removeLast()} - *{@link #pollLast() pollLast()} - *{@link #takeLast() takeLast()} - *{@link #pollLast(long, TimeUnit) pollLast(time, unit)} + *Remove + *{@link #removeLast() removeLast()} + *{@link #pollLast() pollLast()} + *{@link #takeLast() takeLast()} + *{@link #pollLast(long, TimeUnit) pollLast(time, unit)} *- * *Examine - *{@link #getLast() getLast()} - *{@link #peekLast() peekLast()} - *not applicable - *not applicable + *Examine + *{@link #getLast() getLast()} + *{@link #peekLast() peekLast()} + *not applicable + *not applicable **
* diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java --- a/jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java Wed Aug 23 10:58:11 2017 -0700 @@ -56,31 +56,31 @@ *Comparison of BlockingQueue and BlockingDeque methods *- * *{@code BlockingQueue} Method - *Equivalent {@code BlockingDeque} Method + *+ * {@code BlockingQueue} Method + *Equivalent {@code BlockingDeque} Method *- * - *Insert - *- * *{@link #add(Object) add(e)} - *{@link #addLast(Object) addLast(e)} + *Insert + *{@link #add(Object) add(e)} + *{@link #addLast(Object) addLast(e)} *- * *{@link #offer(Object) offer(e)} - *{@link #offerLast(Object) offerLast(e)} + *{@link #offer(Object) offer(e)} + *{@link #offerLast(Object) offerLast(e)} *- * *{@link #put(Object) put(e)} - *{@link #putLast(Object) putLast(e)} + *{@link #put(Object) put(e)} + *{@link #putLast(Object) putLast(e)} *- * - *{@link #offer(Object, long, TimeUnit) offer(e, time, unit)} - *{@link #offerLast(Object, long, TimeUnit) offerLast(e, time, unit)} - *- * *Remove + *{@link #offer(Object, long, TimeUnit) offer(e, time, unit)} + *{@link #offerLast(Object, long, TimeUnit) offerLast(e, time, unit)} *- * *{@link #remove() remove()} - *{@link #removeFirst() removeFirst()} + *Remove + *{@link #remove() remove()} + *{@link #removeFirst() removeFirst()} *- * - *{@link #poll() poll()} - *{@link #pollFirst() pollFirst()} - *- * *{@link #take() take()} - *{@link #takeFirst() takeFirst()} + *{@link #poll() poll()} + *{@link #pollFirst() pollFirst()} *- * *{@link #poll(long, TimeUnit) poll(time, unit)} - *{@link #pollFirst(long, TimeUnit) pollFirst(time, unit)} + *{@link #take() take()} + *{@link #takeFirst() takeFirst()} *- * *Examine + *{@link #poll(long, TimeUnit) poll(time, unit)} + *{@link #pollFirst(long, TimeUnit) pollFirst(time, unit)} *- * *{@link #element() element()} - *{@link #getFirst() getFirst()} + *Examine + *{@link #element() element()} + *{@link #getFirst() getFirst()} *- * *{@link #peek() peek()} - *{@link #peekFirst() peekFirst()} + *{@link #peek() peek()} + *{@link #peekFirst() peekFirst()} *Summary of BlockingQueue methods ** *- * Throws exception - *Special value - *Blocks - *Times out + *Throws exception + *Special value + *Blocks + *Times out *- * *Insert + *Insert *{@link #add(Object) add(e)} *{@link #offer(Object) offer(e)} *{@link #put(Object) put(e)} *{@link #offer(Object, long, TimeUnit) offer(e, time, unit)} *- * *Remove + *Remove *{@link #remove() remove()} *{@link #poll() poll()} *{@link #take() take()} *{@link #poll(long, TimeUnit) poll(time, unit)} *- * *Examine + *Examine *{@link #element() element()} *{@link #peek() peek()} - *not applicable - *not applicable + *not applicable + *not applicable *Summary of task execution methods ** *- * Call from non-fork/join clients - *Call from within fork/join computations + *Call from non-fork/join clients + *Call from within fork/join computations *- * *Arrange async execution + *Arrange async execution *{@link #execute(ForkJoinTask)} *{@link ForkJoinTask#fork} *- * *Await and obtain result + *Await and obtain result *{@link #invoke(ForkJoinTask)} *{@link ForkJoinTask#invoke} *- * diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/doc-files/coll-designfaq.html --- a/jdk/src/java.base/share/classes/java/util/doc-files/coll-designfaq.html Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/doc-files/coll-designfaq.html Wed Aug 23 10:58:11 2017 -0700 @@ -1,7 +1,4 @@ - - - + - - +Arrange exec and obtain Future + *Arrange exec and obtain Future *{@link #submit(ForkJoinTask)} *{@link ForkJoinTask#fork} (ForkJoinTasks are Futures) *Java Collections API Design FAQ +Java Collections API Design FAQ
-
+
This document answers frequently asked questions concerning the design of the Java collections framework. It is derived from the large volume of traffic on the collections-comments alias. It @@ -105,10 +101,10 @@ collections that send out Events when they're modified? -
+
Core Interfaces - General Questions
-
-- Why don't you support immutability +
- Why don't you support immutability directly in the core collection interfaces so that you can do away with optional operations (and UnsupportedOperationException)? @@ -168,7 +164,7 @@ very small set of core interfaces that can throw a runtime exception.
-- Won't programmers have to surround any +
- Won't programmers have to surround any code that calls optional operations with a try-catch clause in case they throw an UnsupportedOperationException?
-It was never our intention that programs should catch these @@ -176,7 +172,7 @@ should only arise as a result of programming errors, in which case, your program will halt due to the uncaught exception.
- Why isn't there a core interface for +
- Why isn't there a core interface for "bags" (AKA multisets)?
-The Collection interface provides this functionality. We are not providing any public implementations of this interface, as we think @@ -185,7 +181,7 @@ atop AbstractCollection (for example, the Collection returned by Map.values).
- Why didn't you use "Beans-style +
- Why didn't you use "Beans-style names" for consistency?
While the names of the new collections methods do not adhere to the "Beans naming conventions", we believe that they are @@ -207,10 +203,10 @@ case. Thus, we adopted the "traditional" JDK style rather than the Beans style.
+
Collection Interface
-
-- Why doesn't Collection extend Cloneable +
- Why doesn't Collection extend Cloneable and Serializable?
-Many Collection implementations (including all of the ones provided by the JDK) will have a public clone method, but it would @@ -224,7 +220,7 @@ this type, and use the addAll method to copy the elements of the original collection into the new one.
- Why don't you provide an "apply" method +
- Why don't you provide an "apply" method in Collection to apply a given method ("upcall") to all the elements of the Collection?
-This is what is referred to as an "Internal Iterator" in the @@ -235,7 +231,7 @@ this functionality is increased by the fact that it requires a public interface to describe upcalls.
- Why didn't you provide a "Predicate" +
- Why didn't you provide a "Predicate" interface, and related methods (e.g., a method to find the first element in the Collection satisfying the predicate)?
-It's easy to implement this functionality atop Iterators, and @@ -244,14 +240,14 @@ weight. It could be added to the Collections class at a later date (implemented atop Iterator), if it's deemed useful.
- Why don't you provide a form of the +
- Why don't you provide a form of the addAll method that takes an Enumeration (or an Iterator)?
-Because we don't believe in using Enumerations (or Iterators) as "poor man's collections." This was occasionally done in prior releases, but now that we have the Collection interface, it is the preferred way to pass around abstract collections of objects.
- Why don't the concrete implementations +
- Why don't the concrete implementations in the JDK have Enumeration (or Iterator) constructors?
-Again, this is an instance of an Enumeration serving as a "poor man's collection" and we're trying to discourage that. Note @@ -259,7 +255,7 @@ should have constructors that take a Collection (and create a new Collection with the same elements).
- Why don't you provide an Iterator.add +
- Why don't you provide an Iterator.add method?
The semantics are unclear, given that the contract for Iterator makes no guarantees about the order of iteration. Note, however, @@ -267,10 +263,10 @@ guarantee the order of the iteration.
+
List Interface
-
-- Why don't you rename the List +
- Why don't you rename the List interface to Sequence; doesn't "list" generally suggest "linked list"? Also, doesn't it conflict with java.awt.List?
-People were evenly divided as to whether List suggests linked @@ -285,16 +281,16 @@ import java.awt.*; import java.util.List; // Dictates interpretation of "List"
- Why don't you rename List's set +
- Why don't you rename List's set method to replace, to avoid confusion with Set.
It was decided that the "set/get" naming convention was strongly enough enshrined in the language that we'd stick with it.
+
Map Interface
-
-- Why doesn't Map extend +
- Why doesn't Map extend Collection?
This was by design. We feel that mappings are not collections and collections are not mappings. Thus, it makes little sense for @@ -317,10 +313,10 @@ Lists.
+
Iterator Interface
-
-- Why doesn't Iterator extend +
- Why doesn't Iterator extend Enumeration?
-We view the method names for Enumeration as unfortunate. They're very long, and very frequently used. Given that we were adding a @@ -329,7 +325,7 @@ names. Of course we could support the new and old names in Iterator, but it doesn't seem worthwhile.
- Why don't you provide an +
- Why don't you provide an Iterator.peek method that allows you to look at the next element in an iteration without advancing the iterator?
It can be implemented atop the current Iterators (a similar @@ -338,10 +334,10 @@ that everyone has to implement.
+
Miscellaneous
-
-- Why did you write a new collections +
- Why did you write a new collections framework instead of adopting JGL (a preexisting collections package from ObjectSpace, Inc.) into the JDK?
-If you examine the goals for our Collections framework (in the @@ -363,7 +359,7 @@ as we can to keep them small and manageable, so that Java continues to be an easy, fun language to learn and to use.
- Why don't you eliminate all of the +
- Why don't you eliminate all of the methods and classes that return "views" (Collections backed by other collection-like objects). This would greatly reduce aliasing. @@ -380,7 +376,7 @@ taking List on input do not have to write secondary forms taking an offset and a length (as they do for arrays).
-- Why don't you provide for +
- Why don't you provide for "observable" collections that send out Events when they're modified?
Primarily, resource constraints. If we're going to commit to @@ -390,9 +386,9 @@ facility on top of the public APIs.
+
-Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/doc-files/coll-index.html --- a/jdk/src/java.base/share/classes/java/util/doc-files/coll-index.html Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/doc-files/coll-index.html Wed Aug 23 10:58:11 2017 -0700 @@ -1,6 +1,4 @@ - - + - +
+Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.The Collections Framework @@ -71,7 +68,7 @@ frequently asked questions (FAQ) about the design of the collections framework. -
+
Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/doc-files/coll-overview.html --- a/jdk/src/java.base/share/classes/java/util/doc-files/coll-overview.html Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/doc-files/coll-overview.html Wed Aug 23 10:58:11 2017 -0700 @@ -1,7 +1,4 @@ - - - + - - + +
Redwood Shores, CA 94065 USA. All rights reserved.Collections Framework Overview +Collections Framework Overview
@@ -73,7 +88,7 @@General-purpose implementations. Primary implementations of the collection interfaces. Legacy implementations. The collection classes -from earlier releases, Vector and Hashtable, were +from earlier releases, Vector
andHashtable
, were retrofitted to implement the collection interfaces.Special-purpose implementations. Implementations designed for use in special situations. These @@ -101,57 +116,57 @@
Collection Interfaces
The collection interfaces are divided into two groups. -The most basic interface, java.util.Collection, +The most basic interface,
java.util.Collection
, has the following descendants:-
-- java.util.Set
-- java.util.SortedSet
-- java.util.NavigableSet
-- java.util.Queue
-- java.util.concurrent.BlockingQueue
-- java.util.concurrent.TransferQueue
-- java.util.Deque
-- java.util.concurrent.BlockingDeque
+- +
java.util.Set
- +
java.util.SortedSet
- +
java.util.NavigableSet
- +
java.util.Queue
- +
java.util.concurrent.BlockingQueue
- +
java.util.concurrent.TransferQueue
- +
java.util.Deque
java.util.concurrent.BlockingDeque
The other collection interfaces are based on java.util.Map and are +
The other collection interfaces are based on
java.util.Map
and are not true collections. However, these interfaces contain collection-view operations, which enable them to be -manipulated as collections. Map has the following +manipulated as collections.Map
has the following offspring:-
- java.util.SortedMap
-- java.util.NavigableMap
-- java.util.concurrent.ConcurrentMap
-- java.util.concurrent.ConcurrentNavigableMap
+- +
java.util.SortedMap
- +
java.util.NavigableMap
- +
java.util.concurrent.ConcurrentMap
java.util.concurrent.ConcurrentNavigableMap
Many of the modification methods in the collection interfaces are labeled optional. Implementations are permitted to not perform one or more of these operations, throwing a runtime -exception (UnsupportedOperationException) if they are +exception (
UnsupportedOperationException
) if they are attempted. The documentation for each implementation must specify which optional operations are supported. Several terms are introduced to aid in this specification:
- Collections that do not support modification operations (such -as add, remove and clear) are referred +as
add
,remove
andclear
) are referred to as unmodifiable. Collections that are not unmodifiable are modifiable.- Collections that additionally guarantee that no change in the -Collection object will be visible are referred to as +
Collection
object will be visible are referred to as immutable. Collections that are not immutable are mutable.- Lists that guarantee that their size remains constant even @@ -161,15 +176,15 @@
- Lists that support fast (generally constant time) indexed element access are known as random access lists. Lists that do not support fast indexed element access are known as -sequential access lists. The RandomAccess +sequential access lists. The
RandomAccess
marker interface enables lists to advertise the fact that they support random access. This enables generic algorithms to change their behavior to provide good performance when applied to either random or sequential access lists.Some implementations restrict what elements (or in the case of -Maps, keys and values) can be stored. Possible +
Maps
, keys and values) can be stored. Possible restrictions include requiring elements to:
- Be of a particular type.
@@ -178,77 +193,70 @@Attempting to add an element that violates an implementation's restrictions results in a runtime exception, typically a -ClassCastException, an IllegalArgumentException, -or a NullPointerException. Attempting to remove or test +
-ClassCastException
, anIllegalArgumentException
, +or aNullPointerException
. Attempting to remove or test for the presence of an element that violates an implementation's restrictions can result in an exception. Some restricted collections permit this usage.
+
Collection Implementations
Classes that implement the collection interfaces typically have names in the form of <Implementation-style><Interface>. The general purpose implementations are summarized in the following table:
-+
+
General purpose implementations - + +Interface -Hash Table -Resizable Array -Balanced Tree -Linked List -Hash Table + Linked List +Interface +Hash Table +Resizable Array +Balanced Tree +Linked List +Hash Table + Linked List - - Set
HashSet -- TreeSet -- LinkedHashSet ++ Set
+ HashSet
+ + TreeSet
+ LinkedHashSet
- - List
- ArrayList -- LinkedList -+ + List
+ + ArrayList
+ + LinkedList
- - Deque
- ArrayDeque -- LinkedList -+ + Deque
+ + ArrayDeque
+ + LinkedList
- - +- Map
HashMap -- TreeMap -- LinkedHashMap ++ Map
+ HashMap
+ + TreeMap
+ LinkedHashMap
The general-purpose implementations support all of the optional operations in the collection interfaces and have no restrictions on the elements they may contain. They are -unsynchronized, but the Collections class contains static +unsynchronized, but the
-Collections
class contains static factories called synchronization wrappers that can be used to add @@ -256,15 +264,15 @@ implementations have fail-fast iterators, which detect invalid concurrent modification, and fail quickly and cleanly (rather than behaving erratically).The AbstractCollection, AbstractSet, -AbstractList, AbstractSequentialList and -AbstractMap classes provide basic implementations of the +
The
-AbstractCollection
,AbstractSet
, +AbstractList
,AbstractSequentialList
and +AbstractMap
classes provide basic implementations of the core collection interfaces, to minimize the effort required to implement them. The API documentation for these classes describes precisely how each method is implemented so the implementer knows which methods must be overridden, given the performance of the basic operations of a specific implementation.
+
Concurrent Collections
Applications that use collections from more than one thread must be carefully programmed. In general, this is known as concurrent @@ -279,47 +287,47 @@ in concurrent programming.
These concurrent-aware interfaces are available:
-
- BlockingQueue
-- TransferQueue
-- BlockingDeque
-- ConcurrentMap
-- ConcurrentNavigableMap
+- +
BlockingQueue
- +
TransferQueue
- +
BlockingDeque
- +
ConcurrentMap
ConcurrentNavigableMap
The following concurrent-aware implementation classes are available. See the API documentation for the correct usage of these implementations.
-
-- LinkedBlockingQueue
-- ArrayBlockingQueue
-- PriorityBlockingQueue
-- DelayQueue
-- SynchronousQueue
+- +
LinkedBlockingQueue
- +
ArrayBlockingQueue
- +
PriorityBlockingQueue
- +
DelayQueue
SynchronousQueue
- LinkedBlockingDeque
+"../concurrent/LinkedBlockingDeque.html">LinkedBlockingDeque
- LinkedTransferQueue
-- CopyOnWriteArrayList
-- CopyOnWriteArraySet
-- ConcurrentSkipListSet
-- ConcurrentHashMap
-- ConcurrentSkipListMap
+"../concurrent/LinkedTransferQueue.html">LinkedTransferQueue
+- +
CopyOnWriteArrayList
- +
CopyOnWriteArraySet
- +
ConcurrentSkipListSet
- +
ConcurrentHashMap
ConcurrentSkipListMap
+
Design Goals
The main design goal was to produce an API that was small in size and, more importantly, in "conceptual weight." It @@ -332,7 +340,7 @@ not attempt to capture such subtle distinctions as mutability, modifiability, and resizability. Instead, certain calls in the core interfaces are optional, enabling implementations to throw -an UnsupportedOperationException to indicate that they do +an
@@ -346,13 +354,13 @@UnsupportedOperationException
to indicate that they do not support a specified optional operation. Collection implementers must clearly document which optional operations are supported by an implementation.It was critical that all reasonable representations of collections interoperate well. This included arrays, which cannot -be made to implement the Collection interface directly +be made to implement the
-Collection
interface directly without changing the language. Thus, the framework includes methods to enable collections to be moved into arrays, arrays to be viewed as collections, and maps to be viewed as collections.
+
-Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/doc-files/coll-reference.html --- a/jdk/src/java.base/share/classes/java/util/doc-files/coll-reference.html Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/doc-files/coll-reference.html Wed Aug 23 10:58:11 2017 -0700 @@ -1,7 +1,4 @@ - - - + - +
+Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.Outline of the Collections Framework +Outline of the Collections Framework
@@ -48,21 +45,21 @@Set - The familiar set abstraction. No duplicate elements permitted. May or -may not be ordered. Extends the Collection interface. +may not be ordered. Extends theCollection
interface.List - Ordered collection, also known as a sequence. Duplicates are generally permitted. Allows positional access. Extends the -Collection interface. +Collection
interface.Queue - A collection designed for holding elements before processing. Besides -basic Collection operations, queues provide additional +basic Collection
operations, queues provide additional insertion, extraction, and inspection operations.Deque - A double ended queue, supporting element insertion and -removal at both ends. Extends the Queue interface. +removal at both ends. Extends theQueue
interface.Map - A mapping from keys to values. Each key can map to one value. @@ -70,62 +67,62 @@ "../SortedSet.html">SortedSet - A set whose elements are automatically sorted, either in their natural ordering (see the Comparable +"../../lang/Comparable.html">Comparable
interface) or by a Comparator -object provided when a SortedSet instance is created. -Extends the Set interface. +"../Comparator.html">Comparator
+object provided when aSortedSet
instance is created. +Extends theSet
interface.SortedMap - A map whose mappings are automatically sorted by key, either using the natural ordering of the keys or by a comparator -provided when a SortedMap instance is created. Extends the -Map interface. +provided when aSortedMap
instance is created. Extends the +Map
interface.NavigableSet -- A SortedSet extended with navigation methods reporting -closest matches for given search targets. A NavigableSet +- A SortedSet
extended with navigation methods reporting +closest matches for given search targets. ANavigableSet
may be accessed and traversed in either ascending or descending order.NavigableMap -- A SortedMap extended with navigation methods returning +- A SortedMap
extended with navigation methods returning the closest matches for given search targets. A -NavigableMap can be accessed and traversed in either +NavigableMap
can be accessed and traversed in either ascending or descending key order.BlockingQueue -- A Queue with operations that wait for the queue to +- A Queue
with operations that wait for the queue to become nonempty when retrieving an element and that wait for space to become available in the queue when storing an element. (This -interface is part of the java.util.concurrent +interface is part of thejava.util.concurrent
package.)TransferQueue -- A BlockingQueue in which producers can wait for +- A BlockingQueue
in which producers can wait for consumers to receive elements. (This interface is part of the -java.util.concurrent +java.util.concurrent
package.)BlockingDeque -- A Deque with operations that wait for the deque to +- A Deque
with operations that wait for the deque to become nonempty when retrieving an element and wait for space to become available in the deque when storing an element. Extends both -the Deque and BlockingQueue interfaces. (This -interface is part of the java.util.concurrent +theDeque
andBlockingQueue
interfaces. (This +interface is part of thejava.util.concurrent
package.)ConcurrentMap -- A Map with atomic putIfAbsent, remove, -and replace methods. (This interface is part of the -java.util.concurrent package.) +- AMap
with atomicputIfAbsent
,remove
, +andreplace
methods. (This interface is part of the +java.util.concurrent
package.)-ConcurrentNavigableMap - A ConcurrentMap that -is also a NavigableMap. +ConcurrentNavigableMap - AConcurrentMap
that +is also aNavigableMap
.General-purpose implementations - The primary @@ -133,52 +130,52 @@
- HashSet - Hash -table implementation of the Set interface. The best -all-around implementation of the Set interface.
+table implementation of theSet
interface. The best +all-around implementation of theSet
interface.TreeSet -- Red-black tree implementation of the NavigableSet +- Red-black tree implementation of the NavigableSet
interface.LinkedHashSet -- Hash table and linked list implementation of the Set -interface. An insertion-ordered Set implementation that -runs nearly as fast as HashSet. +- Hash table and linked list implementation of theSet
+interface. An insertion-orderedSet
implementation that +runs nearly as fast asHashSet
.ArrayList - -Resizable array implementation of the List interface (an -unsynchronized Vector). The best all-around implementation -of the List interface. +Resizable array implementation of theList
interface (an +unsynchronizedVector
). The best all-around implementation +of theList
interface.ArrayDeque - -Efficient, resizable array implementation of the Deque +Efficient, resizable array implementation of the Deque
interface.LinkedList -- Doubly-linked list implementation of the List interface. -Provides better performance than the ArrayList +- Doubly-linked list implementation of the List
interface. +Provides better performance than theArrayList
implementation if elements are frequently inserted or deleted -within the list. Also implements the Deque interface. When -accessed through the Queue interface, LinkedList +within the list. Also implements theDeque
interface. When +accessed through theQueue
interface,LinkedList
acts as a FIFO queue.PriorityQueue - Heap implementation of an unbounded priority queue. HashMap - Hash -table implementation of the Map interface (an -unsynchronized Hashtable that supports null keys -and values). The best all-around implementation of the Map +table implementation of the Map
interface (an +unsynchronizedHashtable
that supportsnull
keys +and values). The best all-around implementation of theMap
interface.TreeMap -Red-black tree implementation of the NavigableMap +Red-black tree implementation of the NavigableMap
interface.LinkedHashMap -- Hash table and linked list implementation of the Map -interface. An insertion-ordered Map implementation that -runs nearly as fast as HashMap. Also useful for building +- Hash table and linked list implementation of the @@ -192,9 +189,9 @@ "../Collections.html#unmodifiableCollection-java.util.Collection-"> Collections.unmodifiableInterface - Returns an unmodifiable view of a specified collection that throws -an UnsupportedOperationException if the user attempts to +anMap
+interface. An insertion-orderedMap
implementation that +runs nearly as fast asHashMap
. Also useful for building caches (see removeEldestEntry(Map.Entry) ).UnsupportedOperationException
if the user attempts to modify it. -Collections.synchronizedInterface @@ -206,7 +203,7 @@ "../Collections.html#checkedCollection-java.util.Collection-java.lang.Class-"> Collections.checkedInterface - Returns a dynamically type-safe view of the specified collection, which -throws a ClassCastException if a client attempts to add an +throws a ClassCastException
if a client attempts to add an element of the wrong type. The generics mechanism in the language provides compile-time (static) type checking, but it is possible to bypass this mechanism. Dynamically type-safe views eliminate this @@ -219,12 +216,12 @@newSetFromMap(Map) - Creates a general-purpose -Set implementation from a general-purpose Map + Set
implementation from a general-purposeMap
implementation.asLifoQueue(Deque) - Returns a view of a -Deque as a Last In First Out (LIFO) Queue. +Deque
as a Last In First Out (LIFO)Queue
.Convenience implementations - High-performance @@ -259,12 +256,12 @@ @@ -272,18 +269,18 @@
- Vector - -Synchronized resizable array implementation of the List +Synchronized resizable array implementation of the
List
interface with additional legacy methods.- Hashtable -- Synchronized hash table implementation of the Map -interface that does not allow null keys or values, plus +- Synchronized hash table implementation of the
Map
+interface that does not allownull
keys or values, plus additional legacy methods.
- WeakHashMap -- An implementation of the Map interface that stores only +- An implementation of the
Map
interface that stores only weak references to its keys. Storing only weak references enables key-value pairs to be garbage collected when the key is no -longer referenced outside of the WeakHashMap. This class +longer referenced outside of theWeakHashMap
. This class is the easiest way to use the power of weak references. It is useful for implementing registry-like data structures, where the utility of an entry vanishes when its key is no longer reachable by any thread.- IdentityHashMap -- Identity-based Map implementation based on a hash table. +- Identity-based
Map
implementation based on a hash table. This class is useful for topology-preserving object graph transformations (such as serialization or deep copying). To perform these transformations, you must maintain an identity-based "node @@ -292,43 +289,43 @@ object-to-meta-information mappings in dynamic debuggers and similar systems. Finally, identity-based maps are useful in preventing "spoof attacks" resulting from intentionally perverse -equals methods. (IdentityHashMap never invokes the equals +equals methods. (IdentityHashMap
never invokes the equals method on its keys.) An added benefit of this implementation is that it is fast.- CopyOnWriteArrayList -- A List implementation backed by an copy-on-write array. -All mutative operations (such as add, set, and -remove) are implemented by making a new copy of the array. +- A
List
implementation backed by an copy-on-write array. +All mutative operations (such asadd
,set
, and +remove
) are implemented by making a new copy of the array. No synchronization is necessary, even during iteration, and iterators are guaranteed never to throw -ConcurrentModificationException. This implementation is +ConcurrentModificationException
. This implementation is well-suited to maintaining event-handler lists (where change is infrequent, and traversal is frequent and potentially time-consuming).- CopyOnWriteArraySet -- A Set implementation backed by a copy-on-write array. -This implementation is similar to CopyOnWriteArrayList. -Unlike most Set implementations, the add, -remove, and contains methods require time +- A
Set
implementation backed by a copy-on-write array. +This implementation is similar toCopyOnWriteArrayList
. +Unlike mostSet
implementations, theadd
, +remove
, andcontains
methods require time proportional to the size of the set. This implementation is well suited to maintaining event-handler lists that must prevent duplicates.- EnumSet - A -high-performance Set implementation backed by a bit -vector. All elements of each EnumSet instance must be +high-performance
Set
implementation backed by a bit +vector. All elements of eachEnumSet
instance must be elements of a single enum type.- EnumMap - A -high-performance Map implementation backed by an array. -All keys in each EnumMap instance must be elements of a +high-performance
Map
implementation backed by an array. +All keys in eachEnumMap
instance must be elements of a single enum type.Concurrent implementations - These -implementations are part of java.util.concurrent. +implementations are part of java.util.concurrent
.
- ConcurrentLinkedQueue @@ -352,7 +349,7 @@
- SynchronousQueue - A simple rendezvous mechanism that uses the -BlockingQueue interface.
+BlockingQueue
interface.LinkedBlockingDeque - An optionally bounded FIFO @@ -360,25 +357,25 @@ LinkedTransferQueue - An unbounded -TransferQueue backed by linked nodes. +TransferQueue
backed by linked nodes.ConcurrentHashMap -- A highly concurrent, high-performance ConcurrentMap +- A highly concurrent, high-performance +replacement forConcurrentMap
implementation based on a hash table. This implementation never blocks when performing retrievals and enables the client to select the concurrency level for updates. It is intended as a drop-in -replacement for Hashtable. In -addition to implementing ConcurrentMap, it supports all of -the legacy methods of Hashtable.Hashtable
. In +addition to implementingConcurrentMap
, it supports all of +the legacy methods ofHashtable
.ConcurrentSkipListSet - Skips list implementation of -the NavigableSet interface. +theNavigableSet
interface.ConcurrentSkipListMap - Skips list implementation of -the ConcurrentNavigableMap interface. +theConcurrentNavigableMap
interface.Abstract implementations - Skeletal @@ -387,25 +384,25 @@
- AbstractCollection -- Skeletal Collection implementation that is neither a set +- Skeletal
Collection
implementation that is neither a set nor a list (such as a "bag" or multiset).- AbstractSet -- Skeletal Set implementation.
+- SkeletalSet
implementation.AbstractList -- Skeletal List implementation backed by a random access +- Skeletal List
implementation backed by a random access data store (such as an array).AbstractSequentialList -- Skeletal List implementation backed by a sequential +- Skeletal List
implementation backed by a sequential access data store (such as a linked list).AbstractQueue -- Skeletal Queue implementation. +- SkeletalQueue
implementation.AbstractMap -- Skeletal Map implementation. +- SkeletalMap
implementation.Algorithms - The @@ -514,7 +511,7 @@ - Represents an order relation, which can be used to sort a list or maintain order in a sorted set or map. Can override a type's natural ordering or order objects of a type that does not implement -the Comparable interface. +theIterator -- In addition to the functionality of the Enumeration +- In addition to the functionality of the Enumeration
interface, enables the user to remove elements from the backing collection with well-defined, useful semantics.ListIterator - Iterator for use with lists. In addition to the functionality of -the Iterator interface, supports bidirectional iteration, +the Iterator
interface, supports bidirectional iteration, element replacement, element insertion, and index retrieval.Comparable
interface.Runtime exceptions @@ -536,7 +533,7 @@ -
- RandomAccess -- Marker interface that lets List implementations indicate +- Marker interface that lets
List
implementations indicate that they support fast (generally constant time) random access. This lets generic algorithms change their behavior to provide good performance when applied to either random or sequential access @@ -550,14 +547,14 @@- Arrays - Contains static methods to sort, search, compare, hash, copy, -resize, convert to String, and fill arrays of primitives +resize, convert to
String
, and fill arrays of primitives and objects.
+
-Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/regex/Pattern.java --- a/jdk/src/java.base/share/classes/java/util/regex/Pattern.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/regex/Pattern.java Wed Aug 23 10:58:11 2017 -0700 @@ -81,309 +81,296 @@ * *
+Copyright © 1998, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.*
@@ -432,26 +419,29 @@ * - * - *- * + * * - *Construct - *Matches + * + *+ * * - *Construct + *Matches *- * + * Characters * - * Characters - * x - *The character x - * {@code \\} - *The backslash character {@code \0}n - *The character with octal value {@code 0}n + * + * x + *The character x + * {@code \\} + *The backslash character - * {@code \0}n + *The character with octal value {@code 0}n * (0 {@code <=} n {@code <=} 7) {@code \0}nn - *The character with octal value {@code 0}nn + * - * {@code \0}nn + *The character with octal value {@code 0}nn * (0 {@code <=} n {@code <=} 7) {@code \0}mnn - *The character with octal value {@code 0}mnn + * - * {@code \0}mnn + *The character with octal value {@code 0}mnn * (0 {@code <=} m {@code <=} 3, * 0 {@code <=} n {@code <=} 7) - * {@code \x}hh - *The character with hexadecimal value {@code 0x}hh - * - * \u
hhhhThe character with hexadecimal value {@code 0x}hhhh - * \x
{h...h}The character with hexadecimal value {@code 0x}h...h + * + * {@code \x}hh + *The character with hexadecimal value {@code 0x}hh + * + * \u
hhhhThe character with hexadecimal value {@code 0x}hhhh - * + * \x
{h...h}The character with hexadecimal value {@code 0x}h...h * ({@link java.lang.Character#MIN_CODE_POINT Character.MIN_CODE_POINT} * <= {@code 0x}h...h <= * {@link java.lang.Character#MAX_CODE_POINT Character.MAX_CODE_POINT}) - * - * \N{
name}
The character with Unicode character name 'name' - * {@code \t} - *The tab character ( '\u0009'
)- * {@code \n} - *The newline (line feed) character ( '\u000A'
)- * {@code \r} - *The carriage-return character ( '\u000D'
)- * {@code \f} - *The form-feed character ( '\u000C'
)- * {@code \a} - *The alert (bell) character ( '\u0007'
)- * {@code \e} - *The escape character ( '\u001B'
)+ * {@code \c}x - *The control character corresponding to x + * + * \N{
name}
The character with Unicode character name 'name' + * {@code \t} + *The tab character ( '\u0009'
)+ * {@code \n} + *The newline (line feed) character ( '\u000A'
)+ * {@code \r} + *The carriage-return character ( '\u000D'
)+ * {@code \f} + *The form-feed character ( '\u000C'
)+ * {@code \a} + *The alert (bell) character ( '\u0007'
)+ * {@code \e} + *The escape character ( '\u001B'
)* - * {@code \c}x + *The control character corresponding to x - * + * Character classes * - * Character classes - * {@code [abc]} - *{@code a}, {@code b}, or {@code c} (simple class) - * {@code [^abc]} - *Any character except {@code a}, {@code b}, or {@code c} (negation) {@code [a-zA-Z]} - *{@code a} through {@code z} + * + * {@code [abc]} + *{@code a}, {@code b}, or {@code c} (simple class) + * {@code [^abc]} + *Any character except {@code a}, {@code b}, or {@code c} (negation) - * {@code [a-zA-Z]} + *{@code a} through {@code z} * or {@code A} through {@code Z}, inclusive (range) {@code [a-d[m-p]]} - *{@code a} through {@code d}, + * - * {@code [a-d[m-p]]} + *{@code a} through {@code d}, * or {@code m} through {@code p}: {@code [a-dm-p]} (union) - * {@code [a-z&&[def]]} - *{@code d}, {@code e}, or {@code f} (intersection) {@code [a-z&&[^bc]]} - *{@code a} through {@code z}, + * + * {@code [a-z&&[def]]} + *{@code d}, {@code e}, or {@code f} (intersection) - * {@code [a-z&&[^bc]]} + *{@code a} through {@code z}, * except for {@code b} and {@code c}: {@code [ad-z]} (subtraction) {@code [a-z&&[^m-p]]} - *{@code a} through {@code z}, + * - * {@code [a-z&&[^m-p]]} + *{@code a} through {@code z}, * and not {@code m} through {@code p}: {@code [a-lq-z]}(subtraction) * - * + * Predefined character classes * - * Predefined character classes - * {@code .} - *Any character (may or may not match line terminators) - * {@code \d} - *A digit: {@code [0-9]} - * {@code \D} - *A non-digit: {@code [^0-9]} {@code \h} - *A horizontal whitespace character: + * + * {@code .} + *Any character (may or may not match line terminators) + * {@code \d} + *A digit: {@code [0-9]} + * {@code \D} + *A non-digit: {@code [^0-9]} - * {@code \h} + *A horizontal whitespace character: * [ \t\xA0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000]
- * {@code \H} - *A non-horizontal whitespace character: {@code [^\h]} - * {@code \s} - *A whitespace character: {@code [ \t\n\x0B\f\r]} - * {@code \S} - *A non-whitespace character: {@code [^\s]} {@code \v} - *A vertical whitespace character: [\n\x0B\f\r\x85\u2028\u2029]
+ *+ * {@code \H} + *A non-horizontal whitespace character: {@code [^\h]} + * {@code \s} + *A whitespace character: {@code [ \t\n\x0B\f\r]} + * {@code \S} + *A non-whitespace character: {@code [^\s]} - * {@code \v} + *A vertical whitespace character: [\n\x0B\f\r\x85\u2028\u2029]
*- * {@code \V} - *A non-vertical whitespace character: {@code [^\v]} - * {@code \w} - *A word character: {@code [a-zA-Z_0-9]} - * {@code \W} - *A non-word character: {@code [^\w]} - * + * POSIX character classes (US-ASCII only) + * {@code \V} + *A non-vertical whitespace character: {@code [^\v]} + * {@code \w} + *A word character: {@code [a-zA-Z_0-9]} + * + * {@code \W} + *A non-word character: {@code [^\w]} * - * POSIX character classes (US-ASCII only) - * {@code \p{Lower}} - *A lower-case alphabetic character: {@code [a-z]} - * {@code \p{Upper}} - *An upper-case alphabetic character:{@code [A-Z]} - * {@code \p{ASCII}} - *All ASCII:{@code [\x00-\x7F]} - * {@code \p{Alpha}} - *An alphabetic character:{@code [\p{Lower}\p{Upper}]} - * {@code \p{Digit}} - *A decimal digit: {@code [0-9]} - * {@code \p{Alnum}} - *An alphanumeric character:{@code [\p{Alpha}\p{Digit}]} + * {@code \p{Punct}} - *Punctuation: One of {@code !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~} + * {@code \p{Lower}} + *A lower-case alphabetic character: {@code [a-z]} + * {@code \p{Upper}} + *An upper-case alphabetic character:{@code [A-Z]} + * {@code \p{ASCII}} + *All ASCII:{@code [\x00-\x7F]} + * {@code \p{Alpha}} + *An alphabetic character:{@code [\p{Lower}\p{Upper}]} + * {@code \p{Digit}} + *A decimal digit: {@code [0-9]} + * {@code \p{Alnum}} + *An alphanumeric character:{@code [\p{Alpha}\p{Digit}]} * - * {@code \p{Punct}} + *Punctuation: One of {@code !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~} - * {@code \p{Graph}} - *A visible character: {@code [\p{Alnum}\p{Punct}]} - * {@code \p{Print}} - *A printable character: {@code [\p{Graph}\x20]} - * {@code \p{Blank}} - *A space or a tab: {@code [ \t]} - * {@code \p{Cntrl}} - *A control character: {@code [\x00-\x1F\x7F]} - * {@code \p{XDigit}} - *A hexadecimal digit: {@code [0-9a-fA-F]} + * {@code \p{Space}} - *A whitespace character: {@code [ \t\n\x0B\f\r]} + * {@code \p{Graph}} + *A visible character: {@code [\p{Alnum}\p{Punct}]} + * {@code \p{Print}} + *A printable character: {@code [\p{Graph}\x20]} + * {@code \p{Blank}} + *A space or a tab: {@code [ \t]} + * {@code \p{Cntrl}} + *A control character: {@code [\x00-\x1F\x7F]} + * {@code \p{XDigit}} + *A hexadecimal digit: {@code [0-9a-fA-F]} * - * {@code \p{Space}} + *A whitespace character: {@code [ \t\n\x0B\f\r]} - * + * java.lang.Character classes (simple java character type) * - * java.lang.Character classes (simple java character type) - * {@code \p{javaLowerCase}} - *Equivalent to java.lang.Character.isLowerCase() - * {@code \p{javaUpperCase}} - *Equivalent to java.lang.Character.isUpperCase() - * {@code \p{javaWhitespace}} - *Equivalent to java.lang.Character.isWhitespace() + * {@code \p{javaMirrored}} - *Equivalent to java.lang.Character.isMirrored() + * {@code \p{javaLowerCase}} + *Equivalent to java.lang.Character.isLowerCase() + * {@code \p{javaUpperCase}} + *Equivalent to java.lang.Character.isUpperCase() + * {@code \p{javaWhitespace}} + *Equivalent to java.lang.Character.isWhitespace() + * + * {@code \p{javaMirrored}} + *Equivalent to java.lang.Character.isMirrored() * - * Classes for Unicode scripts, blocks, categories and binary properties - * - * Classes for Unicode scripts, blocks, categories and binary properties - * {@code \p{IsLatin}} - *A Latin script character (script) - * {@code \p{InGreek}} - *A character in the Greek block (block) - * {@code \p{Lu}} - *An uppercase letter (category) - * {@code \p{IsAlphabetic}} - *An alphabetic character (binary property) - * {@code \p{Sc}} - *A currency symbol - * {@code \P{InGreek}} - *Any character except one in the Greek block (negation) + * {@code [\p{L}&&[^\p{Lu}]]} - *Any letter except an uppercase letter (subtraction) + * {@code \p{IsLatin}} + *A Latin script character (script) + * {@code \p{InGreek}} + *A character in the Greek block (block) + * {@code \p{Lu}} + *An uppercase letter (category) + * {@code \p{IsAlphabetic}} + *An alphabetic character (binary property) + * {@code \p{Sc}} + *A currency symbol + * {@code \P{InGreek}} + *Any character except one in the Greek block (negation) * - * {@code [\p{L}&&[^\p{Lu}]]} + *Any letter except an uppercase letter (subtraction) - * + * Boundary matchers * - * Boundary matchers - * {@code ^} - *The beginning of a line - * {@code $} - *The end of a line - * {@code \b} - *A word boundary - * {@code \b{g}} - *A Unicode extended grapheme cluster boundary - * {@code \B} - *A non-word boundary - * {@code \A} - *The beginning of the input - * {@code \G} - *The end of the previous match {@code \Z} - *The end of the input but for the final + * + * {@code ^} + *The beginning of a line + * {@code $} + *The end of a line + * {@code \b} + *A word boundary + * {@code \b{g}} + *A Unicode extended grapheme cluster boundary + * {@code \B} + *A non-word boundary + * {@code \A} + *The beginning of the input + * {@code \G} + *The end of the previous match - * {@code \Z} + *The end of the input but for the final * terminator, if any + * {@code \z} - *The end of the input * - * {@code \z} + *The end of the input - * - * Linebreak matcher {@code \R} - *Any Unicode linebreak sequence, is equivalent to + * + * + * Linebreak matcher * - * {@code \R} + *Any Unicode linebreak sequence, is equivalent to * \u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029] *
- * - * Unicode Extended Grapheme matcher + * {@code \X} - *Any Unicode extended grapheme cluster * - * Unicode Extended Grapheme matcher - * + * Greedy quantifiers + * + * {@code \X} + *Any Unicode extended grapheme cluster * - * Greedy quantifiers - * X{@code ?} - *X, once or not at all - * X{@code *} - *X, zero or more times - * X{@code +} - *X, one or more times - * X - *{
n}
X, exactly n times - * X - *{
n{@code ,}}X, at least n times + * X - *{
n{@code ,}m}
X, at least n but not more than m times + * X{@code ?} + *X, once or not at all + * X{@code *} + *X, zero or more times + * X{@code +} + *X, one or more times + * X + *{
n}
X, exactly n times + * X + *{
n{@code ,}}X, at least n times * - * X + *{
n{@code ,}m}
X, at least n but not more than m times - * + * Reluctant quantifiers * - * Reluctant quantifiers - * X{@code ??} - *X, once or not at all - * X{@code *?} - *X, zero or more times - * X{@code +?} - *X, one or more times - * X - *{
n}?
X, exactly n times - * X - *{
n,}?
X, at least n times + * X - *{
n{@code ,}m}?
X, at least n but not more than m times + * X{@code ??} + *X, once or not at all + * X{@code *?} + *X, zero or more times + * X{@code +?} + *X, one or more times + * X + *{
n}?
X, exactly n times + * X + *{
n,}?
X, at least n times * - * X + *{
n{@code ,}m}?
X, at least n but not more than m times - * + * Possessive quantifiers * - * Possessive quantifiers - * X{@code ?+} - *X, once or not at all - * X{@code *+} - *X, zero or more times - * X{@code ++} - *X, one or more times - * X - *{
n}+
X, exactly n times - * X - *{
n,}+
X, at least n times + * X - *{
n{@code ,}m}+
X, at least n but not more than m times + * X{@code ?+} + *X, once or not at all + * X{@code *+} + *X, zero or more times + * X{@code ++} + *X, one or more times + * X + *{
n}+
X, exactly n times + * X + *{
n,}+
X, at least n times * - * X + *{
n{@code ,}m}+
X, at least n but not more than m times - * + * Logical operators * - * Logical operators - * XY - *X followed by Y - * X{@code |}Y - *Either X or Y + * {@code (}X{@code )} - *X, as a capturing group + * XY + *X followed by Y + * X{@code |}Y + *Either X or Y * - * {@code (}X{@code )} + *X, as a capturing group - * + * Back references * - * Back references {@code \}n - *Whatever the nth + * - * - * {@code \}n + *Whatever the nth * capturing group matched {@code \}k<name> - *Whatever the + * * - * {@code \}k<name> + *Whatever the * named-capturing group "name" matched - * + * Quotation * - * Quotation - * {@code \} - *Nothing, but quotes the following character - * {@code \Q} - *Nothing, but quotes all characters until {@code \E} + * {@code \E} - *Nothing, but ends quoting started by {@code \Q} + * {@code \} + *Nothing, but quotes the following character + * {@code \Q} + *Nothing, but quotes all characters until {@code \E} * * - * {@code \E} + *Nothing, but ends quoting started by {@code \Q} - * + * Special constructs (named-capturing and non-capturing) * - * Special constructs (named-capturing and non-capturing) - * - * (?<name>
X{@code )}X, as a named-capturing group - * {@code (?:}X{@code )} - *X, as a non-capturing group - * (?idmsuxU-idmsuxU)
Nothing, but turns match flags i + * + * + * (?<name>
X{@code )}X, as a named-capturing group + * {@code (?:}X{@code )} + *X, as a non-capturing group - * + * (?idmsuxU-idmsuxU)
Nothing, but turns match flags i * d m s * u x U * on - off - * (?idmsux-idmsux:
X{@code )}X, as a non-capturing group with the + * - * + * (?idmsux-idmsux:
X{@code )}X, as a non-capturing group with the * given flags i d * m s u * x on - off - * {@code (?=}X{@code )} - *X, via zero-width positive lookahead - * {@code (?!}X{@code )} - *X, via zero-width negative lookahead - * {@code (?<=}X{@code )} - *X, via zero-width positive lookbehind - * {@code (?X{@code )} - *X, via zero-width negative lookbehind + * {@code (?>}X{@code )} - *X, as an independent, non-capturing group + * {@code (?=}X{@code )} + *X, via zero-width positive lookahead + * {@code (?!}X{@code )} + *X, via zero-width negative lookahead + * {@code (?<=}X{@code )} + *X, via zero-width positive lookbehind + * {@code (?X{@code )} + *X, via zero-width negative lookbehind * * * {@code (?>}X{@code )} + *X, as an independent, non-capturing group The precedence of character-class operators is as follows, from * highest to lowest: * - *
+ *
* **
+ * + * + ** - * Precedence Name Example + * 1 + *- * 1 *Literal escape *{@code \x} 2 + *- * 2 *Grouping *{@code [...]} 3 + *- * 3 *Range *{@code a-z} 4 + *- * 4 *Union *{@code [a-e][i-u]} 5 + ** - * 5 *Intersection *{@code [a-z&&[aeiou]]} Note that a different set of metacharacters are in effect inside * a character class than outside a character class. For instance, the @@ -467,18 +457,18 @@ * *
* - *
*- A newline (line feed) character ({@code '\n'}), + *
- A newline (line feed) character ({@code '\n'}), * *
- A carriage-return character followed immediately by a newline - * character ({@code "\r\n"}), + * character ({@code "\r\n"}), * - *
- A standalone carriage-return character ({@code '\r'}), + *
- A standalone carriage-return character ({@code '\r'}), * - *
- A next-line character (
'\u0085'
), + *- A next-line character (
'\u0085'
), * - *- A line-separator character (
'\u2028'
), or + *- A line-separator character (
'\u2028'
), or * - *- A paragraph-separator character (
'\u2029'
). + *- A paragraph-separator character (
'\u2029'
). * *If {@link #UNIX_LINES} mode is activated, then the only line terminators @@ -501,19 +491,12 @@ * left to right. In the expression {@code ((A)(B(C)))}, for example, there * are four such groups:
* - *+ *- *
- * - *- * 1 - *{@code ((A)(B(C)))} - * 2 - *{@code (A)} - * 3 - *{@code (B(C))} - * - * 4 - *{@code (C)} + *
* *- {@code ((A)(B(C)))} + *
- {@code (A)} + *
- {@code (B(C))} + *
- {@code (C)} + *
Group zero always stands for the entire expression. * @@ -649,52 +632,52 @@ * of Unicode Regular Expression * , when {@link #UNICODE_CHARACTER_CLASS} flag is specified. * - *
+ *
*
@@ -1219,34 +1202,36 @@ * * - *- * Classes - *Matches + *+ * * * - *Classes + *Matches *{@code \p{Lower}} + *- * {@code \p{Lower}} *A lowercase character:{@code \p{IsLowercase}} {@code \p{Upper}} + *- * {@code \p{Upper}} *An uppercase character:{@code \p{IsUppercase}} {@code \p{ASCII}} + *- * {@code \p{ASCII}} *All ASCII:{@code [\x00-\x7F]} {@code \p{Alpha}} + *- * {@code \p{Alpha}} *An alphabetic character:{@code \p{IsAlphabetic}} {@code \p{Digit}} + *- * {@code \p{Digit}} *A decimal digit character:{@code \p{IsDigit}} {@code \p{Alnum}} + *- * {@code \p{Alnum}} *An alphanumeric character:{@code [\p{IsAlphabetic}\p{IsDigit}]} {@code \p{Punct}} + *- * {@code \p{Punct}} *A punctuation character:{@code \p{IsPunctuation}} {@code \p{Graph}} + *- * {@code \p{Graph}} *A visible character: {@code [^\p{IsWhite_Space}\p{gc=Cc}\p{gc=Cs}\p{gc=Cn}]} {@code \p{Print}} + *- * {@code \p{Print}} *A printable character: {@code [\p{Graph}\p{Blank}&&[^\p{Cntrl}]]} {@code \p{Blank}} + *- * {@code \p{Blank}} *A space or a tab: {@code [\p{IsWhite_Space}&&[^\p{gc=Zl}\p{gc=Zp}\x0a\x0b\x0c\x0d\x85]]} {@code \p{Cntrl}} + *- * {@code \p{Cntrl}} *A control character: {@code \p{gc=Cc}} {@code \p{XDigit}} + *- * {@code \p{XDigit}} *A hexadecimal digit: {@code [\p{gc=Nd}\p{IsHex_Digit}]} {@code \p{Space}} + *- * {@code \p{Space}} *A whitespace character:{@code \p{IsWhite_Space}} {@code \d} + *- * {@code \d} *A digit: {@code \p{IsDigit}} {@code \D} + *- * {@code \D} *A non-digit: {@code [^\d]} {@code \s} + *- * {@code \s} *A whitespace character: {@code \p{IsWhite_Space}} {@code \S} + *- * {@code \S} *A non-whitespace character: {@code [^\s]} {@code \w} + *- * {@code \w} *A word character: {@code [\p{Alpha}\p{gc=Mn}\p{gc=Me}\p{gc=Mc}\p{Digit}\p{gc=Pc}\p{IsJoin_Control}]} {@code \W} + ** * {@code \W} *A non-word character: {@code [^\w]} The input {@code "boo:and:foo"}, for example, yields the following * results with these parameters: * - *
- *
* * @param input * The character sequence to be split @@ -1310,19 +1295,21 @@ *Split examples showing regex, limit, and result + *+ *
+ * * - *+ * Regex - *Limit - *Result + * * * - *Regex + *Limit + *Result + *: - *2 + *- * : + *2 *{@code { "boo", "and:foo" }} : - *5 + *+ * - *5 *{@code { "boo", "and", "foo" }} : - *-2 + *+ * - *-2 *{@code { "boo", "and", "foo" }} o - *5 + *- * o + *5 *{@code { "b", "", ":and:f", "", "" }} o - *-2 + *+ * - *-2 *{@code { "b", "", ":and:f", "", "" }} o - *0 + *+ * * - *0 *{@code { "b", "", ":and:f" }} The input {@code "boo:and:foo"}, for example, yields the following * results with these expressions: * - *
+ *
* * * @param input diff -r ea81af6257b3 -r e92e67ed12b4 jdk/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java --- a/jdk/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java Wed Aug 23 12:24:55 2017 -0400 +++ b/jdk/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java Wed Aug 23 10:58:11 2017 -0700 @@ -46,18 +46,18 @@ * Calendar}. The following are calendar-common fields and their values to be * supported for each calendar system. * - **
+ * * - *+ * Regex - *Result + * * * - *Regex + *Result + *: + *- * : *{@code { "boo", "and", "foo" }} o + ** - * o *{@code { "b", "", ":and:f" }} + *
*
* *- * * * *Field - *Value - *Description + *Field + *Value + *Description *- * *{@link Calendar#MONTH} + *{@link Calendar#MONTH} *{@link Calendar#JANUARY} to {@link Calendar#UNDECIMBER} *Month numbering is 0-based (e.g., 0 - January, ..., 11 - * December). Some calendar systems have 13 months. Month @@ -67,13 +67,13 @@ * in both of the forms. *- * *{@link Calendar#DAY_OF_WEEK} + *{@link Calendar#DAY_OF_WEEK} *{@link Calendar#SUNDAY} to {@link Calendar#SATURDAY} *Day-of-week numbering is 1-based starting from Sunday (i.e., 1 - Sunday, * ..., 7 - Saturday). *- * @@ -86,81 +86,81 @@ * * *{@link Calendar#AM_PM} + *{@link Calendar#AM_PM} *{@link Calendar#AM} to {@link Calendar#PM} *0 - AM, 1 - PM *- * * * *Calendar Type - *Field - *Value - *Description + *Calendar Type + *Field + *Value + *Description *- * *{@code "gregory"} - *{@link Calendar#ERA} - *0 + *{@code "gregory"} + *{@link Calendar#ERA} + *0 *{@link java.util.GregorianCalendar#BC} (BCE) *- * *1 + *1 *{@link java.util.GregorianCalendar#AD} (CE) *- * *{@code "buddhist"} - *{@link Calendar#ERA} - *0 + *{@code "buddhist"} + *{@link Calendar#ERA} + *0 *BC (BCE) *- * *1 + *1 *B.E. (Buddhist Era) *- * *{@code "japanese"} - *{@link Calendar#ERA} - *0 + *{@code "japanese"} + *{@link Calendar#ERA} + *0 *Seireki (Before Meiji) *- * *1 + *1 *Meiji *- * *2 + *2 *Taisho *- * *3 + *3 *Showa *- * *4 + *4 *Heisei *- * *{@link Calendar#YEAR} - *1 + *{@link Calendar#YEAR} + *1 *the first year in each era. It should be returned when a long * style ({@link Calendar#LONG_FORMAT} or {@link Calendar#LONG_STANDALONE}) is * specified. See also the * Year representation in {@code SimpleDateFormat}. *- * *{@code "roc"} - *{@link Calendar#ERA} - *0 + *{@code "roc"} + *{@link Calendar#ERA} + *0 *Before R.O.C. *- * *1 + *1 *R.O.C. *- * *{@code "islamic"} - *{@link Calendar#ERA} - *0 + *{@code "islamic"} + *{@link Calendar#ERA} + *0 *Before AH *- * *1 + *1 *Anno Hijrah (AH) *