From 70f22c649b8320c72788b01359033b49de933320 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Fri, 31 May 2013 14:32:44 +0200 Subject: [PATCH 001/118] 8022880: False sharing between PSPromotionManager instances Pad the PSPromotionManager instances in the manager array. Reviewed-by: brutisso, jmasa --- .../concurrentMarkSweepGeneration.cpp | 1 + .../parNew/parNewGeneration.hpp | 3 +- .../parNew/parOopClosures.hpp | 3 +- .../parallelScavenge/psPromotionManager.cpp | 25 +++-- .../parallelScavenge/psPromotionManager.hpp | 12 ++- .../psPromotionManager.inline.hpp | 2 +- hotspot/src/share/vm/memory/padded.hpp | 93 +++++++++++++++++++ hotspot/src/share/vm/memory/padded.inline.hpp | 49 ++++++++++ hotspot/src/share/vm/utilities/debug.hpp | 16 ++++ .../share/vm/utilities/globalDefinitions.hpp | 32 ++----- 10 files changed, 189 insertions(+), 47 deletions(-) create mode 100644 hotspot/src/share/vm/memory/padded.hpp create mode 100644 hotspot/src/share/vm/memory/padded.inline.hpp diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index c04a5261338..54ade2db111 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -50,6 +50,7 @@ #include "memory/genMarkSweep.hpp" #include "memory/genOopClosures.inline.hpp" #include "memory/iterator.hpp" +#include "memory/padded.hpp" #include "memory/referencePolicy.hpp" #include "memory/resourceArea.hpp" #include "memory/tenuredGeneration.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp index 987767b1640..6d3b25d9545 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "gc_implementation/shared/parGCAllocBuffer.hpp" #include "gc_implementation/shared/copyFailedInfo.hpp" #include "memory/defNewGeneration.hpp" +#include "memory/padded.hpp" #include "utilities/taskqueue.hpp" class ChunkArray; diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.hpp b/hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.hpp index 0d9d7761c74..00b865f2a35 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.hpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_HPP #include "memory/genOopClosures.hpp" +#include "memory/padded.hpp" // Closures for ParNewGeneration diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp index 32929e7a55c..dd3933b0009 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp @@ -29,14 +29,16 @@ #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" #include "gc_implementation/shared/gcTrace.hpp" #include "gc_implementation/shared/mutableSpace.hpp" +#include "memory/allocation.inline.hpp" #include "memory/memRegion.hpp" +#include "memory/padded.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/oop.psgc.inline.hpp" -PSPromotionManager** PSPromotionManager::_manager_array = NULL; -OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL; -PSOldGen* PSPromotionManager::_old_gen = NULL; -MutableSpace* PSPromotionManager::_young_space = NULL; +PaddedEnd* PSPromotionManager::_manager_array = NULL; +OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL; +PSOldGen* PSPromotionManager::_old_gen = NULL; +MutableSpace* PSPromotionManager::_young_space = NULL; void PSPromotionManager::initialize() { ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); @@ -45,8 +47,10 @@ void PSPromotionManager::initialize() { _old_gen = heap->old_gen(); _young_space = heap->young_gen()->to_space(); + // To prevent false sharing, we pad the PSPromotionManagers + // and make sure that the first instance starts at a cache line. assert(_manager_array == NULL, "Attempt to initialize twice"); - _manager_array = NEW_C_HEAP_ARRAY(PSPromotionManager*, ParallelGCThreads+1, mtGC); + _manager_array = PaddedArray::create_unfreeable(ParallelGCThreads + 1); guarantee(_manager_array != NULL, "Could not initialize promotion manager"); _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads); @@ -54,26 +58,21 @@ void PSPromotionManager::initialize() { // Create and register the PSPromotionManager(s) for the worker threads. for(uint i=0; iregister_queue(i, _manager_array[i]->claimed_stack_depth()); + stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth()); } - // The VMThread gets its own PSPromotionManager, which is not available // for work stealing. - _manager_array[ParallelGCThreads] = new PSPromotionManager(); - guarantee(_manager_array[ParallelGCThreads] != NULL, "Could not create PSPromotionManager"); } PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(int index) { assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range"); assert(_manager_array != NULL, "Sanity"); - return _manager_array[index]; + return &_manager_array[index]; } PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() { assert(_manager_array != NULL, "Sanity"); - return _manager_array[ParallelGCThreads]; + return &_manager_array[ParallelGCThreads]; } void PSPromotionManager::pre_scavenge() { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp index 8f4731428ac..6707ade2d17 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp @@ -29,6 +29,8 @@ #include "gc_implementation/shared/gcTrace.hpp" #include "gc_implementation/shared/copyFailedInfo.hpp" #include "memory/allocation.hpp" +#include "memory/padded.hpp" +#include "utilities/globalDefinitions.hpp" #include "utilities/taskqueue.hpp" // @@ -51,14 +53,14 @@ class MutableSpace; class PSOldGen; class ParCompactionManager; -class PSPromotionManager : public CHeapObj { +class PSPromotionManager VALUE_OBJ_CLASS_SPEC { friend class PSScavenge; friend class PSRefProcTaskExecutor; private: - static PSPromotionManager** _manager_array; - static OopStarTaskQueueSet* _stack_array_depth; - static PSOldGen* _old_gen; - static MutableSpace* _young_space; + static PaddedEnd* _manager_array; + static OopStarTaskQueueSet* _stack_array_depth; + static PSOldGen* _old_gen; + static MutableSpace* _young_space; #if TASKQUEUE_STATS size_t _masked_pushes; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp index 841ef64f20b..34c935408d8 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp @@ -32,7 +32,7 @@ inline PSPromotionManager* PSPromotionManager::manager_array(int index) { assert(_manager_array != NULL, "access of NULL manager_array"); assert(index >= 0 && index <= (int)ParallelGCThreads, "out of range manager_array access"); - return _manager_array[index]; + return &_manager_array[index]; } template diff --git a/hotspot/src/share/vm/memory/padded.hpp b/hotspot/src/share/vm/memory/padded.hpp new file mode 100644 index 00000000000..4c50b39963e --- /dev/null +++ b/hotspot/src/share/vm/memory/padded.hpp @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_MEMORY_PADDED_HPP +#define SHARE_VM_MEMORY_PADDED_HPP + +#include "memory/allocation.hpp" +#include "utilities/globalDefinitions.hpp" + +// Bytes needed to pad type to avoid cache-line sharing; alignment should be the +// expected cache line size (a power of two). The first addend avoids sharing +// when the start address is not a multiple of alignment; the second maintains +// alignment of starting addresses that happen to be a multiple. +#define PADDING_SIZE(type, alignment) \ + ((alignment) + align_size_up_(sizeof(type), alignment)) + +// Templates to create a subclass padded to avoid cache line sharing. These are +// effective only when applied to derived-most (leaf) classes. + +// When no args are passed to the base ctor. +template +class Padded : public T { + private: + char _pad_buf_[PADDING_SIZE(T, alignment)]; +}; + +// When either 0 or 1 args may be passed to the base ctor. +template +class Padded01 : public T { + public: + Padded01(): T() { } + Padded01(Arg1T arg1): T(arg1) { } + private: + char _pad_buf_[PADDING_SIZE(T, alignment)]; +}; + +// Super class of PaddedEnd when pad_size != 0. +template +class PaddedEndImpl : public T { + private: + char _pad_buf[pad_size]; +}; + +// Super class of PaddedEnd when pad_size == 0. +template +class PaddedEndImpl : public T { + // No padding. +}; + +#define PADDED_END_SIZE(type, alignment) (align_size_up_(sizeof(type), alignment) - sizeof(type)) + +// More memory conservative implementation of Padded. The subclass adds the +// minimal amount of padding needed to make the size of the objects be aligned. +// This will help reducing false sharing, +// if the start address is a multiple of alignment. +template +class PaddedEnd : public PaddedEndImpl { + // C++ don't allow zero-length arrays. The padding is put in a + // super class that is specialized for the pad_size == 0 case. +}; + +// Helper class to create an array of PaddedEnd objects. All elements will +// start at a multiple of alignment and the size will be aligned to alignment. +template +class PaddedArray { + public: + // Creates an aligned padded array. + // The memory can't be deleted since the raw memory chunk is not returned. + static PaddedEnd* create_unfreeable(uint length); +}; + +#endif // SHARE_VM_MEMORY_PADDED_HPP diff --git a/hotspot/src/share/vm/memory/padded.inline.hpp b/hotspot/src/share/vm/memory/padded.inline.hpp new file mode 100644 index 00000000000..1e9994ab647 --- /dev/null +++ b/hotspot/src/share/vm/memory/padded.inline.hpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "memory/allocation.inline.hpp" +#include "memory/padded.hpp" +#include "utilities/debug.hpp" +#include "utilities/globalDefinitions.hpp" + +// Creates an aligned padded array. +// The memory can't be deleted since the raw memory chunk is not returned. +template +PaddedEnd* PaddedArray::create_unfreeable(uint length) { + // Check that the PaddedEnd class works as intended. + STATIC_ASSERT(is_size_aligned_(sizeof(PaddedEnd), alignment)); + + // Allocate a chunk of memory large enough to allow for some alignment. + void* chunk = AllocateHeap(length * sizeof(PaddedEnd) + alignment, flags); + + // Make the initial alignment. + PaddedEnd* aligned_padded_array = (PaddedEnd*)align_pointer_up(chunk, alignment); + + // Call the default constructor for each element. + for (uint i = 0; i < length; i++) { + ::new (&aligned_padded_array[i]) T(); + } + + return aligned_padded_array; +} diff --git a/hotspot/src/share/vm/utilities/debug.hpp b/hotspot/src/share/vm/utilities/debug.hpp index 2450c8fe113..85b26f35fda 100644 --- a/hotspot/src/share/vm/utilities/debug.hpp +++ b/hotspot/src/share/vm/utilities/debug.hpp @@ -225,6 +225,22 @@ void report_untested(const char* file, int line, const char* message); void warning(const char* format, ...); +#ifdef ASSERT +// Compile-time asserts. +template struct StaticAssert; +template <> struct StaticAssert {}; + +// Only StaticAssert is defined, so if cond evaluates to false we get +// a compile time exception when trying to use StaticAssert. +#define STATIC_ASSERT(cond) \ + do { \ + StaticAssert<(cond)> DUMMY_STATIC_ASSERT; \ + (void)DUMMY_STATIC_ASSERT; /* ignore */ \ + } while (false) +#else +#define STATIC_ASSERT(cond) +#endif + // out of shared space reporting enum SharedSpaceType { SharedPermGen, diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp index 181e80a0823..f15bb5da9fe 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp @@ -410,6 +410,8 @@ inline intptr_t align_size_down(intptr_t size, intptr_t alignment) { return align_size_down_(size, alignment); } +#define is_size_aligned_(size, alignment) ((size) == (align_size_up_(size, alignment))) + // Align objects by rounding up their size, in HeapWord units. #define align_object_size_(size) align_size_up_(size, MinObjAlignment) @@ -428,6 +430,10 @@ inline intptr_t align_object_offset(intptr_t offset) { return align_size_up(offset, HeapWordsPerLong); } +inline void* align_pointer_up(const void* addr, size_t size) { + return (void*) align_size_up_((uintptr_t)addr, size); +} + // Clamp an address to be within a specific page // 1. If addr is on the page it is returned as is // 2. If addr is above the page_address the start of the *next* page will be returned @@ -449,32 +455,6 @@ inline address clamp_address_in_page(address addr, address page_address, intptr_ // The expected size in bytes of a cache line, used to pad data structures. #define DEFAULT_CACHE_LINE_SIZE 64 -// Bytes needed to pad type to avoid cache-line sharing; alignment should be the -// expected cache line size (a power of two). The first addend avoids sharing -// when the start address is not a multiple of alignment; the second maintains -// alignment of starting addresses that happen to be a multiple. -#define PADDING_SIZE(type, alignment) \ - ((alignment) + align_size_up_(sizeof(type), alignment)) - -// Templates to create a subclass padded to avoid cache line sharing. These are -// effective only when applied to derived-most (leaf) classes. - -// When no args are passed to the base ctor. -template -class Padded: public T { -private: - char _pad_buf_[PADDING_SIZE(T, alignment)]; -}; - -// When either 0 or 1 args may be passed to the base ctor. -template -class Padded01: public T { -public: - Padded01(): T() { } - Padded01(Arg1T arg1): T(arg1) { } -private: - char _pad_buf_[PADDING_SIZE(T, alignment)]; -}; //---------------------------------------------------------------------------------------------------- // Utility macros for compilers From 8a710dcc7eaf0fd5df6e468685b593a48f042cb4 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Thu, 1 Aug 2013 12:38:07 +0100 Subject: [PATCH 002/118] 8022061: More ProblemList.txt updates (7/2013) Reviewed-by: alanb, psandoz --- jdk/test/ProblemList.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 0da9ac03f82..595dfb1a30d 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -138,6 +138,9 @@ java/lang/reflect/Method/GenericStringTest.java generic-all java/lang/instrument/RedefineBigClass.sh linux-x64 java/lang/instrument/RetransformBigClass.sh linux-x64 +# 8021230 +java/lang/ThreadLocal/ThreadLocalSupplierTest.java generic-all + ############################################################################ @@ -370,6 +373,9 @@ java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all # 8020435 java/util/concurrent/CompletableFuture/Basic.java generic-all +# 8020291 +java/util/Random/RandomStreamTest.java generic-all + # 7041639, Solaris DSA keypair generation bug java/util/TimeZone/TimeZoneDatePermissionCheck.sh solaris-all From e1b3c5b5ba5cfb8243d760e99887bbe1015a9d69 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Tue, 30 Jul 2013 21:11:08 +0400 Subject: [PATCH 003/118] 7192942: (coll) Inefficient calculation of power of two in HashMap Reviewed-by: mduigou --- jdk/src/share/classes/java/util/HashMap.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/classes/java/util/HashMap.java b/jdk/src/share/classes/java/util/HashMap.java index c2aace9db8f..8dfafac8642 100644 --- a/jdk/src/share/classes/java/util/HashMap.java +++ b/jdk/src/share/classes/java/util/HashMap.java @@ -876,13 +876,9 @@ public class HashMap private static int roundUpToPowerOf2(int number) { // assert number >= 0 : "number must be non-negative"; - int rounded = number >= MAXIMUM_CAPACITY + return number >= MAXIMUM_CAPACITY ? MAXIMUM_CAPACITY - : (rounded = Integer.highestOneBit(number)) != 0 - ? (Integer.bitCount(number) > 1) ? rounded << 1 : rounded - : 1; - - return rounded; + : (number > 1) ? Integer.highestOneBit((number - 1) << 1) : 1; } /** From ebe38d6cdc5b5a0bde8a6a0b5c9953c69debf06e Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Mon, 29 Jul 2013 12:35:42 +0400 Subject: [PATCH 004/118] 8020669: (fs) Files.readAllBytes() does not read any data when Files.size() is 0 Reviewed-by: alanb, chegar, martin, rriggs --- .../share/classes/java/nio/file/Files.java | 77 +++++++++++++++---- .../java/nio/file/Files/BytesAndLines.java | 23 +++++- 2 files changed, 83 insertions(+), 17 deletions(-) diff --git a/jdk/src/share/classes/java/nio/file/Files.java b/jdk/src/share/classes/java/nio/file/Files.java index 586859f17dc..721184c1533 100644 --- a/jdk/src/share/classes/java/nio/file/Files.java +++ b/jdk/src/share/classes/java/nio/file/Files.java @@ -25,10 +25,10 @@ package java.nio.file; -import java.nio.ByteBuffer; import java.nio.file.attribute.*; import java.nio.file.spi.FileSystemProvider; import java.nio.file.spi.FileTypeDetector; +import java.nio.channels.Channels; import java.nio.channels.FileChannel; import java.nio.channels.SeekableByteChannel; import java.io.Closeable; @@ -2965,7 +2965,63 @@ public final class Files { } /** - * Read all the bytes from a file. The method ensures that the file is + * The maximum size of array to allocate. + * Some VMs reserve some header words in an array. + * Attempts to allocate larger arrays may result in + * OutOfMemoryError: Requested array size exceeds VM limit + */ + private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8; + + /** + * Reads all the bytes from an input stream. Uses {@code initialSize} as a hint + * about how many bytes the stream will have. + * + * @param source + * the input stream to read from + * @param initialSize + * the initial size of the byte array to allocate + * + * @return a byte array containing the bytes read from the file + * + * @throws IOException + * if an I/O error occurs reading from the stream + * @throws OutOfMemoryError + * if an array of the required size cannot be allocated + */ + private static byte[] read(InputStream source, int initialSize) + throws IOException + { + int capacity = initialSize; + byte[] buf = new byte[capacity]; + int nread = 0; + int n; + for (;;) { + // read to EOF which may read more or less than initialSize (eg: file + // is truncated while we are reading) + while ((n = source.read(buf, nread, capacity - nread)) > 0) + nread += n; + + // if last call to source.read() returned -1, we are done + // otherwise, try to read one more byte; if that failed we're done too + if (n < 0 || (n = source.read()) < 0) + break; + + // one more byte was read; need to allocate a larger buffer + if (capacity <= MAX_BUFFER_SIZE - capacity) { + capacity = Math.max(capacity << 1, BUFFER_SIZE); + } else { + if (capacity == MAX_BUFFER_SIZE) + throw new OutOfMemoryError("Required array size too large"); + capacity = MAX_BUFFER_SIZE; + } + buf = Arrays.copyOf(buf, capacity); + buf[nread++] = (byte)n; + } + return (capacity == nread) ? buf : Arrays.copyOf(buf, nread); + } + + /** + * Reads all the bytes from a file. The method ensures that the file is * closed when all bytes have been read or an I/O error, or other runtime * exception, is thrown. * @@ -2989,22 +3045,13 @@ public final class Files { * method is invoked to check read access to the file. */ public static byte[] readAllBytes(Path path) throws IOException { - try (FileChannel fc = FileChannel.open(path)) { + try (FileChannel fc = FileChannel.open(path); + InputStream is = Channels.newInputStream(fc)) { long size = fc.size(); - if (size > (long)Integer.MAX_VALUE) + if (size > (long)MAX_BUFFER_SIZE) throw new OutOfMemoryError("Required array size too large"); - byte[] arr = new byte[(int)size]; - ByteBuffer bb = ByteBuffer.wrap(arr); - while (bb.hasRemaining()) { - if (fc.read(bb) < 0) { - // truncated - break; - } - } - - int nread = bb.position(); - return (nread == size) ? arr : Arrays.copyOf(arr, nread); + return read(is, (int)size); } } diff --git a/jdk/test/java/nio/file/Files/BytesAndLines.java b/jdk/test/java/nio/file/Files/BytesAndLines.java index 2833c99cb73..15fb6a4251b 100644 --- a/jdk/test/java/nio/file/Files/BytesAndLines.java +++ b/jdk/test/java/nio/file/Files/BytesAndLines.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 7006126 + * @bug 7006126 8020669 * @summary Unit test for methods for Files readAllBytes, readAllLines and * and write methods. */ @@ -82,6 +82,16 @@ public class BytesAndLines { write(file, lines, Charset.defaultCharset(), opts); throw new RuntimeException("NullPointerException expected"); } catch (NullPointerException ignore) { } + + // read from procfs + if (System.getProperty("os.name").equals("Linux")) { + // Refer to the Linux proc(5) man page for details about /proc/self/stat file + // procfs reports it to be zero sized, even though data can be read from it + String statFile = "/proc/self/stat"; + Path pathStat = Paths.get(statFile); + byte[] data = Files.readAllBytes(pathStat); + assertTrue(data.length > 0, "Files.readAllBytes('" + statFile + "') failed to read"); + } } @@ -174,6 +184,16 @@ public class BytesAndLines { throw new RuntimeException("NullPointerException expected"); } catch (NullPointerException ignore) { } + // read from procfs + if (System.getProperty("os.name").equals("Linux")) { + // Refer to the Linux proc(5) man page for details about /proc/self/status file + // procfs reports this file to be zero sized, even though data can be read from it + String statusFile = "/proc/self/status"; + Path pathStatus = Paths.get(statusFile); + lines = Files.readAllLines(pathStatus, US_ASCII); + assertTrue(lines.size() > 0, "Files.readAllLines('" + pathStatus + "') failed to read"); + } + } finally { delete(tmpfile); } @@ -242,7 +262,6 @@ public class BytesAndLines { } finally { delete(tmpfile); } - } static void assertTrue(boolean expr, String errmsg) { From b431c6929d129e7e74b1327ec3976cc6dc43443e Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Thu, 1 Aug 2013 07:34:30 -0700 Subject: [PATCH 005/118] 7127524: P11TlsPrfGenerator has anonymous inner class with serialVersionUID Reviewed-by: vinnie --- .../sun/security/pkcs11/P11TlsPrfGenerator.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java b/jdk/src/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java index 8f75b1ec37e..86bee16a72f 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,10 +96,15 @@ final class P11TlsPrfGenerator extends KeyGeneratorSpi { } } - // SecretKeySpec does not allow zero length keys, so we define our own class. + // SecretKeySpec does not allow zero length keys, so we define our + // own class. + // + // As an anonymous class cannot make any guarantees about serialization + // compatibility, it is nonsensical for an anonymous class to define a + // serialVersionUID. Suppress warnings relative to missing serialVersionUID + // field in the anonymous subclass of serializable SecretKey. + @SuppressWarnings("serial") private static final SecretKey NULL_KEY = new SecretKey() { - private static final long serialVersionUID = -8090049519656411362L; - public byte[] getEncoded() { return new byte[0]; } From 98fb15899e845a65ee1a7437f9a7b932f211eca9 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Thu, 1 Aug 2013 16:53:40 +0100 Subject: [PATCH 006/118] 8022087: Fix doclint issues in j.u.Deque & Queue Reviewed-by: chegar, darcy --- jdk/src/share/classes/java/util/Deque.java | 149 +++++++++++---------- jdk/src/share/classes/java/util/Queue.java | 71 +++++----- 2 files changed, 112 insertions(+), 108 deletions(-) diff --git a/jdk/src/share/classes/java/util/Deque.java b/jdk/src/share/classes/java/util/Deque.java index 051ae9cca46..f6511417f33 100644 --- a/jdk/src/share/classes/java/util/Deque.java +++ b/jdk/src/share/classes/java/util/Deque.java @@ -38,7 +38,7 @@ package java.util; /** * A linear collection that supports element insertion and removal at * both ends. The name deque is short for "double ended queue" - * and is usually pronounced "deck". Most Deque + * and is usually pronounced "deck". Most {@code Deque} * implementations place no fixed limits on the number of elements * they may contain, but this interface supports capacity-restricted * deques as well as those with no fixed size limit. @@ -47,10 +47,10 @@ package java.util; * ends of the deque. Methods are provided to insert, remove, and * examine the element. Each of these methods exists in two forms: * one throws an exception if the operation fails, the other returns a - * special value (either null or false, depending on + * special value (either {@code null} or {@code false}, depending on * the operation). The latter form of the insert operation is * designed specifically for use with capacity-restricted - * Deque implementations; in most implementations, insert + * {@code Deque} implementations; in most implementations, insert * operations cannot fail. * *

The twelve methods described above are summarized in the @@ -58,6 +58,7 @@ package java.util; * *

* + * * * * @@ -72,38 +73,39 @@ package java.util; * * * - * - * - * - * + * + * + * + * * * * - * - * - * - * + * + * + * + * * * * - * - * - * - * + * + * + * + * * *
Summary of Deque methods
First Element (Head)
Insert{@link #addFirst addFirst(e)}{@link #offerFirst offerFirst(e)}{@link #addLast addLast(e)}{@link #offerLast offerLast(e)}{@link Deque#addFirst addFirst(e)}{@link Deque#offerFirst offerFirst(e)}{@link Deque#addLast addLast(e)}{@link Deque#offerLast offerLast(e)}
Remove{@link #removeFirst removeFirst()}{@link #pollFirst pollFirst()}{@link #removeLast removeLast()}{@link #pollLast pollLast()}{@link Deque#removeFirst removeFirst()}{@link Deque#pollFirst pollFirst()}{@link Deque#removeLast removeLast()}{@link Deque#pollLast pollLast()}
Examine{@link #getFirst getFirst()}{@link #peekFirst peekFirst()}{@link #getLast getLast()}{@link #peekLast peekLast()}{@link Deque#getFirst getFirst()}{@link Deque#peekFirst peekFirst()}{@link Deque#getLast getLast()}{@link Deque#peekLast peekLast()}
* *

This interface extends the {@link Queue} interface. When a deque is * used as a queue, FIFO (First-In-First-Out) behavior results. Elements are * added at the end of the deque and removed from the beginning. The methods - * inherited from the Queue interface are precisely equivalent to - * Deque methods as indicated in the following table: + * inherited from the {@code Queue} interface are precisely equivalent to + * {@code Deque} methods as indicated in the following table: * *

* + * * - * - * + * + * * * * @@ -135,13 +137,14 @@ package java.util; * interface should be used in preference to the legacy {@link Stack} class. * When a deque is used as a stack, elements are pushed and popped from the * beginning of the deque. Stack methods are precisely equivalent to - * Deque methods as indicated in the table below: + * {@code Deque} methods as indicated in the table below: * *

*

Comparison of Queue and Deque methods
Queue Method Equivalent Deque Method {@code Queue} Method Equivalent {@code Deque} Method
{@link java.util.Queue#add add(e)}
+ * * * - * + * * * * @@ -168,18 +171,18 @@ package java.util; *

Unlike the {@link List} interface, this interface does not * provide support for indexed access to elements. * - *

While Deque implementations are not strictly required + *

While {@code Deque} implementations are not strictly required * to prohibit the insertion of null elements, they are strongly - * encouraged to do so. Users of any Deque implementations + * encouraged to do so. Users of any {@code Deque} implementations * that do allow null elements are strongly encouraged not to * take advantage of the ability to insert nulls. This is so because - * null is used as a special return value by various methods + * {@code null} is used as a special return value by various methods * to indicated that the deque is empty. * - *

Deque implementations generally do not define - * element-based versions of the equals and hashCode + *

{@code Deque} implementations generally do not define + * element-based versions of the {@code equals} and {@code hashCode} * methods, but instead inherit the identity-based versions from class - * Object. + * {@code Object}. * *

This interface is a member of the Java Collections @@ -190,13 +193,13 @@ package java.util; * @since 1.6 * @param the type of elements held in this collection */ - public interface Deque extends Queue { /** * Inserts the specified element at the front of this deque if it is - * possible to do so immediately without violating capacity restrictions. - * When using a capacity-restricted deque, it is generally preferable to - * use method {@link #offerFirst}. + * possible to do so immediately without violating capacity restrictions, + * throwing an {@code IllegalStateException} if no space is currently + * available. When using a capacity-restricted deque, it is generally + * preferable to use method {@link #offerFirst}. * * @param e the element to add * @throws IllegalStateException if the element cannot be added at this @@ -212,9 +215,10 @@ public interface Deque extends Queue { /** * Inserts the specified element at the end of this deque if it is - * possible to do so immediately without violating capacity restrictions. - * When using a capacity-restricted deque, it is generally preferable to - * use method {@link #offerLast}. + * possible to do so immediately without violating capacity restrictions, + * throwing an {@code IllegalStateException} if no space is currently + * available. When using a capacity-restricted deque, it is generally + * preferable to use method {@link #offerLast}. * *

This method is equivalent to {@link #add}. * @@ -237,8 +241,8 @@ public interface Deque extends Queue { * which can fail to insert an element only by throwing an exception. * * @param e the element to add - * @return true if the element was added to this deque, else - * false + * @return {@code true} if the element was added to this deque, else + * {@code false} * @throws ClassCastException if the class of the specified element * prevents it from being added to this deque * @throws NullPointerException if the specified element is null and this @@ -255,8 +259,8 @@ public interface Deque extends Queue { * which can fail to insert an element only by throwing an exception. * * @param e the element to add - * @return true if the element was added to this deque, else - * false + * @return {@code true} if the element was added to this deque, else + * {@code false} * @throws ClassCastException if the class of the specified element * prevents it from being added to this deque * @throws NullPointerException if the specified element is null and this @@ -288,17 +292,17 @@ public interface Deque extends Queue { /** * Retrieves and removes the first element of this deque, - * or returns null if this deque is empty. + * or returns {@code null} if this deque is empty. * - * @return the head of this deque, or null if this deque is empty + * @return the head of this deque, or {@code null} if this deque is empty */ E pollFirst(); /** * Retrieves and removes the last element of this deque, - * or returns null if this deque is empty. + * or returns {@code null} if this deque is empty. * - * @return the tail of this deque, or null if this deque is empty + * @return the tail of this deque, or {@code null} if this deque is empty */ E pollLast(); @@ -325,31 +329,31 @@ public interface Deque extends Queue { /** * Retrieves, but does not remove, the first element of this deque, - * or returns null if this deque is empty. + * or returns {@code null} if this deque is empty. * - * @return the head of this deque, or null if this deque is empty + * @return the head of this deque, or {@code null} if this deque is empty */ E peekFirst(); /** * Retrieves, but does not remove, the last element of this deque, - * or returns null if this deque is empty. + * or returns {@code null} if this deque is empty. * - * @return the tail of this deque, or null if this deque is empty + * @return the tail of this deque, or {@code null} if this deque is empty */ E peekLast(); /** * Removes the first occurrence of the specified element from this deque. * If the deque does not contain the element, it is unchanged. - * More formally, removes the first element e such that + * More formally, removes the first element {@code e} such that * (o==null ? e==null : o.equals(e)) * (if such an element exists). - * Returns true if this deque contained the specified element + * Returns {@code true} if this deque contained the specified element * (or equivalently, if this deque changed as a result of the call). * * @param o element to be removed from this deque, if present - * @return true if an element was removed as a result of this call + * @return {@code true} if an element was removed as a result of this call * @throws ClassCastException if the class of the specified element * is incompatible with this deque * (optional) @@ -362,14 +366,14 @@ public interface Deque extends Queue { /** * Removes the last occurrence of the specified element from this deque. * If the deque does not contain the element, it is unchanged. - * More formally, removes the last element e such that + * More formally, removes the last element {@code e} such that * (o==null ? e==null : o.equals(e)) * (if such an element exists). - * Returns true if this deque contained the specified element + * Returns {@code true} if this deque contained the specified element * (or equivalently, if this deque changed as a result of the call). * * @param o element to be removed from this deque, if present - * @return true if an element was removed as a result of this call + * @return {@code true} if an element was removed as a result of this call * @throws ClassCastException if the class of the specified element * is incompatible with this deque * (optional) @@ -385,15 +389,15 @@ public interface Deque extends Queue { * Inserts the specified element into the queue represented by this deque * (in other words, at the tail of this deque) if it is possible to do so * immediately without violating capacity restrictions, returning - * true upon success and throwing an - * IllegalStateException if no space is currently available. + * {@code true} upon success and throwing an + * {@code IllegalStateException} if no space is currently available. * When using a capacity-restricted deque, it is generally preferable to * use {@link #offer(Object) offer}. * *

This method is equivalent to {@link #addLast}. * * @param e the element to add - * @return true (as specified by {@link Collection#add}) + * @return {@code true} (as specified by {@link Collection#add}) * @throws IllegalStateException if the element cannot be added at this * time due to capacity restrictions * @throws ClassCastException if the class of the specified element @@ -409,7 +413,7 @@ public interface Deque extends Queue { * Inserts the specified element into the queue represented by this deque * (in other words, at the tail of this deque) if it is possible to do so * immediately without violating capacity restrictions, returning - * true upon success and false if no space is currently + * {@code true} upon success and {@code false} if no space is currently * available. When using a capacity-restricted deque, this method is * generally preferable to the {@link #add} method, which can fail to * insert an element only by throwing an exception. @@ -417,8 +421,8 @@ public interface Deque extends Queue { *

This method is equivalent to {@link #offerLast}. * * @param e the element to add - * @return true if the element was added to this deque, else - * false + * @return {@code true} if the element was added to this deque, else + * {@code false} * @throws ClassCastException if the class of the specified element * prevents it from being added to this deque * @throws NullPointerException if the specified element is null and this @@ -444,11 +448,11 @@ public interface Deque extends Queue { /** * Retrieves and removes the head of the queue represented by this deque * (in other words, the first element of this deque), or returns - * null if this deque is empty. + * {@code null} if this deque is empty. * *

This method is equivalent to {@link #pollFirst()}. * - * @return the first element of this deque, or null if + * @return the first element of this deque, or {@code null} if * this deque is empty */ E poll(); @@ -469,12 +473,12 @@ public interface Deque extends Queue { /** * Retrieves, but does not remove, the head of the queue represented by * this deque (in other words, the first element of this deque), or - * returns null if this deque is empty. + * returns {@code null} if this deque is empty. * *

This method is equivalent to {@link #peekFirst()}. * * @return the head of the queue represented by this deque, or - * null if this deque is empty + * {@code null} if this deque is empty */ E peek(); @@ -484,9 +488,8 @@ public interface Deque extends Queue { /** * Pushes an element onto the stack represented by this deque (in other * words, at the head of this deque) if it is possible to do so - * immediately without violating capacity restrictions, returning - * true upon success and throwing an - * IllegalStateException if no space is currently available. + * immediately without violating capacity restrictions, throwing an + * {@code IllegalStateException} if no space is currently available. * *

This method is equivalent to {@link #addFirst}. * @@ -520,16 +523,16 @@ public interface Deque extends Queue { /** * Removes the first occurrence of the specified element from this deque. * If the deque does not contain the element, it is unchanged. - * More formally, removes the first element e such that + * More formally, removes the first element {@code e} such that * (o==null ? e==null : o.equals(e)) * (if such an element exists). - * Returns true if this deque contained the specified element + * Returns {@code true} if this deque contained the specified element * (or equivalently, if this deque changed as a result of the call). * - *

This method is equivalent to {@link #removeFirstOccurrence}. + *

This method is equivalent to {@link #removeFirstOccurrence(Object)}. * * @param o element to be removed from this deque, if present - * @return true if an element was removed as a result of this call + * @return {@code true} if an element was removed as a result of this call * @throws ClassCastException if the class of the specified element * is incompatible with this deque * (optional) @@ -540,13 +543,13 @@ public interface Deque extends Queue { boolean remove(Object o); /** - * Returns true if this deque contains the specified element. - * More formally, returns true if and only if this deque contains - * at least one element e such that + * Returns {@code true} if this deque contains the specified element. + * More formally, returns {@code true} if and only if this deque contains + * at least one element {@code e} such that * (o==null ? e==null : o.equals(e)). * * @param o element whose presence in this deque is to be tested - * @return true if this deque contains the specified element + * @return {@code true} if this deque contains the specified element * @throws ClassCastException if the type of the specified element * is incompatible with this deque * (optional) diff --git a/jdk/src/share/classes/java/util/Queue.java b/jdk/src/share/classes/java/util/Queue.java index 124cc449426..4d345df7e6f 100644 --- a/jdk/src/share/classes/java/util/Queue.java +++ b/jdk/src/share/classes/java/util/Queue.java @@ -41,14 +41,15 @@ package java.util; * queues provide additional insertion, extraction, and inspection * operations. Each of these methods exists in two forms: one throws * an exception if the operation fails, the other returns a special - * value (either null or false, depending on the + * value (either {@code null} or {@code false}, depending on the * operation). The latter form of the insert operation is designed - * specifically for use with capacity-restricted Queue + * specifically for use with capacity-restricted {@code Queue} * implementations; in most implementations, insert operations cannot * fail. * *

*

Comparison of Stack and Deque methods
Stack Method Equivalent Deque Method Equivalent {@code Deque} Method
{@link #push push(e)}
+ * * * * @@ -56,18 +57,18 @@ package java.util; * * * - * - * + * + * * * * - * - * + * + * * * * - * - * + * + * * *
Summary of Queue methods
Throws exception
Insert{@link #add add(e)}{@link #offer offer(e)}{@link Queue#add add(e)}{@link Queue#offer offer(e)}
Remove{@link #remove remove()}{@link #poll poll()}{@link Queue#remove remove()}{@link Queue#poll poll()}
Examine{@link #element element()}{@link #peek peek()}{@link Queue#element element()}{@link Queue#peek peek()}
* @@ -79,15 +80,15 @@ package java.util; * Whatever the ordering used, the head of the queue is that * element which would be removed by a call to {@link #remove() } or * {@link #poll()}. In a FIFO queue, all new elements are inserted at - * the tail of the queue. Other kinds of queues may use - * different placement rules. Every Queue implementation + * the tail of the queue. Other kinds of queues may use + * different placement rules. Every {@code Queue} implementation * must specify its ordering properties. * *

The {@link #offer offer} method inserts an element if possible, - * otherwise returning false. This differs from the {@link + * otherwise returning {@code false}. This differs from the {@link * java.util.Collection#add Collection.add} method, which can fail to * add an element only by throwing an unchecked exception. The - * offer method is designed for use when failure is a normal, + * {@code offer} method is designed for use when failure is a normal, * rather than exceptional occurrence, for example, in fixed-capacity * (or "bounded") queues. * @@ -95,32 +96,32 @@ package java.util; * return the head of the queue. * Exactly which element is removed from the queue is a * function of the queue's ordering policy, which differs from - * implementation to implementation. The remove() and - * poll() methods differ only in their behavior when the - * queue is empty: the remove() method throws an exception, - * while the poll() method returns null. + * implementation to implementation. The {@code remove()} and + * {@code poll()} methods differ only in their behavior when the + * queue is empty: the {@code remove()} method throws an exception, + * while the {@code poll()} method returns {@code null}. * *

The {@link #element()} and {@link #peek()} methods return, but do * not remove, the head of the queue. * - *

The Queue interface does not define the blocking queue + *

The {@code Queue} interface does not define the blocking queue * methods, which are common in concurrent programming. These methods, * which wait for elements to appear or for space to become available, are * defined in the {@link java.util.concurrent.BlockingQueue} interface, which * extends this interface. * - *

Queue implementations generally do not allow insertion - * of null elements, although some implementations, such as - * {@link LinkedList}, do not prohibit insertion of null. - * Even in the implementations that permit it, null should - * not be inserted into a Queue, as null is also - * used as a special return value by the poll method to + *

{@code Queue} implementations generally do not allow insertion + * of {@code null} elements, although some implementations, such as + * {@link LinkedList}, do not prohibit insertion of {@code null}. + * Even in the implementations that permit it, {@code null} should + * not be inserted into a {@code Queue}, as {@code null} is also + * used as a special return value by the {@code poll} method to * indicate that the queue contains no elements. * - *

Queue implementations generally do not define - * element-based versions of methods equals and - * hashCode but instead inherit the identity based versions - * from class Object, because element-based equality is not + *

{@code Queue} implementations generally do not define + * element-based versions of methods {@code equals} and + * {@code hashCode} but instead inherit the identity based versions + * from class {@code Object}, because element-based equality is not * always well-defined for queues with the same elements but different * ordering properties. * @@ -145,11 +146,11 @@ public interface Queue extends Collection { /** * Inserts the specified element into this queue if it is possible to do so * immediately without violating capacity restrictions, returning - * true upon success and throwing an IllegalStateException + * {@code true} upon success and throwing an {@code IllegalStateException} * if no space is currently available. * * @param e the element to add - * @return true (as specified by {@link Collection#add}) + * @return {@code true} (as specified by {@link Collection#add}) * @throws IllegalStateException if the element cannot be added at this * time due to capacity restrictions * @throws ClassCastException if the class of the specified element @@ -169,8 +170,8 @@ public interface Queue extends Collection { * by throwing an exception. * * @param e the element to add - * @return true if the element was added to this queue, else - * false + * @return {@code true} if the element was added to this queue, else + * {@code false} * @throws ClassCastException if the class of the specified element * prevents it from being added to this queue * @throws NullPointerException if the specified element is null and @@ -192,9 +193,9 @@ public interface Queue extends Collection { /** * Retrieves and removes the head of this queue, - * or returns null if this queue is empty. + * or returns {@code null} if this queue is empty. * - * @return the head of this queue, or null if this queue is empty + * @return the head of this queue, or {@code null} if this queue is empty */ E poll(); @@ -210,9 +211,9 @@ public interface Queue extends Collection { /** * Retrieves, but does not remove, the head of this queue, - * or returns null if this queue is empty. + * or returns {@code null} if this queue is empty. * - * @return the head of this queue, or null if this queue is empty + * @return the head of this queue, or {@code null} if this queue is empty */ E peek(); } From 3e78508945cf6f80e607e22de4c22dae92cf313b Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 1 Aug 2013 15:28:57 +0100 Subject: [PATCH 007/118] 8020016: Numerous splitereator impls do not throw NPE for null Consumers Reviewed-by: mduigou, alanb, henryjen --- .../java/util/stream/SpinedBuffer.java | 9 ++++ .../java/util/stream/StreamSpliterators.java | 33 ++++++++++++++ .../classes/java/util/stream/Streams.java | 25 +++++++++++ ...SpliteratorTraversingAndSplittingTest.java | 25 ++++++++++- .../util/stream/SpliteratorTestHelper.java | 45 +++++++++++++++++++ 5 files changed, 136 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/util/stream/SpinedBuffer.java b/jdk/src/share/classes/java/util/stream/SpinedBuffer.java index 77c375612ea..7312c984a51 100644 --- a/jdk/src/share/classes/java/util/stream/SpinedBuffer.java +++ b/jdk/src/share/classes/java/util/stream/SpinedBuffer.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.Objects; import java.util.PrimitiveIterator; import java.util.Spliterator; import java.util.Spliterators; @@ -317,6 +318,8 @@ class SpinedBuffer @Override public boolean tryAdvance(Consumer consumer) { + Objects.requireNonNull(consumer); + if (splSpineIndex < lastSpineIndex || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) { consumer.accept(splChunk[splElementIndex++]); @@ -334,6 +337,8 @@ class SpinedBuffer @Override public void forEachRemaining(Consumer consumer) { + Objects.requireNonNull(consumer); + if (splSpineIndex < lastSpineIndex || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) { int i = splElementIndex; @@ -634,6 +639,8 @@ class SpinedBuffer @Override public boolean tryAdvance(T_CONS consumer) { + Objects.requireNonNull(consumer); + if (splSpineIndex < lastSpineIndex || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) { arrayForOne(splChunk, splElementIndex++, consumer); @@ -651,6 +658,8 @@ class SpinedBuffer @Override public void forEachRemaining(T_CONS consumer) { + Objects.requireNonNull(consumer); + if (splSpineIndex < lastSpineIndex || (splSpineIndex == lastSpineIndex && splElementIndex < lastSpineElementFence)) { int i = splElementIndex; diff --git a/jdk/src/share/classes/java/util/stream/StreamSpliterators.java b/jdk/src/share/classes/java/util/stream/StreamSpliterators.java index d0dc61ed1e0..1a27e98ff29 100644 --- a/jdk/src/share/classes/java/util/stream/StreamSpliterators.java +++ b/jdk/src/share/classes/java/util/stream/StreamSpliterators.java @@ -25,6 +25,7 @@ package java.util.stream; import java.util.Comparator; +import java.util.Objects; import java.util.Spliterator; import java.util.concurrent.atomic.AtomicLong; import java.util.function.BooleanSupplier; @@ -294,6 +295,7 @@ class StreamSpliterators { @Override public boolean tryAdvance(Consumer consumer) { + Objects.requireNonNull(consumer); boolean hasNext = doAdvance(); if (hasNext) consumer.accept(buffer.get(nextToConsume)); @@ -303,6 +305,7 @@ class StreamSpliterators { @Override public void forEachRemaining(Consumer consumer) { if (buffer == null && !finished) { + Objects.requireNonNull(consumer); init(); ph.wrapAndCopyInto((Sink) consumer::accept, spliterator); @@ -350,6 +353,7 @@ class StreamSpliterators { @Override public boolean tryAdvance(IntConsumer consumer) { + Objects.requireNonNull(consumer); boolean hasNext = doAdvance(); if (hasNext) consumer.accept(buffer.get(nextToConsume)); @@ -359,6 +363,7 @@ class StreamSpliterators { @Override public void forEachRemaining(IntConsumer consumer) { if (buffer == null && !finished) { + Objects.requireNonNull(consumer); init(); ph.wrapAndCopyInto((Sink.OfInt) consumer::accept, spliterator); @@ -406,6 +411,7 @@ class StreamSpliterators { @Override public boolean tryAdvance(LongConsumer consumer) { + Objects.requireNonNull(consumer); boolean hasNext = doAdvance(); if (hasNext) consumer.accept(buffer.get(nextToConsume)); @@ -415,6 +421,7 @@ class StreamSpliterators { @Override public void forEachRemaining(LongConsumer consumer) { if (buffer == null && !finished) { + Objects.requireNonNull(consumer); init(); ph.wrapAndCopyInto((Sink.OfLong) consumer::accept, spliterator); @@ -462,6 +469,7 @@ class StreamSpliterators { @Override public boolean tryAdvance(DoubleConsumer consumer) { + Objects.requireNonNull(consumer); boolean hasNext = doAdvance(); if (hasNext) consumer.accept(buffer.get(nextToConsume)); @@ -471,6 +479,7 @@ class StreamSpliterators { @Override public void forEachRemaining(DoubleConsumer consumer) { if (buffer == null && !finished) { + Objects.requireNonNull(consumer); init(); ph.wrapAndCopyInto((Sink.OfDouble) consumer::accept, spliterator); @@ -696,6 +705,8 @@ class StreamSpliterators { @Override public boolean tryAdvance(Consumer action) { + Objects.requireNonNull(action); + if (sliceOrigin >= fence) return false; @@ -713,6 +724,8 @@ class StreamSpliterators { @Override public void forEachRemaining(Consumer action) { + Objects.requireNonNull(action); + if (sliceOrigin >= fence) return; @@ -754,6 +767,8 @@ class StreamSpliterators { @Override public boolean tryAdvance(T_CONS action) { + Objects.requireNonNull(action); + if (sliceOrigin >= fence) return false; @@ -771,6 +786,8 @@ class StreamSpliterators { @Override public void forEachRemaining(T_CONS action) { + Objects.requireNonNull(action); + if (sliceOrigin >= fence) return; @@ -985,6 +1002,8 @@ class StreamSpliterators { @Override public boolean tryAdvance(Consumer action) { + Objects.requireNonNull(action); + while (permitStatus() != PermitStatus.NO_MORE) { if (!s.tryAdvance(this)) return false; @@ -999,6 +1018,8 @@ class StreamSpliterators { @Override public void forEachRemaining(Consumer action) { + Objects.requireNonNull(action); + ArrayBuffer.OfRef sb = null; PermitStatus permitStatus; while ((permitStatus = permitStatus()) != PermitStatus.NO_MORE) { @@ -1051,6 +1072,8 @@ class StreamSpliterators { @Override public boolean tryAdvance(T_CONS action) { + Objects.requireNonNull(action); + while (permitStatus() != PermitStatus.NO_MORE) { if (!s.tryAdvance((T_CONS) this)) return false; @@ -1066,6 +1089,8 @@ class StreamSpliterators { @Override public void forEachRemaining(T_CONS action) { + Objects.requireNonNull(action); + T_BUFF sb = null; PermitStatus permitStatus; while ((permitStatus = permitStatus()) != PermitStatus.NO_MORE) { @@ -1237,6 +1262,8 @@ class StreamSpliterators { @Override public boolean tryAdvance(Consumer action) { + Objects.requireNonNull(action); + action.accept(s.get()); return true; } @@ -1260,6 +1287,8 @@ class StreamSpliterators { @Override public boolean tryAdvance(IntConsumer action) { + Objects.requireNonNull(action); + action.accept(s.getAsInt()); return true; } @@ -1283,6 +1312,8 @@ class StreamSpliterators { @Override public boolean tryAdvance(LongConsumer action) { + Objects.requireNonNull(action); + action.accept(s.getAsLong()); return true; } @@ -1306,6 +1337,8 @@ class StreamSpliterators { @Override public boolean tryAdvance(DoubleConsumer action) { + Objects.requireNonNull(action); + action.accept(s.getAsDouble()); return true; } diff --git a/jdk/src/share/classes/java/util/stream/Streams.java b/jdk/src/share/classes/java/util/stream/Streams.java index fe83b9708df..15c3dcae497 100644 --- a/jdk/src/share/classes/java/util/stream/Streams.java +++ b/jdk/src/share/classes/java/util/stream/Streams.java @@ -25,6 +25,7 @@ package java.util.stream; import java.util.Comparator; +import java.util.Objects; import java.util.Spliterator; import java.util.function.Consumer; import java.util.function.DoubleConsumer; @@ -80,6 +81,8 @@ final class Streams { @Override public boolean tryAdvance(IntConsumer consumer) { + Objects.requireNonNull(consumer); + final int i = from; if (i < upTo) { from++; @@ -96,6 +99,8 @@ final class Streams { @Override public void forEachRemaining(IntConsumer consumer) { + Objects.requireNonNull(consumer); + int i = from; final int hUpTo = upTo; int hLast = last; @@ -199,6 +204,8 @@ final class Streams { @Override public boolean tryAdvance(LongConsumer consumer) { + Objects.requireNonNull(consumer); + final long i = from; if (i < upTo) { from++; @@ -215,6 +222,8 @@ final class Streams { @Override public void forEachRemaining(LongConsumer consumer) { + Objects.requireNonNull(consumer); + long i = from; final long hUpTo = upTo; int hLast = last; @@ -388,6 +397,8 @@ final class Streams { @Override public boolean tryAdvance(Consumer action) { + Objects.requireNonNull(action); + if (count == -2) { action.accept(first); count = -1; @@ -400,6 +411,8 @@ final class Streams { @Override public void forEachRemaining(Consumer action) { + Objects.requireNonNull(action); + if (count == -2) { action.accept(first); count = -1; @@ -475,6 +488,8 @@ final class Streams { @Override public boolean tryAdvance(IntConsumer action) { + Objects.requireNonNull(action); + if (count == -2) { action.accept(first); count = -1; @@ -487,6 +502,8 @@ final class Streams { @Override public void forEachRemaining(IntConsumer action) { + Objects.requireNonNull(action); + if (count == -2) { action.accept(first); count = -1; @@ -562,6 +579,8 @@ final class Streams { @Override public boolean tryAdvance(LongConsumer action) { + Objects.requireNonNull(action); + if (count == -2) { action.accept(first); count = -1; @@ -574,6 +593,8 @@ final class Streams { @Override public void forEachRemaining(LongConsumer action) { + Objects.requireNonNull(action); + if (count == -2) { action.accept(first); count = -1; @@ -649,6 +670,8 @@ final class Streams { @Override public boolean tryAdvance(DoubleConsumer action) { + Objects.requireNonNull(action); + if (count == -2) { action.accept(first); count = -1; @@ -661,6 +684,8 @@ final class Streams { @Override public void forEachRemaining(DoubleConsumer action) { + Objects.requireNonNull(action); + if (count == -2) { action.accept(first); count = -1; diff --git a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java index 6da6214e1ca..458c410c252 100644 --- a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java +++ b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java @@ -81,6 +81,10 @@ import java.util.function.UnaryOperator; import static org.testng.Assert.*; import static org.testng.Assert.assertEquals; +/** + * @test + * @bug 8020016 + */ @Test public class SpliteratorTraversingAndSplittingTest { @@ -386,11 +390,23 @@ public class SpliteratorTraversingAndSplittingTest { db.addCollection(CopyOnWriteArraySet::new); - if (size == 1) { + if (size == 0) { + db.addCollection(c -> Collections.emptySet()); + db.addList(c -> Collections.emptyList()); + } + else if (size == 1) { db.addCollection(c -> Collections.singleton(exp.get(0))); db.addCollection(c -> Collections.singletonList(exp.get(0))); } + { + Integer[] ai = new Integer[size]; + Arrays.fill(ai, 1); + db.add(String.format("Collections.nCopies(%d, 1)", exp.size()), + Arrays.asList(ai), + () -> Collections.nCopies(exp.size(), 1).spliterator()); + } + // Collections.synchronized/unmodifiable/checked wrappers db.addCollection(Collections::unmodifiableCollection); db.addCollection(c -> Collections.unmodifiableSet(new HashSet<>(c))); @@ -454,6 +470,13 @@ public class SpliteratorTraversingAndSplittingTest { db.addMap(ConcurrentHashMap::new); db.addMap(ConcurrentSkipListMap::new); + + if (size == 0) { + db.addMap(m -> Collections.emptyMap()); + } + else if (size == 1) { + db.addMap(m -> Collections.singletonMap(exp.get(0), exp.get(0))); + } } return spliteratorDataProvider = data.toArray(new Object[0][]); diff --git a/jdk/test/java/util/stream/bootlib/java/util/stream/SpliteratorTestHelper.java b/jdk/test/java/util/stream/bootlib/java/util/stream/SpliteratorTestHelper.java index 4d221735315..a3446ffd6cc 100644 --- a/jdk/test/java/util/stream/bootlib/java/util/stream/SpliteratorTestHelper.java +++ b/jdk/test/java/util/stream/bootlib/java/util/stream/SpliteratorTestHelper.java @@ -22,6 +22,8 @@ */ package java.util.stream; +import org.testng.annotations.Test; + import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; @@ -154,6 +156,7 @@ public class SpliteratorTestHelper { Collection exp = Collections.unmodifiableList(fromForEach); + testNullPointerException(supplier); testForEach(exp, supplier, boxingAdapter, asserter); testTryAdvance(exp, supplier, boxingAdapter, asserter); testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, asserter); @@ -166,6 +169,31 @@ public class SpliteratorTestHelper { // + private static > void testNullPointerException(Supplier s) { + S sp = s.get(); + // Have to check instances and use casts to avoid tripwire messages and + // directly test the primitive methods + if (sp instanceof Spliterator.OfInt) { + Spliterator.OfInt psp = (Spliterator.OfInt) sp; + executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((IntConsumer) null)); + executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((IntConsumer) null)); + } + else if (sp instanceof Spliterator.OfLong) { + Spliterator.OfLong psp = (Spliterator.OfLong) sp; + executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((LongConsumer) null)); + executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((LongConsumer) null)); + } + else if (sp instanceof Spliterator.OfDouble) { + Spliterator.OfDouble psp = (Spliterator.OfDouble) sp; + executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((DoubleConsumer) null)); + executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((DoubleConsumer) null)); + } + else { + executeAndCatch(NullPointerException.class, () -> sp.forEachRemaining(null)); + executeAndCatch(NullPointerException.class, () -> sp.tryAdvance(null)); + } + } + private static > void testForEach( Collection exp, Supplier supplier, @@ -573,6 +601,23 @@ public class SpliteratorTestHelper { } } + private static void executeAndCatch(Class expected, Runnable r) { + Exception caught = null; + try { + r.run(); + } + catch (Exception e) { + caught = e; + } + + assertNotNull(caught, + String.format("No Exception was thrown, expected an Exception of %s to be thrown", + expected.getName())); + assertTrue(expected.isInstance(caught), + String.format("Exception thrown %s not an instance of %s", + caught.getClass().getName(), expected.getName())); + } + static void mixedTraverseAndSplit(Consumer b, Spliterator splTop) { Spliterator spl1, spl2, spl3; splTop.tryAdvance(b); From 9688bbb771ee3a2138ed150930c4e43d0c7077a6 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Fri, 2 Aug 2013 08:59:37 +0800 Subject: [PATCH 008/118] 8021789: jarsigner parses alias as command line option (depending on locale) Reviewed-by: vinnie --- .../sun/security/tools/jarsigner/Main.java | 27 ++++--- .../sun/security/tools/jarsigner/collator.sh | 76 +++++++++++++++++++ 2 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 jdk/test/sun/security/tools/jarsigner/collator.sh diff --git a/jdk/src/share/classes/sun/security/tools/jarsigner/Main.java b/jdk/src/share/classes/sun/security/tools/jarsigner/Main.java index c5ed6b1facf..72ce4617bf6 100644 --- a/jdk/src/share/classes/sun/security/tools/jarsigner/Main.java +++ b/jdk/src/share/classes/sun/security/tools/jarsigner/Main.java @@ -291,7 +291,8 @@ public class Main { String flags = args[n]; String modifier = null; - if (flags.charAt(0) == '-') { + + if (flags.startsWith("-")) { int pos = flags.indexOf(':'); if (pos > 0) { modifier = flags.substring(pos+1); @@ -299,7 +300,14 @@ public class Main { } } - if (collator.compare(flags, "-keystore") == 0) { + if (!flags.startsWith("-")) { + if (jarfile == null) { + jarfile = flags; + } else { + alias = flags; + ckaliases.add(alias); + } + } else if (collator.compare(flags, "-keystore") == 0) { if (++n == args.length) usageNoArg(); keystore = args[n]; } else if (collator.compare(flags, "-storepass") ==0) { @@ -380,18 +388,9 @@ public class Main { collator.compare(flags, "-help") == 0) { fullusage(); } else { - if (!flags.startsWith("-")) { - if (jarfile == null) { - jarfile = flags; - } else { - alias = flags; - ckaliases.add(alias); - } - } else { - System.err.println( - rb.getString("Illegal.option.") + flags); - usage(); - } + System.err.println( + rb.getString("Illegal.option.") + flags); + usage(); } } diff --git a/jdk/test/sun/security/tools/jarsigner/collator.sh b/jdk/test/sun/security/tools/jarsigner/collator.sh new file mode 100644 index 00000000000..06e21aac5fe --- /dev/null +++ b/jdk/test/sun/security/tools/jarsigner/collator.sh @@ -0,0 +1,76 @@ +# +# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @bug 8021789 +# @summary jarsigner parses alias as command line option (depending on locale) +# + +if [ "${TESTJAVA}" = "" ] ; then + JAVAC_CMD=`which javac` + TESTJAVA=`dirname $JAVAC_CMD`/.. +fi + +# set platform-dependent variables +OS=`uname -s` +case "$OS" in + Windows_* ) + FS="\\" + ;; + * ) + FS="/" + ;; +esac + +F=collator +KS=collator.jks +JFILE=collator.jar + +KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit \ + -keystore $KS" +JAR=$TESTJAVA${FS}bin${FS}jar +JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner -keystore $KS -storepass changeit" + +rm $F $KS $JFILE 2> /dev/null + +echo 12345 > $F +$JAR cvf $JFILE $F + +ERR="" + +$KT -alias debug -dname CN=debug -genkey -validity 300 || ERR="$ERR 1" + +# use "debug" as alias name +$JARSIGNER $JFILE debug || ERR="$ERR 2" + +# use "" as alias name (although there will be a warning) +$JARSIGNER -verify $JFILE "" || ERR="$ERR 3" + +if [ "$ERR" = "" ]; then + exit 0 +else + echo "ERR is $ERR" + exit 1 +fi + + From b456dfe62998b1d5cc181339779b8d90cb8d8800 Mon Sep 17 00:00:00 2001 From: Alexey Utkin Date: Fri, 2 Aug 2013 13:16:43 +0400 Subject: [PATCH 009/118] 8020191: System.getProperty("os.name") returns "Windows NT (unknown)" on Windows 8.1 Reviewed-by: alanb, khazra, chegar --- jdk/src/windows/native/java/lang/java_props_md.c | 2 ++ jdk/src/windows/resource/java.manifest | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/jdk/src/windows/native/java/lang/java_props_md.c b/jdk/src/windows/native/java/lang/java_props_md.c index 3374bd44225..4dee31a8116 100644 --- a/jdk/src/windows/native/java/lang/java_props_md.c +++ b/jdk/src/windows/native/java/lang/java_props_md.c @@ -443,6 +443,7 @@ GetJavaProperties(JNIEnv* env) case 0: sprops.os_name = "Windows Vista"; break; case 1: sprops.os_name = "Windows 7"; break; case 2: sprops.os_name = "Windows 8"; break; + case 3: sprops.os_name = "Windows 8.1"; break; default: sprops.os_name = "Windows NT (unknown)"; } } else { @@ -450,6 +451,7 @@ GetJavaProperties(JNIEnv* env) case 0: sprops.os_name = "Windows Server 2008"; break; case 1: sprops.os_name = "Windows Server 2008 R2"; break; case 2: sprops.os_name = "Windows Server 2012"; break; + case 3: sprops.os_name = "Windows Server 2012 R2"; break; default: sprops.os_name = "Windows NT (unknown)"; } } diff --git a/jdk/src/windows/resource/java.manifest b/jdk/src/windows/resource/java.manifest index 24b19c06334..52f997e8b39 100644 --- a/jdk/src/windows/resource/java.manifest +++ b/jdk/src/windows/resource/java.manifest @@ -44,8 +44,14 @@ - + + + + + + + From 49fe3afa1855d330eb9975f1822183058557f8aa Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Fri, 2 Aug 2013 11:25:00 +0100 Subject: [PATCH 010/118] 8022121: Remove superfluous @test tag from SpliteratorTraversingAndSplittingTest Reviewed-by: psandoz --- .../Spliterator/SpliteratorTraversingAndSplittingTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java index 458c410c252..a84cbbeaebe 100644 --- a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java +++ b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java @@ -25,6 +25,7 @@ * @test * @summary Spliterator traversing and splitting tests * @run testng SpliteratorTraversingAndSplittingTest + * @bug 8020016 */ import org.testng.annotations.DataProvider; @@ -81,10 +82,6 @@ import java.util.function.UnaryOperator; import static org.testng.Assert.*; import static org.testng.Assert.assertEquals; -/** - * @test - * @bug 8020016 - */ @Test public class SpliteratorTraversingAndSplittingTest { From 0844d3e77bd54bfd5b189e5458f989f681b9a6e5 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Fri, 2 Aug 2013 08:30:46 -0400 Subject: [PATCH 011/118] 8001319: Add SecurityPermission "insertProvider" target name Reviewed-by: vinnie --- .../share/classes/java/security/Security.java | 55 +++++++++-------- .../java/security/SecurityPermission.java | 35 ++++++++--- .../java/security/Security/AddProvider.java | 59 +++++++++++++++++++ .../security/Security/AddProvider.policy.1 | 7 +++ .../security/Security/AddProvider.policy.2 | 8 +++ .../security/Security/AddProvider.policy.3 | 7 +++ 6 files changed, 140 insertions(+), 31 deletions(-) create mode 100644 jdk/test/java/security/Security/AddProvider.java create mode 100644 jdk/test/java/security/Security/AddProvider.policy.1 create mode 100644 jdk/test/java/security/Security/AddProvider.policy.2 create mode 100644 jdk/test/java/security/Security/AddProvider.policy.3 diff --git a/jdk/src/share/classes/java/security/Security.java b/jdk/src/share/classes/java/security/Security.java index 98699da8149..ce99101e716 100644 --- a/jdk/src/share/classes/java/security/Security.java +++ b/jdk/src/share/classes/java/security/Security.java @@ -326,17 +326,13 @@ public final class Security { * *

A provider cannot be added if it is already installed. * - *

First, if there is a security manager, its - * {@code checkSecurityAccess} - * method is called with the string - * {@code "insertProvider."+provider.getName()} - * to see if it's ok to add a new provider. - * If the default implementation of {@code checkSecurityAccess} - * is used (i.e., that method is not overriden), then this will result in - * a call to the security manager's {@code checkPermission} method - * with a - * {@code SecurityPermission("insertProvider."+provider.getName())} - * permission. + *

If there is a security manager, the + * {@link java.lang.SecurityManager#checkSecurityAccess} method is called + * with the {@code "insertProvider"} permission target name to see if + * it's ok to add a new provider. If this permission check is denied, + * {@code checkSecurityAccess} is called again with the + * {@code "insertProvider."+provider.getName()} permission target name. If + * both checks are denied, a {@code SecurityException} is thrown. * * @param provider the provider to be added. * @@ -360,7 +356,7 @@ public final class Security { public static synchronized int insertProviderAt(Provider provider, int position) { String providerName = provider.getName(); - check("insertProvider." + providerName); + checkInsertProvider(providerName); ProviderList list = Providers.getFullProviderList(); ProviderList newList = ProviderList.insertAt(list, provider, position - 1); if (list == newList) { @@ -373,17 +369,13 @@ public final class Security { /** * Adds a provider to the next position available. * - *

First, if there is a security manager, its - * {@code checkSecurityAccess} - * method is called with the string - * {@code "insertProvider."+provider.getName()} - * to see if it's ok to add a new provider. - * If the default implementation of {@code checkSecurityAccess} - * is used (i.e., that method is not overriden), then this will result in - * a call to the security manager's {@code checkPermission} method - * with a - * {@code SecurityPermission("insertProvider."+provider.getName())} - * permission. + *

If there is a security manager, the + * {@link java.lang.SecurityManager#checkSecurityAccess} method is called + * with the {@code "insertProvider"} permission target name to see if + * it's ok to add a new provider. If this permission check is denied, + * {@code checkSecurityAccess} is called again with the + * {@code "insertProvider."+provider.getName()} permission target name. If + * both checks are denied, a {@code SecurityException} is thrown. * * @param provider the provider to be added. * @@ -863,6 +855,23 @@ public final class Security { } } + private static void checkInsertProvider(String name) { + SecurityManager security = System.getSecurityManager(); + if (security != null) { + try { + security.checkSecurityAccess("insertProvider"); + } catch (SecurityException se1) { + try { + security.checkSecurityAccess("insertProvider." + name); + } catch (SecurityException se2) { + // throw first exception, but add second to suppressed + se1.addSuppressed(se2); + throw se1; + } + } + } + } + /* * Returns all providers who satisfy the specified * criterion. diff --git a/jdk/src/share/classes/java/security/SecurityPermission.java b/jdk/src/share/classes/java/security/SecurityPermission.java index e0f0f92b40c..bbdccaeffe3 100644 --- a/jdk/src/share/classes/java/security/SecurityPermission.java +++ b/jdk/src/share/classes/java/security/SecurityPermission.java @@ -130,14 +130,17 @@ import java.util.StringTokenizer; * * * - * insertProvider.{provider name} - * Addition of a new provider, with the specified name + * insertProvider + * Addition of a new provider * This would allow somebody to introduce a possibly * malicious provider (e.g., one that discloses the private keys passed * to it) as the highest-priority provider. This would be possible * because the Security object (which manages the installed providers) * currently does not check the integrity or authenticity of a provider - * before attaching it. + * before attaching it. The "insertProvider" permission subsumes the + * "insertProvider.{provider name}" permission (see the section below for + * more information). + * * * * @@ -186,9 +189,10 @@ import java.util.StringTokenizer; * * *

- * The following permissions are associated with classes that have been - * deprecated: {@link Identity}, {@link IdentityScope}, {@link Signer}. Use of - * them is discouraged. See the applicable classes for more information. + * The following permissions have been superseded by newer permissions or are + * associated with classes that have been deprecated: {@link Identity}, + * {@link IdentityScope}, {@link Signer}. Use of them is discouraged. See the + * applicable classes for more information. *

* * @@ -199,6 +203,23 @@ import java.util.StringTokenizer; * * * + * + * + * + * + * + * * * * " }, + "" }, {"./" + BUG_ID + "/C.html", "

isPaused

" + NL + "
public final double isPaused()
" + NL + diff --git a/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java b/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java index 47873bc3433..4d90d8791fb 100644 --- a/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java +++ b/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ public class TestMemberInheritence extends JavadocTester { // Test overriding/implementing methods with generic parameters. {BUG_ID + FS + "pkg" + FS + "BaseClass.html", - "
" + NL + "
Specified by:
" + NL + + "
" + NL + "
Specified by:
" + NL + "
" + "getAnnotation in interface " + "" + diff --git a/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java b/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java index e30f579d4fe..fdbb664deff 100644 --- a/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java +++ b/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,8 +49,8 @@ public class TestMemberSummary extends JavadocTester { // Check return type in member summary. {BUG_ID + FS + "pkg" + FS + "PublicChild.html", "PublicChild" + NL + - "
" + "Foo2> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html", - "" + "Foo2> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html", "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", - "" + "Foo3>> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", - "" + "Foo3>> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", - "" + "Foo4>>> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", "" + "Foo4>>> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "" + NL + "" + NL + "" + NL + "" + NL + "" + NL + "" @@ -698,25 +698,25 @@ public class TestNewLanguageFeatures extends JavadocTester { {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "@AnnotationTypeUndocumented(optional=\"Class Annotation\"," + NL + " required=1994)" + NL + - "public class AnnotationTypeUsage
extends java.lang.Object
"}, + "public class AnnotationTypeUsage
extends java.lang.Object
"}, //FIELD {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "@AnnotationTypeUndocumented(optional=\"Field Annotation\"," + NL + " required=1994)" + NL + - "public int field"}, + "public int field"}, //CONSTRUCTOR {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "@AnnotationTypeUndocumented(optional=\"Constructor Annotation\"," + NL + " required=1994)" + NL + - "public AnnotationTypeUsage()"}, + "public AnnotationTypeUsage()"}, //METHOD {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "@AnnotationTypeUndocumented(optional=\"Method Annotation\"," + NL + " required=1994)" + NL + - "public void method()"}, + "public void method()"}, //================================= // Make sure annotation types do not diff --git a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java index 7568b0a2516..68999480d44 100644 --- a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java +++ b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,9 +46,9 @@ public class TestOverridenMethodDocCopy extends JavadocTester { //Input for string search tests. private static final String[][] TEST = { {BUG_ID + FS + "pkg1" + FS + "SubClass.html", - "Description copied from class: " + + "Description copied from class: " + "" + - "BaseClass" + "BaseClass" } }; private static final String[][] NEGATED_TEST = NO_TEST; diff --git a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java index aa136d8be91..21a6760d308 100644 --- a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java +++ b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,12 +40,12 @@ public class TestOverridenPrivateMethods extends JavadocTester { private static final String[][] TEST = { //The public method should be overriden {BUG_ID + FS + "pkg1" + FS + "SubClass.html", - "
Overrides:
" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
" + "publicMethod in class " + "BaseClass
"}, //The public method in different package should be overriden {BUG_ID + FS + "pkg2" + FS + "SubClass.html", - "
Overrides:
" + NL + + "
Overrides:
" + NL + "
" + "publicMethod in class " + "BaseClass
"}, @@ -55,7 +55,7 @@ public class TestOverridenPrivateMethodsWithPackageFlag extends JavadocTester { //The package private method should be overriden since the base and sub class are in the same //package. {BUG_ID + FS + "pkg1" + FS + "SubClass.html", - "
Overrides:
" + NL + + "
Overrides:
" + NL + "
" + "packagePrivateMethod in class " + "BaseClass
"} @@ -65,18 +65,18 @@ public class TestOverridenPrivateMethodsWithPackageFlag extends JavadocTester { //The private method in should not be overriden {BUG_ID + FS + "pkg1" + FS + "SubClass.html", - "
Overrides:
" + NL + + "
Overrides:
" + NL + "
"}, //The private method in different package should not be overriden {BUG_ID + FS + "pkg2" + FS + "SubClass.html", - "
Overrides:
" + NL + + "
Overrides:
" + NL + "
"}, //The package private method should not be overriden since the base and sub class are in //different packages. {BUG_ID + FS + "pkg2" + FS + "SubClass.html", - "
Overrides:
" + NL + + "
Overrides:
" + NL + "
"}, }; diff --git a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java index b8b5e7329c4..fbcd30e8b37 100644 --- a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java +++ b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,18 +40,18 @@ public class TestOverridenPrivateMethodsWithPrivateFlag extends JavadocTester { private static final String[][] TEST = { //The public method should be overriden {BUG_ID + FS + "pkg1" + FS + "SubClass.html", - "
Overrides:
" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Overrides:" + NL + + "
Overrides:
" + NL + "
Deprecated." + NL + - "
This package is Deprecated.
" + "
This package is Deprecated." + + "
" }, {BUG_ID + "-1" + FS + "deprecated-list.html", "
  • Deprecated Packages
  • " diff --git a/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java b/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java index 9ff91c2d5c9..b6ae263d8a4 100644 --- a/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java +++ b/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java @@ -112,12 +112,12 @@ public class TestPrivateClasses extends JavadocTester { private static final String[][] NEGATED_TEST1 = { // Should not document that a method overrides method from private class. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", - "Overrides:"}, + "Overrides:"}, // Should not document that a method specified by private interface. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", - "Specified by:"}, + "Specified by:"}, {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", - "Specified by:"}, + "Specified by:"}, // Should not mention that any documentation was copied. {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", "Description copied from"}, @@ -139,7 +139,7 @@ public class TestPrivateClasses extends JavadocTester { //Do not inherit private interface method with generic parameters. //This method has been implemented. {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", - "hello"}, + "hello"}, }; // Test output when -private flag is used. @@ -176,14 +176,14 @@ public class TestPrivateClasses extends JavadocTester { }, // Should document that a method overrides method from private class. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", - "
    Overrides:
    " + NL + + "
    Overrides:
    " + NL + "
    " + "methodOverridenFromParent in class " + "" + "PrivateParent
    "}, // Should document that a method is specified by private interface. {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", - "
    Specified by:
    " + NL + + "
    Specified by:
    " + NL + "
    " + "methodInterface in interface " + "" + @@ -227,11 +227,11 @@ public class TestPrivateClasses extends JavadocTester { //Since private flag is used, we can document that private interface method //with generic parameters has been implemented. {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", - "Description copied from interface: " + - "I"}, + "Description copied from interface: " + + "I"}, {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", - "
    Specified by:
    " + NL + + "
    Specified by:
    " + NL + "
    hello" + " in interface " + "I" + diff --git a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java index fd026b9ad49..760d24af458 100644 --- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java +++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java @@ -47,9 +47,9 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester { "" + NL + "
    " + "C1.setUndecorated(boolean)
    " + NL + ""}, {BUG_ID + FS + "serialized-form.html", "Deprecated." + - " As of JDK version 1.5, replaced by" + NL + + " As of JDK version 1.5, replaced by" + NL + " " + - "setUndecorated(boolean)." + NL + + "setUndecorated(boolean)." + NL + "
    This field indicates whether the C1 " + "is undecorated.
    " + NL + " " + NL + "
    " + NL + "
    Since:
    " + NL + @@ -57,9 +57,9 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester { "" + NL + "
    " + "C1.setUndecorated(boolean)
    " + NL + "
    "}, {BUG_ID + FS + "serialized-form.html", "Deprecated." + - " As of JDK version 1.5, replaced by" + NL + + " As of JDK version 1.5, replaced by" + NL + " " + - "setUndecorated(boolean)." + NL + + "setUndecorated(boolean)." + NL + "
    Reads the object stream.
    " + NL + "
    " + NL + "
    Throws:
    " + NL + "
    " + "IOException
    " + NL + @@ -73,15 +73,15 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester { // information if any. private static final String[][] TEST_NOCMNT = { {BUG_ID + FS + "serialized-form.html", "
    boolean undecorated
    " + NL + - "
    Deprecated. " + + "
    Deprecated. " + "As of JDK version 1.5, replaced by" + NL + " " + - "setUndecorated(boolean).
    " + NL + ""}, + "setUndecorated(boolean)
    .
    " + NL + ""}, {BUG_ID + FS + "serialized-form.html", "" + - "Deprecated. As of JDK version" + + "Deprecated. As of JDK version" + " 1.5, replaced by" + NL + " " + - "setUndecorated(boolean)." + NL + ""}}; + "setUndecorated(boolean)." + NL + ""}}; // Test with -nodeprecated option. The serialized-form.html should // ignore the -nodeprecated tag and display the deprecation info. This From a8090b5024538166576232cb66977894e228c132 Mon Sep 17 00:00:00 2001 From: Bhavesh Patel Date: Wed, 7 Aug 2013 16:09:31 -0700 Subject: [PATCH 081/118] 4749567: stddoclet: Add CSS style for setting header/footer to be italic Reviewed-by: jjg --- .../doclets/formats/html/HelpWriter.java | 2 +- .../formats/html/HtmlDocletWriter.java | 3 +- .../doclets/formats/html/markup/HtmlTree.java | 11 --- .../internal/toolkit/resources/stylesheet.css | 1 + .../sun/javadoc/testOptions/TestOptions.java | 78 +++++++++++++++++++ .../com/sun/javadoc/testOptions/pkg/Foo.java | 27 +++++++ 6 files changed, 108 insertions(+), 14 deletions(-) create mode 100644 langtools/test/com/sun/javadoc/testOptions/TestOptions.java create mode 100644 langtools/test/com/sun/javadoc/testOptions/pkg/Foo.java diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java index 2884d3b45bb..d5e0bf0c71f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java @@ -316,7 +316,7 @@ public class HelpWriter extends HtmlDocletWriter { liConst.addContent(constPara); ul.addContent(liConst); Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul); - Content line30 = HtmlTree.EM(getResource("doclet.Help_line_30")); + Content line30 = HtmlTree.SPAN(HtmlStyle.italic, getResource("doclet.Help_line_30")); divContent.addContent(line30); contentTree.addContent(divContent); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java index bfd7955ebbb..63aa42be9b1 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java @@ -467,8 +467,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { } } Content rawContent = new RawHtml(content); - Content em = HtmlTree.EM(rawContent); - return em; + return rawContent; } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java index ab4fdd8e474..e0343f21d94 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java @@ -281,17 +281,6 @@ public class HtmlTree extends Content { return htmltree; } - /** - * Generates a EM tag with some content. - * - * @param body content to be added to the tag - * @return an HtmlTree object for the EM tag - */ - public static HtmlTree EM(Content body) { - HtmlTree htmltree = new HtmlTree(HtmlTag.EM, nullCheck(body)); - return htmltree; - } - /** * Generates a FRAME tag. * diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css index 18e062a8b27..b2adb742b81 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css @@ -77,6 +77,7 @@ Document title and Copyright styles float:right; padding:0px 21px; font-size:.8em; + font-style:italic; z-index:200; margin-top:-7px; } diff --git a/langtools/test/com/sun/javadoc/testOptions/TestOptions.java b/langtools/test/com/sun/javadoc/testOptions/TestOptions.java new file mode 100644 index 00000000000..1327ff47737 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOptions/TestOptions.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4749567 + * @summary Test the output for -header and -footer options. + * @author Bhavesh Patel + * @library ../lib/ + * @build JavadocTester TestOptions + * @run main TestOptions + */ + +public class TestOptions extends JavadocTester { + + //Test information. + private static final String BUG_ID = "4749567"; + + //Javadoc arguments. + private static final String[] ARGS = new String[] { + "-d", BUG_ID, "-header", "Test header", "-footer", "Test footer", + "-sourcepath", SRC_DIR, "pkg" + }; + + private static final String[][] TEST = { + {BUG_ID + FS + "pkg" + FS + "package-summary.html", + "
    Test header
    "}, + {BUG_ID + FS + "pkg" + FS + "package-summary.html", + "
    Test footer
    "} + }; + + private static final String[][] NEGATED_TEST = NO_TEST; + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String[] args) { + TestOptions tester = new TestOptions(); + run(tester, ARGS, TEST, NEGATED_TEST); + tester.printSummary(); + } + + /** + * {@inheritDoc} + */ + public String getBugId() { + return BUG_ID; + } + + /** + * {@inheritDoc} + */ + public String getBugName() { + return getClass().getName(); + } +} + diff --git a/langtools/test/com/sun/javadoc/testOptions/pkg/Foo.java b/langtools/test/com/sun/javadoc/testOptions/pkg/Foo.java new file mode 100644 index 00000000000..b2a32176bd1 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOptions/pkg/Foo.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +public class Foo {} + From 0982c856e53cf998ce0ad4909d8394f1e312f36a Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Wed, 7 Aug 2013 16:29:36 -0700 Subject: [PATCH 082/118] 8022479: clean up warnings from sun.tools.asm Reviewed-by: lancea, darcy --- .../classes/sun/tools/asm/Assembler.java | 90 ++++++++++--------- .../classes/sun/tools/asm/ConstantPool.java | 12 +-- .../classes/sun/tools/asm/Instruction.java | 17 ++-- .../classes/sun/tools/asm/SwitchData.java | 38 ++++---- .../share/classes/sun/tools/asm/TryData.java | 6 +- 5 files changed, 87 insertions(+), 76 deletions(-) diff --git a/jdk/src/share/classes/sun/tools/asm/Assembler.java b/jdk/src/share/classes/sun/tools/asm/Assembler.java index 1bf406e182e..b4fc8b1d290 100644 --- a/jdk/src/share/classes/sun/tools/asm/Assembler.java +++ b/jdk/src/share/classes/sun/tools/asm/Assembler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,9 +91,9 @@ class Assembler implements Constants { add(new Instruction(where, opc, flagNoCovered)); } - static Vector SourceClassList = new Vector(); + static Vector SourceClassList = new Vector<>(); - static Vector TmpCovTable = new Vector(); + static Vector TmpCovTable = new Vector<>(); static int[] JcovClassCountArray = new int[CT_LAST_KIND + 1]; @@ -177,8 +177,8 @@ class Assembler implements Constants { case opc_lookupswitch: { SwitchData sw = (SwitchData)inst.value; optimize(env, sw.defaultLabel); - for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) { - optimize(env, (Label)e.nextElement()); + for (Enumeration
    insertProvider.{provider name}Addition of a new provider, with the specified nameUse of this permission is discouraged from further use because it is + * possible to circumvent the name restrictions by overriding the + * {@link java.security.Provider#getName} method. Also, there is an equivalent + * level of risk associated with granting code permission to insert a provider + * with a specific name, or any name it chooses. Users should use the + * "insertProvider" permission instead. + *

    This would allow somebody to introduce a possibly + * malicious provider (e.g., one that discloses the private keys passed + * to it) as the highest-priority provider. This would be possible + * because the Security object (which manages the installed providers) + * currently does not check the integrity or authenticity of a provider + * before attaching it.

    setSystemScopeSetting of the system identity scopeThis would allow an attacker to configure the system identity scope with @@ -306,7 +327,6 @@ public final class SecurityPermission extends BasicPermission { * @throws NullPointerException if {@code name} is {@code null}. * @throws IllegalArgumentException if {@code name} is empty. */ - public SecurityPermission(String name) { super(name); @@ -323,7 +343,6 @@ public final class SecurityPermission extends BasicPermission { * @throws NullPointerException if {@code name} is {@code null}. * @throws IllegalArgumentException if {@code name} is empty. */ - public SecurityPermission(String name, String actions) { super(name, actions); diff --git a/jdk/test/java/security/Security/AddProvider.java b/jdk/test/java/security/Security/AddProvider.java new file mode 100644 index 00000000000..27559ffdbc8 --- /dev/null +++ b/jdk/test/java/security/Security/AddProvider.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8001319 + * @summary check that SecurityPermission insertProvider permission is enforced + * correctly + * @run main/othervm/policy=AddProvider.policy.1 AddProvider 1 + * @run main/othervm/policy=AddProvider.policy.2 AddProvider 2 + * @run main/othervm/policy=AddProvider.policy.3 AddProvider 3 + */ +import java.security.Provider; +import java.security.Security; + +public class AddProvider { + + public static void main(String[] args) throws Exception { + boolean legacy = args[0].equals("2"); + Security.addProvider(new TestProvider("Test1")); + Security.insertProviderAt(new TestProvider("Test2"), 1); + try { + Security.addProvider(new TestProvider("Test3")); + if (legacy) { + throw new Exception("Expected SecurityException"); + } + } catch (SecurityException se) { + if (!legacy) { + throw se; + } + } + } + + private static class TestProvider extends Provider { + TestProvider(String name) { + super(name, 0.0, "Not for use in production systems!"); + } + } +} diff --git a/jdk/test/java/security/Security/AddProvider.policy.1 b/jdk/test/java/security/Security/AddProvider.policy.1 new file mode 100644 index 00000000000..17a49b47b77 --- /dev/null +++ b/jdk/test/java/security/Security/AddProvider.policy.1 @@ -0,0 +1,7 @@ +grant codeBase "file:${{java.ext.dirs}}/*" { + permission java.security.AllPermission; +}; + +grant { + permission java.security.SecurityPermission "insertProvider"; +}; diff --git a/jdk/test/java/security/Security/AddProvider.policy.2 b/jdk/test/java/security/Security/AddProvider.policy.2 new file mode 100644 index 00000000000..d5a7ca94442 --- /dev/null +++ b/jdk/test/java/security/Security/AddProvider.policy.2 @@ -0,0 +1,8 @@ +grant codeBase "file:${{java.ext.dirs}}/*" { + permission java.security.AllPermission; +}; + +grant { + permission java.security.SecurityPermission "insertProvider.Test1"; + permission java.security.SecurityPermission "insertProvider.Test2"; +}; diff --git a/jdk/test/java/security/Security/AddProvider.policy.3 b/jdk/test/java/security/Security/AddProvider.policy.3 new file mode 100644 index 00000000000..930b443d7f6 --- /dev/null +++ b/jdk/test/java/security/Security/AddProvider.policy.3 @@ -0,0 +1,7 @@ +grant codeBase "file:${{java.ext.dirs}}/*" { + permission java.security.AllPermission; +}; + +grant { + permission java.security.SecurityPermission "insertProvider.*"; +}; From b1a10b8ed7bedb27ae25341602319a11a1225ee7 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 2 Aug 2013 14:29:31 +0100 Subject: [PATCH 012/118] 8020291: j.u.c.CompletionStage 8020435: CompletableFuture/Basic.java fails on single core machine Reviewed-by: chegar, psandoz --- .../util/concurrent/CompletableFuture.java | 2221 +++++++---------- .../java/util/concurrent/CompletionStage.java | 760 ++++++ jdk/test/ProblemList.txt | 6 - .../concurrent/CompletableFuture/Basic.java | 2 + 4 files changed, 1725 insertions(+), 1264 deletions(-) create mode 100644 jdk/src/share/classes/java/util/concurrent/CompletionStage.java diff --git a/jdk/src/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/share/classes/java/util/concurrent/CompletableFuture.java index 7926f2e63b9..5e2fb134fc1 100644 --- a/jdk/src/share/classes/java/util/concurrent/CompletableFuture.java +++ b/jdk/src/share/classes/java/util/concurrent/CompletableFuture.java @@ -48,13 +48,16 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletionException; +import java.util.concurrent.CompletionStage; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.LockSupport; /** * A {@link Future} that may be explicitly completed (setting its - * value and status), and may include dependent functions and actions - * that trigger upon its completion. + * value and status), and may be used as a {@link CompletionStage}, + * supporting dependent functions and actions that trigger upon its + * completion. * *

    When two or more threads attempt to * {@link #complete complete}, @@ -62,64 +65,50 @@ import java.util.concurrent.locks.LockSupport; * {@link #cancel cancel} * a CompletableFuture, only one of them succeeds. * - *

    Methods are available for adding dependents based on - * user-provided Functions, Consumers, or Runnables. The appropriate - * form to use depends on whether actions require arguments and/or - * produce results. Completion of a dependent action will trigger the - * completion of another CompletableFuture. Actions may also be - * triggered after either or both the current and another - * CompletableFuture complete. Multiple CompletableFutures may also - * be grouped as one using {@link #anyOf(CompletableFuture...)} and - * {@link #allOf(CompletableFuture...)}. + *

    In addition to these and related methods for directly + * manipulating status and results, CompletableFuture implements + * interface {@link CompletionStage} with the following policies:

      * - *

      CompletableFutures themselves do not execute asynchronously. - * However, actions supplied for dependent completions of another - * CompletableFuture may do so, depending on whether they are provided - * via one of the async methods (that is, methods with names - * of the form xxxAsync). The async - * methods provide a way to commence asynchronous processing of an - * action using either a given {@link Executor} or by default the - * {@link ForkJoinPool#commonPool()}. To simplify monitoring, + *

    • Actions supplied for dependent completions of + * non-async methods may be performed by the thread that + * completes the current CompletableFuture, or by any other caller of + * a completion method.
    • + * + *
    • All async methods without an explicit Executor + * argument are performed using the {@link ForkJoinPool#commonPool()} + * (unless it does not support a parallelism level of at least two, in + * which case, a new Thread is used). To simplify monitoring, * debugging, and tracking, all generated asynchronous tasks are - * instances of the marker interface {@link AsynchronousCompletionTask}. + * instances of the marker interface {@link + * AsynchronousCompletionTask}.
    • * - *

      Actions supplied for dependent completions of non-async - * methods may be performed by the thread that completes the current - * CompletableFuture, or by any other caller of these methods. There - * are no guarantees about the order of processing completions unless - * constrained by these methods. + *

    • All CompletionStage methods are implemented independently of + * other public methods, so the behavior of one method is not impacted + * by overrides of others in subclasses.
    * - *

    Since (unlike {@link FutureTask}) this class has no direct + *

    CompletableFuture also implements {@link Future} with the following + * policies:

      + * + *
    • Since (unlike {@link FutureTask}) this class has no direct * control over the computation that causes it to be completed, - * cancellation is treated as just another form of exceptional completion. - * Method {@link #cancel cancel} has the same effect as - * {@code completeExceptionally(new CancellationException())}. + * cancellation is treated as just another form of exceptional + * completion. Method {@link #cancel cancel} has the same effect as + * {@code completeExceptionally(new CancellationException())}. Method + * {@link #isCompletedExceptionally} can be used to determine if a + * CompletableFuture completed in any exceptional fashion.
    • * - *

      Upon exceptional completion (including cancellation), or when a - * completion entails an additional computation which terminates - * abruptly with an (unchecked) exception or error, then all of their - * dependent completions (and their dependents in turn) generally act - * as {@code completeExceptionally} with a {@link CompletionException} - * holding that exception as its cause. However, the {@link - * #exceptionally exceptionally} and {@link #handle handle} - * completions are able to handle exceptional completions of - * the CompletableFutures they depend on. - * - *

      In case of exceptional completion with a CompletionException, + *

    • In case of exceptional completion with a CompletionException, * methods {@link #get()} and {@link #get(long, TimeUnit)} throw an * {@link ExecutionException} with the same cause as held in the - * corresponding CompletionException. However, in these cases, - * methods {@link #join()} and {@link #getNow} throw the - * CompletionException, which simplifies usage. - * - *

      Arguments used to pass a completion result (that is, for parameters - * of type {@code T}) may be null, but passing a null value for any other - * parameter will result in a {@link NullPointerException} being thrown. + * corresponding CompletionException. To simplify usage in most + * contexts, this class also defines methods {@link #join()} and + * {@link #getNow} that instead throw the CompletionException directly + * in these cases.

    * * @author Doug Lea * @since 1.8 */ -public class CompletableFuture implements Future { +public class CompletableFuture implements Future, CompletionStage { /* * Overview: @@ -438,6 +427,19 @@ public class CompletableFuture implements Future { public final void run() { exec(); } } + /** + * Starts the given async task using the given executor, unless + * the executor is ForkJoinPool.commonPool and it has been + * disabled, in which case starts a new thread. + */ + static void execAsync(Executor e, Async r) { + if (e == ForkJoinPool.commonPool() && + ForkJoinPool.getCommonPoolParallelism() <= 1) + new Thread(r).start(); + else + e.execute(r); + } + static final class AsyncRun extends Async { final Runnable fn; final CompletableFuture dst; @@ -538,13 +540,13 @@ public class CompletableFuture implements Future { static final class AsyncAccept extends Async { final T arg; final Consumer fn; - final CompletableFuture dst; + final CompletableFuture dst; AsyncAccept(T arg, Consumer fn, - CompletableFuture dst) { + CompletableFuture dst) { this.arg = arg; this.fn = fn; this.dst = dst; } public final boolean exec() { - CompletableFuture d; Throwable ex; + CompletableFuture d; Throwable ex; if ((d = this.dst) != null && d.result == null) { try { fn.accept(arg); @@ -563,14 +565,14 @@ public class CompletableFuture implements Future { final T arg1; final U arg2; final BiConsumer fn; - final CompletableFuture dst; + final CompletableFuture dst; AsyncAcceptBoth(T arg1, U arg2, BiConsumer fn, - CompletableFuture dst) { + CompletableFuture dst) { this.arg1 = arg1; this.arg2 = arg2; this.fn = fn; this.dst = dst; } public final boolean exec() { - CompletableFuture d; Throwable ex; + CompletableFuture d; Throwable ex; if ((d = this.dst) != null && d.result == null) { try { fn.accept(arg1, arg2); @@ -587,10 +589,10 @@ public class CompletableFuture implements Future { static final class AsyncCompose extends Async { final T arg; - final Function> fn; + final Function> fn; final CompletableFuture dst; AsyncCompose(T arg, - Function> fn, + Function> fn, CompletableFuture dst) { this.arg = arg; this.fn = fn; this.dst = dst; } @@ -598,7 +600,8 @@ public class CompletableFuture implements Future { CompletableFuture d, fr; U u; Throwable ex; if ((d = this.dst) != null && d.result == null) { try { - fr = fn.apply(arg); + CompletionStage cs = fn.apply(arg); + fr = (cs == null) ? null : cs.toCompletableFuture(); ex = (fr == null) ? new NullPointerException() : null; } catch (Throwable rex) { ex = rex; @@ -626,6 +629,33 @@ public class CompletableFuture implements Future { private static final long serialVersionUID = 5232453952276885070L; } + static final class AsyncWhenComplete extends Async { + final T arg1; + final Throwable arg2; + final BiConsumer fn; + final CompletableFuture dst; + AsyncWhenComplete(T arg1, Throwable arg2, + BiConsumer fn, + CompletableFuture dst) { + this.arg1 = arg1; this.arg2 = arg2; this.fn = fn; this.dst = dst; + } + public final boolean exec() { + CompletableFuture d; + if ((d = this.dst) != null && d.result == null) { + Throwable ex = arg2; + try { + fn.accept(arg1, ex); + } catch (Throwable rex) { + if (ex == null) + ex = rex; + } + d.internalComplete(arg1, ex); + } + return true; + } + private static final long serialVersionUID = 5232453952276885070L; + } + /* ------------- Completions -------------- */ /** @@ -680,7 +710,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncApply(t, fn, dst)); + execAsync(e, new AsyncApply(t, fn, dst)); else u = fn.apply(t); } catch (Throwable rex) { @@ -697,11 +727,11 @@ public class CompletableFuture implements Future { static final class ThenAccept extends Completion { final CompletableFuture src; final Consumer fn; - final CompletableFuture dst; + final CompletableFuture dst; final Executor executor; ThenAccept(CompletableFuture src, Consumer fn, - CompletableFuture dst, + CompletableFuture dst, Executor executor) { this.src = src; this.fn = fn; this.dst = dst; this.executor = executor; @@ -709,7 +739,7 @@ public class CompletableFuture implements Future { public final void run() { final CompletableFuture a; final Consumer fn; - final CompletableFuture dst; + final CompletableFuture dst; Object r; T t; Throwable ex; if ((dst = this.dst) != null && (fn = this.fn) != null && @@ -729,7 +759,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncAccept(t, fn, dst)); + execAsync(e, new AsyncAccept(t, fn, dst)); else fn.accept(t); } catch (Throwable rex) { @@ -773,7 +803,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncRun(fn, dst)); + execAsync(e, new AsyncRun(fn, dst)); else fn.run(); } catch (Throwable rex) { @@ -839,7 +869,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncCombine(t, u, fn, dst)); + execAsync(e, new AsyncCombine(t, u, fn, dst)); else v = fn.apply(t, u); } catch (Throwable rex) { @@ -904,7 +934,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncAcceptBoth(t, u, fn, dst)); + execAsync(e, new AsyncAcceptBoth(t, u, fn, dst)); else fn.accept(t, u); } catch (Throwable rex) { @@ -956,7 +986,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncRun(fn, dst)); + execAsync(e, new AsyncRun(fn, dst)); else fn.run(); } catch (Throwable rex) { @@ -1042,7 +1072,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncApply(t, fn, dst)); + execAsync(e, new AsyncApply(t, fn, dst)); else u = fn.apply(t); } catch (Throwable rex) { @@ -1095,7 +1125,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncAccept(t, fn, dst)); + execAsync(e, new AsyncAccept(t, fn, dst)); else fn.accept(t); } catch (Throwable rex) { @@ -1143,7 +1173,7 @@ public class CompletableFuture implements Future { if (ex == null) { try { if (e != null) - e.execute(new AsyncRun(fn, dst)); + execAsync(e, new AsyncRun(fn, dst)); else fn.run(); } catch (Throwable rex) { @@ -1226,6 +1256,54 @@ public class CompletableFuture implements Future { private static final long serialVersionUID = 5232453952276885070L; } + static final class WhenCompleteCompletion extends Completion { + final CompletableFuture src; + final BiConsumer fn; + final CompletableFuture dst; + final Executor executor; + WhenCompleteCompletion(CompletableFuture src, + BiConsumer fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final BiConsumer fn; + final CompletableFuture dst; + Object r; T t; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + Executor e = executor; + Throwable dx = null; + try { + if (e != null) + execAsync(e, new AsyncWhenComplete(t, ex, fn, dst)); + else + fn.accept(t, ex); + } catch (Throwable rex) { + dx = rex; + } + if (e == null || dx != null) + dst.internalComplete(t, ex != null ? ex : dx); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + static final class ThenCopy extends Completion { final CompletableFuture src; final CompletableFuture dst; @@ -1286,10 +1364,13 @@ public class CompletableFuture implements Future { final CompletableFuture src; final BiFunction fn; final CompletableFuture dst; + final Executor executor; HandleCompletion(CompletableFuture src, BiFunction fn, - CompletableFuture dst) { + CompletableFuture dst, + Executor executor) { this.src = src; this.fn = fn; this.dst = dst; + this.executor = executor; } public final void run() { final CompletableFuture a; @@ -1310,13 +1391,19 @@ public class CompletableFuture implements Future { @SuppressWarnings("unchecked") T tr = (T) r; t = tr; } - U u = null; Throwable dx = null; + Executor e = executor; + U u = null; + Throwable dx = null; try { - u = fn.apply(t, ex); + if (e != null) + execAsync(e, new AsyncCombine(t, ex, fn, dst)); + else + u = fn.apply(t, ex); } catch (Throwable rex) { dx = rex; } - dst.internalComplete(u, dx); + if (e == null || dx != null) + dst.internalComplete(u, dx); } } private static final long serialVersionUID = 5232453952276885070L; @@ -1324,11 +1411,11 @@ public class CompletableFuture implements Future { static final class ThenCompose extends Completion { final CompletableFuture src; - final Function> fn; + final Function> fn; final CompletableFuture dst; final Executor executor; ThenCompose(CompletableFuture src, - Function> fn, + Function> fn, CompletableFuture dst, Executor executor) { this.src = src; this.fn = fn; this.dst = dst; @@ -1336,7 +1423,7 @@ public class CompletableFuture implements Future { } public final void run() { final CompletableFuture a; - final Function> fn; + final Function> fn; final CompletableFuture dst; Object r; T t; Throwable ex; Executor e; if ((dst = this.dst) != null && @@ -1358,10 +1445,12 @@ public class CompletableFuture implements Future { boolean complete = false; if (ex == null) { if ((e = executor) != null) - e.execute(new AsyncCompose(t, fn, dst)); + execAsync(e, new AsyncCompose(t, fn, dst)); else { try { - if ((c = fn.apply(t)) == null) + CompletionStage cs = fn.apply(t); + c = (cs == null) ? null : cs.toCompletableFuture(); + if (c == null) ex = new NullPointerException(); } catch (Throwable rex) { ex = rex; @@ -1401,6 +1490,619 @@ public class CompletableFuture implements Future { private static final long serialVersionUID = 5232453952276885070L; } + // Implementations of stage methods with (plain, async, Executor) forms + + private CompletableFuture doThenApply + (Function fn, + Executor e) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenApply d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = new CompletionNode + (d = new ThenApply(this, fn, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + U u = null; + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncApply(t, fn, dst)); + else + u = fn.apply(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(u, ex); + } + helpPostComplete(); + return dst; + } + + private CompletableFuture doThenAccept(Consumer fn, + Executor e) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenAccept d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = new CompletionNode + (d = new ThenAccept(this, fn, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncAccept(t, fn, dst)); + else + fn.accept(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + return dst; + } + + private CompletableFuture doThenRun(Runnable action, + Executor e) { + if (action == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenRun d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = new CompletionNode + (d = new ThenRun(this, action, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + Throwable ex; + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncRun(action, dst)); + else + action.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + return dst; + } + + private CompletableFuture doThenCombine + (CompletableFuture other, + BiFunction fn, + Executor e) { + if (other == null || fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenCombine d = null; + Object r, s = null; + if ((r = result) == null || (s = other.result) == null) { + d = new ThenCombine(this, other, fn, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r == null && (r = result) == null) || + (s == null && (s = other.result) == null)) { + if (q != null) { + if (s != null || + UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (r != null || + UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) { + if (s != null) + break; + q = new CompletionNode(d); + } + } + } + if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { + T t; U u; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex != null) + u = null; + else if (s instanceof AltResult) { + ex = ((AltResult)s).ex; + u = null; + } + else { + @SuppressWarnings("unchecked") U us = (U) s; + u = us; + } + V v = null; + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncCombine(t, u, fn, dst)); + else + v = fn.apply(t, u); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(v, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + private CompletableFuture doThenAcceptBoth + (CompletableFuture other, + BiConsumer fn, + Executor e) { + if (other == null || fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenAcceptBoth d = null; + Object r, s = null; + if ((r = result) == null || (s = other.result) == null) { + d = new ThenAcceptBoth(this, other, fn, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r == null && (r = result) == null) || + (s == null && (s = other.result) == null)) { + if (q != null) { + if (s != null || + UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (r != null || + UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) { + if (s != null) + break; + q = new CompletionNode(d); + } + } + } + if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { + T t; U u; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex != null) + u = null; + else if (s instanceof AltResult) { + ex = ((AltResult)s).ex; + u = null; + } + else { + @SuppressWarnings("unchecked") U us = (U) s; + u = us; + } + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncAcceptBoth(t, u, fn, dst)); + else + fn.accept(t, u); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + private CompletableFuture doRunAfterBoth(CompletableFuture other, + Runnable action, + Executor e) { + if (other == null || action == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + RunAfterBoth d = null; + Object r, s = null; + if ((r = result) == null || (s = other.result) == null) { + d = new RunAfterBoth(this, other, action, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r == null && (r = result) == null) || + (s == null && (s = other.result) == null)) { + if (q != null) { + if (s != null || + UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (r != null || + UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) { + if (s != null) + break; + q = new CompletionNode(d); + } + } + } + if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { + Throwable ex; + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null && (s instanceof AltResult)) + ex = ((AltResult)s).ex; + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncRun(action, dst)); + else + action.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + private CompletableFuture doApplyToEither + (CompletableFuture other, + Function fn, + Executor e) { + if (other == null || fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ApplyToEither d = null; + Object r; + if ((r = result) == null && (r = other.result) == null) { + d = new ApplyToEither(this, other, fn, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r = result) == null && (r = other.result) == null) { + if (q != null) { + if (UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + q = new CompletionNode(d); + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + U u = null; + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncApply(t, fn, dst)); + else + u = fn.apply(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(u, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + private CompletableFuture doAcceptEither + (CompletableFuture other, + Consumer fn, + Executor e) { + if (other == null || fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + AcceptEither d = null; + Object r; + if ((r = result) == null && (r = other.result) == null) { + d = new AcceptEither(this, other, fn, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r = result) == null && (r = other.result) == null) { + if (q != null) { + if (UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + q = new CompletionNode(d); + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncAccept(t, fn, dst)); + else + fn.accept(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + private CompletableFuture doRunAfterEither + (CompletableFuture other, + Runnable action, + Executor e) { + if (other == null || action == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + RunAfterEither d = null; + Object r; + if ((r = result) == null && (r = other.result) == null) { + d = new RunAfterEither(this, other, action, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r = result) == null && (r = other.result) == null) { + if (q != null) { + if (UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + q = new CompletionNode(d); + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + Throwable ex; + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null) { + try { + if (e != null) + execAsync(e, new AsyncRun(action, dst)); + else + action.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + private CompletableFuture doThenCompose + (Function> fn, + Executor e) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = null; + ThenCompose d = null; + Object r; + if ((r = result) == null) { + dst = new CompletableFuture(); + CompletionNode p = new CompletionNode + (d = new ThenCompose(this, fn, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex == null) { + if (e != null) { + if (dst == null) + dst = new CompletableFuture(); + execAsync(e, new AsyncCompose(t, fn, dst)); + } + else { + try { + CompletionStage cs = fn.apply(t); + if (cs == null || + (dst = cs.toCompletableFuture()) == null) + ex = new NullPointerException(); + } catch (Throwable rex) { + ex = rex; + } + } + } + if (dst == null) + dst = new CompletableFuture(); + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + dst.helpPostComplete(); + return dst; + } + + private CompletableFuture doWhenComplete + (BiConsumer fn, + Executor e) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + WhenCompleteCompletion d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = + new CompletionNode(d = new WhenCompleteCompletion + (this, fn, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, + p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + Throwable dx = null; + try { + if (e != null) + execAsync(e, new AsyncWhenComplete(t, ex, fn, dst)); + else + fn.accept(t, ex); + } catch (Throwable rex) { + dx = rex; + } + if (e == null || dx != null) + dst.internalComplete(t, ex != null ? ex : dx); + } + helpPostComplete(); + return dst; + } + + private CompletableFuture doHandle + (BiFunction fn, + Executor e) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + HandleCompletion d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = + new CompletionNode(d = new HandleCompletion + (this, fn, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, + p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + U u = null; + Throwable dx = null; + try { + if (e != null) + execAsync(e, new AsyncCombine(t, ex, fn, dst)); + else { + u = fn.apply(t, ex); + dx = null; + } + } catch (Throwable rex) { + dx = rex; + u = null; + } + if (e == null || dx != null) + dst.internalComplete(u, dx); + } + helpPostComplete(); + return dst; + } + + // public methods /** @@ -1416,13 +2118,13 @@ public class CompletableFuture implements Future { * * @param supplier a function returning the value to be used * to complete the returned CompletableFuture + * @param the function's return type * @return the new CompletableFuture */ public static CompletableFuture supplyAsync(Supplier supplier) { if (supplier == null) throw new NullPointerException(); CompletableFuture f = new CompletableFuture(); - ForkJoinPool.commonPool(). - execute((ForkJoinTask)new AsyncSupply(supplier, f)); + execAsync(ForkJoinPool.commonPool(), new AsyncSupply(supplier, f)); return f; } @@ -1434,6 +2136,7 @@ public class CompletableFuture implements Future { * @param supplier a function returning the value to be used * to complete the returned CompletableFuture * @param executor the executor to use for asynchronous execution + * @param the function's return type * @return the new CompletableFuture */ public static CompletableFuture supplyAsync(Supplier supplier, @@ -1441,7 +2144,7 @@ public class CompletableFuture implements Future { if (executor == null || supplier == null) throw new NullPointerException(); CompletableFuture f = new CompletableFuture(); - executor.execute(new AsyncSupply(supplier, f)); + execAsync(executor, new AsyncSupply(supplier, f)); return f; } @@ -1457,8 +2160,7 @@ public class CompletableFuture implements Future { public static CompletableFuture runAsync(Runnable runnable) { if (runnable == null) throw new NullPointerException(); CompletableFuture f = new CompletableFuture(); - ForkJoinPool.commonPool(). - execute((ForkJoinTask)new AsyncRun(runnable, f)); + execAsync(ForkJoinPool.commonPool(), new AsyncRun(runnable, f)); return f; } @@ -1477,7 +2179,7 @@ public class CompletableFuture implements Future { if (executor == null || runnable == null) throw new NullPointerException(); CompletableFuture f = new CompletableFuture(); - executor.execute(new AsyncRun(runnable, f)); + execAsync(executor, new AsyncRun(runnable, f)); return f; } @@ -1486,6 +2188,7 @@ public class CompletableFuture implements Future { * the given value. * * @param value the value + * @param the type of the value * @return the completed CompletableFuture */ public static CompletableFuture completedFuture(U value) { @@ -1657,60 +2360,18 @@ public class CompletableFuture implements Future { return triggered; } - /** - * Returns a new CompletableFuture that is completed - * when this CompletableFuture completes, with the result of the - * given function of this CompletableFuture's result. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied function throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture thenApply(Function fn) { + // CompletionStage methods + + public CompletableFuture thenApply + (Function fn) { return doThenApply(fn, null); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when this CompletableFuture completes, with the result of the - * given function of this CompletableFuture's result from a - * task running in the {@link ForkJoinPool#commonPool()}. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied function throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @return the new CompletableFuture - */ public CompletableFuture thenApplyAsync (Function fn) { return doThenApply(fn, ForkJoinPool.commonPool()); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when this CompletableFuture completes, with the result of the - * given function of this CompletableFuture's result from a - * task running in the given executor. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied function throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ public CompletableFuture thenApplyAsync (Function fn, Executor executor) { @@ -1718,1149 +2379,228 @@ public class CompletableFuture implements Future { return doThenApply(fn, executor); } - private CompletableFuture doThenApply - (Function fn, - Executor e) { - if (fn == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - ThenApply d = null; - Object r; - if ((r = result) == null) { - CompletionNode p = new CompletionNode - (d = new ThenApply(this, fn, dst, e)); - while ((r = result) == null) { - if (UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) - break; - } - } - if (r != null && (d == null || d.compareAndSet(0, 1))) { - T t; Throwable ex; - if (r instanceof AltResult) { - ex = ((AltResult)r).ex; - t = null; - } - else { - ex = null; - @SuppressWarnings("unchecked") T tr = (T) r; - t = tr; - } - U u = null; - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncApply(t, fn, dst)); - else - u = fn.apply(t); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(u, ex); - } - helpPostComplete(); - return dst; + public CompletableFuture thenAccept + (Consumer action) { + return doThenAccept(action, null); } - /** - * Returns a new CompletableFuture that is completed - * when this CompletableFuture completes, after performing the given - * action with this CompletableFuture's result. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied action throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param block the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture thenAccept(Consumer block) { - return doThenAccept(block, null); + public CompletableFuture thenAcceptAsync + (Consumer action) { + return doThenAccept(action, ForkJoinPool.commonPool()); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when this CompletableFuture completes, after performing the given - * action with this CompletableFuture's result from a task running - * in the {@link ForkJoinPool#commonPool()}. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied action throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param block the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture thenAcceptAsync(Consumer block) { - return doThenAccept(block, ForkJoinPool.commonPool()); - } - - /** - * Returns a new CompletableFuture that is asynchronously completed - * when this CompletableFuture completes, after performing the given - * action with this CompletableFuture's result from a task running - * in the given executor. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied action throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param block the action to perform before completing the - * returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public CompletableFuture thenAcceptAsync(Consumer block, - Executor executor) { + public CompletableFuture thenAcceptAsync + (Consumer action, + Executor executor) { if (executor == null) throw new NullPointerException(); - return doThenAccept(block, executor); + return doThenAccept(action, executor); } - private CompletableFuture doThenAccept(Consumer fn, - Executor e) { - if (fn == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - ThenAccept d = null; - Object r; - if ((r = result) == null) { - CompletionNode p = new CompletionNode - (d = new ThenAccept(this, fn, dst, e)); - while ((r = result) == null) { - if (UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) - break; - } - } - if (r != null && (d == null || d.compareAndSet(0, 1))) { - T t; Throwable ex; - if (r instanceof AltResult) { - ex = ((AltResult)r).ex; - t = null; - } - else { - ex = null; - @SuppressWarnings("unchecked") T tr = (T) r; - t = tr; - } - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncAccept(t, fn, dst)); - else - fn.accept(t); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(null, ex); - } - helpPostComplete(); - return dst; - } - - /** - * Returns a new CompletableFuture that is completed - * when this CompletableFuture completes, after performing the given - * action. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied action throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param action the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture thenRun(Runnable action) { + public CompletableFuture thenRun + (Runnable action) { return doThenRun(action, null); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when this CompletableFuture completes, after performing the given - * action from a task running in the {@link ForkJoinPool#commonPool()}. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied action throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param action the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture thenRunAsync(Runnable action) { + public CompletableFuture thenRunAsync + (Runnable action) { return doThenRun(action, ForkJoinPool.commonPool()); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when this CompletableFuture completes, after performing the given - * action from a task running in the given executor. - * - *

    If this CompletableFuture completes exceptionally, or the - * supplied action throws an exception, then the returned - * CompletableFuture completes exceptionally with a - * CompletionException holding the exception as its cause. - * - * @param action the action to perform before completing the - * returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public CompletableFuture thenRunAsync(Runnable action, - Executor executor) { + public CompletableFuture thenRunAsync + (Runnable action, + Executor executor) { if (executor == null) throw new NullPointerException(); return doThenRun(action, executor); } - private CompletableFuture doThenRun(Runnable action, - Executor e) { - if (action == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - ThenRun d = null; - Object r; - if ((r = result) == null) { - CompletionNode p = new CompletionNode - (d = new ThenRun(this, action, dst, e)); - while ((r = result) == null) { - if (UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) - break; - } - } - if (r != null && (d == null || d.compareAndSet(0, 1))) { - Throwable ex; - if (r instanceof AltResult) - ex = ((AltResult)r).ex; - else - ex = null; - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncRun(action, dst)); - else - action.run(); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(null, ex); - } - helpPostComplete(); - return dst; - } - - /** - * Returns a new CompletableFuture that is completed - * when both this and the other given CompletableFuture complete, - * with the result of the given function of the results of the two - * CompletableFutures. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied function throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @return the new CompletableFuture - */ public CompletableFuture thenCombine - (CompletableFuture other, + (CompletionStage other, BiFunction fn) { - return doThenCombine(other, fn, null); + return doThenCombine(other.toCompletableFuture(), fn, null); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when both this and the other given CompletableFuture complete, - * with the result of the given function of the results of the two - * CompletableFutures from a task running in the - * {@link ForkJoinPool#commonPool()}. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied function throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @return the new CompletableFuture - */ public CompletableFuture thenCombineAsync - (CompletableFuture other, + (CompletionStage other, BiFunction fn) { - return doThenCombine(other, fn, ForkJoinPool.commonPool()); + return doThenCombine(other.toCompletableFuture(), fn, + ForkJoinPool.commonPool()); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when both this and the other given CompletableFuture complete, - * with the result of the given function of the results of the two - * CompletableFutures from a task running in the given executor. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied function throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ public CompletableFuture thenCombineAsync - (CompletableFuture other, + (CompletionStage other, BiFunction fn, Executor executor) { if (executor == null) throw new NullPointerException(); - return doThenCombine(other, fn, executor); + return doThenCombine(other.toCompletableFuture(), fn, executor); } - private CompletableFuture doThenCombine - (CompletableFuture other, - BiFunction fn, - Executor e) { - if (other == null || fn == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - ThenCombine d = null; - Object r, s = null; - if ((r = result) == null || (s = other.result) == null) { - d = new ThenCombine(this, other, fn, dst, e); - CompletionNode q = null, p = new CompletionNode(d); - while ((r == null && (r = result) == null) || - (s == null && (s = other.result) == null)) { - if (q != null) { - if (s != null || - UNSAFE.compareAndSwapObject - (other, COMPLETIONS, q.next = other.completions, q)) - break; - } - else if (r != null || - UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) { - if (s != null) - break; - q = new CompletionNode(d); - } - } - } - if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { - T t; U u; Throwable ex; - if (r instanceof AltResult) { - ex = ((AltResult)r).ex; - t = null; - } - else { - ex = null; - @SuppressWarnings("unchecked") T tr = (T) r; - t = tr; - } - if (ex != null) - u = null; - else if (s instanceof AltResult) { - ex = ((AltResult)s).ex; - u = null; - } - else { - @SuppressWarnings("unchecked") U us = (U) s; - u = us; - } - V v = null; - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncCombine(t, u, fn, dst)); - else - v = fn.apply(t, u); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(v, ex); - } - helpPostComplete(); - other.helpPostComplete(); - return dst; - } - - /** - * Returns a new CompletableFuture that is completed - * when both this and the other given CompletableFuture complete, - * after performing the given action with the results of the two - * CompletableFutures. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied action throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param block the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ public CompletableFuture thenAcceptBoth - (CompletableFuture other, - BiConsumer block) { - return doThenAcceptBoth(other, block, null); + (CompletionStage other, + BiConsumer action) { + return doThenAcceptBoth(other.toCompletableFuture(), action, null); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when both this and the other given CompletableFuture complete, - * after performing the given action with the results of the two - * CompletableFutures from a task running in the {@link - * ForkJoinPool#commonPool()}. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied action throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param block the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ public CompletableFuture thenAcceptBothAsync - (CompletableFuture other, - BiConsumer block) { - return doThenAcceptBoth(other, block, ForkJoinPool.commonPool()); + (CompletionStage other, + BiConsumer action) { + return doThenAcceptBoth(other.toCompletableFuture(), action, + ForkJoinPool.commonPool()); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when both this and the other given CompletableFuture complete, - * after performing the given action with the results of the two - * CompletableFutures from a task running in the given executor. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied action throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param block the action to perform before completing the - * returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ public CompletableFuture thenAcceptBothAsync - (CompletableFuture other, - BiConsumer block, + (CompletionStage other, + BiConsumer action, Executor executor) { if (executor == null) throw new NullPointerException(); - return doThenAcceptBoth(other, block, executor); + return doThenAcceptBoth(other.toCompletableFuture(), action, executor); } - private CompletableFuture doThenAcceptBoth - (CompletableFuture other, - BiConsumer fn, - Executor e) { - if (other == null || fn == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - ThenAcceptBoth d = null; - Object r, s = null; - if ((r = result) == null || (s = other.result) == null) { - d = new ThenAcceptBoth(this, other, fn, dst, e); - CompletionNode q = null, p = new CompletionNode(d); - while ((r == null && (r = result) == null) || - (s == null && (s = other.result) == null)) { - if (q != null) { - if (s != null || - UNSAFE.compareAndSwapObject - (other, COMPLETIONS, q.next = other.completions, q)) - break; - } - else if (r != null || - UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) { - if (s != null) - break; - q = new CompletionNode(d); - } - } - } - if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { - T t; U u; Throwable ex; - if (r instanceof AltResult) { - ex = ((AltResult)r).ex; - t = null; - } - else { - ex = null; - @SuppressWarnings("unchecked") T tr = (T) r; - t = tr; - } - if (ex != null) - u = null; - else if (s instanceof AltResult) { - ex = ((AltResult)s).ex; - u = null; - } - else { - @SuppressWarnings("unchecked") U us = (U) s; - u = us; - } - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncAcceptBoth(t, u, fn, dst)); - else - fn.accept(t, u); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(null, ex); - } - helpPostComplete(); - other.helpPostComplete(); - return dst; - } - - /** - * Returns a new CompletableFuture that is completed - * when both this and the other given CompletableFuture complete, - * after performing the given action. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied action throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param action the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture runAfterBoth(CompletableFuture other, - Runnable action) { - return doRunAfterBoth(other, action, null); - } - - /** - * Returns a new CompletableFuture that is asynchronously completed - * when both this and the other given CompletableFuture complete, - * after performing the given action from a task running in the - * {@link ForkJoinPool#commonPool()}. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied action throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param action the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture runAfterBothAsync(CompletableFuture other, - Runnable action) { - return doRunAfterBoth(other, action, ForkJoinPool.commonPool()); - } - - /** - * Returns a new CompletableFuture that is asynchronously completed - * when both this and the other given CompletableFuture complete, - * after performing the given action from a task running in the - * given executor. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, or the supplied action throws an exception, - * then the returned CompletableFuture completes exceptionally - * with a CompletionException holding the exception as its cause. - * - * @param other the other CompletableFuture - * @param action the action to perform before completing the - * returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public CompletableFuture runAfterBothAsync(CompletableFuture other, - Runnable action, - Executor executor) { - if (executor == null) throw new NullPointerException(); - return doRunAfterBoth(other, action, executor); - } - - private CompletableFuture doRunAfterBoth(CompletableFuture other, - Runnable action, - Executor e) { - if (other == null || action == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - RunAfterBoth d = null; - Object r, s = null; - if ((r = result) == null || (s = other.result) == null) { - d = new RunAfterBoth(this, other, action, dst, e); - CompletionNode q = null, p = new CompletionNode(d); - while ((r == null && (r = result) == null) || - (s == null && (s = other.result) == null)) { - if (q != null) { - if (s != null || - UNSAFE.compareAndSwapObject - (other, COMPLETIONS, q.next = other.completions, q)) - break; - } - else if (r != null || - UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) { - if (s != null) - break; - q = new CompletionNode(d); - } - } - } - if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { - Throwable ex; - if (r instanceof AltResult) - ex = ((AltResult)r).ex; - else - ex = null; - if (ex == null && (s instanceof AltResult)) - ex = ((AltResult)s).ex; - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncRun(action, dst)); - else - action.run(); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(null, ex); - } - helpPostComplete(); - other.helpPostComplete(); - return dst; - } - - /** - * Returns a new CompletableFuture that is completed - * when either this or the other given CompletableFuture completes, - * with the result of the given function of either this or the other - * CompletableFuture's result. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied function - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture applyToEither - (CompletableFuture other, - Function fn) { - return doApplyToEither(other, fn, null); - } - - /** - * Returns a new CompletableFuture that is asynchronously completed - * when either this or the other given CompletableFuture completes, - * with the result of the given function of either this or the other - * CompletableFuture's result from a task running in the - * {@link ForkJoinPool#commonPool()}. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied function - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture applyToEitherAsync - (CompletableFuture other, - Function fn) { - return doApplyToEither(other, fn, ForkJoinPool.commonPool()); - } - - /** - * Returns a new CompletableFuture that is asynchronously completed - * when either this or the other given CompletableFuture completes, - * with the result of the given function of either this or the other - * CompletableFuture's result from a task running in the - * given executor. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied function - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param fn the function to use to compute the value of - * the returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public CompletableFuture applyToEitherAsync - (CompletableFuture other, - Function fn, - Executor executor) { - if (executor == null) throw new NullPointerException(); - return doApplyToEither(other, fn, executor); - } - - private CompletableFuture doApplyToEither - (CompletableFuture other, - Function fn, - Executor e) { - if (other == null || fn == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - ApplyToEither d = null; - Object r; - if ((r = result) == null && (r = other.result) == null) { - d = new ApplyToEither(this, other, fn, dst, e); - CompletionNode q = null, p = new CompletionNode(d); - while ((r = result) == null && (r = other.result) == null) { - if (q != null) { - if (UNSAFE.compareAndSwapObject - (other, COMPLETIONS, q.next = other.completions, q)) - break; - } - else if (UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) - q = new CompletionNode(d); - } - } - if (r != null && (d == null || d.compareAndSet(0, 1))) { - T t; Throwable ex; - if (r instanceof AltResult) { - ex = ((AltResult)r).ex; - t = null; - } - else { - ex = null; - @SuppressWarnings("unchecked") T tr = (T) r; - t = tr; - } - U u = null; - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncApply(t, fn, dst)); - else - u = fn.apply(t); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(u, ex); - } - helpPostComplete(); - other.helpPostComplete(); - return dst; - } - - /** - * Returns a new CompletableFuture that is completed - * when either this or the other given CompletableFuture completes, - * after performing the given action with the result of either this - * or the other CompletableFuture's result. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied action - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param block the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture acceptEither - (CompletableFuture other, - Consumer block) { - return doAcceptEither(other, block, null); - } - - /** - * Returns a new CompletableFuture that is asynchronously completed - * when either this or the other given CompletableFuture completes, - * after performing the given action with the result of either this - * or the other CompletableFuture's result from a task running in - * the {@link ForkJoinPool#commonPool()}. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied action - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param block the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture acceptEitherAsync - (CompletableFuture other, - Consumer block) { - return doAcceptEither(other, block, ForkJoinPool.commonPool()); - } - - /** - * Returns a new CompletableFuture that is asynchronously completed - * when either this or the other given CompletableFuture completes, - * after performing the given action with the result of either this - * or the other CompletableFuture's result from a task running in - * the given executor. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied action - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param block the action to perform before completing the - * returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public CompletableFuture acceptEitherAsync - (CompletableFuture other, - Consumer block, - Executor executor) { - if (executor == null) throw new NullPointerException(); - return doAcceptEither(other, block, executor); - } - - private CompletableFuture doAcceptEither - (CompletableFuture other, - Consumer fn, - Executor e) { - if (other == null || fn == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - AcceptEither d = null; - Object r; - if ((r = result) == null && (r = other.result) == null) { - d = new AcceptEither(this, other, fn, dst, e); - CompletionNode q = null, p = new CompletionNode(d); - while ((r = result) == null && (r = other.result) == null) { - if (q != null) { - if (UNSAFE.compareAndSwapObject - (other, COMPLETIONS, q.next = other.completions, q)) - break; - } - else if (UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) - q = new CompletionNode(d); - } - } - if (r != null && (d == null || d.compareAndSet(0, 1))) { - T t; Throwable ex; - if (r instanceof AltResult) { - ex = ((AltResult)r).ex; - t = null; - } - else { - ex = null; - @SuppressWarnings("unchecked") T tr = (T) r; - t = tr; - } - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncAccept(t, fn, dst)); - else - fn.accept(t); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(null, ex); - } - helpPostComplete(); - other.helpPostComplete(); - return dst; - } - - /** - * Returns a new CompletableFuture that is completed - * when either this or the other given CompletableFuture completes, - * after performing the given action. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied action - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param action the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture runAfterEither(CompletableFuture other, - Runnable action) { - return doRunAfterEither(other, action, null); - } - - /** - * Returns a new CompletableFuture that is asynchronously completed - * when either this or the other given CompletableFuture completes, - * after performing the given action from a task running in the - * {@link ForkJoinPool#commonPool()}. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied action - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param action the action to perform before completing the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture runAfterEitherAsync - (CompletableFuture other, + public CompletableFuture runAfterBoth + (CompletionStage other, Runnable action) { - return doRunAfterEither(other, action, ForkJoinPool.commonPool()); + return doRunAfterBoth(other.toCompletableFuture(), action, null); } - /** - * Returns a new CompletableFuture that is asynchronously completed - * when either this or the other given CompletableFuture completes, - * after performing the given action from a task running in the - * given executor. - * - *

    If this and/or the other CompletableFuture complete - * exceptionally, then the returned CompletableFuture may also do so, - * with a CompletionException holding one of these exceptions as its - * cause. No guarantees are made about which result or exception is - * used in the returned CompletableFuture. If the supplied action - * throws an exception, then the returned CompletableFuture completes - * exceptionally with a CompletionException holding the exception as - * its cause. - * - * @param other the other CompletableFuture - * @param action the action to perform before completing the - * returned CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the new CompletableFuture - */ - public CompletableFuture runAfterEitherAsync - (CompletableFuture other, + public CompletableFuture runAfterBothAsync + (CompletionStage other, + Runnable action) { + return doRunAfterBoth(other.toCompletableFuture(), action, + ForkJoinPool.commonPool()); + } + + public CompletableFuture runAfterBothAsync + (CompletionStage other, Runnable action, Executor executor) { if (executor == null) throw new NullPointerException(); - return doRunAfterEither(other, action, executor); + return doRunAfterBoth(other.toCompletableFuture(), action, executor); } - private CompletableFuture doRunAfterEither - (CompletableFuture other, + + public CompletableFuture applyToEither + (CompletionStage other, + Function fn) { + return doApplyToEither(other.toCompletableFuture(), fn, null); + } + + public CompletableFuture applyToEitherAsync + (CompletionStage other, + Function fn) { + return doApplyToEither(other.toCompletableFuture(), fn, + ForkJoinPool.commonPool()); + } + + public CompletableFuture applyToEitherAsync + (CompletionStage other, + Function fn, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doApplyToEither(other.toCompletableFuture(), fn, executor); + } + + public CompletableFuture acceptEither + (CompletionStage other, + Consumer action) { + return doAcceptEither(other.toCompletableFuture(), action, null); + } + + public CompletableFuture acceptEitherAsync + (CompletionStage other, + Consumer action) { + return doAcceptEither(other.toCompletableFuture(), action, + ForkJoinPool.commonPool()); + } + + public CompletableFuture acceptEitherAsync + (CompletionStage other, + Consumer action, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doAcceptEither(other.toCompletableFuture(), action, executor); + } + + public CompletableFuture runAfterEither(CompletionStage other, + Runnable action) { + return doRunAfterEither(other.toCompletableFuture(), action, null); + } + + public CompletableFuture runAfterEitherAsync + (CompletionStage other, + Runnable action) { + return doRunAfterEither(other.toCompletableFuture(), action, + ForkJoinPool.commonPool()); + } + + public CompletableFuture runAfterEitherAsync + (CompletionStage other, Runnable action, - Executor e) { - if (other == null || action == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - RunAfterEither d = null; - Object r; - if ((r = result) == null && (r = other.result) == null) { - d = new RunAfterEither(this, other, action, dst, e); - CompletionNode q = null, p = new CompletionNode(d); - while ((r = result) == null && (r = other.result) == null) { - if (q != null) { - if (UNSAFE.compareAndSwapObject - (other, COMPLETIONS, q.next = other.completions, q)) - break; - } - else if (UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) - q = new CompletionNode(d); - } - } - if (r != null && (d == null || d.compareAndSet(0, 1))) { - Throwable ex; - if (r instanceof AltResult) - ex = ((AltResult)r).ex; - else - ex = null; - if (ex == null) { - try { - if (e != null) - e.execute(new AsyncRun(action, dst)); - else - action.run(); - } catch (Throwable rex) { - ex = rex; - } - } - if (e == null || ex != null) - dst.internalComplete(null, ex); - } - helpPostComplete(); - other.helpPostComplete(); - return dst; + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doRunAfterEither(other.toCompletableFuture(), action, executor); } - /** - * Returns a CompletableFuture that upon completion, has the same - * value as produced by the given function of the result of this - * CompletableFuture. - * - *

    If this CompletableFuture completes exceptionally, then the - * returned CompletableFuture also does so, with a - * CompletionException holding this exception as its cause. - * Similarly, if the computed CompletableFuture completes - * exceptionally, then so does the returned CompletableFuture. - * - * @param fn the function returning a new CompletableFuture - * @return the CompletableFuture - */ public CompletableFuture thenCompose - (Function> fn) { + (Function> fn) { return doThenCompose(fn, null); } - /** - * Returns a CompletableFuture that upon completion, has the same - * value as that produced asynchronously using the {@link - * ForkJoinPool#commonPool()} by the given function of the result - * of this CompletableFuture. - * - *

    If this CompletableFuture completes exceptionally, then the - * returned CompletableFuture also does so, with a - * CompletionException holding this exception as its cause. - * Similarly, if the computed CompletableFuture completes - * exceptionally, then so does the returned CompletableFuture. - * - * @param fn the function returning a new CompletableFuture - * @return the CompletableFuture - */ public CompletableFuture thenComposeAsync - (Function> fn) { + (Function> fn) { return doThenCompose(fn, ForkJoinPool.commonPool()); } - /** - * Returns a CompletableFuture that upon completion, has the same - * value as that produced asynchronously using the given executor - * by the given function of this CompletableFuture. - * - *

    If this CompletableFuture completes exceptionally, then the - * returned CompletableFuture also does so, with a - * CompletionException holding this exception as its cause. - * Similarly, if the computed CompletableFuture completes - * exceptionally, then so does the returned CompletableFuture. - * - * @param fn the function returning a new CompletableFuture - * @param executor the executor to use for asynchronous execution - * @return the CompletableFuture - */ public CompletableFuture thenComposeAsync - (Function> fn, + (Function> fn, Executor executor) { if (executor == null) throw new NullPointerException(); return doThenCompose(fn, executor); } - private CompletableFuture doThenCompose - (Function> fn, - Executor e) { - if (fn == null) throw new NullPointerException(); - CompletableFuture dst = null; - ThenCompose d = null; - Object r; - if ((r = result) == null) { - dst = new CompletableFuture(); - CompletionNode p = new CompletionNode - (d = new ThenCompose(this, fn, dst, e)); - while ((r = result) == null) { - if (UNSAFE.compareAndSwapObject - (this, COMPLETIONS, p.next = completions, p)) - break; - } - } - if (r != null && (d == null || d.compareAndSet(0, 1))) { - T t; Throwable ex; - if (r instanceof AltResult) { - ex = ((AltResult)r).ex; - t = null; - } - else { - ex = null; - @SuppressWarnings("unchecked") T tr = (T) r; - t = tr; - } - if (ex == null) { - if (e != null) { - if (dst == null) - dst = new CompletableFuture(); - e.execute(new AsyncCompose(t, fn, dst)); - } - else { - try { - if ((dst = fn.apply(t)) == null) - ex = new NullPointerException(); - } catch (Throwable rex) { - ex = rex; - } - } - } - if (dst == null) - dst = new CompletableFuture(); - if (e == null || ex != null) - dst.internalComplete(null, ex); - } - helpPostComplete(); - dst.helpPostComplete(); - return dst; + public CompletableFuture whenComplete + (BiConsumer action) { + return doWhenComplete(action, null); } + public CompletableFuture whenCompleteAsync + (BiConsumer action) { + return doWhenComplete(action, ForkJoinPool.commonPool()); + } + + public CompletableFuture whenCompleteAsync + (BiConsumer action, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doWhenComplete(action, executor); + } + + public CompletableFuture handle + (BiFunction fn) { + return doHandle(fn, null); + } + + public CompletableFuture handleAsync + (BiFunction fn) { + return doHandle(fn, ForkJoinPool.commonPool()); + } + + public CompletableFuture handleAsync + (BiFunction fn, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doHandle(fn, executor); + } + + /** + * Returns this CompletableFuture + * + * @return this CompletableFuture + */ + public CompletableFuture toCompletableFuture() { + return this; + } + + // not in interface CompletionStage + /** * Returns a new CompletableFuture that is completed when this * CompletableFuture completes, with the result of the given @@ -2868,6 +2608,8 @@ public class CompletableFuture implements Future { * completion when it completes exceptionally; otherwise, if this * CompletableFuture completes normally, then the returned * CompletableFuture also completes normally with the same value. + * Note: More flexible versions of this functionality are + * available using methods {@code whenComplete} and {@code handle}. * * @param fn the function to use to compute the value of the * returned CompletableFuture if this CompletableFuture completed @@ -2882,7 +2624,8 @@ public class CompletableFuture implements Future { Object r; if ((r = result) == null) { CompletionNode p = - new CompletionNode(d = new ExceptionCompletion(this, fn, dst)); + new CompletionNode(d = new ExceptionCompletion + (this, fn, dst)); while ((r = result) == null) { if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, p.next = completions, p)) @@ -2910,59 +2653,6 @@ public class CompletableFuture implements Future { return dst; } - /** - * Returns a new CompletableFuture that is completed when this - * CompletableFuture completes, with the result of the given - * function of the result and exception of this CompletableFuture's - * completion. The given function is invoked with the result (or - * {@code null} if none) and the exception (or {@code null} if none) - * of this CompletableFuture when complete. - * - * @param fn the function to use to compute the value of the - * returned CompletableFuture - * @return the new CompletableFuture - */ - public CompletableFuture handle - (BiFunction fn) { - if (fn == null) throw new NullPointerException(); - CompletableFuture dst = new CompletableFuture(); - HandleCompletion d = null; - Object r; - if ((r = result) == null) { - CompletionNode p = - new CompletionNode(d = new HandleCompletion(this, fn, dst)); - while ((r = result) == null) { - if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, - p.next = completions, p)) - break; - } - } - if (r != null && (d == null || d.compareAndSet(0, 1))) { - T t; Throwable ex; - if (r instanceof AltResult) { - ex = ((AltResult)r).ex; - t = null; - } - else { - ex = null; - @SuppressWarnings("unchecked") T tr = (T) r; - t = tr; - } - U u; Throwable dx; - try { - u = fn.apply(t, ex); - dx = null; - } catch (Throwable rex) { - dx = rex; - u = null; - } - dst.internalComplete(u, dx); - } - helpPostComplete(); - return dst; - } - - /* ------------- Arbitrary-arity constructions -------------- */ /* @@ -3214,6 +2904,21 @@ public class CompletableFuture implements Future { (((AltResult)r).ex instanceof CancellationException); } + /** + * Returns {@code true} if this CompletableFuture completed + * exceptionally, in any way. Possible causes include + * cancellation, explicit invocation of {@code + * completeExceptionally}, and abrupt termination of a + * CompletionStage action. + * + * @return {@code true} if this CompletableFuture completed + * exceptionally + */ + public boolean isCompletedExceptionally() { + Object r; + return ((r = result) instanceof AltResult) && r != NIL; + } + /** * Forcibly sets or resets the value subsequently returned by * method {@link #get()} and related methods, whether or not diff --git a/jdk/src/share/classes/java/util/concurrent/CompletionStage.java b/jdk/src/share/classes/java/util/concurrent/CompletionStage.java new file mode 100644 index 00000000000..6de60980cff --- /dev/null +++ b/jdk/src/share/classes/java/util/concurrent/CompletionStage.java @@ -0,0 +1,760 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +package java.util.concurrent; +import java.util.function.Supplier; +import java.util.function.Consumer; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.function.BiFunction; +import java.util.concurrent.Executor; + +/** + * A stage of a possibly asynchronous computation, that performs an + * action or computes a value when another CompletionStage completes. + * A stage completes upon termination of its computation, but this may + * in turn trigger other dependent stages. The functionality defined + * in this interface takes only a few basic forms, which expand out to + * a larger set of methods to capture a range of usage styles:

      + * + *
    • The computation performed by a stage may be expressed as a + * Function, Consumer, or Runnable (using methods with names including + * apply, accept, or run, respectively) + * depending on whether it requires arguments and/or produces results. + * For example, {@code stage.thenApply(x -> square(x)).thenAccept(x -> + * System.out.print(x)).thenRun(() -> System.out.println())}. An + * additional form (compose) applies functions of stages + * themselves, rather than their results.
    • + * + *
    • One stage's execution may be triggered by completion of a + * single stage, or both of two stages, or either of two stages. + * Dependencies on a single stage are arranged using methods with + * prefix then. Those triggered by completion of + * both of two stages may combine their results or + * effects, using correspondingly named methods. Those triggered by + * either of two stages make no guarantees about which of the + * results or effects are used for the dependent stage's + * computation.
    • + * + *
    • Dependencies among stages control the triggering of + * computations, but do not otherwise guarantee any particular + * ordering. Additionally, execution of a new stage's computations may + * be arranged in any of three ways: default execution, default + * asynchronous execution (using methods with suffix async + * that employ the stage's default asynchronous execution facility), + * or custom (via a supplied {@link Executor}). The execution + * properties of default and async modes are specified by + * CompletionStage implementations, not this interface. Methods with + * explicit Executor arguments may have arbitrary execution + * properties, and might not even support concurrent execution, but + * are arranged for processing in a way that accommodates asynchrony. + * + *
    • Two method forms support processing whether the triggering + * stage completed normally or exceptionally: Method {@link + * #whenComplete whenComplete} allows injection of an action + * regardless of outcome, otherwise preserving the outcome in its + * completion. Method {@link #handle handle} additionally allows the + * stage to compute a replacement result that may enable further + * processing by other dependent stages. In all other cases, if a + * stage's computation terminates abruptly with an (unchecked) + * exception or error, then all dependent stages requiring its + * completion complete exceptionally as well, with a {@link + * CompletionException} holding the exception as its cause. If a + * stage is dependent on both of two stages, and both + * complete exceptionally, then the CompletionException may correspond + * to either one of these exceptions. If a stage is dependent on + * either of two others, and only one of them completes + * exceptionally, no guarantees are made about whether the dependent + * stage completes normally or exceptionally. In the case of method + * {@code whenComplete}, when the supplied action itself encounters an + * exception, then the stage exceptionally completes with this + * exception if not already completed exceptionally.
    • + * + *
    + * + *

    All methods adhere to the above triggering, execution, and + * exceptional completion specifications (which are not repeated in + * individual method specifications). Additionally, while arguments + * used to pass a completion result (that is, for parameters of type + * {@code T}) for methods accepting them may be null, passing a null + * value for any other parameter will result in a {@link + * NullPointerException} being thrown. + * + *

    This interface does not define methods for initially creating, + * forcibly completing normally or exceptionally, probing completion + * status or results, or awaiting completion of a stage. + * Implementations of CompletionStage may provide means of achieving + * such effects, as appropriate. Method {@link #toCompletableFuture} + * enables interoperability among different implementations of this + * interface by providing a common conversion type. + * + * @author Doug Lea + * @since 1.8 + */ +public interface CompletionStage { + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed with this stage's result as the argument + * to the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage thenApply(Function fn); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed using this stage's default asynchronous + * execution facility, with this stage's result as the argument to + * the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage thenApplyAsync + (Function fn); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed using the supplied Executor, with this + * stage's result as the argument to the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage thenApplyAsync + (Function fn, + Executor executor); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed with this stage's result as the argument + * to the supplied action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage thenAccept(Consumer action); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed using this stage's default asynchronous + * execution facility, with this stage's result as the argument to + * the supplied action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage thenAcceptAsync(Consumer action); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed using the supplied Executor, with this + * stage's result as the argument to the supplied action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param action the action to perform before completing the + * returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @return the new CompletionStage + */ + public CompletionStage thenAcceptAsync(Consumer action, + Executor executor); + /** + * Returns a new CompletionStage that, when this stage completes + * normally, executes the given action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage thenRun(Runnable action); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, executes the given action using this stage's default + * asynchronous execution facility. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage thenRunAsync(Runnable action); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, executes the given action using the supplied Executor. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param action the action to perform before completing the + * returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @return the new CompletionStage + */ + public CompletionStage thenRunAsync(Runnable action, + Executor executor); + + /** + * Returns a new CompletionStage that, when this and the other + * given stage both complete normally, is executed with the two + * results as arguments to the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param the type of the other CompletionStage's result + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage thenCombine + (CompletionStage other, + BiFunction fn); + + /** + * Returns a new CompletionStage that, when this and the other + * given stage complete normally, is executed using this stage's + * default asynchronous execution facility, with the two results + * as arguments to the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param the type of the other CompletionStage's result + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage thenCombineAsync + (CompletionStage other, + BiFunction fn); + + /** + * Returns a new CompletionStage that, when this and the other + * given stage complete normally, is executed using the supplied + * executor, with the two results as arguments to the supplied + * function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @param the type of the other CompletionStage's result + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage thenCombineAsync + (CompletionStage other, + BiFunction fn, + Executor executor); + + /** + * Returns a new CompletionStage that, when this and the other + * given stage both complete normally, is executed with the two + * results as arguments to the supplied action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @param the type of the other CompletionStage's result + * @return the new CompletionStage + */ + public CompletionStage thenAcceptBoth + (CompletionStage other, + BiConsumer action); + + /** + * Returns a new CompletionStage that, when this and the other + * given stage complete normally, is executed using this stage's + * default asynchronous execution facility, with the two results + * as arguments to the supplied action. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @param the type of the other CompletionStage's result + * @return the new CompletionStage + */ + public CompletionStage thenAcceptBothAsync + (CompletionStage other, + BiConsumer action); + + /** + * Returns a new CompletionStage that, when this and the other + * given stage complete normally, is executed using the supplied + * executor, with the two results as arguments to the supplied + * function. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @param the type of the other CompletionStage's result + * @return the new CompletionStage + */ + public CompletionStage thenAcceptBothAsync + (CompletionStage other, + BiConsumer action, + Executor executor); + + /** + * Returns a new CompletionStage that, when this and the other + * given stage both complete normally, executes the given action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage runAfterBoth(CompletionStage other, + Runnable action); + /** + * Returns a new CompletionStage that, when this and the other + * given stage complete normally, executes the given action using + * this stage's default asynchronous execution facility. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage runAfterBothAsync(CompletionStage other, + Runnable action); + + /** + * Returns a new CompletionStage that, when this and the other + * given stage complete normally, executes the given action using + * the supplied executor + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @return the new CompletionStage + */ + public CompletionStage runAfterBothAsync(CompletionStage other, + Runnable action, + Executor executor); + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, is executed with the + * corresponding result as argument to the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage applyToEither + (CompletionStage other, + Function fn); + + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, is executed using this + * stage's default asynchronous execution facility, with the + * corresponding result as argument to the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage applyToEitherAsync + (CompletionStage other, + Function fn); + + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, is executed using the + * supplied executor, with the corresponding result as argument to + * the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param fn the function to use to compute the value of + * the returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage applyToEitherAsync + (CompletionStage other, + Function fn, + Executor executor); + + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, is executed with the + * corresponding result as argument to the supplied action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage acceptEither + (CompletionStage other, + Consumer action); + + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, is executed using this + * stage's default asynchronous execution facility, with the + * corresponding result as argument to the supplied action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage acceptEitherAsync + (CompletionStage other, + Consumer action); + + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, is executed using the + * supplied executor, with the corresponding result as argument to + * the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @return the new CompletionStage + */ + public CompletionStage acceptEitherAsync + (CompletionStage other, + Consumer action, + Executor executor); + + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, executes the given action. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage runAfterEither(CompletionStage other, + Runnable action); + + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, executes the given action + * using this stage's default asynchronous execution facility. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @return the new CompletionStage + */ + public CompletionStage runAfterEitherAsync + (CompletionStage other, + Runnable action); + + /** + * Returns a new CompletionStage that, when either this or the + * other given stage complete normally, executes the given action + * using supplied executor. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param other the other CompletionStage + * @param action the action to perform before completing the + * returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @return the new CompletionStage + */ + public CompletionStage runAfterEitherAsync + (CompletionStage other, + Runnable action, + Executor executor); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed with this stage as the argument + * to the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param fn the function returning a new CompletionStage + * @param the type of the returned CompletionStage's result + * @return the CompletionStage + */ + public CompletionStage thenCompose + (Function> fn); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed using this stage's default asynchronous + * execution facility, with this stage as the argument to the + * supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param fn the function returning a new CompletionStage + * @param the type of the returned CompletionStage's result + * @return the CompletionStage + */ + public CompletionStage thenComposeAsync + (Function> fn); + + /** + * Returns a new CompletionStage that, when this stage completes + * normally, is executed using the supplied Executor, with this + * stage's result as the argument to the supplied function. + * + * See the {@link CompletionStage} documentation for rules + * covering exceptional completion. + * + * @param fn the function returning a new CompletionStage + * @param executor the executor to use for asynchronous execution + * @param the type of the returned CompletionStage's result + * @return the CompletionStage + */ + public CompletionStage thenComposeAsync + (Function> fn, + Executor executor); + + /** + * Returns a new CompletionStage that, when this stage completes + * exceptionally, is executed with this stage's exception as the + * argument to the supplied function. Otherwise, if this stage + * completes normally, then the returned stage also completes + * normally with the same value. + * + * @param fn the function to use to compute the value of the + * returned CompletionStage if this CompletionStage completed + * exceptionally + * @return the new CompletionStage + */ + public CompletionStage exceptionally + (Function fn); + + /** + * Returns a new CompletionStage with the same result or exception + * as this stage, and when this stage completes, executes the + * given action with the result (or {@code null} if none) and the + * exception (or {@code null} if none) of this stage. + * + * @param action the action to perform + * @return the new CompletionStage + */ + public CompletionStage whenComplete + (BiConsumer action); + + /** + * Returns a new CompletionStage with the same result or exception + * as this stage, and when this stage completes, executes the + * given action executes the given action using this stage's + * default asynchronous execution facility, with the result (or + * {@code null} if none) and the exception (or {@code null} if + * none) of this stage as arguments. + * + * @param action the action to perform + * @return the new CompletionStage + */ + public CompletionStage whenCompleteAsync + (BiConsumer action); + + /** + * Returns a new CompletionStage with the same result or exception + * as this stage, and when this stage completes, executes using + * the supplied Executor, the given action with the result (or + * {@code null} if none) and the exception (or {@code null} if + * none) of this stage as arguments. + * + * @param action the action to perform + * @param executor the executor to use for asynchronous execution + * @return the new CompletionStage + */ + public CompletionStage whenCompleteAsync + (BiConsumer action, + Executor executor); + + /** + * Returns a new CompletionStage that, when this stage completes + * either normally or exceptionally, is executed with this stage's + * result and exception as arguments to the supplied function. + * The given function is invoked with the result (or {@code null} + * if none) and the exception (or {@code null} if none) of this + * stage when complete as arguments. + * + * @param fn the function to use to compute the value of the + * returned CompletionStage + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage handle + (BiFunction fn); + + /** + * Returns a new CompletionStage that, when this stage completes + * either normally or exceptionally, is executed using this stage's + * default asynchronous execution facility, with this stage's + * result and exception as arguments to the supplied function. + * The given function is invoked with the result (or {@code null} + * if none) and the exception (or {@code null} if none) of this + * stage when complete as arguments. + * + * @param fn the function to use to compute the value of the + * returned CompletionStage + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage handleAsync + (BiFunction fn); + + /** + * Returns a new CompletionStage that, when this stage completes + * either normally or exceptionally, is executed using the + * supplied executor, with this stage's result and exception as + * arguments to the supplied function. The given function is + * invoked with the result (or {@code null} if none) and the + * exception (or {@code null} if none) of this stage when complete + * as arguments. + * + * @param fn the function to use to compute the value of the + * returned CompletionStage + * @param executor the executor to use for asynchronous execution + * @param the function's return type + * @return the new CompletionStage + */ + public CompletionStage handleAsync + (BiFunction fn, + Executor executor); + + /** + * Returns a {@link CompletableFuture} maintaining the same + * completion properties as this stage. If this stage is already a + * CompletableFuture, this method may return this stage itself. + * Otherwise, invocation of this method may be equivalent in + * effect to {@code thenApply(x -> x)}, but returning an instance + * of type {@code CompletableFuture}. A CompletionStage + * implementation that does not choose to interoperate with others + * may throw {@code UnsupportedOperationException}. + * + * @return the CompletableFuture + * @throws UnsupportedOperationException if this implementation + * does not interoperate with CompletableFuture + */ + public CompletableFuture toCompletableFuture(); + +} diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 595dfb1a30d..7dcb991f486 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -370,12 +370,6 @@ java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all # Filed 6772009 java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all -# 8020435 -java/util/concurrent/CompletableFuture/Basic.java generic-all - -# 8020291 -java/util/Random/RandomStreamTest.java generic-all - # 7041639, Solaris DSA keypair generation bug java/util/TimeZone/TimeZoneDatePermissionCheck.sh solaris-all diff --git a/jdk/test/java/util/concurrent/CompletableFuture/Basic.java b/jdk/test/java/util/concurrent/CompletableFuture/Basic.java index ec6909de2de..f6233892c90 100644 --- a/jdk/test/java/util/concurrent/CompletableFuture/Basic.java +++ b/jdk/test/java/util/concurrent/CompletableFuture/Basic.java @@ -34,6 +34,8 @@ /* * @test * @bug 8005696 + * @run main Basic + * @run main/othervm -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 Basic * @summary Basic tests for CompletableFuture * @author Chris Hegarty */ From 2c31d993a43254f31c7a1652ad5a4bda13cd040a Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 31 Jul 2013 10:53:33 -0700 Subject: [PATCH 013/118] 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion Update specification to match implementation. Reviewed-by: darcy --- .../share/classes/java/util/Formatter.java | 30 ++++++---- .../java/util/Formatter/Basic-X.java.template | 59 ++++++++++++++----- jdk/test/java/util/Formatter/Basic.java | 2 +- jdk/test/java/util/Formatter/BasicDouble.java | 59 ++++++++++++++----- 4 files changed, 107 insertions(+), 43 deletions(-) diff --git a/jdk/src/share/classes/java/util/Formatter.java b/jdk/src/share/classes/java/util/Formatter.java index 5c096c63acf..275e1854e0a 100644 --- a/jdk/src/share/classes/java/util/Formatter.java +++ b/jdk/src/share/classes/java/util/Formatter.java @@ -626,12 +626,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 {@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 + *

    For the floating-point conversions {@code 'a'}, {@code 'A'}, {@code 'e'}, + * {@code 'E'}, and {@code 'f'} the precision is the number of digits after the + * radix point. 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 {@code 'a'} or {@code 'A'}, then the - * precision must not be specified. + * rounding. * *

    For character, integral, and date/time argument types and the percent * and line separator conversions, the precision is not applicable; if a @@ -1297,14 +1296,21 @@ import sun.misc.FormattedFloatingDecimal; * of the significand as a fraction. The exponent is represented by * {@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. + * Integer#toString(int) Integer.toString} on the exponent value. If the + * precision is specified, the value is rounded to the given number of + * hexadecimal digits. * *

  • If m is a {@code double} value with a subnormal - * representation then the significand is represented by the characters - * {@code '0x0.'} followed by the hexadecimal representation of the rest - * of the significand as a fraction. The exponent is represented by - * {@code 'p-1022'}. Note that there must be at least one nonzero digit - * in a subnormal significand. + * representation then, unless the precision is specified to be in the range + * 1 through 12, inclusive, the significand is represented by the characters + * {@code '0x0.'} followed by the hexadecimal representation of the rest of + * the significand as a fraction, and the exponent represented by + * {@code 'p-1022'}. If the precision is in the interval + * [1, 12], the subnormal value is normalized such that it + * begins with the characters {@code '0x1.'}, rounded to the number of + * hexadecimal digits of precision, and the exponent adjusted + * accordingly. Note that there must be at least one nonzero digit in a + * subnormal significand. * * * @@ -1367,7 +1373,7 @@ import sun.misc.FormattedFloatingDecimal; * {@code 1}. * *

    If the conversion is {@code 'a'} or {@code 'A'}, then the precision - * is the number of hexadecimal digits after the decimal separator. If the + * is the number of hexadecimal digits after the radix point. If the * precision is not provided, then all of the digits as returned by {@link * Double#toHexString(double)} will be output. * diff --git a/jdk/test/java/util/Formatter/Basic-X.java.template b/jdk/test/java/util/Formatter/Basic-X.java.template index a2d586a8958..813cf2d6782 100644 --- a/jdk/test/java/util/Formatter/Basic-X.java.template +++ b/jdk/test/java/util/Formatter/Basic-X.java.template @@ -1319,10 +1319,8 @@ public class Basic$Type$ extends Basic { Math.nextDown(DoubleConsts.MIN_NORMAL)); test("%.1a", "0x1.0p-1022", Math.nextDown(DoubleConsts.MIN_NORMAL)); - test("%.11a", "0x1.ffffffffffep-1023", - Double.parseDouble("0x0.fffffffffffp-1022")); - test("%.1a", "0x1.0p-1022", - Double.parseDouble("0x0.fffffffffffp-1022")); + test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022); + test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022); test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE); test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE); test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE); @@ -1336,19 +1334,50 @@ public class Basic$Type$ extends Basic { test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE); test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE); test("%.1a", "0x1.0p1024", Double.MAX_VALUE); - test("%.11a", "0x1.18000000000p0", Double.parseDouble("0x1.18p0")); - test("%.1a", "0x1.2p0", Double.parseDouble("0x1.18p0")); + test("%.11a", "0x1.18000000000p0", 0x1.18p0); + test("%.1a", "0x1.2p0", 0x1.18p0); - test("%.11a", "0x1.18000000000p0", - Double.parseDouble("0x1.180000000001p0")); - test("%.1a", "0x1.2p0", - Double.parseDouble("0x1.180000000001p0")); - test("%.11a", "0x1.28000000000p0", Double.parseDouble("0x1.28p0")); - test("%.1a", "0x1.2p0", Double.parseDouble("0x1.28p0")); + test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0); + test("%.1a", "0x1.2p0", 0x1.180000000001p0); + test("%.11a", "0x1.28000000000p0", 0x1.28p0); + test("%.1a", "0x1.2p0", 0x1.28p0); + + test("%.11a", "0x1.28000000000p0", 0x1.280000000001p0); + test("%.1a", "0x1.3p0", 0x1.280000000001p0); + + test("%a", "0x0.123p-1022", 0x0.123p-1022); + test("%1.3a", "0x1.230p-1026", 0x0.123p-1022); + test("%1.12a", "0x1.230000000000p-1026", 0x0.123p-1022); + test("%1.15a", "0x0.123000000000000p-1022", 0x0.123p-1022); + test("%1.5a", "0x1.00000p-1074", 0x0.0000000000001p-1022); + test("%1.7a", "0x1.0000000p-1022", 0x0.fffffffffffffp-1022); + + test("%1.6a", "0x1.230000p-1026", 0x0.123000057p-1022); + test("%1.7a", "0x1.2300005p-1026", 0x0.123000057p-1022); + test("%1.8a", "0x1.23000057p-1026", 0x0.123000057p-1022); + test("%1.9a", "0x1.230000570p-1026", 0x0.123000057p-1022); + + test("%1.6a", "0x1.230000p-1026", 0x0.123000058p-1022); + test("%1.7a", "0x1.2300006p-1026", 0x0.123000058p-1022); + test("%1.8a", "0x1.23000058p-1026", 0x0.123000058p-1022); + test("%1.9a", "0x1.230000580p-1026", 0x0.123000058p-1022); + + test("%1.6a", "0x1.230000p-1026", 0x0.123000059p-1022); + test("%1.7a", "0x1.2300006p-1026", 0x0.123000059p-1022); + test("%1.8a", "0x1.23000059p-1026", 0x0.123000059p-1022); + test("%1.9a", "0x1.230000590p-1026", 0x0.123000059p-1022); + + test("%1.4a", "0x1.0000p-1022", Math.nextDown(Double.MIN_NORMAL)); + + test("%a", "0x1.fffffffffffffp1023", Double.MAX_VALUE); + test("%1.1a", "0x1.0p1024", Double.MAX_VALUE); + test("%1.2a", "0x1.00p1024", Double.MAX_VALUE); + test("%1.6a", "0x1.000000p1024", Double.MAX_VALUE); + test("%1.9a", "0x1.000000000p1024", Double.MAX_VALUE); + test("%1.11a", "0x1.00000000000p1024", Double.MAX_VALUE); + test("%1.12a", "0x1.000000000000p1024", Double.MAX_VALUE); + test("%1.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE); - test("%.11a", "0x1.28000000000p0", - Double.parseDouble("0x1.280000000001p0")); - test("%.1a", "0x1.3p0", Double.parseDouble("0x1.280000000001p0")); #end[double] //--------------------------------------------------------------------- diff --git a/jdk/test/java/util/Formatter/Basic.java b/jdk/test/java/util/Formatter/Basic.java index 79123a19bca..88b21102818 100644 --- a/jdk/test/java/util/Formatter/Basic.java +++ b/jdk/test/java/util/Formatter/Basic.java @@ -25,7 +25,7 @@ * @summary Unit test for formatter * @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 5002937 * 5005104 5007745 5061412 5055180 5066788 5088703 6317248 6318369 6320122 - * 6344623 6369500 6534606 6282094 6286592 6476425 5063507 6469160 + * 6344623 6369500 6534606 6282094 6286592 6476425 5063507 6469160 6476168 * * @run shell/timeout=240 Basic.sh */ diff --git a/jdk/test/java/util/Formatter/BasicDouble.java b/jdk/test/java/util/Formatter/BasicDouble.java index 4c86c29c198..fa7bd1efa7d 100644 --- a/jdk/test/java/util/Formatter/BasicDouble.java +++ b/jdk/test/java/util/Formatter/BasicDouble.java @@ -1319,10 +1319,8 @@ public class BasicDouble extends Basic { Math.nextDown(DoubleConsts.MIN_NORMAL)); test("%.1a", "0x1.0p-1022", Math.nextDown(DoubleConsts.MIN_NORMAL)); - test("%.11a", "0x1.ffffffffffep-1023", - Double.parseDouble("0x0.fffffffffffp-1022")); - test("%.1a", "0x1.0p-1022", - Double.parseDouble("0x0.fffffffffffp-1022")); + test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022); + test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022); test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE); test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE); test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE); @@ -1336,19 +1334,50 @@ public class BasicDouble extends Basic { test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE); test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE); test("%.1a", "0x1.0p1024", Double.MAX_VALUE); - test("%.11a", "0x1.18000000000p0", Double.parseDouble("0x1.18p0")); - test("%.1a", "0x1.2p0", Double.parseDouble("0x1.18p0")); + test("%.11a", "0x1.18000000000p0", 0x1.18p0); + test("%.1a", "0x1.2p0", 0x1.18p0); - test("%.11a", "0x1.18000000000p0", - Double.parseDouble("0x1.180000000001p0")); - test("%.1a", "0x1.2p0", - Double.parseDouble("0x1.180000000001p0")); - test("%.11a", "0x1.28000000000p0", Double.parseDouble("0x1.28p0")); - test("%.1a", "0x1.2p0", Double.parseDouble("0x1.28p0")); + test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0); + test("%.1a", "0x1.2p0", 0x1.180000000001p0); + test("%.11a", "0x1.28000000000p0", 0x1.28p0); + test("%.1a", "0x1.2p0", 0x1.28p0); + + test("%.11a", "0x1.28000000000p0", 0x1.280000000001p0); + test("%.1a", "0x1.3p0", 0x1.280000000001p0); + + test("%a", "0x0.123p-1022", 0x0.123p-1022); + test("%1.3a", "0x1.230p-1026", 0x0.123p-1022); + test("%1.12a", "0x1.230000000000p-1026", 0x0.123p-1022); + test("%1.15a", "0x0.123000000000000p-1022", 0x0.123p-1022); + test("%1.5a", "0x1.00000p-1074", 0x0.0000000000001p-1022); + test("%1.7a", "0x1.0000000p-1022", 0x0.fffffffffffffp-1022); + + test("%1.6a", "0x1.230000p-1026", 0x0.123000057p-1022); + test("%1.7a", "0x1.2300005p-1026", 0x0.123000057p-1022); + test("%1.8a", "0x1.23000057p-1026", 0x0.123000057p-1022); + test("%1.9a", "0x1.230000570p-1026", 0x0.123000057p-1022); + + test("%1.6a", "0x1.230000p-1026", 0x0.123000058p-1022); + test("%1.7a", "0x1.2300006p-1026", 0x0.123000058p-1022); + test("%1.8a", "0x1.23000058p-1026", 0x0.123000058p-1022); + test("%1.9a", "0x1.230000580p-1026", 0x0.123000058p-1022); + + test("%1.6a", "0x1.230000p-1026", 0x0.123000059p-1022); + test("%1.7a", "0x1.2300006p-1026", 0x0.123000059p-1022); + test("%1.8a", "0x1.23000059p-1026", 0x0.123000059p-1022); + test("%1.9a", "0x1.230000590p-1026", 0x0.123000059p-1022); + + test("%1.4a", "0x1.0000p-1022", Math.nextDown(Double.MIN_NORMAL)); + + test("%a", "0x1.fffffffffffffp1023", Double.MAX_VALUE); + test("%1.1a", "0x1.0p1024", Double.MAX_VALUE); + test("%1.2a", "0x1.00p1024", Double.MAX_VALUE); + test("%1.6a", "0x1.000000p1024", Double.MAX_VALUE); + test("%1.9a", "0x1.000000000p1024", Double.MAX_VALUE); + test("%1.11a", "0x1.00000000000p1024", Double.MAX_VALUE); + test("%1.12a", "0x1.000000000000p1024", Double.MAX_VALUE); + test("%1.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE); - test("%.11a", "0x1.28000000000p0", - Double.parseDouble("0x1.280000000001p0")); - test("%.1a", "0x1.3p0", Double.parseDouble("0x1.280000000001p0")); //--------------------------------------------------------------------- From b661fb4e1aee40d80bd0a35959b23af63ab83821 Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Fri, 2 Aug 2013 15:30:11 -0700 Subject: [PATCH 014/118] 8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X On Mac, default to UTF-8 if no environmental hints are available Reviewed-by: naoto, ddehaven --- .../solaris/native/java/lang/java_props_md.c | 19 ++ .../ExpectedEncoding.java | 22 ++- .../MacJNUEncoding.sh | 0 .../System/MacEncoding/TestFileEncoding.java | 168 ++++++++++++++++++ 4 files changed, 203 insertions(+), 6 deletions(-) rename jdk/test/java/lang/System/{MacJNUEncoding => MacEncoding}/ExpectedEncoding.java (72%) rename jdk/test/java/lang/System/{MacJNUEncoding => MacEncoding}/MacJNUEncoding.sh (100%) create mode 100644 jdk/test/java/lang/System/MacEncoding/TestFileEncoding.java diff --git a/jdk/src/solaris/native/java/lang/java_props_md.c b/jdk/src/solaris/native/java/lang/java_props_md.c index c8c18982585..58e5e4543d7 100644 --- a/jdk/src/solaris/native/java/lang/java_props_md.c +++ b/jdk/src/solaris/native/java/lang/java_props_md.c @@ -360,6 +360,25 @@ static int ParseLocale(JNIEnv* env, int cat, char ** std_language, char ** std_s */ *std_encoding = "Big5-HKSCS-2001"; } +#endif +#ifdef MACOSX + /* + * For the case on MacOS X where encoding is set to US-ASCII, but we + * don't have any encoding hints from LANG/LC_ALL/LC_CTYPE, use UTF-8 + * instead. + * + * The contents of ASCII files will still be read and displayed + * correctly, but so will files containing UTF-8 characters beyond the + * standard ASCII range. + * + * Specifically, this allows apps launched by double-clicking a .jar + * file to correctly read UTF-8 files using the default encoding (see + * 8011194). + */ + if (strcmp(p,"US-ASCII") == 0 && getenv("LANG") == NULL && + getenv("LC_ALL") == NULL && getenv("LC_CTYPE") == NULL) { + *std_encoding = "UTF-8"; + } #endif } diff --git a/jdk/test/java/lang/System/MacJNUEncoding/ExpectedEncoding.java b/jdk/test/java/lang/System/MacEncoding/ExpectedEncoding.java similarity index 72% rename from jdk/test/java/lang/System/MacJNUEncoding/ExpectedEncoding.java rename to jdk/test/java/lang/System/MacEncoding/ExpectedEncoding.java index 723d45c677f..f9eb5161356 100644 --- a/jdk/test/java/lang/System/MacJNUEncoding/ExpectedEncoding.java +++ b/jdk/test/java/lang/System/MacEncoding/ExpectedEncoding.java @@ -31,6 +31,7 @@ public class ExpectedEncoding { if (args.length != 2) { System.out.println("Usage:"); System.out.println("$ java ExpectedEncoding "); + System.out.println("$ use \"skip\" to skip checking property's value"); System.exit(1); } String expectFileEnc = args[0]; @@ -39,16 +40,25 @@ public class ExpectedEncoding { String fileEnc = System.getProperty("file.encoding"); String jnuEnc = System.getProperty("sun.jnu.encoding"); - if (fileEnc == null || !fileEnc.equals(expectFileEnc)) { + if ("skip".equals(expectFileEnc)) { + System.err.println("Expected file.encoding is \"skip\", ignoring"); + } else { System.err.println("Expected file.encoding: " + expectFileEnc); System.err.println("Actual file.encoding: " + fileEnc); - failed = true; + if (fileEnc == null || !fileEnc.equals(expectFileEnc)) { + failed = true; + } } - if (jnuEnc == null || !jnuEnc.equals(expectSunJnuEnc)) { - System.err.println("Expected sun.jnu.encoding: " + expectSunJnuEnc); - System.err.println("Actual sun.jnu.encoding: " + jnuEnc); - failed = true; + if ("skip".equals(expectSunJnuEnc)) { + System.err.println("Expected sun.jnu.encoding is \"skip\", ignoring"); + } else { + if (jnuEnc == null || !jnuEnc.equals(expectSunJnuEnc)) { + System.err.println("Expected sun.jnu.encoding: " + expectSunJnuEnc); + System.err.println("Actual sun.jnu.encoding: " + jnuEnc); + failed = true; + } } + if (failed) { throw new RuntimeException("Test Failed"); } diff --git a/jdk/test/java/lang/System/MacJNUEncoding/MacJNUEncoding.sh b/jdk/test/java/lang/System/MacEncoding/MacJNUEncoding.sh similarity index 100% rename from jdk/test/java/lang/System/MacJNUEncoding/MacJNUEncoding.sh rename to jdk/test/java/lang/System/MacEncoding/MacJNUEncoding.sh diff --git a/jdk/test/java/lang/System/MacEncoding/TestFileEncoding.java b/jdk/test/java/lang/System/MacEncoding/TestFileEncoding.java new file mode 100644 index 00000000000..f911d5b8653 --- /dev/null +++ b/jdk/test/java/lang/System/MacEncoding/TestFileEncoding.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; + +/* + * @test + * @bug 8011194 + * @summary Test value of file.encoding for corresponding value of LANG, etc + * @library ../../../../tools/launcher/ ../ + * @build TestHelper TestFileEncoding ExpectedEncoding + * @run main TestFileEncoding UTF-8 + * @run main/othervm -Dfile.encoding=MyEncoding -DuserEncoding=MyEncoding TestFileEncoding MyEncoding + * @run main TestFileEncoding UTF-8 en_US.UTF-8 + * @run main/othervm -Dfile.encoding=MyEncoding -DuserEncoding=MyEncoding TestFileEncoding MyEncoding en_US.UTF-8 + * @run main TestFileEncoding US-ASCII C + * @run main/othervm -Dfile.encoding=MyEncoding -DuserEncoding=MyEncoding TestFileEncoding MyEncoding C + * @author Brent Christian + */ + +/** + * Setup the environment and run a sub-test to check the expected value of + * file.encoding, based on the value(s) of encoding-related environment vars + * (LANG, LC_ALL, LC_CTYPE). + * + * The first argument (required) is the expected value of the + * file.encoding System property. + * The second argument (optional) is the value to set to the LANG/etc env vars. + */ +public class TestFileEncoding { + private static final String TEST_NAME = "ExpectedEncoding"; + + private String expectedEncoding; // Expected value for file.encoding + private String langVar = null; // Value to set for LANG, etc + + private static Set envToRm = new HashSet<>(3); + static { + // Take these vars out of the test's run environment, possibly adding + // our own value back in. + envToRm.add("LANG"); + envToRm.add("LC_ALL"); + envToRm.add("LC_CTYPE"); + } + + public TestFileEncoding(String expectedEncoding) { + this.expectedEncoding = expectedEncoding; + } + + public TestFileEncoding(String expectedEncoding, String langVar) { + this.expectedEncoding = expectedEncoding; + this.langVar = langVar; + } + + /* + * Launch ExpectedEncoding with the given parameters, check for the + * expected file.encoding. + */ + private void run() { + String testClasses = System.getProperty("test.classes"); + + // Pick up VM opts + String vmOptsStr = System.getProperty("test.vm.opts"); + System.out.println("test.vm.opts: " + vmOptsStr); + String[] vmOpts = new String[0]; + if (vmOptsStr != null && !"".equals(vmOptsStr)) { + vmOpts = vmOptsStr.split(" "); + System.out.println("found vm options:"); + for (String opt : vmOpts) { + System.out.println(" <" + opt + ">"); + } + } + + // Build java cmd + LinkedList cmdList = new LinkedList<>(); + cmdList.add(TestHelper.javaCmd); + for (String vmOpt : vmOpts) { + if (vmOpt != null && !vmOpt.equals("")) { + cmdList.add(vmOpt); + } + } + + // See if the user specified a file.encoding that we should pass through + String userEncoding = System.getProperty("userEncoding"); + if (userEncoding != null) { + cmdList.add("-Dfile.encoding="+userEncoding); + } + + cmdList.add("-cp"); + cmdList.add(testClasses); + cmdList.add(TEST_NAME); + cmdList.add(expectedEncoding); + cmdList.add("skip"); // ignore sun.jnu.encoding for this test + + String cmdArray[] = new String[cmdList.size()]; + cmdList.toArray(cmdArray); + + // Run the test(s) + if (langVar == null) { + System.out.println("TestFileEncoding: Running with no envvars set"); + TestHelper.TestResult tr = TestHelper.doExec(null, envToRm, + cmdArray); + checkResult(tr); + } else { + runWithEnvVar("LANG", cmdArray); + runWithEnvVar("LC_ALL", cmdArray); + runWithEnvVar("LC_CTYPE", cmdArray); + } + } + + /* + * Run the test, setting the environment named by envVarName to the value + * in langVar. + */ + private void runWithEnvVar(String envVarName, String[] cmdArray) { + Map envToAdd = new HashMap<>(1); + TestHelper.TestResult tr = null; + + System.out.println("TestFileEncoding: Running with " + envVarName + "=" + langVar); + envToAdd.put(envVarName, langVar); + tr = TestHelper.doExec(envToAdd, envToRm, cmdArray); + checkResult(tr); + } + + private void checkResult(TestHelper.TestResult tr) { + System.out.println(tr); + if (!tr.isOK()) { + throw new RuntimeException("TEST FAILED: !tr.isOK()"); + } + } + + public static void main(String[] args) { + TestFileEncoding cfe = null; + if (!TestHelper.isMacOSX) { + System.out.println("Test is currently only for Mac OS X - pass."); + return; + } + if (args.length == 1) { + cfe = new TestFileEncoding(args[0]); + } else if (args.length == 2) { + cfe = new TestFileEncoding(args[0], args[1]); + } else { + System.out.println("Usage: TestFileEncoding "); + System.out.println(" TestFileEncoding "); + return; + } + cfe.run(); + } +} From aafacb6fa664f26689076592a896b79c63eb5ac0 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 2 Aug 2013 11:10:41 -0700 Subject: [PATCH 015/118] 8022094: BigDecimal/CompareToTests and BigInteger/CompareToTests are incorrect Fail test if errors; fix test values; port BigDecimal version to BigInteger Reviewed-by: smarks, alanb --- .../java/math/BigDecimal/CompareToTests.java | 35 +++++--- .../java/math/BigInteger/CompareToTests.java | 81 ++++++++++++------- 2 files changed, 79 insertions(+), 37 deletions(-) diff --git a/jdk/test/java/math/BigDecimal/CompareToTests.java b/jdk/test/java/math/BigDecimal/CompareToTests.java index 311f378d652..f9e3d258299 100644 --- a/jdk/test/java/math/BigDecimal/CompareToTests.java +++ b/jdk/test/java/math/BigDecimal/CompareToTests.java @@ -53,12 +53,29 @@ public class CompareToTests { {valueOf(5,-1), valueOf(2), ONE}, // Boundary and near boundary values - {valueOf(Long.MAX_VALUE), valueOf(Long.MAX_VALUE), ZERO}, - {valueOf(Long.MAX_VALUE-1), valueOf(Long.MAX_VALUE), MINUS_ONE}, - {valueOf(Long.MIN_VALUE), valueOf(Long.MAX_VALUE), MINUS_ONE}, - {valueOf(Long.MIN_VALUE+1), valueOf(Long.MAX_VALUE), MINUS_ONE}, - {valueOf(Long.MIN_VALUE), valueOf(Long.MIN_VALUE), ZERO}, - {valueOf(Long.MIN_VALUE+1), valueOf(Long.MAX_VALUE), ONE}, + {valueOf(Long.MAX_VALUE), valueOf(Long.MAX_VALUE), ZERO}, + {valueOf(Long.MAX_VALUE).negate(), valueOf(Long.MAX_VALUE), MINUS_ONE}, + + {valueOf(Long.MAX_VALUE-1), valueOf(Long.MAX_VALUE), MINUS_ONE}, + {valueOf(Long.MAX_VALUE-1).negate(), valueOf(Long.MAX_VALUE), MINUS_ONE}, + + {valueOf(Long.MIN_VALUE), valueOf(Long.MAX_VALUE), MINUS_ONE}, + {valueOf(Long.MIN_VALUE).negate(), valueOf(Long.MAX_VALUE), ONE}, + + {valueOf(Long.MIN_VALUE+1), valueOf(Long.MAX_VALUE), MINUS_ONE}, + {valueOf(Long.MIN_VALUE+1).negate(), valueOf(Long.MAX_VALUE), ZERO}, + + {valueOf(Long.MAX_VALUE), valueOf(Long.MIN_VALUE), ONE}, + {valueOf(Long.MAX_VALUE).negate(), valueOf(Long.MIN_VALUE), ONE}, + + {valueOf(Long.MAX_VALUE-1), valueOf(Long.MIN_VALUE), ONE}, + {valueOf(Long.MAX_VALUE-1).negate(), valueOf(Long.MIN_VALUE), ONE}, + + {valueOf(Long.MIN_VALUE), valueOf(Long.MIN_VALUE), ZERO}, + {valueOf(Long.MIN_VALUE).negate(), valueOf(Long.MIN_VALUE), ONE}, + + {valueOf(Long.MIN_VALUE+1), valueOf(Long.MIN_VALUE), ONE}, + {valueOf(Long.MIN_VALUE+1).negate(), valueOf(Long.MIN_VALUE), ONE}, }; for (BigDecimal[] testCase : testCases) { @@ -69,8 +86,6 @@ public class CompareToTests { int expected = testCase[2].intValue(); failures += compareToTest(a, b, expected); - failures += compareToTest(a_negate, b, -1); - failures += compareToTest(a, b_negate, 1); failures += compareToTest(a_negate, b_negate, -expected); } @@ -81,11 +96,11 @@ public class CompareToTests { private static int compareToTest(BigDecimal a, BigDecimal b, int expected) { int result = a.compareTo(b); int failed = (result==expected) ? 0 : 1; - if (result == 1) { + if (failed == 1) { System.err.println("(" + a + ").compareTo(" + b + ") => " + result + "\n\tExpected " + expected); } - return result; + return failed; } public static void main(String argv[]) { diff --git a/jdk/test/java/math/BigInteger/CompareToTests.java b/jdk/test/java/math/BigInteger/CompareToTests.java index 311f378d652..fc4386a797a 100644 --- a/jdk/test/java/math/BigInteger/CompareToTests.java +++ b/jdk/test/java/math/BigInteger/CompareToTests.java @@ -24,20 +24,23 @@ /* * @test * @bug 6473768 - * @summary Tests of BigDecimal.compareTo + * @summary Tests of BigInteger.compareTo * @author Joseph D. Darcy */ import java.math.*; -import static java.math.BigDecimal.*; +import static java.math.BigInteger.*; public class CompareToTests { private static int compareToTests() { int failures = 0; - final BigDecimal MINUS_ONE = BigDecimal.ONE.negate(); + final BigInteger MINUS_ONE = BigInteger.ONE.negate(); + final BigInteger TWO_POW_126 = ONE.shiftLeft(126); + final BigInteger TWO_POW_127 = ONE.shiftLeft(127); + final BigInteger TWO_POW_128 = ONE.shiftLeft(128); // First operand, second operand, expected compareTo result - BigDecimal [][] testCases = { + BigInteger [][] testCases = { // Basics {valueOf(0), valueOf(0), ZERO}, {valueOf(0), valueOf(1), MINUS_ONE}, @@ -45,32 +48,56 @@ public class CompareToTests { {valueOf(2), valueOf(1), ONE}, {valueOf(10), valueOf(10), ZERO}, - // Significands would compare differently than scaled value - {valueOf(2,1), valueOf(2), MINUS_ONE}, - {valueOf(2,-1), valueOf(2), ONE}, - {valueOf(1,1), valueOf(2), MINUS_ONE}, - {valueOf(1,-1), valueOf(2), ONE}, - {valueOf(5,-1), valueOf(2), ONE}, + // Various relative lengths of internal mag array. + {TWO_POW_127, TWO_POW_127, ZERO}, + {TWO_POW_127.negate(), TWO_POW_127, MINUS_ONE}, - // Boundary and near boundary values - {valueOf(Long.MAX_VALUE), valueOf(Long.MAX_VALUE), ZERO}, - {valueOf(Long.MAX_VALUE-1), valueOf(Long.MAX_VALUE), MINUS_ONE}, - {valueOf(Long.MIN_VALUE), valueOf(Long.MAX_VALUE), MINUS_ONE}, - {valueOf(Long.MIN_VALUE+1), valueOf(Long.MAX_VALUE), MINUS_ONE}, - {valueOf(Long.MIN_VALUE), valueOf(Long.MIN_VALUE), ZERO}, - {valueOf(Long.MIN_VALUE+1), valueOf(Long.MAX_VALUE), ONE}, + {TWO_POW_128.or(TWO_POW_126), TWO_POW_128, ONE}, + {TWO_POW_128.or(TWO_POW_126), TWO_POW_128.negate(), ONE}, + + {TWO_POW_128, TWO_POW_128.or(TWO_POW_126), MINUS_ONE}, + {TWO_POW_128.negate(), TWO_POW_128.or(TWO_POW_126), MINUS_ONE}, + + {TWO_POW_127, TWO_POW_128, MINUS_ONE}, + {TWO_POW_127.negate(), TWO_POW_128, MINUS_ONE}, + + {TWO_POW_128, TWO_POW_127, ONE}, + {TWO_POW_128.negate(), TWO_POW_127, MINUS_ONE}, + + // Long boundary and near boundary values + {valueOf(Long.MAX_VALUE), valueOf(Long.MAX_VALUE), ZERO}, + {valueOf(Long.MAX_VALUE).negate(), valueOf(Long.MAX_VALUE), MINUS_ONE}, + + {valueOf(Long.MAX_VALUE-1), valueOf(Long.MAX_VALUE), MINUS_ONE}, + {valueOf(Long.MAX_VALUE-1).negate(), valueOf(Long.MAX_VALUE), MINUS_ONE}, + + {valueOf(Long.MIN_VALUE), valueOf(Long.MAX_VALUE), MINUS_ONE}, + {valueOf(Long.MIN_VALUE).negate(), valueOf(Long.MAX_VALUE), ONE}, + + {valueOf(Long.MIN_VALUE+1), valueOf(Long.MAX_VALUE), MINUS_ONE}, + {valueOf(Long.MIN_VALUE+1).negate(), valueOf(Long.MAX_VALUE), ZERO}, + + {valueOf(Long.MAX_VALUE), valueOf(Long.MIN_VALUE), ONE}, + {valueOf(Long.MAX_VALUE).negate(), valueOf(Long.MIN_VALUE), ONE}, + + {valueOf(Long.MAX_VALUE-1), valueOf(Long.MIN_VALUE), ONE}, + {valueOf(Long.MAX_VALUE-1).negate(), valueOf(Long.MIN_VALUE), ONE}, + + {valueOf(Long.MIN_VALUE), valueOf(Long.MIN_VALUE), ZERO}, + {valueOf(Long.MIN_VALUE).negate(), valueOf(Long.MIN_VALUE), ONE}, + + {valueOf(Long.MIN_VALUE+1), valueOf(Long.MIN_VALUE), ONE}, + {valueOf(Long.MIN_VALUE+1).negate(), valueOf(Long.MIN_VALUE), ONE}, }; - for (BigDecimal[] testCase : testCases) { - BigDecimal a = testCase[0]; - BigDecimal a_negate = a.negate(); - BigDecimal b = testCase[1]; - BigDecimal b_negate = b.negate(); + for (BigInteger[] testCase : testCases) { + BigInteger a = testCase[0]; + BigInteger a_negate = a.negate(); + BigInteger b = testCase[1]; + BigInteger b_negate = b.negate(); int expected = testCase[2].intValue(); failures += compareToTest(a, b, expected); - failures += compareToTest(a_negate, b, -1); - failures += compareToTest(a, b_negate, 1); failures += compareToTest(a_negate, b_negate, -expected); } @@ -78,14 +105,14 @@ public class CompareToTests { return failures; } - private static int compareToTest(BigDecimal a, BigDecimal b, int expected) { + private static int compareToTest(BigInteger a, BigInteger b, int expected) { int result = a.compareTo(b); int failed = (result==expected) ? 0 : 1; - if (result == 1) { + if (failed == 1) { System.err.println("(" + a + ").compareTo(" + b + ") => " + result + "\n\tExpected " + expected); } - return result; + return failed; } public static void main(String argv[]) { From 2be7768ab06be1db080133019c6aeecbdcb712f7 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 5 Aug 2013 07:50:16 -0700 Subject: [PATCH 016/118] 8022190: Fix varargs lint warnings in the JDK Reviewed-by: alanb, lancea, alexsch --- jdk/src/share/classes/java/util/stream/Stream.java | 1 + jdk/src/share/classes/javax/swing/SwingWorker.java | 3 ++- .../share/classes/sun/reflect/annotation/AnnotationParser.java | 1 + jdk/src/share/classes/sun/swing/AccumulativeRunnable.java | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/util/stream/Stream.java b/jdk/src/share/classes/java/util/stream/Stream.java index a5f36841f4a..76789d38f13 100644 --- a/jdk/src/share/classes/java/util/stream/Stream.java +++ b/jdk/src/share/classes/java/util/stream/Stream.java @@ -827,6 +827,7 @@ public interface Stream extends BaseStream> { * @return the new stream */ @SafeVarargs + @SuppressWarnings("varargs") // Creating a stream from an array is safe public static Stream of(T... values) { return Arrays.stream(values); } diff --git a/jdk/src/share/classes/javax/swing/SwingWorker.java b/jdk/src/share/classes/javax/swing/SwingWorker.java index 294808188cd..f7b343d8e44 100644 --- a/jdk/src/share/classes/javax/swing/SwingWorker.java +++ b/jdk/src/share/classes/javax/swing/SwingWorker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -405,6 +405,7 @@ public abstract class SwingWorker implements RunnableFuture { * */ @SafeVarargs + @SuppressWarnings("varargs") // Passing chunks to add is safe protected final void publish(V... chunks) { synchronized (this) { if (doProcess == null) { diff --git a/jdk/src/share/classes/sun/reflect/annotation/AnnotationParser.java b/jdk/src/share/classes/sun/reflect/annotation/AnnotationParser.java index 341f2033f64..2dc978a4dea 100644 --- a/jdk/src/share/classes/sun/reflect/annotation/AnnotationParser.java +++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationParser.java @@ -88,6 +88,7 @@ public class AnnotationParser { * @param selectAnnotationClasses an array of annotation types to select when parsing */ @SafeVarargs + @SuppressWarnings("varargs") // selectAnnotationClasses is used safely static Map, Annotation> parseSelectAnnotations( byte[] rawAnnotations, ConstantPool constPool, diff --git a/jdk/src/share/classes/sun/swing/AccumulativeRunnable.java b/jdk/src/share/classes/sun/swing/AccumulativeRunnable.java index a1712731524..ac57e6d2115 100644 --- a/jdk/src/share/classes/sun/swing/AccumulativeRunnable.java +++ b/jdk/src/share/classes/sun/swing/AccumulativeRunnable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -121,6 +121,7 @@ public abstract class AccumulativeRunnable implements Runnable { * @param args the arguments to accumulate */ @SafeVarargs + @SuppressWarnings("varargs") // Copying args is safe public final synchronized void add(T... args) { boolean isSubmitted = true; if (arguments == null) { From bdc36d78a1669edd37eb380a72e00bc7dca7095e Mon Sep 17 00:00:00 2001 From: Andreas Rieber Date: Mon, 5 Aug 2013 21:31:40 +0530 Subject: [PATCH 017/118] 8016531: jconsole-plugin script demo does not work with nashorn Reviewed-by: lagergren, hannesw --- .../scripting/jconsole/ScriptShellPanel.java | 4 +- .../jconsole-plugin/src/resources/jconsole.js | 146 +++++++++++++----- .../jconsole-plugin/src/scripts/invoke.js | 4 +- .../jconsole-plugin/src/scripts/jstack.js | 10 +- .../jconsole-plugin/src/scripts/jtop.js | 12 +- .../jconsole-plugin/src/scripts/sysprops.js | 10 +- .../sample/scripting/scriptpad/README.txt | 2 +- .../scripting/scriptpad/src/resources/conc.js | 4 +- .../scripting/scriptpad/src/resources/mm.js | 57 ++++--- 9 files changed, 156 insertions(+), 93 deletions(-) diff --git a/jdk/src/share/demo/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java b/jdk/src/share/demo/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java index 40cf8088169..c7e4dee51bc 100644 --- a/jdk/src/share/demo/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java +++ b/jdk/src/share/demo/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -54,7 +54,7 @@ import javax.swing.text.*; * jconsole's script console. */ -class ScriptShellPanel extends JPanel { +public class ScriptShellPanel extends JPanel { private static final long serialVersionUID = 4116273141148726319L; diff --git a/jdk/src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js b/jdk/src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js index 715da1d9a56..f39dea30069 100644 --- a/jdk/src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js +++ b/jdk/src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -77,12 +77,37 @@ function jcontext() { return plugin.getContext(); } -jcontext.docString = "returns JConsoleContext for the current jconsole plugin" +jcontext.docString = "returns JConsoleContext for the current jconsole plugin"; function mbeanConnection() { return jcontext().getMBeanServerConnection(); } -mbeanConnection.docString = "returns current MBeanServer connection" +mbeanConnection.docString = "returns current MBeanServer connection"; + +// check if there is a build in sync function, define one if missing +if (typeof sync === "undefined") { + var sync = function(func, obj) { + if (arguments.length < 1 || arguments.length > 2 ) { + throw "sync(function [,object]) parameter count mismatch"; + } + + var syncobj = (arguments.length == 2 ? obj : this); + + if (!syncobj._syncLock) { + syncobj._syncLock = new Lock(); + } + + return function() { + syncobj._syncLock.lock(); + try { + func.apply(null, arguments); + } finally { + syncobj._syncLock.unlock(); + } + }; + }; + sync.docString = "synchronize a function, optionally on an object"; +} /** * Prints one liner help message for each function exposed here @@ -188,22 +213,12 @@ queryMBeans.docString = "return MBeans using given ObjectName and optional query // wraps a script array as java.lang.Object[] function objectArray(array) { - var len = array.length; - var res = java.lang.reflect.Array.newInstance(java.lang.Object, len); - for (var i = 0; i < array.length; i++) { - res[i] = array[i]; - } - return res; + return Java.to(array, "java.lang.Object[]"); } // wraps a script (string) array as java.lang.String[] function stringArray(array) { - var len = array.length; - var res = java.lang.reflect.Array.newInstance(java.lang.String, len); - for (var i = 0; i < array.length; i++) { - res[i] = String(array[i]); - } - return res; + return Java.to(array, "java.lang.String[]"); } // script array to Java List @@ -286,16 +301,18 @@ invokeMBean.docString = "invokes MBean operation on given ObjectName"; * will be of type FutureTask. When you need value, call 'get' on it. */ function mbean(objName, async) { + var index; + objName = objectName(objName); var info = mbeanInfo(objName); var attrs = info.attributes; var attrMap = new Object; - for (var index in attrs) { + for (index in attrs) { attrMap[attrs[index].name] = attrs[index]; } var opers = info.operations; var operMap = new Object; - for (var index in opers) { + for (index in opers) { operMap[opers[index].name] = opers[index]; } @@ -318,21 +335,30 @@ function mbean(objName, async) { } else { return getMBeanAttribute(objName, name); } - } else if (isOperation(name)) { + } else { + return undefined; + } + }, + __call__: function(name) { + if (isOperation(name)) { var oper = operMap[name]; - return function() { - var params = objectArray(arguments); - var sigs = oper.signature; - var sigNames = new Array(sigs.length); - for (var index in sigs) { - sigNames[index] = sigs[index].getType(); - } - if (async) { - return invokeMBean.future(objName, name, - params, sigNames); - } else { - return invokeMBean(objName, name, params, sigNames); - } + + var params = []; + for (var j = 1; j < arguments.length; j++) { + params[j-1]= arguments[j]; + } + + var sigs = oper.signature; + + var sigNames = new Array(sigs.length); + for (var index in sigs) { + sigNames[index] = sigs[index].getType(); + } + + if (async) { + return invokeMBean.future(objName, name, params, sigNames); + } else { + return invokeMBean(objName, name, params, sigNames); } } else { return undefined; @@ -520,7 +546,7 @@ Function.prototype.sync = function (lock) { } finally { lock.unlock(); } -} +}; /** * Causes current thread to sleep for specified @@ -534,8 +560,7 @@ function sleep(interval) { sleep.docString = "wrapper for java.lang.Thread.sleep method"; /** - * Schedules a task to be executed once in - * every N milliseconds specified. + * Schedules a task to be executed once in N milliseconds specified. * * @param callback function or expression to evaluate * @param interval in milliseconds to sleep @@ -549,15 +574,15 @@ function setTimeout(callback, interval) { // start a new thread that sleeps given time // and calls callback in an infinite loop return (function() { - while (true) { + try { sleep(interval); - callback(); - } + } catch (x) { } + callback(); }).daemon(); } -setTimeout.docString = "calls given callback once after specified interval" +setTimeout.docString = "calls given callback once after specified interval"; -/** +/** * Cancels a timeout set earlier. * @param tid timeout ID returned from setTimeout */ @@ -565,6 +590,45 @@ function clearTimeout(tid) { // we just interrupt the timer thread tid.interrupt(); } +clearTimeout.docString = "interrupt a setTimeout timer"; + +/** + * Schedules a task to be executed once in + * every N milliseconds specified. + * + * @param callback function or expression to evaluate + * @param interval in milliseconds to sleep + * @return timeout ID (which is nothing but Thread instance) + */ +function setInterval(callback, interval) { + if (! (callback instanceof Function)) { + callback = new Function(callback); + } + + // start a new thread that sleeps given time + // and calls callback in an infinite loop + return (function() { + while (true) { + try { + sleep(interval); + } catch (x) { + break; + } + callback(); + } + }).daemon(); +} +setInterval.docString = "calls given callback every specified interval"; + +/** + * Cancels a timeout set earlier. + * @param tid timeout ID returned from setTimeout + */ +function clearInterval(tid) { + // we just interrupt the timer thread + tid.interrupt(); +} +clearInterval.docString = "interrupt a setInterval timer"; /** * Simple access to thread local storage. @@ -680,7 +744,7 @@ function msgBox(msg, title, msgType) { if (msg === undefined) msg = "undefined"; if (msg === null) msg = "null"; if (title == undefined) title = msg; - if (msgType == undefined) type = JOptionPane.INFORMATION_MESSAGE; + if (msgType == undefined) msgType = JOptionPane.INFORMATION_MESSAGE; JOptionPane.showMessageDialog(window, msg, title, msgType); } if (isEventThread()) { @@ -800,7 +864,7 @@ echo.docString = "echoes arguments to interactive console screen"; * Clear the screen */ function clear() { - (function() { window.clear(false) }).invokeLater(); + (function() { window.clear(false); }).invokeLater(); } clear.docString = "clears interactive console screen"; diff --git a/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/invoke.js b/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/invoke.js index 8c66e0df388..919769bc493 100644 --- a/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/invoke.js +++ b/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/invoke.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -53,6 +53,6 @@ * */ function resetPeakThreadCount() { - return invokeMBean("java.lang:type=Threading", "resetPeakThreadCount", [], ""); + return invokeMBean("java.lang:type=Threading", "resetPeakThreadCount", [], {}); } diff --git a/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/jstack.js b/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/jstack.js index b05dc198b47..aff7d7c04e1 100644 --- a/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/jstack.js +++ b/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/jstack.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -43,16 +43,16 @@ * threads.'jstack' function which can be called once or periodically * from a timer thread (calling it periodically would slow down the target * application). To call this once, just call 'jstack()' in script - * console prompt. To call jtop in a timer thread, you can use + * console prompt. To call jstack in a timer thread, you can use * - * var t = setTimeout(function () { jstack(print); }, 5000); + * var t = setInterval(function () { jstack(print); }, 5000); * * The above call prints threads in sorted order for every 5 seconds. * The print output goes to OS console window from which jconsole was * started. The timer can be cancelled later by clearTimeout() function * as shown below: * - * clearTimeout(t); + * clearInterval(t); */ @@ -87,7 +87,7 @@ function jstack(printFunc, maxFrames) { var tmbean = newPlatformMXBeanProxy( "java.lang:type=Threading", - java.lang.management.ThreadMXBean); + java.lang.management.ThreadMXBean.class); var tids = tmbean.allThreadIds; var tinfos = tmbean["getThreadInfo(long[],int)"](tids, maxFrames); diff --git a/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/jtop.js b/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/jtop.js index daebfc63a4f..2733b12a69e 100644 --- a/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/jtop.js +++ b/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/jtop.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -45,14 +45,14 @@ * To call this once, just call 'jtop()' in script console prompt. * To call jtop in a timer thread, you can use * - * var t = setTimeout(function () { jtop(print); }, 2000); + * var t = setInterval(function () { jtop(print); }, 2000); * * The above call prints threads in sorted order for every 2 seconds. * The print output goes to OS console window from which jconsole was * started. The timer can be cancelled later by clearTimeout() function * as shown below: - * - * clearTimeout(t); + * + * clearInterval(t); */ /** @@ -62,10 +62,10 @@ function getThreadList() { var tmbean = newPlatformMXBeanProxy( "java.lang:type=Threading", - java.lang.management.ThreadMXBean); + java.lang.management.ThreadMXBean.class); if (!tmbean.isThreadCpuTimeSupported()) { - return; + return java.util.Collections.EMPTY_LIST; } tmbean.setThreadCpuTimeEnabled(true); diff --git a/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/sysprops.js b/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/sysprops.js index d15d482ae57..5ff958d836e 100644 --- a/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/sysprops.js +++ b/jdk/src/share/demo/scripting/jconsole-plugin/src/scripts/sysprops.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -43,16 +43,16 @@ * properties.'sysprops' function which can be called once or periodically * from a timer thread (calling it periodically would slow down the target * application). To call this once, just call 'sysprops()' in script - * console prompt. To call jtop in a timer thread, you can use + * console prompt. To call sysprops in a timer thread, you can use * - * var t = setTimeout(function () { sysprops(print); }, 5000); + * var t = setInterval(function () { sysprops(print); }, 5000); * * The above call prints threads in sorted order for every 5 seconds. * The print output goes to OS console window from which jconsole was * started. The timer can be cancelled later by clearTimeout() function * as shown below: * - * clearTimeout(t); + * clearInterval(t); */ @@ -62,7 +62,7 @@ function getSystemProps() { var runtimeBean = newPlatformMXBeanProxy( "java.lang:type=Runtime", - java.lang.management.RuntimeMXBean); + java.lang.management.RuntimeMXBean.class); return runtimeBean.systemProperties; } diff --git a/jdk/src/share/sample/scripting/scriptpad/README.txt b/jdk/src/share/sample/scripting/scriptpad/README.txt index 446feae4e0b..ab4bd5fed96 100644 --- a/jdk/src/share/sample/scripting/scriptpad/README.txt +++ b/jdk/src/share/sample/scripting/scriptpad/README.txt @@ -108,7 +108,7 @@ under the ./src/scripts directory. java -Dcom.sun.management.jmxremote.port=1090 \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ - -jar $JDK_HOME/demo/jfc/Java2D/Java2Demo.jar + -jar $JDK_HOME/demo/jfc/Font2DTest/Font2DTest.jar (2) Start scriptpad and click on "Tools->JMX Connect" menu. In the prompt, enter "localhost:1090" to connect to the above diff --git a/jdk/src/share/sample/scripting/scriptpad/src/resources/conc.js b/jdk/src/share/sample/scripting/scriptpad/src/resources/conc.js index 7e56fad4703..aaca49aea79 100644 --- a/jdk/src/share/sample/scripting/scriptpad/src/resources/conc.js +++ b/jdk/src/share/sample/scripting/scriptpad/src/resources/conc.js @@ -221,7 +221,7 @@ sleep.docString = "wrapper for java.lang.Thread.sleep method"; * @return timeout ID (which is nothing but Thread instance) */ function setTimeout(callback, interval) { - if (! (callback instanceof Function) && typeof callback !== "function") { + if (! (callback instanceof Function)) { callback = new Function(callback); } @@ -255,7 +255,7 @@ clearTimeout.docString = "interrupt a setTimeout timer"; * @return timeout ID (which is nothing but Thread instance) */ function setInterval(callback, interval) { - if (! (callback instanceof Function) && typeof callback !== "function") { + if (! (callback instanceof Function)) { callback = new Function(callback); } diff --git a/jdk/src/share/sample/scripting/scriptpad/src/resources/mm.js b/jdk/src/share/sample/scripting/scriptpad/src/resources/mm.js index 2b75f243bfc..07efad27801 100644 --- a/jdk/src/share/sample/scripting/scriptpad/src/resources/mm.js +++ b/jdk/src/share/sample/scripting/scriptpad/src/resources/mm.js @@ -159,22 +159,12 @@ queryMBeans.docString = "return MBeans using given ObjectName and optional query // wraps a script array as java.lang.Object[] function objectArray(array) { - var len = array.length; - var res = java.lang.reflect.Array.newInstance(java.lang.Object, len); - for (var i = 0; i < array.length; i++) { - res[i] = array[i]; - } - return res; + return Java.to(array, "java.lang.Object[]"); } // wraps a script (string) array as java.lang.String[] function stringArray(array) { - var len = array.length; - var res = java.lang.reflect.Array.newInstance(java.lang.String, len); - for (var i = 0; i < array.length; i++) { - res[i] = String(array[i]); - } - return res; + return Java.to(array, "java.lang.String[]"); } // script array to Java List @@ -284,26 +274,35 @@ function mbean(objName, async) { __get__: function (name) { if (isAttribute(name)) { if (async) { - return getMBeanAttribute.future(objName, name); + return getMBeanAttribute.future(objName, name); } else { - return getMBeanAttribute(objName, name); + return getMBeanAttribute(objName, name); } - } else if (isOperation(name)) { + } else { + return undefined; + } + }, + __call__: function(name) { + if (isOperation(name)) { var oper = operMap[name]; - return function() { - var params = objectArray(arguments); - var sigs = oper.signature; - var sigNames = new Array(sigs.length); - for (var index in sigs) { - sigNames[index] = sigs[index].getType(); - } - if (async) { - return invokeMBean.future(objName, name, - params, sigNames); - } else { - return invokeMBean(objName, name, params, sigNames); - } - }; + + var params = []; + for (var j = 1; j < arguments.length; j++) { + params[j-1]= arguments[j]; + } + + var sigs = oper.signature; + + var sigNames = new Array(sigs.length); + for (var index in sigs) { + sigNames[index] = sigs[index].getType(); + } + + if (async) { + return invokeMBean.future(objName, name, params, sigNames); + } else { + return invokeMBean(objName, name, params, sigNames); + } } else { return undefined; } From c05c2330cf5f27f660fc3677d0deefb73267f70a Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Mon, 5 Aug 2013 19:12:33 -0700 Subject: [PATCH 018/118] 8020854: change RMI javadocs to specify that remote objects are exported to the wildcard address Reviewed-by: rgallard, alanb --- .../java/rmi/server/RMISocketFactory.java | 40 +++++++++++++++++-- .../java/rmi/server/UnicastRemoteObject.java | 22 +++++++++- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java b/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java index ccff225c87d..e7b7581820b 100644 --- a/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java +++ b/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,15 +33,47 @@ import java.net.*; * in order to obtain client and server sockets for RMI calls. An * application may use the setSocketFactory method to * request that the RMI runtime use its socket factory instance - * instead of the default implementation.

    + * instead of the default implementation. * - * The default socket factory implementation used goes through a + *

    The default socket factory implementation performs a * three-tiered approach to creating client sockets. First, a direct * socket connection to the remote VM is attempted. If that fails * (due to a firewall), the runtime uses HTTP with the explicit port * number of the server. If the firewall does not allow this type of * communication, then HTTP to a cgi-bin script on the server is used - * to POST the RMI call.

    + * to POST the RMI call. + * + *

    The default socket factory implementation creates server sockets that + * are bound to the wildcard address, which accepts requests from all network + * interfaces. + * + * @implNote + *

    You can use the {@code RMISocketFactory} class to create a server socket that + * is bound to a specific address, restricting the origin of requests. For example, + * the following code implements a socket factory that binds server sockets to the + * loopback address. This restricts RMI to processing requests only from the local host. + * + *

    {@code
    + *     class LoopbackSocketFactory extends RMISocketFactory {
    + *         public ServerSocket createServerSocket(int port) throws IOException {
    + *             return new ServerSocket(port, 5, InetAddress.getLoopbackAddress());
    + *         }
    + *
    + *         public Socket createSocket(String host, int port) throws IOException {
    + *             // just call the default client socket factory
    + *             return RMISocketFactory.getDefaultSocketFactory()
    + *                                    .createSocket(host, port);
    + *         }
    + *     }
    + *
    + *     // ...
    + *
    + *     RMISocketFactory.setSocketFactory(new LoopbackSocketFactory());
    + * }
    + * + * Set the {@code java.rmi.server.hostname} system property + * to a host name (typically {@code localhost}) that resolves to the loopback + * interface to ensure that the generated stubs use the right network interface. * * @author Ann Wollrath * @author Peter Jones diff --git a/jdk/src/share/classes/java/rmi/server/UnicastRemoteObject.java b/jdk/src/share/classes/java/rmi/server/UnicastRemoteObject.java index 7764627bceb..be86c275246 100644 --- a/jdk/src/share/classes/java/rmi/server/UnicastRemoteObject.java +++ b/jdk/src/share/classes/java/rmi/server/UnicastRemoteObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,6 +100,26 @@ import sun.rmi.server.UnicastServerRef2; * * * + *

    If an object is exported with the + * {@link #exportObject(Remote) exportObject(Remote)} + * or + * {@link #exportObject(Remote, int) exportObject(Remote, port)} + * methods, or if a subclass constructor invokes one of the + * {@link #UnicastRemoteObject()} + * or + * {@link #UnicastRemoteObject(int) UnicastRemoteObject(port)} + * constructors, the object is exported with a server socket created using the + * {@link RMISocketFactory} + * class. + * + * @implNote + *

    By default, server sockets created by the {@link RMISocketFactory} class + * listen on all network interfaces. See the + * {@link RMISocketFactory} class and the section + * RMI Socket Factories + * in the + * Java RMI Specification. + * * @author Ann Wollrath * @author Peter Jones * @since JDK1.1 From b65847a20663e72b88bb81c3e8da858b30858b9b Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Tue, 6 Aug 2013 14:04:49 +0400 Subject: [PATCH 019/118] 8011038: sourceObj validation during desereliazation of RelationNotification should be relaxed SourceObj could be set to null by setSource() relax a validation of deserialized object. Reviewed-by: sjiang, skoivu, dfuchs --- .../relation/RelationNotification.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/classes/javax/management/relation/RelationNotification.java b/jdk/src/share/classes/javax/management/relation/RelationNotification.java index a05aa719b1b..7edbc895ac2 100644 --- a/jdk/src/share/classes/javax/management/relation/RelationNotification.java +++ b/jdk/src/share/classes/javax/management/relation/RelationNotification.java @@ -260,7 +260,7 @@ public class RelationNotification extends Notification { super(notifType, sourceObj, sequence, timeStamp, message); - if (!isValidBasic(notifType,sourceObj,id,typeName) || !isValidCreate(notifType)) { + if (!isValidBasicStrict(notifType,sourceObj,id,typeName) || !isValidCreate(notifType)) { throw new IllegalArgumentException("Invalid parameter."); } @@ -310,7 +310,7 @@ public class RelationNotification extends Notification { super(notifType, sourceObj, sequence, timeStamp, message); - if (!isValidBasic(notifType,sourceObj,id,typeName) || !isValidUpdate(notifType,name,newValue,oldValue)) { + if (!isValidBasicStrict(notifType,sourceObj,id,typeName) || !isValidUpdate(notifType,name,newValue,oldValue)) { throw new IllegalArgumentException("Invalid parameter."); } @@ -457,14 +457,26 @@ public class RelationNotification extends Notification { // - no role old value (for role update) // - no role new value (for role update) + // Despite the fact, that validation in constructor of RelationNotification prohibit + // creation of the class instance with null sourceObj its possible to set it to null later + // by public setSource() method. + // So we should relax validation rules to preserve serialization behavior compatibility. + + private boolean isValidBasicStrict(String notifType, Object sourceObj, String id, String typeName){ + if (sourceObj == null) { + return false; + } + return isValidBasic(notifType,sourceObj,id,typeName); + } + private boolean isValidBasic(String notifType, Object sourceObj, String id, String typeName){ - if (notifType == null || sourceObj == null || - id == null || typeName == null) { + if (notifType == null || id == null || typeName == null) { return false; } - if (!(sourceObj instanceof RelationService) && - !(sourceObj instanceof ObjectName)) { + if (sourceObj != null && ( + !(sourceObj instanceof RelationService) && + !(sourceObj instanceof ObjectName))) { return false; } From 04449cd1a910973c5e5d8656fe4bc29a0d9fdf29 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Tue, 6 Aug 2013 15:35:20 +0100 Subject: [PATCH 020/118] 8022344: Additional debug info for test/java/net/NetworkInterface/IndexTest.java Reviewed-by: michaelm, alanb --- .../java/net/NetworkInterface/IndexTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/jdk/test/java/net/NetworkInterface/IndexTest.java b/jdk/test/java/net/NetworkInterface/IndexTest.java index f52c56ac788..4d5a0150be9 100644 --- a/jdk/test/java/net/NetworkInterface/IndexTest.java +++ b/jdk/test/java/net/NetworkInterface/IndexTest.java @@ -27,7 +27,10 @@ */ import java.net.*; +import java.util.Arrays; +import java.util.Collections; import java.util.Enumeration; +import static java.lang.System.out; public class IndexTest { public static void main(String[] args) throws Exception { @@ -39,12 +42,17 @@ public class IndexTest { if (index >= 0) { NetworkInterface nif2 = NetworkInterface.getByIndex(index); if (! nif.equals(nif2)) { + out.printf("%nExpected interfaces to be the same, but got:%n"); + displayInterfaceInformation(nif); + displayInterfaceInformation(nif2); throw new RuntimeException("both interfaces should be equal"); } } } try { nif = NetworkInterface.getByIndex(-1); + out.printf("%ngetByIndex(-1) should have thrown, but instead returned:%n"); + displayInterfaceInformation(nif); throw new RuntimeException("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { // OK @@ -52,7 +60,29 @@ public class IndexTest { // In all likelyhood, this interface should not exist. nif = NetworkInterface.getByIndex(Integer.MAX_VALUE - 1); if (nif != null) { + out.printf("%ngetByIndex(MAX_VALUE - 1), expected null, got:%n"); + displayInterfaceInformation(nif); throw new RuntimeException("getByIndex() should have returned null"); } } + + static void displayInterfaceInformation(NetworkInterface netint) throws SocketException { + out.printf("Display name: %s%n", netint.getDisplayName()); + out.printf("Name: %s%n", netint.getName()); + Enumeration inetAddresses = netint.getInetAddresses(); + + for (InetAddress inetAddress : Collections.list(inetAddresses)) + out.printf("InetAddress: %s%n", inetAddress); + + out.printf("Up? %s%n", netint.isUp()); + out.printf("Loopback? %s%n", netint.isLoopback()); + out.printf("PointToPoint? %s%n", netint.isPointToPoint()); + out.printf("Supports multicast? %s%n", netint.supportsMulticast()); + out.printf("Virtual? %s%n", netint.isVirtual()); + out.printf("Hardware address: %s%n", + Arrays.toString(netint.getHardwareAddress())); + out.printf("MTU: %s%n", netint.getMTU()); + out.printf("Index: %s%n", netint.getIndex()); + out.printf("%n"); + } } From 78255f5c55ead4e04878b066da3befb1a68582c9 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Tue, 6 Aug 2013 08:31:24 -0700 Subject: [PATCH 021/118] 8022120: JCK test api/javax_xml/crypto/dsig/TransformService/index_ParamMethods fails TransformService.init and marshalParams must throw NullPointerException when parent parameter is null Reviewed-by: xuelei --- .../internal/dom/ApacheCanonicalizer.java | 10 ++- .../dsig/internal/dom/ApacheTransform.java | 10 ++- .../dsig/TransformService/NullParent.java | 63 +++++++++++++++++++ 3 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 jdk/test/javax/xml/crypto/dsig/TransformService/NullParent.java diff --git a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java index 97554e4d200..ec6e9c6b722 100644 --- a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java +++ b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java @@ -75,7 +75,10 @@ public abstract class ApacheCanonicalizer extends TransformService { throw new ClassCastException ("context must be of type DOMCryptoContext"); } - if (parent == null || !(parent instanceof javax.xml.crypto.dom.DOMStructure)) { + if (parent == null) { + throw new NullPointerException(); + } + if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) { throw new ClassCastException("parent must be of type DOMStructure"); } transformElem = (Element) @@ -90,7 +93,10 @@ public abstract class ApacheCanonicalizer extends TransformService { throw new ClassCastException ("context must be of type DOMCryptoContext"); } - if (parent == null || !(parent instanceof javax.xml.crypto.dom.DOMStructure)) { + if (parent == null) { + throw new NullPointerException(); + } + if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) { throw new ClassCastException("parent must be of type DOMStructure"); } transformElem = (Element) diff --git a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java index 7df11e6204a..aac051804b0 100644 --- a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java +++ b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java @@ -76,7 +76,10 @@ public abstract class ApacheTransform extends TransformService { throw new ClassCastException ("context must be of type DOMCryptoContext"); } - if (parent == null || !(parent instanceof javax.xml.crypto.dom.DOMStructure)) { + if (parent == null) { + throw new NullPointerException(); + } + if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) { throw new ClassCastException("parent must be of type DOMStructure"); } transformElem = (Element) @@ -91,7 +94,10 @@ public abstract class ApacheTransform extends TransformService { throw new ClassCastException ("context must be of type DOMCryptoContext"); } - if (parent == null || !(parent instanceof javax.xml.crypto.dom.DOMStructure)) { + if (parent == null) { + throw new NullPointerException(); + } + if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) { throw new ClassCastException("parent must be of type DOMStructure"); } transformElem = (Element) diff --git a/jdk/test/javax/xml/crypto/dsig/TransformService/NullParent.java b/jdk/test/javax/xml/crypto/dsig/TransformService/NullParent.java new file mode 100644 index 00000000000..79c03174d20 --- /dev/null +++ b/jdk/test/javax/xml/crypto/dsig/TransformService/NullParent.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8022120 + * @summary check that the init and marshalParams methods throw + * NullPointerException when the parent parameter is null + */ + +import javax.xml.crypto.dsig.CanonicalizationMethod; +import javax.xml.crypto.dsig.Transform; +import javax.xml.crypto.dsig.TransformService; + +public class NullParent { + + public static void main(String[] args) throws Exception { + String[] transforms = new String[] + { Transform.BASE64, Transform.ENVELOPED, Transform.XPATH, + Transform.XPATH2, Transform.XSLT, + CanonicalizationMethod.EXCLUSIVE, + CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS, + CanonicalizationMethod.INCLUSIVE, + CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS }; + + for (String transform : transforms) { + System.out.println("Testing " + transform); + TransformService ts = TransformService.getInstance(transform, + "DOM"); + try { + ts.init(null, null); + throw new Exception("init must throw NullPointerException " + + "when the parent parameter is null"); + } catch (NullPointerException npe) { } + try { + ts.marshalParams(null, null); + throw new Exception("marshalParams must throw " + + "NullPointerException when the parent " + + "parameter is null"); + } catch (NullPointerException npe) { } + } + } +} From 0f4a06a92a7a2605e9fc55ad17aa54c927b82279 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Tue, 6 Aug 2013 18:54:02 +0200 Subject: [PATCH 022/118] 7184826: (reflect) Add support for Project Lambda concepts in core reflection Reviewed-by: darcy, jfranck --- .../DefaultStaticInvokeTest.java | 307 ++++++++++++++ .../DefaultStaticTestData.java | 401 ++++++++++++++++++ .../DefaultStaticTest/helper/Declared.java | 35 ++ .../reflect/DefaultStaticTest/helper/Mod.java | 37 ++ .../reflect/Method/DefaultMethodModeling.java | 31 +- .../lang/reflect/Method/IsDefaultTest.java | 66 +++ 6 files changed, 876 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticInvokeTest.java create mode 100644 jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticTestData.java create mode 100644 jdk/test/java/lang/reflect/DefaultStaticTest/helper/Declared.java create mode 100644 jdk/test/java/lang/reflect/DefaultStaticTest/helper/Mod.java diff --git a/jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticInvokeTest.java b/jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticInvokeTest.java new file mode 100644 index 00000000000..28d49be6896 --- /dev/null +++ b/jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticInvokeTest.java @@ -0,0 +1,307 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Test locating and invoking default/static method that defined + * in interfaces and/or in inheritance + * @bug 7184826 + * @build helper.Mod helper.Declared DefaultStaticTestData + * @run testng DefaultStaticInvokeTest + * @author Yong Lu + */ + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import org.testng.annotations.Test; + +import static helper.Mod.*; +import static helper.Declared.*; +import helper.Mod; + +public class DefaultStaticInvokeTest { + + @Test(dataProvider = "testCasesAll", + dataProviderClass = DefaultStaticTestData.class) + public void testGetMethods(String testTarget, Object param) + throws Exception { + // test the methods retrieved by getMethods() + testMethods(ALL_METHODS, testTarget, param); + } + + @Test(dataProvider = "testCasesAll", + dataProviderClass = DefaultStaticTestData.class) + public void testGetDeclaredMethods(String testTarget, Object param) + throws Exception { + // test the methods retrieved by getDeclaredMethods() + testMethods(DECLARED_ONLY, testTarget, param); + } + + @Test(dataProvider = "testCasesAll", + dataProviderClass = DefaultStaticTestData.class) + public void testMethodInvoke(String testTarget, Object param) + throws Exception { + Class typeUnderTest = Class.forName(testTarget); + MethodDesc[] expectedMethods = typeUnderTest.getAnnotationsByType(MethodDesc.class); + + // test the method retrieved by Class.getMethod(String, Object[]) + for (MethodDesc toTest : expectedMethods) { + String name = toTest.name(); + Method m = getTestMethod(typeUnderTest, name, param); + testThisMethod(toTest, m, typeUnderTest, param); + } + } + + @Test(dataProvider = "testCasesAll", + dataProviderClass = DefaultStaticTestData.class) + public void testMethodHandleInvoke(String testTarget, Object param) + throws Throwable { + Class typeUnderTest = Class.forName(testTarget); + MethodDesc[] expectedMethods = typeUnderTest.getAnnotationsByType(MethodDesc.class); + + for (MethodDesc toTest : expectedMethods) { + String mName = toTest.name(); + Mod mod = toTest.mod(); + if (mod != STATIC && typeUnderTest.isInterface()) { + return; + } + + String result = null; + String expectedReturn = toTest.retval(); + + MethodHandle methodHandle = getTestMH(typeUnderTest, mName, param); + if (mName.equals("staticMethod")) { + result = (param == null) + ? (String) methodHandle.invoke() + : (String) methodHandle.invoke(param); + } else { + result = (param == null) + ? (String) methodHandle.invoke(typeUnderTest.newInstance()) + : (String) methodHandle.invoke(typeUnderTest.newInstance(), param); + } + + assertEquals(result, expectedReturn); + } + + } + + @Test(dataProvider = "testClasses", + dataProviderClass = DefaultStaticTestData.class) + public void testIAE(String testTarget, Object param) + throws ClassNotFoundException { + + Class typeUnderTest = Class.forName(testTarget); + MethodDesc[] expectedMethods = typeUnderTest.getAnnotationsByType(MethodDesc.class); + + for (MethodDesc toTest : expectedMethods) { + String mName = toTest.name(); + Mod mod = toTest.mod(); + if (mod != STATIC && typeUnderTest.isInterface()) { + return; + } + Exception caught = null; + try { + getTestMH(typeUnderTest, mName, param, true); + } catch (Exception e) { + caught = e; + } + assertTrue(caught != null); + assertEquals(caught.getClass(), IllegalAccessException.class); + } + } + private static final String[] OBJECT_METHOD_NAMES = { + "equals", + "hashCode", + "getClass", + "notify", + "notifyAll", + "toString", + "wait", + "wait", + "wait",}; + private static final String LAMBDA_METHOD_NAMES = "lambda$"; + private static final HashSet OBJECT_NAMES = new HashSet<>(Arrays.asList(OBJECT_METHOD_NAMES)); + private static final boolean DECLARED_ONLY = true; + private static final boolean ALL_METHODS = false; + + private void testMethods(boolean declaredOnly, String testTarget, Object param) + throws Exception { + Class typeUnderTest = Class.forName(testTarget); + Method[] methods = declaredOnly + ? typeUnderTest.getDeclaredMethods() + : typeUnderTest.getMethods(); + + MethodDesc[] baseExpectedMethods = typeUnderTest.getAnnotationsByType(MethodDesc.class); + MethodDesc[] expectedMethods; + + // If only declared filter out non-declared from expected result + if (declaredOnly) { + int nonDeclared = 0; + for (MethodDesc desc : baseExpectedMethods) { + if (desc.declared() == NO) { + nonDeclared++; + } + } + expectedMethods = new MethodDesc[baseExpectedMethods.length - nonDeclared]; + int i = 0; + for (MethodDesc desc : baseExpectedMethods) { + if (desc.declared() == YES) { + expectedMethods[i++] = desc; + } + } + } else { + expectedMethods = baseExpectedMethods; + } + + HashMap myMethods = new HashMap<>(methods.length); + for (Method m : methods) { + String mName = m.getName(); + // don't add Object methods and method created from lambda expression + if ((!OBJECT_NAMES.contains(mName)) && (!mName.contains(LAMBDA_METHOD_NAMES))) { + myMethods.put(mName, m); + } + } + assertEquals(expectedMethods.length, myMethods.size()); + + for (MethodDesc toTest : expectedMethods) { + + String name = toTest.name(); + Method candidate = myMethods.get(name); + + assertNotNull(candidate); + myMethods.remove(name); + + testThisMethod(toTest, candidate, typeUnderTest, param); + + } + + // Should be no methods left since we remove all we expect to see + assertTrue(myMethods.isEmpty()); + } + + private void testThisMethod(MethodDesc toTest, Method method, + Class typeUnderTest, Object param) throws Exception { + // Test modifiers, and invoke + Mod mod = toTest.mod(); + String expectedReturn = toTest.retval(); + switch (mod) { + case STATIC: + //assert candidate is static + assertTrue(Modifier.isStatic(method.getModifiers())); + assertFalse(method.isDefault()); + + // Test invoke it + assertEquals(tryInvoke(method, null, param), expectedReturn); + break; + case DEFAULT: + // if typeUnderTest is a class then instantiate and invoke + if (!typeUnderTest.isInterface()) { + assertEquals(tryInvoke( + method, + typeUnderTest, + param), + expectedReturn); + } + + //assert candidate is default + assertFalse(Modifier.isStatic(method.getModifiers())); + assertTrue(method.isDefault()); + break; + case REGULAR: + // if typeUnderTest must be a class + assertEquals(tryInvoke( + method, + typeUnderTest, + param), + expectedReturn); + + //assert candidate is neither default nor static + assertFalse(Modifier.isStatic(method.getModifiers())); + assertFalse(method.isDefault()); + break; + case ABSTRACT: + //assert candidate is neither default nor static + assertFalse(Modifier.isStatic(method.getModifiers())); + assertFalse(method.isDefault()); + break; + default: + assertFalse(true); //this should never happen + break; + } + + } + + private Object tryInvoke(Method m, Class receiverType, Object param) + throws Exception { + Object receiver = receiverType == null ? null : receiverType.newInstance(); + Object result = null; + if (param == null) { + result = m.invoke(receiver); + } else { + result = m.invoke(receiver, param); + } + return result; + } + + private Method getTestMethod(Class clazz, String methodName, Object param) + throws NoSuchMethodException { + Class[] paramsType = (param != null) + ? new Class[]{Object.class} + : new Class[]{}; + return clazz.getMethod(methodName, paramsType); + } + + private MethodHandle getTestMH(Class clazz, String methodName, Object param) + throws Exception { + return getTestMH(clazz, methodName, param, false); + } + + private MethodHandle getTestMH(Class clazz, String methodName, + Object param, boolean isNegativeTest) + throws Exception { + MethodType mType = (param != null) + ? MethodType.genericMethodType(1) + : MethodType.methodType(String.class); + MethodHandles.Lookup lookup = MethodHandles.lookup(); + if (!isNegativeTest) { + return methodName.equals("staticMethod") + ? lookup.findStatic(clazz, methodName, mType) + : lookup.findVirtual(clazz, methodName, mType); + } else { + return methodName.equals("staticMethod") + ? lookup.findVirtual(clazz, methodName, mType) + : lookup.findStatic(clazz, methodName, mType); + } + } +} diff --git a/jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticTestData.java b/jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticTestData.java new file mode 100644 index 00000000000..ef9dec71616 --- /dev/null +++ b/jdk/test/java/lang/reflect/DefaultStaticTest/DefaultStaticTestData.java @@ -0,0 +1,401 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * Test Data used for testing default/static method + * + * @author Yong Lu + */ + +import java.util.Arrays; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.collections.Lists; + +import static helper.Mod.*; +import static helper.Declared.*; +import helper.Mod; +import helper.Declared; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = YES) +interface TestIF1 { + + default String defaultMethod() { + return "TestIF1.defaultMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO) +class TestClass1 implements TestIF1 { +} + +@MethodDesc(name = "staticMethod", retval = "TestIF2.staticMethod", mod = STATIC, declared = YES) +interface TestIF2 { + + static String staticMethod() { + return "TestIF2.staticMethod"; + } +} + +@MethodDesc(name = "method", retval = "TestIF2.staticMethod", mod = REGULAR, declared = YES) +class TestClass2 implements TestIF2 { + + public String method() { + return TestIF2.staticMethod(); + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF3.defaultMethod", mod = DEFAULT, declared = YES) +@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES) +interface TestIF3 { + + String method(); + + default String defaultMethod() { + return "TestIF3.defaultMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF3.defaultMethod", mod = DEFAULT, declared = NO) +@MethodDesc(name = "method", retval = "TestClass3.method", mod = REGULAR, declared = YES) +class TestClass3 implements TestIF3 { + + public String method() { + return "TestClass3.method"; + } +} + +@MethodDesc(name = "staticMethod", retval = "TestIF4.staticMethod", mod = STATIC, declared = YES) +@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES) +interface TestIF4 { + + String method(); + + static String staticMethod() { + return "TestIF4.staticMethod"; + } +} + +@MethodDesc(name = "method", retval = "TestClass4.method", mod = REGULAR, declared = YES) +class TestClass4 implements TestIF4 { + + public String method() { + return "TestClass4.method"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF5.defaultMethod", mod = DEFAULT, declared = YES) +@MethodDesc(name = "staticMethod", retval = "TestIF5.staticMethod", mod = STATIC, declared = YES) +interface TestIF5 { + + default String defaultMethod() { + return "TestIF5.defaultMethod"; + } + + static String staticMethod() { + return "TestIF5.staticMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF5.defaultMethod", mod = DEFAULT, declared = NO) +class TestClass5 implements TestIF5 { +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF6.defaultMethod", mod = DEFAULT, declared = YES) +@MethodDesc(name = "staticMethod", retval = "TestIF6.staticMethod", mod = STATIC, declared = YES) +@MethodDesc(name = "method", retval = "", mod = ABSTRACT, declared = YES) +interface TestIF6 { + + String method(); + + default String defaultMethod() { + return "TestIF6.defaultMethod"; + } + + static String staticMethod() { + return "TestIF6.staticMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF6.defaultMethod", mod = DEFAULT, declared = NO) +@MethodDesc(name = "method", retval = "TestClass6.method", mod = REGULAR, declared = YES) +class TestClass6 implements TestIF6 { + + public String method() { + return "TestClass6.method"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF7.TestClass7", mod = DEFAULT, declared = YES) +interface TestIF7 { + + default T defaultMethod(T t) { + return t; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF7.TestClass7", mod = DEFAULT, declared = NO) +class TestClass7 implements TestIF7 { +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF8.TestClass8", mod = DEFAULT, declared = YES) +interface TestIF8 { + + default E defaultMethod(E e) { + return e; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF8.TestClass8", mod = DEFAULT, declared = NO) +class TestClass8 implements TestIF8 { +}; + +@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = YES) +interface TestIF9 extends TestIF1 { + + default String defaultMethod() { + return "TestIF9.defaultMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = NO) +class TestClass9 implements TestIF9 { +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF9.defaultMethod", mod = DEFAULT, declared = NO) +@MethodDesc(name = "method", retval = "TestIF9.defaultMethod", mod = REGULAR, declared = YES) +class TestClass91 implements TestIF9, TestIF1 { + + public String method() { + return defaultMethod(); + } +} + +@MethodDesc(name = "staticMethod", retval = "TestIF10.staticMethod", mod = STATIC, declared = YES) +interface TestIF10 extends TestIF2 { + + static String staticMethod() { + + return "TestIF10.staticMethod"; + } +} + +@MethodDesc(name = "staticMethod", retval = "TestIF11.staticMethod", mod = STATIC, declared = YES) +@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO) +interface TestIF11 extends TestIF1 { + + static String staticMethod() { + return "TestIF11.staticMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO) +class TestClass11 implements TestIF11 { +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = YES) +@MethodDesc(name = "staticMethod", retval = "TestIF2.staticMethod", mod = STATIC, declared = NO) +interface TestIF12 extends TestIF2 { + + default String defaultMethod() { + return "TestIF12.defaultMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF12.defaultMethod", mod = DEFAULT, declared = NO) +class TestClass12 implements TestIF12 { +} + +//Diamond Case +@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO) +interface TestIF1A extends TestIF1 { +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO) +interface TestIF1B extends TestIF1 { +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF1.defaultMethod", mod = DEFAULT, declared = NO) +class TestClass13 implements TestIF1A, TestIF1B { +} + +//Diamond Override Case +@MethodDesc(name = "defaultMethod", retval = "TestIF1C.defaultMethod", mod = DEFAULT, declared = YES) +interface TestIF1C extends TestIF1 { + + default String defaultMethod() { + return "TestIF1C.defaultMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF1D.defaultMethod", mod = DEFAULT, declared = YES) +interface TestIF1D extends TestIF1 { + + default String defaultMethod() { + return "TestIF1D.defaultMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestClass14.defaultMethod", mod = REGULAR, declared = YES) +class TestClass14 implements TestIF1C, TestIF1D { + + public String defaultMethod() { + return "TestClass14.defaultMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "", mod = ABSTRACT, declared = YES) +interface TestIF15 extends TestIF1 { + + String defaultMethod(); +} + +@MethodDesc(name = "defaultMethod", retval = "TestClass15.defaultMethod", mod = REGULAR, declared = YES) +class TestClass15 implements TestIF15 { + + public String defaultMethod() { + return "TestClass15.defaultMethod"; + } +} + +interface FuncInterface { + + String test(T t); +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF16.defaultMethod", mod = DEFAULT, declared = YES) +interface TestIF16 { + + default String defaultMethod() { + FuncInterface fi = o -> o.toString(); + Object o = "TestIF16.defaultMethod"; + return fi.test(o); + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF16.defaultMethod", mod = DEFAULT, declared = NO) +class TestClass16 implements TestIF16 { +}; + +@MethodDesc(name = "defaultMethod", retval = "TestIF17.defaultMethod", mod = DEFAULT, declared = YES) +@MethodDesc(name = "staticMethod", retval = "TestIF17.staticMethod", mod = STATIC, declared = YES) +interface TestIF17 { + + default String defaultMethod() { + return staticMethod().replace("staticMethod", "defaultMethod"); + } + + public static String staticMethod() { + return "TestIF17.staticMethod"; + } +} + +@MethodDesc(name = "defaultMethod", retval = "TestIF17.defaultMethod", mod = DEFAULT, declared = NO) +class TestClass17 implements TestIF17 { +} + +@Retention(RetentionPolicy.RUNTIME) +@Repeatable(MethodDescs.class) +@interface MethodDesc { + String name(); + String retval(); + Mod mod(); + Declared declared(); +} + +@Retention(RetentionPolicy.RUNTIME) +@interface MethodDescs { + MethodDesc[] value(); +} + +public class DefaultStaticTestData { + + /** + * Test data for DefaultStaticInvokeTest The format of inner array is: First + * data is the name of the class under test Second data used in test as the + * arguments used for the method call. + */ + @DataProvider + static Object[][] testClasses() { + return new Object[][]{ + {"TestClass1", null}, + //{"TestClass2", null}, @ignore due to JDK-8009411 + {"TestClass3", null}, + //{"TestClass4", null}, @ignore due to JDK-8009411 + //{"TestClass5", null}, @ignore due to JDK-8009411 + //{"TestClass6", null}, @ignore due to JDK-8009411 + {"TestClass7", "TestIF7.TestClass7"}, + {"TestClass8", "TestIF8.TestClass8"}, + {"TestClass9", null}, + {"TestClass91", null}, + //{"TestClass11", null}, @ignore due to JDK-8009411 + //{"TestClass12", null}, @ignore due to JDK-8009411 + {"TestClass13", null}, + {"TestClass14", null}, + {"TestClass15", null}, + {"TestClass16", null} + //{"TestClass17", null} @ignore due to JDK-8009411 + }; + } + + /** + * Test data for DefaultStaticInvokeTest The format of inner array is: First + * data is the name of the interface under test Second data used in test as + * the arguments used for the method call. + */ + @DataProvider + static Object[][] testInterfaces() { + return new Object[][]{ + {"TestIF1", null}, + {"TestIF2", null}, + {"TestIF3", null}, + {"TestIF4", null}, + {"TestIF5", null}, + {"TestIF6", null}, + {"TestIF7", "TestIF7.TestClass7"}, + {"TestIF8", "TestIF8.TestClass8"}, + {"TestIF9", null}, + {"TestIF10", null}, + {"TestIF11", null}, + {"TestIF12", null}, + {"TestIF1A", null}, + {"TestIF1B", null}, + {"TestIF1C", null}, + {"TestIF1D", null}, + {"TestIF15", null}, + {"TestIF16", null}, + {"TestIF17", null},}; + } + + @DataProvider + static Object[][] testCasesAll() { + List result = Lists.newArrayList(); + result.addAll(Arrays.asList(testClasses())); + result.addAll(Arrays.asList(testInterfaces())); + return result.toArray(new Object[result.size()][]); + } +} diff --git a/jdk/test/java/lang/reflect/DefaultStaticTest/helper/Declared.java b/jdk/test/java/lang/reflect/DefaultStaticTest/helper/Declared.java new file mode 100644 index 00000000000..1e10b85da9b --- /dev/null +++ b/jdk/test/java/lang/reflect/DefaultStaticTest/helper/Declared.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * Helper class used for testing default/static method + * + * @author Yong Lu + */ + +package helper; + +public enum Declared { + YES, + NO +} diff --git a/jdk/test/java/lang/reflect/DefaultStaticTest/helper/Mod.java b/jdk/test/java/lang/reflect/DefaultStaticTest/helper/Mod.java new file mode 100644 index 00000000000..ed1451cd9ba --- /dev/null +++ b/jdk/test/java/lang/reflect/DefaultStaticTest/helper/Mod.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * Helper class used for testing default/static method + * + * @author Yong Lu + */ + +package helper; + +public enum Mod { + DEFAULT, + STATIC, + REGULAR, + ABSTRACT +} diff --git a/jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java b/jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java index 99ecd24b221..83a3d0bd546 100644 --- a/jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java +++ b/jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java @@ -43,7 +43,7 @@ public class DefaultMethodModeling { SuperIwithDefault.class, SuperIwithDefaultChild.class, Base.class, Combo1.class, Combo2.class, SonSuperIwithDefault.class, DaughterSuperIwithDefault.class, GrandchildSuperIwithDefault.class, D.class, - B.class, C.class + B.class, C.class, B1.class, D1.class }; for(Class clazz : classes) { @@ -202,6 +202,17 @@ class D implements GrandchildSuperIwithDefault { public void quux(){} } +class D1 implements SonSuperIwithDefault, DaughterSuperIwithDefault { + @ExpectedModel(declaringClass=D1.class) + public void foo(){} + + @ExpectedModel(declaringClass=D1.class) + public void baz(){} + + @ExpectedModel(declaringClass=D1.class) + public void quux(){} +} + // -=-=-=- // What does re-abstraction look like? @@ -222,3 +233,21 @@ class C extends B implements SuperIwithDefault { @ExpectedModel(declaringClass=C.class) public void bar(){} } + +abstract class A1 implements SonSuperIwithDefault { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=A1.class) + public abstract void baz(); + + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=A1.class) + public abstract void foo(); +} + +class B1 extends A1 { + @ExpectedModel(declaringClass=B1.class) + @Override + public void foo(){;} + + @ExpectedModel(declaringClass=B1.class) + @Override + public void baz(){} +} diff --git a/jdk/test/java/lang/reflect/Method/IsDefaultTest.java b/jdk/test/java/lang/reflect/Method/IsDefaultTest.java index 1dd67aeb874..97967ee4fe4 100644 --- a/jdk/test/java/lang/reflect/Method/IsDefaultTest.java +++ b/jdk/test/java/lang/reflect/Method/IsDefaultTest.java @@ -42,6 +42,12 @@ public class IsDefaultTest { classList.add(TestType2.class); classList.add(TestType3.class); classList.add(TestType4.class); + classList.add(TestType2.nestedTestType2.class); + classList.add(TestType5.class); + classList.add(TestType5.nestedTestType5.class); + classList.add(TestType6.class); + classList.add(TestType6.nestedTestType6.class); + classList.add(TestType7.class); for(Class clazz: classList) { for(Method method: clazz.getDeclaredMethods()) { @@ -78,11 +84,22 @@ interface TestType1 { @ExpectedIsDefault(true) default void bar() {}; // Default method + + @ExpectedIsDefault(true) + default void bar(int i) {}; // Default method + + @ExpectedIsDefault(true) + default void bar(String i) {}; // Default method } class TestType2 { @ExpectedIsDefault(false) void bar() {}; + + interface nestedTestType2 { + @ExpectedIsDefault(true) + default void nestedBar() {}; + } } class TestType3 implements TestType1 { @@ -92,6 +109,10 @@ class TestType3 implements TestType1 { @ExpectedIsDefault(false) @Override public void bar() {}; + + @ExpectedIsDefault(false) + @Override + public void bar(int i) {}; } @interface TestType4 { @@ -102,6 +123,51 @@ class TestType3 implements TestType1 { String anotherValue() default ""; } +interface TestType5 { + @ExpectedIsDefault(false) + abstract void aFoo(); + + @ExpectedIsDefault(false) + static void sFoo() {}; + + @ExpectedIsDefault(true) + public default void pBar() {}; + + @ExpectedIsDefault(true) + public default String sBar() {return "";}; + + interface nestedTestType5{ + @ExpectedIsDefault(false) + void nestedFoo(); + + @ExpectedIsDefault(true) + default void nestedBar() {}; + } +} + +class TestType6{ + interface nestedTestType6 { + @ExpectedIsDefault(true) + default void nestedBar() {}; + + @ExpectedIsDefault(false) + void nestedFoo(); + } + + @ExpectedIsDefault(false) + void foo(nestedTestType6 n) {} +} + +class TestType7 implements TestType6.nestedTestType6 { + + @ExpectedIsDefault(false) + public void nestedFoo() {} + + @ExpectedIsDefault(false) + @Override + public void nestedBar() {}; +} + @Retention(RetentionPolicy.RUNTIME) @interface ExpectedIsDefault { boolean value(); From ae54a3c9653c397c0e3a5a9ddbdd9cd9769c67d0 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 6 Aug 2013 13:25:04 -0700 Subject: [PATCH 023/118] 8022174: Fix doclint warnings in javax.sound 8022404: Fix doclint issues in java.applet Reviewed-by: prr --- jdk/src/share/classes/java/applet/AppletContext.java | 6 +++--- .../share/classes/javax/sound/midi/MetaMessage.java | 2 +- .../share/classes/javax/sound/midi/MidiDevice.java | 6 +++--- .../classes/javax/sound/midi/MidiDeviceReceiver.java | 6 ++++-- .../javax/sound/midi/MidiDeviceTransmitter.java | 6 ++++-- .../classes/javax/sound/midi/MidiFileFormat.java | 3 ++- .../share/classes/javax/sound/midi/MidiMessage.java | 8 ++++++-- .../share/classes/javax/sound/midi/MidiSystem.java | 5 ++++- .../share/classes/javax/sound/midi/ShortMessage.java | 11 ++++++----- .../share/classes/javax/sound/midi/Synthesizer.java | 10 +++++----- .../share/classes/javax/sound/midi/SysexMessage.java | 3 ++- jdk/src/share/classes/javax/sound/midi/Track.java | 5 +++-- .../classes/javax/sound/sampled/AudioFileFormat.java | 3 ++- .../classes/javax/sound/sampled/AudioFormat.java | 3 ++- .../classes/javax/sound/sampled/AudioSystem.java | 3 ++- .../classes/javax/sound/sampled/BooleanControl.java | 3 ++- jdk/src/share/classes/javax/sound/sampled/Mixer.java | 4 +++- .../sound/sampled/spi/FormatConversionProvider.java | 5 ++++- 18 files changed, 58 insertions(+), 34 deletions(-) diff --git a/jdk/src/share/classes/java/applet/AppletContext.java b/jdk/src/share/classes/java/applet/AppletContext.java index 87623ee334f..f28308cfb11 100644 --- a/jdk/src/share/classes/java/applet/AppletContext.java +++ b/jdk/src/share/classes/java/applet/AppletContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ public interface AppletContext { /** * Returns an Image object that can then be painted on - * the screen. The url argument that is + * the screen. The url argument that is * passed as an argument must specify an absolute URL. *

    * This method always returns immediately, whether or not the image @@ -157,7 +157,7 @@ public interface AppletContext { * @param stream stream to be associated with the specified key. If this * parameter is null, the specified key is removed * in this applet context. - * @throws IOException if the stream size exceeds a certain + * @throws IOException if the stream size exceeds a certain * size limit. Size limit is decided by the implementor of this * interface. * @since 1.4 diff --git a/jdk/src/share/classes/javax/sound/midi/MetaMessage.java b/jdk/src/share/classes/javax/sound/midi/MetaMessage.java index b7c235565f3..6378435acc7 100644 --- a/jdk/src/share/classes/javax/sound/midi/MetaMessage.java +++ b/jdk/src/share/classes/javax/sound/midi/MetaMessage.java @@ -149,7 +149,7 @@ public class MetaMessage extends MidiMessage { * @param data the data bytes in the MIDI message * @param length the number of bytes in the data * byte array - * @throws InvalidMidiDataException if the + * @throws InvalidMidiDataException if the * parameter values do not specify a valid MIDI meta message */ public void setMessage(int type, byte[] data, int length) throws InvalidMidiDataException { diff --git a/jdk/src/share/classes/javax/sound/midi/MidiDevice.java b/jdk/src/share/classes/javax/sound/midi/MidiDevice.java index 75d6638f681..be950e8aa48 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiDevice.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,13 +86,13 @@ import java.util.List; * To detect if a MidiDevice represents a hardware MIDI port, the * following programming technique can be used: * - *

    + * 
    {@code
      * MidiDevice device = ...;
      * if ( ! (device instanceof Sequencer) && ! (device instanceof Synthesizer)) {
      *   // we're now sure that device represents a MIDI port
      *   // ...
      * }
    - * 
    + * }
    * *

    * A MidiDevice includes a {@link MidiDevice.Info} object diff --git a/jdk/src/share/classes/javax/sound/midi/MidiDeviceReceiver.java b/jdk/src/share/classes/javax/sound/midi/MidiDeviceReceiver.java index 9ea1df7c38e..550c7a4ccb8 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiDeviceReceiver.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiDeviceReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,9 @@ package javax.sound.midi; * @since 1.7 */ public interface MidiDeviceReceiver extends Receiver { - /** Obtains a MidiDevice object which is an owner of this Receiver. + /** + * Obtains a MidiDevice object which is an owner of this Receiver. + * @return a MidiDevice object which is an owner of this Receiver */ public MidiDevice getMidiDevice(); } diff --git a/jdk/src/share/classes/javax/sound/midi/MidiDeviceTransmitter.java b/jdk/src/share/classes/javax/sound/midi/MidiDeviceTransmitter.java index b6a827188e2..730628c5e8d 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiDeviceTransmitter.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiDeviceTransmitter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,9 @@ package javax.sound.midi; */ public interface MidiDeviceTransmitter extends Transmitter { - /** Obtains a MidiDevice object which is an owner of this Transmitter. + /** + * Obtains a MidiDevice object which is an owner of this Transmitter. + * @return a MidiDevice object which is an owner of this Transmitter */ public MidiDevice getMidiDevice(); } diff --git a/jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java b/jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java index 4c399dbbe72..1d4669a2458 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,6 +50,7 @@ import java.util.Map; * be used in implementations: * * + * * * diff --git a/jdk/src/share/classes/javax/sound/midi/MidiMessage.java b/jdk/src/share/classes/javax/sound/midi/MidiMessage.java index 244757f27d7..7cc840bd775 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiMessage.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ package javax.sound.midi; * processing MIDI data that originated outside Java Sound and now * is encoded as signed bytes, the bytes can * can be converted to integers using this conversion: - *
    int i = (int)(byte & 0xFF)
    + *
    {@code int i = (int)(byte & 0xFF)}
    *

    * If you simply need to pass a known MIDI byte value as a method parameter, * it can be expressed directly as an integer, using (for example) decimal or @@ -118,6 +118,10 @@ public abstract class MidiMessage implements Cloneable { * method is called by concrete subclasses, which should * ensure that the data array specifies a complete, valid MIDI * message. + * + * @param data the data bytes in the MIDI message + * @param length the number of bytes in the data byte array + * @throws InvalidMidiDataException if the parameter values do not specify a valid MIDI meta message */ protected void setMessage(byte[] data, int length) throws InvalidMidiDataException { if (length < 0 || (length > 0 && length > data.length)) { diff --git a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java index 9d6763a6406..4e390f11998 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,6 +80,7 @@ import com.sun.media.sound.MidiDeviceTransmitterEnvelope; * consider them: * *

    MIDI File Format Properties
    Property keyValue type
    + * * * * @@ -425,6 +426,8 @@ public class MidiSystem { * it is used to identify the default sequencer. * For details, refer to the {@link MidiSystem class description}. * + * @param connected whether or not the returned {@code Sequencer} + * is connected to the default {@code Synthesizer} * @return the default sequencer * @throws MidiUnavailableException if the sequencer is not * available due to resource restrictions, diff --git a/jdk/src/share/classes/javax/sound/midi/ShortMessage.java b/jdk/src/share/classes/javax/sound/midi/ShortMessage.java index f2ccdd23f94..1445201f3fe 100644 --- a/jdk/src/share/classes/javax/sound/midi/ShortMessage.java +++ b/jdk/src/share/classes/javax/sound/midi/ShortMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -283,7 +283,7 @@ public class ShortMessage extends MidiMessage { /** * Sets the parameters for a MIDI message that takes no data bytes. * @param status the MIDI status byte - * @throws InvalidMidiDataException if status does not + * @throws InvalidMidiDataException if status does not * specify a valid MIDI status byte for a message that requires no data bytes. * @see #setMessage(int, int, int) * @see #setMessage(int, int, int, int) @@ -307,7 +307,7 @@ public class ShortMessage extends MidiMessage { * @param status the MIDI status byte * @param data1 the first data byte * @param data2 the second data byte - * @throws InvalidMidiDataException if the + * @throws InvalidMidiDataException if the * the status byte, or all data bytes belonging to the message, do * not specify a valid MIDI message. * @see #setMessage(int, int, int, int) @@ -357,7 +357,7 @@ public class ShortMessage extends MidiMessage { * @param channel the channel associated with the message * @param data1 the first data byte * @param data2 the second data byte - * @throws InvalidMidiDataException if the + * @throws InvalidMidiDataException if the * status byte or all data bytes belonging to the message, do * not specify a valid MIDI message * @@ -397,6 +397,7 @@ public class ShortMessage extends MidiMessage { * Obtains the MIDI command associated with this event. This method * assumes that the event is a MIDI channel message; if not, the return * value will not be meaningful. + * @return the MIDI command associated with this event * @see #setMessage(int, int, int, int) */ public int getCommand() { @@ -450,7 +451,7 @@ public class ShortMessage extends MidiMessage { * status byte value. * @param status status byte value, which must represent a short MIDI message * @return data length in bytes (0, 1, or 2) - * @throws InvalidMidiDataException if the + * @throws InvalidMidiDataException if the * status argument does not represent the status byte for any * short message */ diff --git a/jdk/src/share/classes/javax/sound/midi/Synthesizer.java b/jdk/src/share/classes/javax/sound/midi/Synthesizer.java index f9701c62c43..6740479b389 100644 --- a/jdk/src/share/classes/javax/sound/midi/Synthesizer.java +++ b/jdk/src/share/classes/javax/sound/midi/Synthesizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -170,7 +170,7 @@ public interface Synthesizer extends MidiDevice { * already had been), false if the instrument could not be * loaded (for example, if the synthesizer has insufficient * memory to load it) - * @throws IllegalArgumentException if this + * @throws IllegalArgumentException if this * Synthesizer doesn't support the specified instrument's * soundbank * @see #unloadInstrument @@ -186,7 +186,7 @@ public interface Synthesizer extends MidiDevice { /** * Unloads a particular instrument. * @param instrument instrument to unload - * @throws IllegalArgumentException if this + * @throws IllegalArgumentException if this * Synthesizer doesn't support the specified instrument's * soundbank * @see #loadInstrument @@ -214,10 +214,10 @@ public interface Synthesizer extends MidiDevice { * of the old instrument, it should be loaded into the synthesizer * @return true if the instrument succeessfully remapped, * false if feature is not implemented by synthesizer - * @throws IllegalArgumentException if instrument + * @throws IllegalArgumentException if instrument * from or instrument to aren't supported by * synthesizer or if instrument to is not loaded - * @throws NullPointerException if from or + * @throws NullPointerException if from or * to parameters have null value * @see #loadInstrument * @see #loadInstruments diff --git a/jdk/src/share/classes/javax/sound/midi/SysexMessage.java b/jdk/src/share/classes/javax/sound/midi/SysexMessage.java index c86519bff34..ae4e418e8e6 100644 --- a/jdk/src/share/classes/javax/sound/midi/SysexMessage.java +++ b/jdk/src/share/classes/javax/sound/midi/SysexMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -204,6 +204,7 @@ public class SysexMessage extends MidiMessage { * @param data the system exclusive message data * @param length the length of the valid message data in * the array + * @throws InvalidMidiDataException if the status byte is invalid for a sysex message */ public void setMessage(int status, byte[] data, int length) throws InvalidMidiDataException { if ( (status != 0xF0) && (status != 0xF7) ) { diff --git a/jdk/src/share/classes/javax/sound/midi/Track.java b/jdk/src/share/classes/javax/sound/midi/Track.java index ad1ff52d202..4e54a8aa3dd 100644 --- a/jdk/src/share/classes/javax/sound/midi/Track.java +++ b/jdk/src/share/classes/javax/sound/midi/Track.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -211,10 +211,11 @@ public class Track { /** * Obtains the event at the specified index. * @param index the location of the desired event in the event vector - * @throws ArrayIndexOutOfBoundsException if the + * @throws ArrayIndexOutOfBoundsException if the * specified index is negative or not less than the current size of * this track. * @see #size + * @return the event at the specified index */ public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException { try { diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioFileFormat.java b/jdk/src/share/classes/javax/sound/sampled/AudioFileFormat.java index 30fe82be365..d1216e207a7 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioFileFormat.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,6 +57,7 @@ import java.util.Map; * be used in implementations: * *
    MIDI System Property Keys
    Property KeyInterface
    + * * * * diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioFormat.java b/jdk/src/share/classes/javax/sound/sampled/AudioFormat.java index 7457f8220eb..2e679784ea3 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioFormat.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,6 +85,7 @@ import java.util.Map; * service providers should use, if applicable: * *
    Audio File Format Property Keys
    Property keyValue type
    + * * * * diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java index cf06ca25741..6c8bfaf9f5e 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,6 +75,7 @@ import com.sun.media.sound.JDK13Services; * consider them: * *
    Audio Format Property Keys
    Property keyValue type
    + * * * * diff --git a/jdk/src/share/classes/javax/sound/sampled/BooleanControl.java b/jdk/src/share/classes/javax/sound/sampled/BooleanControl.java index 047b2f00803..e48e06c339c 100644 --- a/jdk/src/share/classes/javax/sound/sampled/BooleanControl.java +++ b/jdk/src/share/classes/javax/sound/sampled/BooleanControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,6 +125,7 @@ public abstract class BooleanControl extends Control { /** * Obtains the label for the specified state. + * @param state the state whose label will be returned * @return the label for the specified state, such as "true" or "on" * for true, or "false" or "off" for false. */ diff --git a/jdk/src/share/classes/javax/sound/sampled/Mixer.java b/jdk/src/share/classes/javax/sound/sampled/Mixer.java index c4d0ccbef03..755ab913342 100644 --- a/jdk/src/share/classes/javax/sound/sampled/Mixer.java +++ b/jdk/src/share/classes/javax/sound/sampled/Mixer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,6 +133,8 @@ public interface Mixer extends Line { * DataLine. * * @param info describes the desired line + * @return a line that is available for use and that matches the description + * in the specified {@code Line.Info} object * @throws LineUnavailableException if a matching line * is not available due to resource restrictions * @throws IllegalArgumentException if this mixer does diff --git a/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java b/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java index 194582f17dd..a27184a0b87 100644 --- a/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java +++ b/jdk/src/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,6 +116,7 @@ public abstract class FormatConversionProvider { * given a particular source format. * If no target format encodings are supported for this source format, * an array of length 0 is returned. + * @param sourceFormat format of the incoming data * @return array of supported target format encodings. */ public abstract AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat); @@ -146,6 +147,8 @@ public abstract class FormatConversionProvider { * supported by the format converter * If no target formats with the specified encoding are supported * for this source format, an array of length 0 is returned. + * @param targetEncoding desired encoding of the stream after processing + * @param sourceFormat format of the incoming data * @return array of supported target formats. */ public abstract AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat); From cd162a777df6b84a2682ad40e27ff6c5fed7bc76 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Tue, 6 Aug 2013 12:56:18 -0700 Subject: [PATCH 024/118] 8022412: Fixed warnings in java.util root, except for HashMap Reviewed-by: mduigou, darcy --- .../classes/java/util/ArrayPrefixHelpers.java | 5 +- .../share/classes/java/util/Collections.java | 53 +++++++++++-------- .../share/classes/java/util/Comparator.java | 5 +- .../share/classes/java/util/Comparators.java | 4 +- .../share/classes/java/util/Hashtable.java | 2 + .../classes/java/util/IdentityHashMap.java | 2 + jdk/src/share/classes/java/util/Vector.java | 7 +-- .../share/classes/java/util/WeakHashMap.java | 2 + 8 files changed, 47 insertions(+), 33 deletions(-) diff --git a/jdk/src/share/classes/java/util/ArrayPrefixHelpers.java b/jdk/src/share/classes/java/util/ArrayPrefixHelpers.java index ef59ec7d478..afa872c5855 100644 --- a/jdk/src/share/classes/java/util/ArrayPrefixHelpers.java +++ b/jdk/src/share/classes/java/util/ArrayPrefixHelpers.java @@ -128,6 +128,7 @@ class ArrayPrefixHelpers { this.lo = lo; this.hi = hi; } + @SuppressWarnings("unchecked") public final void compute() { final BinaryOperator fn; final T[] a; @@ -692,6 +693,4 @@ class ArrayPrefixHelpers { } } } - - -} \ No newline at end of file +} diff --git a/jdk/src/share/classes/java/util/Collections.java b/jdk/src/share/classes/java/util/Collections.java index 43ce42eeea6..97555f567fa 100644 --- a/jdk/src/share/classes/java/util/Collections.java +++ b/jdk/src/share/classes/java/util/Collections.java @@ -1143,6 +1143,7 @@ public class Collections { public boolean removeIf(Predicate filter) { throw new UnsupportedOperationException(); } + @SuppressWarnings("unchecked") @Override public Spliterator spliterator() { return (Spliterator)c.spliterator(); @@ -1900,7 +1901,7 @@ public class Collections { private static final long serialVersionUID = -2239321462712562324L; - EmptyNavigableMap() { super(new TreeMap()); } + EmptyNavigableMap() { super(new TreeMap()); } @Override public NavigableSet navigableKeySet() @@ -1928,46 +1929,52 @@ public class Collections { public K ceilingKey(K key) { return nm.ceilingKey(key); } public K higherKey(K key) { return nm.higherKey(key); } + @SuppressWarnings("unchecked") public Entry lowerEntry(K key) { Entry lower = (Entry) nm.lowerEntry(key); return (null != lower) - ? new UnmodifiableEntrySet.UnmodifiableEntry(lower) + ? new UnmodifiableEntrySet.UnmodifiableEntry<>(lower) : null; } + @SuppressWarnings("unchecked") public Entry floorEntry(K key) { Entry floor = (Entry) nm.floorEntry(key); return (null != floor) - ? new UnmodifiableEntrySet.UnmodifiableEntry(floor) + ? new UnmodifiableEntrySet.UnmodifiableEntry<>(floor) : null; } + @SuppressWarnings("unchecked") public Entry ceilingEntry(K key) { Entry ceiling = (Entry) nm.ceilingEntry(key); return (null != ceiling) - ? new UnmodifiableEntrySet.UnmodifiableEntry(ceiling) + ? new UnmodifiableEntrySet.UnmodifiableEntry<>(ceiling) : null; } + @SuppressWarnings("unchecked") public Entry higherEntry(K key) { Entry higher = (Entry) nm.higherEntry(key); return (null != higher) - ? new UnmodifiableEntrySet.UnmodifiableEntry(higher) + ? new UnmodifiableEntrySet.UnmodifiableEntry<>(higher) : null; } + @SuppressWarnings("unchecked") public Entry firstEntry() { Entry first = (Entry) nm.firstEntry(); return (null != first) - ? new UnmodifiableEntrySet.UnmodifiableEntry(first) + ? new UnmodifiableEntrySet.UnmodifiableEntry<>(first) : null; } + @SuppressWarnings("unchecked") public Entry lastEntry() { Entry last = (Entry) nm.lastEntry(); return (null != last) - ? new UnmodifiableEntrySet.UnmodifiableEntry(last) + ? new UnmodifiableEntrySet.UnmodifiableEntry<>(last) : null; } @@ -2360,7 +2367,7 @@ public class Collections { } public NavigableSet tailSet(E fromElement) { synchronized (mutex) { - return new SynchronizedNavigableSet(ns.tailSet(fromElement, true), mutex); + return new SynchronizedNavigableSet<>(ns.tailSet(fromElement, true), mutex); } } @@ -2925,7 +2932,7 @@ public class Collections { public NavigableMap descendingMap() { synchronized (mutex) { return - new SynchronizedNavigableMap(nm.descendingMap(), mutex); + new SynchronizedNavigableMap<>(nm.descendingMap(), mutex); } } @@ -2935,13 +2942,13 @@ public class Collections { public NavigableSet navigableKeySet() { synchronized (mutex) { - return new SynchronizedNavigableSet(nm.navigableKeySet(), mutex); + return new SynchronizedNavigableSet<>(nm.navigableKeySet(), mutex); } } public NavigableSet descendingKeySet() { synchronized (mutex) { - return new SynchronizedNavigableSet(nm.descendingKeySet(), mutex); + return new SynchronizedNavigableSet<>(nm.descendingKeySet(), mutex); } } @@ -2959,27 +2966,27 @@ public class Collections { } public SortedMap tailMap(K fromKey) { synchronized (mutex) { - return new SynchronizedNavigableMap<>(nm.tailMap(fromKey, true),mutex); + return new SynchronizedNavigableMap<>(nm.tailMap(fromKey, true),mutex); } } public NavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { synchronized (mutex) { - return new SynchronizedNavigableMap( + return new SynchronizedNavigableMap<>( nm.subMap(fromKey, fromInclusive, toKey, toInclusive), mutex); } } public NavigableMap headMap(K toKey, boolean inclusive) { synchronized (mutex) { - return new SynchronizedNavigableMap( + return new SynchronizedNavigableMap<>( nm.headMap(toKey, inclusive), mutex); } } public NavigableMap tailMap(K fromKey, boolean inclusive) { synchronized (mutex) { - return new SynchronizedNavigableMap( + return new SynchronizedNavigableMap<>( nm.tailMap(fromKey, inclusive), mutex); } } @@ -4081,7 +4088,7 @@ public class Collections { public Entry lowerEntry(K key) { Entry lower = nm.lowerEntry(key); return (null != lower) - ? new CheckedMap.CheckedEntrySet.CheckedEntry(lower, valueType) + ? new CheckedMap.CheckedEntrySet.CheckedEntry<>(lower, valueType) : null; } @@ -4090,7 +4097,7 @@ public class Collections { public Entry floorEntry(K key) { Entry floor = nm.floorEntry(key); return (null != floor) - ? new CheckedMap.CheckedEntrySet.CheckedEntry(floor, valueType) + ? new CheckedMap.CheckedEntrySet.CheckedEntry<>(floor, valueType) : null; } @@ -4099,7 +4106,7 @@ public class Collections { public Entry ceilingEntry(K key) { Entry ceiling = nm.ceilingEntry(key); return (null != ceiling) - ? new CheckedMap.CheckedEntrySet.CheckedEntry(ceiling, valueType) + ? new CheckedMap.CheckedEntrySet.CheckedEntry<>(ceiling, valueType) : null; } @@ -4108,7 +4115,7 @@ public class Collections { public Entry higherEntry(K key) { Entry higher = nm.higherEntry(key); return (null != higher) - ? new CheckedMap.CheckedEntrySet.CheckedEntry(higher, valueType) + ? new CheckedMap.CheckedEntrySet.CheckedEntry<>(higher, valueType) : null; } @@ -4117,14 +4124,14 @@ public class Collections { public Entry firstEntry() { Entry first = nm.firstEntry(); return (null != first) - ? new CheckedMap.CheckedEntrySet.CheckedEntry(first, valueType) + ? new CheckedMap.CheckedEntrySet.CheckedEntry<>(first, valueType) : null; } public Entry lastEntry() { Entry last = nm.lastEntry(); return (null != last) - ? new CheckedMap.CheckedEntrySet.CheckedEntry(last, valueType) + ? new CheckedMap.CheckedEntrySet.CheckedEntry<>(last, valueType) : null; } @@ -4132,14 +4139,14 @@ public class Collections { Entry entry = nm.pollFirstEntry(); return (null == entry) ? null - : new CheckedMap.CheckedEntrySet.CheckedEntry(entry, valueType); + : new CheckedMap.CheckedEntrySet.CheckedEntry<>(entry, valueType); } public Entry pollLastEntry() { Entry entry = nm.pollLastEntry(); return (null == entry) ? null - : new CheckedMap.CheckedEntrySet.CheckedEntry(entry, valueType); + : new CheckedMap.CheckedEntrySet.CheckedEntry<>(entry, valueType); } public NavigableMap descendingMap() { diff --git a/jdk/src/share/classes/java/util/Comparator.java b/jdk/src/share/classes/java/util/Comparator.java index cd65ca4ea06..55d5efb9866 100644 --- a/jdk/src/share/classes/java/util/Comparator.java +++ b/jdk/src/share/classes/java/util/Comparator.java @@ -352,6 +352,7 @@ public interface Comparator { * @see Comparable * @since 1.8 */ + @SuppressWarnings("unchecked") public static > Comparator naturalOrder() { return (Comparator) Comparators.NaturalOrderComparator.INSTANCE; } @@ -374,7 +375,7 @@ public interface Comparator { * @since 1.8 */ public static Comparator nullsFirst(Comparator comparator) { - return new Comparators.NullComparator(true, comparator); + return new Comparators.NullComparator<>(true, comparator); } /** @@ -395,7 +396,7 @@ public interface Comparator { * @since 1.8 */ public static Comparator nullsLast(Comparator comparator) { - return new Comparators.NullComparator(false, comparator); + return new Comparators.NullComparator<>(false, comparator); } /** diff --git a/jdk/src/share/classes/java/util/Comparators.java b/jdk/src/share/classes/java/util/Comparators.java index a9038321085..ee806798d7a 100644 --- a/jdk/src/share/classes/java/util/Comparators.java +++ b/jdk/src/share/classes/java/util/Comparators.java @@ -87,12 +87,12 @@ class Comparators { @Override public Comparator thenComparing(Comparator other) { Objects.requireNonNull(other); - return new NullComparator(nullFirst, real == null ? other : real.thenComparing(other)); + return new NullComparator<>(nullFirst, real == null ? other : real.thenComparing(other)); } @Override public Comparator reversed() { - return new NullComparator(!nullFirst, real == null ? null : real.reversed()); + return new NullComparator<>(!nullFirst, real == null ? null : real.reversed()); } } } diff --git a/jdk/src/share/classes/java/util/Hashtable.java b/jdk/src/share/classes/java/util/Hashtable.java index a481719be0c..518bd17f5b7 100644 --- a/jdk/src/share/classes/java/util/Hashtable.java +++ b/jdk/src/share/classes/java/util/Hashtable.java @@ -928,6 +928,7 @@ public class Hashtable return (null == result) ? defaultValue : result; } + @SuppressWarnings("unchecked") @Override public synchronized void forEach(BiConsumer action) { Objects.requireNonNull(action); // explicit check required in case @@ -947,6 +948,7 @@ public class Hashtable } } + @SuppressWarnings("unchecked") @Override public synchronized void replaceAll(BiFunction function) { Objects.requireNonNull(function); // explicit check required in case diff --git a/jdk/src/share/classes/java/util/IdentityHashMap.java b/jdk/src/share/classes/java/util/IdentityHashMap.java index 3064588c901..a4bdc4b9efd 100644 --- a/jdk/src/share/classes/java/util/IdentityHashMap.java +++ b/jdk/src/share/classes/java/util/IdentityHashMap.java @@ -1339,6 +1339,7 @@ public class IdentityHashMap tab[i + 1] = value; } + @SuppressWarnings("unchecked") @Override public void forEach(BiConsumer action) { Objects.requireNonNull(action); @@ -1357,6 +1358,7 @@ public class IdentityHashMap } } + @SuppressWarnings("unchecked") @Override public void replaceAll(BiFunction function) { Objects.requireNonNull(function); diff --git a/jdk/src/share/classes/java/util/Vector.java b/jdk/src/share/classes/java/util/Vector.java index 18cc6f2f0aa..6146957dfd6 100644 --- a/jdk/src/share/classes/java/util/Vector.java +++ b/jdk/src/share/classes/java/util/Vector.java @@ -1164,12 +1164,13 @@ public class Vector if (i >= size) { return; } - final Object[] elementData = Vector.this.elementData; + @SuppressWarnings("unchecked") + final E[] elementData = (E[]) Vector.this.elementData; if (i >= elementData.length) { throw new ConcurrentModificationException(); } while (i != size && modCount == expectedModCount) { - action.accept((E) elementData[i++]); + action.accept(elementData[i++]); } // update once at end of iteration to reduce heap write traffic cursor = i; @@ -1311,8 +1312,8 @@ public class Vector modCount++; } - @Override @SuppressWarnings("unchecked") + @Override public synchronized void sort(Comparator c) { final int expectedModCount = modCount; Arrays.sort((E[]) elementData, 0, elementCount, c); diff --git a/jdk/src/share/classes/java/util/WeakHashMap.java b/jdk/src/share/classes/java/util/WeakHashMap.java index eb2e636e2ba..0299d296638 100644 --- a/jdk/src/share/classes/java/util/WeakHashMap.java +++ b/jdk/src/share/classes/java/util/WeakHashMap.java @@ -1038,6 +1038,7 @@ public class WeakHashMap } } + @SuppressWarnings("unchecked") @Override public void forEach(BiConsumer action) { Objects.requireNonNull(action); @@ -1059,6 +1060,7 @@ public class WeakHashMap } } + @SuppressWarnings("unchecked") @Override public void replaceAll(BiFunction function) { Objects.requireNonNull(function); From ebb9d2fb06d142f25f123e9656e38c9f5660cf10 Mon Sep 17 00:00:00 2001 From: Jason Uh Date: Tue, 6 Aug 2013 13:46:15 -0700 Subject: [PATCH 025/118] 8022439: Fix lint warnings in sun.security.ec Reviewed-by: darcy --- jdk/src/share/classes/sun/security/ec/ECDSASignature.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/src/share/classes/sun/security/ec/ECDSASignature.java b/jdk/src/share/classes/sun/security/ec/ECDSASignature.java index c831259f5ad..1e80694207e 100644 --- a/jdk/src/share/classes/sun/security/ec/ECDSASignature.java +++ b/jdk/src/share/classes/sun/security/ec/ECDSASignature.java @@ -323,6 +323,7 @@ abstract class ECDSASignature extends SignatureSpi { // set parameter, not supported. See JCA doc @Override + @Deprecated protected void engineSetParameter(String param, Object value) throws InvalidParameterException { throw new UnsupportedOperationException("setParameter() not supported"); @@ -330,6 +331,7 @@ abstract class ECDSASignature extends SignatureSpi { // get parameter, not supported. See JCA doc @Override + @Deprecated protected Object engineGetParameter(String param) throws InvalidParameterException { throw new UnsupportedOperationException("getParameter() not supported"); From 6ecdd925d1d66588fae4274a6e111600c07cfc61 Mon Sep 17 00:00:00 2001 From: Jason Uh Date: Tue, 6 Aug 2013 14:10:06 -0700 Subject: [PATCH 026/118] 8022443: Fix lint warnings in sun.security.pkcs12 Reviewed-by: darcy --- .../share/classes/sun/security/pkcs12/PKCS12KeyStore.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java index 32f1da53afa..35564498c0e 100644 --- a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java +++ b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java @@ -775,7 +775,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi { } } if (params != null) { - if (algorithm.equals(pbes2_OID)) { + if (algorithm.equals((Object)pbes2_OID)) { algParams = AlgorithmParameters.getInstance("PBES2"); } else { algParams = AlgorithmParameters.getInstance("PBE"); @@ -912,7 +912,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi { private static String mapPBEParamsToAlgorithm(ObjectIdentifier algorithm, AlgorithmParameters algParams) throws NoSuchAlgorithmException { // Check for PBES2 algorithms - if (algorithm.equals(pbes2_OID) && algParams != null) { + if (algorithm.equals((Object)pbes2_OID) && algParams != null) { return algParams.toString(); } return algorithm.toString(); @@ -1921,7 +1921,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi { } safeContentsData = safeContents.getData(); - } else if (contentType.equals(ContentInfo.ENCRYPTED_DATA_OID)) { + } else if (contentType.equals((Object)ContentInfo.ENCRYPTED_DATA_OID)) { if (password == null) { continue; } From 6c4cb951711550d80f5aee766208edaf03462d70 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Tue, 6 Aug 2013 14:24:05 -0700 Subject: [PATCH 027/118] 8022440: suppress deprecation warnings in sun.rmi Reviewed-by: mduigou --- jdk/src/share/classes/sun/rmi/runtime/Log.java | 3 ++- jdk/src/share/classes/sun/rmi/server/ActivatableRef.java | 3 ++- jdk/src/share/classes/sun/rmi/server/Dispatcher.java | 3 ++- jdk/src/share/classes/sun/rmi/server/LoaderHandler.java | 3 ++- jdk/src/share/classes/sun/rmi/server/UnicastRef.java | 5 +++-- jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java | 3 ++- jdk/src/share/classes/sun/rmi/server/Util.java | 3 ++- jdk/src/share/classes/sun/rmi/transport/DGCImpl.java | 3 ++- .../share/classes/sun/rmi/transport/StreamRemoteCall.java | 3 ++- jdk/src/share/classes/sun/rmi/transport/Transport.java | 3 ++- .../sun/rmi/transport/proxy/RMIMasterSocketFactory.java | 3 ++- .../classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java | 3 ++- .../share/classes/sun/rmi/transport/tcp/TCPTransport.java | 3 ++- 13 files changed, 27 insertions(+), 14 deletions(-) diff --git a/jdk/src/share/classes/sun/rmi/runtime/Log.java b/jdk/src/share/classes/sun/rmi/runtime/Log.java index 7a1b0982fba..62d03614dfe 100644 --- a/jdk/src/share/classes/sun/rmi/runtime/Log.java +++ b/jdk/src/share/classes/sun/rmi/runtime/Log.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,6 +61,7 @@ import java.util.HashMap; * @author Laird Dornin * @since 1.4 */ +@SuppressWarnings("deprecation") public abstract class Log { /** Logger re-definition of old RMI log values */ diff --git a/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java b/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java index 6224ff35655..7e6668c389e 100644 --- a/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java +++ b/jdk/src/share/classes/sun/rmi/server/ActivatableRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ import java.rmi.server.RemoteObjectInvocationHandler; import java.rmi.server.RemoteRef; import java.rmi.server.RemoteStub; +@SuppressWarnings("deprecation") public class ActivatableRef implements RemoteRef { private static final long serialVersionUID = 7579060052569229166L; diff --git a/jdk/src/share/classes/sun/rmi/server/Dispatcher.java b/jdk/src/share/classes/sun/rmi/server/Dispatcher.java index 947aa4176e2..a2ec6dcf264 100644 --- a/jdk/src/share/classes/sun/rmi/server/Dispatcher.java +++ b/jdk/src/share/classes/sun/rmi/server/Dispatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.rmi.server.RemoteCall; * The Dispatcher interface allows the transport to make * the upcall to the server side remote reference. */ +@SuppressWarnings("deprecation") public interface Dispatcher { /** diff --git a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java index 7830ed354bb..c35da195ad2 100644 --- a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java +++ b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,6 +67,7 @@ import sun.security.action.GetPropertyAction; * @author Peter Jones * @author Laird Dornin */ +@SuppressWarnings("deprecation") public final class LoaderHandler { /** RMI class loader log level */ diff --git a/jdk/src/share/classes/sun/rmi/server/UnicastRef.java b/jdk/src/share/classes/sun/rmi/server/UnicastRef.java index 3ea4bd34ce5..9b95724094a 100644 --- a/jdk/src/share/classes/sun/rmi/server/UnicastRef.java +++ b/jdk/src/share/classes/sun/rmi/server/UnicastRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,8 @@ import sun.security.action.GetBooleanAction; * NOTE: There is a JDK-internal dependency on the existence of this * class's getLiveRef method (as it is inherited by UnicastRef2) in * the implementation of javax.management.remote.rmi.RMIConnector. - **/ + */ +@SuppressWarnings("deprecation") public class UnicastRef implements RemoteRef { /** diff --git a/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java b/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java index b47b4ed6e20..180a6252304 100644 --- a/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java +++ b/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,6 +67,7 @@ import sun.security.action.GetBooleanAction; * @author Roger Riggs * @author Peter Jones */ +@SuppressWarnings("deprecation") public class UnicastServerRef extends UnicastRef implements ServerRef, Dispatcher { diff --git a/jdk/src/share/classes/sun/rmi/server/Util.java b/jdk/src/share/classes/sun/rmi/server/Util.java index 0f6c7ddee50..0f82a84c9b1 100644 --- a/jdk/src/share/classes/sun/rmi/server/Util.java +++ b/jdk/src/share/classes/sun/rmi/server/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,6 +64,7 @@ import sun.security.action.GetPropertyAction; * A utility class with static methods for creating stubs/proxies and * skeletons for remote objects. */ +@SuppressWarnings("deprecation") public final class Util { /** "server" package log level */ diff --git a/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java b/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java index b5ce50cacc7..88ac91b648d 100644 --- a/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java +++ b/jdk/src/share/classes/sun/rmi/transport/DGCImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,6 +59,7 @@ import sun.security.action.GetPropertyAction; * * @author Ann Wollrath */ +@SuppressWarnings("deprecation") final class DGCImpl implements DGC { /* dgc system log */ diff --git a/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java b/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java index 5971405d970..915ed6f9262 100644 --- a/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java +++ b/jdk/src/share/classes/sun/rmi/transport/StreamRemoteCall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,7 @@ import sun.rmi.transport.tcp.TCPEndpoint; * * @author Ann Wollrath */ +@SuppressWarnings("deprecation") public class StreamRemoteCall implements RemoteCall { private ConnectionInputStream in = null; private ConnectionOutputStream out = null; diff --git a/jdk/src/share/classes/sun/rmi/transport/Transport.java b/jdk/src/share/classes/sun/rmi/transport/Transport.java index 286682dff8a..217c93682bd 100644 --- a/jdk/src/share/classes/sun/rmi/transport/Transport.java +++ b/jdk/src/share/classes/sun/rmi/transport/Transport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,7 @@ import sun.rmi.server.UnicastServerRef; * * @author Ann Wollrath */ +@SuppressWarnings("deprecation") public abstract class Transport { /** "transport" package log level */ diff --git a/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java b/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java index d3dbf6f1da4..e77e224597f 100644 --- a/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java +++ b/jdk/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ import sun.security.action.GetLongAction; * connect to the same host will automatically use the same * mechanism. */ +@SuppressWarnings("deprecation") public class RMIMasterSocketFactory extends RMISocketFactory { /** "proxy" package log level */ diff --git a/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java b/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java index b12809a26bf..d1b6cbf7e15 100644 --- a/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java +++ b/jdk/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,7 @@ import sun.rmi.runtime.Log; * * @author Peter Jones */ +@SuppressWarnings("deprecation") final class ConnectionMultiplexer { /** "multiplex" log level */ diff --git a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java index 54d6d21d9e6..24655c2f0b5 100644 --- a/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java +++ b/jdk/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,6 +84,7 @@ import sun.security.action.GetPropertyAction; * @author Ann Wollrath * @author Peter Jones */ +@SuppressWarnings("deprecation") public class TCPTransport extends Transport { /* tcp package log */ From bcf263eb10ddd769d0584d3256ad21da00b29611 Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Tue, 6 Aug 2013 14:33:56 -0700 Subject: [PATCH 028/118] 8022410: Fix Javac Warnings in com.sun.security.auth Package Reviewed-by: darcy --- .../com/sun/security/auth/PolicyFile.java | 68 ++++++++++--------- .../sun/security/auth/SubjectCodeSource.java | 62 ++++++++--------- 2 files changed, 63 insertions(+), 67 deletions(-) diff --git a/jdk/src/share/classes/com/sun/security/auth/PolicyFile.java b/jdk/src/share/classes/com/sun/security/auth/PolicyFile.java index 447eb395b69..2ea13fb3169 100644 --- a/jdk/src/share/classes/com/sun/security/auth/PolicyFile.java +++ b/jdk/src/share/classes/com/sun/security/auth/PolicyFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,10 @@ import javax.security.auth.PrivateCredentialPermission; import sun.security.util.PropertyExpander; +import sun.security.provider.PolicyParser.PrincipalEntry; +import sun.security.provider.PolicyParser.GrantEntry; +import sun.security.provider.PolicyParser.PermissionEntry; + /** * This class represents a default implementation for * javax.security.auth.Policy. @@ -469,7 +473,8 @@ public class PolicyFile extends javax.security.auth.Policy { * @param policyFile the policy Reader object. */ private void init(URL policy) { - PolicyParser pp = new PolicyParser(expandProperties); + sun.security.provider.PolicyParser pp = + new sun.security.provider.PolicyParser(expandProperties); try { InputStreamReader isr = new InputStreamReader(getInputStream(policy)); @@ -477,12 +482,12 @@ public class PolicyFile extends javax.security.auth.Policy { isr.close(); KeyStore keyStore = initKeyStore(policy, pp.getKeyStoreUrl(), pp.getKeyStoreType()); - Enumeration enum_ = pp.grantElements(); + Enumeration enum_ = pp.grantElements(); while (enum_.hasMoreElements()) { - PolicyParser.GrantEntry ge = enum_.nextElement(); + GrantEntry ge = enum_.nextElement(); addGrantEntry(ge, keyStore); } - } catch (PolicyParser.ParsingException pe) { + } catch (sun.security.provider.PolicyParser.ParsingException pe) { System.err.println(AUTH_POLICY + rb.getString(".error.parsing.") + policy); System.err.println(AUTH_POLICY + @@ -521,8 +526,8 @@ public class PolicyFile extends javax.security.auth.Policy { * * @return null if signedBy alias is not recognized */ - CodeSource getCodeSource(PolicyParser.GrantEntry ge, KeyStore keyStore) - throws java.net.MalformedURLException + CodeSource getCodeSource(GrantEntry ge, KeyStore keyStore) + throws java.net.MalformedURLException { Certificate[] certs = null; if (ge.signedBy != null) { @@ -559,20 +564,18 @@ public class PolicyFile extends javax.security.auth.Policy { /** * Add one policy entry to the vector. */ - private void addGrantEntry(PolicyParser.GrantEntry ge, - KeyStore keyStore) { + private void addGrantEntry(GrantEntry ge, KeyStore keyStore) { if (debug != null) { debug.println("Adding policy entry: "); debug.println(" signedBy " + ge.signedBy); debug.println(" codeBase " + ge.codeBase); if (ge.principals != null && ge.principals.size() > 0) { - ListIterator li = - ge.principals.listIterator(); + ListIterator li = ge.principals.listIterator(); while (li.hasNext()) { - PolicyParser.PrincipalEntry pppe = li.next(); - debug.println(" " + pppe.principalClass + - " " + pppe.principalName); + PrincipalEntry pppe = li.next(); + debug.println(" " + pppe.getPrincipalClass() + + " " + pppe.getPrincipalName()); } } debug.println(); @@ -584,10 +587,9 @@ public class PolicyFile extends javax.security.auth.Policy { if (codesource == null) return; PolicyEntry entry = new PolicyEntry(codesource); - Enumeration enum_ = - ge.permissionElements(); + Enumeration enum_ = ge.permissionElements(); while (enum_.hasMoreElements()) { - PolicyParser.PermissionEntry pe = enum_.nextElement(); + PermissionEntry pe = enum_.nextElement(); try { // XXX special case PrivateCredentialPermission-SELF Permission perm; @@ -998,11 +1000,11 @@ public class PolicyFile extends javax.security.auth.Policy { return true; } - ListIterator pli = - scs.getPrincipals().listIterator(); + ListIterator pli = + scs.getPrincipals().listIterator(); while (pli.hasNext()) { - PolicyParser.PrincipalEntry principal = pli.next(); + PrincipalEntry principal = pli.next(); // XXX // if the Policy entry's Principal does not contain a @@ -1050,30 +1052,29 @@ public class PolicyFile extends javax.security.auth.Policy { * if (y == 1), it's the principal name. */ private String[][] getPrincipalInfo - (PolicyParser.PrincipalEntry principal, - final CodeSource accCs) { + (PrincipalEntry principal, final CodeSource accCs) { // there are 3 possibilities: // 1) the entry's Principal class and name are not wildcarded // 2) the entry's Principal name is wildcarded only // 3) the entry's Principal class and name are wildcarded - if (!principal.principalClass.equals - (PolicyParser.PrincipalEntry.WILDCARD_CLASS) && - !principal.principalName.equals - (PolicyParser.PrincipalEntry.WILDCARD_NAME)) { + if (!principal.getPrincipalClass().equals + (PrincipalEntry.WILDCARD_CLASS) && + !principal.getPrincipalName().equals + (PrincipalEntry.WILDCARD_NAME)) { // build a PrivateCredentialPermission for the principal // from the Policy entry String[][] info = new String[1][2]; - info[0][0] = principal.principalClass; - info[0][1] = principal.principalName; + info[0][0] = principal.getPrincipalClass(); + info[0][1] = principal.getPrincipalName(); return info; - } else if (!principal.principalClass.equals - (PolicyParser.PrincipalEntry.WILDCARD_CLASS) && - principal.principalName.equals - (PolicyParser.PrincipalEntry.WILDCARD_NAME)) { + } else if (!principal.getPrincipalClass().equals + (PrincipalEntry.WILDCARD_CLASS) && + principal.getPrincipalName().equals + (PrincipalEntry.WILDCARD_NAME)) { // build a PrivateCredentialPermission for all // the Subject's principals that are instances of principalClass @@ -1088,7 +1089,7 @@ public class PolicyFile extends javax.security.auth.Policy { // If it doesn't, we should stop here with a ClassCastException. @SuppressWarnings("unchecked") Class pClass = (Class) - Class.forName(principal.principalClass, false, + Class.forName(principal.getPrincipalClass(), false, ClassLoader.getSystemClassLoader()); principalSet = scs.getSubject().getPrincipals(pClass); } catch (Exception e) { @@ -1387,6 +1388,7 @@ public class PolicyFile extends javax.security.auth.Policy { } } +@SuppressWarnings("deprecation") class PolicyPermissions extends PermissionCollection { private static final long serialVersionUID = -1954188373270545523L; diff --git a/jdk/src/share/classes/com/sun/security/auth/SubjectCodeSource.java b/jdk/src/share/classes/com/sun/security/auth/SubjectCodeSource.java index 35d3bf1c410..7e38a087420 100644 --- a/jdk/src/share/classes/com/sun/security/auth/SubjectCodeSource.java +++ b/jdk/src/share/classes/com/sun/security/auth/SubjectCodeSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.security.cert.Certificate; import java.lang.reflect.Constructor; import javax.security.auth.Subject; +import sun.security.provider.PolicyParser.PrincipalEntry; /** *

    This SubjectCodeSource class contains @@ -57,7 +58,7 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { }); private Subject subject; - private LinkedList principals; + private LinkedList principals; private static final Class[] PARAMS = { String.class }; private static final sun.security.util.Debug debug = sun.security.util.Debug.getInstance("auth", "\t[Auth Access]"); @@ -87,14 +88,14 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { * SubjectCodeSource

    */ SubjectCodeSource(Subject subject, - LinkedList principals, + LinkedList principals, URL url, Certificate[] certs) { super(url, certs); this.subject = subject; this.principals = (principals == null ? - new LinkedList() : - new LinkedList(principals)); + new LinkedList() : + new LinkedList(principals)); sysClassLoader = java.security.AccessController.doPrivileged (new java.security.PrivilegedAction() { public ClassLoader run() { @@ -114,7 +115,7 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { * SubjectCodeSource as a LinkedList * of PolicyParser.PrincipalEntry objects. */ - LinkedList getPrincipals() { + LinkedList getPrincipals() { return principals; } @@ -167,7 +168,7 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { */ public boolean implies(CodeSource codesource) { - LinkedList subjectList = null; + LinkedList subjectList = null; if (codesource == null || !(codesource instanceof SubjectCodeSource) || @@ -197,20 +198,19 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { return false; } - ListIterator li = - this.principals.listIterator(0); + ListIterator li = this.principals.listIterator(0); while (li.hasNext()) { - PolicyParser.PrincipalEntry pppe = li.next(); + PrincipalEntry pppe = li.next(); try { // handle PrincipalComparators Class principalComparator = Class.forName( - pppe.principalClass, true, sysClassLoader); + pppe.getPrincipalClass(), true, sysClassLoader); Constructor c = principalComparator.getConstructor(PARAMS); PrincipalComparator pc = (PrincipalComparator)c.newInstance - (new Object[] { pppe.principalName }); + (new Object[] { pppe.getPrincipalName() }); if (!pc.implies(that.getSubject())) { if (debug != null) @@ -236,11 +236,10 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { Iterator i = that.getSubject().getPrincipals().iterator(); - subjectList = new LinkedList(); + subjectList = new LinkedList(); while (i.hasNext()) { Principal p = i.next(); - PolicyParser.PrincipalEntry spppe = - new PolicyParser.PrincipalEntry + PrincipalEntry spppe = new PrincipalEntry (p.getClass().getName(), p.getName()); subjectList.add(spppe); } @@ -281,23 +280,19 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { * pppe argument. */ private boolean subjectListImpliesPrincipalEntry( - LinkedList subjectList, - PolicyParser.PrincipalEntry pppe) { + LinkedList subjectList, PrincipalEntry pppe) { - ListIterator li = - subjectList.listIterator(0); + ListIterator li = subjectList.listIterator(0); while (li.hasNext()) { - PolicyParser.PrincipalEntry listPppe = li.next(); + PrincipalEntry listPppe = li.next(); - if (pppe.principalClass.equals - (PolicyParser.PrincipalEntry.WILDCARD_CLASS) || - pppe.principalClass.equals - (listPppe.principalClass)) { - - if (pppe.principalName.equals - (PolicyParser.PrincipalEntry.WILDCARD_NAME) || - pppe.principalName.equals - (listPppe.principalName)) + if (pppe.getPrincipalClass().equals + (PrincipalEntry.WILDCARD_CLASS) || + pppe.getPrincipalClass().equals(listPppe.getPrincipalClass())) + { + if (pppe.getPrincipalName().equals + (PrincipalEntry.WILDCARD_NAME) || + pppe.getPrincipalName().equals(listPppe.getPrincipalName())) return true; } } @@ -390,13 +385,12 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { } } if (principals != null) { - ListIterator li = - principals.listIterator(); + ListIterator li = principals.listIterator(); while (li.hasNext()) { - PolicyParser.PrincipalEntry pppe = li.next(); + PrincipalEntry pppe = li.next(); returnMe = returnMe + rb.getString("NEWLINE") + - pppe.principalClass + " " + - pppe.principalName; + pppe.getPrincipalClass() + " " + + pppe.getPrincipalName(); } } return returnMe; From 10f964a32464c5c751bfeeec942d3c9a69fc418b Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 6 Aug 2013 16:01:39 -0700 Subject: [PATCH 029/118] 8022406: Fix doclint issues in java.beans Reviewed-by: prr --- .../classes/java/beans/AppletInitializer.java | 3 +- jdk/src/share/classes/java/beans/Beans.java | 9 ++-- .../java/beans/ConstructorProperties.java | 4 +- .../beans/DefaultPersistenceDelegate.java | 3 +- .../classes/java/beans/EventHandler.java | 5 ++- .../share/classes/java/beans/Expression.java | 6 ++- .../java/beans/IndexedPropertyDescriptor.java | 4 ++ .../classes/java/beans/Introspector.java | 13 +++++- .../java/beans/PersistenceDelegate.java | 3 +- .../java/beans/PropertyChangeSupport.java | 6 +-- .../java/beans/PropertyDescriptor.java | 2 + .../share/classes/java/beans/Transient.java | 12 ++++-- .../java/beans/VetoableChangeSupport.java | 10 ++--- .../java/beans/beancontext/BeanContext.java | 14 +++--- .../beans/beancontext/BeanContextChild.java | 4 +- .../beancontext/BeanContextChildSupport.java | 6 ++- .../BeanContextMembershipEvent.java | 3 +- .../beancontext/BeanContextServices.java | 5 ++- .../BeanContextServicesSupport.java | 27 ++++++++++-- .../beans/beancontext/BeanContextSupport.java | 43 ++++++++++++++----- 20 files changed, 130 insertions(+), 52 deletions(-) diff --git a/jdk/src/share/classes/java/beans/AppletInitializer.java b/jdk/src/share/classes/java/beans/AppletInitializer.java index 9e4b7239d61..2c271a236ca 100644 --- a/jdk/src/share/classes/java/beans/AppletInitializer.java +++ b/jdk/src/share/classes/java/beans/AppletInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,6 @@ public interface AppletInitializer { * the Applet with its Container during the subsequent invocation of its * addChildren() method. * - *

    * * @param newAppletBean The newly instantiated JavaBean * @param bCtxt The BeanContext intended for this Applet, or diff --git a/jdk/src/share/classes/java/beans/Beans.java b/jdk/src/share/classes/java/beans/Beans.java index 2183d224167..58a411691fd 100644 --- a/jdk/src/share/classes/java/beans/Beans.java +++ b/jdk/src/share/classes/java/beans/Beans.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,7 @@ public class Beans { *

    * Instantiate a JavaBean. *

    - * + * @return a JavaBean * @param cls the class-loader from which we should create * the bean. If this is null, then the system * class-loader is used. @@ -82,6 +82,7 @@ public class Beans { *

    * Instantiate a JavaBean. *

    + * @return a JavaBean * * @param cls the class-loader from which we should create * the bean. If this is null, then the system @@ -137,6 +138,7 @@ public class Beans { * the JDK appletviewer (for a reference browser environment) and the * BDK BeanBox (for a reference bean container). * + * @return a JavaBean * @param cls the class-loader from which we should create * the bean. If this is null, then the system * class-loader is used. @@ -361,6 +363,8 @@ public class Beans { * This method is provided in Beans 1.0 as a hook to allow the * addition of more flexible bean behaviour in the future. * + * @return an object representing a specified type view of the + * source object * @param bean Object from which we want to obtain a view. * @param targetType The type of view we'd like to get. * @@ -384,7 +388,6 @@ public class Beans { return Introspector.isSubclass(bean.getClass(), targetType); } - /** * Test if we are in design-mode. * diff --git a/jdk/src/share/classes/java/beans/ConstructorProperties.java b/jdk/src/share/classes/java/beans/ConstructorProperties.java index 3166de31747..5ee947c1f1c 100644 --- a/jdk/src/share/classes/java/beans/ConstructorProperties.java +++ b/jdk/src/share/classes/java/beans/ConstructorProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ import static java.lang.annotation.RetentionPolicy.*; the {@code getY()} method. Since parameter names are not in general available at runtime, without the annotation there would be no way to know whether the parameters correspond to {@code getX()} - and {@code getY()} or the other way around.

    + and {@code getY()} or the other way around. @since 1.6 */ diff --git a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java index 3c6c7c2a3d3..de6a1b75178 100644 --- a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java +++ b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -382,6 +382,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate { * a class such that no property value depends on the value of * a subsequent property. * + * @param type the type of the instances * @param oldInstance The instance to be copied. * @param newInstance The instance that is to be modified. * @param out The stream to which any initialization statements should be written. diff --git a/jdk/src/share/classes/java/beans/EventHandler.java b/jdk/src/share/classes/java/beans/EventHandler.java index b7635c931b7..b428f2892a1 100644 --- a/jdk/src/share/classes/java/beans/EventHandler.java +++ b/jdk/src/share/classes/java/beans/EventHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -515,6 +515,7 @@ public class EventHandler implements InvocationHandler { * * * + * @param the type to create * @param listenerInterface the listener interface to create a proxy for * @param target the object that will perform the action * @param action the name of a (possibly qualified) property or method on @@ -570,6 +571,7 @@ public class EventHandler implements InvocationHandler { * * * + * @param the type to create * @param listenerInterface the listener interface to create a proxy for * @param target the object that will perform the action * @param action the name of a (possibly qualified) property or method on @@ -659,6 +661,7 @@ public class EventHandler implements InvocationHandler { * * * + * @param the type to create * @param listenerInterface the listener interface to create a proxy for * @param target the object that will perform the action * @param action the name of a (possibly qualified) property or method on diff --git a/jdk/src/share/classes/java/beans/Expression.java b/jdk/src/share/classes/java/beans/Expression.java index f7a15c3464a..ce6fafb104e 100644 --- a/jdk/src/share/classes/java/beans/Expression.java +++ b/jdk/src/share/classes/java/beans/Expression.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -139,7 +139,7 @@ public class Expression extends Statement { * replaces this default value in the same way that any other value * would, ensuring that expressions are never evaluated more than once. *

    - * See the excecute method for details on how + * See the execute method for details on how * methods are chosen using the dynamic types of the target * and arguments. * @@ -147,6 +147,8 @@ public class Expression extends Statement { * @see #setValue * * @return The result of applying this method to these arguments. + * @throws Exception if the method with the specified methodName + * throws an exception */ public Object getValue() throws Exception { if (value == unbound) { diff --git a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java index d3f16d2901e..1d59f7afddb 100644 --- a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java +++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java @@ -207,6 +207,8 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { * Sets the method that should be used to read an indexed property value. * * @param readMethod The new indexed read method. + * @throws IntrospectionException if an exception occurs during + * introspection. */ public synchronized void setIndexedReadMethod(Method readMethod) throws IntrospectionException { @@ -285,6 +287,8 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { * Sets the method that should be used to write an indexed property value. * * @param writeMethod The new indexed write method. + * @throws IntrospectionException if an exception occurs during + * introspection. */ public synchronized void setIndexedWriteMethod(Method writeMethod) throws IntrospectionException { diff --git a/jdk/src/share/classes/java/beans/Introspector.java b/jdk/src/share/classes/java/beans/Introspector.java index 783fcbef315..acc0f77f389 100644 --- a/jdk/src/share/classes/java/beans/Introspector.java +++ b/jdk/src/share/classes/java/beans/Introspector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,8 +93,17 @@ import sun.reflect.misc.ReflectUtil; public class Introspector { // Flags that can be used to control getBeanInfo: + /** + * Flag to indicate to use of all beaninfo. + */ public final static int USE_ALL_BEANINFO = 1; + /** + * Flag to indicate to ignore immediate beaninfo. + */ public final static int IGNORE_IMMEDIATE_BEANINFO = 2; + /** + * Flag to indicate to ignore all beaninfo. + */ public final static int IGNORE_ALL_BEANINFO = 3; // Static Caches to speed up introspection. @@ -202,7 +211,7 @@ public class Introspector { * If the BeanInfo class for a Java Bean has been previously Introspected * based on the same arguments, then the BeanInfo class is retrieved * from the BeanInfo cache. - * + * @return the BeanInfo for the bean * @param beanClass The bean class to be analyzed. * @param stopClass The baseclass at which to stop the analysis. Any * methods/properties/events in the stopClass or in its baseclasses diff --git a/jdk/src/share/classes/java/beans/PersistenceDelegate.java b/jdk/src/share/classes/java/beans/PersistenceDelegate.java index 01c5bb12387..bbdcdbf060c 100644 --- a/jdk/src/share/classes/java/beans/PersistenceDelegate.java +++ b/jdk/src/share/classes/java/beans/PersistenceDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -197,6 +197,7 @@ public abstract class PersistenceDelegate { * The default implementation, calls the initialize * method of the type's superclass. * + * @param type the type of the instances * @param oldInstance The instance to be copied. * @param newInstance The instance that is to be modified. * @param out The stream to which any initialization statements should be written. diff --git a/jdk/src/share/classes/java/beans/PropertyChangeSupport.java b/jdk/src/share/classes/java/beans/PropertyChangeSupport.java index c3c73179b1a..d55ae76efc8 100644 --- a/jdk/src/share/classes/java/beans/PropertyChangeSupport.java +++ b/jdk/src/share/classes/java/beans/PropertyChangeSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -156,7 +156,7 @@ public class PropertyChangeSupport implements Serializable { * PropertyChangeListenerProxy, perform the cast, and examine * the parameter. * - *

    +     * 
    {@code
          * PropertyChangeListener[] listeners = bean.getPropertyChangeListeners();
          * for (int i = 0; i < listeners.length; i++) {
          *   if (listeners[i] instanceof PropertyChangeListenerProxy) {
    @@ -168,7 +168,7 @@ public class PropertyChangeSupport implements Serializable {
          *     }
          *   }
          * }
    -     *
    + * }
    * * @see PropertyChangeListenerProxy * @return all of the PropertyChangeListeners added or an diff --git a/jdk/src/share/classes/java/beans/PropertyDescriptor.java b/jdk/src/share/classes/java/beans/PropertyDescriptor.java index 0abdcad972b..c519b504d58 100644 --- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java +++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java @@ -243,6 +243,7 @@ public class PropertyDescriptor extends FeatureDescriptor { * Sets the method that should be used to read the property value. * * @param readMethod The new read method. + * @throws IntrospectionException if the read method is invalid */ public synchronized void setReadMethod(Method readMethod) throws IntrospectionException { @@ -313,6 +314,7 @@ public class PropertyDescriptor extends FeatureDescriptor { * Sets the method that should be used to write the property value. * * @param writeMethod The new write method. + * @throws IntrospectionException if the write method is invalid */ public synchronized void setWriteMethod(Method writeMethod) throws IntrospectionException { diff --git a/jdk/src/share/classes/java/beans/Transient.java b/jdk/src/share/classes/java/beans/Transient.java index 0a2761ce8b9..165621b39fd 100644 --- a/jdk/src/share/classes/java/beans/Transient.java +++ b/jdk/src/share/classes/java/beans/Transient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * A {@code true} value for the "transient" attribute * indicates to encoders derived from {@link Encoder} * that this feature should be ignored. - *

    + *

    * The {@code Transient} annotation may be be used * in any of the methods that are involved * in a {@link FeatureDescriptor} subclass @@ -49,7 +49,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * to put the annotation and it is this declaration * that takes precedence in the case of multiple annotations * being defined for the same feature. - *

    + *

    * To declare a feature non-transient in a class * whose superclass declares it transient, * use {@code @Transient(false)}. @@ -64,5 +64,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; @Target({METHOD}) @Retention(RUNTIME) public @interface Transient { + /** + * Returns whether or not the {@code Introspector} should + * construct artifacts for the annotated method. + * @return whether or not the {@code Introspector} should + * construct artifacts for the annotated method + */ boolean value() default true; } diff --git a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java index 6b7e268eba7..293ae5af2c6 100644 --- a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java +++ b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ import java.util.Map.Entry; *

    * Here is an example of {@code VetoableChangeSupport} usage that follows * the rules and recommendations laid out in the JavaBeans™ specification: - *

    + * 
    {@code
      * public class MyBean {
      *     private final VetoableChangeSupport vcs = new VetoableChangeSupport(this);
      *
    @@ -68,7 +68,7 @@ import java.util.Map.Entry;
      *
      *     [...]
      * }
    - * 
    + * }
    *

    * A {@code VetoableChangeSupport} instance is thread-safe. *

    @@ -156,7 +156,7 @@ public class VetoableChangeSupport implements Serializable { * VetoableChangeListenerProxy, perform the cast, and examine * the parameter. * - *

    +     * 
    {@code
          * VetoableChangeListener[] listeners = bean.getVetoableChangeListeners();
          * for (int i = 0; i < listeners.length; i++) {
          *        if (listeners[i] instanceof VetoableChangeListenerProxy) {
    @@ -168,7 +168,7 @@ public class VetoableChangeSupport implements Serializable {
          *     }
          *   }
          * }
    -     *
    + * }
    * * @see VetoableChangeListenerProxy * @return all of the VetoableChangeListeners added or an diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContext.java b/jdk/src/share/classes/java/beans/beancontext/BeanContext.java index c6217289faf..308147b9e3c 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContext.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,10 +64,12 @@ public interface BeanContext extends BeanContextChild, Collection, DesignMode, V * and is defined by the * java.beans.Beans.instantiate() method. * + * @return a javaBean named as a child of this + * BeanContext * @param beanName The name of the JavaBean to instantiate * as a child of this BeanContext - * @throws IOException - * @throws ClassNotFoundException if the class identified + * @throws IOException if an IO problem occurs + * @throws ClassNotFoundException if the class identified * by the beanName parameter is not found */ Object instantiateChild(String beanName) throws IOException, ClassNotFoundException; @@ -83,7 +85,7 @@ public interface BeanContext extends BeanContextChild, Collection, DesignMode, V * @return an InputStream for reading the resource, * or null if the resource could not * be found. - * @throws IllegalArgumentException if + * @throws IllegalArgumentException if * the resource is not valid */ InputStream getResourceAsStream(String name, BeanContextChild bcc) throws IllegalArgumentException; @@ -98,7 +100,7 @@ public interface BeanContext extends BeanContextChild, Collection, DesignMode, V * @param bcc the specified child * @return a URL for the named * resource for the specified child - * @throws IllegalArgumentException + * @throws IllegalArgumentException * if the resource is not valid */ URL getResource(String name, BeanContextChild bcc) throws IllegalArgumentException; @@ -109,7 +111,7 @@ public interface BeanContext extends BeanContextChild, Collection, DesignMode, V * this BeanContext whenever it adds * or removes a child Component(s). * - * @param bcml the BeanContextMembershipListener to be added + * @param bcml the BeanContextMembershipListener to be added */ void addBeanContextMembershipListener(BeanContextMembershipListener bcml); diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextChild.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextChild.java index 841e3ccbc5e..e84b7a7eeb5 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextChild.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextChild.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ public interface BeanContextChild { *

    * @param bc The BeanContext with which * to associate this BeanContextChild. - * @throws PropertyVetoException if the + * @throws PropertyVetoException if the * addition of the specified BeanContext is refused. */ void setBeanContext(BeanContext bc) throws PropertyVetoException; diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextChildSupport.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextChildSupport.java index 056913b654a..b2b855867b5 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextChildSupport.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextChildSupport.java @@ -78,6 +78,7 @@ public class BeanContextChildSupport implements BeanContextChild, BeanContextSer * construct a BeanContextChildSupport where the JavaBean component * itself implements BeanContextChild, and encapsulates this, delegating * that interface to this implementation + * @param bcc the underlying bean context child */ public BeanContextChildSupport(BeanContextChild bcc) { @@ -94,7 +95,7 @@ public class BeanContextChildSupport implements BeanContextChild, BeanContextSer * this BeanContextChildSupport. * @param bc the new value to be assigned to the BeanContext * property - * @throws PropertyVetoException if the change is rejected + * @throws PropertyVetoException if the change is rejected */ public synchronized void setBeanContext(BeanContext bc) throws PropertyVetoException { if (bc == beanContext) return; @@ -361,6 +362,9 @@ public class BeanContextChildSupport implements BeanContextChild, BeanContextSer */ protected VetoableChangeSupport vcSupport; + /** + * The bean context. + */ protected transient BeanContext beanContext; /** diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java index 6b5f4f5609c..24406d4e7db 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,6 +103,7 @@ public class BeanContextMembershipEvent extends BeanContextEvent { * Is the child specified affected by the event? * @return true if affected, false * if not + * @param child the object to check for being affected */ public boolean contains(Object child) { return children.contains(child); diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java index 168056c260d..0348817bfe8 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,6 +60,7 @@ public interface BeanContextServices extends BeanContext, BeanContextServicesLis * @param serviceClass the service to add * @param serviceProvider the BeanContextServiceProvider * associated with the service + * @return true if the service was successful added, false otherwise */ boolean addService(Class serviceClass, BeanContextServiceProvider serviceProvider); @@ -108,7 +109,7 @@ public interface BeanContextServices extends BeanContext, BeanContextServicesLis * @param bcsrl the * BeanContextServiceRevokedListener to notify * if the service should later become revoked - * @throws TooManyListenersException + * @throws TooManyListenersException if there are too many listeners * @return a reference to this context's named * Service as requested or null */ diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java index 94d104b14bd..ca0942efef9 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -603,12 +603,16 @@ public class BeanContextServicesSupport extends BeanContextSupport serviceProvider = bcsp; } + /** + * Returns the service provider. + * @return the service provider + */ protected BeanContextServiceProvider getServiceProvider() { return serviceProvider; } - /* - * fields + /** + * The service provider. */ protected BeanContextServiceProvider serviceProvider; @@ -618,6 +622,9 @@ public class BeanContextServicesSupport extends BeanContextSupport * subclasses can override this method to create new subclasses of * BCSSServiceProvider without having to overrride addService() in * order to instantiate. + * @param sc the class + * @param bcsp the service provider + * @return a service provider without overriding addService() */ protected BCSSServiceProvider createBCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) { @@ -629,7 +636,7 @@ public class BeanContextServicesSupport extends BeanContextSupport /** * add a BeanContextServicesListener * - * @throws NullPointerException + * @throws NullPointerException if the argument is null */ public void addBeanContextServicesListener(BeanContextServicesListener bcsl) { @@ -660,6 +667,8 @@ public class BeanContextServicesSupport extends BeanContextSupport /** * add a service + * @param serviceClass the service class + * @param bcsp the service provider */ public boolean addService(Class serviceClass, BeanContextServiceProvider bcsp) { @@ -668,6 +677,10 @@ public class BeanContextServicesSupport extends BeanContextSupport /** * add a service + * @param serviceClass the service class + * @param bcsp the service provider + * @param fireEvent whether or not an event should be fired + * @return true if the service was successfully added */ protected boolean addService(Class serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent) { @@ -709,6 +722,9 @@ public class BeanContextServicesSupport extends BeanContextSupport /** * remove a service + * @param serviceClass the service class + * @param bcsp the service provider + * @param revokeCurrentServicesNow whether or not to revoke the service */ public void revokeService(Class serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow) { @@ -1067,6 +1083,7 @@ public class BeanContextServicesSupport extends BeanContextSupport /** * Fires a BeanContextServiceEvent notifying of a new service. + * @param serviceClass the service class */ protected final void fireServiceAdded(Class serviceClass) { BeanContextServiceAvailableEvent bcssae = new BeanContextServiceAvailableEvent(getBeanContextServicesPeer(), serviceClass); @@ -1109,6 +1126,8 @@ public class BeanContextServicesSupport extends BeanContextSupport * Fires a BeanContextServiceRevokedEvent * indicating that a particular service is * no longer available. + * @param serviceClass the service class + * @param revokeNow whether or not the event should be revoked now */ protected final void fireServiceRevoked(Class serviceClass, boolean revokeNow) { Object[] copy; diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java index 85b1a5a292f..a549e2dc317 100644 --- a/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java +++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,6 @@ import java.util.Map; /** * This helper class provides a utility implementation of the * java.beans.beancontext.BeanContext interface. - *

    *

    * Since this class directly implements the BeanContext interface, the class * can, and is intended to be used either by subclassing this implementation, @@ -351,9 +350,8 @@ public class BeanContextSupport extends BeanContextChildSupport * of Child without having to override add() or the other Collection * methods that add children to the set. *

    - * * @param targetChild the child to create the Child on behalf of - * @param peer the peer if the tragetChild and the peer are related by an implementation of BeanContextProxy + * @param peer the peer if the tragetChild and the peer are related by an implementation of BeanContextProxy * @return Subtype-specific subclass of Child without overriding collection methods */ protected BCSChild createBCSChild(Object targetChild, Object peer) { @@ -492,6 +490,7 @@ public class BeanContextSupport extends BeanContextChildSupport * @param callChildSetBC used to indicate that * the child should be notified that it is no * longer nested in this BeanContext. + * @return whether or not was present before being removed */ protected boolean remove(Object targetChild, boolean callChildSetBC) { @@ -580,7 +579,8 @@ public class BeanContextSupport extends BeanContextChildSupport /** * add Collection to set of Children (Unsupported) * implementations must synchronized on the hierarchy lock and "children" protected field - * @throws UnsupportedOperationException + * @throws UnsupportedOperationException thrown unconditionally by this implementation + * @return this implementation unconditionally throws {@code UnsupportedOperationException} */ public boolean addAll(Collection c) { throw new UnsupportedOperationException(); @@ -589,7 +589,9 @@ public class BeanContextSupport extends BeanContextChildSupport /** * remove all specified children (Unsupported) * implementations must synchronized on the hierarchy lock and "children" protected field - * @throws UnsupportedOperationException + * @throws UnsupportedOperationException thrown unconditionally by this implementation + * @return this implementation unconditionally throws {@code UnsupportedOperationException} + */ public boolean removeAll(Collection c) { throw new UnsupportedOperationException(); @@ -599,7 +601,8 @@ public class BeanContextSupport extends BeanContextChildSupport /** * retain only specified children (Unsupported) * implementations must synchronized on the hierarchy lock and "children" protected field - * @throws UnsupportedOperationException + * @throws UnsupportedOperationException thrown unconditionally by this implementation + * @return this implementation unconditionally throws {@code UnsupportedOperationException} */ public boolean retainAll(Collection c) { throw new UnsupportedOperationException(); @@ -608,7 +611,7 @@ public class BeanContextSupport extends BeanContextChildSupport /** * clear the children (Unsupported) * implementations must synchronized on the hierarchy lock and "children" protected field - * @throws UnsupportedOperationException + * @throws UnsupportedOperationException thrown unconditionally by this implementation */ public void clear() { throw new UnsupportedOperationException(); @@ -618,7 +621,7 @@ public class BeanContextSupport extends BeanContextChildSupport * Adds a BeanContextMembershipListener * * @param bcml the BeanContextMembershipListener to add - * @throws NullPointerException + * @throws NullPointerException if the argument is null */ public void addBeanContextMembershipListener(BeanContextMembershipListener bcml) { @@ -636,7 +639,7 @@ public class BeanContextSupport extends BeanContextChildSupport * Removes a BeanContextMembershipListener * * @param bcml the BeanContextMembershipListener to remove - * @throws NullPointerException + * @throws NullPointerException if the argument is null */ public void removeBeanContextMembershipListener(BeanContextMembershipListener bcml) { @@ -655,7 +658,7 @@ public class BeanContextSupport extends BeanContextChildSupport * @param bcc the child object making the request. * * @return the requested resource as an InputStream - * @throws NullPointerException + * @throws NullPointerException if the argument is null */ public InputStream getResourceAsStream(String name, BeanContextChild bcc) { @@ -849,6 +852,8 @@ public class BeanContextSupport extends BeanContextChildSupport * * This method should not however be used by subclasses to replace their * own implementation (if any) of writeObject(). + * @param oos the {@code ObjectOutputStream} to use during serialization + * @throws IOException if serialization failed */ protected void bcsPreSerializationHook(ObjectOutputStream oos) throws IOException { @@ -864,6 +869,9 @@ public class BeanContextSupport extends BeanContextChildSupport * * This method should not however be used by subclasses to replace their * own implementation (if any) of readObject(). + * @param ois the {@code ObjectInputStream} to use during deserialization + * @throws IOException if deserialization failed + * @throws ClassNotFoundException if needed classes are not found */ protected void bcsPreDeserializationHook(ObjectInputStream ois) throws IOException, ClassNotFoundException { @@ -914,6 +922,8 @@ public class BeanContextSupport extends BeanContextChildSupport * used by readObject to deserialize a collection. * @param ois the ObjectInputStream to use * @param coll the Collection + * @throws IOException if deserialization failed + * @throws ClassNotFoundException if needed classes are not found */ protected final void deserialize(ObjectInputStream ois, Collection coll) throws IOException, ClassNotFoundException { int count = 0; @@ -1005,6 +1015,9 @@ public class BeanContextSupport extends BeanContextChildSupport * When an instance of this class is used as a delegate for the * implementation of the BeanContext protocols (and its subprotocols) * there exists a 'chicken and egg' problem during deserialization + * @param ois the ObjectInputStream to use + * @throws IOException if deserialization failed + * @throws ClassNotFoundException if needed classes are not found */ public final void readChildren(ObjectInputStream ois) throws IOException, ClassNotFoundException { @@ -1122,6 +1135,7 @@ public class BeanContextSupport extends BeanContextChildSupport * immediately prior to their being added to the BeanContext. *

    * + * @param targetChild the child to create the Child on behalf of * @return true iff the child may be added to this BeanContext, otherwise false. */ @@ -1136,6 +1150,7 @@ public class BeanContextSupport extends BeanContextChildSupport * immediately prior to their being removed from the BeanContext. *

    * + * @param targetChild the child to create the Child on behalf of * @return true iff the child may be removed from this BeanContext, otherwise false. */ @@ -1147,6 +1162,8 @@ public class BeanContextSupport extends BeanContextChildSupport * subclasses may override this method to simply extend add() semantics * after the child has been added and before the event notification has * occurred. The method is called with the child synchronized. + * @param child the child + * @param bcsc the BCSChild */ protected void childJustAddedHook(Object child, BCSChild bcsc) { @@ -1156,6 +1173,8 @@ public class BeanContextSupport extends BeanContextChildSupport * subclasses may override this method to simply extend remove() semantics * after the child has been removed and before the event notification has * occurred. The method is called with the child synchronized. + * @param child the child + * @param bcsc the BCSChild */ protected void childJustRemovedHook(Object child, BCSChild bcsc) { @@ -1254,6 +1273,7 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Fire a BeanContextshipEvent on the BeanContextMembershipListener interface + * @param bcme the event to fire */ protected final void fireChildrenAdded(BeanContextMembershipEvent bcme) { @@ -1267,6 +1287,7 @@ public class BeanContextSupport extends BeanContextChildSupport /** * Fire a BeanContextshipEvent on the BeanContextMembershipListener interface + * @param bcme the event to fire */ protected final void fireChildrenRemoved(BeanContextMembershipEvent bcme) { From e11ec149ced43f1ac5fac7f4ab3bba94d5ce0703 Mon Sep 17 00:00:00 2001 From: Brian Goetz Date: Fri, 28 Jun 2013 16:26:54 -0400 Subject: [PATCH 030/118] 8015318: Extend Collector with 'finish' operation Reviewed-by: mduigou --- .../java/util/DoubleSummaryStatistics.java | 15 +- .../java/util/IntSummaryStatistics.java | 15 +- .../java/util/LongSummaryStatistics.java | 17 +- .../share/classes/java/util/StringJoiner.java | 7 +- .../classes/java/util/stream/Collector.java | 222 +++-- .../classes/java/util/stream/Collectors.java | 865 ++++++++++-------- .../java/util/stream/DelegatingStream.java | 2 +- .../java/util/stream/DoubleStream.java | 2 +- .../classes/java/util/stream/IntStream.java | 2 +- .../classes/java/util/stream/LongStream.java | 2 +- .../classes/java/util/stream/ReduceOps.java | 22 +- .../java/util/stream/ReferencePipeline.java | 17 +- .../classes/java/util/stream/Stream.java | 3 +- .../java/util/stream/package-info.java | 4 +- .../tests/java/util/FillableStringTest.java | 6 +- .../tests/java/util/stream/GroupByOpTest.java | 12 +- .../util/stream/SummaryStatisticsTest.java | 12 +- .../java/util/stream/TabulatorsTest.java | 222 ++++- .../MethodReferenceTestInstanceMethod.java | 2 +- jdk/test/jdk/lambda/separate/TestHarness.java | 4 +- 20 files changed, 909 insertions(+), 544 deletions(-) diff --git a/jdk/src/share/classes/java/util/DoubleSummaryStatistics.java b/jdk/src/share/classes/java/util/DoubleSummaryStatistics.java index fb79c56660b..63c887e23ce 100644 --- a/jdk/src/share/classes/java/util/DoubleSummaryStatistics.java +++ b/jdk/src/share/classes/java/util/DoubleSummaryStatistics.java @@ -25,6 +25,7 @@ package java.util; import java.util.function.DoubleConsumer; +import java.util.stream.Collector; /** * A state object for collecting statistics such as count, min, max, sum, and @@ -35,24 +36,24 @@ import java.util.function.DoubleConsumer; * summary statistics on a stream of doubles with: *
     {@code
      * DoubleSummaryStatistics stats = doubleStream.collect(DoubleSummaryStatistics::new,
    - *     DoubleSummaryStatistics::accept,
    - *     DoubleSummaryStatistics::combine);
    + *                                                      DoubleSummaryStatistics::accept,
    + *                                                      DoubleSummaryStatistics::combine);
      * }
    * *

    {@code DoubleSummaryStatistics} can be used as a - * {@linkplain java.util.stream.Stream#reduce(java.util.function.BinaryOperator) reduction} + * {@linkplain java.util.stream.Stream#collect(Collector) reduction} * target for a {@linkplain java.util.stream.Stream stream}. For example: * *

     {@code
      * DoubleSummaryStatistics stats = people.stream()
    - *     .collect(Collectors.toDoubleSummaryStatistics(Person::getWeight));
    + *     .collect(Collectors.summarizingDouble(Person::getWeight));
      *}
    * * This computes, in a single pass, the count of people, as well as the minimum, * maximum, sum, and average of their weights. * * @implNote This implementation is not thread safe. However, it is safe to use - * {@link java.util.stream.Collectors#toDoubleSummaryStatistics(java.util.function.ToDoubleFunction) + * {@link java.util.stream.Collectors#summarizingDouble(java.util.function.ToDoubleFunction) * Collectors.toDoubleStatistics()} on a parallel stream, because the parallel * implementation of {@link java.util.stream.Stream#collect Stream.collect()} * provides the necessary partitioning, isolation, and merging of results for @@ -152,7 +153,7 @@ public class DoubleSummaryStatistics implements DoubleConsumer { } /** - * Returns the average of values recorded, or zero if no values have been + * Returns the arithmetic mean of values recorded, or zero if no values have been * recorded. The average returned can vary depending upon the order in * which values are recorded. This is due to accumulated rounding error in * addition of values of differing magnitudes. Values sorted by increasing @@ -160,7 +161,7 @@ public class DoubleSummaryStatistics implements DoubleConsumer { * value is a {@code NaN} or the sum is at any point a {@code NaN} then the * average will be {@code NaN}. * - * @return the average of values, or zero if none + * @return the arithmetic mean of values, or zero if none */ public final double getAverage() { return getCount() > 0 ? getSum() / getCount() : 0.0d; diff --git a/jdk/src/share/classes/java/util/IntSummaryStatistics.java b/jdk/src/share/classes/java/util/IntSummaryStatistics.java index fcca3296f85..f93436e7017 100644 --- a/jdk/src/share/classes/java/util/IntSummaryStatistics.java +++ b/jdk/src/share/classes/java/util/IntSummaryStatistics.java @@ -25,6 +25,7 @@ package java.util; import java.util.function.IntConsumer; +import java.util.stream.Collector; /** * A state object for collecting statistics such as count, min, max, sum, and @@ -35,24 +36,24 @@ import java.util.function.IntConsumer; * summary statistics on a stream of ints with: *
     {@code
      * IntSummaryStatistics stats = intStream.collect(IntSummaryStatistics::new,
    - *     IntSummaryStatistics::accept,
    - *     IntSummaryStatistics::combine);
    + *                                                IntSummaryStatistics::accept,
    + *                                                IntSummaryStatistics::combine);
      * }
    * *

    {@code IntSummaryStatistics} can be used as a - * {@linkplain java.util.stream.Stream#reduce(java.util.function.BinaryOperator) reduction} + * {@linkplain java.util.stream.Stream#collect(Collector) reduction} * target for a {@linkplain java.util.stream.Stream stream}. For example: * *

     {@code
      * IntSummaryStatistics stats = people.stream()
    - *     .collect(Collectors.toIntSummaryStatistics(Person::getDependents));
    + *                                    .collect(Collectors.summarizingInt(Person::getDependents));
      *}
    * * This computes, in a single pass, the count of people, as well as the minimum, * maximum, sum, and average of their number of dependents. * * @implNote This implementation is not thread safe. However, it is safe to use - * {@link java.util.stream.Collectors#toIntSummaryStatistics(java.util.function.ToIntFunction) + * {@link java.util.stream.Collectors#summarizingInt(java.util.function.ToIntFunction) * Collectors.toIntStatistics()} on a parallel stream, because the parallel * implementation of {@link java.util.stream.Stream#collect Stream.collect()} * provides the necessary partitioning, isolation, and merging of results for @@ -140,10 +141,10 @@ public class IntSummaryStatistics implements IntConsumer { } /** - * Returns the average of values recorded, or zero if no values have been + * Returns the arithmetic mean of values recorded, or zero if no values have been * recorded. * - * @return the average of values, or zero if none + * @return the arithmetic mean of values, or zero if none */ public final double getAverage() { return getCount() > 0 ? (double) getSum() / getCount() : 0.0d; diff --git a/jdk/src/share/classes/java/util/LongSummaryStatistics.java b/jdk/src/share/classes/java/util/LongSummaryStatistics.java index 0e2da71f8bc..085aa298075 100644 --- a/jdk/src/share/classes/java/util/LongSummaryStatistics.java +++ b/jdk/src/share/classes/java/util/LongSummaryStatistics.java @@ -26,6 +26,7 @@ package java.util; import java.util.function.IntConsumer; import java.util.function.LongConsumer; +import java.util.stream.Collector; /** * A state object for collecting statistics such as count, min, max, sum, and @@ -36,24 +37,24 @@ import java.util.function.LongConsumer; * summary statistics on a stream of longs with: *
     {@code
      * LongSummaryStatistics stats = longStream.collect(LongSummaryStatistics::new,
    - *     LongSummaryStatistics::accept,
    - *     LongSummaryStatistics::combine);
    + *                                                  LongSummaryStatistics::accept,
    + *                                                  LongSummaryStatistics::combine);
      * }
    * *

    {@code LongSummaryStatistics} can be used as a - * {@linkplain java.util.stream.Stream#reduce(java.util.function.BinaryOperator) reduction} + * {@linkplain java.util.stream.Stream#collect(Collector)} reduction} * target for a {@linkplain java.util.stream.Stream stream}. For example: * *

     {@code
      * LongSummaryStatistics stats = people.stream()
    - *     .collect(Collectors.toLongSummaryStatistics(Person::getAge));
    + *                                     .collect(Collectors.summarizingLong(Person::getAge));
      *}
    * * This computes, in a single pass, the count of people, as well as the minimum, - * maximum, sum, and average of their ages in milliseconds. + * maximum, sum, and average of their ages. * * @implNote This implementation is not thread safe. However, it is safe to use - * {@link java.util.stream.Collectors#toLongSummaryStatistics(java.util.function.ToLongFunction) + * {@link java.util.stream.Collectors#summarizingLong(java.util.function.ToLongFunction) * Collectors.toLongStatistics()} on a parallel stream, because the parallel * implementation of {@link java.util.stream.Stream#collect Stream.collect()} * provides the necessary partitioning, isolation, and merging of results for @@ -152,10 +153,10 @@ public class LongSummaryStatistics implements LongConsumer, IntConsumer { } /** - * Returns the average of values recorded, or zero if no values have been + * Returns the arithmetic mean of values recorded, or zero if no values have been * recorded. * - * @return The average of values, or zero if none + * @return The arithmetic mean of values, or zero if none */ public final double getAverage() { return getCount() > 0 ? (double) getSum() / getCount() : 0.0d; diff --git a/jdk/src/share/classes/java/util/StringJoiner.java b/jdk/src/share/classes/java/util/StringJoiner.java index 66d49b64f0a..d4050a4afd5 100644 --- a/jdk/src/share/classes/java/util/StringJoiner.java +++ b/jdk/src/share/classes/java/util/StringJoiner.java @@ -49,16 +49,17 @@ package java.util; *

    * A {@code StringJoiner} may be employed to create formatted output from a * {@link java.util.stream.Stream} using - * {@link java.util.stream.Collectors#toStringJoiner}. For example: + * {@link java.util.stream.Collectors#joining(CharSequence)}. For example: * *

     {@code
      * List numbers = Arrays.asList(1, 2, 3, 4);
      * String commaSeparatedNumbers = numbers.stream()
      *     .map(i -> i.toString())
    - *     .collect(Collectors.toStringJoiner(", ")).toString();
    + *     .collect(Collectors.joining(", "));
      * }
    * - * @see java.util.stream.Collectors#toStringJoiner + * @see java.util.stream.Collectors#joining(CharSequence) + * @see java.util.stream.Collectors#joining(CharSequence, CharSequence, CharSequence) * @since 1.8 */ public final class StringJoiner { diff --git a/jdk/src/share/classes/java/util/stream/Collector.java b/jdk/src/share/classes/java/util/stream/Collector.java index 71bb2276f7b..49629176032 100644 --- a/jdk/src/share/classes/java/util/stream/Collector.java +++ b/jdk/src/share/classes/java/util/stream/Collector.java @@ -25,40 +25,45 @@ package java.util.stream; import java.util.Collections; +import java.util.EnumSet; import java.util.Set; -import java.util.function.BiFunction; +import java.util.function.BiConsumer; import java.util.function.BinaryOperator; +import java.util.function.Function; import java.util.function.Supplier; /** * A reduction operation that - * supports folding input elements into a cumulative result. The result may be - * a value or may be a mutable result container. Examples of operations - * accumulating results into a mutable result container include: accumulating - * input elements into a {@code Collection}; concatenating strings into a - * {@code StringBuilder}; computing summary information about elements such as - * sum, min, max, or average; computing "pivot table" summaries such as "maximum - * valued transaction by seller", etc. Reduction operations can be performed - * either sequentially or in parallel. + * folds input elements into a mutable result container, optionally transforming + * the accumulated result into a final representation after all input elements + * have been processed. + * + *

    Examples of mutable reduction operations include: + * accumulating elements into a {@code Collection}; concatenating + * strings using a {@code StringBuilder}; computing summary information about + * elements such as sum, min, max, or average; computing "pivot table" summaries + * such as "maximum valued transaction by seller", etc. Reduction operations + * can be performed either sequentially or in parallel. * *

    The following are examples of using the predefined {@code Collector} * implementations in {@link Collectors} with the {@code Stream} API to perform * mutable reduction tasks: *

    {@code
    - *     // Accumulate elements into a List
    - *     List list = stream.collect(Collectors.toList());
    + *     // Accumulate names into a List
    + *     List list = people.stream().map(Person::getName).collect(Collectors.toList());
      *
    - *     // Accumulate elements into a TreeSet
    - *     Set list = stream.collect(Collectors.toCollection(TreeSet::new));
    + *     // Accumulate names into a TreeSet
    + *     Set list = people.stream().map(Person::getName).collect(Collectors.toCollection(TreeSet::new));
      *
      *     // Convert elements to strings and concatenate them, separated by commas
    - *     String joined = stream.map(Object::toString)
    - *                           .collect(Collectors.toStringJoiner(", "))
    - *                           .toString();
    + *     String joined = things.stream()
    + *                           .map(Object::toString)
    + *                           .collect(Collectors.joining(", "));
      *
      *     // Find highest-paid employee
      *     Employee highestPaid = employees.stream()
    - *                                     .collect(Collectors.maxBy(Comparators.comparing(Employee::getSalary)));
    + *                                     .collect(Collectors.maxBy(Comparators.comparing(Employee::getSalary)))
    + *                                     .get();
      *
      *     // Group employees by department
      *     Map> byDept
    @@ -66,7 +71,7 @@ import java.util.function.Supplier;
      *                    .collect(Collectors.groupingBy(Employee::getDepartment));
      *
      *     // Find highest-paid employee by department
    - *     Map highestPaidByDept
    + *     Map> highestPaidByDept
      *         = employees.stream()
      *                    .collect(Collectors.groupingBy(Employee::getDepartment,
      *                                                   Collectors.maxBy(Comparators.comparing(Employee::getSalary))));
    @@ -74,43 +79,42 @@ import java.util.function.Supplier;
      *     // Partition students into passing and failing
      *     Map> passingFailing =
      *         students.stream()
    - *                 .collect(Collectors.partitioningBy(s -> s.getGrade() >= PASS_THRESHOLD);
    + *                 .collect(Collectors.partitioningBy(s -> s.getGrade() >= PASS_THRESHOLD));
      *
      * }
    * - *

    A {@code Collector} is specified by three functions that work together to - * manage a result or result container. They are: creation of an initial - * result, incorporating a new data element into a result, and combining two - * results into one. The last function -- combining two results into one -- is - * used during parallel operations, where subsets of the input are accumulated - * in parallel, and then the subresults merged into a combined result. The - * result may be a mutable container or a value. If the result is mutable, the - * accumulation and combination functions may either mutate their left argument - * and return that (such as adding elements to a collection), or return a new - * result, in which case it should not perform any mutation. + *

    A {@code Collector} is specified by four functions that work together to + * accumulate entries into a mutable result container, and optionally perform + * a final transform on the result. They are: creation of a new result container, + * incorporating a new data element into a result container, combining two + * result containers into one, and performing a final transform on the container. + * The combiner function is used during parallel operations, where + * subsets of the input are accumulated into separate result + * containers, and then the subresults merged into a combined result. The + * combiner function may merge one set of subresults into the other and return + * that, or it may return a new object to describe the combined results. * - *

    Collectors also have a set of characteristics, including - * {@link Characteristics#CONCURRENT} and - * {@link Characteristics#STRICTLY_MUTATIVE}. These characteristics provide + *

    Collectors also have a set of characteristics, such as + * {@link Characteristics#CONCURRENT}. These characteristics provide * hints that can be used by a reduction implementation to provide better * performance. * *

    Libraries that implement reduction based on {@code Collector}, such as * {@link Stream#collect(Collector)}, must adhere to the following constraints: *

    Audio System Property Keys
    Property KeyInterface
    - * + * * @@ -57,7 +57,7 @@ import javax.print.attribute.PrintJobAttribute; * * * * * * * * * * * * @@ -60,13 +60,13 @@ import javax.print.attribute.PrintJobAttribute; *   * * * * * * * * * * * * * * * * * * * * * *
    * Chromaticity
    Attribute *
    - * {@link #MONOCHROME MONOCHROME} + * {@link #MONOCHROME MONOCHROME} * * Printed as is, in monochrome @@ -68,7 +68,7 @@ import javax.print.attribute.PrintJobAttribute; *
    - * {@link #COLOR COLOR} + * {@link #COLOR COLOR} * * Printed as is, in monochrome diff --git a/jdk/src/share/classes/javax/print/attribute/standard/Compression.java b/jdk/src/share/classes/javax/print/attribute/standard/Compression.java index 19c94b45f4e..5679a73f850 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/Compression.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/Compression.java @@ -34,7 +34,7 @@ import javax.print.attribute.DocAttribute; * print data (the doc), not of the Print Job. If a Compression attribute is not * specified for a doc, the printer assumes the doc's print data is uncompressed * (i.e., the default Compression value is always {@link #NONE - * NONE}). + * NONE}). *

    * IPP Compatibility: The category name returned by * getName() is the IPP attribute name. The enumeration's diff --git a/jdk/src/share/classes/javax/print/attribute/standard/Finishings.java b/jdk/src/share/classes/javax/print/attribute/standard/Finishings.java index cebbf7b6f2a..3f09cd9088f 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/Finishings.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/Finishings.java @@ -46,13 +46,13 @@ import javax.print.attribute.PrintJobAttribute; *   *

    - * {@link #NONE NONE} + * {@link #NONE NONE} * - * {@link #STAPLE STAPLE} + * {@link #STAPLE STAPLE} * - * {@link #EDGE_STITCH EDGE_STITCH} + * {@link #EDGE_STITCH EDGE_STITCH} *
    - * {@link #BIND BIND} + * {@link #BIND BIND} * - * {@link #SADDLE_STITCH SADDLE_STITCH} + * {@link #SADDLE_STITCH SADDLE_STITCH} * - * {@link #COVER COVER} + * {@link #COVER COVER} * *   @@ -82,13 +82,13 @@ import javax.print.attribute.PrintJobAttribute; *   * - * {@link #STAPLE_TOP_LEFT STAPLE_TOP_LEFT} + * {@link #STAPLE_TOP_LEFT STAPLE_TOP_LEFT} * - * {@link #EDGE_STITCH_LEFT EDGE_STITCH_LEFT} + * {@link #EDGE_STITCH_LEFT EDGE_STITCH_LEFT} * - * {@link #STAPLE_DUAL_LEFT STAPLE_DUAL_LEFT} + * {@link #STAPLE_DUAL_LEFT STAPLE_DUAL_LEFT} * *   @@ -99,13 +99,13 @@ import javax.print.attribute.PrintJobAttribute; *   * - * {@link #STAPLE_BOTTOM_LEFT STAPLE_BOTTOM_LEFT} + * {@link #STAPLE_BOTTOM_LEFT STAPLE_BOTTOM_LEFT} * - * {@link #EDGE_STITCH_TOP EDGE_STITCH_TOP} + * {@link #EDGE_STITCH_TOP EDGE_STITCH_TOP} * - * {@link #STAPLE_DUAL_TOP STAPLE_DUAL_TOP} + * {@link #STAPLE_DUAL_TOP STAPLE_DUAL_TOP} * *   @@ -116,13 +116,13 @@ import javax.print.attribute.PrintJobAttribute; *   * - * {@link #STAPLE_TOP_RIGHT STAPLE_TOP_RIGHT} + * {@link #STAPLE_TOP_RIGHT STAPLE_TOP_RIGHT} * - * {@link #EDGE_STITCH_RIGHT EDGE_STITCH_RIGHT} + * {@link #EDGE_STITCH_RIGHT EDGE_STITCH_RIGHT} * - * {@link #STAPLE_DUAL_RIGHT STAPLE_DUAL_RIGHT} + * {@link #STAPLE_DUAL_RIGHT STAPLE_DUAL_RIGHT} * *   @@ -133,13 +133,13 @@ import javax.print.attribute.PrintJobAttribute; *   * - * {@link #STAPLE_BOTTOM_RIGHT STAPLE_BOTTOM_RIGHT} + * {@link #STAPLE_BOTTOM_RIGHT STAPLE_BOTTOM_RIGHT} * - * {@link #EDGE_STITCH_BOTTOM EDGE_STITCH_BOTTOM} + * {@link #EDGE_STITCH_BOTTOM EDGE_STITCH_BOTTOM} * - * {@link #STAPLE_DUAL_BOTTOM STAPLE_DUAL_BOTTOM} + * {@link #STAPLE_DUAL_BOTTOM STAPLE_DUAL_BOTTOM} * *   @@ -147,16 +147,16 @@ import javax.print.attribute.PrintJobAttribute; *
    *

    - * The STAPLE_XXX values are specified with respect to the + * The STAPLE_XXX values are specified with respect to the * document as if the document were a portrait document. If the document is * actually a landscape or a reverse-landscape document, the client supplies the * appropriate transformed value. For example, to position a staple in the upper * left hand corner of a landscape document when held for reading, the client - * supplies the STAPLE_BOTTOM_LEFT value (since landscape is + * supplies the STAPLE_BOTTOM_LEFT value (since landscape is * defined as a +90 degree rotation from portrait, i.e., anti-clockwise). On the * other hand, to position a staple in the upper left hand corner of a * reverse-landscape document when held for reading, the client supplies the - * STAPLE_TOP_RIGHT value (since reverse-landscape is defined as a + * STAPLE_TOP_RIGHT value (since reverse-landscape is defined as a * -90 degree rotation from portrait, i.e., clockwise). *

    * The angle (vertical, horizontal, angled) of each staple with respect to the diff --git a/jdk/src/share/classes/javax/print/attribute/standard/JobKOctets.java b/jdk/src/share/classes/javax/print/attribute/standard/JobKOctets.java index 8f29b7b2c66..f5b16307df9 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/JobKOctets.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/JobKOctets.java @@ -67,7 +67,7 @@ import javax.print.attribute.PrintJobAttribute; * shown in the table below. *

    * - * + * * * * diff --git a/jdk/src/share/classes/javax/print/attribute/standard/MediaPrintableArea.java b/jdk/src/share/classes/javax/print/attribute/standard/MediaPrintableArea.java index dbb50f633cc..a800f7c6c42 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/MediaPrintableArea.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/MediaPrintableArea.java @@ -62,7 +62,7 @@ import javax.print.attribute.PrintRequestAttribute; * The (x,y) origin is positioned at the top-left of the paper in portrait * mode regardless of the orientation specified in the requesting context. * For example a printable area for A4 paper in portrait or landscape - * orientation will have height > width. + * orientation will have height {@literal >} width. *

    * A printable area attribute's values are stored * internally as integers in units of micrometers (µm), where 1 micrometer @@ -107,9 +107,9 @@ public final class MediaPrintableArea * @param units in which the values are expressed. * * @exception IllegalArgumentException - * Thrown if x < 0 or y < 0 - * or w <= 0 or h <= 0 or - * units < 1. + * Thrown if {@code x < 0} or {@code y < 0} + * or {@code w <= 0} or {@code h <= 0} or + * {@code units < 1}. */ public MediaPrintableArea(float x, float y, float w, float h, int units) { if ((x < 0.0) || (y < 0.0) || (w <= 0.0) || (h <= 0.0) || @@ -133,9 +133,9 @@ public final class MediaPrintableArea * @param units in which the values are expressed. * * @exception IllegalArgumentException - * Thrown if x < 0 or y < 0 - * or w <= 0 or h <= 0 or - * units < 1. + * Thrown if {@code x < 0} or {@code y < 0} + * or {@code w <= 0} or {@code h <= 0} or + * {@code units < 1}. */ public MediaPrintableArea(int x, int y, int w, int h, int units) { if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || @@ -159,7 +159,7 @@ public final class MediaPrintableArea * @return printable area as array of x, y, w, h in the specified units. * * @exception IllegalArgumentException - * (unchecked exception) Thrown if units < 1. + * (unchecked exception) Thrown if {@code units < 1}. */ public float[] getPrintableArea(int units) { return new float[] { getX(units), getY(units), @@ -177,7 +177,7 @@ public final class MediaPrintableArea * specified units. * * @exception IllegalArgumentException - * (unchecked exception) Thrown if units < 1. + * (unchecked exception) Thrown if {@code units < 1}. */ public float getX(int units) { return convertFromMicrometers(x, units); @@ -194,7 +194,7 @@ public final class MediaPrintableArea * specified units. * * @exception IllegalArgumentException - * (unchecked exception) Thrown if units < 1. + * (unchecked exception) Thrown if {@code units < 1}. */ public float getY(int units) { return convertFromMicrometers(y, units); @@ -209,7 +209,7 @@ public final class MediaPrintableArea * @return width of the printable area in the specified units. * * @exception IllegalArgumentException - * (unchecked exception) Thrown if units < 1. + * (unchecked exception) Thrown if {@code units < 1}. */ public float getWidth(int units) { return convertFromMicrometers(w, units); @@ -224,7 +224,7 @@ public final class MediaPrintableArea * @return height of the printable area in the specified units. * * @exception IllegalArgumentException - * (unchecked exception) Thrown if units < 1. + * (unchecked exception) Thrown if {@code units < 1}. */ public float getHeight(int units) { return convertFromMicrometers(h, units); @@ -301,7 +301,7 @@ public final class MediaPrintableArea * @return String version of this two-dimensional size attribute. * * @exception IllegalArgumentException - * (unchecked exception) Thrown if units < 1. + * (unchecked exception) Thrown if {@code units < 1}. */ public String toString(int units, String unitsName) { if (unitsName == null) { diff --git a/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java b/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java index 9f35e34a23a..1d6677fb674 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java @@ -45,7 +45,7 @@ import javax.print.attribute.Attribute; * MediaSize.getMediaSizeForName(MediaSizeName) * to find the physical dimensions of the MediaSizeName instances * enumerated in this API. This is useful for clients which need this - * information to format & paginate printing. + * information to format {@literal &} paginate printing. *

    * * @author Phil Race, Alan Kaminsky @@ -71,8 +71,8 @@ public class MediaSize extends Size2DSyntax implements Attribute { * Size2DSyntax.MM. * * @exception IllegalArgumentException - * (Unchecked exception) Thrown if x < 0 or y - * < 0 or units < 1 or x > y. + * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or + * {@code units < 1} or {@code x > y}. */ public MediaSize(float x, float y,int units) { super (x, y, units); @@ -92,8 +92,8 @@ public class MediaSize extends Size2DSyntax implements Attribute { * Size2DSyntax.MM. * * @exception IllegalArgumentException - * (Unchecked exception) Thrown if x < 0 or y - * < 0 or units < 1 or x > y. + * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or + * {@code units < 1} or {@code x > y}. */ public MediaSize(int x, int y,int units) { super (x, y, units); @@ -115,8 +115,8 @@ public class MediaSize extends Size2DSyntax implements Attribute { * @param media a media name to associate with this MediaSize * * @exception IllegalArgumentException - * (Unchecked exception) Thrown if x < 0 or y - * < 0 or units < 1 or x > y. + * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or + * {@code units < 1} or {@code x > y}. */ public MediaSize(float x, float y,int units, MediaSizeName media) { super (x, y, units); @@ -141,8 +141,8 @@ public class MediaSize extends Size2DSyntax implements Attribute { * @param media a media name to associate with this MediaSize * * @exception IllegalArgumentException - * (Unchecked exception) Thrown if x < 0 or y - * < 0 or units < 1 or x > y. + * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or + * {@code units < 1} or {@code x > y}. */ public MediaSize(int x, int y,int units, MediaSizeName media) { super (x, y, units); @@ -194,7 +194,8 @@ public class MediaSize extends Size2DSyntax implements Attribute { * Unit conversion factor, e.g. Size2DSyntax.INCH or * Size2DSyntax.MM * @return MediaSizeName matching these dimensions, or null. - * @exception IllegalArgumentException if x <= 0, y <= 0, or units < 1 + * @exception IllegalArgumentException if {@code x <= 0}, + * {@code y <= 0}, or {@code units < 1}. * */ public static MediaSizeName findMedia(float x, float y, int units) { diff --git a/jdk/src/share/classes/javax/print/attribute/standard/PresentationDirection.java b/jdk/src/share/classes/javax/print/attribute/standard/PresentationDirection.java index 0ac7c93c8ce..88e3a445cd0 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/PresentationDirection.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/PresentationDirection.java @@ -56,56 +56,56 @@ public final class PresentationDirection extends EnumSyntax /** * Pages are laid out in columns starting at the top left, - * proceeeding towards the bottom & right. + * proceeeding towards the bottom {@literal &} right. */ public static final PresentationDirection TOBOTTOM_TORIGHT = new PresentationDirection(0); /** * Pages are laid out in columns starting at the top right, - * proceeeding towards the bottom & left. + * proceeeding towards the bottom {@literal &} left. */ public static final PresentationDirection TOBOTTOM_TOLEFT = new PresentationDirection(1); /** * Pages are laid out in columns starting at the bottom left, - * proceeeding towards the top & right. + * proceeeding towards the top {@literal &} right. */ public static final PresentationDirection TOTOP_TORIGHT = new PresentationDirection(2); /** * Pages are laid out in columns starting at the bottom right, - * proceeeding towards the top & left. + * proceeeding towards the top {@literal &} left. */ public static final PresentationDirection TOTOP_TOLEFT = new PresentationDirection(3); /** * Pages are laid out in rows starting at the top left, - * proceeeding towards the right & bottom. + * proceeeding towards the right {@literal &} bottom. */ public static final PresentationDirection TORIGHT_TOBOTTOM = new PresentationDirection(4); /** * Pages are laid out in rows starting at the bottom left, - * proceeeding towards the right & top. + * proceeeding towards the right {@literal &} top. */ public static final PresentationDirection TORIGHT_TOTOP = new PresentationDirection(5); /** * Pages are laid out in rows starting at the top right, - * proceeeding towards the left & bottom. + * proceeeding towards the left {@literal &} bottom. */ public static final PresentationDirection TOLEFT_TOBOTTOM = new PresentationDirection(6); /** * Pages are laid out in rows starting at the bottom right, - * proceeeding towards the left & top. + * proceeeding towards the left {@literal &} top. */ public static final PresentationDirection TOLEFT_TOTOP = new PresentationDirection(7); diff --git a/jdk/src/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java b/jdk/src/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java index a6be2838a27..8d507d54389 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java @@ -40,7 +40,7 @@ import javax.print.attribute.PrintServiceAttribute; * details on color support). The information is intended to be germane to * this kind of printer without regard to site specific modifications or * services. - *

    * In contrast, the {@link PrinterMoreInfo PrinterMoreInfo} attribute is used * to find out more information about this specific printer rather than this * general kind of printer. diff --git a/jdk/src/share/classes/javax/print/attribute/standard/PrinterResolution.java b/jdk/src/share/classes/javax/print/attribute/standard/PrinterResolution.java index 8ca5100c48a..e4ad0486496 100644 --- a/jdk/src/share/classes/javax/print/attribute/standard/PrinterResolution.java +++ b/jdk/src/share/classes/javax/print/attribute/standard/PrinterResolution.java @@ -84,11 +84,11 @@ public final class PrinterResolution extends ResolutionSyntax * Feed direction resolution. * @param units * Unit conversion factor, e.g. ResolutionSyntax.DPI - * or ResolutionSyntax.>DPCM. + * or ResolutionSyntax.DPCM. * * @exception IllegalArgumentException - * (unchecked exception) Thrown if crossFeedResolution < - * 1 or feedResolution < 1 or units < 1. + * (unchecked exception) Thrown if {@code crossFeedResolution < 1} or + * {@code feedResolution < 1} or {@code units < 1}. */ public PrinterResolution(int crossFeedResolution, int feedResolution, int units) { From d75477b14780e2b1f4b60251ff727a622573ba34 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Tue, 6 Aug 2013 14:22:48 -0700 Subject: [PATCH 056/118] 8021583: test/javax/print/autosense/PrintAutoSenseData.java throwing NPE Reviewed-by: jchen, prr --- jdk/src/solaris/classes/sun/print/UnixPrintJob.java | 4 ++++ jdk/src/windows/classes/sun/print/Win32PrintJob.java | 4 ++++ .../javax/print/attribute/autosense/PrintAutoSenseData.java | 2 +- jdk/test/javax/print/attribute/autosense/sample.txt | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 jdk/test/javax/print/attribute/autosense/sample.txt diff --git a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java index b394884e81e..69ff359cca3 100644 --- a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java +++ b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java @@ -334,6 +334,10 @@ public class UnixPrintJob implements CancelablePrintJob { throw new PrintException("can't get print data: " + e.toString()); } + if (data == null) { + throw new PrintException("Null print data."); + } + if (flavor == null || (!service.isDocFlavorSupported(flavor))) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobFlavorException("invalid flavor", flavor); diff --git a/jdk/src/windows/classes/sun/print/Win32PrintJob.java b/jdk/src/windows/classes/sun/print/Win32PrintJob.java index 2428edf5572..844f3ee4f22 100644 --- a/jdk/src/windows/classes/sun/print/Win32PrintJob.java +++ b/jdk/src/windows/classes/sun/print/Win32PrintJob.java @@ -340,6 +340,10 @@ public class Win32PrintJob implements CancelablePrintJob { throw new PrintException("can't get print data: " + e.toString()); } + if (data == null) { + throw new PrintException("Null print data."); + } + if (flavor == null || (!service.isDocFlavorSupported(flavor))) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobFlavorException("invalid flavor", flavor); diff --git a/jdk/test/javax/print/attribute/autosense/PrintAutoSenseData.java b/jdk/test/javax/print/attribute/autosense/PrintAutoSenseData.java index 307408fe082..214b9ad339b 100644 --- a/jdk/test/javax/print/attribute/autosense/PrintAutoSenseData.java +++ b/jdk/test/javax/print/attribute/autosense/PrintAutoSenseData.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4468109 + * @bug 4468109 8021583 * @summary Test for printing AUTOSENSE DocFlavor. No exception should be thrown. * @run main PrintAutoSenseData */ diff --git a/jdk/test/javax/print/attribute/autosense/sample.txt b/jdk/test/javax/print/attribute/autosense/sample.txt new file mode 100644 index 00000000000..ea84f750953 --- /dev/null +++ b/jdk/test/javax/print/attribute/autosense/sample.txt @@ -0,0 +1 @@ +This is a program for testing AutoSense data. From 70ac5c3a4876aefb07779767c4d353bd1b9fb055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Borggr=C3=A9n-Franck?= Date: Wed, 7 Aug 2013 01:32:39 +0200 Subject: [PATCH 057/118] 8009367: Wrong kind of name used in comparison in javax.lang.model code for repeatable annotations Reviewed-by: jjg, darcy --- .../javac/model/JavacAnnoConstructs.java | 8 +- .../8009367/TestQualifiedNameUsed.java | 82 +++++++++++++++++++ .../processing/model/element/8009367/p/Q.java | 29 +++++++ .../model/element/8009367/p/QQ.java | 28 +++++++ .../processing/model/element/8009367/p/R.java | 32 ++++++++ .../model/element/8009367/p/RR.java | 28 +++++++ 6 files changed, 203 insertions(+), 4 deletions(-) create mode 100644 langtools/test/tools/javac/processing/model/element/8009367/TestQualifiedNameUsed.java create mode 100644 langtools/test/tools/javac/processing/model/element/8009367/p/Q.java create mode 100644 langtools/test/tools/javac/processing/model/element/8009367/p/QQ.java create mode 100644 langtools/test/tools/javac/processing/model/element/8009367/p/R.java create mode 100644 langtools/test/tools/javac/processing/model/element/8009367/p/RR.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java index 882449fdd69..a2cd3c55de7 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java @@ -172,8 +172,8 @@ public class JavacAnnoConstructs { } // So we have a containing type - String annoTypeName = annoType.getSimpleName(); - String containerTypeName = containerType.getSimpleName(); + String annoTypeName = annoType.getName(); + String containerTypeName = containerType.getName(); int directIndex = -1, containerIndex = -1; Attribute.Compound direct = null, container = null; // Find directly (explicit or implicit) present annotations @@ -303,8 +303,8 @@ public class JavacAnnoConstructs { } // So we have a containing type - String annoTypeName = annoType.getSimpleName(); - String containerTypeName = containerType.getSimpleName(); + String annoTypeName = annoType.getName(); + String containerTypeName = containerType.getName(); int directIndex = -1, containerIndex = -1; Attribute.Compound direct = null, container = null; // Find directly (explicit or implicit) present annotations diff --git a/langtools/test/tools/javac/processing/model/element/8009367/TestQualifiedNameUsed.java b/langtools/test/tools/javac/processing/model/element/8009367/TestQualifiedNameUsed.java new file mode 100644 index 00000000000..5a8b12de589 --- /dev/null +++ b/langtools/test/tools/javac/processing/model/element/8009367/TestQualifiedNameUsed.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8009367 + * @summary Test that the correct kind of names (binary) are used when comparing + * Class and Symbol for repeatable Classes. + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor TestQualifiedNameUsed p.Q p.QQ p.R p.RR + * @run compile -processor TestQualifiedNameUsed -proc:only TestQualifiedNameUsed.java + */ + +import java.lang.annotation.Repeatable; +import java.util.Set; +import javax.annotation.processing.*; +import javax.lang.model.element.*; +import static javax.lang.model.util.ElementFilter.*; + +import com.sun.tools.javac.util.Assert; + +import java.util.Arrays; + +public class TestQualifiedNameUsed extends JavacTestingAbstractProcessor { + @Q + @p.Q + @p.R.Q + public boolean process(Set annotations, + RoundEnvironment roundEnv) { + if (!roundEnv.processingOver()) { + boolean hasRun = false; + for (Element element : roundEnv.getRootElements()) { + for (ExecutableElement e : methodsIn(element.getEnclosedElements())) { + if (e.getSimpleName().contentEquals("value")) + continue; // don't want to look Q.value() in this file + + hasRun = true; + Q[] qs = e.getAnnotationsByType(Q.class); + Assert.check(qs.length == 1); + Assert.check(qs[0] instanceof Q); + + p.Q[] ps = e.getAnnotationsByType(p.Q.class); + Assert.check(ps.length == 1); + Assert.check(ps[0] instanceof p.Q); + + p.R.Q[] rs = e.getAnnotationsByType(p.R.Q.class); + Assert.check(rs.length == 1); + Assert.check(rs[0] instanceof p.R.Q); + } + } + if (!hasRun) throw new RuntimeException("No methods!"); + } + return true; + } +} + +@Repeatable(QQ.class) +@interface Q {} + +@interface QQ { + Q[] value(); +} diff --git a/langtools/test/tools/javac/processing/model/element/8009367/p/Q.java b/langtools/test/tools/javac/processing/model/element/8009367/p/Q.java new file mode 100644 index 00000000000..d41331c8275 --- /dev/null +++ b/langtools/test/tools/javac/processing/model/element/8009367/p/Q.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p; + +import java.lang.annotation.Repeatable; + +@Repeatable(QQ.class) +public @interface Q {} diff --git a/langtools/test/tools/javac/processing/model/element/8009367/p/QQ.java b/langtools/test/tools/javac/processing/model/element/8009367/p/QQ.java new file mode 100644 index 00000000000..e13e8d7ea7f --- /dev/null +++ b/langtools/test/tools/javac/processing/model/element/8009367/p/QQ.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p; + +public @interface QQ { + Q[] value(); +} diff --git a/langtools/test/tools/javac/processing/model/element/8009367/p/R.java b/langtools/test/tools/javac/processing/model/element/8009367/p/R.java new file mode 100644 index 00000000000..da41577be11 --- /dev/null +++ b/langtools/test/tools/javac/processing/model/element/8009367/p/R.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p; + +import java.lang.annotation.Repeatable; + +public class R { + + @Repeatable(RR.class) + public @interface Q {} +} diff --git a/langtools/test/tools/javac/processing/model/element/8009367/p/RR.java b/langtools/test/tools/javac/processing/model/element/8009367/p/RR.java new file mode 100644 index 00000000000..2782d01181b --- /dev/null +++ b/langtools/test/tools/javac/processing/model/element/8009367/p/RR.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p; + +public @interface RR { + R.Q[] value(); +} From 4974d1aef2e7beac482a9ec4dafbea4ad7761a9d Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Tue, 6 Aug 2013 16:33:59 -0700 Subject: [PATCH 058/118] 7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments Restore the appendix argument after PopFrame() call Reviewed-by: twisti, coleenp --- .../sparc/vm/templateInterpreter_sparc.cpp | 21 +++++++++++++++ .../cpu/x86/vm/templateInterpreter_x86_32.cpp | 23 ++++++++++++++++ .../cpu/x86/vm/templateInterpreter_x86_64.cpp | 23 ++++++++++++++++ .../src/share/vm/classfile/javaClasses.cpp | 21 +++++++++++++++ .../src/share/vm/classfile/javaClasses.hpp | 26 +++++++++++++++++++ .../share/vm/classfile/systemDictionary.hpp | 1 + hotspot/src/share/vm/classfile/vmSymbols.hpp | 2 ++ .../vm/interpreter/interpreterRuntime.cpp | 23 ++++++++++++++++ .../vm/interpreter/interpreterRuntime.hpp | 3 +++ 9 files changed, 143 insertions(+) diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp index 7b9a494dff0..b6f8a5a5d1a 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp @@ -1887,6 +1887,27 @@ void TemplateInterpreterGenerator::generate_throw_exception() { if (ProfileInterpreter) { __ set_method_data_pointer_for_bcp(); } + +#if INCLUDE_JVMTI + if (EnableInvokeDynamic) { + Label L_done; + + __ ldub(Address(Lbcp, 0), G1_scratch); // Load current bytecode + __ cmp_and_br_short(G1_scratch, Bytecodes::_invokestatic, Assembler::notEqual, Assembler::pn, L_done); + + // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call. + // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL. + + __ call_VM(G1_scratch, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), I0, Lmethod, Lbcp); + + __ br_null(G1_scratch, false, Assembler::pn, L_done); + __ delayed()->nop(); + + __ st_ptr(G1_scratch, Lesp, wordSize); + __ bind(L_done); + } +#endif // INCLUDE_JVMTI + // Resume bytecode interpretation at the current bcp __ dispatch_next(vtos); // end of JVMTI PopFrame support diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index 2efa59f8b33..52e459900c7 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -1920,6 +1920,29 @@ void TemplateInterpreterGenerator::generate_throw_exception() { __ get_thread(thread); __ movl(Address(thread, JavaThread::popframe_condition_offset()), JavaThread::popframe_inactive); +#if INCLUDE_JVMTI + if (EnableInvokeDynamic) { + Label L_done; + const Register local0 = rdi; + + __ cmpb(Address(rsi, 0), Bytecodes::_invokestatic); + __ jcc(Assembler::notEqual, L_done); + + // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call. + // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL. + + __ get_method(rdx); + __ movptr(rax, Address(local0, 0)); + __ call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), rax, rdx, rsi); + + __ testptr(rax, rax); + __ jcc(Assembler::zero, L_done); + + __ movptr(Address(rbx, 0), rax); + __ bind(L_done); + } +#endif // INCLUDE_JVMTI + __ dispatch_next(vtos); // end of PopFrame support diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp index f0a2258a70e..4ac85c49578 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp @@ -1929,6 +1929,29 @@ void TemplateInterpreterGenerator::generate_throw_exception() { __ movl(Address(r15_thread, JavaThread::popframe_condition_offset()), JavaThread::popframe_inactive); +#if INCLUDE_JVMTI + if (EnableInvokeDynamic) { + Label L_done; + const Register local0 = r14; + + __ cmpb(Address(r13, 0), Bytecodes::_invokestatic); + __ jcc(Assembler::notEqual, L_done); + + // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call. + // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL. + + __ get_method(rdx); + __ movptr(rax, Address(local0, 0)); + __ call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), rax, rdx, r13); + + __ testptr(rax, rax); + __ jcc(Assembler::zero, L_done); + + __ movptr(Address(rbx, 0), rax); + __ bind(L_done); + } +#endif // INCLUDE_JVMTI + __ dispatch_next(vtos); // end of PopFrame support diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 678cb2dcd13..8e94d834ad9 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -2557,6 +2557,26 @@ void java_lang_ref_SoftReference::set_clock(jlong value) { *offset = value; } +// Support for java_lang_invoke_DirectMethodHandle + +int java_lang_invoke_DirectMethodHandle::_member_offset; + +oop java_lang_invoke_DirectMethodHandle::member(oop dmh) { + oop member_name = NULL; + bool is_dmh = dmh->is_oop() && java_lang_invoke_DirectMethodHandle::is_instance(dmh); + assert(is_dmh, "a DirectMethodHandle oop is expected"); + if (is_dmh) { + member_name = dmh->obj_field(member_offset_in_bytes()); + } + return member_name; +} + +void java_lang_invoke_DirectMethodHandle::compute_offsets() { + Klass* klass_oop = SystemDictionary::DirectMethodHandle_klass(); + if (klass_oop != NULL && EnableInvokeDynamic) { + compute_offset(_member_offset, klass_oop, vmSymbols::member_name(), vmSymbols::java_lang_invoke_MemberName_signature()); + } +} // Support for java_lang_invoke_MethodHandle @@ -3205,6 +3225,7 @@ void JavaClasses::compute_offsets() { java_lang_ThreadGroup::compute_offsets(); if (EnableInvokeDynamic) { java_lang_invoke_MethodHandle::compute_offsets(); + java_lang_invoke_DirectMethodHandle::compute_offsets(); java_lang_invoke_MemberName::compute_offsets(); java_lang_invoke_LambdaForm::compute_offsets(); java_lang_invoke_MethodType::compute_offsets(); diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 899d3ba48a3..8a8e801f387 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -976,6 +976,32 @@ class java_lang_invoke_MethodHandle: AllStatic { static int form_offset_in_bytes() { return _form_offset; } }; +// Interface to java.lang.invoke.DirectMethodHandle objects + +class java_lang_invoke_DirectMethodHandle: AllStatic { + friend class JavaClasses; + + private: + static int _member_offset; // the MemberName of this DMH + + static void compute_offsets(); + + public: + // Accessors + static oop member(oop mh); + + // Testers + static bool is_subclass(Klass* klass) { + return klass->is_subclass_of(SystemDictionary::DirectMethodHandle_klass()); + } + static bool is_instance(oop obj) { + return obj != NULL && is_subclass(obj->klass()); + } + + // Accessors for code generation: + static int member_offset_in_bytes() { return _member_offset; } +}; + // Interface to java.lang.invoke.LambdaForm objects // (These are a private interface for managing adapter code generation.) diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index a2a1a857517..85735a732fa 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -151,6 +151,7 @@ class SymbolPropertyTable; do_klass(reflect_CallerSensitive_klass, sun_reflect_CallerSensitive, Opt ) \ \ /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \ + do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle, Opt ) \ do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle, Pre_JSR292 ) \ do_klass(MemberName_klass, java_lang_invoke_MemberName, Pre_JSR292 ) \ do_klass(MethodHandleNatives_klass, java_lang_invoke_MethodHandleNatives, Pre_JSR292 ) \ diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index df370237167..067cf503305 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -255,6 +255,7 @@ /* Support for JSR 292 & invokedynamic (JDK 1.7 and above) */ \ template(java_lang_invoke_CallSite, "java/lang/invoke/CallSite") \ template(java_lang_invoke_ConstantCallSite, "java/lang/invoke/ConstantCallSite") \ + template(java_lang_invoke_DirectMethodHandle, "java/lang/invoke/DirectMethodHandle") \ template(java_lang_invoke_MutableCallSite, "java/lang/invoke/MutableCallSite") \ template(java_lang_invoke_VolatileCallSite, "java/lang/invoke/VolatileCallSite") \ template(java_lang_invoke_MethodHandle, "java/lang/invoke/MethodHandle") \ @@ -352,6 +353,7 @@ template(thread_id_name, "tid") \ template(newInstance0_name, "newInstance0") \ template(limit_name, "limit") \ + template(member_name, "member") \ template(forName_name, "forName") \ template(forName0_name, "forName0") \ template(isJavaIdentifierStart_name, "isJavaIdentifierStart") \ diff --git a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp index f5f9d39bcec..4a3019f867f 100644 --- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp +++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp @@ -1209,3 +1209,26 @@ IRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* threa size_of_arguments * Interpreter::stackElementSize); IRT_END #endif + +#if INCLUDE_JVMTI +// This is a support of the JVMTI PopFrame interface. +// Make sure it is an invokestatic of a polymorphic intrinsic that has a member_name argument +// and return it as a vm_result so that it can be reloaded in the list of invokestatic parameters. +// The dmh argument is a reference to a DirectMethoHandle that has a member name field. +IRT_ENTRY(void, InterpreterRuntime::member_name_arg_or_null(JavaThread* thread, address dmh, + Method* method, address bcp)) + Bytecodes::Code code = Bytecodes::code_at(method, bcp); + if (code != Bytecodes::_invokestatic) { + return; + } + ConstantPool* cpool = method->constants(); + int cp_index = Bytes::get_native_u2(bcp + 1) + ConstantPool::CPCACHE_INDEX_TAG; + Symbol* cname = cpool->klass_name_at(cpool->klass_ref_index_at(cp_index)); + Symbol* mname = cpool->name_ref_at(cp_index); + + if (MethodHandles::has_member_arg(cname, mname)) { + oop member_name = java_lang_invoke_DirectMethodHandle::member((oop)dmh); + thread->set_vm_result(member_name); + } +IRT_END +#endif // INCLUDE_JVMTI diff --git a/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp b/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp index d46c43e94e0..ad44210ef4d 100644 --- a/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp +++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp @@ -95,6 +95,9 @@ class InterpreterRuntime: AllStatic { static void create_exception(JavaThread* thread, char* name, char* message); static void create_klass_exception(JavaThread* thread, char* name, oopDesc* obj); static address exception_handler_for_exception(JavaThread* thread, oopDesc* exception); +#if INCLUDE_JVMTI + static void member_name_arg_or_null(JavaThread* thread, address dmh, Method* m, address bcp); +#endif static void throw_pending_exception(JavaThread* thread); // Statics & fields From 6fede334f9693fdf546c8b4dcde9e37cd5b2e71a Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 6 Aug 2013 16:45:43 -0700 Subject: [PATCH 059/118] 8022453: Fix doclint issues in javax.accessibility Reviewed-by: prr --- .../share/classes/javax/accessibility/Accessible.java | 3 ++- .../classes/javax/accessibility/AccessibleBundle.java | 5 ++++- .../javax/accessibility/AccessibleExtendedTable.java | 4 ++-- .../javax/accessibility/AccessibleRelationSet.java | 3 ++- .../classes/javax/accessibility/AccessibleTable.java | 6 +++++- .../accessibility/AccessibleTableModelChange.java | 10 +++++++--- .../javax/accessibility/AccessibleTextSequence.java | 4 ++-- .../classes/javax/accessibility/AccessibleValue.java | 3 ++- 8 files changed, 26 insertions(+), 12 deletions(-) diff --git a/jdk/src/share/classes/javax/accessibility/Accessible.java b/jdk/src/share/classes/javax/accessibility/Accessible.java index 0a22e5578b0..c7793715a84 100644 --- a/jdk/src/share/classes/javax/accessibility/Accessible.java +++ b/jdk/src/share/classes/javax/accessibility/Accessible.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,7 @@ public interface Accessible { * of an object that implements Accessible, and that subclass * is not Accessible, the developer should override the * getAccessibleContext method to return null. + * @return the AccessibleContext associated with this object */ public AccessibleContext getAccessibleContext(); } diff --git a/jdk/src/share/classes/javax/accessibility/AccessibleBundle.java b/jdk/src/share/classes/javax/accessibility/AccessibleBundle.java index 282cc2afbe0..65ce81bed6f 100644 --- a/jdk/src/share/classes/javax/accessibility/AccessibleBundle.java +++ b/jdk/src/share/classes/javax/accessibility/AccessibleBundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,6 +53,9 @@ public abstract class AccessibleBundle { private final String defaultResourceBundleName = "com.sun.accessibility.internal.resources.accessibility"; + /** + * Construct an {@code AccessibleBundle}. + */ public AccessibleBundle() { } diff --git a/jdk/src/share/classes/javax/accessibility/AccessibleExtendedTable.java b/jdk/src/share/classes/javax/accessibility/AccessibleExtendedTable.java index 485d68daa59..87385639db1 100644 --- a/jdk/src/share/classes/javax/accessibility/AccessibleExtendedTable.java +++ b/jdk/src/share/classes/javax/accessibility/AccessibleExtendedTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ public interface AccessibleExtendedTable extends AccessibleTable { */ public int getAccessibleColumn(int index); - /* + /** * Returns the index at a row and column in the table. * * @param r zero-based row of the table diff --git a/jdk/src/share/classes/javax/accessibility/AccessibleRelationSet.java b/jdk/src/share/classes/javax/accessibility/AccessibleRelationSet.java index d6b0ece3da2..e1409089fb9 100644 --- a/jdk/src/share/classes/javax/accessibility/AccessibleRelationSet.java +++ b/jdk/src/share/classes/javax/accessibility/AccessibleRelationSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -163,6 +163,7 @@ public class AccessibleRelationSet { /** * Returns the number of relations in the relation set. + * @return the number of relations in the relation set */ public int size() { if (relations == null) { diff --git a/jdk/src/share/classes/javax/accessibility/AccessibleTable.java b/jdk/src/share/classes/javax/accessibility/AccessibleTable.java index c1921aa823f..74c7a03dc0d 100644 --- a/jdk/src/share/classes/javax/accessibility/AccessibleTable.java +++ b/jdk/src/share/classes/javax/accessibility/AccessibleTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,6 +90,8 @@ public interface AccessibleTable { * Returns the number of rows occupied by the Accessible at * a specified row and column in the table. * + * @param r zero-based row of the table + * @param c zero-based column of the table * @return the number of rows occupied by the Accessible at a * given specified (row, column) */ @@ -99,6 +101,8 @@ public interface AccessibleTable { * Returns the number of columns occupied by the Accessible at * a specified row and column in the table. * + * @param r zero-based row of the table + * @param c zero-based column of the table * @return the number of columns occupied by the Accessible at a * given specified row and column */ diff --git a/jdk/src/share/classes/javax/accessibility/AccessibleTableModelChange.java b/jdk/src/share/classes/javax/accessibility/AccessibleTableModelChange.java index 43bb28c6bd2..03cdf9ab666 100644 --- a/jdk/src/share/classes/javax/accessibility/AccessibleTableModelChange.java +++ b/jdk/src/share/classes/javax/accessibility/AccessibleTableModelChange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,8 +71,8 @@ public interface AccessibleTableModelChange { public static final int DELETE = -1; /** - * Returns the type of event - * + * Returns the type of event. + * @return the type of event * @see #INSERT * @see #UPDATE * @see #DELETE @@ -81,21 +81,25 @@ public interface AccessibleTableModelChange { /** * Returns the first row that changed. + * @return the first row that changed */ public int getFirstRow(); /** * Returns the last row that changed. + * @return the last row that changed */ public int getLastRow(); /** * Returns the first column that changed. + * @return the first column that changed */ public int getFirstColumn(); /** * Returns the last column that changed. + * @return the last column that changed */ public int getLastColumn(); } diff --git a/jdk/src/share/classes/javax/accessibility/AccessibleTextSequence.java b/jdk/src/share/classes/javax/accessibility/AccessibleTextSequence.java index 58af80b3be5..cc70970af77 100644 --- a/jdk/src/share/classes/javax/accessibility/AccessibleTextSequence.java +++ b/jdk/src/share/classes/javax/accessibility/AccessibleTextSequence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ package javax.accessibility; */ public class AccessibleTextSequence { - /* The start index of the text sequence */ + /** The start index of the text sequence */ public int startIndex; /** The end index of the text sequence */ diff --git a/jdk/src/share/classes/javax/accessibility/AccessibleValue.java b/jdk/src/share/classes/javax/accessibility/AccessibleValue.java index 5108428f933..448eaac4f37 100644 --- a/jdk/src/share/classes/javax/accessibility/AccessibleValue.java +++ b/jdk/src/share/classes/javax/accessibility/AccessibleValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,6 +60,7 @@ public interface AccessibleValue { /** * Set the value of this object as a Number. * + * @param n the number to use for the value * @return True if the value was set; else False * @see #getCurrentAccessibleValue */ From ddf5fcb7c2ca28d58a000f286a1408969c1bf853 Mon Sep 17 00:00:00 2001 From: Vladimir Danushevsky Date: Tue, 6 Aug 2013 20:01:40 -0400 Subject: [PATCH 060/118] 8012144: multiple SIGSEGVs fails on staxf Forward port of 7u change to add additional fence() on RMO platforms, with a load_acquire on all platforms Reviewed-by: dholmes, kvn --- hotspot/src/share/vm/utilities/taskqueue.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/utilities/taskqueue.hpp b/hotspot/src/share/vm/utilities/taskqueue.hpp index aea96c8581c..d3eafd5de47 100644 --- a/hotspot/src/share/vm/utilities/taskqueue.hpp +++ b/hotspot/src/share/vm/utilities/taskqueue.hpp @@ -395,7 +395,13 @@ bool GenericTaskQueue::pop_local_slow(uint localBot, Age oldAge) { template bool GenericTaskQueue::pop_global(E& t) { Age oldAge = _age.get(); - uint localBot = _bottom; + // Architectures with weak memory model require a barrier here + // to guarantee that bottom is not older than age, + // which is crucial for the correctness of the algorithm. +#if !(defined SPARC || defined IA32 || defined AMD64) + OrderAccess::fence(); +#endif + uint localBot = OrderAccess::load_acquire((volatile juint*)&_bottom); uint n_elems = size(localBot, oldAge.top()); if (n_elems == 0) { return false; @@ -644,7 +650,7 @@ public: template inline bool GenericTaskQueue::push(E t) { uint localBot = _bottom; - assert((localBot >= 0) && (localBot < N), "_bottom out of range."); + assert(localBot < N, "_bottom out of range."); idx_t top = _age.top(); uint dirty_n_elems = dirty_size(localBot, top); assert(dirty_n_elems < N, "n_elems out of range."); From f211cb81b9ace27de21ab170186e0d59b876daf2 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 6 Aug 2013 17:11:29 -0700 Subject: [PATCH 061/118] 8022455: Fix doclint warnings in javax.imageio Reviewed-by: darcy --- .../share/classes/javax/imageio/ImageIO.java | 2 +- .../classes/javax/imageio/ImageReadParam.java | 2 +- .../classes/javax/imageio/ImageReader.java | 40 +++++----- .../javax/imageio/ImageTypeSpecifier.java | 2 +- .../javax/imageio/ImageWriteParam.java | 9 +-- .../classes/javax/imageio/ImageWriter.java | 2 +- .../metadata/IIOMetadataFormatImpl.java | 3 + .../plugins/bmp/BMPImageWriteParam.java | 6 +- .../plugins/jpeg/JPEGImageReadParam.java | 16 ++-- .../plugins/jpeg/JPEGImageWriteParam.java | 6 +- .../javax/imageio/spi/ImageReaderSpi.java | 2 +- .../javax/imageio/spi/ImageWriterSpi.java | 2 +- .../javax/imageio/spi/ServiceRegistry.java | 11 +++ .../imageio/stream/ImageInputStream.java | 74 +++++++++---------- .../imageio/stream/ImageInputStreamImpl.java | 2 +- .../imageio/stream/ImageOutputStream.java | 17 ++--- 16 files changed, 101 insertions(+), 95 deletions(-) diff --git a/jdk/src/share/classes/javax/imageio/ImageIO.java b/jdk/src/share/classes/javax/imageio/ImageIO.java index 2474bb6582e..62098779a72 100644 --- a/jdk/src/share/classes/javax/imageio/ImageIO.java +++ b/jdk/src/share/classes/javax/imageio/ImageIO.java @@ -228,7 +228,7 @@ public final class ImageIO { * be used when creating ImageInputStreams and * ImageOutputStreams. * - *

    When reading from a standard InputStream>, it + *

    When reading from a standard InputStream, it * may be necessary to save previously read information in a cache * since the underlying stream does not allow data to be re-read. * Similarly, when writing to a standard diff --git a/jdk/src/share/classes/javax/imageio/ImageReadParam.java b/jdk/src/share/classes/javax/imageio/ImageReadParam.java index d24b7ef99e7..6053348d100 100644 --- a/jdk/src/share/classes/javax/imageio/ImageReadParam.java +++ b/jdk/src/share/classes/javax/imageio/ImageReadParam.java @@ -80,7 +80,7 @@ import java.awt.image.BufferedImage; * *

    The resulting region is then subsampled according to the * factors given in {@link IIOParam#setSourceSubsampling - * IIOParam.setSourceSubsampling}. The first pixel, + * IIOParam.setSourceSubsampling}. The first pixel, * the number of pixels per row, and the number of rows all depend * on the subsampling settings. * Call the minimum X and Y coordinates of the resulting rectangle diff --git a/jdk/src/share/classes/javax/imageio/ImageReader.java b/jdk/src/share/classes/javax/imageio/ImageReader.java index c1d62ababcb..ebbb98324a0 100644 --- a/jdk/src/share/classes/javax/imageio/ImageReader.java +++ b/jdk/src/share/classes/javax/imageio/ImageReader.java @@ -230,8 +230,8 @@ public abstract class ImageReader { * increased as each image (or thumbnail, or image metadata) is * read. If seekForwardOnly is true, then a call to * read(index) will throw an - * IndexOutOfBoundsException if index < - * this.minIndex; otherwise, the value of + * IndexOutOfBoundsException if {@code index < this.minIndex}; + * otherwise, the value of * minIndex will be set to index. If * seekForwardOnly is false, the value of * minIndex will remain 0 regardless of any read @@ -328,8 +328,8 @@ public abstract class ImageReader { * increased as each image (or thumbnail, or image metadata) is * read. If seekForwardOnly is true, then a call to * read(index) will throw an - * IndexOutOfBoundsException if index < - * this.minIndex; otherwise, the value of + * IndexOutOfBoundsException if {@code index < this.minIndex}; + * otherwise, the value of * minIndex will be set to index. If * seekForwardOnly is false, the value of * minIndex will remain 0 regardless of any read @@ -600,8 +600,7 @@ public abstract class ImageReader { *

    Note that formats that return false from * this method may nonetheless allow tiling (e.g. Restart * Markers in JPEG), and random access will likely be reasonably - * efficient on tiles. See {@link #isImageTiled - * isImageTiled}. + * efficient on tiles. See {@link #isImageTiled isImageTiled}. * *

    A reader for which all images are guaranteed to support * easy random access, or are guaranteed not to support easy @@ -1212,11 +1211,10 @@ public abstract class ImageReader { /** * Returns true if this plug-in supports reading - * just a {@link java.awt.image.Raster Raster} of pixel data. + * just a {@link java.awt.image.Raster Raster} of pixel data. * If this method returns false, calls to - * {@link #readRaster readRaster} or {@link #readTileRaster - * readTileRaster} will throw an - * UnsupportedOperationException. + * {@link #readRaster readRaster} or {@link #readTileRaster readTileRaster} + * will throw an UnsupportedOperationException. * *

    The default implementation returns false. * @@ -1236,7 +1234,7 @@ public abstract class ImageReader { * application must determine how to interpret the pixel data by other * means. Any destination or image-type parameters in the supplied * ImageReadParam object are ignored, but all other - * parameters are used exactly as in the {@link #read read} + * parameters are used exactly as in the {@link #read read} * method, except that any destination offset is used as a logical rather * than a physical offset. The size of the returned Raster * will always be that of the source region clipped to the actual image. @@ -1249,10 +1247,9 @@ public abstract class ImageReader { * *

    Any registered readUpdateListeners are ignored, as * there is no BufferedImage, but all other listeners are - * called exactly as they are for the {@link #read read} - * method. + * called exactly as they are for the {@link #read read} method. * - *

    If {@link #canReadRaster canReadRaster()} returns + *

    If {@link #canReadRaster canReadRaster()} returns * false, this method throws an * UnsupportedOperationException. * @@ -1481,13 +1478,13 @@ public abstract class ImageReader { * The application must determine how to interpret the pixel data by other * means. * - *

    If {@link #canReadRaster canReadRaster()} returns + *

    If {@link #canReadRaster canReadRaster()} returns * false, this method throws an * UnsupportedOperationException. * *

    The default implementation checks if reading * Rasters is supported, and if so calls {@link - * #readRaster readRaster(imageIndex, null)} if + * #readRaster readRaster(imageIndex, null)} if * tileX and tileY are 0, or throws an * IllegalArgumentException otherwise. * @@ -1548,8 +1545,8 @@ public abstract class ImageReader { * source render size or any format-specific settings), they will * be ignored. * - *

    The default implementation just calls {@link #read - * read(imageIndex, param)}. + *

    The default implementation just calls + * {@link #read read(imageIndex, param)}. * * @param imageIndex the index of the image to be retrieved. * @param param an ImageReadParam used to control @@ -2544,9 +2541,8 @@ public abstract class ImageReader { * the supplied ImageReadParam. The actual * subsampling factors, destination size, and destination offset * are not taken into consideration, thus further - * clipping must take place. The {@link #computeRegions - * computeRegions} method performs all necessary - * clipping. + * clipping must take place. The {@link #computeRegions computeRegions} + * method performs all necessary clipping. * * @param param the ImageReadParam being used, or * null. @@ -2601,7 +2597,7 @@ public abstract class ImageReader { * width or height of 0, an IllegalArgumentException * is thrown. * - *

    The {@link #getSourceRegion getSourceRegion} + *

    The {@link #getSourceRegion getSourceRegion>} * method may be used if only source clipping is desired. * * @param param an ImageReadParam, or null. diff --git a/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java b/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java index 556f8b76985..c9c17dfe4c1 100644 --- a/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java +++ b/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java @@ -840,7 +840,7 @@ public class ImageTypeSpecifier { * not one of 1, 2, 4, 8, or 16. * @exception IllegalArgumentException if the * non-null LUT parameters do not have lengths of - * exactly 1 << bits. + * exactly {@code 1 << bits}. * @exception IllegalArgumentException if dataType is * not one of DataBuffer.TYPE_BYTE, * DataBuffer.TYPE_SHORT, diff --git a/jdk/src/share/classes/javax/imageio/ImageWriteParam.java b/jdk/src/share/classes/javax/imageio/ImageWriteParam.java index 4db0e591ea6..adf4f3a9029 100644 --- a/jdk/src/share/classes/javax/imageio/ImageWriteParam.java +++ b/jdk/src/share/classes/javax/imageio/ImageWriteParam.java @@ -49,7 +49,7 @@ import java.util.Locale; * and include additional pixels within the intersected bounds * according to the horizontal and vertical subsampling factors * specified by {@link IIOParam#setSourceSubsampling - * IIOParam.setSourceSubsampling}. + * IIOParam.setSourceSubsampling}. * *

    Individual features such as tiling, progressive encoding, and * compression may be set in one of four modes. @@ -462,9 +462,8 @@ public class ImageWriteParam extends IIOParam { * IllegalStateException. * *

  • MODE_EXPLICIT - The image will be tiled - * according to parameters given in the {@link #setTiling - * setTiling} method. Any previously set tiling - * parameters are discarded. + * according to parameters given in the {@link #setTiling setTiling} + * method. Any previously set tiling parameters are discarded. * *
  • MODE_COPY_FROM_METADATA - The image will * conform to the metadata object passed in to a write. @@ -1421,7 +1420,7 @@ public class ImageWriteParam extends IIOParam { * with getCompressionQualityDescriptions as part of a user * interface for setting or displaying the compression quality * level. See {@link #getCompressionQualityDescriptions - * getCompressionQualityDescriptions} for more information. + * getCompressionQualityDescriptions} for more information. * *

    If no descriptions are available, null is * returned. If null is returned from diff --git a/jdk/src/share/classes/javax/imageio/ImageWriter.java b/jdk/src/share/classes/javax/imageio/ImageWriter.java index a9ecb042b3e..1fdabdcd5f8 100644 --- a/jdk/src/share/classes/javax/imageio/ImageWriter.java +++ b/jdk/src/share/classes/javax/imageio/ImageWriter.java @@ -692,7 +692,7 @@ public abstract class ImageWriter implements ImageTranscoder { * output prior to the current seek position may be flushed, and * need not be readable or writable, unless the plug-in needs to * be able to patch up the header information when - * endWriteSequence is called (e.g. TIFF). + * endWriteSequence is called (e.g. TIFF). * *

    If canWriteSequence returns false, * this method will throw an diff --git a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormatImpl.java b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormatImpl.java index 1a68b019d59..4ca4f74c4a0 100644 --- a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormatImpl.java +++ b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormatImpl.java @@ -729,6 +729,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat { * @param required true if an object value must be present. * @param defaultValue the default value for the * Object reference, or null. + * @param the type of the object. * * @exception IllegalArgumentException if elementName * is null, or is not a legal element name for this format. @@ -765,6 +766,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat { * @param enumeratedValues a List of * Objects containing the legal values for the * object reference. + * @param the type of the object. * * @exception IllegalArgumentException if elementName * is null, or is not a legal element name for this format. @@ -836,6 +838,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat { * is inclusive. * @param maxInclusive true if maxValue * is inclusive. + * @param the type of the object. * * @exception IllegalArgumentException if elementName * is null, or is not a legal element name for this diff --git a/jdk/src/share/classes/javax/imageio/plugins/bmp/BMPImageWriteParam.java b/jdk/src/share/classes/javax/imageio/plugins/bmp/BMPImageWriteParam.java index 840e6c3f223..de35f5fe11e 100644 --- a/jdk/src/share/classes/javax/imageio/plugins/bmp/BMPImageWriteParam.java +++ b/jdk/src/share/classes/javax/imageio/plugins/bmp/BMPImageWriteParam.java @@ -56,9 +56,9 @@ import com.sun.imageio.plugins.bmp.BMPConstants; *

  • Representation ClassDocument Size
    * * - * - * - * + * + * + * * *
    Compression Types
    Type String Description Image Types
    BI_RGB Uncompressed RLE <= 8-bits/sample
    BI_RLE8 8-bit Run Length Encoding <= 8-bits/sample
    BI_RLE4 4-bit Run Length Encoding <= 4-bits/sample
    BI_RGB Uncompressed RLE {@literal <= } 8-bits/sample
    BI_RLE8 8-bit Run Length Encoding {@literal <=} 8-bits/sample
    BI_RLE4 4-bit Run Length Encoding {@literal <=} 4-bits/sample
    BI_BITFIELDS Packed data 16 or 32 bits/sample
    */ diff --git a/jdk/src/share/classes/javax/imageio/plugins/jpeg/JPEGImageReadParam.java b/jdk/src/share/classes/javax/imageio/plugins/jpeg/JPEGImageReadParam.java index 269c03acc5b..720aa600129 100644 --- a/jdk/src/share/classes/javax/imageio/plugins/jpeg/JPEGImageReadParam.java +++ b/jdk/src/share/classes/javax/imageio/plugins/jpeg/JPEGImageReadParam.java @@ -46,16 +46,15 @@ import javax.imageio.ImageReadParam; * This class allows the tables to be specified directly from client * code. If no tables are specified either in the stream or in a * JPEGImageReadParam, then the stream is presumed to use - * the "standard" visually lossless tables. See {@link JPEGQTable - * JPEGQTable} and {@link JPEGHuffmanTable - * JPEGHuffmanTable} for more information on the default - * tables. + * the "standard" visually lossless tables. See {@link JPEGQTable JPEGQTable} + * and {@link JPEGHuffmanTable JPEGHuffmanTable} for more information + * on the default tables. * *

    The default JPEGImageReadParam returned by the * getDefaultReadParam method of the builtin JPEG reader * contains no tables. Default tables may be obtained from the table - * classes {@link JPEGQTable JPEGQTable} and {@link - * JPEGHuffmanTable JPEGHuffmanTable}. + * classes {@link JPEGQTable JPEGQTable} and + * {@link JPEGHuffmanTable JPEGHuffmanTable}. * *

    If a stream does contain tables, the tables given in a * JPEGImageReadParam are ignored. Furthermore, if the @@ -64,13 +63,12 @@ import javax.imageio.ImageReadParam; * abbreviated images. Once tables have been read from a stream, they * can be overridden only by tables subsequently read from the same * stream. In order to specify new tables, the {@link - * javax.imageio.ImageReader#setInput setInput} method of + * javax.imageio.ImageReader#setInput setInput} method of * the reader must be called to change the stream. * *

    Note that this class does not provide a means for obtaining the * tables found in a stream. These may be extracted from a stream by - * consulting the IIOMetadata object returned by the - * reader. + * consulting the IIOMetadata object returned by the reader. * *

    * For more information about the operation of the built-in JPEG plug-ins, diff --git a/jdk/src/share/classes/javax/imageio/plugins/jpeg/JPEGImageWriteParam.java b/jdk/src/share/classes/javax/imageio/plugins/jpeg/JPEGImageWriteParam.java index 4e8a35cbefa..b4df14e99c6 100644 --- a/jdk/src/share/classes/javax/imageio/plugins/jpeg/JPEGImageWriteParam.java +++ b/jdk/src/share/classes/javax/imageio/plugins/jpeg/JPEGImageWriteParam.java @@ -66,8 +66,8 @@ import com.sun.imageio.plugins.jpeg.JPEG; * when an abbreviated stream must be written without writing any tables * to a stream first. In order to use this class, the metadata object * passed into the writer must contain no tables, and no stream metadata - * must be provided. See {@link JPEGQTable JPEGQTable} and - * {@link JPEGHuffmanTable JPEGHuffmanTable} for more + * must be provided. See {@link JPEGQTable JPEGQTable} and + * {@link JPEGHuffmanTable JPEGHuffmanTable} for more * information on the default tables. * *

    The default JPEGImageWriteParam returned by the @@ -80,7 +80,7 @@ import com.sun.imageio.plugins.jpeg.JPEG; * set of tables has been written, only tables in the metadata can * override them for subsequent writes, whether to the same stream or * a different one. In order to specify new tables using this class, - * the {@link javax.imageio.ImageWriter#reset reset} + * the {@link javax.imageio.ImageWriter#reset reset} * method of the writer must be called. * *

    diff --git a/jdk/src/share/classes/javax/imageio/spi/ImageReaderSpi.java b/jdk/src/share/classes/javax/imageio/spi/ImageReaderSpi.java index 969bc8d9a4d..4d4ccec0fa6 100644 --- a/jdk/src/share/classes/javax/imageio/spi/ImageReaderSpi.java +++ b/jdk/src/share/classes/javax/imageio/spi/ImageReaderSpi.java @@ -78,7 +78,7 @@ public abstract class ImageReaderSpi extends ImageReaderWriterSpi { * ImageInputStream.class, to be returned from * getInputTypes. * @deprecated Instead of using this field, directly create - * the equivalent array { ImageInputStream.class }. + * the equivalent array { ImageInputStream.class }. */ @Deprecated public static final Class[] STANDARD_INPUT_TYPE = diff --git a/jdk/src/share/classes/javax/imageio/spi/ImageWriterSpi.java b/jdk/src/share/classes/javax/imageio/spi/ImageWriterSpi.java index b6e0c9e46da..7fc1a334a9f 100644 --- a/jdk/src/share/classes/javax/imageio/spi/ImageWriterSpi.java +++ b/jdk/src/share/classes/javax/imageio/spi/ImageWriterSpi.java @@ -80,7 +80,7 @@ public abstract class ImageWriterSpi extends ImageReaderWriterSpi { * ImageOutputStream.class, to be returned from * getOutputTypes. * @deprecated Instead of using this field, directly create - * the equivalent array { ImageOutputStream.class }. + * the equivalent array { ImageOutputStream.class }. */ @Deprecated public static final Class[] STANDARD_OUTPUT_TYPE = diff --git a/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java b/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java index c94c98d0359..3f4338d7db9 100644 --- a/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java +++ b/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java @@ -157,6 +157,8 @@ public class ServiceRegistry { * or null if the system class loader (or, failing that * the bootstrap class loader) is to be used. * + * @param the type of the providerClass. + * * @return An Iterator that yields provider objects * for the given service, in some arbitrary order. The iterator * will throw an Error if a provider-configuration @@ -188,6 +190,8 @@ public class ServiceRegistry { * @param providerClass a Classobject indicating the * class or interface of the service providers being detected. * + * @param the type of the providerClass. + * * @return An Iterator that yields provider objects * for the given service, in some arbitrary order. The iterator * will throw an Error if a provider-configuration @@ -247,6 +251,7 @@ public class ServiceRegistry { * @param provider the service provide object to be registered. * @param category the category under which to register the * provider. + * @param the type of the provider. * * @return true if no provider of the same class was previously * registered in the same category category. @@ -348,6 +353,7 @@ public class ServiceRegistry { * @param provider the service provider object to be deregistered. * @param category the category from which to deregister the * provider. + * @param the type of the provider. * * @return true if the provider was previously * registered in the same category category, @@ -435,6 +441,7 @@ public class ServiceRegistry { * @param category the category to be retrieved from. * @param useOrdering true if pairwise orderings * should be taken account in ordering the returned objects. + * @param the type of the category. * * @return an Iterator containing service provider * objects from the given category, possibly in order. @@ -490,6 +497,7 @@ public class ServiceRegistry { * whose filter method will be invoked. * @param useOrdering true if pairwise orderings * should be taken account in ordering the returned objects. + * @param the type of the category. * * @return an Iterator containing service provider * objects from the given category, possibly in order. @@ -517,6 +525,7 @@ public class ServiceRegistry { * * @param providerClass the Class of the desired * service provider object. + * @param the type of the provider. * * @return a currently registered service provider object with the * desired Classtype, or null is none is @@ -561,6 +570,7 @@ public class ServiceRegistry { * @param firstProvider the preferred provider. * @param secondProvider the provider to which * firstProvider is preferred. + * @param the type of the category. * * @return true if a previously unset ordering * was established. @@ -606,6 +616,7 @@ public class ServiceRegistry { * @param firstProvider the formerly preferred provider. * @param secondProvider the provider to which * firstProvider was formerly preferred. + * @param the type of the category. * * @return true if a previously set ordering was * disestablished. diff --git a/jdk/src/share/classes/javax/imageio/stream/ImageInputStream.java b/jdk/src/share/classes/javax/imageio/stream/ImageInputStream.java index d51f22aa8b6..ebf984a9ddc 100644 --- a/jdk/src/share/classes/javax/imageio/stream/ImageInputStream.java +++ b/jdk/src/share/classes/javax/imageio/stream/ImageInputStream.java @@ -183,7 +183,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return a boolean value from the stream. * - * @exception EOFException if the end of the stream is reached. + * @exception java.io.EOFException if the end of the stream is reached. * @exception IOException if an I/O error occurs. */ boolean readBoolean() throws IOException; @@ -201,7 +201,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return a signed byte value from the stream. * - * @exception EOFException if the end of the stream is reached. + * @exception java.io.EOFException if the end of the stream is reached. * @exception IOException if an I/O error occurs. */ byte readByte() throws IOException; @@ -225,7 +225,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return an unsigned byte value from the stream. * - * @exception EOFException if the end of the stream is reached. + * @exception java.io.EOFException if the end of the stream is reached. * @exception IOException if an I/O error occurs. */ int readUnsignedByte() throws IOException; @@ -240,7 +240,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return a signed short value from the stream. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @@ -261,7 +261,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return an unsigned short value from the stream, as an int. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @@ -278,7 +278,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return an unsigned char value from the stream. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @@ -296,7 +296,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return a signed int value from the stream. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @@ -316,7 +316,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return an unsigned int value from the stream, as a long. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @@ -334,7 +334,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return a signed long value from the stream. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @@ -352,7 +352,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return a float value from the stream. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @@ -370,7 +370,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return a double value from the stream. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @@ -469,7 +469,7 @@ public interface ImageInputStream extends DataInput, Closeable { * then a UTFDataFormatException is thrown. * *

    If end of file is encountered at any time during this - * entire process, then an EOFException is thrown. + * entire process, then an java.io.EOFException is thrown. * *

    After every group has been converted to a character by this * process, the characters are gathered, in the same order in @@ -488,10 +488,10 @@ public interface ImageInputStream extends DataInput, Closeable { * * @return a String read from the stream. * - * @exception EOFException if this stream reaches the end + * @exception java.io.EOFException if this stream reaches the end * before reading all the bytes. - * @exception UTFDataFormatException if the bytes do not represent a - * valid modified UTF-8 encoding of a string. + * @exception java.io.UTFDataFormatException if the bytes do not represent + * a valid modified UTF-8 encoding of a string. * @exception IOException if an I/O error occurs. */ String readUTF() throws IOException; @@ -499,7 +499,7 @@ public interface ImageInputStream extends DataInput, Closeable { /** * Reads len bytes from the stream, and stores them * into b starting at index off. - * If the end of the stream is reached, an EOFException + * If the end of the stream is reached, an java.io.EOFException * will be thrown. * *

    The bit offset within the stream is reset to zero before @@ -514,7 +514,7 @@ public interface ImageInputStream extends DataInput, Closeable { * len is greater than b.length. * @exception NullPointerException if b is * null. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. */ @@ -523,7 +523,7 @@ public interface ImageInputStream extends DataInput, Closeable { /** * Reads b.length bytes from the stream, and stores them * into b starting at index 0. - * If the end of the stream is reached, an EOFException + * If the end of the stream is reached, an java.io.EOFException * will be thrown. * *

    The bit offset within the stream is reset to zero before @@ -533,7 +533,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @exception NullPointerException if b is * null. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. */ @@ -544,7 +544,7 @@ public interface ImageInputStream extends DataInput, Closeable { * stream according to the current byte order, and * stores them into s starting at index * off. If the end of the stream is reached, an - * EOFException will be thrown. + * java.io.EOFException will be thrown. * *

    The bit offset within the stream is reset to zero before * the read occurs. @@ -558,7 +558,7 @@ public interface ImageInputStream extends DataInput, Closeable { * len is greater than s.length. * @exception NullPointerException if s is * null. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. */ @@ -569,7 +569,7 @@ public interface ImageInputStream extends DataInput, Closeable { * stream according to the current byte order, and * stores them into c starting at index * off. If the end of the stream is reached, an - * EOFException will be thrown. + * java.io.EOFException will be thrown. * *

    The bit offset within the stream is reset to zero before * the read occurs. @@ -583,7 +583,7 @@ public interface ImageInputStream extends DataInput, Closeable { * len is greater than c.length. * @exception NullPointerException if c is * null. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. */ @@ -594,7 +594,7 @@ public interface ImageInputStream extends DataInput, Closeable { * stream according to the current byte order, and * stores them into i starting at index * off. If the end of the stream is reached, an - * EOFException will be thrown. + * java.io.EOFException will be thrown. * *

    The bit offset within the stream is reset to zero before * the read occurs. @@ -608,7 +608,7 @@ public interface ImageInputStream extends DataInput, Closeable { * len is greater than i.length. * @exception NullPointerException if i is * null. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. */ @@ -619,7 +619,7 @@ public interface ImageInputStream extends DataInput, Closeable { * stream according to the current byte order, and * stores them into l starting at index * off. If the end of the stream is reached, an - * EOFException will be thrown. + * java.io.EOFException will be thrown. * *

    The bit offset within the stream is reset to zero before * the read occurs. @@ -633,7 +633,7 @@ public interface ImageInputStream extends DataInput, Closeable { * len is greater than l.length. * @exception NullPointerException if l is * null. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. */ @@ -644,7 +644,7 @@ public interface ImageInputStream extends DataInput, Closeable { * floats) from the stream according to the current byte order, * and stores them into f starting at * index off. If the end of the stream is reached, - * an EOFException will be thrown. + * an java.io.EOFException will be thrown. * *

    The bit offset within the stream is reset to zero before * the read occurs. @@ -658,7 +658,7 @@ public interface ImageInputStream extends DataInput, Closeable { * len is greater than f.length. * @exception NullPointerException if f is * null. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. */ @@ -669,7 +669,7 @@ public interface ImageInputStream extends DataInput, Closeable { * floats) from the stream according to the current byte order, * and stores them into d starting at * index off. If the end of the stream is reached, - * an EOFException will be thrown. + * an java.io.EOFException will be thrown. * *

    The bit offset within the stream is reset to zero before * the read occurs. @@ -683,7 +683,7 @@ public interface ImageInputStream extends DataInput, Closeable { * len is greater than d.length. * @exception NullPointerException if d is * null. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. */ @@ -748,7 +748,7 @@ public interface ImageInputStream extends DataInput, Closeable { * @return an int containing the value 0 * or 1. * - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bits. * @exception IOException if an I/O error occurs. */ @@ -768,13 +768,13 @@ public interface ImageInputStream extends DataInput, Closeable { * the right side of the return value, as shown by the following * pseudo-code: * - *

    +     * 
    {@code
          * long accum = 0L;
          * for (int i = 0; i < numBits; i++) {
          *   accum <<= 1; // Shift left one bit to make room
          *   accum |= readBit();
          * }
    -     * 
    + * }
    * * Note that the result of readBits(32) may thus not * be equal to that of readInt() if a reverse network @@ -782,7 +782,7 @@ public interface ImageInputStream extends DataInput, Closeable { * false). * *

    If the end of the stream is encountered before all the bits - * have been read, an EOFException is thrown. + * have been read, an java.io.EOFException is thrown. * * @param numBits the number of bits to read, as an int * between 0 and 64, inclusive. @@ -791,7 +791,7 @@ public interface ImageInputStream extends DataInput, Closeable { * * @exception IllegalArgumentException if numBits * is not between 0 and 64, inclusive. - * @exception EOFException if the stream reaches the end before + * @exception java.io.EOFException if the stream reaches the end before * reading all the bits. * @exception IOException if an I/O error occurs. */ @@ -850,7 +850,7 @@ public interface ImageInputStream extends DataInput, Closeable { * returned by getflushedPosition). * *

    It is legal to seek past the end of the file; an - * EOFException will be thrown only if a read is + * java.io.EOFException will be thrown only if a read is * performed. * * @param pos a long containing the desired file diff --git a/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java b/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java index cf66019768b..8f7061f960e 100644 --- a/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java +++ b/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java @@ -88,7 +88,7 @@ public abstract class ImageInputStreamImpl implements ImageInputStream { /** * The position prior to which data may be discarded. Seeking * to a smaller position is not allowed. flushedPos - * will always be >= 0. + * will always be {@literal >= 0}. */ protected long flushedPos = 0; diff --git a/jdk/src/share/classes/javax/imageio/stream/ImageOutputStream.java b/jdk/src/share/classes/javax/imageio/stream/ImageOutputStream.java index c525ca39c1e..8deddd3b36b 100644 --- a/jdk/src/share/classes/javax/imageio/stream/ImageOutputStream.java +++ b/jdk/src/share/classes/javax/imageio/stream/ImageOutputStream.java @@ -59,9 +59,9 @@ public interface ImageOutputStream extends ImageInputStream, DataOutput { * remainder of the current byte is padded with 0s * and written out first. The bit offset will be 0 after the * write. Implementers can use the - * {@link ImageOutputStreamImpl#flushBits flushBits} - * method of {@link ImageOutputStreamImpl - * ImageOutputStreamImpl} to guarantee this. + * {@link ImageOutputStreamImpl#flushBits flushBits} + * method of {@link ImageOutputStreamImpl ImageOutputStreamImpl} + * to guarantee this. * * @param b an int whose lower 8 bits are to be * written. @@ -99,9 +99,9 @@ public interface ImageOutputStream extends ImageInputStream, DataOutput { * remainder of the current byte is padded with 0s * and written out first. The bit offset will be 0 after the * write. Implementers can use the - * {@link ImageOutputStreamImpl#flushBits flushBits} - * method of {@link ImageOutputStreamImpl - * ImageOutputStreamImpl} to guarantee this. + * {@link ImageOutputStreamImpl#flushBits flushBits} + * method of {@link ImageOutputStreamImpl ImageOutputStreamImpl} + * to guarantee this. * * @param b an array of bytes to be written. * @param off the start offset in the data. @@ -182,8 +182,7 @@ public interface ImageOutputStream extends ImageInputStream, DataOutput { void writeShort(int v) throws IOException; /** - * This method is a synonym for - * {@link #writeShort writeShort}. + * This method is a synonym for {@link #writeShort writeShort}. * * @param v an int containing the char (unsigned * short) value to be written. @@ -430,7 +429,7 @@ public interface ImageOutputStream extends ImageInputStream, DataOutput { * * @exception NullPointerException if s is * null. - * @exception UTFDataFormatException if the modified UTF-8 + * @exception java.io.UTFDataFormatException if the modified UTF-8 * representation of s requires more than 65536 bytes. * @exception IOException if an I/O error occurs. */ From 753a6e3b0cd6042c78907d92058ef4835bc4faa5 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 6 Aug 2013 17:12:37 -0700 Subject: [PATCH 062/118] 8022447: Fix doclint warnings in java.awt.image Reviewed-by: darcy --- .../classes/java/awt/image/BufferStrategy.java | 4 ++-- .../classes/java/awt/image/BufferedImage.java | 16 ++++++++-------- .../classes/java/awt/image/ByteLookupTable.java | 2 +- .../share/classes/java/awt/image/ColorModel.java | 6 +++--- .../classes/java/awt/image/DirectColorModel.java | 12 ++++++------ .../classes/java/awt/image/ImageProducer.java | 4 ++-- .../classes/java/awt/image/IndexColorModel.java | 1 + .../java/awt/image/MemoryImageSource.java | 8 ++++---- .../awt/image/MultiPixelPackedSampleModel.java | 4 ++-- .../classes/java/awt/image/PixelGrabber.java | 14 +++++++------- .../classes/java/awt/image/RGBImageFilter.java | 4 ++-- .../classes/java/awt/image/ShortLookupTable.java | 4 ++-- .../awt/image/SinglePixelPackedSampleModel.java | 4 ++-- .../classes/java/awt/image/WritableRaster.java | 4 ++-- 14 files changed, 44 insertions(+), 43 deletions(-) diff --git a/jdk/src/share/classes/java/awt/image/BufferStrategy.java b/jdk/src/share/classes/java/awt/image/BufferStrategy.java index 82ad5e07d97..de7877330b9 100644 --- a/jdk/src/share/classes/java/awt/image/BufferStrategy.java +++ b/jdk/src/share/classes/java/awt/image/BufferStrategy.java @@ -55,7 +55,7 @@ import java.awt.Image; * Alternatively, the contents of the back buffer can be copied, or * blitted forward in a chain instead of moving the video pointer. *

    - *

    + * 
    {@code
      * Double buffering:
      *
      *                    ***********         ***********
    @@ -72,7 +72,7 @@ import java.awt.Image;
      *          *         * <------ *         * <----- *         *
      *          ***********         ***********        ***********
      *
    - * 
    + * }
    *

    * Here is an example of how buffer strategies can be created and used: *

    
    diff --git a/jdk/src/share/classes/java/awt/image/BufferedImage.java b/jdk/src/share/classes/java/awt/image/BufferedImage.java
    index d510dcc1ba4..b4222b1e740 100644
    --- a/jdk/src/share/classes/java/awt/image/BufferedImage.java
    +++ b/jdk/src/share/classes/java/awt/image/BufferedImage.java
    @@ -602,12 +602,12 @@ public class BufferedImage extends java.awt.Image
          *                  the raster has been premultiplied with alpha.
          * @param properties Hashtable of
          *                  String/Object pairs.
    -     * @exception RasterFormatException if the number and
    +     * @exception RasterFormatException if the number and
          * types of bands in the SampleModel of the
          * Raster do not match the number and types required by
          * the ColorModel to represent its color and alpha
          * components.
    -     * @exception IllegalArgumentException if
    +     * @exception IllegalArgumentException if
          *          raster is incompatible with cm
          * @see ColorModel
          * @see Raster
    @@ -927,7 +927,7 @@ public class BufferedImage extends java.awt.Image
          * each color component in the returned data when
          * using this method.  With a specified coordinate (x, y) in the
          * image, the ARGB pixel can be accessed in this way:
    -     * 

    + *

    * *

          *    pixel   = rgbArray[offset + (y-startY)*scansize + (x-startX)]; 
    @@ -1131,7 +1131,7 @@ public class BufferedImage extends java.awt.Image * @return an {@link Object} that is the property referred to by the * specified name or null if the * properties of this image are not yet known. - * @throws NullPointerException if the property name is null. + * @throws NullPointerException if the property name is null. * @see ImageObserver * @see java.awt.Image#UndefinedProperty */ @@ -1144,7 +1144,7 @@ public class BufferedImage extends java.awt.Image * @param name the property name * @return an Object that is the property referred to by * the specified name. - * @throws NullPointerException if the property name is null. + * @throws NullPointerException if the property name is null. */ public Object getProperty(String name) { if (name == null) { @@ -1196,7 +1196,7 @@ public class BufferedImage extends java.awt.Image * @param h the height of the specified rectangular region * @return a BufferedImage that is the subimage of this * BufferedImage. - * @exception RasterFormatException if the specified + * @exception RasterFormatException if the specified * area is not contained within this BufferedImage. */ public BufferedImage getSubimage (int x, int y, int w, int h) { @@ -1388,7 +1388,7 @@ public class BufferedImage extends java.awt.Image * @param tileY the y index of the requested tile in the tile array * @return a Raster that is the tile defined by the * arguments tileX and tileY. - * @exception ArrayIndexOutOfBoundsException if both + * @exception ArrayIndexOutOfBoundsException if both * tileX and tileY are not * equal to 0 */ @@ -1558,7 +1558,7 @@ public class BufferedImage extends java.awt.Image * @return true if the tile specified by the specified * indices is checked out for writing; false * otherwise. - * @exception ArrayIndexOutOfBoundsException if both + * @exception ArrayIndexOutOfBoundsException if both * tileX and tileY are not equal * to 0 */ diff --git a/jdk/src/share/classes/java/awt/image/ByteLookupTable.java b/jdk/src/share/classes/java/awt/image/ByteLookupTable.java index 6f7e67d7432..35968d62ac8 100644 --- a/jdk/src/share/classes/java/awt/image/ByteLookupTable.java +++ b/jdk/src/share/classes/java/awt/image/ByteLookupTable.java @@ -171,7 +171,7 @@ public class ByteLookupTable extends LookupTable { * @exception ArrayIndexOutOfBoundsException if src is * longer than dst or if for any element * i of src, - * (src[i]&0xff)-offset is either less than + * {@code (src[i]&0xff)-offset} is either less than * zero or greater than or equal to the length of the * lookup table for any band. */ diff --git a/jdk/src/share/classes/java/awt/image/ColorModel.java b/jdk/src/share/classes/java/awt/image/ColorModel.java index 5ce313e1bf3..73f5b49fc28 100644 --- a/jdk/src/share/classes/java/awt/image/ColorModel.java +++ b/jdk/src/share/classes/java/awt/image/ColorModel.java @@ -692,12 +692,12 @@ public abstract class ColorModel implements Transparency{ * DataBuffer.TYPE_INT. * @param inData an array of pixel values * @return the value of the green component of the specified pixel. - * @throws ClassCastException if inData + * @throws ClassCastException if inData * is not a primitive array of type transferType - * @throws ArrayIndexOutOfBoundsException if + * @throws ArrayIndexOutOfBoundsException if * inData is not large enough to hold a pixel value * for this ColorModel - * @throws UnsupportedOperationException if this + * @throws UnsupportedOperationException if this * tranferType is not supported by this * ColorModel */ diff --git a/jdk/src/share/classes/java/awt/image/DirectColorModel.java b/jdk/src/share/classes/java/awt/image/DirectColorModel.java index 751d780ba64..2ddd85c1ad1 100644 --- a/jdk/src/share/classes/java/awt/image/DirectColorModel.java +++ b/jdk/src/share/classes/java/awt/image/DirectColorModel.java @@ -642,12 +642,12 @@ public class DirectColorModel extends PackedColorModel { * @param inData the specified pixel * @return the alpha component of the specified pixel, scaled from * 0 to 255. - * @exception ClassCastException if inData + * @exception ClassCastException if inData * is not a primitive array of type transferType - * @exception ArrayIndexOutOfBoundsException if + * @exception ArrayIndexOutOfBoundsException if * inData is not large enough to hold a pixel value * for this ColorModel - * @exception UnsupportedOperationException if this + * @exception UnsupportedOperationException if this * tranferType is not supported by this * ColorModel */ @@ -1055,7 +1055,7 @@ public class DirectColorModel extends PackedColorModel { * begin retrieving the color and alpha components * @return an int pixel value in this * ColorModel corresponding to the specified components. - * @exception ArrayIndexOutOfBoundsException if + * @exception ArrayIndexOutOfBoundsException if * the components array is not large enough to * hold all of the color and alpha components starting at * offset @@ -1097,9 +1097,9 @@ public class DirectColorModel extends PackedColorModel { * and alpha components * @return an Object representing an array of color and * alpha components. - * @exception ClassCastException if obj + * @exception ClassCastException if obj * is not a primitive array of type transferType - * @exception ArrayIndexOutOfBoundsException if + * @exception ArrayIndexOutOfBoundsException if * obj is not large enough to hold a pixel value * for this ColorModel or the components * array is not large enough to hold all of the color and alpha diff --git a/jdk/src/share/classes/java/awt/image/ImageProducer.java b/jdk/src/share/classes/java/awt/image/ImageProducer.java index 768aad50dd9..a419f8bd644 100644 --- a/jdk/src/share/classes/java/awt/image/ImageProducer.java +++ b/jdk/src/share/classes/java/awt/image/ImageProducer.java @@ -100,11 +100,11 @@ public interface ImageProducer { * ImageProducer should respond by executing * the following minimum set of ImageConsumer * method calls: - *
    +     * 
    {@code
          *  ic.setHints(TOPDOWNLEFTRIGHT | < otherhints >);
          *  ic.setPixels(...);      // As many times as needed
          *  ic.imageComplete();
    -     * 
    + * }
    * @param ic the specified ImageConsumer * @see ImageConsumer#setHints */ diff --git a/jdk/src/share/classes/java/awt/image/IndexColorModel.java b/jdk/src/share/classes/java/awt/image/IndexColorModel.java index fabe8d20432..d26e3d381be 100644 --- a/jdk/src/share/classes/java/awt/image/IndexColorModel.java +++ b/jdk/src/share/classes/java/awt/image/IndexColorModel.java @@ -98,6 +98,7 @@ import java.math.BigInteger; * Index values greater than or equal to the map size, but less than * 2n, are undefined and return 0 for all color and * alpha components. + * *

    * For those methods that use a primitive array pixel representation of * type transferType, the array length is always one. diff --git a/jdk/src/share/classes/java/awt/image/MemoryImageSource.java b/jdk/src/share/classes/java/awt/image/MemoryImageSource.java index b5fd99b475f..90519ce26e4 100644 --- a/jdk/src/share/classes/java/awt/image/MemoryImageSource.java +++ b/jdk/src/share/classes/java/awt/image/MemoryImageSource.java @@ -37,7 +37,7 @@ import java.util.Enumeration; * uses an array to produce pixel values for an Image. Here is an example * which calculates a 100x100 image representing a fade from black to blue * along the X axis and a fade from black to red along the Y axis: - *

    + * 
    {@code
      *
      *      int w = 100;
      *      int h = 100;
    @@ -52,12 +52,12 @@ import java.util.Enumeration;
      *      }
      *      Image img = createImage(new MemoryImageSource(w, h, pix, 0, w));
      *
    - * 
    + * }
    * The MemoryImageSource is also capable of managing a memory image which * varies over time to allow animation or custom rendering. Here is an * example showing how to set up the animation source and signal changes * in the data (adapted from the MemoryAnimationSourceDemo by Garth Dickie): - *
    + * 
    {@code
      *
      *      int pixels[];
      *      MemoryImageSource source;
    @@ -96,7 +96,7 @@ import java.util.Enumeration;
      *          }
      *      }
      *
    - * 
    + * }
    * * @see ImageProducer * diff --git a/jdk/src/share/classes/java/awt/image/MultiPixelPackedSampleModel.java b/jdk/src/share/classes/java/awt/image/MultiPixelPackedSampleModel.java index 43d3a8080ba..8095dad2fc5 100644 --- a/jdk/src/share/classes/java/awt/image/MultiPixelPackedSampleModel.java +++ b/jdk/src/share/classes/java/awt/image/MultiPixelPackedSampleModel.java @@ -52,14 +52,14 @@ package java.awt.image; * x, y from DataBuffer data * and storing the pixel data in data elements of type * dataType: - *
    + * 
    {@code
      *      int dataElementSize = DataBuffer.getDataTypeSize(dataType);
      *      int bitnum = dataBitOffset + x*pixelBitStride;
      *      int element = data.getElem(y*scanlineStride + bitnum/dataElementSize);
      *      int shift = dataElementSize - (bitnum & (dataElementSize-1))
      *                  - pixelBitStride;
      *      int pixel = (element >> shift) & ((1 << pixelBitStride) - 1);
    - * 
    + * }
    */ public class MultiPixelPackedSampleModel extends SampleModel diff --git a/jdk/src/share/classes/java/awt/image/PixelGrabber.java b/jdk/src/share/classes/java/awt/image/PixelGrabber.java index 85dde7875ce..2053ed71bdc 100644 --- a/jdk/src/share/classes/java/awt/image/PixelGrabber.java +++ b/jdk/src/share/classes/java/awt/image/PixelGrabber.java @@ -35,7 +35,7 @@ import java.awt.Image; * The PixelGrabber class implements an ImageConsumer which can be attached * to an Image or ImageProducer object to retrieve a subset of the pixels * in that image. Here is an example: - *
    + * 
    {@code
      *
      * public void handlesinglepixel(int x, int y, int pixel) {
      *      int alpha = (pixel >> 24) & 0xff;
    @@ -65,7 +65,7 @@ import java.awt.Image;
      *      }
      * }
      *
    - * 
    + * }
    * * @see ColorModel#getRGBdefault * @@ -165,8 +165,8 @@ public class PixelGrabber implements ImageConsumer { * accumulated in the default RGB ColorModel. If the forceRGB * parameter is true, then the pixels will be accumulated in the * default RGB ColorModel anyway. A buffer is allocated by the - * PixelGrabber to hold the pixels in either case. If (w < 0) or - * (h < 0), then they will default to the remaining width and + * PixelGrabber to hold the pixels in either case. If {@code (w < 0)} or + * {@code (h < 0)}, then they will default to the remaining width and * height of the source data when that information is delivered. * @param img the image to retrieve the image data from * @param x the x coordinate of the upper left corner of the rectangle @@ -233,10 +233,10 @@ public class PixelGrabber implements ImageConsumer { * behaves in the following ways, depending on the value of * ms: *
      - *
    • If ms == 0, waits until all pixels are delivered - *
    • If ms > 0, waits until all pixels are delivered + *
    • If {@code ms == 0}, waits until all pixels are delivered + *
    • If {@code ms > 0}, waits until all pixels are delivered * as timeout expires. - *
    • If ms < 0, returns true if all pixels + *
    • If {@code ms < 0}, returns true if all pixels * are grabbed, false otherwise and does not wait. *
    * @param ms the number of milliseconds to wait for the image pixels diff --git a/jdk/src/share/classes/java/awt/image/RGBImageFilter.java b/jdk/src/share/classes/java/awt/image/RGBImageFilter.java index 59d77e3428d..2f807ddf50f 100644 --- a/jdk/src/share/classes/java/awt/image/RGBImageFilter.java +++ b/jdk/src/share/classes/java/awt/image/RGBImageFilter.java @@ -39,7 +39,7 @@ import java.awt.image.ColorModel; * The only method which needs to be defined to create a useable image * filter is the filterRGB method. Here is an example of a definition * of a filter which swaps the red and blue components of an image: - *
    + * 
    {@code
      *
      *      class RedBlueSwapFilter extends RGBImageFilter {
      *          public RedBlueSwapFilter() {
    @@ -56,7 +56,7 @@ import java.awt.image.ColorModel;
      *          }
      *      }
      *
    - * 
    + * }
    * * @see FilteredImageSource * @see ImageFilter diff --git a/jdk/src/share/classes/java/awt/image/ShortLookupTable.java b/jdk/src/share/classes/java/awt/image/ShortLookupTable.java index 09309e0045e..f0c18e0878e 100644 --- a/jdk/src/share/classes/java/awt/image/ShortLookupTable.java +++ b/jdk/src/share/classes/java/awt/image/ShortLookupTable.java @@ -114,7 +114,7 @@ public class ShortLookupTable extends LookupTable { * @exception ArrayIndexOutOfBoundsException if src is * longer than dst or if for any element * i of src, - * (src[i]&0xffff)-offset is either less than + * {@code (src[i]&0xffff)-offset} is either less than * zero or greater than or equal to the length of the * lookup table for any band. */ @@ -165,7 +165,7 @@ public class ShortLookupTable extends LookupTable { * @exception ArrayIndexOutOfBoundsException if src is * longer than dst or if for any element * i of src, - * (src[i]&0xffff)-offset is either less than + * {@code (src[i]&0xffff)-offset} is either less than * zero or greater than or equal to the length of the * lookup table for any band. */ diff --git a/jdk/src/share/classes/java/awt/image/SinglePixelPackedSampleModel.java b/jdk/src/share/classes/java/awt/image/SinglePixelPackedSampleModel.java index b99eda6c79e..58c1db0b726 100644 --- a/jdk/src/share/classes/java/awt/image/SinglePixelPackedSampleModel.java +++ b/jdk/src/share/classes/java/awt/image/SinglePixelPackedSampleModel.java @@ -57,10 +57,10 @@ import java.util.Arrays; * The following code illustrates extracting the bits of the sample * representing band b for pixel x,y * from DataBuffer data: - *
    + * 
    {@code
      *      int sample = data.getElem(y * scanlineStride + x);
      *      sample = (sample & bitMasks[b]) >>> bitOffsets[b];
    - * 
    + * }
    */ public class SinglePixelPackedSampleModel extends SampleModel diff --git a/jdk/src/share/classes/java/awt/image/WritableRaster.java b/jdk/src/share/classes/java/awt/image/WritableRaster.java index d38d7af3f60..190596af0a2 100644 --- a/jdk/src/share/classes/java/awt/image/WritableRaster.java +++ b/jdk/src/share/classes/java/awt/image/WritableRaster.java @@ -372,13 +372,13 @@ public class WritableRaster extends Raster { * integral type and less than or equal to 32 bits in size, then calling * this method is equivalent to executing the following code for all * x,y addresses valid in both Rasters. - *
    +     * 
    {@code
          *       Raster srcRaster;
          *       WritableRaster dstRaster;
          *       for (int b = 0; b < srcRaster.getNumBands(); b++) {
          *           dstRaster.setSample(x, y, b, srcRaster.getSample(x, y, b));
          *       }
    -     * 
    + * }
    * Thus, when copying an integral type source to an integral type * destination, if the source sample size is greater than the destination * sample size for a particular band, the high order bits of the source From b2cc9db8d8a46f01fca2f51843208693c372f70e Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Tue, 6 Aug 2013 17:42:47 -0700 Subject: [PATCH 063/118] 8022446: Fix serial warnings in java.util.stream Reviewed-by: darcy --- .../util/stream/AbstractShortCircuitTask.java | 1 + .../java/util/stream/AbstractTask.java | 4 ++++ .../classes/java/util/stream/FindOps.java | 1 + .../classes/java/util/stream/ForEachOps.java | 2 ++ .../classes/java/util/stream/MatchOps.java | 1 + .../share/classes/java/util/stream/Nodes.java | 19 +++++++++++++++++++ .../classes/java/util/stream/ReduceOps.java | 3 ++- .../classes/java/util/stream/SliceOps.java | 1 + 8 files changed, 31 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java b/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java index 7a102e80d8e..484e3efb5ec 100644 --- a/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java +++ b/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java @@ -39,6 +39,7 @@ import java.util.concurrent.atomic.AtomicReference; * @param type of child and sibling tasks * @since 1.8 */ +@SuppressWarnings("serial") abstract class AbstractShortCircuitTask> extends AbstractTask { diff --git a/jdk/src/share/classes/java/util/stream/AbstractTask.java b/jdk/src/share/classes/java/util/stream/AbstractTask.java index b8344e84c59..33de7d5c52a 100644 --- a/jdk/src/share/classes/java/util/stream/AbstractTask.java +++ b/jdk/src/share/classes/java/util/stream/AbstractTask.java @@ -73,6 +73,9 @@ import java.util.concurrent.ForkJoinPool; * } * }
    * + *

    Serialization is not supported as there is no intention to serialize + * tasks managed by stream ops. + * * @param Type of elements input to the pipeline * @param Type of elements output from the pipeline * @param Type of intermediate result, which may be different from operation @@ -80,6 +83,7 @@ import java.util.concurrent.ForkJoinPool; * @param Type of parent, child and sibling tasks * @since 1.8 */ +@SuppressWarnings("serial") abstract class AbstractTask> extends CountedCompleter { diff --git a/jdk/src/share/classes/java/util/stream/FindOps.java b/jdk/src/share/classes/java/util/stream/FindOps.java index 6b34b24244d..197d99c0890 100644 --- a/jdk/src/share/classes/java/util/stream/FindOps.java +++ b/jdk/src/share/classes/java/util/stream/FindOps.java @@ -246,6 +246,7 @@ final class FindOps { * @param Output element type from the stream pipeline * @param Result type from the find operation */ + @SuppressWarnings("serial") private static final class FindTask extends AbstractShortCircuitTask> { private final FindOp op; diff --git a/jdk/src/share/classes/java/util/stream/ForEachOps.java b/jdk/src/share/classes/java/util/stream/ForEachOps.java index 0d9ea6a69c3..2c343fbc3c1 100644 --- a/jdk/src/share/classes/java/util/stream/ForEachOps.java +++ b/jdk/src/share/classes/java/util/stream/ForEachOps.java @@ -249,6 +249,7 @@ final class ForEachOps { } /** A {@code ForkJoinTask} for performing a parallel for-each operation */ + @SuppressWarnings("serial") static final class ForEachTask extends CountedCompleter { private Spliterator spliterator; private final Sink sink; @@ -314,6 +315,7 @@ final class ForEachOps { * A {@code ForkJoinTask} for performing a parallel for-each operation * which visits the elements in encounter order */ + @SuppressWarnings("serial") static final class ForEachOrderedTask extends CountedCompleter { private final PipelineHelper helper; private Spliterator spliterator; diff --git a/jdk/src/share/classes/java/util/stream/MatchOps.java b/jdk/src/share/classes/java/util/stream/MatchOps.java index 0f9362adfc9..cc809e4acea 100644 --- a/jdk/src/share/classes/java/util/stream/MatchOps.java +++ b/jdk/src/share/classes/java/util/stream/MatchOps.java @@ -274,6 +274,7 @@ final class MatchOps { * @param the type of source elements for the pipeline * @param the type of output elements for the pipeline */ + @SuppressWarnings("serial") private static final class MatchTask extends AbstractShortCircuitTask> { private final MatchOp op; diff --git a/jdk/src/share/classes/java/util/stream/Nodes.java b/jdk/src/share/classes/java/util/stream/Nodes.java index 4edf324a84c..e39a5733717 100644 --- a/jdk/src/share/classes/java/util/stream/Nodes.java +++ b/jdk/src/share/classes/java/util/stream/Nodes.java @@ -1786,6 +1786,10 @@ final class Nodes { } } + /* + * This and subclasses are not intended to be serializable + */ + @SuppressWarnings("serial") private static abstract class SizedCollectorTask, K extends SizedCollectorTask> extends CountedCompleter @@ -1855,6 +1859,7 @@ final class Nodes { fence = (int) offset + (int) length; } + @SuppressWarnings("serial") static final class OfRef extends SizedCollectorTask, OfRef> implements Sink { @@ -1886,6 +1891,7 @@ final class Nodes { } } + @SuppressWarnings("serial") static final class OfInt extends SizedCollectorTask> implements Sink.OfInt { @@ -1917,6 +1923,7 @@ final class Nodes { } } + @SuppressWarnings("serial") static final class OfLong extends SizedCollectorTask> implements Sink.OfLong { @@ -1948,6 +1955,7 @@ final class Nodes { } } + @SuppressWarnings("serial") static final class OfDouble extends SizedCollectorTask> implements Sink.OfDouble { @@ -1980,6 +1988,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static abstract class ToArrayTask, K extends ToArrayTask> extends CountedCompleter { @@ -2025,6 +2034,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static final class OfRef extends ToArrayTask, OfRef> { private final T[] array; @@ -2050,6 +2060,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static class OfPrimitive, T_NODE extends Node.OfPrimitive> @@ -2077,6 +2088,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static final class OfInt extends OfPrimitive { private OfInt(Node.OfInt node, int[] array, int offset) { @@ -2084,6 +2096,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static final class OfLong extends OfPrimitive { private OfLong(Node.OfLong node, long[] array, int offset) { @@ -2091,6 +2104,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static final class OfDouble extends OfPrimitive { private OfDouble(Node.OfDouble node, double[] array, int offset) { @@ -2099,6 +2113,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static class CollectorTask, T_BUILDER extends Node.Builder> extends AbstractTask> { protected final PipelineHelper helper; @@ -2141,6 +2156,7 @@ final class Nodes { super.onCompletion(caller); } + @SuppressWarnings("serial") private static final class OfRef extends CollectorTask, Node.Builder> { OfRef(PipelineHelper helper, @@ -2150,6 +2166,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static final class OfInt extends CollectorTask { OfInt(PipelineHelper helper, Spliterator spliterator) { @@ -2157,6 +2174,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static final class OfLong extends CollectorTask { OfLong(PipelineHelper helper, Spliterator spliterator) { @@ -2164,6 +2182,7 @@ final class Nodes { } } + @SuppressWarnings("serial") private static final class OfDouble extends CollectorTask { OfDouble(PipelineHelper helper, Spliterator spliterator) { diff --git a/jdk/src/share/classes/java/util/stream/ReduceOps.java b/jdk/src/share/classes/java/util/stream/ReduceOps.java index 20d3336863b..754a4774a3d 100644 --- a/jdk/src/share/classes/java/util/stream/ReduceOps.java +++ b/jdk/src/share/classes/java/util/stream/ReduceOps.java @@ -43,7 +43,7 @@ import java.util.function.ObjLongConsumer; import java.util.function.Supplier; /** - * Factory for the creating instances of {@code TerminalOp) that implement + * Factory for creating instances of {@code TerminalOp} that implement * reductions. * * @since 1.8 @@ -718,6 +718,7 @@ final class ReduceOps { /** * A {@code ForkJoinTask} for performing a parallel reduce operation. */ + @SuppressWarnings("serial") private static final class ReduceTask> extends AbstractTask> { diff --git a/jdk/src/share/classes/java/util/stream/SliceOps.java b/jdk/src/share/classes/java/util/stream/SliceOps.java index ac538f2d86c..09e14f637f4 100644 --- a/jdk/src/share/classes/java/util/stream/SliceOps.java +++ b/jdk/src/share/classes/java/util/stream/SliceOps.java @@ -550,6 +550,7 @@ final class SliceOps { * @param Input element type to the stream pipeline * @param Output element type from the stream pipeline */ + @SuppressWarnings("serial") private static final class SliceTask extends AbstractShortCircuitTask, SliceTask> { private final AbstractPipeline op; From f387416fed637a44d3e8cab0370fd858cdf7d042 Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Tue, 6 Aug 2013 18:16:02 -0700 Subject: [PATCH 064/118] 8022478: Fix Warnings In sun.net.www.protocol.http Package Reviewed-by: darcy --- .../share/classes/sun/net/www/protocol/http/AuthCacheValue.java | 2 ++ .../classes/sun/net/www/protocol/http/AuthenticationInfo.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/AuthCacheValue.java b/jdk/src/share/classes/sun/net/www/protocol/http/AuthCacheValue.java index d2c003ee2bb..1ebef35e592 100644 --- a/jdk/src/share/classes/sun/net/www/protocol/http/AuthCacheValue.java +++ b/jdk/src/share/classes/sun/net/www/protocol/http/AuthCacheValue.java @@ -37,6 +37,8 @@ import java.net.PasswordAuthentication; public abstract class AuthCacheValue implements Serializable { + static final long serialVersionUID = 735249334068211611L; + public enum Type { Proxy, Server diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java b/jdk/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java index 23e84ba4462..e44bb3d76e7 100644 --- a/jdk/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java +++ b/jdk/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java @@ -51,6 +51,8 @@ import sun.net.www.HeaderParser; public abstract class AuthenticationInfo extends AuthCacheValue implements Cloneable { + static final long serialVersionUID = -2588378268010453259L; + // Constants saying what kind of authroization this is. This determines // the namespace in the hash table lookup. public static final char SERVER_AUTHENTICATION = 's'; From 67517a374c09166c3880c48d137cbed885a4b026 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Tue, 6 Aug 2013 18:18:12 -0700 Subject: [PATCH 065/118] 8022476: cleanup some raw types and unchecked warnings in java.util.stream Co-authored-by: Henry Jen Reviewed-by: darcy --- jdk/src/share/classes/java/util/Optional.java | 2 +- .../java/util/stream/AbstractPipeline.java | 49 ++++++++++++++----- .../util/stream/AbstractShortCircuitTask.java | 3 +- .../java/util/stream/DoublePipeline.java | 2 + .../classes/java/util/stream/IntPipeline.java | 4 ++ .../java/util/stream/LongPipeline.java | 4 ++ .../share/classes/java/util/stream/Nodes.java | 3 +- .../classes/java/util/stream/ReduceOps.java | 2 +- .../java/util/stream/ReferencePipeline.java | 7 ++- .../share/classes/java/util/stream/Sink.java | 4 ++ .../classes/java/util/stream/SortedOps.java | 8 +-- .../java/util/stream/StreamSpliterators.java | 5 +- 12 files changed, 69 insertions(+), 24 deletions(-) diff --git a/jdk/src/share/classes/java/util/Optional.java b/jdk/src/share/classes/java/util/Optional.java index 5eed705255a..ce2a33d1de6 100644 --- a/jdk/src/share/classes/java/util/Optional.java +++ b/jdk/src/share/classes/java/util/Optional.java @@ -307,7 +307,7 @@ public final class Optional { return false; } - Optional other = (Optional) obj; + Optional other = (Optional) obj; return Objects.equals(value, other.value); } diff --git a/jdk/src/share/classes/java/util/stream/AbstractPipeline.java b/jdk/src/share/classes/java/util/stream/AbstractPipeline.java index bde7efb1f80..3b2f5bdc5f7 100644 --- a/jdk/src/share/classes/java/util/stream/AbstractPipeline.java +++ b/jdk/src/share/classes/java/util/stream/AbstractPipeline.java @@ -75,11 +75,13 @@ abstract class AbstractPipeline> * Backlink to the head of the pipeline chain (self if this is the source * stage). */ + @SuppressWarnings("rawtypes") private final AbstractPipeline sourceStage; /** * The "upstream" pipeline, or null if this is the source stage. */ + @SuppressWarnings("rawtypes") private final AbstractPipeline previousStage; /** @@ -92,6 +94,7 @@ abstract class AbstractPipeline> * The next stage in the pipeline, or null if this is the last stage. * Effectively final at the point of linking to the next pipeline. */ + @SuppressWarnings("rawtypes") private AbstractPipeline nextStage; /** @@ -222,8 +225,8 @@ abstract class AbstractPipeline> linkedOrConsumed = true; return isParallel() - ? (R) terminalOp.evaluateParallel(this, sourceSpliterator(terminalOp.getOpFlags())) - : (R) terminalOp.evaluateSequential(this, sourceSpliterator(terminalOp.getOpFlags())); + ? terminalOp.evaluateParallel(this, sourceSpliterator(terminalOp.getOpFlags())) + : terminalOp.evaluateSequential(this, sourceSpliterator(terminalOp.getOpFlags())); } /** @@ -232,6 +235,7 @@ abstract class AbstractPipeline> * @param generator the array generator to be used to create array instances * @return a flat array-backed Node that holds the collected output elements */ + @SuppressWarnings("unchecked") final Node evaluateToArrayNode(IntFunction generator) { if (linkedOrConsumed) throw new IllegalStateException("stream has already been operated upon"); @@ -256,6 +260,7 @@ abstract class AbstractPipeline> * @throws IllegalStateException if this pipeline stage is not the source * stage. */ + @SuppressWarnings("unchecked") final Spliterator sourceStageSpliterator() { if (this != sourceStage) throw new IllegalStateException(); @@ -265,11 +270,13 @@ abstract class AbstractPipeline> linkedOrConsumed = true; if (sourceStage.sourceSpliterator != null) { + @SuppressWarnings("unchecked") Spliterator s = sourceStage.sourceSpliterator; sourceStage.sourceSpliterator = null; return s; } else if (sourceStage.sourceSupplier != null) { + @SuppressWarnings("unchecked") Spliterator s = (Spliterator) sourceStage.sourceSupplier.get(); sourceStage.sourceSupplier = null; return s; @@ -282,12 +289,14 @@ abstract class AbstractPipeline> // BaseStream @Override + @SuppressWarnings("unchecked") public final S sequential() { sourceStage.parallel = false; return (S) this; } @Override + @SuppressWarnings("unchecked") public final S parallel() { sourceStage.parallel = true; return (S) this; @@ -295,6 +304,7 @@ abstract class AbstractPipeline> // Primitive specialization use co-variant overrides, hence is not final @Override + @SuppressWarnings("unchecked") public Spliterator spliterator() { if (linkedOrConsumed) throw new IllegalStateException("stream has already been operated upon"); @@ -302,12 +312,14 @@ abstract class AbstractPipeline> if (this == sourceStage) { if (sourceStage.sourceSpliterator != null) { - Spliterator s = sourceStage.sourceSpliterator; + @SuppressWarnings("unchecked") + Spliterator s = (Spliterator) sourceStage.sourceSpliterator; sourceStage.sourceSpliterator = null; return s; } else if (sourceStage.sourceSupplier != null) { - Supplier> s = sourceStage.sourceSupplier; + @SuppressWarnings("unchecked") + Supplier> s = (Supplier>) sourceStage.sourceSupplier; sourceStage.sourceSupplier = null; return lazySpliterator(s); } @@ -349,10 +361,11 @@ abstract class AbstractPipeline> * @param terminalFlags Operation flags for the terminal operation */ private void parallelPrepare(int terminalFlags) { + @SuppressWarnings("rawtypes") AbstractPipeline backPropagationHead = sourceStage; if (sourceStage.sourceAnyStateful) { int depth = 1; - for (AbstractPipeline u = sourceStage, p = sourceStage.nextStage; + for ( @SuppressWarnings("rawtypes") AbstractPipeline u = sourceStage, p = sourceStage.nextStage; p != null; u = p, p = p.nextStage) { int thisOpFlags = p.sourceOrOpFlags; @@ -383,7 +396,7 @@ abstract class AbstractPipeline> // Apply the upstream terminal flags if (terminalFlags != 0) { int upstreamTerminalFlags = terminalFlags & StreamOpFlag.UPSTREAM_TERMINAL_OP_MASK; - for (AbstractPipeline p = backPropagationHead; p.nextStage != null; p = p.nextStage) { + for ( @SuppressWarnings("rawtypes") AbstractPipeline p = backPropagationHead; p.nextStage != null; p = p.nextStage) { p.combinedFlags = StreamOpFlag.combineOpFlags(upstreamTerminalFlags, p.combinedFlags); } @@ -398,6 +411,7 @@ abstract class AbstractPipeline> * of all computations up to and including the most recent stateful * operation. */ + @SuppressWarnings("unchecked") private Spliterator sourceSpliterator(int terminalFlags) { // Get the source spliterator of the pipeline Spliterator spliterator = null; @@ -421,7 +435,7 @@ abstract class AbstractPipeline> // Adapt the source spliterator, evaluating each stateful op // in the pipeline up to and including this pipeline stage - for (AbstractPipeline u = sourceStage, p = sourceStage.nextStage, e = this; + for ( @SuppressWarnings("rawtypes") AbstractPipeline u = sourceStage, p = sourceStage.nextStage, e = this; u != e; u = p, p = p.nextStage) { @@ -442,6 +456,7 @@ abstract class AbstractPipeline> @Override final StreamShape getSourceShape() { + @SuppressWarnings("rawtypes") AbstractPipeline p = AbstractPipeline.this; while (p.depth > 0) { p = p.previousStage; @@ -475,7 +490,9 @@ abstract class AbstractPipeline> } @Override + @SuppressWarnings("unchecked") final void copyIntoWithCancel(Sink wrappedSink, Spliterator spliterator) { + @SuppressWarnings({"rawtypes","unchecked"}) AbstractPipeline p = AbstractPipeline.this; while (p.depth > 0) { p = p.previousStage; @@ -495,16 +512,18 @@ abstract class AbstractPipeline> } @Override + @SuppressWarnings("unchecked") final Sink wrapSink(Sink sink) { Objects.requireNonNull(sink); - for (AbstractPipeline p=AbstractPipeline.this; p.depth > 0; p=p.previousStage) { + for ( @SuppressWarnings("rawtypes") AbstractPipeline p=AbstractPipeline.this; p.depth > 0; p=p.previousStage) { sink = p.opWrapSink(p.previousStage.combinedFlags, sink); } return (Sink) sink; } @Override + @SuppressWarnings("unchecked") final Spliterator wrapSpliterator(Spliterator sourceSpliterator) { if (depth == 0) { return (Spliterator) sourceSpliterator; @@ -591,16 +610,19 @@ abstract class AbstractPipeline> /** * Make a node builder compatible with this stream shape. * - * @param exactSizeIfKnown if {@literal >=0}, then a node builder will be created that - * has a fixed capacity of at most sizeIfKnown elements. If {@literal < 0}, - * then the node builder has an unfixed capacity. A fixed capacity node - * builder will throw exceptions if an element is added after builder has - * reached capacity, or is built before the builder has reached capacity. + * @param exactSizeIfKnown if {@literal >=0}, then a node builder will be + * created that has a fixed capacity of at most sizeIfKnown elements. If + * {@literal < 0}, then the node builder has an unfixed capacity. A fixed + * capacity node builder will throw exceptions if an element is added after + * builder has reached capacity, or is built before the builder has reached + * capacity. + * * @param generator the array generator to be used to create instances of a * T[] array. For implementations supporting primitive nodes, this parameter * may be ignored. * @return a node builder */ + @Override abstract Node.Builder makeNodeBuilder(long exactSizeIfKnown, IntFunction generator); @@ -679,6 +701,7 @@ abstract class AbstractPipeline> * @param spliterator the source {@code Spliterator} * @return a {@code Spliterator} describing the result of the evaluation */ + @SuppressWarnings("unchecked") Spliterator opEvaluateParallelLazy(PipelineHelper helper, Spliterator spliterator) { return opEvaluateParallel(helper, spliterator, i -> (E_OUT[]) new Object[i]).spliterator(); diff --git a/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java b/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java index 484e3efb5ec..bbf09f03b14 100644 --- a/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java +++ b/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java @@ -220,7 +220,8 @@ abstract class AbstractShortCircuitTask } @Override + @SuppressWarnings("unchecked") final Spliterator.OfDouble lazySpliterator(Supplier> supplier) { return new StreamSpliterators.DelegatingSpliterator.OfDouble((Supplier) supplier); } @@ -209,6 +210,7 @@ abstract class DoublePipeline Sink opWrapSink(int flags, Sink sink) { return new Sink.ChainedDouble(sink) { @Override + @SuppressWarnings("unchecked") public void accept(double t) { downstream.accept(mapper.apply(t)); } diff --git a/jdk/src/share/classes/java/util/stream/IntPipeline.java b/jdk/src/share/classes/java/util/stream/IntPipeline.java index 10cfb890719..d380e4a3bf5 100644 --- a/jdk/src/share/classes/java/util/stream/IntPipeline.java +++ b/jdk/src/share/classes/java/util/stream/IntPipeline.java @@ -150,6 +150,7 @@ abstract class IntPipeline } @Override + @SuppressWarnings("unchecked") final Spliterator.OfInt lazySpliterator(Supplier> supplier) { return new StreamSpliterators.DelegatingSpliterator.OfInt((Supplier) supplier); } @@ -190,6 +191,7 @@ abstract class IntPipeline Sink opWrapSink(int flags, Sink sink) { return new Sink.ChainedInt(sink) { @Override + @SuppressWarnings("unchecked") public void accept(int t) { downstream.accept((long) t); } @@ -206,6 +208,7 @@ abstract class IntPipeline Sink opWrapSink(int flags, Sink sink) { return new Sink.ChainedInt(sink) { @Override + @SuppressWarnings("unchecked") public void accept(int t) { downstream.accept((double) t); } @@ -245,6 +248,7 @@ abstract class IntPipeline Sink opWrapSink(int flags, Sink sink) { return new Sink.ChainedInt(sink) { @Override + @SuppressWarnings("unchecked") public void accept(int t) { downstream.accept(mapper.apply(t)); } diff --git a/jdk/src/share/classes/java/util/stream/LongPipeline.java b/jdk/src/share/classes/java/util/stream/LongPipeline.java index e52a5cade16..083f7bb8b2b 100644 --- a/jdk/src/share/classes/java/util/stream/LongPipeline.java +++ b/jdk/src/share/classes/java/util/stream/LongPipeline.java @@ -148,6 +148,7 @@ abstract class LongPipeline } @Override + @SuppressWarnings("unchecked") final Spliterator.OfLong lazySpliterator(Supplier> supplier) { return new StreamSpliterators.DelegatingSpliterator.OfLong((Supplier) supplier); } @@ -209,6 +210,7 @@ abstract class LongPipeline Sink opWrapSink(int flags, Sink sink) { return new Sink.ChainedLong(sink) { @Override + @SuppressWarnings("unchecked") public void accept(long t) { downstream.accept(mapper.applyAsLong(t)); } @@ -226,6 +228,7 @@ abstract class LongPipeline Sink opWrapSink(int flags, Sink sink) { return new Sink.ChainedLong(sink) { @Override + @SuppressWarnings("unchecked") public void accept(long t) { downstream.accept(mapper.apply(t)); } @@ -243,6 +246,7 @@ abstract class LongPipeline Sink opWrapSink(int flags, Sink sink) { return new Sink.ChainedLong(sink) { @Override + @SuppressWarnings("unchecked") public void accept(long t) { downstream.accept(mapper.applyAsInt(t)); } diff --git a/jdk/src/share/classes/java/util/stream/Nodes.java b/jdk/src/share/classes/java/util/stream/Nodes.java index e39a5733717..687174462b3 100644 --- a/jdk/src/share/classes/java/util/stream/Nodes.java +++ b/jdk/src/share/classes/java/util/stream/Nodes.java @@ -60,6 +60,7 @@ final class Nodes { */ static final long MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + @SuppressWarnings("raw") private static final Node EMPTY_NODE = new EmptyNode.OfRef(); private static final Node.OfInt EMPTY_INT_NODE = new EmptyNode.OfInt(); private static final Node.OfLong EMPTY_LONG_NODE = new EmptyNode.OfLong(); @@ -2150,7 +2151,7 @@ final class Nodes { } @Override - public void onCompletion(CountedCompleter caller) { + public void onCompletion(CountedCompleter caller) { if (!isLeaf()) setLocalResult(concFactory.apply(leftChild.getLocalResult(), rightChild.getLocalResult())); super.onCompletion(caller); diff --git a/jdk/src/share/classes/java/util/stream/ReduceOps.java b/jdk/src/share/classes/java/util/stream/ReduceOps.java index 754a4774a3d..3a0f81a0f72 100644 --- a/jdk/src/share/classes/java/util/stream/ReduceOps.java +++ b/jdk/src/share/classes/java/util/stream/ReduceOps.java @@ -748,7 +748,7 @@ final class ReduceOps { } @Override - public void onCompletion(CountedCompleter caller) { + public void onCompletion(CountedCompleter caller) { if (!isLeaf()) { S leftResult = leftChild.getLocalResult(); leftResult.combine(rightChild.getLocalResult()); diff --git a/jdk/src/share/classes/java/util/stream/ReferencePipeline.java b/jdk/src/share/classes/java/util/stream/ReferencePipeline.java index 5e67b31c467..c201950d88c 100644 --- a/jdk/src/share/classes/java/util/stream/ReferencePipeline.java +++ b/jdk/src/share/classes/java/util/stream/ReferencePipeline.java @@ -170,9 +170,10 @@ abstract class ReferencePipeline } @Override + @SuppressWarnings("unchecked") public void accept(P_OUT u) { if (predicate.test(u)) - downstream.accept(u); + downstream.accept((Object) u); } }; } @@ -180,6 +181,7 @@ abstract class ReferencePipeline } @Override + @SuppressWarnings("unchecked") public final Stream map(Function mapper) { Objects.requireNonNull(mapper); return new StatelessOp(this, StreamShape.REFERENCE, @@ -262,6 +264,7 @@ abstract class ReferencePipeline } @Override + @SuppressWarnings("unchecked") public void accept(P_OUT u) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it Stream result = mapper.apply(u); @@ -363,6 +366,7 @@ abstract class ReferencePipeline Sink opWrapSink(int flags, Sink sink) { return new Sink.ChainedReference(sink) { @Override + @SuppressWarnings("unchecked") public void accept(P_OUT u) { tee.accept(u); downstream.accept(u); @@ -439,6 +443,7 @@ abstract class ReferencePipeline // The runtime type of U is never checked for equality with the component type of the runtime type of A[]. // Runtime checking will be performed when an element is stored in A[], thus if A is not a // super type of U an ArrayStoreException will be thrown. + @SuppressWarnings("rawtypes") IntFunction rawGenerator = (IntFunction) generator; return (A[]) Nodes.flatten(evaluateToArrayNode(rawGenerator), rawGenerator) .asArray(rawGenerator); diff --git a/jdk/src/share/classes/java/util/stream/Sink.java b/jdk/src/share/classes/java/util/stream/Sink.java index 33e256c7b9b..987d0e9efa7 100644 --- a/jdk/src/share/classes/java/util/stream/Sink.java +++ b/jdk/src/share/classes/java/util/stream/Sink.java @@ -242,6 +242,7 @@ interface Sink extends Consumer { * {@code accept()} method on the downstream {@code Sink}. */ static abstract class ChainedReference implements Sink { + @SuppressWarnings("rawtypes") protected final Sink downstream; public ChainedReference(Sink downstream) { @@ -274,6 +275,7 @@ interface Sink extends Consumer { * {@code accept()} method on the downstream {@code Sink}. */ static abstract class ChainedInt implements Sink.OfInt { + @SuppressWarnings("rawtypes") protected final Sink downstream; public ChainedInt(Sink downstream) { @@ -306,6 +308,7 @@ interface Sink extends Consumer { * {@code accept()} method on the downstream {@code Sink}. */ static abstract class ChainedLong implements Sink.OfLong { + @SuppressWarnings("rawtypes") protected final Sink downstream; public ChainedLong(Sink downstream) { @@ -338,6 +341,7 @@ interface Sink extends Consumer { * {@code accept()} method on the downstream {@code Sink}. */ static abstract class ChainedDouble implements Sink.OfDouble { + @SuppressWarnings("rawtypes") protected final Sink downstream; public ChainedDouble(Sink downstream) { diff --git a/jdk/src/share/classes/java/util/stream/SortedOps.java b/jdk/src/share/classes/java/util/stream/SortedOps.java index de02ba8e32f..047479a645d 100644 --- a/jdk/src/share/classes/java/util/stream/SortedOps.java +++ b/jdk/src/share/classes/java/util/stream/SortedOps.java @@ -209,7 +209,7 @@ final class SortedOps { } @Override - public Sink opWrapSink(int flags, Sink sink) { + public Sink opWrapSink(int flags, Sink sink) { Objects.requireNonNull(sink); if (StreamOpFlag.SORTED.isKnown(flags)) @@ -248,7 +248,7 @@ final class SortedOps { } @Override - public Sink opWrapSink(int flags, Sink sink) { + public Sink opWrapSink(int flags, Sink sink) { Objects.requireNonNull(sink); if (StreamOpFlag.SORTED.isKnown(flags)) @@ -285,7 +285,7 @@ final class SortedOps { private T[] array; private int offset; - SizedRefSortingSink(Sink sink, Comparator comparator) { + SizedRefSortingSink(Sink sink, Comparator comparator) { super(sink); this.comparator = comparator; } @@ -324,7 +324,7 @@ final class SortedOps { private final Comparator comparator; private ArrayList list; - RefSortingSink(Sink sink, Comparator comparator) { + RefSortingSink(Sink sink, Comparator comparator) { super(sink); this.comparator = comparator; } diff --git a/jdk/src/share/classes/java/util/stream/StreamSpliterators.java b/jdk/src/share/classes/java/util/stream/StreamSpliterators.java index 1a27e98ff29..4a62803b56b 100644 --- a/jdk/src/share/classes/java/util/stream/StreamSpliterators.java +++ b/jdk/src/share/classes/java/util/stream/StreamSpliterators.java @@ -912,7 +912,8 @@ class StreamSpliterators { this.permits = new AtomicLong(limit >= 0 ? skip + limit : skip); } - UnorderedSliceSpliterator(T_SPLITR s, UnorderedSliceSpliterator parent) { + UnorderedSliceSpliterator(T_SPLITR s, + UnorderedSliceSpliterator parent) { this.s = s; this.unlimited = parent.unlimited; this.permits = parent.permits; @@ -991,7 +992,7 @@ class StreamSpliterators { super(s, skip, limit); } - OfRef(Spliterator s, OfRef parent) { + OfRef(Spliterator s, OfRef parent) { super(s, parent); } From 0fb4cd9d382208fbc4f31b4f0d1db3e3b29dba30 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 7 Aug 2013 10:41:20 +0100 Subject: [PATCH 066/118] 8020997: TreeMaker.AnnotationBuilder creates broken element literals with repeating annotations Reviewed-by: jjg, jfranck --- .../com/sun/tools/javac/tree/TreeMaker.java | 2 +- .../CannotCompileRepeatedAnnoTest.java | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/T8020997/CannotCompileRepeatedAnnoTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java index e0b74340b77..b94dd5f8a4f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java @@ -781,7 +781,7 @@ public class TreeMaker implements JCTree.Factory { class AnnotationBuilder implements Attribute.Visitor { JCExpression result = null; public void visitConstant(Attribute.Constant v) { - result = Literal(v.value); + result = Literal(v.type.getTag(), v.value); } public void visitClass(Attribute.Class clazz) { result = ClassLiteral(clazz.classType).setType(syms.classType); diff --git a/langtools/test/tools/javac/T8020997/CannotCompileRepeatedAnnoTest.java b/langtools/test/tools/javac/T8020997/CannotCompileRepeatedAnnoTest.java new file mode 100644 index 00000000000..2e7edbb58b9 --- /dev/null +++ b/langtools/test/tools/javac/T8020997/CannotCompileRepeatedAnnoTest.java @@ -0,0 +1,46 @@ + +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8020997 + * @summary Cannot compile class with repeating annotation + * @compile CannotCompileRepeatedAnnoTest.java + */ + +import java.lang.annotation.*; + +@Anno(req = true) +@Anno() +public class CannotCompileRepeatedAnnoTest { +} + +@Repeatable(Container.class) +@interface Anno { + boolean req() default false; +} + +@interface Container{ + Anno[] value(); +} From 3103641be329078565659fa43a1d46d15f7df71e Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 7 Aug 2013 11:04:07 +0100 Subject: [PATCH 067/118] 8008274: javac should not reference/use sample code Reviewed-by: jjg --- .../classes/com/sun/tools/javac/Main.java | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/Main.java b/langtools/src/share/classes/com/sun/tools/javac/Main.java index eb3acca5c8e..2587d198972 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/Main.java +++ b/langtools/src/share/classes/com/sun/tools/javac/Main.java @@ -26,8 +26,6 @@ package com.sun.tools.javac; import java.io.PrintWriter; -import java.lang.reflect.*; - /** * The programmatic interface for the Java Programming Language @@ -44,23 +42,12 @@ import java.lang.reflect.*; @jdk.Supported public class Main { - /** Unsupported command line interface. - * @param args The command line parameters. + /** Main entry point for the launcher. + * Note: This method calls System.exit. + * @param args command line arguments */ public static void main(String[] args) throws Exception { - if (args.length > 0 && args[0].equals("-Xjdb")) { - String[] newargs = new String[args.length + 2]; - Class c = Class.forName("com.sun.tools.example.debug.tty.TTY"); - Method method = c.getDeclaredMethod ("main", new Class[] {args.getClass()}); - method.setAccessible(true); - System.arraycopy(args, 1, newargs, 3, args.length - 1); - newargs[0] = "-connect"; - newargs[1] = "com.sun.jdi.CommandLineLaunch:options=-esa -ea:com.sun.tools..."; - newargs[2] = "com.sun.tools.javac.Main"; - method.invoke(null, new Object[] { newargs }); - } else { System.exit(compile(args)); - } } /** Programmatic interface to the Java Programming Language From 7d97d753492b982fdb7ad1cd1c43c73e665990e1 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 7 Aug 2013 19:06:29 +0800 Subject: [PATCH 068/118] 7151062: [macosx] SCDynamicStore prints error messages to stderr Reviewed-by: xuelei --- .../macosx/native/java/util/SCDynamicStoreConfig.m | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m b/jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m index f6ad5e2e3fa..86e6a67d793 100644 --- a/jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m +++ b/jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m @@ -103,7 +103,6 @@ NSDictionary *realmConfigsForRealms(SCDynamicStoreRef store, NSArray *realms) { CFTypeRef realmInfo = SCDynamicStoreCopyValue(store, (CFStringRef) [NSString stringWithFormat:@"Kerberos:%@", realm]); if (CFGetTypeID(realmInfo) != CFDictionaryGetTypeID()) { - NSLog(@"Unexpected CFType for realm Info: %lu", CFGetTypeID(realmInfo)); return nil; } @@ -140,7 +139,6 @@ JNF_COCOA_ENTER(env); SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java"), _SCDynamicStoreCallBack, NULL); if (store == NULL) { - NSLog(@"Unable to load SCDynamicStore to install NotificationCallback"); return; } @@ -171,19 +169,11 @@ JNF_COCOA_ENTER(env); SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL); if (store == NULL) { - NSLog(@"Unable to load SCDynamicStore"); - return NULL; - } - - // Create the store if it is NULL and set it. - if (store == NULL) { - NSLog(@"Invalid value for SCDynamicStore"); return NULL; } CFTypeRef realms = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS); if (realms == NULL || CFGetTypeID(realms) != CFArrayGetTypeID()) { - NSLog(@"Unable to load realm info from SCDynamicStore"); if (realms) CFRelease(realms); CFRelease(store); return NULL; @@ -192,7 +182,6 @@ JNF_COCOA_ENTER(env); CFTypeRef realmMappings = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS); if (realmMappings == NULL || CFGetTypeID(realmMappings) != CFArrayGetTypeID()) { - NSLog(@"Unable to load realm mapping info from SCDynamicStore"); if (realmMappings) CFRelease(realmMappings); CFRelease(realms); CFRelease(store); From 35fe257db992975e0d1f339dc7bc963108b723d9 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 7 Aug 2013 18:16:25 +0530 Subject: [PATCH 069/118] 8022483: Nashorn compatibility issues in jhat's OQL feature Reviewed-by: lagergren, attila, hannesw --- .../com/sun/tools/hat/resources/hat.js | 122 ++++++++++-------- .../com/sun/tools/hat/resources/oqlhelp.html | 19 ++- 2 files changed, 75 insertions(+), 66 deletions(-) diff --git a/jdk/src/share/classes/com/sun/tools/hat/resources/hat.js b/jdk/src/share/classes/com/sun/tools/hat/resources/hat.js index 468d25ae172..f2c92ab4b0d 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/resources/hat.js +++ b/jdk/src/share/classes/com/sun/tools/hat/resources/hat.js @@ -151,7 +151,7 @@ function JavaClassProto() { while (tmp != null) { res[res.length] = tmp; tmp = tmp.superclass; - } + } return res; } @@ -263,16 +263,19 @@ function wrapJavaObject(thing) { if (name == 'class') { return wrapJavaValue(instance.clazz); - } else if (name == 'toString') { - return function() { - return instance.toString(); - } } else if (name == 'wrapped-object') { return instance; } return undefined; - } + }, + __call__: function(name) { + if (name == 'toString') { + return instance.toString(); + } else { + return undefined; + } + } } } @@ -297,7 +300,7 @@ function wrapJavaObject(thing) { return true; } } - return theJavaClassProto[name] != undefined; + return false; }, __get__ : function(name) { for (var i in fields) { @@ -305,7 +308,7 @@ function wrapJavaObject(thing) { return wrapJavaValue(fields[i].value); } } - return theJavaClassProto[name]; + return undefined; } } @@ -322,7 +325,12 @@ function wrapJavaObject(thing) { this.name = jclass.name; this.fields = jclass.fields; this['wrapped-object'] = jclass; - this.__proto__ = this.statics; + } + + for (var i in theJavaClassProto) { + if (typeof theJavaClassProto[i] == 'function') { + JavaClassWrapper.prototype[i] = theJavaClassProto[i]; + } } // returns wrapper for Java object arrays @@ -334,32 +342,35 @@ function wrapJavaObject(thing) { __getIds__ : function() { var res = new Array(elements.length); for (var i = 0; i < elements.length; i++) { - res[i] = i; + res[i] = String(i); } return res; }, __has__: function(name) { - return (typeof(name) == 'number' && - name >= 0 && name < elements.length) || + return (name >= 0 && name < elements.length) || name == 'length' || name == 'class' || name == 'toString' || name == 'wrapped-object'; }, __get__ : function(name) { - if (typeof(name) == 'number' && - name >= 0 && name < elements.length) { + if (name >= 0 && name < elements.length) { return wrapJavaValue(elements[name]); } else if (name == 'length') { return elements.length; } else if (name == 'class') { return wrapJavaValue(array.clazz); - } else if (name == 'toString') { - return function() { return array.toString(); } } else if (name == 'wrapped-object') { return array; } else { return undefined; } - } + }, + __call__: function(name) { + if (name == 'toString') { + return array.toString(); + } else { + return undefined; + } + } } } @@ -373,26 +384,22 @@ function wrapJavaObject(thing) { __getIds__ : function() { var r = new Array(array.length); for (var i = 0; i < array.length; i++) { - r[i] = i; + r[i] = String(i); } return r; }, __has__: function(name) { - return (typeof(name) == 'number' && - name >= 0 && name < array.length) || + return (name >= 0 && name < array.length) || name == 'length' || name == 'class' || name == 'toString' || name == 'wrapped-object'; }, __get__: function(name) { - if (typeof(name) == 'number' && - name >= 0 && name < array.length) { + if (name >= 0 && name < array.length) { return elements[name]; } if (name == 'length') { return array.length; - } else if (name == 'toString') { - return function() { return array.valueString(true); } } else if (name == 'wrapped-object') { return array; } else if (name == 'class') { @@ -400,7 +407,14 @@ function wrapJavaObject(thing) { } else { return undefined; } - } + }, + __call__: function(name) { + if (name == 'toString') { + return array.valueString(true); + } else { + return undefined; + } + } } } return javaObject(thing); @@ -673,34 +687,33 @@ function wrapHeapSnapshot(heap) { __getIds__ : function() { var res = new Array(path.length); for (var i = 0; i < path.length; i++) { - res[i] = i; + res[i] = String(i); } return res; }, __has__ : function (name) { - return (typeof(name) == 'number' && - name >= 0 && name < path.length) || + return (name >= 0 && name < path.length) || name == 'length' || name == 'toHtml' || name == 'toString'; }, __get__ : function(name) { - if (typeof(name) == 'number' && - name >= 0 && name < path.length) { + if (name >= 0 && name < path.length) { return path[name]; } else if (name == 'length') { return path.length; - } else if (name == 'toHtml') { - return function() { - return computeDescription(true); - } - } else if (name == 'toString') { - return function() { - return computeDescription(false); - } } else { return undefined; } }, + __call__: function(name) { + if (name == 'toHtml') { + return computeDescription(true); + } else if (name == 'toString') { + return computeDescription(false); + } else { + return undefined; + } + } }; } @@ -1005,22 +1018,8 @@ function toHtml(obj) { return "" + name + "@" + id + ""; } - } else if ((typeof(obj) == 'object') || (obj instanceof JSAdapter)) { - if (obj instanceof java.lang.Object) { - // script wrapped Java object - obj = wrapIterator(obj); - // special case for enumeration - if (obj instanceof java.util.Enumeration) { - var res = "[ "; - while (obj.hasMoreElements()) { - res += toHtml(obj.nextElement()) + ", "; - } - res += "]"; - return res; - } else { - return obj; - } - } else if (obj instanceof Array) { + } else if (obj instanceof Object) { + if (Array.isArray(obj)) { // script array var res = "[ "; for (var i in obj) { @@ -1047,8 +1046,19 @@ function toHtml(obj) { } } } else { - // JavaScript primitive value - return obj; + // a Java object + obj = wrapIterator(obj); + // special case for enumeration + if (obj instanceof java.util.Enumeration) { + var res = "[ "; + while (obj.hasMoreElements()) { + res += toHtml(obj.nextElement()) + ", "; + } + res += "]"; + return res; + } else { + return obj; + } } } diff --git a/jdk/src/share/classes/com/sun/tools/hat/resources/oqlhelp.html b/jdk/src/share/classes/com/sun/tools/hat/resources/oqlhelp.html index 3937f4a1c39..d660fd3cae8 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/resources/oqlhelp.html +++ b/jdk/src/share/classes/com/sun/tools/hat/resources/oqlhelp.html @@ -79,7 +79,7 @@ bound to a JavaScript variable of the identifier name specified in select s.value.toString() from java.lang.String s - where /java/(s.value.toString()) + where /java/.test(s.value.toString())

  • show path value of all File objects @@ -219,7 +219,6 @@ Examples:
     
         select heap.findClass("java.lang.System").statics.props
    -    select heap.findClass("java.lang.System").props
     
     
  • get number of fields of java.lang.String class @@ -237,7 +236,7 @@ Examples:
  • select all classes that have name pattern java.net.*
     
    -    select filter(heap.classes(), "/java.net./(it.name)")
    +    select filter(heap.classes(), "/java.net./.test(it.name)")
     
     
    @@ -536,7 +535,7 @@ refer to the following built-in variables. Example: print number of classes that have specific name pattern
     
    -    select count(heap.classes(), "/java.io./(it.name)")
    +    select count(heap.classes(), "/java.io./.test(it.name)")
     
     
    @@ -559,14 +558,14 @@ Examples:
  • show all classes that have java.io.* name pattern
     
    -    select filter(heap.classes(), "/java.io./(it.name)")
    +    select filter(heap.classes(), "/java.io./.test(it.name)")
     
     
  • show all referrers of URL object where the referrer is not from java.net package
     
    -    select filter(referrers(u), "! /java.net./(classof(it).name)")
    +    select filter(referrers(u), "! /java.net./.test(classof(it).name)")
         from java.net.URL u
     
     
    @@ -619,13 +618,13 @@ Examples:
  • find the maximum length of any String instance
     
    -    select max(map(heap.objects('java.lang.String', false), 'it.count'))
    +    select max(map(heap.objects('java.lang.String', false), 'it.value.length'))
     
     
  • find string instance that has the maximum length
     
    -    select max(heap.objects('java.lang.String'), 'lhs.count > rhs.count')
    +    select max(heap.objects('java.lang.String'), 'lhs.value.length > rhs.value.length')
     
     
    @@ -775,7 +774,7 @@ and walk until parent is null using the callback function to map call.
     
    -   select map(filter(heap.findClass('java.lang.System').props.table, 'it != null'), 
    +   select map(filter(heap.findClass('java.lang.System').statics.props.table, 'it != null'), 
                 function (it) {
                     var res = "";
                     while (it != null) {
    
    From 4cb22654f8fba1f118ee435f1a335c742cd8a5e6 Mon Sep 17 00:00:00 2001
    From: Xue-Lei Andrew Fan 
    Date: Wed, 7 Aug 2013 06:42:06 -0700
    Subject: [PATCH 070/118] 8013809: deadlock in SSLSocketImpl between between
     write and close
    
    Reviewed-by: wetmore
    ---
     jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
    index ffa8f4528e8..dfe612966e0 100644
    --- a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
    +++ b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
    @@ -169,7 +169,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
         /*
          * Drives the protocol state machine.
          */
    -    private int                 connectionState;
    +    private volatile int        connectionState;
     
         /*
          * Flag indicating if the next record we receive MUST be a Finished
    @@ -1467,7 +1467,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
          */
         @Override
         public boolean isClosed() {
    -        return getConnectionState() == cs_APP_CLOSED;
    +        return connectionState == cs_APP_CLOSED;
         }
     
         /**
    
    From 5c82273ab34512ec10dfbc84cd5ef5f0242a3716 Mon Sep 17 00:00:00 2001
    From: Alexander Scherbatiy 
    Date: Wed, 7 Aug 2013 18:32:03 +0400
    Subject: [PATCH 071/118] 8022532: [parfait] Potential memory leak in
     gtk2_interface.c
    
    Reviewed-by: art, serb
    ---
     jdk/src/solaris/native/sun/awt/gtk2_interface.c | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/jdk/src/solaris/native/sun/awt/gtk2_interface.c b/jdk/src/solaris/native/sun/awt/gtk2_interface.c
    index e1228fc9036..43a4bcfcb08 100644
    --- a/jdk/src/solaris/native/sun/awt/gtk2_interface.c
    +++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.c
    @@ -794,6 +794,7 @@ gboolean gtk2_load()
                 }
                 putenv (new_env);
                 free (new_env);
    +            free (tmp_env);
             }
         }
     
    
    From eede95c5cfd2599d4c679bdede60ac97548f97f8 Mon Sep 17 00:00:00 2001
    From: Alexander Scherbatiy 
    Date: Wed, 7 Aug 2013 18:58:28 +0400
    Subject: [PATCH 072/118] 8013849: Awt assert on Hashtable.cpp:124
    
    Reviewed-by: serb
    ---
     .../native/sun/windows/awt_Component.cpp      |  8 ++-
     .../DeadKey/DeadKeySystemAssertionDialog.java | 65 +++++++++++++++++++
     2 files changed, 71 insertions(+), 2 deletions(-)
     create mode 100644 jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java
    
    diff --git a/jdk/src/windows/native/sun/windows/awt_Component.cpp b/jdk/src/windows/native/sun/windows/awt_Component.cpp
    index 6d645e052a8..42dff896459 100644
    --- a/jdk/src/windows/native/sun/windows/awt_Component.cpp
    +++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp
    @@ -3528,8 +3528,12 @@ UINT AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops,
         if (ops == SAVE) {
             transTable.put(reinterpret_cast(static_cast(wkey)),
                            reinterpret_cast(static_cast(translation)));
    -        deadKeyFlagTable.put(reinterpret_cast(static_cast(wkey)),
    -                       reinterpret_cast(static_cast(deadKeyFlag)));
    +        if (deadKeyFlag) {
    +            deadKeyFlagTable.put(reinterpret_cast(static_cast(wkey)),
    +                         reinterpret_cast(static_cast(deadKeyFlag)));
    +        } else {
    +            deadKeyFlagTable.remove(reinterpret_cast(static_cast(wkey)));
    +        }
         }
     
         isDeadKey = deadKeyFlag;
    diff --git a/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java b/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java
    new file mode 100644
    index 00000000000..b7523d2b152
    --- /dev/null
    +++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java
    @@ -0,0 +1,65 @@
    +/*
    + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    + *
    + * This code is free software; you can redistribute it and/or modify it
    + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    + * or visit www.oracle.com if you need additional information or have any
    + * questions.
    + */
    +
    +import java.awt.Frame;
    +import java.awt.Robot;
    +import java.awt.TextField;
    +import java.awt.Toolkit;
    +import java.awt.event.KeyEvent;
    +import sun.awt.SunToolkit;
    +/*
    + * @test
    + * @bug 8013849
    + * @summary Awt assert on Hashtable.cpp:124
    + * @author alexandr.scherbatiy area=awt.event
    + * @run main/timeout=5 DeadKeySystemAssertionDialog
    + */
    +
    +public class DeadKeySystemAssertionDialog {
    +
    +    public static void main(String[] args) throws Exception {
    +
    +        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    +        Frame frame = new Frame();
    +        frame.setSize(300, 200);
    +
    +        TextField textField = new TextField();
    +        frame.add(textField);
    +
    +        frame.setVisible(true);
    +        toolkit.realSync();
    +
    +        textField.requestFocus();
    +        toolkit.realSync();
    +
    +        // Check that the system assertion dialog does not block Java
    +        Robot robot = new Robot();
    +        robot.setAutoDelay(50);
    +        robot.keyPress(KeyEvent.VK_A);
    +        robot.keyRelease(KeyEvent.VK_A);
    +        toolkit.realSync();
    +
    +        frame.setVisible(false);
    +        frame.dispose();
    +    }
    +}
    
    From 27f8eea2ea77967cc031b89ed947518118a5747f Mon Sep 17 00:00:00 2001
    From: Krystal Mok 
    Date: Wed, 7 Aug 2013 19:02:06 +0400
    Subject: [PATCH 073/118] 8021771: warning stat64 is deprecated - when building
     on OSX 10.7.5
    
    Stat64 have to be replaced with stat
    
    Reviewed-by: dholmes, kmo
    ---
     hotspot/src/os/bsd/vm/attachListener_bsd.cpp | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/hotspot/src/os/bsd/vm/attachListener_bsd.cpp b/hotspot/src/os/bsd/vm/attachListener_bsd.cpp
    index 6f128f2543b..4a580b486fc 100644
    --- a/hotspot/src/os/bsd/vm/attachListener_bsd.cpp
    +++ b/hotspot/src/os/bsd/vm/attachListener_bsd.cpp
    @@ -445,14 +445,14 @@ AttachOperation* AttachListener::dequeue() {
     
     void AttachListener::vm_start() {
       char fn[UNIX_PATH_MAX];
    -  struct stat64 st;
    +  struct stat st;
       int ret;
     
       int n = snprintf(fn, UNIX_PATH_MAX, "%s/.java_pid%d",
                os::get_temp_directory(), os::current_process_id());
       assert(n < (int)UNIX_PATH_MAX, "java_pid file name buffer overflow");
     
    -  RESTARTABLE(::stat64(fn, &st), ret);
    +  RESTARTABLE(::stat(fn, &st), ret);
       if (ret == 0) {
         ret = ::unlink(fn);
         if (ret == -1) {
    
    From 5409730fdee8f9d4cfa279c6688d9f76d7fa854e Mon Sep 17 00:00:00 2001
    From: Marcus Lagergren 
    Date: Wed, 7 Aug 2013 08:08:57 -0700
    Subject: [PATCH 074/118] 8022454: Fixed various serializations and deprecation
     warnings in java.util, java.net and sun.tools
    
    Reviewed-by: darcy
    ---
     .../share/classes/java/net/SocketAddress.java |  3 +++
     .../java/util/logging/XMLFormatter.java       | 27 ++++++++++---------
     .../classes/sun/tools/jar/JarException.java   |  3 +++
     3 files changed, 20 insertions(+), 13 deletions(-)
    
    diff --git a/jdk/src/share/classes/java/net/SocketAddress.java b/jdk/src/share/classes/java/net/SocketAddress.java
    index 5cdd4a519cb..a3ee4ee52f5 100644
    --- a/jdk/src/share/classes/java/net/SocketAddress.java
    +++ b/jdk/src/share/classes/java/net/SocketAddress.java
    @@ -39,4 +39,7 @@ package java.net;
      * @since 1.4
      */
     public abstract class SocketAddress implements java.io.Serializable {
    +
    +    static final long serialVersionUID = 5215720748342549866L;
    +
     }
    diff --git a/jdk/src/share/classes/java/util/logging/XMLFormatter.java b/jdk/src/share/classes/java/util/logging/XMLFormatter.java
    index 6b0a58a7130..d32d978dbe5 100644
    --- a/jdk/src/share/classes/java/util/logging/XMLFormatter.java
    +++ b/jdk/src/share/classes/java/util/logging/XMLFormatter.java
    @@ -47,7 +47,7 @@ public class XMLFormatter extends Formatter {
         private LogManager manager = LogManager.getLogManager();
     
         // Append a two digit number.
    -    private void a2(StringBuffer sb, int x) {
    +    private void a2(StringBuilder sb, int x) {
             if (x < 10) {
                 sb.append('0');
             }
    @@ -55,25 +55,26 @@ public class XMLFormatter extends Formatter {
         }
     
         // Append the time and date in ISO 8601 format
    -    private void appendISO8601(StringBuffer sb, long millis) {
    -        Date date = new Date(millis);
    -        sb.append(date.getYear() + 1900);
    +    private void appendISO8601(StringBuilder sb, long millis) {
    +        GregorianCalendar cal = new GregorianCalendar();
    +        cal.setTimeInMillis(millis);
    +        sb.append(cal.get(Calendar.YEAR) + 1900);
             sb.append('-');
    -        a2(sb, date.getMonth() + 1);
    +        a2(sb, cal.get(Calendar.MONTH) + 1);
             sb.append('-');
    -        a2(sb, date.getDate());
    +        a2(sb, cal.get(Calendar.DAY_OF_MONTH));
             sb.append('T');
    -        a2(sb, date.getHours());
    +        a2(sb, cal.get(Calendar.HOUR_OF_DAY));
             sb.append(':');
    -        a2(sb, date.getMinutes());
    +        a2(sb, cal.get(Calendar.MINUTE));
             sb.append(':');
    -        a2(sb, date.getSeconds());
    +        a2(sb, cal.get(Calendar.SECOND));
         }
     
    -    // Append to the given StringBuffer an escaped version of the
    +    // Append to the given StringBuilder an escaped version of the
         // given text string where XML special characters have been escaped.
         // For a null string we append ""
    -    private void escape(StringBuffer sb, String text) {
    +    private void escape(StringBuilder sb, String text) {
             if (text == null) {
                 text = "";
             }
    @@ -102,7 +103,7 @@ public class XMLFormatter extends Formatter {
          * @return a formatted log record
          */
         public String format(LogRecord record) {
    -        StringBuffer sb = new StringBuffer(500);
    +        StringBuilder sb = new StringBuilder(500);
             sb.append("\n");
     
             sb.append("  ");
    @@ -224,7 +225,7 @@ public class XMLFormatter extends Formatter {
          * @return  a valid XML string
          */
         public String getHead(Handler h) {
    -        StringBuffer sb = new StringBuffer();
    +        StringBuilder sb = new StringBuilder();
             String encoding;
             sb.append("
    Date: Wed, 7 Aug 2013 17:56:19 +0200
    Subject: [PATCH 075/118] 8022284: Hide internal data structure in PhaseCFG
    
    Hide private node to block mapping using public interface
    
    Reviewed-by: kvn, roland
    ---
     .../sun/jvm/hotspot/opto/PhaseCFG.java        |   2 +-
     hotspot/src/share/vm/opto/block.cpp           | 113 ++++++++-------
     hotspot/src/share/vm/opto/block.hpp           |  59 +++++---
     hotspot/src/share/vm/opto/buildOopMap.cpp     |  19 ++-
     hotspot/src/share/vm/opto/chaitin.cpp         |  32 ++--
     hotspot/src/share/vm/opto/coalesce.cpp        |  36 +++--
     hotspot/src/share/vm/opto/compile.cpp         |   4 +-
     hotspot/src/share/vm/opto/domgraph.cpp        |   4 +-
     hotspot/src/share/vm/opto/gcm.cpp             | 137 +++++++++---------
     .../src/share/vm/opto/idealGraphPrinter.cpp   |   6 +-
     hotspot/src/share/vm/opto/ifg.cpp             |   4 +-
     hotspot/src/share/vm/opto/lcm.cpp             |  97 +++++++------
     hotspot/src/share/vm/opto/live.cpp            |  10 +-
     hotspot/src/share/vm/opto/node.hpp            |   1 -
     hotspot/src/share/vm/opto/output.cpp          |  37 +++--
     hotspot/src/share/vm/opto/output.hpp          |   3 -
     hotspot/src/share/vm/opto/postaloc.cpp        |  19 ++-
     hotspot/src/share/vm/opto/reg_split.cpp       |  22 +--
     hotspot/src/share/vm/runtime/vmStructs.cpp    |   2 +-
     19 files changed, 327 insertions(+), 280 deletions(-)
    
    diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java
    index 2530f1af7a7..66344b553f6 100644
    --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java
    +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java
    @@ -44,7 +44,7 @@ public class PhaseCFG extends Phase {
         Type type      = db.lookupType("PhaseCFG");
         numBlocksField = new CIntField(type.getCIntegerField("_num_blocks"), 0);
         blocksField = type.getAddressField("_blocks");
    -    bbsField = type.getAddressField("_bbs");
    +    bbsField = type.getAddressField("_node_to_block_mapping");
         brootField = type.getAddressField("_broot");
       }
     
    diff --git a/hotspot/src/share/vm/opto/block.cpp b/hotspot/src/share/vm/opto/block.cpp
    index 0aa41de0120..9153d070886 100644
    --- a/hotspot/src/share/vm/opto/block.cpp
    +++ b/hotspot/src/share/vm/opto/block.cpp
    @@ -221,7 +221,7 @@ bool Block::has_uncommon_code() const {
     //------------------------------is_uncommon------------------------------------
     // True if block is low enough frequency or guarded by a test which
     // mostly does not go here.
    -bool Block::is_uncommon( Block_Array &bbs ) const {
    +bool Block::is_uncommon(PhaseCFG* cfg) const {
       // Initial blocks must never be moved, so are never uncommon.
       if (head()->is_Root() || head()->is_Start())  return false;
     
    @@ -238,7 +238,7 @@ bool Block::is_uncommon( Block_Array &bbs ) const {
       uint uncommon_for_freq_preds = 0;
     
       for( uint i=1; i_idx];
    +    Block* guard = cfg->get_block_for_node(pred(i));
         // Check to see if this block follows its guard 1 time out of 10000
         // or less.
         //
    @@ -285,11 +285,11 @@ void Block::dump_bidx(const Block* orig, outputStream* st) const {
       }
     }
     
    -void Block::dump_pred(const Block_Array *bbs, Block* orig, outputStream* st) const {
    +void Block::dump_pred(const PhaseCFG* cfg, Block* orig, outputStream* st) const {
       if (is_connector()) {
         for (uint i=1; i_idx]);
    -      p->dump_pred(bbs, orig, st);
    +      Block *p = cfg->get_block_for_node(pred(i));
    +      p->dump_pred(cfg, orig, st);
         }
       } else {
         dump_bidx(orig, st);
    @@ -297,7 +297,7 @@ void Block::dump_pred(const Block_Array *bbs, Block* orig, outputStream* st) con
       }
     }
     
    -void Block::dump_head( const Block_Array *bbs, outputStream* st ) const {
    +void Block::dump_head(const PhaseCFG* cfg, outputStream* st) const {
       // Print the basic block
       dump_bidx(this, st);
       st->print(": #\t");
    @@ -311,26 +311,28 @@ void Block::dump_head( const Block_Array *bbs, outputStream* st ) const {
       if( head()->is_block_start() ) {
         for (uint i=1; i_idx];
    -        p->dump_pred(bbs, p, st);
    +      if (cfg != NULL) {
    +        Block *p = cfg->get_block_for_node(s);
    +        p->dump_pred(cfg, p, st);
           } else {
             while (!s->is_block_start())
               s = s->in(0);
             st->print("N%d ", s->_idx );
           }
         }
    -  } else
    +  } else {
         st->print("BLOCK HEAD IS JUNK  ");
    +  }
     
       // Print loop, if any
       const Block *bhead = this;    // Head of self-loop
       Node *bh = bhead->head();
    -  if( bbs && bh->is_Loop() && !head()->is_Root() ) {
    +
    +  if ((cfg != NULL) && bh->is_Loop() && !head()->is_Root()) {
         LoopNode *loop = bh->as_Loop();
    -    const Block *bx = (*bbs)[loop->in(LoopNode::LoopBackControl)->_idx];
    +    const Block *bx = cfg->get_block_for_node(loop->in(LoopNode::LoopBackControl));
         while (bx->is_connector()) {
    -      bx = (*bbs)[bx->pred(1)->_idx];
    +      bx = cfg->get_block_for_node(bx->pred(1));
         }
         st->print("\tLoop: B%d-B%d ", bhead->_pre_order, bx->_pre_order);
         // Dump any loop-specific bits, especially for CountedLoops.
    @@ -349,29 +351,32 @@ void Block::dump_head( const Block_Array *bbs, outputStream* st ) const {
       st->print_cr("");
     }
     
    -void Block::dump() const { dump(NULL); }
    +void Block::dump() const {
    +  dump(NULL);
    +}
     
    -void Block::dump( const Block_Array *bbs ) const {
    -  dump_head(bbs);
    -  uint cnt = _nodes.size();
    -  for( uint i=0; idump();
    +  }
       tty->print("\n");
     }
     #endif
     
     //=============================================================================
     //------------------------------PhaseCFG---------------------------------------
    -PhaseCFG::PhaseCFG( Arena *a, RootNode *r, Matcher &m ) :
    -  Phase(CFG),
    -  _bbs(a),
    -  _root(r),
    -  _node_latency(NULL)
    +PhaseCFG::PhaseCFG(Arena* arena, RootNode* root, Matcher& matcher)
    +: Phase(CFG)
    +, _block_arena(arena)
    +, _node_to_block_mapping(arena)
    +, _root(root)
    +, _node_latency(NULL)
     #ifndef PRODUCT
    -  , _trace_opto_pipelining(TraceOptoPipelining || C->method_has_option("TraceOptoPipelining"))
    +, _trace_opto_pipelining(TraceOptoPipelining || C->method_has_option("TraceOptoPipelining"))
     #endif
     #ifdef ASSERT
    -  , _raw_oops(a)
    +, _raw_oops(arena)
     #endif
     {
       ResourceMark rm;
    @@ -380,13 +385,13 @@ PhaseCFG::PhaseCFG( Arena *a, RootNode *r, Matcher &m ) :
       // Node on demand.
       Node *x = new (C) GotoNode(NULL);
       x->init_req(0, x);
    -  _goto = m.match_tree(x);
    +  _goto = matcher.match_tree(x);
       assert(_goto != NULL, "");
       _goto->set_req(0,_goto);
     
       // Build the CFG in Reverse Post Order
       _num_blocks = build_cfg();
    -  _broot = _bbs[_root->_idx];
    +  _broot = get_block_for_node(_root);
     }
     
     //------------------------------build_cfg--------------------------------------
    @@ -440,9 +445,9 @@ uint PhaseCFG::build_cfg() {
           // 'p' now points to the start of this basic block
     
           // Put self in array of basic blocks
    -      Block *bb = new (_bbs._arena) Block(_bbs._arena,p);
    -      _bbs.map(p->_idx,bb);
    -      _bbs.map(x->_idx,bb);
    +      Block *bb = new (_block_arena) Block(_block_arena, p);
    +      map_node_to_block(p, bb);
    +      map_node_to_block(x, bb);
           if( x != p ) {                // Only for root is x == p
             bb->_nodes.push((Node*)x);
           }
    @@ -473,16 +478,16 @@ uint PhaseCFG::build_cfg() {
           // Check if it the fist node pushed on stack at the beginning.
           if (idx == 0) break;          // end of the build
           // Find predecessor basic block
    -      Block *pb = _bbs[x->_idx];
    +      Block *pb = get_block_for_node(x);
           // Insert into nodes array, if not already there
    -      if( !_bbs.lookup(proj->_idx) ) {
    +      if (!has_block(proj)) {
             assert( x != proj, "" );
             // Map basic block of projection
    -        _bbs.map(proj->_idx,pb);
    +        map_node_to_block(proj, pb);
             pb->_nodes.push(proj);
           }
           // Insert self as a child of my predecessor block
    -      pb->_succs.map(pb->_num_succs++, _bbs[np->_idx]);
    +      pb->_succs.map(pb->_num_succs++, get_block_for_node(np));
           assert( pb->_nodes[ pb->_nodes.size() - pb->_num_succs ]->is_block_proj(),
                   "too many control users, not a CFG?" );
         }
    @@ -511,15 +516,15 @@ void PhaseCFG::insert_goto_at(uint block_no, uint succ_no) {
       RegionNode* region = new (C) RegionNode(2);
       region->init_req(1, proj);
       // setup corresponding basic block
    -  Block* block = new (_bbs._arena) Block(_bbs._arena, region);
    -  _bbs.map(region->_idx, block);
    +  Block* block = new (_block_arena) Block(_block_arena, region);
    +  map_node_to_block(region, block);
       C->regalloc()->set_bad(region->_idx);
       // add a goto node
       Node* gto = _goto->clone(); // get a new goto node
       gto->set_req(0, region);
       // add it to the basic block
       block->_nodes.push(gto);
    -  _bbs.map(gto->_idx, block);
    +  map_node_to_block(gto, block);
       C->regalloc()->set_bad(gto->_idx);
       // hook up successor block
       block->_succs.map(block->_num_succs++, out);
    @@ -570,7 +575,7 @@ void PhaseCFG::convert_NeverBranch_to_Goto(Block *b) {
       gto->set_req(0, b->head());
       Node *bp = b->_nodes[end_idx];
       b->_nodes.map(end_idx,gto); // Slam over NeverBranch
    -  _bbs.map(gto->_idx, b);
    +  map_node_to_block(gto, b);
       C->regalloc()->set_bad(gto->_idx);
       b->_nodes.pop();              // Yank projections
       b->_nodes.pop();              // Yank projections
    @@ -613,7 +618,7 @@ bool PhaseCFG::move_to_next(Block* bx, uint b_index) {
       // If the previous block conditionally falls into bx, return false,
       // because moving bx will create an extra jump.
       for(uint k = 1; k < bx->num_preds(); k++ ) {
    -    Block* pred = _bbs[bx->pred(k)->_idx];
    +    Block* pred = get_block_for_node(bx->pred(k));
         if (pred == _blocks[bx_index-1]) {
           if (pred->_num_succs != 1) {
             return false;
    @@ -682,7 +687,7 @@ void PhaseCFG::remove_empty() {
     
         // Look for uncommon blocks and move to end.
         if (!C->do_freq_based_layout()) {
    -      if( b->is_uncommon(_bbs) ) {
    +      if (b->is_uncommon(this)) {
             move_to_end(b, i);
             last--;                   // No longer check for being uncommon!
             if( no_flip_branch(b) ) { // Fall-thru case must follow?
    @@ -870,28 +875,31 @@ void PhaseCFG::_dump_cfg( const Node *end, VectorSet &visited  ) const {
       } while( !p->is_block_start() );
     
       // Recursively visit
    -  for( uint i=1; ireq(); i++ )
    -    _dump_cfg(p->in(i),visited);
    +  for (uint i = 1; i < p->req(); i++) {
    +    _dump_cfg(p->in(i), visited);
    +  }
     
       // Dump the block
    -  _bbs[p->_idx]->dump(&_bbs);
    +  get_block_for_node(p)->dump(this);
     }
     
     void PhaseCFG::dump( ) const {
       tty->print("\n--- CFG --- %d BBs\n",_num_blocks);
    -  if( _blocks.size() ) {        // Did we do basic-block layout?
    -    for( uint i=0; i<_num_blocks; i++ )
    -      _blocks[i]->dump(&_bbs);
    +  if (_blocks.size()) {        // Did we do basic-block layout?
    +    for (uint i = 0; i < _num_blocks; i++) {
    +      _blocks[i]->dump(this);
    +    }
       } else {                      // Else do it with a DFS
    -    VectorSet visited(_bbs._arena);
    +    VectorSet visited(_block_arena);
         _dump_cfg(_root,visited);
       }
     }
     
     void PhaseCFG::dump_headers() {
       for( uint i = 0; i < _num_blocks; i++ ) {
    -    if( _blocks[i] == NULL ) continue;
    -    _blocks[i]->dump_head(&_bbs);
    +    if (_blocks[i]) {
    +      _blocks[i]->dump_head(this);
    +    }
       }
     }
     
    @@ -904,7 +912,7 @@ void PhaseCFG::verify( ) const {
         uint j;
         for (j = 0; j < cnt; j++)  {
           Node *n = b->_nodes[j];
    -      assert( _bbs[n->_idx] == b, "" );
    +      assert(get_block_for_node(n) == b, "");
           if (j >= 1 && n->is_Mach() &&
               n->as_Mach()->ideal_Opcode() == Op_CreateEx) {
             assert(j == 1 || b->_nodes[j-1]->is_Phi(),
    @@ -913,13 +921,12 @@ void PhaseCFG::verify( ) const {
           for (uint k = 0; k < n->req(); k++) {
             Node *def = n->in(k);
             if (def && def != n) {
    -          assert(_bbs[def->_idx] || def->is_Con(),
    -                 "must have block; constants for debug info ok");
    +          assert(get_block_for_node(def) || def->is_Con(), "must have block; constants for debug info ok");
               // Verify that instructions in the block is in correct order.
               // Uses must follow their definition if they are at the same block.
               // Mostly done to check that MachSpillCopy nodes are placed correctly
               // when CreateEx node is moved in build_ifg_physical().
    -          if (_bbs[def->_idx] == b &&
    +          if (get_block_for_node(def) == b &&
                   !(b->head()->is_Loop() && n->is_Phi()) &&
                   // See (+++) comment in reg_split.cpp
                   !(n->jvms() != NULL && n->jvms()->is_monitor_use(k))) {
    diff --git a/hotspot/src/share/vm/opto/block.hpp b/hotspot/src/share/vm/opto/block.hpp
    index a2e4615b8d0..cb9384de2ee 100644
    --- a/hotspot/src/share/vm/opto/block.hpp
    +++ b/hotspot/src/share/vm/opto/block.hpp
    @@ -48,13 +48,12 @@ class Block_Array : public ResourceObj {
       friend class VMStructs;
       uint _size;                   // allocated size, as opposed to formal limit
       debug_only(uint _limit;)      // limit to formal domain
    +  Arena *_arena;                // Arena to allocate in
     protected:
       Block **_blocks;
       void grow( uint i );          // Grow array node to fit
     
     public:
    -  Arena *_arena;                // Arena to allocate in
    -
       Block_Array(Arena *a) : _arena(a), _size(OptoBlockListSize) {
         debug_only(_limit=0);
         _blocks = NEW_ARENA_ARRAY( a, Block *, OptoBlockListSize );
    @@ -77,7 +76,7 @@ class Block_List : public Block_Array {
     public:
       uint _cnt;
       Block_List() : Block_Array(Thread::current()->resource_area()), _cnt(0) {}
    -  void push( Block *b ) { map(_cnt++,b); }
    +  void push( Block *b ) {  map(_cnt++,b); }
       Block *pop() { return _blocks[--_cnt]; }
       Block *rpop() { Block *b = _blocks[0]; _blocks[0]=_blocks[--_cnt]; return b;}
       void remove( uint i );
    @@ -284,15 +283,15 @@ class Block : public CFGElement {
       // helper function that adds caller save registers to MachProjNode
       void add_call_kills(MachProjNode *proj, RegMask& regs, const char* save_policy, bool exclude_soe);
       // Schedule a call next in the block
    -  uint sched_call(Matcher &matcher, Block_Array &bbs, uint node_cnt, Node_List &worklist, GrowableArray &ready_cnt, MachCallNode *mcall, VectorSet &next_call);
    +  uint sched_call(Matcher &matcher, PhaseCFG* cfg, uint node_cnt, Node_List &worklist, GrowableArray &ready_cnt, MachCallNode *mcall, VectorSet &next_call);
     
       // Perform basic-block local scheduling
       Node *select(PhaseCFG *cfg, Node_List &worklist, GrowableArray &ready_cnt, VectorSet &next_call, uint sched_slot);
    -  void set_next_call( Node *n, VectorSet &next_call, Block_Array &bbs );
    -  void needed_for_next_call(Node *this_call, VectorSet &next_call, Block_Array &bbs);
    +  void set_next_call( Node *n, VectorSet &next_call, PhaseCFG* cfg);
    +  void needed_for_next_call(Node *this_call, VectorSet &next_call, PhaseCFG* cfg);
       bool schedule_local(PhaseCFG *cfg, Matcher &m, GrowableArray &ready_cnt, VectorSet &next_call);
       // Cleanup if any code lands between a Call and his Catch
    -  void call_catch_cleanup(Block_Array &bbs, Compile *C);
    +  void call_catch_cleanup(PhaseCFG* cfg, Compile *C);
       // Detect implicit-null-check opportunities.  Basically, find NULL checks
       // with suitable memory ops nearby.  Use the memory op to do the NULL check.
       // I can generate a memory op if there is not one nearby.
    @@ -331,15 +330,15 @@ class Block : public CFGElement {
     
       // Use frequency calculations and code shape to predict if the block
       // is uncommon.
    -  bool is_uncommon( Block_Array &bbs ) const;
    +  bool is_uncommon(PhaseCFG* cfg) const;
     
     #ifndef PRODUCT
       // Debugging print of basic block
       void dump_bidx(const Block* orig, outputStream* st = tty) const;
    -  void dump_pred(const Block_Array *bbs, Block* orig, outputStream* st = tty) const;
    -  void dump_head( const Block_Array *bbs, outputStream* st = tty ) const;
    +  void dump_pred(const PhaseCFG* cfg, Block* orig, outputStream* st = tty) const;
    +  void dump_head(const PhaseCFG* cfg, outputStream* st = tty) const;
       void dump() const;
    -  void dump( const Block_Array *bbs ) const;
    +  void dump(const PhaseCFG* cfg) const;
     #endif
     };
     
    @@ -349,6 +348,12 @@ class Block : public CFGElement {
     class PhaseCFG : public Phase {
       friend class VMStructs;
      private:
    +  // Arena for the blocks to be stored in
    +  Arena* _block_arena;
    +
    +  // Map nodes to owning basic block
    +  Block_Array _node_to_block_mapping;
    +
       // Build a proper looking cfg.  Return count of basic blocks
       uint build_cfg();
     
    @@ -371,22 +376,42 @@ class PhaseCFG : public Phase {
     
       Block* insert_anti_dependences(Block* LCA, Node* load, bool verify = false);
       void verify_anti_dependences(Block* LCA, Node* load) {
    -    assert(LCA == _bbs[load->_idx], "should already be scheduled");
    +    assert(LCA == get_block_for_node(load), "should already be scheduled");
         insert_anti_dependences(LCA, load, true);
       }
     
      public:
    -  PhaseCFG( Arena *a, RootNode *r, Matcher &m );
    +  PhaseCFG(Arena* arena, RootNode* root, Matcher& matcher);
     
       uint _num_blocks;             // Count of basic blocks
       Block_List _blocks;           // List of basic blocks
       RootNode *_root;              // Root of whole program
    -  Block_Array _bbs;             // Map Nodes to owning Basic Block
       Block *_broot;                // Basic block of root
       uint _rpo_ctr;
       CFGLoop* _root_loop;
       float _outer_loop_freq;       // Outmost loop frequency
     
    +
    +  // set which block this node should reside in
    +  void map_node_to_block(const Node* node, Block* block) {
    +    _node_to_block_mapping.map(node->_idx, block);
    +  }
    +
    +  // removes the mapping from a node to a block
    +  void unmap_node_from_block(const Node* node) {
    +    _node_to_block_mapping.map(node->_idx, NULL);
    +  }
    +
    +  // get the block in which this node resides
    +  Block* get_block_for_node(const Node* node) const {
    +    return _node_to_block_mapping[node->_idx];
    +  }
    +
    +  // does this node reside in a block; return true
    +  bool has_block(const Node* node) const {
    +    return (_node_to_block_mapping.lookup(node->_idx) != NULL);
    +  }
    +
       // Per node latency estimation, valid only during GCM
       GrowableArray *_node_latency;
     
    @@ -405,7 +430,7 @@ class PhaseCFG : public Phase {
       void Estimate_Block_Frequency();
     
       // Global Code Motion.  See Click's PLDI95 paper.  Place Nodes in specific
    -  // basic blocks; i.e. _bbs now maps _idx for all Nodes to some Block.
    +  // basic blocks; i.e. _node_to_block_mapping now maps _idx for all Nodes to some Block.
       void GlobalCodeMotion( Matcher &m, uint unique, Node_List &proj_list );
     
       // Compute the (backwards) latency of a node from the uses
    @@ -454,7 +479,7 @@ class PhaseCFG : public Phase {
       // Insert a node into a block, and update the _bbs
       void insert( Block *b, uint idx, Node *n ) {
         b->_nodes.insert( idx, n );
    -    _bbs.map( n->_idx, b );
    +    map_node_to_block(n, b);
       }
     
     #ifndef PRODUCT
    @@ -543,7 +568,7 @@ class CFGLoop : public CFGElement {
         _child(NULL),
         _exit_prob(1.0f) {}
       CFGLoop* parent() { return _parent; }
    -  void push_pred(Block* blk, int i, Block_List& worklist, Block_Array& node_to_blk);
    +  void push_pred(Block* blk, int i, Block_List& worklist, PhaseCFG* cfg);
       void add_member(CFGElement *s) { _members.push(s); }
       void add_nested_loop(CFGLoop* cl);
       Block* head() {
    diff --git a/hotspot/src/share/vm/opto/buildOopMap.cpp b/hotspot/src/share/vm/opto/buildOopMap.cpp
    index fc731604eaa..884142d57df 100644
    --- a/hotspot/src/share/vm/opto/buildOopMap.cpp
    +++ b/hotspot/src/share/vm/opto/buildOopMap.cpp
    @@ -426,14 +426,16 @@ static void do_liveness( PhaseRegAlloc *regalloc, PhaseCFG *cfg, Block_List *wor
       }
       memset( live, 0, cfg->_num_blocks * (max_reg_ints<req(); i++ )
    -    worklist->push(cfg->_bbs[root->in(i)->_idx]);
    +  for (uint i = 1; i < root->req(); i++) {
    +    Block* block = cfg->get_block_for_node(root->in(i));
    +    worklist->push(block);
    +  }
     
       // ZKM.jar includes tiny infinite loops which are unreached from below.
       // If we missed any blocks, we'll retry here after pushing all missed
       // blocks on the worklist.  Normally this outer loop never trips more
       // than once.
    -  while( 1 ) {
    +  while (1) {
     
         while( worklist->size() ) { // Standard worklist algorithm
           Block *b = worklist->rpop();
    @@ -537,8 +539,10 @@ static void do_liveness( PhaseRegAlloc *regalloc, PhaseCFG *cfg, Block_List *wor
             for( l=0; lnum_preds(); l++ )
    -          worklist->push(cfg->_bbs[b->pred(l)->_idx]);
    +        for (l = 1; l < (int)b->num_preds(); l++) {
    +          Block* block = cfg->get_block_for_node(b->pred(l));
    +          worklist->push(block);
    +        }
           }
         }
     
    @@ -629,10 +633,9 @@ void Compile::BuildOopMaps() {
         // pred to this block.  Otherwise we have to grab a new OopFlow.
         OopFlow *flow = NULL;       // Flag for finding optimized flow
         Block *pred = (Block*)0xdeadbeef;
    -    uint j;
         // Scan this block's preds to find a done predecessor
    -    for( j=1; jnum_preds(); j++ ) {
    -      Block *p = _cfg->_bbs[b->pred(j)->_idx];
    +    for (uint j = 1; j < b->num_preds(); j++) {
    +      Block* p = _cfg->get_block_for_node(b->pred(j));
           OopFlow *p_flow = flows[p->_pre_order];
           if( p_flow ) {            // Predecessor is done
             assert( p_flow->_b == p, "cross check" );
    diff --git a/hotspot/src/share/vm/opto/chaitin.cpp b/hotspot/src/share/vm/opto/chaitin.cpp
    index 53ffc573284..4fc254f40ca 100644
    --- a/hotspot/src/share/vm/opto/chaitin.cpp
    +++ b/hotspot/src/share/vm/opto/chaitin.cpp
    @@ -295,7 +295,7 @@ void PhaseChaitin::new_lrg(const Node *x, uint lrg) {
     
     
     bool PhaseChaitin::clone_projs_shared(Block *b, uint idx, Node *con, Node *copy, uint max_lrg_id) {
    -  Block *bcon = _cfg._bbs[con->_idx];
    +  Block* bcon = _cfg.get_block_for_node(con);
       uint cindex = bcon->find_node(con);
       Node *con_next = bcon->_nodes[cindex+1];
       if (con_next->in(0) != con || !con_next->is_MachProj()) {
    @@ -306,7 +306,7 @@ bool PhaseChaitin::clone_projs_shared(Block *b, uint idx, Node *con, Node *copy,
       Node *kills = con_next->clone();
       kills->set_req(0, copy);
       b->_nodes.insert(idx, kills);
    -  _cfg._bbs.map(kills->_idx, b);
    +  _cfg.map_node_to_block(kills, b);
       new_lrg(kills, max_lrg_id);
       return true;
     }
    @@ -962,8 +962,7 @@ void PhaseChaitin::gather_lrg_masks( bool after_aggressive ) {
             // AggressiveCoalesce.  This effectively pre-virtual-splits
             // around uncommon uses of common defs.
             const RegMask &rm = n->in_RegMask(k);
    -        if( !after_aggressive &&
    -          _cfg._bbs[n->in(k)->_idx]->_freq > 1000*b->_freq ) {
    +        if (!after_aggressive && _cfg.get_block_for_node(n->in(k))->_freq > 1000 * b->_freq) {
               // Since we are BEFORE aggressive coalesce, leave the register
               // mask untrimmed by the call.  This encourages more coalescing.
               // Later, AFTER aggressive, this live range will have to spill
    @@ -1709,16 +1708,15 @@ Node *PhaseChaitin::find_base_for_derived( Node **derived_base_map, Node *derive
           // set control to _root and place it into Start block
           // (where top() node is placed).
           base->init_req(0, _cfg._root);
    -      Block *startb = _cfg._bbs[C->top()->_idx];
    +      Block *startb = _cfg.get_block_for_node(C->top());
           startb->_nodes.insert(startb->find_node(C->top()), base );
    -      _cfg._bbs.map( base->_idx, startb );
    +      _cfg.map_node_to_block(base, startb);
           assert(_lrg_map.live_range_id(base) == 0, "should not have LRG yet");
         }
         if (_lrg_map.live_range_id(base) == 0) {
           new_lrg(base, maxlrg++);
         }
    -    assert(base->in(0) == _cfg._root &&
    -           _cfg._bbs[base->_idx] == _cfg._bbs[C->top()->_idx], "base NULL should be shared");
    +    assert(base->in(0) == _cfg._root && _cfg.get_block_for_node(base) == _cfg.get_block_for_node(C->top()), "base NULL should be shared");
         derived_base_map[derived->_idx] = base;
         return base;
       }
    @@ -1754,12 +1752,12 @@ Node *PhaseChaitin::find_base_for_derived( Node **derived_base_map, Node *derive
       base->as_Phi()->set_type(t);
     
       // Search the current block for an existing base-Phi
    -  Block *b = _cfg._bbs[derived->_idx];
    +  Block *b = _cfg.get_block_for_node(derived);
       for( i = 1; i <= b->end_idx(); i++ ) {// Search for matching Phi
         Node *phi = b->_nodes[i];
         if( !phi->is_Phi() ) {      // Found end of Phis with no match?
           b->_nodes.insert( i, base ); // Must insert created Phi here as base
    -      _cfg._bbs.map( base->_idx, b );
    +      _cfg.map_node_to_block(base, b);
           new_lrg(base,maxlrg++);
           break;
         }
    @@ -1815,8 +1813,8 @@ bool PhaseChaitin::stretch_base_pointer_live_ranges(ResourceArea *a) {
           if( n->is_Mach() && n->as_Mach()->ideal_Opcode() == Op_CmpI ) {
             Node *phi = n->in(1);
             if( phi->is_Phi() && phi->as_Phi()->region()->is_Loop() ) {
    -          Block *phi_block = _cfg._bbs[phi->_idx];
    -          if( _cfg._bbs[phi_block->pred(2)->_idx] == b ) {
    +          Block *phi_block = _cfg.get_block_for_node(phi);
    +          if (_cfg.get_block_for_node(phi_block->pred(2)) == b) {
                 const RegMask *mask = C->matcher()->idealreg2spillmask[Op_RegI];
                 Node *spill = new (C) MachSpillCopyNode( phi, *mask, *mask );
                 insert_proj( phi_block, 1, spill, maxlrg++ );
    @@ -1870,7 +1868,7 @@ bool PhaseChaitin::stretch_base_pointer_live_ranges(ResourceArea *a) {
                 if ((_lrg_map.live_range_id(base) >= _lrg_map.max_lrg_id() || // (Brand new base (hence not live) or
                      !liveout.member(_lrg_map.live_range_id(base))) && // not live) AND
                      (_lrg_map.live_range_id(base) > 0) && // not a constant
    -                 _cfg._bbs[base->_idx] != b) { // base not def'd in blk)
    +                 _cfg.get_block_for_node(base) != b) { // base not def'd in blk)
                   // Base pointer is not currently live.  Since I stretched
                   // the base pointer to here and it crosses basic-block
                   // boundaries, the global live info is now incorrect.
    @@ -1993,8 +1991,8 @@ void PhaseChaitin::dump(const Node *n) const {
       tty->print("\n");
     }
     
    -void PhaseChaitin::dump( const Block * b ) const {
    -  b->dump_head( &_cfg._bbs );
    +void PhaseChaitin::dump(const Block *b) const {
    +  b->dump_head(&_cfg);
     
       // For all instructions
       for( uint j = 0; j < b->_nodes.size(); j++ )
    @@ -2299,7 +2297,7 @@ void PhaseChaitin::dump_lrg( uint lidx, bool defs_only ) const {
           if (_lrg_map.find_const(n) == lidx) {
             if (!dump_once++) {
               tty->cr();
    -          b->dump_head( &_cfg._bbs );
    +          b->dump_head(&_cfg);
             }
             dump(n);
             continue;
    @@ -2314,7 +2312,7 @@ void PhaseChaitin::dump_lrg( uint lidx, bool defs_only ) const {
               if (_lrg_map.find_const(m) == lidx) {
                 if (!dump_once++) {
                   tty->cr();
    -              b->dump_head(&_cfg._bbs);
    +              b->dump_head(&_cfg);
                 }
                 dump(n);
               }
    diff --git a/hotspot/src/share/vm/opto/coalesce.cpp b/hotspot/src/share/vm/opto/coalesce.cpp
    index 60c88dc12ba..d1f880a6493 100644
    --- a/hotspot/src/share/vm/opto/coalesce.cpp
    +++ b/hotspot/src/share/vm/opto/coalesce.cpp
    @@ -52,7 +52,7 @@ void PhaseCoalesce::dump() const {
         // Print a nice block header
         tty->print("B%d: ",b->_pre_order);
         for( j=1; jnum_preds(); j++ )
    -      tty->print("B%d ", _phc._cfg._bbs[b->pred(j)->_idx]->_pre_order);
    +      tty->print("B%d ", _phc._cfg.get_block_for_node(b->pred(j))->_pre_order);
         tty->print("-> ");
         for( j=0; j_num_succs; j++ )
           tty->print("B%d ",b->_succs[j]->_pre_order);
    @@ -208,7 +208,7 @@ void PhaseAggressiveCoalesce::insert_copy_with_overlap( Block *b, Node *copy, ui
         copy->set_req(idx,tmp);
         // Save source in temp early, before source is killed
         b->_nodes.insert(kill_src_idx,tmp);
    -    _phc._cfg._bbs.map( tmp->_idx, b );
    +    _phc._cfg.map_node_to_block(tmp, b);
         last_use_idx++;
       }
     
    @@ -286,7 +286,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) {
               Node *m = n->in(j);
               uint src_name = _phc._lrg_map.find(m);
               if (src_name != phi_name) {
    -            Block *pred = _phc._cfg._bbs[b->pred(j)->_idx];
    +            Block *pred = _phc._cfg.get_block_for_node(b->pred(j));
                 Node *copy;
                 assert(!m->is_Con() || m->is_Mach(), "all Con must be Mach");
                 // Rematerialize constants instead of copying them
    @@ -305,7 +305,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) {
                 }
                 // Insert the copy in the use-def chain
                 n->set_req(j, copy);
    -            _phc._cfg._bbs.map( copy->_idx, pred );
    +            _phc._cfg.map_node_to_block(copy, pred);
                 // Extend ("register allocate") the names array for the copy.
                 _phc._lrg_map.extend(copy->_idx, phi_name);
               } // End of if Phi names do not match
    @@ -343,13 +343,13 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) {
                 n->set_req(idx, copy);
                 // Extend ("register allocate") the names array for the copy.
                 _phc._lrg_map.extend(copy->_idx, name);
    -            _phc._cfg._bbs.map( copy->_idx, b );
    +            _phc._cfg.map_node_to_block(copy, b);
               }
     
             } // End of is two-adr
     
             // Insert a copy at a debug use for a lrg which has high frequency
    -        if (b->_freq < OPTO_DEBUG_SPLIT_FREQ || b->is_uncommon(_phc._cfg._bbs)) {
    +        if (b->_freq < OPTO_DEBUG_SPLIT_FREQ || b->is_uncommon(&_phc._cfg)) {
               // Walk the debug inputs to the node and check for lrg freq
               JVMState* jvms = n->jvms();
               uint debug_start = jvms ? jvms->debug_start() : 999999;
    @@ -391,7 +391,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) {
                   uint max_lrg_id = _phc._lrg_map.max_lrg_id();
                   _phc.new_lrg(copy, max_lrg_id);
                   _phc._lrg_map.set_max_lrg_id(max_lrg_id + 1);
    -              _phc._cfg._bbs.map(copy->_idx, b);
    +              _phc._cfg.map_node_to_block(copy, b);
                   //tty->print_cr("Split a debug use in Aggressive Coalesce");
                 }  // End of if high frequency use/def
               }  // End of for all debug inputs
    @@ -437,7 +437,10 @@ void PhaseAggressiveCoalesce::coalesce( Block *b ) {
         Block *bs = b->_succs[i];
         // Find index of 'b' in 'bs' predecessors
         uint j=1;
    -    while( _phc._cfg._bbs[bs->pred(j)->_idx] != b ) j++;
    +    while (_phc._cfg.get_block_for_node(bs->pred(j)) != b) {
    +      j++;
    +    }
    +
         // Visit all the Phis in successor block
         for( uint k = 1; k_nodes.size(); k++ ) {
           Node *n = bs->_nodes[k];
    @@ -510,9 +513,9 @@ void PhaseConservativeCoalesce::union_helper( Node *lr1_node, Node *lr2_node, ui
       if( bindex < b->_fhrp_index ) b->_fhrp_index--;
     
       // Stretched lr1; add it to liveness of intermediate blocks
    -  Block *b2 = _phc._cfg._bbs[src_copy->_idx];
    +  Block *b2 = _phc._cfg.get_block_for_node(src_copy);
       while( b != b2 ) {
    -    b = _phc._cfg._bbs[b->pred(1)->_idx];
    +    b = _phc._cfg.get_block_for_node(b->pred(1));
         _phc._live->live(b)->insert(lr1);
       }
     }
    @@ -532,7 +535,7 @@ uint PhaseConservativeCoalesce::compute_separating_interferences(Node *dst_copy,
         bindex2--;                  // Chain backwards 1 instruction
         while( bindex2 == 0 ) {     // At block start, find prior block
           assert( b2->num_preds() == 2, "cannot double coalesce across c-flow" );
    -      b2 = _phc._cfg._bbs[b2->pred(1)->_idx];
    +      b2 = _phc._cfg.get_block_for_node(b2->pred(1));
           bindex2 = b2->end_idx()-1;
         }
         // Get prior instruction
    @@ -676,8 +679,8 @@ bool PhaseConservativeCoalesce::copy_copy(Node *dst_copy, Node *src_copy, Block
     
       if (UseFPUForSpilling && rm.is_AllStack() ) {
         // Don't coalesce when frequency difference is large
    -    Block *dst_b = _phc._cfg._bbs[dst_copy->_idx];
    -    Block *src_def_b = _phc._cfg._bbs[src_def->_idx];
    +    Block *dst_b = _phc._cfg.get_block_for_node(dst_copy);
    +    Block *src_def_b = _phc._cfg.get_block_for_node(src_def);
         if (src_def_b->_freq > 10*dst_b->_freq )
           return false;
       }
    @@ -690,7 +693,7 @@ bool PhaseConservativeCoalesce::copy_copy(Node *dst_copy, Node *src_copy, Block
       // Another early bail-out test is when we are double-coalescing and the
       // 2 copies are separated by some control flow.
       if( dst_copy != src_copy ) {
    -    Block *src_b = _phc._cfg._bbs[src_copy->_idx];
    +    Block *src_b = _phc._cfg.get_block_for_node(src_copy);
         Block *b2 = b;
         while( b2 != src_b ) {
           if( b2->num_preds() > 2 ){// Found merge-point
    @@ -701,7 +704,7 @@ bool PhaseConservativeCoalesce::copy_copy(Node *dst_copy, Node *src_copy, Block
             //record_bias( _phc._lrgs, lr1, lr2 );
             return false;           // To hard to find all interferences
           }
    -      b2 = _phc._cfg._bbs[b2->pred(1)->_idx];
    +      b2 = _phc._cfg.get_block_for_node(b2->pred(1));
         }
       }
     
    @@ -786,8 +789,9 @@ bool PhaseConservativeCoalesce::copy_copy(Node *dst_copy, Node *src_copy, Block
     // Conservative (but pessimistic) copy coalescing of a single block
     void PhaseConservativeCoalesce::coalesce( Block *b ) {
       // Bail out on infrequent blocks
    -  if( b->is_uncommon(_phc._cfg._bbs) )
    +  if (b->is_uncommon(&_phc._cfg)) {
         return;
    +  }
       // Check this block for copies.
       for( uint i = 1; iend_idx(); i++ ) {
         // Check for actual copies on inputs.  Coalesce a copy into its
    diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp
    index cd650b00156..f7cadda849b 100644
    --- a/hotspot/src/share/vm/opto/compile.cpp
    +++ b/hotspot/src/share/vm/opto/compile.cpp
    @@ -2262,7 +2262,7 @@ void Compile::dump_asm(int *pcs, uint pc_limit) {
           tty->print("%3.3x   ", pcs[n->_idx]);
         else
           tty->print("      ");
    -    b->dump_head( &_cfg->_bbs );
    +    b->dump_head(_cfg);
         if (b->is_connector()) {
           tty->print_cr("        # Empty connector block");
         } else if (b->num_preds() == 2 && b->pred(1)->is_CatchProj() && b->pred(1)->as_CatchProj()->_con == CatchProjNode::fall_through_index) {
    @@ -3525,7 +3525,7 @@ void Compile::ConstantTable::add(Constant& con) {
     }
     
     Compile::Constant Compile::ConstantTable::add(MachConstantNode* n, BasicType type, jvalue value) {
    -  Block* b = Compile::current()->cfg()->_bbs[n->_idx];
    +  Block* b = Compile::current()->cfg()->get_block_for_node(n);
       Constant con(type, value, b->_freq);
       add(con);
       return con;
    diff --git a/hotspot/src/share/vm/opto/domgraph.cpp b/hotspot/src/share/vm/opto/domgraph.cpp
    index 9973cb562f8..b64e291e7ca 100644
    --- a/hotspot/src/share/vm/opto/domgraph.cpp
    +++ b/hotspot/src/share/vm/opto/domgraph.cpp
    @@ -105,8 +105,8 @@ void PhaseCFG::Dominators( ) {
     
         // Step 2:
         Node *whead = w->_block->head();
    -    for( uint j=1; j < whead->req(); j++ ) {
    -      Block *b = _bbs[whead->in(j)->_idx];
    +    for (uint j = 1; j < whead->req(); j++) {
    +      Block* b = get_block_for_node(whead->in(j));
           Tarjan *vx = &tarjan[b->_pre_order];
           Tarjan *u = vx->EVAL();
           if( u->_semi < w->_semi )
    diff --git a/hotspot/src/share/vm/opto/gcm.cpp b/hotspot/src/share/vm/opto/gcm.cpp
    index 811dc5c6c87..9ded635f65f 100644
    --- a/hotspot/src/share/vm/opto/gcm.cpp
    +++ b/hotspot/src/share/vm/opto/gcm.cpp
    @@ -66,7 +66,7 @@
     // are in b also.
     void PhaseCFG::schedule_node_into_block( Node *n, Block *b ) {
       // Set basic block of n, Add n to b,
    -  _bbs.map(n->_idx, b);
    +  map_node_to_block(n, b);
       b->add_inst(n);
     
       // After Matching, nearly any old Node may have projections trailing it.
    @@ -75,11 +75,12 @@ void PhaseCFG::schedule_node_into_block( Node *n, Block *b ) {
       for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
         Node*  use  = n->fast_out(i);
         if (use->is_Proj()) {
    -      Block* buse = _bbs[use->_idx];
    +      Block* buse = get_block_for_node(use);
           if (buse != b) {              // In wrong block?
    -        if (buse != NULL)
    +        if (buse != NULL) {
               buse->find_remove(use);   // Remove from wrong block
    -        _bbs.map(use->_idx, b);     // Re-insert in this block
    +        }
    +        map_node_to_block(use, b);
             b->add_inst(use);
           }
         }
    @@ -97,7 +98,7 @@ void PhaseCFG::replace_block_proj_ctrl( Node *n ) {
       if (p != NULL && p != n) {    // Control from a block projection?
         assert(!n->pinned() || n->is_MachConstantBase(), "only pinned MachConstantBase node is expected here");
         // Find trailing Region
    -    Block *pb = _bbs[in0->_idx]; // Block-projection already has basic block
    +    Block *pb = get_block_for_node(in0); // Block-projection already has basic block
         uint j = 0;
         if (pb->_num_succs != 1) {  // More then 1 successor?
           // Search for successor
    @@ -127,14 +128,15 @@ void PhaseCFG::schedule_pinned_nodes( VectorSet &visited ) {
       while ( spstack.is_nonempty() ) {
         Node *n = spstack.pop();
         if( !visited.test_set(n->_idx) ) { // Test node and flag it as visited
    -      if( n->pinned() && !_bbs.lookup(n->_idx) ) {  // Pinned?  Nail it down!
    +      if( n->pinned() && !has_block(n)) {  // Pinned?  Nail it down!
             assert( n->in(0), "pinned Node must have Control" );
             // Before setting block replace block_proj control edge
             replace_block_proj_ctrl(n);
             Node *input = n->in(0);
    -        while( !input->is_block_start() )
    +        while (!input->is_block_start()) {
               input = input->in(0);
    -        Block *b = _bbs[input->_idx];  // Basic block of controlling input
    +        }
    +        Block *b = get_block_for_node(input); // Basic block of controlling input
             schedule_node_into_block(n, b);
           }
           for( int i = n->req() - 1; i >= 0; --i ) {  // For all inputs
    @@ -149,7 +151,7 @@ void PhaseCFG::schedule_pinned_nodes( VectorSet &visited ) {
     // Assert that new input b2 is dominated by all previous inputs.
     // Check this by by seeing that it is dominated by b1, the deepest
     // input observed until b2.
    -static void assert_dom(Block* b1, Block* b2, Node* n, Block_Array &bbs) {
    +static void assert_dom(Block* b1, Block* b2, Node* n, const PhaseCFG* cfg) {
       if (b1 == NULL)  return;
       assert(b1->_dom_depth < b2->_dom_depth, "sanity");
       Block* tmp = b2;
    @@ -162,7 +164,7 @@ static void assert_dom(Block* b1, Block* b2, Node* n, Block_Array &bbs) {
         for (uint j=0; jlen(); j++) { // For all inputs
           Node* inn = n->in(j); // Get input
           if (inn == NULL)  continue;  // Ignore NULL, missing inputs
    -      Block* inb = bbs[inn->_idx];
    +      Block* inb = cfg->get_block_for_node(inn);
           tty->print("B%d idom=B%d depth=%2d ",inb->_pre_order,
                      inb->_idom ? inb->_idom->_pre_order : 0, inb->_dom_depth);
           inn->dump();
    @@ -174,20 +176,20 @@ static void assert_dom(Block* b1, Block* b2, Node* n, Block_Array &bbs) {
     }
     #endif
     
    -static Block* find_deepest_input(Node* n, Block_Array &bbs) {
    +static Block* find_deepest_input(Node* n, const PhaseCFG* cfg) {
       // Find the last input dominated by all other inputs.
       Block* deepb           = NULL;        // Deepest block so far
       int    deepb_dom_depth = 0;
       for (uint k = 0; k < n->len(); k++) { // For all inputs
         Node* inn = n->in(k);               // Get input
         if (inn == NULL)  continue;         // Ignore NULL, missing inputs
    -    Block* inb = bbs[inn->_idx];
    +    Block* inb = cfg->get_block_for_node(inn);
         assert(inb != NULL, "must already have scheduled this input");
         if (deepb_dom_depth < (int) inb->_dom_depth) {
           // The new inb must be dominated by the previous deepb.
           // The various inputs must be linearly ordered in the dom
           // tree, or else there will not be a unique deepest block.
    -      DEBUG_ONLY(assert_dom(deepb, inb, n, bbs));
    +      DEBUG_ONLY(assert_dom(deepb, inb, n, cfg));
           deepb = inb;                      // Save deepest block
           deepb_dom_depth = deepb->_dom_depth;
         }
    @@ -243,7 +245,7 @@ bool PhaseCFG::schedule_early(VectorSet &visited, Node_List &roots) {
             ++i;
             if (in == NULL) continue;    // Ignore NULL, missing inputs
             int is_visited = visited.test_set(in->_idx);
    -        if (!_bbs.lookup(in->_idx)) { // Missing block selection?
    +        if (!has_block(in)) { // Missing block selection?
               if (is_visited) {
                 // assert( !visited.test(in->_idx), "did not schedule early" );
                 return false;
    @@ -265,9 +267,9 @@ bool PhaseCFG::schedule_early(VectorSet &visited, Node_List &roots) {
             // any projections which depend on them.
             if (!n->pinned()) {
               // Set earliest legal block.
    -          _bbs.map(n->_idx, find_deepest_input(n, _bbs));
    +          map_node_to_block(n, find_deepest_input(n, this));
             } else {
    -          assert(_bbs[n->_idx] == _bbs[n->in(0)->_idx], "Pinned Node should be at the same block as its control edge");
    +          assert(get_block_for_node(n) == get_block_for_node(n->in(0)), "Pinned Node should be at the same block as its control edge");
             }
     
             if (nstack.is_empty()) {
    @@ -313,8 +315,8 @@ Block* Block::dom_lca(Block* LCA) {
     // The definition must dominate the use, so move the LCA upward in the
     // dominator tree to dominate the use.  If the use is a phi, adjust
     // the LCA only with the phi input paths which actually use this def.
    -static Block* raise_LCA_above_use(Block* LCA, Node* use, Node* def, Block_Array &bbs) {
    -  Block* buse = bbs[use->_idx];
    +static Block* raise_LCA_above_use(Block* LCA, Node* use, Node* def, const PhaseCFG* cfg) {
    +  Block* buse = cfg->get_block_for_node(use);
       if (buse == NULL)    return LCA;   // Unused killing Projs have no use block
       if (!use->is_Phi())  return buse->dom_lca(LCA);
       uint pmax = use->req();       // Number of Phi inputs
    @@ -329,7 +331,7 @@ static Block* raise_LCA_above_use(Block* LCA, Node* use, Node* def, Block_Array
       // more than once.
       for (uint j=1; jin(j) == def) {    // Found matching input?
    -      Block* pred = bbs[buse->pred(j)->_idx];
    +      Block* pred = cfg->get_block_for_node(buse->pred(j));
           LCA = pred->dom_lca(LCA);
         }
       }
    @@ -342,8 +344,7 @@ static Block* raise_LCA_above_use(Block* LCA, Node* use, Node* def, Block_Array
     // which are marked with the given index.  Return the LCA (in the dom tree)
     // of all marked blocks.  If there are none marked, return the original
     // LCA.
    -static Block* raise_LCA_above_marks(Block* LCA, node_idx_t mark,
    -                                    Block* early, Block_Array &bbs) {
    +static Block* raise_LCA_above_marks(Block* LCA, node_idx_t mark, Block* early, const PhaseCFG* cfg) {
       Block_List worklist;
       worklist.push(LCA);
       while (worklist.size() > 0) {
    @@ -366,7 +367,7 @@ static Block* raise_LCA_above_marks(Block* LCA, node_idx_t mark,
         } else {
           // Keep searching through this block's predecessors.
           for (uint j = 1, jmax = mid->num_preds(); j < jmax; j++) {
    -        Block* mid_parent = bbs[ mid->pred(j)->_idx ];
    +        Block* mid_parent = cfg->get_block_for_node(mid->pred(j));
             worklist.push(mid_parent);
           }
         }
    @@ -384,7 +385,7 @@ static Block* raise_LCA_above_marks(Block* LCA, node_idx_t mark,
     // be earlier (at a shallower dom_depth) than the true schedule_early
     // point of the node. We compute this earlier block as a more permissive
     // site for anti-dependency insertion, but only if subsume_loads is enabled.
    -static Block* memory_early_block(Node* load, Block* early, Block_Array &bbs) {
    +static Block* memory_early_block(Node* load, Block* early, const PhaseCFG* cfg) {
       Node* base;
       Node* index;
       Node* store = load->in(MemNode::Memory);
    @@ -412,12 +413,12 @@ static Block* memory_early_block(Node* load, Block* early, Block_Array &bbs) {
         Block* deepb           = NULL;        // Deepest block so far
         int    deepb_dom_depth = 0;
         for (int i = 0; i < mem_inputs_length; i++) {
    -      Block* inb = bbs[mem_inputs[i]->_idx];
    +      Block* inb = cfg->get_block_for_node(mem_inputs[i]);
           if (deepb_dom_depth < (int) inb->_dom_depth) {
             // The new inb must be dominated by the previous deepb.
             // The various inputs must be linearly ordered in the dom
             // tree, or else there will not be a unique deepest block.
    -        DEBUG_ONLY(assert_dom(deepb, inb, load, bbs));
    +        DEBUG_ONLY(assert_dom(deepb, inb, load, cfg));
             deepb = inb;                      // Save deepest block
             deepb_dom_depth = deepb->_dom_depth;
           }
    @@ -488,14 +489,14 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
       // and other inputs are first available.  (Computed by schedule_early.)
       // For normal loads, 'early' is the shallowest place (dom graph wise)
       // to look for anti-deps between this load and any store.
    -  Block* early = _bbs[load_index];
    +  Block* early = get_block_for_node(load);
     
       // If we are subsuming loads, compute an "early" block that only considers
       // memory or address inputs. This block may be different than the
       // schedule_early block in that it could be at an even shallower depth in the
       // dominator tree, and allow for a broader discovery of anti-dependences.
       if (C->subsume_loads()) {
    -    early = memory_early_block(load, early, _bbs);
    +    early = memory_early_block(load, early, this);
       }
     
       ResourceArea *area = Thread::current()->resource_area();
    @@ -619,7 +620,7 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
         // or else observe that 'store' is all the way up in the
         // earliest legal block for 'load'.  In the latter case,
         // immediately insert an anti-dependence edge.
    -    Block* store_block = _bbs[store->_idx];
    +    Block* store_block = get_block_for_node(store);
         assert(store_block != NULL, "unused killing projections skipped above");
     
         if (store->is_Phi()) {
    @@ -637,7 +638,7 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
           for (uint j = PhiNode::Input, jmax = store->req(); j < jmax; j++) {
             if (store->in(j) == mem) {   // Found matching input?
               DEBUG_ONLY(found_match = true);
    -          Block* pred_block = _bbs[store_block->pred(j)->_idx];
    +          Block* pred_block = get_block_for_node(store_block->pred(j));
               if (pred_block != early) {
                 // If any predecessor of the Phi matches the load's "early block",
                 // we do not need a precedence edge between the Phi and 'load'
    @@ -711,7 +712,7 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
       // preventing the load from sinking past any block containing
       // a store that may invalidate the memory state required by 'load'.
       if (must_raise_LCA)
    -    LCA = raise_LCA_above_marks(LCA, load->_idx, early, _bbs);
    +    LCA = raise_LCA_above_marks(LCA, load->_idx, early, this);
       if (LCA == early)  return LCA;
     
       // Insert anti-dependence edges from 'load' to each store
    @@ -720,7 +721,7 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
       if (LCA->raise_LCA_mark() == load_index) {
         while (non_early_stores.size() > 0) {
           Node* store = non_early_stores.pop();
    -      Block* store_block = _bbs[store->_idx];
    +      Block* store_block = get_block_for_node(store);
           if (store_block == LCA) {
             // add anti_dependence from store to load in its own block
             assert(store != load->in(0), "dependence cycle found");
    @@ -754,7 +755,7 @@ private:
     
     public:
       // Constructor for the iterator
    -  Node_Backward_Iterator(Node *root, VectorSet &visited, Node_List &stack, Block_Array &bbs);
    +  Node_Backward_Iterator(Node *root, VectorSet &visited, Node_List &stack, PhaseCFG &cfg);
     
       // Postincrement operator to iterate over the nodes
       Node *next();
    @@ -762,12 +763,12 @@ public:
     private:
       VectorSet   &_visited;
       Node_List   &_stack;
    -  Block_Array &_bbs;
    +  PhaseCFG &_cfg;
     };
     
     // Constructor for the Node_Backward_Iterator
    -Node_Backward_Iterator::Node_Backward_Iterator( Node *root, VectorSet &visited, Node_List &stack, Block_Array &bbs )
    -  : _visited(visited), _stack(stack), _bbs(bbs) {
    +Node_Backward_Iterator::Node_Backward_Iterator( Node *root, VectorSet &visited, Node_List &stack, PhaseCFG &cfg)
    +  : _visited(visited), _stack(stack), _cfg(cfg) {
       // The stack should contain exactly the root
       stack.clear();
       stack.push(root);
    @@ -797,8 +798,8 @@ Node *Node_Backward_Iterator::next() {
         _visited.set(self->_idx);
     
         // Now schedule all uses as late as possible.
    -    uint src     = self->is_Proj() ? self->in(0)->_idx : self->_idx;
    -    uint src_rpo = _bbs[src]->_rpo;
    +    const Node* src = self->is_Proj() ? self->in(0) : self;
    +    uint src_rpo = _cfg.get_block_for_node(src)->_rpo;
     
         // Schedule all nodes in a post-order visit
         Node *unvisited = NULL;  // Unvisited anti-dependent Node, if any
    @@ -814,7 +815,7 @@ Node *Node_Backward_Iterator::next() {
     
           // do not traverse backward control edges
           Node *use = n->is_Proj() ? n->in(0) : n;
    -      uint use_rpo = _bbs[use->_idx]->_rpo;
    +      uint use_rpo = _cfg.get_block_for_node(use)->_rpo;
     
           if ( use_rpo < src_rpo )
             continue;
    @@ -852,7 +853,7 @@ void PhaseCFG::ComputeLatenciesBackwards(VectorSet &visited, Node_List &stack) {
         tty->print("\n#---- ComputeLatenciesBackwards ----\n");
     #endif
     
    -  Node_Backward_Iterator iter((Node *)_root, visited, stack, _bbs);
    +  Node_Backward_Iterator iter((Node *)_root, visited, stack, *this);
       Node *n;
     
       // Walk over all the nodes from last to first
    @@ -883,7 +884,7 @@ void PhaseCFG::partial_latency_of_defs(Node *n) {
     
       uint nlen = n->len();
       uint use_latency = _node_latency->at_grow(n->_idx);
    -  uint use_pre_order = _bbs[n->_idx]->_pre_order;
    +  uint use_pre_order = get_block_for_node(n)->_pre_order;
     
       for ( uint j=0; jin(j);
    @@ -903,7 +904,7 @@ void PhaseCFG::partial_latency_of_defs(Node *n) {
     #endif
     
         // If the defining block is not known, assume it is ok
    -    Block *def_block = _bbs[def->_idx];
    +    Block *def_block = get_block_for_node(def);
         uint def_pre_order = def_block ? def_block->_pre_order : 0;
     
         if ( (use_pre_order <  def_pre_order) ||
    @@ -931,10 +932,11 @@ void PhaseCFG::partial_latency_of_defs(Node *n) {
     // Compute the latency of a specific use
     int PhaseCFG::latency_from_use(Node *n, const Node *def, Node *use) {
       // If self-reference, return no latency
    -  if (use == n || use->is_Root())
    +  if (use == n || use->is_Root()) {
         return 0;
    +  }
     
    -  uint def_pre_order = _bbs[def->_idx]->_pre_order;
    +  uint def_pre_order = get_block_for_node(def)->_pre_order;
       uint latency = 0;
     
       // If the use is not a projection, then it is simple...
    @@ -946,7 +948,7 @@ int PhaseCFG::latency_from_use(Node *n, const Node *def, Node *use) {
         }
     #endif
     
    -    uint use_pre_order = _bbs[use->_idx]->_pre_order;
    +    uint use_pre_order = get_block_for_node(use)->_pre_order;
     
         if (use_pre_order < def_pre_order)
           return 0;
    @@ -1018,7 +1020,7 @@ Block* PhaseCFG::hoist_to_cheaper_block(Block* LCA, Block* early, Node* self) {
       uint start_latency = _node_latency->at_grow(LCA->_nodes[0]->_idx);
       uint end_latency   = _node_latency->at_grow(LCA->_nodes[LCA->end_idx()]->_idx);
       bool in_latency    = (target <= start_latency);
    -  const Block* root_block = _bbs[_root->_idx];
    +  const Block* root_block = get_block_for_node(_root);
     
       // Turn off latency scheduling if scheduling is just plain off
       if (!C->do_scheduling())
    @@ -1126,12 +1128,12 @@ void PhaseCFG::schedule_late(VectorSet &visited, Node_List &stack) {
         tty->print("\n#---- schedule_late ----\n");
     #endif
     
    -  Node_Backward_Iterator iter((Node *)_root, visited, stack, _bbs);
    +  Node_Backward_Iterator iter((Node *)_root, visited, stack, *this);
       Node *self;
     
       // Walk over all the nodes from last to first
       while (self = iter.next()) {
    -    Block* early = _bbs[self->_idx];   // Earliest legal placement
    +    Block* early = get_block_for_node(self); // Earliest legal placement
     
         if (self->is_top()) {
           // Top node goes in bb #2 with other constants.
    @@ -1179,7 +1181,7 @@ void PhaseCFG::schedule_late(VectorSet &visited, Node_List &stack) {
           for (DUIterator_Fast imax, i = self->fast_outs(imax); i < imax; i++) {
             // For all uses, find LCA
             Node* use = self->fast_out(i);
    -        LCA = raise_LCA_above_use(LCA, use, self, _bbs);
    +        LCA = raise_LCA_above_use(LCA, use, self, this);
           }
         }  // (Hide defs of imax, i from rest of block.)
     
    @@ -1187,7 +1189,7 @@ void PhaseCFG::schedule_late(VectorSet &visited, Node_List &stack) {
         // requirement for correctness but it reduces useless
         // interference between temps and other nodes.
         if (mach != NULL && mach->is_MachTemp()) {
    -      _bbs.map(self->_idx, LCA);
    +      map_node_to_block(self, LCA);
           LCA->add_inst(self);
           continue;
         }
    @@ -1262,10 +1264,10 @@ void PhaseCFG::GlobalCodeMotion( Matcher &matcher, uint unique, Node_List &proj_
       }
     #endif
     
    -  // Initialize the bbs.map for things on the proj_list
    -  uint i;
    -  for( i=0; i < proj_list.size(); i++ )
    -    _bbs.map(proj_list[i]->_idx, NULL);
    +  // Initialize the node to block mapping for things on the proj_list
    +  for (uint i = 0; i < proj_list.size(); i++) {
    +    unmap_node_from_block(proj_list[i]);
    +  }
     
       // Set the basic block for Nodes pinned into blocks
       Arena *a = Thread::current()->resource_area();
    @@ -1333,7 +1335,7 @@ void PhaseCFG::GlobalCodeMotion( Matcher &matcher, uint unique, Node_List &proj_
         for( int i= matcher._null_check_tests.size()-2; i>=0; i-=2 ) {
           Node *proj = matcher._null_check_tests[i  ];
           Node *val  = matcher._null_check_tests[i+1];
    -      _bbs[proj->_idx]->implicit_null_check(this, proj, val, allowed_reasons);
    +      get_block_for_node(proj)->implicit_null_check(this, proj, val, allowed_reasons);
           // The implicit_null_check will only perform the transformation
           // if the null branch is truly uncommon, *and* it leads to an
           // uncommon trap.  Combined with the too_many_traps guards
    @@ -1353,7 +1355,7 @@ void PhaseCFG::GlobalCodeMotion( Matcher &matcher, uint unique, Node_List &proj_
       uint max_idx = C->unique();
       GrowableArray ready_cnt(max_idx, max_idx, -1);
       visited.Clear();
    -  for (i = 0; i < _num_blocks; i++) {
    +  for (uint i = 0; i < _num_blocks; i++) {
         if (!_blocks[i]->schedule_local(this, matcher, ready_cnt, visited)) {
           if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) {
             C->record_method_not_compilable("local schedule failed");
    @@ -1364,8 +1366,9 @@ void PhaseCFG::GlobalCodeMotion( Matcher &matcher, uint unique, Node_List &proj_
     
       // If we inserted any instructions between a Call and his CatchNode,
       // clone the instructions on all paths below the Catch.
    -  for( i=0; i < _num_blocks; i++ )
    -    _blocks[i]->call_catch_cleanup(_bbs, C);
    +  for (uint i = 0; i < _num_blocks; i++) {
    +    _blocks[i]->call_catch_cleanup(this, C);
    +  }
     
     #ifndef PRODUCT
       if (trace_opto_pipelining()) {
    @@ -1392,7 +1395,7 @@ void PhaseCFG::Estimate_Block_Frequency() {
         Block_List worklist;
         Block* root_blk = _blocks[0];
         for (uint i = 1; i < root_blk->num_preds(); i++) {
    -      Block *pb = _bbs[root_blk->pred(i)->_idx];
    +      Block *pb = get_block_for_node(root_blk->pred(i));
           if (pb->has_uncommon_code()) {
             worklist.push(pb);
           }
    @@ -1401,7 +1404,7 @@ void PhaseCFG::Estimate_Block_Frequency() {
           Block* uct = worklist.pop();
           if (uct == _broot) continue;
           for (uint i = 1; i < uct->num_preds(); i++) {
    -        Block *pb = _bbs[uct->pred(i)->_idx];
    +        Block *pb = get_block_for_node(uct->pred(i));
             if (pb->_num_succs == 1) {
               worklist.push(pb);
             } else if (pb->num_fall_throughs() == 2) {
    @@ -1430,7 +1433,7 @@ void PhaseCFG::Estimate_Block_Frequency() {
         Block_List worklist;
         Block* root_blk = _blocks[0];
         for (uint i = 1; i < root_blk->num_preds(); i++) {
    -      Block *pb = _bbs[root_blk->pred(i)->_idx];
    +      Block *pb = get_block_for_node(root_blk->pred(i));
           if (pb->has_uncommon_code()) {
             worklist.push(pb);
           }
    @@ -1439,7 +1442,7 @@ void PhaseCFG::Estimate_Block_Frequency() {
           Block* uct = worklist.pop();
           uct->_freq = PROB_MIN;
           for (uint i = 1; i < uct->num_preds(); i++) {
    -        Block *pb = _bbs[uct->pred(i)->_idx];
    +        Block *pb = get_block_for_node(uct->pred(i));
             if (pb->_num_succs == 1 && pb->_freq > PROB_MIN) {
               worklist.push(pb);
             }
    @@ -1499,7 +1502,7 @@ CFGLoop* PhaseCFG::create_loop_tree() {
           Block* loop_head = b;
           assert(loop_head->num_preds() - 1 == 2, "loop must have 2 predecessors");
           Node* tail_n = loop_head->pred(LoopNode::LoopBackControl);
    -      Block* tail = _bbs[tail_n->_idx];
    +      Block* tail = get_block_for_node(tail_n);
     
           // Defensively filter out Loop nodes for non-single-entry loops.
           // For all reasonable loops, the head occurs before the tail in RPO.
    @@ -1514,13 +1517,13 @@ CFGLoop* PhaseCFG::create_loop_tree() {
             loop_head->_loop = nloop;
             // Add to nloop so push_pred() will skip over inner loops
             nloop->add_member(loop_head);
    -        nloop->push_pred(loop_head, LoopNode::LoopBackControl, worklist, _bbs);
    +        nloop->push_pred(loop_head, LoopNode::LoopBackControl, worklist, this);
     
             while (worklist.size() > 0) {
               Block* member = worklist.pop();
               if (member != loop_head) {
                 for (uint j = 1; j < member->num_preds(); j++) {
    -              nloop->push_pred(member, j, worklist, _bbs);
    +              nloop->push_pred(member, j, worklist, this);
                 }
               }
             }
    @@ -1557,9 +1560,9 @@ CFGLoop* PhaseCFG::create_loop_tree() {
     }
     
     //------------------------------push_pred--------------------------------------
    -void CFGLoop::push_pred(Block* blk, int i, Block_List& worklist, Block_Array& node_to_blk) {
    +void CFGLoop::push_pred(Block* blk, int i, Block_List& worklist, PhaseCFG* cfg) {
       Node* pred_n = blk->pred(i);
    -  Block* pred = node_to_blk[pred_n->_idx];
    +  Block* pred = cfg->get_block_for_node(pred_n);
       CFGLoop *pred_loop = pred->_loop;
       if (pred_loop == NULL) {
         // Filter out blocks for non-single-entry loops.
    @@ -1580,7 +1583,7 @@ void CFGLoop::push_pred(Block* blk, int i, Block_List& worklist, Block_Array& no
           Block* pred_head = pred_loop->head();
           assert(pred_head->num_preds() - 1 == 2, "loop must have 2 predecessors");
           assert(pred_head != head(), "loop head in only one loop");
    -      push_pred(pred_head, LoopNode::EntryControl, worklist, node_to_blk);
    +      push_pred(pred_head, LoopNode::EntryControl, worklist, cfg);
         } else {
           assert(pred_loop->_parent == this && _parent == NULL, "just checking");
         }
    diff --git a/hotspot/src/share/vm/opto/idealGraphPrinter.cpp b/hotspot/src/share/vm/opto/idealGraphPrinter.cpp
    index e6909054324..4330643b8b5 100644
    --- a/hotspot/src/share/vm/opto/idealGraphPrinter.cpp
    +++ b/hotspot/src/share/vm/opto/idealGraphPrinter.cpp
    @@ -413,9 +413,9 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {
         print_prop("debug_idx", node->_debug_idx);
     #endif
     
    -    if(C->cfg() != NULL) {
    -      Block *block = C->cfg()->_bbs[node->_idx];
    -      if(block == NULL) {
    +    if (C->cfg() != NULL) {
    +      Block* block = C->cfg()->get_block_for_node(node);
    +      if (block == NULL) {
             print_prop("block", C->cfg()->_blocks[0]->_pre_order);
           } else {
             print_prop("block", block->_pre_order);
    diff --git a/hotspot/src/share/vm/opto/ifg.cpp b/hotspot/src/share/vm/opto/ifg.cpp
    index 96c0957cffb..82a8ea893e4 100644
    --- a/hotspot/src/share/vm/opto/ifg.cpp
    +++ b/hotspot/src/share/vm/opto/ifg.cpp
    @@ -565,7 +565,7 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) {
                   lrgs(r)._def = 0;
                 }
                 n->disconnect_inputs(NULL, C);
    -            _cfg._bbs.map(n->_idx,NULL);
    +            _cfg.unmap_node_from_block(n);
                 n->replace_by(C->top());
                 // Since yanking a Node from block, high pressure moves up one
                 hrp_index[0]--;
    @@ -607,7 +607,7 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) {
               if( n->is_SpillCopy()
                   && lrgs(r).is_singledef()        // MultiDef live range can still split
                   && n->outcnt() == 1              // and use must be in this block
    -              && _cfg._bbs[n->unique_out()->_idx] == b ) {
    +              && _cfg.get_block_for_node(n->unique_out()) == b ) {
                 // All single-use MachSpillCopy(s) that immediately precede their
                 // use must color early.  If a longer live range steals their
                 // color, the spill copy will split and may push another spill copy
    diff --git a/hotspot/src/share/vm/opto/lcm.cpp b/hotspot/src/share/vm/opto/lcm.cpp
    index 2b3eca478d9..fc05a79b416 100644
    --- a/hotspot/src/share/vm/opto/lcm.cpp
    +++ b/hotspot/src/share/vm/opto/lcm.cpp
    @@ -237,7 +237,7 @@ void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowe
         }
     
         // Check ctrl input to see if the null-check dominates the memory op
    -    Block *cb = cfg->_bbs[mach->_idx];
    +    Block *cb = cfg->get_block_for_node(mach);
         cb = cb->_idom;             // Always hoist at least 1 block
         if( !was_store ) {          // Stores can be hoisted only one block
           while( cb->_dom_depth > (_dom_depth + 1))
    @@ -262,7 +262,7 @@ void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowe
             if( is_decoden ) continue;
           }
           // Block of memory-op input
    -      Block *inb = cfg->_bbs[mach->in(j)->_idx];
    +      Block *inb = cfg->get_block_for_node(mach->in(j));
           Block *b = this;          // Start from nul check
           while( b != inb && b->_dom_depth > inb->_dom_depth )
             b = b->_idom;           // search upwards for input
    @@ -272,7 +272,7 @@ void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowe
         }
         if( j > 0 )
           continue;
    -    Block *mb = cfg->_bbs[mach->_idx];
    +    Block *mb = cfg->get_block_for_node(mach);
         // Hoisting stores requires more checks for the anti-dependence case.
         // Give up hoisting if we have to move the store past any load.
         if( was_store ) {
    @@ -291,7 +291,7 @@ void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowe
               break;                // Found anti-dependent load
             // Make sure control does not do a merge (would have to check allpaths)
             if( b->num_preds() != 2 ) break;
    -        b = cfg->_bbs[b->pred(1)->_idx]; // Move up to predecessor block
    +        b = cfg->get_block_for_node(b->pred(1)); // Move up to predecessor block
           }
           if( b != this ) continue;
         }
    @@ -303,15 +303,15 @@ void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowe
     
         // Found a candidate!  Pick one with least dom depth - the highest
         // in the dom tree should be closest to the null check.
    -    if( !best ||
    -        cfg->_bbs[mach->_idx]->_dom_depth < cfg->_bbs[best->_idx]->_dom_depth ) {
    +    if (best == NULL || cfg->get_block_for_node(mach)->_dom_depth < cfg->get_block_for_node(best)->_dom_depth) {
           best = mach;
           bidx = vidx;
    -
         }
       }
       // No candidate!
    -  if( !best ) return;
    +  if (best == NULL) {
    +    return;
    +  }
     
       // ---- Found an implicit null check
       extern int implicit_null_checks;
    @@ -319,29 +319,29 @@ void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowe
     
       if( is_decoden ) {
         // Check if we need to hoist decodeHeapOop_not_null first.
    -    Block *valb = cfg->_bbs[val->_idx];
    +    Block *valb = cfg->get_block_for_node(val);
         if( this != valb && this->_dom_depth < valb->_dom_depth ) {
           // Hoist it up to the end of the test block.
           valb->find_remove(val);
           this->add_inst(val);
    -      cfg->_bbs.map(val->_idx,this);
    +      cfg->map_node_to_block(val, this);
           // DecodeN on x86 may kill flags. Check for flag-killing projections
           // that also need to be hoisted.
           for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) {
             Node* n = val->fast_out(j);
             if( n->is_MachProj() ) {
    -          cfg->_bbs[n->_idx]->find_remove(n);
    +          cfg->get_block_for_node(n)->find_remove(n);
               this->add_inst(n);
    -          cfg->_bbs.map(n->_idx,this);
    +          cfg->map_node_to_block(n, this);
             }
           }
         }
       }
       // Hoist the memory candidate up to the end of the test block.
    -  Block *old_block = cfg->_bbs[best->_idx];
    +  Block *old_block = cfg->get_block_for_node(best);
       old_block->find_remove(best);
       add_inst(best);
    -  cfg->_bbs.map(best->_idx,this);
    +  cfg->map_node_to_block(best, this);
     
       // Move the control dependence
       if (best->in(0) && best->in(0) == old_block->_nodes[0])
    @@ -352,9 +352,9 @@ void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowe
       for (DUIterator_Fast jmax, j = best->fast_outs(jmax); j < jmax; j++) {
         Node* n = best->fast_out(j);
         if( n->is_MachProj() ) {
    -      cfg->_bbs[n->_idx]->find_remove(n);
    +      cfg->get_block_for_node(n)->find_remove(n);
           add_inst(n);
    -      cfg->_bbs.map(n->_idx,this);
    +      cfg->map_node_to_block(n, this);
         }
       }
     
    @@ -385,7 +385,7 @@ void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowe
       Node *old_tst = proj->in(0);
       MachNode *nul_chk = new (C) MachNullCheckNode(old_tst->in(0),best,bidx);
       _nodes.map(end_idx(),nul_chk);
    -  cfg->_bbs.map(nul_chk->_idx,this);
    +  cfg->map_node_to_block(nul_chk, this);
       // Redirect users of old_test to nul_chk
       for (DUIterator_Last i2min, i2 = old_tst->last_outs(i2min); i2 >= i2min; --i2)
         old_tst->last_out(i2)->set_req(0, nul_chk);
    @@ -468,7 +468,7 @@ Node *Block::select(PhaseCFG *cfg, Node_List &worklist, GrowableArray &read
             Node* use = n->fast_out(j);
     
             // The use is a conditional branch, make them adjacent
    -        if (use->is_MachIf() && cfg->_bbs[use->_idx]==this ) {
    +        if (use->is_MachIf() && cfg->get_block_for_node(use) == this) {
               found_machif = true;
               break;
             }
    @@ -529,13 +529,14 @@ Node *Block::select(PhaseCFG *cfg, Node_List &worklist, GrowableArray &read
     
     
     //------------------------------set_next_call----------------------------------
    -void Block::set_next_call( Node *n, VectorSet &next_call, Block_Array &bbs ) {
    +void Block::set_next_call( Node *n, VectorSet &next_call, PhaseCFG* cfg) {
       if( next_call.test_set(n->_idx) ) return;
       for( uint i=0; ilen(); i++ ) {
         Node *m = n->in(i);
         if( !m ) continue;  // must see all nodes in block that precede call
    -    if( bbs[m->_idx] == this )
    -      set_next_call( m, next_call, bbs );
    +    if (cfg->get_block_for_node(m) == this) {
    +      set_next_call(m, next_call, cfg);
    +    }
       }
     }
     
    @@ -545,12 +546,12 @@ void Block::set_next_call( Node *n, VectorSet &next_call, Block_Array &bbs ) {
     // next subroutine call get priority - basically it moves things NOT needed
     // for the next call till after the call.  This prevents me from trying to
     // carry lots of stuff live across a call.
    -void Block::needed_for_next_call(Node *this_call, VectorSet &next_call, Block_Array &bbs) {
    +void Block::needed_for_next_call(Node *this_call, VectorSet &next_call, PhaseCFG* cfg) {
       // Find the next control-defining Node in this block
       Node* call = NULL;
       for (DUIterator_Fast imax, i = this_call->fast_outs(imax); i < imax; i++) {
         Node* m = this_call->fast_out(i);
    -    if( bbs[m->_idx] == this && // Local-block user
    +    if(cfg->get_block_for_node(m) == this && // Local-block user
             m != this_call &&       // Not self-start node
             m->is_MachCall() )
           call = m;
    @@ -558,7 +559,7 @@ void Block::needed_for_next_call(Node *this_call, VectorSet &next_call, Block_Ar
       }
       if (call == NULL)  return;    // No next call (e.g., block end is near)
       // Set next-call for all inputs to this call
    -  set_next_call(call, next_call, bbs);
    +  set_next_call(call, next_call, cfg);
     }
     
     //------------------------------add_call_kills-------------------------------------
    @@ -578,7 +579,7 @@ void Block::add_call_kills(MachProjNode *proj, RegMask& regs, const char* save_p
     
     
     //------------------------------sched_call-------------------------------------
    -uint Block::sched_call( Matcher &matcher, Block_Array &bbs, uint node_cnt, Node_List &worklist, GrowableArray &ready_cnt, MachCallNode *mcall, VectorSet &next_call ) {
    +uint Block::sched_call( Matcher &matcher, PhaseCFG* cfg, uint node_cnt, Node_List &worklist, GrowableArray &ready_cnt, MachCallNode *mcall, VectorSet &next_call ) {
       RegMask regs;
     
       // Schedule all the users of the call right now.  All the users are
    @@ -597,12 +598,14 @@ uint Block::sched_call( Matcher &matcher, Block_Array &bbs, uint node_cnt, Node_
         // Check for scheduling the next control-definer
         if( n->bottom_type() == Type::CONTROL )
           // Warm up next pile of heuristic bits
    -      needed_for_next_call(n, next_call, bbs);
    +      needed_for_next_call(n, next_call, cfg);
     
         // Children of projections are now all ready
         for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
           Node* m = n->fast_out(j); // Get user
    -      if( bbs[m->_idx] != this ) continue;
    +      if(cfg->get_block_for_node(m) != this) {
    +        continue;
    +      }
           if( m->is_Phi() ) continue;
           int m_cnt = ready_cnt.at(m->_idx)-1;
           ready_cnt.at_put(m->_idx, m_cnt);
    @@ -620,7 +623,7 @@ uint Block::sched_call( Matcher &matcher, Block_Array &bbs, uint node_cnt, Node_
       uint r_cnt = mcall->tf()->range()->cnt();
       int op = mcall->ideal_Opcode();
       MachProjNode *proj = new (matcher.C) MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj );
    -  bbs.map(proj->_idx,this);
    +  cfg->map_node_to_block(proj, this);
       _nodes.insert(node_cnt++, proj);
     
       // Select the right register save policy.
    @@ -708,7 +711,7 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, GrowableArray &
           uint local = 0;
           for( uint j=0; jin(j);
    -        if( m && cfg->_bbs[m->_idx] == this && !m->is_top() )
    +        if( m && cfg->get_block_for_node(m) == this && !m->is_top() )
               local++;              // One more block-local input
           }
           ready_cnt.at_put(n->_idx, local); // Count em up
    @@ -720,7 +723,7 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, GrowableArray &
               for (uint prec = n->req(); prec < n->len(); prec++) {
                 Node* oop_store = n->in(prec);
                 if (oop_store != NULL) {
    -              assert(cfg->_bbs[oop_store->_idx]->_dom_depth <= this->_dom_depth, "oop_store must dominate card-mark");
    +              assert(cfg->get_block_for_node(oop_store)->_dom_depth <= this->_dom_depth, "oop_store must dominate card-mark");
                 }
               }
             }
    @@ -753,7 +756,7 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, GrowableArray &
         Node *n = _nodes[i3];       // Get pre-scheduled
         for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
           Node* m = n->fast_out(j);
    -      if( cfg->_bbs[m->_idx] ==this ) { // Local-block user
    +      if (cfg->get_block_for_node(m) == this) { // Local-block user
             int m_cnt = ready_cnt.at(m->_idx)-1;
             ready_cnt.at_put(m->_idx, m_cnt);   // Fix ready count
           }
    @@ -786,7 +789,7 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, GrowableArray &
       }
     
       // Warm up the 'next_call' heuristic bits
    -  needed_for_next_call(_nodes[0], next_call, cfg->_bbs);
    +  needed_for_next_call(_nodes[0], next_call, cfg);
     
     #ifndef PRODUCT
         if (cfg->trace_opto_pipelining()) {
    @@ -837,7 +840,7 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, GrowableArray &
     #endif
         if( n->is_MachCall() ) {
           MachCallNode *mcall = n->as_MachCall();
    -      phi_cnt = sched_call(matcher, cfg->_bbs, phi_cnt, worklist, ready_cnt, mcall, next_call);
    +      phi_cnt = sched_call(matcher, cfg, phi_cnt, worklist, ready_cnt, mcall, next_call);
           continue;
         }
     
    @@ -847,7 +850,7 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, GrowableArray &
           regs.OR(n->out_RegMask());
     
           MachProjNode *proj = new (matcher.C) MachProjNode( n, 1, RegMask::Empty, MachProjNode::fat_proj );
    -      cfg->_bbs.map(proj->_idx,this);
    +      cfg->map_node_to_block(proj, this);
           _nodes.insert(phi_cnt++, proj);
     
           add_call_kills(proj, regs, matcher._c_reg_save_policy, false);
    @@ -856,7 +859,9 @@ bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, GrowableArray &
         // Children are now all ready
         for (DUIterator_Fast i5max, i5 = n->fast_outs(i5max); i5 < i5max; i5++) {
           Node* m = n->fast_out(i5); // Get user
    -      if( cfg->_bbs[m->_idx] != this ) continue;
    +      if (cfg->get_block_for_node(m) != this) {
    +        continue;
    +      }
           if( m->is_Phi() ) continue;
           if (m->_idx >= max_idx) { // new node, skip it
             assert(m->is_MachProj() && n->is_Mach() && n->as_Mach()->has_call(), "unexpected node types");
    @@ -914,7 +919,7 @@ static void catch_cleanup_fix_all_inputs(Node *use, Node *old_def, Node *new_def
     }
     
     //------------------------------catch_cleanup_find_cloned_def------------------
    -static Node *catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *def_blk, Block_Array &bbs, int n_clone_idx) {
    +static Node *catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *def_blk, PhaseCFG* cfg, int n_clone_idx) {
       assert( use_blk != def_blk, "Inter-block cleanup only");
     
       // The use is some block below the Catch.  Find and return the clone of the def
    @@ -940,7 +945,8 @@ static Node *catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *def
         // PhiNode, the PhiNode uses from the def and IT's uses need fixup.
         Node_Array inputs = new Node_List(Thread::current()->resource_area());
         for(uint k = 1; k < use_blk->num_preds(); k++) {
    -      inputs.map(k, catch_cleanup_find_cloned_def(bbs[use_blk->pred(k)->_idx], def, def_blk, bbs, n_clone_idx));
    +      Block* block = cfg->get_block_for_node(use_blk->pred(k));
    +      inputs.map(k, catch_cleanup_find_cloned_def(block, def, def_blk, cfg, n_clone_idx));
         }
     
         // Check to see if the use_blk already has an identical phi inserted.
    @@ -962,7 +968,7 @@ static Node *catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *def
         if (fixup == NULL) {
           Node *new_phi = PhiNode::make(use_blk->head(), def);
           use_blk->_nodes.insert(1, new_phi);
    -      bbs.map(new_phi->_idx, use_blk);
    +      cfg->map_node_to_block(new_phi, use_blk);
           for (uint k = 1; k < use_blk->num_preds(); k++) {
             new_phi->set_req(k, inputs[k]);
           }
    @@ -1002,17 +1008,17 @@ static void catch_cleanup_intra_block(Node *use, Node *def, Block *blk, int beg,
     //------------------------------catch_cleanup_inter_block---------------------
     // Fix all input edges in use that reference "def".  The use is in a different
     // block than the def.
    -static void catch_cleanup_inter_block(Node *use, Block *use_blk, Node *def, Block *def_blk, Block_Array &bbs, int n_clone_idx) {
    +static void catch_cleanup_inter_block(Node *use, Block *use_blk, Node *def, Block *def_blk, PhaseCFG* cfg, int n_clone_idx) {
       if( !use_blk ) return;        // Can happen if the use is a precedence edge
     
    -  Node *new_def = catch_cleanup_find_cloned_def(use_blk, def, def_blk, bbs, n_clone_idx);
    +  Node *new_def = catch_cleanup_find_cloned_def(use_blk, def, def_blk, cfg, n_clone_idx);
       catch_cleanup_fix_all_inputs(use, def, new_def);
     }
     
     //------------------------------call_catch_cleanup-----------------------------
     // If we inserted any instructions between a Call and his CatchNode,
     // clone the instructions on all paths below the Catch.
    -void Block::call_catch_cleanup(Block_Array &bbs, Compile* C) {
    +void Block::call_catch_cleanup(PhaseCFG* cfg, Compile* C) {
     
       // End of region to clone
       uint end = end_idx();
    @@ -1037,7 +1043,7 @@ void Block::call_catch_cleanup(Block_Array &bbs, Compile* C) {
           // since clones dominate on each path.
           Node *clone = _nodes[j-1]->clone();
           sb->_nodes.insert( 1, clone );
    -      bbs.map(clone->_idx,sb);
    +      cfg->map_node_to_block(clone, sb);
         }
       }
     
    @@ -1054,18 +1060,19 @@ void Block::call_catch_cleanup(Block_Array &bbs, Compile* C) {
         uint max = out->size();
         for (uint j = 0; j < max; j++) {// For all users
           Node *use = out->pop();
    -      Block *buse = bbs[use->_idx];
    +      Block *buse = cfg->get_block_for_node(use);
           if( use->is_Phi() ) {
             for( uint k = 1; k < use->req(); k++ )
               if( use->in(k) == n ) {
    -            Node *fixup = catch_cleanup_find_cloned_def(bbs[buse->pred(k)->_idx], n, this, bbs, n_clone_idx);
    +            Block* block = cfg->get_block_for_node(buse->pred(k));
    +            Node *fixup = catch_cleanup_find_cloned_def(block, n, this, cfg, n_clone_idx);
                 use->set_req(k, fixup);
               }
           } else {
             if (this == buse) {
               catch_cleanup_intra_block(use, n, this, beg, n_clone_idx);
             } else {
    -          catch_cleanup_inter_block(use, buse, n, this, bbs, n_clone_idx);
    +          catch_cleanup_inter_block(use, buse, n, this, cfg, n_clone_idx);
             }
           }
         } // End for all users
    diff --git a/hotspot/src/share/vm/opto/live.cpp b/hotspot/src/share/vm/opto/live.cpp
    index 773dd1ea2e6..846609e8a49 100644
    --- a/hotspot/src/share/vm/opto/live.cpp
    +++ b/hotspot/src/share/vm/opto/live.cpp
    @@ -101,7 +101,7 @@ void PhaseLive::compute(uint maxlrg) {
           for( uint k=1; kin(k);
             uint nkidx = nk->_idx;
    -        if( _cfg._bbs[nkidx] != b ) {
    +        if (_cfg.get_block_for_node(nk) != b) {
               uint u = _names[nkidx];
               use->insert( u );
               DEBUG_ONLY(def_outside->insert( u );)
    @@ -121,7 +121,7 @@ void PhaseLive::compute(uint maxlrg) {
     
         // Push these live-in things to predecessors
         for( uint l=1; lnum_preds(); l++ ) {
    -      Block *p = _cfg._bbs[b->pred(l)->_idx];
    +      Block *p = _cfg.get_block_for_node(b->pred(l));
           add_liveout( p, use, first_pass );
     
           // PhiNode uses go in the live-out set of prior blocks.
    @@ -142,8 +142,10 @@ void PhaseLive::compute(uint maxlrg) {
           assert( delta->count(), "missing delta set" );
     
           // Add new-live-in to predecessors live-out sets
    -      for( uint l=1; lnum_preds(); l++ )
    -        add_liveout( _cfg._bbs[b->pred(l)->_idx], delta, first_pass );
    +      for (uint l = 1; l < b->num_preds(); l++) {
    +        Block* block = _cfg.get_block_for_node(b->pred(l));
    +        add_liveout(block, delta, first_pass);
    +      }
     
           freeset(b);
         } // End of while-worklist-not-empty
    diff --git a/hotspot/src/share/vm/opto/node.hpp b/hotspot/src/share/vm/opto/node.hpp
    index bb5e8f200d0..0690d21b122 100644
    --- a/hotspot/src/share/vm/opto/node.hpp
    +++ b/hotspot/src/share/vm/opto/node.hpp
    @@ -42,7 +42,6 @@ class AliasInfo;
     class AllocateArrayNode;
     class AllocateNode;
     class Block;
    -class Block_Array;
     class BoolNode;
     class BoxLockNode;
     class CMoveNode;
    diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp
    index f04ab721b97..24a4497c680 100644
    --- a/hotspot/src/share/vm/opto/output.cpp
    +++ b/hotspot/src/share/vm/opto/output.cpp
    @@ -68,7 +68,6 @@ void Compile::Output() {
         return;
       }
       // Make sure I can find the Start Node
    -  Block_Array& bbs = _cfg->_bbs;
       Block *entry = _cfg->_blocks[1];
       Block *broot = _cfg->_broot;
     
    @@ -77,8 +76,8 @@ void Compile::Output() {
       // Replace StartNode with prolog
       MachPrologNode *prolog = new (this) MachPrologNode();
       entry->_nodes.map( 0, prolog );
    -  bbs.map( prolog->_idx, entry );
    -  bbs.map( start->_idx, NULL ); // start is no longer in any block
    +  _cfg->map_node_to_block(prolog, entry);
    +  _cfg->unmap_node_from_block(start); // start is no longer in any block
     
       // Virtual methods need an unverified entry point
     
    @@ -117,8 +116,7 @@ void Compile::Output() {
           if( m->is_Mach() && m->as_Mach()->ideal_Opcode() != Op_Halt ) {
             MachEpilogNode *epilog = new (this) MachEpilogNode(m->as_Mach()->ideal_Opcode() == Op_Return);
             b->add_inst( epilog );
    -        bbs.map(epilog->_idx, b);
    -        //_regalloc->set_bad(epilog->_idx); // Already initialized this way.
    +        _cfg->map_node_to_block(epilog, b);
           }
         }
       }
    @@ -252,7 +250,7 @@ void Compile::Insert_zap_nodes() {
             if (insert) {
               Node *zap = call_zap_node(n->as_MachSafePoint(), i);
               b->_nodes.insert( j, zap );
    -          _cfg->_bbs.map( zap->_idx, b );
    +          _cfg->map_node_to_block(zap, b);
               ++j;
             }
           }
    @@ -1234,7 +1232,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) {
     #ifdef ASSERT
         if (!b->is_connector()) {
           stringStream st;
    -      b->dump_head(&_cfg->_bbs, &st);
    +      b->dump_head(_cfg, &st);
           MacroAssembler(cb).block_comment(st.as_string());
         }
         jmp_target[i] = 0;
    @@ -1310,7 +1308,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) {
               MachNode *nop = new (this) MachNopNode(nops_cnt);
               b->_nodes.insert(j++, nop);
               last_inst++;
    -          _cfg->_bbs.map( nop->_idx, b );
    +          _cfg->map_node_to_block(nop, b);
               nop->emit(*cb, _regalloc);
               cb->flush_bundle(true);
               current_offset = cb->insts_size();
    @@ -1395,7 +1393,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) {
                   if (needs_padding && replacement->avoid_back_to_back()) {
                     MachNode *nop = new (this) MachNopNode();
                     b->_nodes.insert(j++, nop);
    -                _cfg->_bbs.map(nop->_idx, b);
    +                _cfg->map_node_to_block(nop, b);
                     last_inst++;
                     nop->emit(*cb, _regalloc);
                     cb->flush_bundle(true);
    @@ -1549,7 +1547,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) {
           if( padding > 0 ) {
             MachNode *nop = new (this) MachNopNode(padding / nop_size);
             b->_nodes.insert( b->_nodes.size(), nop );
    -        _cfg->_bbs.map( nop->_idx, b );
    +        _cfg->map_node_to_block(nop, b);
             nop->emit(*cb, _regalloc);
             current_offset = cb->insts_size();
           }
    @@ -1737,7 +1735,6 @@ uint Scheduling::_total_instructions_per_bundle[Pipeline::_max_instrs_per_cycle+
     Scheduling::Scheduling(Arena *arena, Compile &compile)
       : _arena(arena),
         _cfg(compile.cfg()),
    -    _bbs(compile.cfg()->_bbs),
         _regalloc(compile.regalloc()),
         _reg_node(arena),
         _bundle_instr_count(0),
    @@ -2085,8 +2082,9 @@ void Scheduling::DecrementUseCounts(Node *n, const Block *bb) {
         if( def->is_Proj() )        // If this is a machine projection, then
           def = def->in(0);         // propagate usage thru to the base instruction
     
    -    if( _bbs[def->_idx] != bb ) // Ignore if not block-local
    +    if(_cfg->get_block_for_node(def) != bb) { // Ignore if not block-local
           continue;
    +    }
     
         // Compute the latency
         uint l = _bundle_cycle_number + n->latency(i);
    @@ -2358,9 +2356,10 @@ void Scheduling::ComputeUseCount(const Block *bb) {
           Node *inp = n->in(k);
           if (!inp) continue;
           assert(inp != n, "no cycles allowed" );
    -      if( _bbs[inp->_idx] == bb ) { // Block-local use?
    -        if( inp->is_Proj() )    // Skip through Proj's
    +      if (_cfg->get_block_for_node(inp) == bb) { // Block-local use?
    +        if (inp->is_Proj()) { // Skip through Proj's
               inp = inp->in(0);
    +        }
             ++_uses[inp->_idx];     // Count 1 block-local use
           }
         }
    @@ -2643,7 +2642,7 @@ void Scheduling::anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is
         return;
     
       Node *pinch = _reg_node[def_reg]; // Get pinch point
    -  if( !pinch || _bbs[pinch->_idx] != b || // No pinch-point yet?
    +  if ((pinch == NULL) || _cfg->get_block_for_node(pinch) != b || // No pinch-point yet?
           is_def ) {    // Check for a true def (not a kill)
         _reg_node.map(def_reg,def); // Record def/kill as the optimistic pinch-point
         return;
    @@ -2669,7 +2668,7 @@ void Scheduling::anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is
           _cfg->C->record_method_not_compilable("too many D-U pinch points");
           return;
         }
    -    _bbs.map(pinch->_idx,b);      // Pretend it's valid in this block (lazy init)
    +    _cfg->map_node_to_block(pinch, b);      // Pretend it's valid in this block (lazy init)
         _reg_node.map(def_reg,pinch); // Record pinch-point
         //_regalloc->set_bad(pinch->_idx); // Already initialized this way.
         if( later_def->outcnt() == 0 || later_def->ideal_reg() == MachProjNode::fat_proj ) { // Distinguish def from kill
    @@ -2713,9 +2712,9 @@ void Scheduling::anti_do_use( Block *b, Node *use, OptoReg::Name use_reg ) {
         return;
       Node *pinch = _reg_node[use_reg]; // Get pinch point
       // Check for no later def_reg/kill in block
    -  if( pinch && _bbs[pinch->_idx] == b &&
    +  if ((pinch != NULL) && _cfg->get_block_for_node(pinch) == b &&
           // Use has to be block-local as well
    -      _bbs[use->_idx] == b ) {
    +      _cfg->get_block_for_node(use) == b) {
         if( pinch->Opcode() == Op_Node && // Real pinch-point (not optimistic?)
             pinch->req() == 1 ) {   // pinch not yet in block?
           pinch->del_req(0);        // yank pointer to later-def, also set flag
    @@ -2895,7 +2894,7 @@ void Scheduling::garbage_collect_pinch_nodes() {
         int trace_cnt = 0;
         for (uint k = 0; k < _reg_node.Size(); k++) {
           Node* pinch = _reg_node[k];
    -      if (pinch != NULL && pinch->Opcode() == Op_Node &&
    +      if ((pinch != NULL) && pinch->Opcode() == Op_Node &&
               // no predecence input edges
               (pinch->req() == pinch->len() || pinch->in(pinch->req()) == NULL) ) {
             cleanup_pinch(pinch);
    diff --git a/hotspot/src/share/vm/opto/output.hpp b/hotspot/src/share/vm/opto/output.hpp
    index 50b6e76035e..5fb68c6828a 100644
    --- a/hotspot/src/share/vm/opto/output.hpp
    +++ b/hotspot/src/share/vm/opto/output.hpp
    @@ -96,9 +96,6 @@ private:
       // List of nodes currently available for choosing for scheduling
       Node_List _available;
     
    -  // Mapping from node (index) to basic block
    -  Block_Array& _bbs;
    -
       // For each instruction beginning a bundle, the number of following
       // nodes to be bundled with it.
       Bundle *_node_bundling_base;
    diff --git a/hotspot/src/share/vm/opto/postaloc.cpp b/hotspot/src/share/vm/opto/postaloc.cpp
    index c1b3fdbd231..76c3def2d40 100644
    --- a/hotspot/src/share/vm/opto/postaloc.cpp
    +++ b/hotspot/src/share/vm/opto/postaloc.cpp
    @@ -78,11 +78,13 @@ bool PhaseChaitin::may_be_copy_of_callee( Node *def ) const {
     // Helper function for yank_if_dead
     int PhaseChaitin::yank( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) {
       int blk_adjust=0;
    -  Block *oldb = _cfg._bbs[old->_idx];
    +  Block *oldb = _cfg.get_block_for_node(old);
       oldb->find_remove(old);
       // Count 1 if deleting an instruction from the current block
    -  if( oldb == current_block ) blk_adjust++;
    -  _cfg._bbs.map(old->_idx,NULL);
    +  if (oldb == current_block) {
    +    blk_adjust++;
    +  }
    +  _cfg.unmap_node_from_block(old);
       OptoReg::Name old_reg = lrgs(_lrg_map.live_range_id(old)).reg();
       if( regnd && (*regnd)[old_reg]==old ) { // Instruction is currently available?
         value->map(old_reg,NULL);  // Yank from value/regnd maps
    @@ -433,7 +435,7 @@ void PhaseChaitin::post_allocate_copy_removal() {
         bool missing_some_inputs = false;
         Block *freed = NULL;
         for( j = 1; j < b->num_preds(); j++ ) {
    -      Block *pb = _cfg._bbs[b->pred(j)->_idx];
    +      Block *pb = _cfg.get_block_for_node(b->pred(j));
           // Remove copies along phi edges
           for( uint k=1; k_nodes[k], j, b, *blk2value[pb->_pre_order], *blk2regnd[pb->_pre_order], false );
    @@ -478,7 +480,7 @@ void PhaseChaitin::post_allocate_copy_removal() {
         } else {
           if( !freed ) {            // Didn't get a freebie prior block
             // Must clone some data
    -        freed = _cfg._bbs[b->pred(1)->_idx];
    +        freed = _cfg.get_block_for_node(b->pred(1));
             Node_List &f_value = *blk2value[freed->_pre_order];
             Node_List &f_regnd = *blk2regnd[freed->_pre_order];
             for( uint k = 0; k < (uint)_max_reg; k++ ) {
    @@ -488,7 +490,7 @@ void PhaseChaitin::post_allocate_copy_removal() {
           }
           // Merge all inputs together, setting to NULL any conflicts.
           for( j = 1; j < b->num_preds(); j++ ) {
    -        Block *pb = _cfg._bbs[b->pred(j)->_idx];
    +        Block *pb = _cfg.get_block_for_node(b->pred(j));
             if( pb == freed ) continue; // Did self already via freelist
             Node_List &p_regnd = *blk2regnd[pb->_pre_order];
             for( uint k = 0; k < (uint)_max_reg; k++ ) {
    @@ -515,8 +517,9 @@ void PhaseChaitin::post_allocate_copy_removal() {
               u = u ? NodeSentinel : x; // Capture unique input, or NodeSentinel for 2nd input
           }
           if( u != NodeSentinel ) {    // Junk Phi.  Remove
    -        b->_nodes.remove(j--); phi_dex--;
    -        _cfg._bbs.map(phi->_idx,NULL);
    +        b->_nodes.remove(j--);
    +        phi_dex--;
    +        _cfg.unmap_node_from_block(phi);
             phi->replace_by(u);
             phi->disconnect_inputs(NULL, C);
             continue;
    diff --git a/hotspot/src/share/vm/opto/reg_split.cpp b/hotspot/src/share/vm/opto/reg_split.cpp
    index 30ac26ba989..6e4323b406e 100644
    --- a/hotspot/src/share/vm/opto/reg_split.cpp
    +++ b/hotspot/src/share/vm/opto/reg_split.cpp
    @@ -132,7 +132,7 @@ void PhaseChaitin::insert_proj( Block *b, uint i, Node *spill, uint maxlrg ) {
       }
     
       b->_nodes.insert(i,spill);    // Insert node in block
    -  _cfg._bbs.map(spill->_idx,b); // Update node->block mapping to reflect
    +  _cfg.map_node_to_block(spill,  b); // Update node->block mapping to reflect
       // Adjust the point where we go hi-pressure
       if( i <= b->_ihrp_index ) b->_ihrp_index++;
       if( i <= b->_fhrp_index ) b->_fhrp_index++;
    @@ -219,7 +219,7 @@ uint PhaseChaitin::split_USE( Node *def, Block *b, Node *use, uint useidx, uint
             use->set_req(useidx, def);
           } else {
             // Block and index where the use occurs.
    -        Block *b = _cfg._bbs[use->_idx];
    +        Block *b = _cfg.get_block_for_node(use);
             // Put the clone just prior to use
             int bindex = b->find_node(use);
             // DEF is UP, so must copy it DOWN and hook in USE
    @@ -270,7 +270,7 @@ uint PhaseChaitin::split_USE( Node *def, Block *b, Node *use, uint useidx, uint
       int bindex;
       // Phi input spill-copys belong at the end of the prior block
       if( use->is_Phi() ) {
    -    b = _cfg._bbs[b->pred(useidx)->_idx];
    +    b = _cfg.get_block_for_node(b->pred(useidx));
         bindex = b->end_idx();
       } else {
         // Put the clone just prior to use
    @@ -335,7 +335,7 @@ Node *PhaseChaitin::split_Rematerialize( Node *def, Block *b, uint insidx, uint
             continue;
           }
     
    -      Block *b_def = _cfg._bbs[def->_idx];
    +      Block *b_def = _cfg.get_block_for_node(def);
           int idx_def = b_def->find_node(def);
           Node *in_spill = get_spillcopy_wide( in, def, i );
           if( !in_spill ) return 0; // Bailed out
    @@ -589,7 +589,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
             UPblock[slidx] = true;
             // Record following instruction in case 'n' rematerializes and
             // kills flags
    -        Block *pred1 = _cfg._bbs[b->pred(1)->_idx];
    +        Block *pred1 = _cfg.get_block_for_node(b->pred(1));
             continue;
           }
     
    @@ -601,7 +601,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
           // Grab predecessor block header
           n1 = b->pred(1);
           // Grab the appropriate reaching def info for inpidx
    -      pred = _cfg._bbs[n1->_idx];
    +      pred = _cfg.get_block_for_node(n1);
           pidx = pred->_pre_order;
           Node **Ltmp = Reaches[pidx];
           bool  *Utmp = UP[pidx];
    @@ -616,7 +616,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
             // Grab predecessor block headers
             n2 = b->pred(inpidx);
             // Grab the appropriate reaching def info for inpidx
    -        pred = _cfg._bbs[n2->_idx];
    +        pred = _cfg.get_block_for_node(n2);
             pidx = pred->_pre_order;
             Ltmp = Reaches[pidx];
             Utmp = UP[pidx];
    @@ -701,7 +701,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
             // Grab predecessor block header
             n1 = b->pred(1);
             // Grab the appropriate reaching def info for k
    -        pred = _cfg._bbs[n1->_idx];
    +        pred = _cfg.get_block_for_node(n1);
             pidx = pred->_pre_order;
             Node **Ltmp = Reaches[pidx];
             bool  *Utmp = UP[pidx];
    @@ -919,7 +919,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
                     return 0;
                   }
                   _lrg_map.extend(def->_idx, 0);
    -              _cfg._bbs.map(def->_idx,b);
    +              _cfg.map_node_to_block(def, b);
                   n->set_req(inpidx, def);
                   continue;
                 }
    @@ -1291,7 +1291,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
       for( insidx = 0; insidx < phis->size(); insidx++ ) {
         Node *phi = phis->at(insidx);
         assert(phi->is_Phi(),"This list must only contain Phi Nodes");
    -    Block *b = _cfg._bbs[phi->_idx];
    +    Block *b = _cfg.get_block_for_node(phi);
         // Grab the live range number
         uint lidx = _lrg_map.find_id(phi);
         uint slidx = lrg2reach[lidx];
    @@ -1315,7 +1315,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) {
         // DEF has the wrong UP/DOWN value.
         for( uint i = 1; i < b->num_preds(); i++ ) {
           // Get predecessor block pre-order number
    -      Block *pred = _cfg._bbs[b->pred(i)->_idx];
    +      Block *pred = _cfg.get_block_for_node(b->pred(i));
           pidx = pred->_pre_order;
           // Grab reaching def
           Node *def = Reaches[pidx][slidx];
    diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp
    index e7de9601c96..163433b524f 100644
    --- a/hotspot/src/share/vm/runtime/vmStructs.cpp
    +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp
    @@ -1098,7 +1098,7 @@ typedef BinaryTreeDictionary MetablockTreeDictionary;
                                                                                                                                          \
       c2_nonstatic_field(PhaseCFG,           _num_blocks,              uint)                                                             \
       c2_nonstatic_field(PhaseCFG,           _blocks,                  Block_List)                                                       \
    -  c2_nonstatic_field(PhaseCFG,           _bbs,                     Block_Array)                                                      \
    +  c2_nonstatic_field(PhaseCFG,           _node_to_block_mapping,   Block_Array)                                                      \
       c2_nonstatic_field(PhaseCFG,           _broot,                   Block*)                                                           \
                                                                                                                                          \
       c2_nonstatic_field(PhaseRegAlloc,      _node_regs,               OptoRegPair*)                                                     \
    
    From 5fe59d132cb345c65fdc4bb87c6cab1d60e65205 Mon Sep 17 00:00:00 2001
    From: Sergey Bylokhov 
    Date: Wed, 7 Aug 2013 19:57:18 +0400
    Subject: [PATCH 076/118] 7124339: [macosx] setIconImage is not endlessly
     tolerant to the broken image-arguments
    
    Reviewed-by: alexsch, leonidr
    ---
     .../sun/lwawt/macosx/CPlatformWindow.java     | 19 ++++++++++---------
     1 file changed, 10 insertions(+), 9 deletions(-)
    
    diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
    index 8aed7e5feaa..d38946d4376 100644
    --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
    +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
    @@ -830,18 +830,19 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
         //                          UTILITY METHODS
         // ----------------------------------------------------------------------
     
    -    /*
    -     * Find image to install into Title or into Application icon.
    -     * First try icons installed for toplevel. If there is no icon
    -     * use default Duke image.
    -     * This method shouldn't return null.
    +    /**
    +     * Find image to install into Title or into Application icon. First try
    +     * icons installed for toplevel. Null is returned, if there is no icon and
    +     * default Duke image should be used.
          */
         private CImage getImageForTarget() {
    -        List icons = target.getIconImages();
    -        if (icons == null || icons.size() == 0) {
    -            return null;
    +        CImage icon = null;
    +        try {
    +            icon = CImage.getCreator().createFromImages(target.getIconImages());
    +        } catch (Exception ignored) {
    +            // Perhaps the icon passed into Java is broken. Skipping this icon.
             }
    -        return CImage.getCreator().createFromImages(icons);
    +        return icon;
         }
     
         /*
    
    From fc44cdf0ecd816b025deea2d56201bd4dcb81300 Mon Sep 17 00:00:00 2001
    From: Niclas Adlertz 
    Date: Wed, 7 Aug 2013 18:04:42 +0200
    Subject: [PATCH 077/118] 8022475: Remove unneeded ad-files
    
    Remove .ad files that are not used
    
    Reviewed-by: kvn
    ---
     hotspot/make/bsd/makefiles/adlc.make          |  6 +-
     hotspot/make/linux/makefiles/adlc.make        |  6 +-
     hotspot/make/solaris/makefiles/adlc.make      |  6 +-
     hotspot/make/windows/makefiles/adlc.make      |  6 +-
     hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad   | 26 --------
     hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad   | 65 -------------------
     .../src/os_cpu/linux_x86/vm/linux_x86_32.ad   | 26 --------
     .../src/os_cpu/linux_x86/vm/linux_x86_64.ad   | 65 -------------------
     .../os_cpu/solaris_sparc/vm/solaris_sparc.ad  | 27 --------
     .../os_cpu/solaris_x86/vm/solaris_x86_32.ad   | 26 --------
     .../os_cpu/solaris_x86/vm/solaris_x86_64.ad   | 63 ------------------
     .../os_cpu/windows_x86/vm/windows_x86_32.ad   | 26 --------
     .../os_cpu/windows_x86/vm/windows_x86_64.ad   | 63 ------------------
     13 files changed, 8 insertions(+), 403 deletions(-)
     delete mode 100644 hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad
     delete mode 100644 hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad
     delete mode 100644 hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.ad
     delete mode 100644 hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad
     delete mode 100644 hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.ad
     delete mode 100644 hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.ad
     delete mode 100644 hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad
     delete mode 100644 hotspot/src/os_cpu/windows_x86/vm/windows_x86_32.ad
     delete mode 100644 hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad
    
    diff --git a/hotspot/make/bsd/makefiles/adlc.make b/hotspot/make/bsd/makefiles/adlc.make
    index 826d256b9eb..cf5c05e2ac7 100644
    --- a/hotspot/make/bsd/makefiles/adlc.make
    +++ b/hotspot/make/bsd/makefiles/adlc.make
    @@ -41,13 +41,11 @@ SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad
     
     ifeq ("${Platform_arch_model}", "${Platform_arch}")
       SOURCES.AD = \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
    +  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) 
     else
       SOURCES.AD = \
       $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
    +  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) 
     endif
     
     EXEC	= $(OUTDIR)/adlc
    diff --git a/hotspot/make/linux/makefiles/adlc.make b/hotspot/make/linux/makefiles/adlc.make
    index 25ace2f5f76..7b808d9b2ae 100644
    --- a/hotspot/make/linux/makefiles/adlc.make
    +++ b/hotspot/make/linux/makefiles/adlc.make
    @@ -41,13 +41,11 @@ SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad
     
     ifeq ("${Platform_arch_model}", "${Platform_arch}")
       SOURCES.AD = \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
    +  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) 
     else
       SOURCES.AD = \
       $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
    +  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) 
     endif
     
     EXEC	= $(OUTDIR)/adlc
    diff --git a/hotspot/make/solaris/makefiles/adlc.make b/hotspot/make/solaris/makefiles/adlc.make
    index 750bd8319bf..642a7ca6136 100644
    --- a/hotspot/make/solaris/makefiles/adlc.make
    +++ b/hotspot/make/solaris/makefiles/adlc.make
    @@ -42,13 +42,11 @@ SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad
     
     ifeq ("${Platform_arch_model}", "${Platform_arch}")
       SOURCES.AD = \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
    +  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) 
     else
       SOURCES.AD = \
       $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) \
    -  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
    +  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) 
     endif
     
     EXEC	= $(OUTDIR)/adlc
    diff --git a/hotspot/make/windows/makefiles/adlc.make b/hotspot/make/windows/makefiles/adlc.make
    index f320d4e932d..7bcaef718fd 100644
    --- a/hotspot/make/windows/makefiles/adlc.make
    +++ b/hotspot/make/windows/makefiles/adlc.make
    @@ -55,13 +55,11 @@ CXX_INCLUDE_DIRS=\
     
     !if "$(Platform_arch_model)" == "$(Platform_arch)"
     SOURCES_AD=\
    -  $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad \
    -  $(WorkSpace)/src/os_cpu/windows_$(Platform_arch)/vm/windows_$(Platform_arch_model).ad
    +  $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad 
     !else
     SOURCES_AD=\
       $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad \
    -  $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch).ad \
    -  $(WorkSpace)/src/os_cpu/windows_$(Platform_arch)/vm/windows_$(Platform_arch_model).ad
    +  $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch).ad 
     !endif
     
     # NOTE! If you add any files here, you must also update GENERATED_NAMES_IN_DIR
    diff --git a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad
    deleted file mode 100644
    index f58244ea48f..00000000000
    --- a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad
    +++ /dev/null
    @@ -1,26 +0,0 @@
    -//
    -// Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -//
    -
    -// X86 Bsd Architecture Description File
    -
    diff --git a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad
    deleted file mode 100644
    index 254328e0971..00000000000
    --- a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad
    +++ /dev/null
    @@ -1,65 +0,0 @@
    -//
    -// Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -//
    -
    -// AMD64 Bsd Architecture Description File
    -
    -//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------
    -// This block specifies the encoding classes used by the compiler to
    -// output byte streams.  Encoding classes generate functions which are
    -// called by Machine Instruction Nodes in order to generate the bit
    -// encoding of the instruction.  Operands specify their base encoding
    -// interface with the interface keyword.  There are currently
    -// supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
    -// COND_INTER.  REG_INTER causes an operand to generate a function
    -// which returns its register number when queried.  CONST_INTER causes
    -// an operand to generate a function which returns the value of the
    -// constant when queried.  MEMORY_INTER causes an operand to generate
    -// four functions which return the Base Register, the Index Register,
    -// the Scale Value, and the Offset Value of the operand when queried.
    -// COND_INTER causes an operand to generate six functions which return
    -// the encoding code (ie - encoding bits for the instruction)
    -// associated with each basic boolean condition for a conditional
    -// instruction.  Instructions specify two basic values for encoding.
    -// They use the ins_encode keyword to specify their encoding class
    -// (which must be one of the class names specified in the encoding
    -// block), and they use the opcode keyword to specify, in order, their
    -// primary, secondary, and tertiary opcode.  Only the opcode sections
    -// which a particular instruction needs for encoding need to be
    -// specified.
    -encode %{
    -  // Build emit functions for each basic byte or larger field in the intel
    -  // encoding scheme (opcode, rm, sib, immediate), and call them from C++
    -  // code in the enc_class source block.  Emit functions will live in the
    -  // main source block for now.  In future, we can generalize this by
    -  // adding a syntax that specifies the sizes of fields in an order,
    -  // so that the adlc can build the emit functions automagically
    -
    -%}
    -
    -
    -// Platform dependent source
    -
    -source %{
    -
    -%}
    diff --git a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.ad b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.ad
    deleted file mode 100644
    index 5e234deaa4f..00000000000
    --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.ad
    +++ /dev/null
    @@ -1,26 +0,0 @@
    -//
    -// Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -//
    -
    -// X86 Linux Architecture Description File
    -
    diff --git a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad
    deleted file mode 100644
    index 3b3ac007cd1..00000000000
    --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad
    +++ /dev/null
    @@ -1,65 +0,0 @@
    -//
    -// Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -//
    -
    -// AMD64 Linux Architecture Description File
    -
    -//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------
    -// This block specifies the encoding classes used by the compiler to
    -// output byte streams.  Encoding classes generate functions which are
    -// called by Machine Instruction Nodes in order to generate the bit
    -// encoding of the instruction.  Operands specify their base encoding
    -// interface with the interface keyword.  There are currently
    -// supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
    -// COND_INTER.  REG_INTER causes an operand to generate a function
    -// which returns its register number when queried.  CONST_INTER causes
    -// an operand to generate a function which returns the value of the
    -// constant when queried.  MEMORY_INTER causes an operand to generate
    -// four functions which return the Base Register, the Index Register,
    -// the Scale Value, and the Offset Value of the operand when queried.
    -// COND_INTER causes an operand to generate six functions which return
    -// the encoding code (ie - encoding bits for the instruction)
    -// associated with each basic boolean condition for a conditional
    -// instruction.  Instructions specify two basic values for encoding.
    -// They use the ins_encode keyword to specify their encoding class
    -// (which must be one of the class names specified in the encoding
    -// block), and they use the opcode keyword to specify, in order, their
    -// primary, secondary, and tertiary opcode.  Only the opcode sections
    -// which a particular instruction needs for encoding need to be
    -// specified.
    -encode %{
    -  // Build emit functions for each basic byte or larger field in the intel
    -  // encoding scheme (opcode, rm, sib, immediate), and call them from C++
    -  // code in the enc_class source block.  Emit functions will live in the
    -  // main source block for now.  In future, we can generalize this by
    -  // adding a syntax that specifies the sizes of fields in an order,
    -  // so that the adlc can build the emit functions automagically
    -
    -%}
    -
    -
    -// Platform dependent source
    -
    -source %{
    -
    -%}
    diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.ad b/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.ad
    deleted file mode 100644
    index 7f27d4591b3..00000000000
    --- a/hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.ad
    +++ /dev/null
    @@ -1,27 +0,0 @@
    -//
    -// Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -
    -//
    -//
    -
    -// SPARC Solaris Architecture Description File
    diff --git a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.ad b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.ad
    deleted file mode 100644
    index 9b95823b844..00000000000
    --- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.ad
    +++ /dev/null
    @@ -1,26 +0,0 @@
    -//
    -// Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -//
    -
    -// X86 Solaris Architecture Description File
    -
    diff --git a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad
    deleted file mode 100644
    index f3334952f62..00000000000
    --- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad
    +++ /dev/null
    @@ -1,63 +0,0 @@
    -//
    -// Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -//
    -
    -// AMD64 Solaris Architecture Description File
    -
    -//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------
    -// This block specifies the encoding classes used by the compiler to
    -// output byte streams.  Encoding classes generate functions which are
    -// called by Machine Instruction Nodes in order to generate the bit
    -// encoding of the instruction.  Operands specify their base encoding
    -// interface with the interface keyword.  There are currently
    -// supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
    -// COND_INTER.  REG_INTER causes an operand to generate a function
    -// which returns its register number when queried.  CONST_INTER causes
    -// an operand to generate a function which returns the value of the
    -// constant when queried.  MEMORY_INTER causes an operand to generate
    -// four functions which return the Base Register, the Index Register,
    -// the Scale Value, and the Offset Value of the operand when queried.
    -// COND_INTER causes an operand to generate six functions which return
    -// the encoding code (ie - encoding bits for the instruction)
    -// associated with each basic boolean condition for a conditional
    -// instruction.  Instructions specify two basic values for encoding.
    -// They use the ins_encode keyword to specify their encoding class
    -// (which must be one of the class names specified in the encoding
    -// block), and they use the opcode keyword to specify, in order, their
    -// primary, secondary, and tertiary opcode.  Only the opcode sections
    -// which a particular instruction needs for encoding need to be
    -// specified.
    -encode %{
    -  // Build emit functions for each basic byte or larger field in the intel
    -  // encoding scheme (opcode, rm, sib, immediate), and call them from C++
    -  // code in the enc_class source block.  Emit functions will live in the
    -  // main source block for now.  In future, we can generalize this by
    -  // adding a syntax that specifies the sizes of fields in an order,
    -  // so that the adlc can build the emit functions automagically
    -%}
    -
    -
    -// Platform dependent source
    -
    -source %{
    -%}
    diff --git a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_32.ad b/hotspot/src/os_cpu/windows_x86/vm/windows_x86_32.ad
    deleted file mode 100644
    index 27fedf269c5..00000000000
    --- a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_32.ad
    +++ /dev/null
    @@ -1,26 +0,0 @@
    -//
    -// Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -//
    -
    -// X86 Win32 Architecture Description File
    -
    diff --git a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad b/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad
    deleted file mode 100644
    index 54e183a0bc5..00000000000
    --- a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad
    +++ /dev/null
    @@ -1,63 +0,0 @@
    -//
    -// Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    -//
    -// This code is free software; you can redistribute it and/or modify it
    -// 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    -// or visit www.oracle.com if you need additional information or have any
    -// questions.
    -//
    -//
    -
    -// AMD64 Win32 Architecture Description File
    -
    -//----------OS-DEPENDENT ENCODING BLOCK-----------------------------------------------------
    -// This block specifies the encoding classes used by the compiler to output
    -// byte streams.  Encoding classes generate functions which are called by
    -// Machine Instruction Nodes in order to generate the bit encoding of the
    -// instruction.  Operands specify their base encoding interface with the
    -// interface keyword.  There are currently supported four interfaces,
    -// REG_INTER, CONST_INTER, MEMORY_INTER, & COND_INTER.  REG_INTER causes an
    -// operand to generate a function which returns its register number when
    -// queried.   CONST_INTER causes an operand to generate a function which
    -// returns the value of the constant when queried.  MEMORY_INTER causes an
    -// operand to generate four functions which return the Base Register, the
    -// Index Register, the Scale Value, and the Offset Value of the operand when
    -// queried.  COND_INTER causes an operand to generate six functions which
    -// return the encoding code (ie - encoding bits for the instruction)
    -// associated with each basic boolean condition for a conditional instruction.
    -// Instructions specify two basic values for encoding.  They use the
    -// ins_encode keyword to specify their encoding class (which must be one of
    -// the class names specified in the encoding block), and they use the
    -// opcode keyword to specify, in order, their primary, secondary, and
    -// tertiary opcode.  Only the opcode sections which a particular instruction
    -// needs for encoding need to be specified.
    -encode %{
    -  // Build emit functions for each basic byte or larger field in the intel
    -  // encoding scheme (opcode, rm, sib, immediate), and call them from C++
    -  // code in the enc_class source block.  Emit functions will live in the
    -  // main source block for now.  In future, we can generalize this by
    -  // adding a syntax that specifies the sizes of fields in an order,
    -  // so that the adlc can build the emit functions automagically
    -
    -%}
    -
    -
    -// Platform dependent source
    -
    -source %{
    -
    -%}
    
    From d98a8a162fb1b643053848b33a028216d6226432 Mon Sep 17 00:00:00 2001
    From: Artem Ananiev 
    Date: Wed, 7 Aug 2013 21:31:42 +0400
    Subject: [PATCH 078/118] 6551589: ContainerListener Documentation may be
     incorrect
    
    Reviewed-by: serb
    ---
     jdk/src/share/classes/java/awt/event/ContainerListener.java | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/jdk/src/share/classes/java/awt/event/ContainerListener.java b/jdk/src/share/classes/java/awt/event/ContainerListener.java
    index d5c444ff184..6fb8321589b 100644
    --- a/jdk/src/share/classes/java/awt/event/ContainerListener.java
    +++ b/jdk/src/share/classes/java/awt/event/ContainerListener.java
    @@ -42,7 +42,7 @@ import java.util.EventListener;
      * Container events are provided for notification purposes ONLY;
      * The AWT will automatically handle add and remove operations
      * internally so the program works properly regardless of
    - * whether the program registers a ComponentListener or not.
    + * whether the program registers a {@code ContainerListener} or not.
      *
      * @see ContainerAdapter
      * @see ContainerEvent
    
    From f4de445e6a56131bb9e77ad9d0be4fc87835a9c2 Mon Sep 17 00:00:00 2001
    From: Dan Xu 
    Date: Wed, 7 Aug 2013 12:13:34 -0700
    Subject: [PATCH 079/118] 8022554: Fix Warnings in sun.invoke.anon Package
    
    Reviewed-by: darcy, mduigou, lancea
    ---
     jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java
    index 259d4b2336e..b4fde055034 100644
    --- a/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java
    +++ b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java
    @@ -418,7 +418,7 @@ public class ConstantPoolPatch {
     
         private static final Map, Byte> CONSTANT_VALUE_CLASS_TAG
             = new IdentityHashMap, Byte>();
    -    private static final Class[] CONSTANT_VALUE_CLASS = new Class[16];
    +    private static final Class[] CONSTANT_VALUE_CLASS = new Class[16];
         static {
             Object[][] values = {
                 {Integer.class, CONSTANT_Integer},
    
    From 69a3c42db7e3e796667c737db0f2972abc74f6c4 Mon Sep 17 00:00:00 2001
    From: Bhavesh Patel 
    Date: Wed, 7 Aug 2013 15:00:24 -0700
    Subject: [PATCH 080/118] 7198274: RFE : Javadoc Accessibility : Use CSS styles
     rather than  or  tags
    
    Reviewed-by: jjg
    ---
     .../html/AbstractExecutableMemberWriter.java  |  2 +-
     ...nnotationTypeRequiredMemberWriterImpl.java |  2 +-
     .../html/AnnotationTypeWriterImpl.java        |  2 +-
     .../doclets/formats/html/ClassWriterImpl.java |  2 +-
     .../formats/html/EnumConstantWriterImpl.java  |  2 +-
     .../doclets/formats/html/FieldWriterImpl.java |  4 +-
     .../formats/html/HtmlDocletWriter.java        |  4 +-
     .../formats/html/MethodWriterImpl.java        |  6 +-
     .../formats/html/NestedClassWriterImpl.java   |  2 +-
     .../formats/html/PackageFrameWriter.java      |  2 +-
     .../html/ProfilePackageFrameWriter.java       |  2 +-
     .../formats/html/PropertyWriterImpl.java      | 15 +++--
     .../formats/html/SubWriterHolderWriter.java   |  4 +-
     .../formats/html/TagletWriterImpl.java        |  2 +-
     .../formats/html/markup/HtmlStyle.java        |  3 +-
     .../doclets/formats/html/markup/HtmlTree.java | 22 -------
     .../internal/toolkit/resources/stylesheet.css |  3 +
     .../TestClassCrossReferences.java             |  4 +-
     .../TestExternalOverridenMethod.java          |  6 +-
     .../TestHtmlDefinitionListTag.java            | 24 +++----
     .../javadoc/testInterface/TestInterface.java  |  6 +-
     .../sun/javadoc/testJavaFX/TestJavaFX.java    |  4 +-
     .../TestMemberInheritence.java                |  4 +-
     .../testMemberSummary/TestMemberSummary.java  |  6 +-
     .../TestNewLanguageFeatures.java              | 62 +++++++++----------
     .../TestOverridenMethodDocCopy.java           |  6 +-
     .../TestOverridenPrivateMethods.java          | 14 ++---
     ...verridenPrivateMethodsWithPackageFlag.java | 14 ++---
     ...verridenPrivateMethodsWithPrivateFlag.java | 14 ++---
     .../TestPackageDeprecation.java               |  5 +-
     .../TestPrivateClasses.java                   | 18 +++---
     .../TestSerializedFormDeprecationInfo.java    | 16 ++---
     32 files changed, 132 insertions(+), 150 deletions(-)
    
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
    index 0468a8e9134..9c20777e137 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
    @@ -101,7 +101,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
                 Content tdSummary) {
             ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
             String name = emd.name();
    -        Content strong = HtmlTree.STRONG(
    +        Content strong = HtmlTree.SPAN(HtmlStyle.strong,
                     writer.getDocLink(context, cd, (MemberDoc) emd,
                     name, false));
             Content code = HtmlTree.CODE(strong);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
    index 6583b891809..a2fa33b68a5 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
    @@ -225,7 +225,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
          */
         protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
                 Content tdSummary) {
    -        Content strong = HtmlTree.STRONG(
    +        Content strong = HtmlTree.SPAN(HtmlStyle.strong,
                     writer.getDocLink(context, (MemberDoc) member, member.name(), false));
             Content code = HtmlTree.CODE(strong);
             tdSummary.addContent(code);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
    index df4b5ea1ef8..88e1441b7ed 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
    @@ -262,7 +262,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
             annotationInfoTree.addContent(hr);
             Tag[] deprs = annotationType.tags("deprecated");
             if (Util.isDeprecated(annotationType)) {
    -            Content strong = HtmlTree.STRONG(deprecatedPhrase);
    +            Content strong = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
                 Content div = HtmlTree.DIV(HtmlStyle.block, strong);
                 if (deprs.length > 0) {
                     Tag[] commentTags = deprs[0].inlineTags();
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
    index 47e9346a072..b98739c9390 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
    @@ -547,7 +547,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
             classInfoTree.addContent(hr);
             Tag[] deprs = classDoc.tags("deprecated");
             if (Util.isDeprecated(classDoc)) {
    -            Content strong = HtmlTree.STRONG(deprecatedPhrase);
    +            Content strong = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
                 Content div = HtmlTree.DIV(HtmlStyle.block, strong);
                 if (deprs.length > 0) {
                     Tag[] commentTags = deprs[0].inlineTags();
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
    index 9643e878117..382f16f1f00 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
    @@ -222,7 +222,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
          */
         protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
                 Content tdSummary) {
    -        Content strong = HtmlTree.STRONG(
    +        Content strong = HtmlTree.SPAN(HtmlStyle.strong,
                     writer.getDocLink(context, (MemberDoc) member, member.name(), false));
             Content code = HtmlTree.CODE(strong);
             tdSummary.addContent(code);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
    index 4f1dbbd9bff..f599ac2ff6b 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
    @@ -139,7 +139,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
                                 holder.typeName() : holder.qualifiedTypeName(),
                                 false);
                     Content codeLink = HtmlTree.CODE(link);
    -                Content strong = HtmlTree.STRONG(holder.isClass()?
    +                Content strong = HtmlTree.SPAN(HtmlStyle.strong, holder.isClass()?
                        writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
                     strong.addContent(writer.getSpace());
                     strong.addContent(codeLink);
    @@ -256,7 +256,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
          */
         protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
                 Content tdSummary) {
    -        Content strong = HtmlTree.STRONG(
    +        Content strong = HtmlTree.SPAN(HtmlStyle.strong,
                     writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false));
             Content code = HtmlTree.CODE(strong);
             tdSummary.addContent(code);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
    index cde30f30d32..bfd7955ebbb 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
    @@ -1029,7 +1029,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     
         public Content italicsClassName(ClassDoc cd, boolean qual) {
             Content name = new StringContent((qual)? cd.qualifiedName(): cd.name());
    -        return (cd.isInterface())?  HtmlTree.I(name): name;
    +        return (cd.isInterface())?  HtmlTree.SPAN(HtmlStyle.italic, name): name;
         }
     
         /**
    @@ -1545,7 +1545,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
             Content div;
             Content result = commentTagsToContent(null, doc, tags, first);
             if (depr) {
    -            Content italic = HtmlTree.I(result);
    +            Content italic = HtmlTree.SPAN(HtmlStyle.italic, result);
                 div = HtmlTree.DIV(HtmlStyle.block, italic);
                 htmltree.addContent(div);
             }
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
    index 235c913b913..bb67b99c200 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
    @@ -159,7 +159,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
                                 holder.typeName() : holder.qualifiedTypeName(),
                                 false);
                     Content codelLink = HtmlTree.CODE(link);
    -                Content strong = HtmlTree.STRONG(holder.asClassDoc().isClass()?
    +                Content strong = HtmlTree.SPAN(HtmlStyle.strong, holder.asClassDoc().isClass()?
                         writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
                     strong.addContent(writer.getSpace());
                     strong.addContent(codelLink);
    @@ -309,7 +309,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
                     label = writer.specifiedByLabel;
                     context = LinkInfoImpl.Kind.METHOD_SPECIFIED_BY;
                 }
    -            Content dt = HtmlTree.DT(HtmlTree.STRONG(label));
    +            Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, label));
                 dl.addContent(dt);
                 Content overriddenTypeLink =
                         writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType));
    @@ -364,7 +364,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
                 Content intfaclink = writer.getLink(new LinkInfoImpl(
                         writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
                 Content codeIntfacLink = HtmlTree.CODE(intfaclink);
    -            Content dt = HtmlTree.DT(HtmlTree.STRONG(writer.specifiedByLabel));
    +            Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong, writer.specifiedByLabel));
                 dl.addContent(dt);
                 Content methlink = writer.getDocLink(
                         LinkInfoImpl.Kind.MEMBER, implementedMeth,
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
    index 487d9ff101a..d44dd25feb0 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
    @@ -164,7 +164,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
          */
         protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
                 Content tdSummary) {
    -        Content strong = HtmlTree.STRONG(
    +        Content strong = HtmlTree.SPAN(HtmlStyle.strong,
                     writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member)));
             Content code = HtmlTree.CODE(strong);
             tdSummary.addContent(code);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
    index cdd88372250..26d3a8f0b4c 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
    @@ -183,7 +183,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
                         printedHeader = true;
                     }
                     Content arr_i_name = new StringContent(arr[i].name());
    -                if (arr[i].isInterface()) arr_i_name = HtmlTree.I(arr_i_name);
    +                if (arr[i].isInterface()) arr_i_name = HtmlTree.SPAN(HtmlStyle.italic, arr_i_name);
                     Content link = getLink(new LinkInfoImpl(configuration,
                             LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i]).label(arr_i_name).target("classFrame"));
                     Content li = HtmlTree.LI(link);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java
    index ef8c0fbbc5f..38b7b1cee32 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java
    @@ -174,7 +174,7 @@ public class ProfilePackageFrameWriter extends HtmlDocletWriter {
                         printedHeader = true;
                     }
                     Content arr_i_name = new StringContent(arr[i].name());
    -                if (arr[i].isInterface()) arr_i_name = HtmlTree.I(arr_i_name);
    +                if (arr[i].isInterface()) arr_i_name = HtmlTree.SPAN(HtmlStyle.italic, arr_i_name);
                     Content link = getLink(new LinkInfoImpl(configuration,
                             LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i]).label(arr_i_name).target("classFrame"));
                     Content li = HtmlTree.LI(link);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java
    index 9018b77ece6..838732b5212 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java
    @@ -135,7 +135,7 @@ public class PropertyWriterImpl extends AbstractMemberWriter
                                 holder.typeName() : holder.qualifiedTypeName(),
                                 false);
                     Content codeLink = HtmlTree.CODE(link);
    -                Content strong = HtmlTree.STRONG(holder.isClass()?
    +                Content strong = HtmlTree.SPAN(HtmlStyle.strong, holder.isClass()?
                        writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
                     strong.addContent(writer.getSpace());
                     strong.addContent(codeLink);
    @@ -252,13 +252,12 @@ public class PropertyWriterImpl extends AbstractMemberWriter
          */
         protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
                 Content tdSummary) {
    -        Content strong = HtmlTree.STRONG(
    -                writer.getDocLink(context,
    -                        cd,
    -                        (MemberDoc) member,
    -                        member.name().substring(0, member.name().lastIndexOf("Property")),
    -                        false,
    -                        true));
    +        Content strong = HtmlTree.SPAN(HtmlStyle.strong,
    +                writer.getDocLink(context, cd,
    +                (MemberDoc) member,
    +                member.name().substring(0, member.name().lastIndexOf("Property")),
    +                false,
    +                true));
     
             Content code = HtmlTree.CODE(strong);
             tdSummary.addContent(code);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
    index 94bde2e35ec..ce6a0fd053d 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
    @@ -175,7 +175,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
             Tag[] deprs = member.tags("deprecated");
             Content div;
             if (Util.isDeprecated((ProgramElementDoc) member)) {
    -            Content strong = HtmlTree.STRONG(deprecatedPhrase);
    +            Content strong = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
                 div = HtmlTree.DIV(HtmlStyle.block, strong);
                 div.addContent(getSpace());
                 if (deprs.length > 0) {
    @@ -186,7 +186,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
             } else {
                 ClassDoc cd = ((ProgramElementDoc)member).containingClass();
                 if (cd != null && Util.isDeprecated(cd)) {
    -                Content strong = HtmlTree.STRONG(deprecatedPhrase);
    +                Content strong = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
                     div = HtmlTree.DIV(HtmlStyle.block, strong);
                     div.addContent(getSpace());
                     tdSummary.addContent(div);
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
    index fc63f4f8654..95e9a74ed78 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
    @@ -118,7 +118,7 @@ public class TagletWriterImpl extends TagletWriter {
                     if (deprs.length > 0) {
                         Content body = commentTagsToOutput(null, doc,
                             deprs[0].inlineTags(), false);
    -                    result.addContent(HtmlTree.I(body));
    +                    result.addContent(HtmlTree.SPAN(HtmlStyle.italic, body));
                     }
                 } else {
                     if (Util.isDeprecated(member.containingClass())) {
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
    index a1719bbe8cf..c20ac4c5d5f 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -59,6 +59,7 @@ public enum HtmlStyle {
         indexContainer,
         indexHeader,
         inheritance,
    +    italic,
         legalCopy,
         nameValue,
         navBarCell1Rev,
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
    index e6c101a5d4b..ab4fdd8e474 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
    @@ -415,17 +415,6 @@ public class HtmlTree extends Content {
             return htmltree;
         }
     
    -    /**
    -     * Generates a I tag with some content.
    -     *
    -     * @param body content for the tag
    -     * @return an HtmlTree object for the I tag
    -     */
    -    public static HtmlTree I(Content body) {
    -        HtmlTree htmltree = new HtmlTree(HtmlTag.I, nullCheck(body));
    -        return htmltree;
    -    }
    -
         /**
          * Generates a LI tag with some content.
          *
    @@ -558,17 +547,6 @@ public class HtmlTree extends Content {
             return htmltree;
         }
     
    -    /**
    -     * Generates a STRONG tag with some content.
    -     *
    -     * @param body content for the tag
    -     * @return an HtmlTree object for the STRONG tag
    -     */
    -    public static HtmlTree STRONG(Content body) {
    -        HtmlTree htmltree = new HtmlTree(HtmlTag.STRONG, nullCheck(body));
    -        return htmltree;
    -    }
    -
         /**
          * Generates a SPAN tag with some content.
          *
    diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
    index 6634d8aedfe..18e062a8b27 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
    +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
    @@ -519,3 +519,6 @@ h1.hidden {
     .strong {
         font-weight:bold;
     }
    +.italic {
    +    font-style:italic;
    +}
    diff --git a/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java b/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
    index d3f9bf3f954..048f2186df5 100644
    --- a/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
    +++ b/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -48,7 +48,7 @@ public class TestClassCrossReferences extends JavadocTester {
                 "Link to external member gcd"},
             {BUG_ID + FS + "C.html",
    -            "
    " + NL + "
    Overrides:
    " + NL + + "
    " + NL + "
    Overrides:
    " + NL + "
    toString in class java.lang.Object
    " + NL + "
    "} }; diff --git a/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java b/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java index c3fe082ddad..78921d49d27 100644 --- a/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java +++ b/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,13 +39,13 @@ public class TestExternalOverridenMethod extends JavadocTester { private static final String BUG_ID = "4857717"; private static final String[][] TEST = { {BUG_ID + FS + "pkg" + FS + "XReader.html", - "
    Overrides:
    " + NL + + "
    Overrides:
    " + NL + "
    read in class " + "FilterReader
    "}, {BUG_ID + FS + "pkg" + FS + "XReader.html", - "
    Specified by:
    " + NL + + "
    Specified by:
    " + NL + "
    readInt in interface " + "" + NL + "
    " + "C1.setUndecorated(boolean)
    " + NL + "
    "}, {BUG_ID + FS + "serialized-form.html", "Deprecated." + - " As of JDK version 1.5, replaced by" + NL + + " As of JDK version 1.5, replaced by" + NL + " " + - "setUndecorated(boolean)." + NL + + "setUndecorated(boolean)." + NL + "
    This field indicates whether the C1 is " + "undecorated.
    " + NL + " " + NL + "
    " + NL + "
    Since:
    " + NL + "
    1.4
    " + NL + "
    See Also:" + "
    " + NL + "
    " + "C1.setUndecorated(boolean)
    " + NL + "
    "}, {BUG_ID + FS + "serialized-form.html", "Deprecated." + - " As of JDK version 1.5, replaced by" + NL + + " As of JDK version 1.5, replaced by" + NL + " " + - "setUndecorated(boolean)." + NL + + "setUndecorated(boolean)." + NL + "
    Reads the object stream.
    " + NL + "
    " + NL + "
    Throws:" + "
    " + NL + "
    " + @@ -153,18 +153,18 @@ public class TestHtmlDefinitionListTag extends JavadocTester { "" + NL + "
    " + "C1.setUndecorated(boolean)
    " + NL + "
    "}, {BUG_ID + FS + "serialized-form.html", "Deprecated." + - " As of JDK version 1.5, replaced by" + NL + + " As of JDK version 1.5, replaced by" + NL + " " + - "setUndecorated(boolean)." + NL + + "setUndecorated(boolean)." + NL + "
    This field indicates whether the C1 is " + "undecorated.
    " + NL + " " + NL + "
    " + NL + "
    Since:
    " + NL + "
    1.4
    " + NL + "
    See Also:" + "
    " + NL + "
    " + "C1.setUndecorated(boolean)
    " + NL + "
    "}, {BUG_ID + FS + "serialized-form.html", "Deprecated." + - " As of JDK version 1.5, replaced by" + NL + + " As of JDK version 1.5, replaced by" + NL + " " + - "setUndecorated(boolean)." + NL + + "setUndecorated(boolean)." + NL + "
    Reads the object stream.
    " + NL + "
    " + NL + "
    Throws:" + "
    " + NL + "
    " + @@ -187,14 +187,14 @@ public class TestHtmlDefinitionListTag extends JavadocTester { "APPLICATION_EXCLUDE
    " + NL + "
  • "}, {BUG_ID + FS + "serialized-form.html", "
    boolean " +
                      "undecorated
    " + NL + "
    " + - "Deprecated. As of JDK version 1.5, replaced by" + NL + + "Deprecated. As of JDK version 1.5, replaced by" + NL + " " + - "setUndecorated(boolean).
    " + NL + ""}, + "setUndecorated(boolean)
    ." + NL + ""}, {BUG_ID + FS + "serialized-form.html", "" + - "Deprecated. As of JDK version" + + "Deprecated. As of JDK version" + " 1.5, replaced by" + NL + " " + - "setUndecorated(boolean)." + NL + ""}}; + "setUndecorated(boolean)." + NL + ""}}; // Test for valid HTML generation which should not comprise of empty // definition list tags. diff --git a/langtools/test/com/sun/javadoc/testInterface/TestInterface.java b/langtools/test/com/sun/javadoc/testInterface/TestInterface.java index d0f1afc2bf3..cfaff523fde 100644 --- a/langtools/test/com/sun/javadoc/testInterface/TestInterface.java +++ b/langtools/test/com/sun/javadoc/testInterface/TestInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,7 @@ public class TestInterface extends JavadocTester { }, //Make sure "Specified By" has substituted type parameters. {BUG_ID + FS + "pkg" + FS + "Child.html", - "
    Specified by:
    " + NL + + "
    Specified by:
    " + NL + "
    method" + " in interface " + "" + @@ -92,7 +92,7 @@ public class TestInterface extends JavadocTester { }, //Make sure "Overrides" has substituted type parameters. {BUG_ID + FS + "pkg" + FS + "Child.html", - "
    Overrides:
    " + NL + + "
    Overrides:
    " + NL + "
    method" + " in class Parent<Gets the value of the property rate." + NL + "
    " + NL + "
    Property description:
    " }, {"./" + BUG_ID + "/C.html", - "

  • rate" + NL + + "rate" + NL + "
    Defines the direction/speed at which the Timeline is expected to"}, {"./" + BUG_ID + "/C.html", @@ -63,7 +63,7 @@ public class TestJavaFX extends JavadocTester { {"./" + BUG_ID + "/C.html", "Property description:"}, {"./" + BUG_ID + "/C.html", - "
    setTestMethodProperty() setTestMethodProperty() " + - "returnTypeTest()" + "" + + "returnTypeTest()" }, // Check return type in member detail. {BUG_ID + FS + "pkg" + FS + "PublicChild.html", diff --git a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java index db5c2f24e0f..e16fd5450f2 100644 --- a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java +++ b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java @@ -62,7 +62,7 @@ public class TestNewLanguageFeatures extends JavadocTester { " "}, //Detail for enum constant {BUG_ID + FS + "pkg" + FS + "Coin.html", - "Dime"}, + "Dime"}, //Automatically insert documentation for values() and valueOf(). {BUG_ID + FS + "pkg" + FS + "Coin.html", "Returns an array containing the constants of this enum type,"}, @@ -320,11 +320,11 @@ public class TestNewLanguageFeatures extends JavadocTester { "Foo " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", - "ClassUseTest1<T extends " + "Foo" + " & " + - "Foo2> 
    Methods in ClassUseTest1." + - "method" + + "method" + "(T t) " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", @@ -372,11 +372,11 @@ public class TestNewLanguageFeatures extends JavadocTester { "
    ClassUseTest1<T extends " + "Foo" + " & " + - "Foo2> 
    Methods in " + - "ClassUseTest1.method" + + "ClassUseTest1.method" + "(T t) " }, @@ -401,11 +401,11 @@ public class TestNewLanguageFeatures extends JavadocTester { " 
    ClassUseTest2<T extends " + "" + "ParamTest<" + - "Foo3>> 
    Methods in ClassUseTest2." + - "method" + + "method" + "(T t) " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", @@ -456,11 +456,11 @@ public class TestNewLanguageFeatures extends JavadocTester { "Foo3 
    ClassUseTest2<T extends " + "" + "ParamTest<" + - "Foo3>> 
    Methods in ClassUseTest2." + - "method" + + "method" + "(T t) " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", @@ -500,12 +500,12 @@ public class TestNewLanguageFeatures extends JavadocTester { " 
    ClassUseTest3<T extends " + "" + "ParamTest2<java.util.List<? extends " + "" + - "Foo4>>> 
    Methods in ClassUseTest3" + - ".method(T t) " + ".method(T t) " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", "
    <T extends " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", - "ClassUseTest3<T extends " + "" + "ParamTest2<java.util.List<? extends " + "" + - "Foo4>>> 
    Methods in ClassUseTest3." + - "method(T t)" + + "method(T t)" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", @@ -587,8 +587,8 @@ public class TestNewLanguageFeatures extends JavadocTester { "" + NL + "
    voidClassUseTest3." + - "method(java." + + "method(java." + "util.Set<Foo4> p)