--- a/.hgtags Sat Nov 01 14:40:09 2014 +0300
+++ b/.hgtags Mon Nov 03 10:11:10 2014 -0800
@@ -279,3 +279,4 @@
9618201c5df28a460631577fad1f61e96f775c34 jdk9-b34
a137992d750c72f6f944f341aa19b0d0d96afe0c jdk9-b35
41df50e7303daf73c0d661ef601c4fe250915de5 jdk9-b36
+b409bc51bc23cfd51f2bd04ea919ec83535af9d0 jdk9-b37
--- a/.hgtags-top-repo Sat Nov 01 14:40:09 2014 +0300
+++ b/.hgtags-top-repo Mon Nov 03 10:11:10 2014 -0800
@@ -279,3 +279,4 @@
087b23f35631e68e950496a36fce8ccca612966a jdk9-b34
c173ba994245380fb11ef077d1e59823386840eb jdk9-b35
201d4e235d597a25a2d3ee1404394789ba386119 jdk9-b36
+723a67b0c442391447b1d8aad8b249d06d1032e8 jdk9-b37
--- a/common/autoconf/flags.m4 Sat Nov 01 14:40:09 2014 +0300
+++ b/common/autoconf/flags.m4 Mon Nov 03 10:11:10 2014 -0800
@@ -136,8 +136,8 @@
SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\""
SYSROOT_LDFLAGS=$SYSROOT_CFLAGS
elif test "x$TOOLCHAIN_TYPE" = xgcc; then
- SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\""
- SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\""
+ SYSROOT_CFLAGS="--sysroot=$SYSROOT"
+ SYSROOT_LDFLAGS="--sysroot=$SYSROOT"
elif test "x$TOOLCHAIN_TYPE" = xclang; then
SYSROOT_CFLAGS="-isysroot \"$SYSROOT\""
SYSROOT_LDFLAGS="-isysroot \"$SYSROOT\""
--- a/common/autoconf/generated-configure.sh Sat Nov 01 14:40:09 2014 +0300
+++ b/common/autoconf/generated-configure.sh Mon Nov 03 10:11:10 2014 -0800
@@ -4328,7 +4328,7 @@
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1413533532
+DATE_WHEN_GENERATED=1414663067
###############################################################################
#
@@ -41681,8 +41681,8 @@
SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\""
SYSROOT_LDFLAGS=$SYSROOT_CFLAGS
elif test "x$TOOLCHAIN_TYPE" = xgcc; then
- SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\""
- SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\""
+ SYSROOT_CFLAGS="--sysroot=$SYSROOT"
+ SYSROOT_LDFLAGS="--sysroot=$SYSROOT"
elif test "x$TOOLCHAIN_TYPE" = xclang; then
SYSROOT_CFLAGS="-isysroot \"$SYSROOT\""
SYSROOT_LDFLAGS="-isysroot \"$SYSROOT\""
@@ -44037,17 +44037,6 @@
-R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
fi
- #
- # Weird Sol10 something check...TODO change to try compile
- #
- if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
- if test "`uname -r`" = "5.10"; then
- if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
- X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
- fi
- fi
- fi
-
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -44055,7 +44044,7 @@
ac_compiler_gnu=$ac_cv_c_compiler_gnu
OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $X_CFLAGS"
+ CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_CFLAGS"
# Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
for ac_header in X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h
@@ -44079,6 +44068,31 @@
done
+ # If XLinearGradient isn't available in Xrender.h, signal that it needs to be
+ # defined in libawt_xawt.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if XlinearGradient is defined in Xrender.h" >&5
+$as_echo_n "checking if XlinearGradient is defined in Xrender.h... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <X11/extensions/Xrender.h>
+int
+main ()
+{
+XLinearGradient x;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ X_CFLAGS="$X_CFLAGS -DSOLARIS10_NO_XRENDER_STRUCTS"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
CFLAGS="$OLD_CFLAGS"
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
--- a/common/autoconf/libraries.m4 Sat Nov 01 14:40:09 2014 +0300
+++ b/common/autoconf/libraries.m4 Mon Nov 03 10:11:10 2014 -0800
@@ -139,20 +139,9 @@
-R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
fi
- #
- # Weird Sol10 something check...TODO change to try compile
- #
- if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
- if test "`uname -r`" = "5.10"; then
- if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
- X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
- fi
- fi
- fi
-
AC_LANG_PUSH(C)
OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $X_CFLAGS"
+ CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_CFLAGS"
# Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
@@ -164,6 +153,16 @@
]
)
+ # If XLinearGradient isn't available in Xrender.h, signal that it needs to be
+ # defined in libawt_xawt.
+ AC_MSG_CHECKING([if XlinearGradient is defined in Xrender.h])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],
+ [[XLinearGradient x;]])],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ X_CFLAGS="$X_CFLAGS -DSOLARIS10_NO_XRENDER_STRUCTS"])
+
CFLAGS="$OLD_CFLAGS"
AC_LANG_POP(C)
--- a/corba/.hgtags Sat Nov 01 14:40:09 2014 +0300
+++ b/corba/.hgtags Mon Nov 03 10:11:10 2014 -0800
@@ -279,3 +279,4 @@
24a0bad5910f775bb4002d1dacf8b3af87c63cd8 jdk9-b34
9bc2dbd3dfb8c9fa88e00056b8b93a81ee6d306e jdk9-b35
ffd90c81d4ef9d94d880fc852e2fc482ecd9b374 jdk9-b36
+7e9add74ad50841fb39dae75db56374aefa1de4c jdk9-b37
--- a/hotspot/.hgtags Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/.hgtags Mon Nov 03 10:11:10 2014 -0800
@@ -439,3 +439,4 @@
821164b0131a47ca065697c7d27d8f215e608c8d jdk9-b34
438cb613151c4bd290bb732697517cba1cafcb04 jdk9-b35
464ab653fbb17eb518d8ef60f8df301de7ef00d0 jdk9-b36
+b1c2dd843f247a1db19e1e85eb62ca405f72dc26 jdk9-b37
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -734,7 +734,7 @@
// Move class loader data from main list to the unloaded list for unloading
// and deallocation later.
-bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure) {
+bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, bool clean_alive) {
ClassLoaderData* data = _head;
ClassLoaderData* prev = NULL;
bool seen_dead_loader = false;
@@ -743,27 +743,9 @@
// purging and we don't want to rewalk the previously unloaded class loader data.
_saved_unloading = _unloading;
- // mark metadata seen on the stack and code cache so we can delete
- // unneeded entries.
- bool has_redefined_a_class = JvmtiExport::has_redefined_a_class();
- MetadataOnStackMark md_on_stack(has_redefined_a_class);
- if (has_redefined_a_class) {
- // purge_previous_versions also cleans weak method links. Because
- // one method's MDO can reference another method from another
- // class loader, we need to first clean weak method links for all
- // class loaders here. Below, we can then free redefined methods
- // for all class loaders.
- while (data != NULL) {
- if (data->is_alive(is_alive_closure)) {
- data->classes_do(InstanceKlass::purge_previous_versions);
- }
- data = data->next();
- }
- }
data = _head;
while (data != NULL) {
if (data->is_alive(is_alive_closure)) {
- data->free_deallocate_list();
prev = data;
data = data->next();
continue;
@@ -785,6 +767,11 @@
_unloading = dead;
}
+ if (clean_alive) {
+ // Clean previous versions and the deallocate list.
+ ClassLoaderDataGraph::clean_metaspaces();
+ }
+
if (seen_dead_loader) {
post_class_unload_events();
}
@@ -792,6 +779,26 @@
return seen_dead_loader;
}
+void ClassLoaderDataGraph::clean_metaspaces() {
+ // mark metadata seen on the stack and code cache so we can delete unneeded entries.
+ bool has_redefined_a_class = JvmtiExport::has_redefined_a_class();
+ MetadataOnStackMark md_on_stack(has_redefined_a_class);
+
+ if (has_redefined_a_class) {
+ // purge_previous_versions also cleans weak method links. Because
+ // one method's MDO can reference another method from another
+ // class loader, we need to first clean weak method links for all
+ // class loaders here. Below, we can then free redefined methods
+ // for all class loaders.
+ for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
+ data->classes_do(InstanceKlass::purge_previous_versions);
+ }
+ }
+
+ // Need to purge the previous version before deallocating.
+ free_deallocate_lists();
+}
+
void ClassLoaderDataGraph::purge() {
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
ClassLoaderData* list = _unloading;
@@ -819,6 +826,14 @@
#endif
}
+void ClassLoaderDataGraph::free_deallocate_lists() {
+ for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
+ // We need to keep this data until InstanceKlass::purge_previous_version has been
+ // called on all alive classes. See the comment in ClassLoaderDataGraph::clean_metaspaces.
+ cld->free_deallocate_list();
+ }
+}
+
// CDS support
// Global metaspaces for writing information to the shared archive. When
--- a/hotspot/src/share/vm/classfile/classLoaderData.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -71,6 +71,7 @@
static ClassLoaderData* add(Handle class_loader, bool anonymous, TRAPS);
static void post_class_unload_events(void);
+ static void clean_metaspaces();
public:
static ClassLoaderData* find_or_create(Handle class_loader, TRAPS);
static void purge();
@@ -90,7 +91,7 @@
static void methods_do(void f(Method*));
static void loaded_classes_do(KlassClosure* klass_closure);
static void classes_unloading_do(void f(Klass* const));
- static bool do_unloading(BoolObjectClosure* is_alive);
+ static bool do_unloading(BoolObjectClosure* is_alive, bool clean_alive);
// CMS support.
static void remember_new_clds(bool remember) { _saved_head = (remember ? _head : NULL); }
@@ -106,6 +107,8 @@
}
}
+ static void free_deallocate_lists();
+
static void dump_on(outputStream * const out) PRODUCT_RETURN;
static void dump() { dump_on(tty); }
static void verify();
--- a/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -31,25 +31,23 @@
#include "runtime/synchronizer.hpp"
#include "runtime/thread.hpp"
#include "services/threadService.hpp"
-#include "utilities/growableArray.hpp"
-
+#include "utilities/chunkedList.hpp"
-// Keep track of marked on-stack metadata so it can be cleared.
-GrowableArray<Metadata*>* _marked_objects = NULL;
+volatile MetadataOnStackBuffer* MetadataOnStackMark::_used_buffers = NULL;
+volatile MetadataOnStackBuffer* MetadataOnStackMark::_free_buffers = NULL;
+
NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;)
// Walk metadata on the stack and mark it so that redefinition doesn't delete
// it. Class unloading also walks the previous versions and might try to
// delete it, so this class is used by class unloading also.
-MetadataOnStackMark::MetadataOnStackMark(bool has_redefined_a_class) {
+MetadataOnStackMark::MetadataOnStackMark(bool visit_code_cache) {
assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
+ assert(_used_buffers == NULL, "sanity check");
NOT_PRODUCT(_is_active = true;)
- if (_marked_objects == NULL) {
- _marked_objects = new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(1000, true);
- }
Threads::metadata_do(Metadata::mark_on_stack);
- if (has_redefined_a_class) {
+ if (visit_code_cache) {
CodeCache::alive_nmethods_do(nmethod::mark_on_stack);
}
CompileBroker::mark_on_stack();
@@ -62,15 +60,93 @@
// Unmark everything that was marked. Can't do the same walk because
// redefine classes messes up the code cache so the set of methods
// might not be the same.
- for (int i = 0; i< _marked_objects->length(); i++) {
- _marked_objects->at(i)->set_on_stack(false);
+
+ retire_buffer_for_thread(Thread::current());
+
+ MetadataOnStackBuffer* buffer = const_cast<MetadataOnStackBuffer* >(_used_buffers);
+ while (buffer != NULL) {
+ // Clear on stack state for all metadata.
+ size_t size = buffer->size();
+ for (size_t i = 0; i < size; i++) {
+ Metadata* md = buffer->at(i);
+ md->set_on_stack(false);
+ }
+
+ MetadataOnStackBuffer* next = buffer->next_used();
+
+ // Move the buffer to the free list.
+ buffer->clear();
+ buffer->set_next_used(NULL);
+ buffer->set_next_free(const_cast<MetadataOnStackBuffer*>(_free_buffers));
+ _free_buffers = buffer;
+
+ // Step to next used buffer.
+ buffer = next;
}
- _marked_objects->clear(); // reuse growable array for next time.
+
+ _used_buffers = NULL;
+
NOT_PRODUCT(_is_active = false;)
}
+void MetadataOnStackMark::retire_buffer(MetadataOnStackBuffer* buffer) {
+ if (buffer == NULL) {
+ return;
+ }
+
+ MetadataOnStackBuffer* old_head;
+
+ do {
+ old_head = const_cast<MetadataOnStackBuffer*>(_used_buffers);
+ buffer->set_next_used(old_head);
+ } while (Atomic::cmpxchg_ptr(buffer, &_used_buffers, old_head) != old_head);
+}
+
+void MetadataOnStackMark::retire_buffer_for_thread(Thread* thread) {
+ retire_buffer(thread->metadata_on_stack_buffer());
+ thread->set_metadata_on_stack_buffer(NULL);
+}
+
+bool MetadataOnStackMark::has_buffer_for_thread(Thread* thread) {
+ return thread->metadata_on_stack_buffer() != NULL;
+}
+
+MetadataOnStackBuffer* MetadataOnStackMark::allocate_buffer() {
+ MetadataOnStackBuffer* allocated;
+ MetadataOnStackBuffer* new_head;
+
+ do {
+ allocated = const_cast<MetadataOnStackBuffer*>(_free_buffers);
+ if (allocated == NULL) {
+ break;
+ }
+ new_head = allocated->next_free();
+ } while (Atomic::cmpxchg_ptr(new_head, &_free_buffers, allocated) != allocated);
+
+ if (allocated == NULL) {
+ allocated = new MetadataOnStackBuffer();
+ }
+
+ assert(!allocated->is_full(), err_msg("Should not be full: " PTR_FORMAT, p2i(allocated)));
+
+ return allocated;
+}
+
// Record which objects are marked so we can unmark the same objects.
-void MetadataOnStackMark::record(Metadata* m) {
+void MetadataOnStackMark::record(Metadata* m, Thread* thread) {
assert(_is_active, "metadata on stack marking is active");
- _marked_objects->push(m);
+
+ MetadataOnStackBuffer* buffer = thread->metadata_on_stack_buffer();
+
+ if (buffer != NULL && buffer->is_full()) {
+ retire_buffer(buffer);
+ buffer = NULL;
+ }
+
+ if (buffer == NULL) {
+ buffer = allocate_buffer();
+ thread->set_metadata_on_stack_buffer(buffer);
+ }
+
+ buffer->push(m);
}
--- a/hotspot/src/share/vm/classfile/metadataOnStackMark.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/classfile/metadataOnStackMark.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -26,9 +26,12 @@
#define SHARE_VM_CLASSFILE_METADATAONSTACKMARK_HPP
#include "memory/allocation.hpp"
+#include "utilities/chunkedList.hpp"
class Metadata;
+typedef ChunkedList<Metadata*, mtInternal> MetadataOnStackBuffer;
+
// Helper class to mark and unmark metadata used on the stack as either handles
// or executing methods, so that it can't be deleted during class redefinition
// and class unloading.
@@ -36,10 +39,20 @@
// metadata during parsing, relocated methods, and methods in backtraces.
class MetadataOnStackMark : public StackObj {
NOT_PRODUCT(static bool _is_active;)
+
+ static volatile MetadataOnStackBuffer* _used_buffers;
+ static volatile MetadataOnStackBuffer* _free_buffers;
+
+ static MetadataOnStackBuffer* allocate_buffer();
+ static void retire_buffer(MetadataOnStackBuffer* buffer);
+
public:
- MetadataOnStackMark(bool has_redefined_a_class);
- ~MetadataOnStackMark();
- static void record(Metadata* m);
+ MetadataOnStackMark(bool visit_code_cache);
+ ~MetadataOnStackMark();
+
+ static void record(Metadata* m, Thread* thread);
+ static void retire_buffer_for_thread(Thread* thread);
+ static bool has_buffer_for_thread(Thread* thread);
};
#endif // SHARE_VM_CLASSFILE_METADATAONSTACKMARK_HPP
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -1690,9 +1690,9 @@
// Assumes classes in the SystemDictionary are only unloaded at a safepoint
// Note: anonymous classes are not in the SD.
-bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) {
+bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive, bool clean_alive) {
// First, mark for unload all ClassLoaderData referencing a dead class loader.
- bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive);
+ bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive, clean_alive);
if (unloading_occurred) {
dictionary()->do_unloading();
constraints()->purge_loader_constraints();
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -334,7 +334,7 @@
// Unload (that is, break root links to) all unmarked classes and
// loaders. Returns "true" iff something was unloaded.
- static bool do_unloading(BoolObjectClosure* is_alive);
+ static bool do_unloading(BoolObjectClosure* is_alive, bool clean_alive = true);
// Used by DumpSharedSpaces only to remove classes that failed verification
static void remove_classes_in_error_state();
--- a/hotspot/src/share/vm/code/nmethod.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/code/nmethod.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -1700,11 +1700,17 @@
set_unload_reported();
}
-void static clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive) {
+void static clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive, bool mark_on_stack) {
if (ic->is_icholder_call()) {
// The only exception is compiledICHolder oops which may
// yet be marked below. (We check this further below).
CompiledICHolder* cichk_oop = ic->cached_icholder();
+
+ if (mark_on_stack) {
+ Metadata::mark_on_stack(cichk_oop->holder_method());
+ Metadata::mark_on_stack(cichk_oop->holder_klass());
+ }
+
if (cichk_oop->holder_method()->method_holder()->is_loader_alive(is_alive) &&
cichk_oop->holder_klass()->is_loader_alive(is_alive)) {
return;
@@ -1712,6 +1718,10 @@
} else {
Metadata* ic_oop = ic->cached_metadata();
if (ic_oop != NULL) {
+ if (mark_on_stack) {
+ Metadata::mark_on_stack(ic_oop);
+ }
+
if (ic_oop->is_klass()) {
if (((Klass*)ic_oop)->is_loader_alive(is_alive)) {
return;
@@ -1772,7 +1782,7 @@
while(iter.next()) {
if (iter.type() == relocInfo::virtual_call_type) {
CompiledIC *ic = CompiledIC_at(&iter);
- clean_ic_if_metadata_is_dead(ic, is_alive);
+ clean_ic_if_metadata_is_dead(ic, is_alive, false);
}
}
}
@@ -1840,6 +1850,53 @@
return clean_if_nmethod_is_unloaded(csc, csc->destination(), is_alive, from);
}
+bool nmethod::unload_if_dead_at(RelocIterator* iter_at_oop, BoolObjectClosure *is_alive, bool unloading_occurred) {
+ assert(iter_at_oop->type() == relocInfo::oop_type, "Wrong relocation type");
+
+ oop_Relocation* r = iter_at_oop->oop_reloc();
+ // Traverse those oops directly embedded in the code.
+ // Other oops (oop_index>0) are seen as part of scopes_oops.
+ assert(1 == (r->oop_is_immediate()) +
+ (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()),
+ "oop must be found in exactly one place");
+ if (r->oop_is_immediate() && r->oop_value() != NULL) {
+ // Unload this nmethod if the oop is dead.
+ if (can_unload(is_alive, r->oop_addr(), unloading_occurred)) {
+ return true;;
+ }
+ }
+
+ return false;
+}
+
+void nmethod::mark_metadata_on_stack_at(RelocIterator* iter_at_metadata) {
+ assert(iter_at_metadata->type() == relocInfo::metadata_type, "Wrong relocation type");
+
+ metadata_Relocation* r = iter_at_metadata->metadata_reloc();
+ // In this metadata, we must only follow those metadatas directly embedded in
+ // the code. Other metadatas (oop_index>0) are seen as part of
+ // the metadata section below.
+ assert(1 == (r->metadata_is_immediate()) +
+ (r->metadata_addr() >= metadata_begin() && r->metadata_addr() < metadata_end()),
+ "metadata must be found in exactly one place");
+ if (r->metadata_is_immediate() && r->metadata_value() != NULL) {
+ Metadata* md = r->metadata_value();
+ if (md != _method) Metadata::mark_on_stack(md);
+ }
+}
+
+void nmethod::mark_metadata_on_stack_non_relocs() {
+ // Visit the metadata section
+ for (Metadata** p = metadata_begin(); p < metadata_end(); p++) {
+ if (*p == Universe::non_oop_word() || *p == NULL) continue; // skip non-oops
+ Metadata* md = *p;
+ Metadata::mark_on_stack(md);
+ }
+
+ // Visit metadata not embedded in the other places.
+ if (_method != NULL) Metadata::mark_on_stack(_method);
+}
+
bool nmethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred) {
ResourceMark rm;
@@ -1869,6 +1926,11 @@
unloading_occurred = true;
}
+ // When class redefinition is used all metadata in the CodeCache has to be recorded,
+ // so that unused "previous versions" can be purged. Since walking the CodeCache can
+ // be expensive, the "mark on stack" is piggy-backed on this parallel unloading code.
+ bool mark_metadata_on_stack = a_class_was_redefined;
+
// Exception cache
clean_exception_cache(is_alive);
@@ -1884,7 +1946,7 @@
if (unloading_occurred) {
// If class unloading occurred we first iterate over all inline caches and
// clear ICs where the cached oop is referring to an unloaded klass or method.
- clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive);
+ clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive, mark_metadata_on_stack);
}
postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this);
@@ -1900,24 +1962,21 @@
case relocInfo::oop_type:
if (!is_unloaded) {
- // Unload check
- oop_Relocation* r = iter.oop_reloc();
- // Traverse those oops directly embedded in the code.
- // Other oops (oop_index>0) are seen as part of scopes_oops.
- assert(1 == (r->oop_is_immediate()) +
- (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()),
- "oop must be found in exactly one place");
- if (r->oop_is_immediate() && r->oop_value() != NULL) {
- if (can_unload(is_alive, r->oop_addr(), unloading_occurred)) {
- is_unloaded = true;
- }
- }
+ is_unloaded = unload_if_dead_at(&iter, is_alive, unloading_occurred);
}
break;
+ case relocInfo::metadata_type:
+ if (mark_metadata_on_stack) {
+ mark_metadata_on_stack_at(&iter);
+ }
}
}
+ if (mark_metadata_on_stack) {
+ mark_metadata_on_stack_non_relocs();
+ }
+
if (is_unloaded) {
return postponed;
}
@@ -2065,7 +2124,7 @@
while (iter.next()) {
if (iter.type() == relocInfo::metadata_type ) {
metadata_Relocation* r = iter.metadata_reloc();
- // In this lmetadata, we must only follow those metadatas directly embedded in
+ // In this metadata, we must only follow those metadatas directly embedded in
// the code. Other metadatas (oop_index>0) are seen as part of
// the metadata section below.
assert(1 == (r->metadata_is_immediate()) +
@@ -2099,7 +2158,7 @@
f(md);
}
- // Call function Method*, not embedded in these other places.
+ // Visit metadata not embedded in the other places.
if (_method != NULL) f(_method);
}
--- a/hotspot/src/share/vm/code/nmethod.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/code/nmethod.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -615,9 +615,16 @@
// The parallel versions are used by G1.
bool do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred);
void do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred);
+
+ private:
// Unload a nmethod if the *root object is dead.
bool can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_occurred);
+ bool unload_if_dead_at(RelocIterator *iter_at_oop, BoolObjectClosure* is_alive, bool unloading_occurred);
+ void mark_metadata_on_stack_at(RelocIterator* iter_at_metadata);
+ void mark_metadata_on_stack_non_relocs();
+
+ public:
void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map,
OopClosure* f);
void oops_do(OopClosure* f) { oops_do(f, false); }
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -64,23 +64,6 @@
set_hint(hint);
}
-#ifndef PRODUCT
-template <class Chunk>
-void AdaptiveFreeList<Chunk>::assert_proper_lock_protection_work() const {
- assert(protecting_lock() != NULL, "Don't call this directly");
- assert(ParallelGCThreads > 0, "Don't call this directly");
- Thread* thr = Thread::current();
- if (thr->is_VM_thread() || thr->is_ConcurrentGC_thread()) {
- // assert that we are holding the freelist lock
- } else if (thr->is_GC_task_thread()) {
- assert(protecting_lock()->owned_by_self(), "FreeList RACE DETECTED");
- } else if (thr->is_Java_thread()) {
- assert(!SafepointSynchronize::is_at_safepoint(), "Should not be executing");
- } else {
- ShouldNotReachHere(); // unaccounted thread type?
- }
-}
-#endif
template <class Chunk>
void AdaptiveFreeList<Chunk>::init_statistics(bool split_birth) {
_allocation_stats.initialize(split_birth);
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -81,8 +81,6 @@
// Reset the head, tail, hint, and count of a free list.
void reset(size_t hint);
- void assert_proper_lock_protection_work() const PRODUCT_RETURN;
-
void print_on(outputStream* st, const char* c = NULL) const;
size_t hint() const {
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -149,18 +149,15 @@
check_free_list_consistency();
// Initialize locks for parallel case.
-
- if (CollectedHeap::use_parallel_gc_threads()) {
- for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
- _indexedFreeListParLocks[i] = new Mutex(Mutex::leaf - 1, // == ExpandHeap_lock - 1
- "a freelist par lock",
- true);
- DEBUG_ONLY(
- _indexedFreeList[i].set_protecting_lock(_indexedFreeListParLocks[i]);
- )
- }
- _dictionary->set_par_lock(&_parDictionaryAllocLock);
+ for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
+ _indexedFreeListParLocks[i] = new Mutex(Mutex::leaf - 1, // == ExpandHeap_lock - 1
+ "a freelist par lock",
+ true);
+ DEBUG_ONLY(
+ _indexedFreeList[i].set_protecting_lock(_indexedFreeListParLocks[i]);
+ )
}
+ _dictionary->set_par_lock(&_parDictionaryAllocLock);
}
// Like CompactibleSpace forward() but always calls cross_threshold() to
@@ -622,17 +619,11 @@
// Mark the boundary of the new block in BOT
_bt.mark_block(prevEnd, value);
// put it all in the linAB
- if (ParallelGCThreads == 0) {
- _smallLinearAllocBlock._ptr = prevEnd;
- _smallLinearAllocBlock._word_size = newFcSize;
- repairLinearAllocBlock(&_smallLinearAllocBlock);
- } else { // ParallelGCThreads > 0
- MutexLockerEx x(parDictionaryAllocLock(),
- Mutex::_no_safepoint_check_flag);
- _smallLinearAllocBlock._ptr = prevEnd;
- _smallLinearAllocBlock._word_size = newFcSize;
- repairLinearAllocBlock(&_smallLinearAllocBlock);
- }
+ MutexLockerEx x(parDictionaryAllocLock(),
+ Mutex::_no_safepoint_check_flag);
+ _smallLinearAllocBlock._ptr = prevEnd;
+ _smallLinearAllocBlock._word_size = newFcSize;
+ repairLinearAllocBlock(&_smallLinearAllocBlock);
// Births of chunks put into a LinAB are not recorded. Births
// of chunks as they are allocated out of a LinAB are.
} else {
@@ -1740,10 +1731,7 @@
assert(chunk != NULL && is_in_reserved(chunk), "Not in this space!");
// One of the parallel gc task threads may be here
// whilst others are allocating.
- Mutex* lock = NULL;
- if (ParallelGCThreads != 0) {
- lock = &_parDictionaryAllocLock;
- }
+ Mutex* lock = &_parDictionaryAllocLock;
FreeChunk* ec;
{
MutexLockerEx x(lock, Mutex::_no_safepoint_check_flag);
@@ -1760,7 +1748,7 @@
}
ec->set_size(size);
debug_only(ec->mangleFreed(size));
- if (size < SmallForDictionary && ParallelGCThreads != 0) {
+ if (size < SmallForDictionary) {
lock = _indexedFreeListParLocks[size];
}
MutexLockerEx x(lock, Mutex::_no_safepoint_check_flag);
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -887,10 +887,8 @@
// along with all the other pointers into the heap but
// compaction is expected to be a rare event with
// a heap using cms so don't do it without seeing the need.
- if (CollectedHeap::use_parallel_gc_threads()) {
- for (uint i = 0; i < ParallelGCThreads; i++) {
- _par_gc_thread_states[i]->promo.reset();
- }
+ for (uint i = 0; i < ParallelGCThreads; i++) {
+ _par_gc_thread_states[i]->promo.reset();
}
}
@@ -2804,10 +2802,8 @@
collector()->gc_epilogue(full);
// Also reset promotion tracking in par gc thread states.
- if (CollectedHeap::use_parallel_gc_threads()) {
- for (uint i = 0; i < ParallelGCThreads; i++) {
- _par_gc_thread_states[i]->promo.stopTrackingPromotions(i);
- }
+ for (uint i = 0; i < ParallelGCThreads; i++) {
+ _par_gc_thread_states[i]->promo.stopTrackingPromotions(i);
}
}
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
+#include "classfile/metadataOnStackMark.hpp"
#include "classfile/symbolTable.hpp"
#include "code/codeCache.hpp"
#include "gc_implementation/g1/concurrentMark.inline.hpp"
@@ -611,74 +612,64 @@
ConcGCThreads, ParallelGCThreads);
return;
}
- if (ParallelGCThreads == 0) {
- // if we are not running with any parallel GC threads we will not
- // spawn any marking threads either
- _parallel_marking_threads = 0;
- _max_parallel_marking_threads = 0;
- _sleep_factor = 0.0;
- _marking_task_overhead = 1.0;
+ if (!FLAG_IS_DEFAULT(ConcGCThreads) && ConcGCThreads > 0) {
+ // Note: ConcGCThreads has precedence over G1MarkingOverheadPercent
+ // if both are set
+ _sleep_factor = 0.0;
+ _marking_task_overhead = 1.0;
+ } else if (G1MarkingOverheadPercent > 0) {
+ // We will calculate the number of parallel marking threads based
+ // on a target overhead with respect to the soft real-time goal
+ double marking_overhead = (double) G1MarkingOverheadPercent / 100.0;
+ double overall_cm_overhead =
+ (double) MaxGCPauseMillis * marking_overhead /
+ (double) GCPauseIntervalMillis;
+ double cpu_ratio = 1.0 / (double) os::processor_count();
+ double marking_thread_num = ceil(overall_cm_overhead / cpu_ratio);
+ double marking_task_overhead =
+ overall_cm_overhead / marking_thread_num *
+ (double) os::processor_count();
+ double sleep_factor =
+ (1.0 - marking_task_overhead) / marking_task_overhead;
+
+ FLAG_SET_ERGO(uintx, ConcGCThreads, (uint) marking_thread_num);
+ _sleep_factor = sleep_factor;
+ _marking_task_overhead = marking_task_overhead;
} else {
- if (!FLAG_IS_DEFAULT(ConcGCThreads) && ConcGCThreads > 0) {
- // Note: ConcGCThreads has precedence over G1MarkingOverheadPercent
- // if both are set
- _sleep_factor = 0.0;
- _marking_task_overhead = 1.0;
- } else if (G1MarkingOverheadPercent > 0) {
- // We will calculate the number of parallel marking threads based
- // on a target overhead with respect to the soft real-time goal
- double marking_overhead = (double) G1MarkingOverheadPercent / 100.0;
- double overall_cm_overhead =
- (double) MaxGCPauseMillis * marking_overhead /
- (double) GCPauseIntervalMillis;
- double cpu_ratio = 1.0 / (double) os::processor_count();
- double marking_thread_num = ceil(overall_cm_overhead / cpu_ratio);
- double marking_task_overhead =
- overall_cm_overhead / marking_thread_num *
- (double) os::processor_count();
- double sleep_factor =
- (1.0 - marking_task_overhead) / marking_task_overhead;
-
- FLAG_SET_ERGO(uintx, ConcGCThreads, (uint) marking_thread_num);
- _sleep_factor = sleep_factor;
- _marking_task_overhead = marking_task_overhead;
- } else {
- // Calculate the number of parallel marking threads by scaling
- // the number of parallel GC threads.
- uint marking_thread_num = scale_parallel_threads((uint) ParallelGCThreads);
- FLAG_SET_ERGO(uintx, ConcGCThreads, marking_thread_num);
- _sleep_factor = 0.0;
- _marking_task_overhead = 1.0;
- }
-
- assert(ConcGCThreads > 0, "Should have been set");
- _parallel_marking_threads = (uint) ConcGCThreads;
- _max_parallel_marking_threads = _parallel_marking_threads;
-
- if (parallel_marking_threads() > 1) {
- _cleanup_task_overhead = 1.0;
- } else {
- _cleanup_task_overhead = marking_task_overhead();
- }
- _cleanup_sleep_factor =
- (1.0 - cleanup_task_overhead()) / cleanup_task_overhead();
+ // Calculate the number of parallel marking threads by scaling
+ // the number of parallel GC threads.
+ uint marking_thread_num = scale_parallel_threads((uint) ParallelGCThreads);
+ FLAG_SET_ERGO(uintx, ConcGCThreads, marking_thread_num);
+ _sleep_factor = 0.0;
+ _marking_task_overhead = 1.0;
+ }
+
+ assert(ConcGCThreads > 0, "Should have been set");
+ _parallel_marking_threads = (uint) ConcGCThreads;
+ _max_parallel_marking_threads = _parallel_marking_threads;
+
+ if (parallel_marking_threads() > 1) {
+ _cleanup_task_overhead = 1.0;
+ } else {
+ _cleanup_task_overhead = marking_task_overhead();
+ }
+ _cleanup_sleep_factor =
+ (1.0 - cleanup_task_overhead()) / cleanup_task_overhead();
#if 0
- gclog_or_tty->print_cr("Marking Threads %d", parallel_marking_threads());
- gclog_or_tty->print_cr("CM Marking Task Overhead %1.4lf", marking_task_overhead());
- gclog_or_tty->print_cr("CM Sleep Factor %1.4lf", sleep_factor());
- gclog_or_tty->print_cr("CL Marking Task Overhead %1.4lf", cleanup_task_overhead());
- gclog_or_tty->print_cr("CL Sleep Factor %1.4lf", cleanup_sleep_factor());
+ gclog_or_tty->print_cr("Marking Threads %d", parallel_marking_threads());
+ gclog_or_tty->print_cr("CM Marking Task Overhead %1.4lf", marking_task_overhead());
+ gclog_or_tty->print_cr("CM Sleep Factor %1.4lf", sleep_factor());
+ gclog_or_tty->print_cr("CL Marking Task Overhead %1.4lf", cleanup_task_overhead());
+ gclog_or_tty->print_cr("CL Sleep Factor %1.4lf", cleanup_sleep_factor());
#endif
- guarantee(parallel_marking_threads() > 0, "peace of mind");
- _parallel_workers = new FlexibleWorkGang("G1 Parallel Marking Threads",
- _max_parallel_marking_threads, false, true);
- if (_parallel_workers == NULL) {
- vm_exit_during_initialization("Failed necessary allocation.");
- } else {
- _parallel_workers->initialize_workers();
- }
+ _parallel_workers = new FlexibleWorkGang("G1 Parallel Marking Threads",
+ _max_parallel_marking_threads, false, true);
+ if (_parallel_workers == NULL) {
+ vm_exit_during_initialization("Failed necessary allocation.");
+ } else {
+ _parallel_workers->initialize_workers();
}
if (FLAG_IS_DEFAULT(MarkStackSize)) {
@@ -1166,29 +1157,23 @@
// Calculates the number of active workers for a concurrent
// phase.
uint ConcurrentMark::calc_parallel_marking_threads() {
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- uint n_conc_workers = 0;
- if (!UseDynamicNumberOfGCThreads ||
- (!FLAG_IS_DEFAULT(ConcGCThreads) &&
- !ForceDynamicNumberOfGCThreads)) {
- n_conc_workers = max_parallel_marking_threads();
- } else {
- n_conc_workers =
- AdaptiveSizePolicy::calc_default_active_workers(
- max_parallel_marking_threads(),
- 1, /* Minimum workers */
- parallel_marking_threads(),
- Threads::number_of_non_daemon_threads());
- // Don't scale down "n_conc_workers" by scale_parallel_threads() because
- // that scaling has already gone into "_max_parallel_marking_threads".
- }
- assert(n_conc_workers > 0, "Always need at least 1");
- return n_conc_workers;
+ uint n_conc_workers = 0;
+ if (!UseDynamicNumberOfGCThreads ||
+ (!FLAG_IS_DEFAULT(ConcGCThreads) &&
+ !ForceDynamicNumberOfGCThreads)) {
+ n_conc_workers = max_parallel_marking_threads();
+ } else {
+ n_conc_workers =
+ AdaptiveSizePolicy::calc_default_active_workers(
+ max_parallel_marking_threads(),
+ 1, /* Minimum workers */
+ parallel_marking_threads(),
+ Threads::number_of_non_daemon_threads());
+ // Don't scale down "n_conc_workers" by scale_parallel_threads() because
+ // that scaling has already gone into "_max_parallel_marking_threads".
}
- // If we are not running with any parallel GC threads we will not
- // have spawned any marking threads either. Hence the number of
- // concurrent workers should be 0.
- return 0;
+ assert(n_conc_workers > 0, "Always need at least 1");
+ return n_conc_workers;
}
void ConcurrentMark::scanRootRegion(HeapRegion* hr, uint worker_id) {
@@ -1243,12 +1228,8 @@
uint active_workers = MAX2(1U, parallel_marking_threads());
CMRootRegionScanTask task(this);
- if (use_parallel_marking_threads()) {
- _parallel_workers->set_active_workers((int) active_workers);
- _parallel_workers->run_task(&task);
- } else {
- task.work(0);
- }
+ _parallel_workers->set_active_workers(active_workers);
+ _parallel_workers->run_task(&task);
// It's possible that has_aborted() is true here without actually
// aborting the survivor scan earlier. This is OK as it's
@@ -1279,15 +1260,11 @@
set_concurrency_and_phase(active_workers, true /* concurrent */);
CMConcurrentMarkingTask markingTask(this, cmThread());
- if (use_parallel_marking_threads()) {
- _parallel_workers->set_active_workers((int)active_workers);
- // Don't set _n_par_threads because it affects MT in process_roots()
- // and the decisions on that MT processing is made elsewhere.
- assert(_parallel_workers->active_workers() > 0, "Should have been set");
- _parallel_workers->run_task(&markingTask);
- } else {
- markingTask.work(0);
- }
+ _parallel_workers->set_active_workers(active_workers);
+ // Don't set _n_par_threads because it affects MT in process_roots()
+ // and the decisions on that MT processing is made elsewhere.
+ assert(_parallel_workers->active_workers() > 0, "Should have been set");
+ _parallel_workers->run_task(&markingTask);
print_stats();
}
@@ -1714,11 +1691,7 @@
_expected_card_bm,
_verbose);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- _g1h->heap_region_par_iterate(&verify_cl, worker_id, &_hrclaimer);
- } else {
- _g1h->heap_region_iterate(&verify_cl);
- }
+ _g1h->heap_region_par_iterate(&verify_cl, worker_id, &_hrclaimer);
Atomic::add(verify_cl.failures(), &_failures);
}
@@ -1821,11 +1794,7 @@
_actual_region_bm,
_actual_card_bm);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- _g1h->heap_region_par_iterate(&final_update_cl, worker_id, &_hrclaimer);
- } else {
- _g1h->heap_region_iterate(&final_update_cl);
- }
+ _g1h->heap_region_par_iterate(&final_update_cl, worker_id, &_hrclaimer);
}
};
@@ -1922,11 +1891,7 @@
HRRSCleanupTask hrrs_cleanup_task;
G1NoteEndOfConcMarkClosure g1_note_end(_g1h, &local_cleanup_list,
&hrrs_cleanup_task);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- _g1h->heap_region_par_iterate(&g1_note_end, worker_id, &_hrclaimer);
- } else {
- _g1h->heap_region_iterate(&g1_note_end);
- }
+ _g1h->heap_region_par_iterate(&g1_note_end, worker_id, &_hrclaimer);
assert(g1_note_end.complete(), "Shouldn't have yielded!");
// Now update the lists
@@ -1977,11 +1942,7 @@
}
void work(uint worker_id) {
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- _g1rs->scrub_par(_region_bm, _card_bm, worker_id, &_hrclaimer);
- } else {
- _g1rs->scrub(_region_bm, _card_bm);
- }
+ _g1rs->scrub(_region_bm, _card_bm, worker_id, &_hrclaimer);
}
};
@@ -2020,18 +1981,13 @@
// Do counting once more with the world stopped for good measure.
G1ParFinalCountTask g1_par_count_task(g1h, &_region_bm, &_card_bm);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- g1h->set_par_threads();
- n_workers = g1h->n_par_threads();
- assert(g1h->n_par_threads() == n_workers,
- "Should not have been reset");
- g1h->workers()->run_task(&g1_par_count_task);
- // Done with the parallel phase so reset to 0.
- g1h->set_par_threads(0);
- } else {
- n_workers = 1;
- g1_par_count_task.work(0);
- }
+ g1h->set_par_threads();
+ n_workers = g1h->n_par_threads();
+ assert(g1h->n_par_threads() == n_workers,
+ "Should not have been reset");
+ g1h->workers()->run_task(&g1_par_count_task);
+ // Done with the parallel phase so reset to 0.
+ g1h->set_par_threads(0);
if (VerifyDuringGC) {
// Verify that the counting data accumulated during marking matches
@@ -2047,14 +2003,10 @@
&expected_region_bm,
&expected_card_bm);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- g1h->set_par_threads((int)n_workers);
- g1h->workers()->run_task(&g1_par_verify_task);
- // Done with the parallel phase so reset to 0.
- g1h->set_par_threads(0);
- } else {
- g1_par_verify_task.work(0);
- }
+ g1h->set_par_threads((int)n_workers);
+ g1h->workers()->run_task(&g1_par_verify_task);
+ // Done with the parallel phase so reset to 0.
+ g1h->set_par_threads(0);
guarantee(g1_par_verify_task.failures() == 0, "Unexpected accounting failures");
}
@@ -2078,13 +2030,9 @@
// Note end of marking in all heap regions.
G1ParNoteEndTask g1_par_note_end_task(g1h, &_cleanup_list, n_workers);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- g1h->set_par_threads((int)n_workers);
- g1h->workers()->run_task(&g1_par_note_end_task);
- g1h->set_par_threads(0);
- } else {
- g1_par_note_end_task.work(0);
- }
+ g1h->set_par_threads((int)n_workers);
+ g1h->workers()->run_task(&g1_par_note_end_task);
+ g1h->set_par_threads(0);
g1h->check_gc_time_stamps();
if (!cleanup_list_is_empty()) {
@@ -2099,13 +2047,9 @@
if (G1ScrubRemSets) {
double rs_scrub_start = os::elapsedTime();
G1ParScrubRemSetTask g1_par_scrub_rs_task(g1h, &_region_bm, &_card_bm, n_workers);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- g1h->set_par_threads((int)n_workers);
- g1h->workers()->run_task(&g1_par_scrub_rs_task);
- g1h->set_par_threads(0);
- } else {
- g1_par_scrub_rs_task.work(0);
- }
+ g1h->set_par_threads((int)n_workers);
+ g1h->workers()->run_task(&g1_par_scrub_rs_task);
+ g1h->set_par_threads(0);
double rs_scrub_end = os::elapsedTime();
double this_rs_scrub_time = (rs_scrub_end - rs_scrub_start);
@@ -2502,7 +2446,7 @@
// is not multi-threaded we use the current (VMThread) thread,
// otherwise we use the work gang from the G1CollectedHeap and
// we utilize all the worker threads we can.
- bool processing_is_mt = rp->processing_is_mt() && g1h->workers() != NULL;
+ bool processing_is_mt = rp->processing_is_mt();
uint active_workers = (processing_is_mt ? g1h->workers()->active_workers() : 1U);
active_workers = MAX2(MIN2(active_workers, _max_worker_id), 1U);
@@ -2564,17 +2508,27 @@
G1CMTraceTime trace("Unloading", G1Log::finer());
if (ClassUnloadingWithConcurrentMark) {
+ // Cleaning of klasses depends on correct information from MetadataMarkOnStack. The CodeCache::mark_on_stack
+ // part is too slow to be done serially, so it is handled during the weakRefsWorkParallelPart phase.
+ // Defer the cleaning until we have complete on_stack data.
+ MetadataOnStackMark md_on_stack(false /* Don't visit the code cache at this point */);
+
bool purged_classes;
{
G1CMTraceTime trace("System Dictionary Unloading", G1Log::finest());
- purged_classes = SystemDictionary::do_unloading(&g1_is_alive);
+ purged_classes = SystemDictionary::do_unloading(&g1_is_alive, false /* Defer klass cleaning */);
}
{
G1CMTraceTime trace("Parallel Unloading", G1Log::finest());
weakRefsWorkParallelPart(&g1_is_alive, purged_classes);
}
+
+ {
+ G1CMTraceTime trace("Deallocate Metadata", G1Log::finest());
+ ClassLoaderDataGraph::free_deallocate_lists();
+ }
}
if (G1StringDedup::is_enabled()) {
@@ -2611,16 +2565,15 @@
G1CMOopClosure _cm_cl;
MarkingCodeBlobClosure _code_cl;
int _thread_parity;
- bool _is_par;
public:
- G1RemarkThreadsClosure(G1CollectedHeap* g1h, CMTask* task, bool is_par) :
+ G1RemarkThreadsClosure(G1CollectedHeap* g1h, CMTask* task) :
_cm_obj(task), _cm_cl(g1h, g1h->concurrent_mark(), task), _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations),
- _thread_parity(SharedHeap::heap()->strong_roots_parity()), _is_par(is_par) {}
+ _thread_parity(SharedHeap::heap()->strong_roots_parity()) {}
void do_thread(Thread* thread) {
if (thread->is_Java_thread()) {
- if (thread->claim_oops_do(_is_par, _thread_parity)) {
+ if (thread->claim_oops_do(true, _thread_parity)) {
JavaThread* jt = (JavaThread*)thread;
// In theory it should not be neccessary to explicitly walk the nmethods to find roots for concurrent marking
@@ -2634,7 +2587,7 @@
jt->satb_mark_queue().apply_closure_and_empty(&_cm_obj);
}
} else if (thread->is_VM_thread()) {
- if (thread->claim_oops_do(_is_par, _thread_parity)) {
+ if (thread->claim_oops_do(true, _thread_parity)) {
JavaThread::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(&_cm_obj);
}
}
@@ -2644,7 +2597,6 @@
class CMRemarkTask: public AbstractGangTask {
private:
ConcurrentMark* _cm;
- bool _is_serial;
public:
void work(uint worker_id) {
// Since all available tasks are actually started, we should
@@ -2656,14 +2608,14 @@
ResourceMark rm;
HandleMark hm;
- G1RemarkThreadsClosure threads_f(G1CollectedHeap::heap(), task, !_is_serial);
+ G1RemarkThreadsClosure threads_f(G1CollectedHeap::heap(), task);
Threads::threads_do(&threads_f);
}
do {
task->do_marking_step(1000000000.0 /* something very large */,
true /* do_termination */,
- _is_serial);
+ false /* is_serial */);
} while (task->has_aborted() && !_cm->has_overflown());
// If we overflow, then we do not want to restart. We instead
// want to abort remark and do concurrent marking again.
@@ -2671,8 +2623,8 @@
}
}
- CMRemarkTask(ConcurrentMark* cm, int active_workers, bool is_serial) :
- AbstractGangTask("Par Remark"), _cm(cm), _is_serial(is_serial) {
+ CMRemarkTask(ConcurrentMark* cm, int active_workers) :
+ AbstractGangTask("Par Remark"), _cm(cm) {
_cm->terminator()->reset_for_reuse(active_workers);
}
};
@@ -2686,43 +2638,28 @@
g1h->ensure_parsability(false);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- G1CollectedHeap::StrongRootsScope srs(g1h);
- // this is remark, so we'll use up all active threads
- uint active_workers = g1h->workers()->active_workers();
- if (active_workers == 0) {
- assert(active_workers > 0, "Should have been set earlier");
- active_workers = (uint) ParallelGCThreads;
- g1h->workers()->set_active_workers(active_workers);
- }
- set_concurrency_and_phase(active_workers, false /* concurrent */);
- // Leave _parallel_marking_threads at it's
- // value originally calculated in the ConcurrentMark
- // constructor and pass values of the active workers
- // through the gang in the task.
-
- CMRemarkTask remarkTask(this, active_workers, false /* is_serial */);
- // We will start all available threads, even if we decide that the
- // active_workers will be fewer. The extra ones will just bail out
- // immediately.
- g1h->set_par_threads(active_workers);
- g1h->workers()->run_task(&remarkTask);
- g1h->set_par_threads(0);
- } else {
- G1CollectedHeap::StrongRootsScope srs(g1h);
- uint active_workers = 1;
- set_concurrency_and_phase(active_workers, false /* concurrent */);
-
- // Note - if there's no work gang then the VMThread will be
- // the thread to execute the remark - serially. We have
- // to pass true for the is_serial parameter so that
- // CMTask::do_marking_step() doesn't enter the sync
- // barriers in the event of an overflow. Doing so will
- // cause an assert that the current thread is not a
- // concurrent GC thread.
- CMRemarkTask remarkTask(this, active_workers, true /* is_serial*/);
- remarkTask.work(0);
+ G1CollectedHeap::StrongRootsScope srs(g1h);
+ // this is remark, so we'll use up all active threads
+ uint active_workers = g1h->workers()->active_workers();
+ if (active_workers == 0) {
+ assert(active_workers > 0, "Should have been set earlier");
+ active_workers = (uint) ParallelGCThreads;
+ g1h->workers()->set_active_workers(active_workers);
}
+ set_concurrency_and_phase(active_workers, false /* concurrent */);
+ // Leave _parallel_marking_threads at it's
+ // value originally calculated in the ConcurrentMark
+ // constructor and pass values of the active workers
+ // through the gang in the task.
+
+ CMRemarkTask remarkTask(this, active_workers);
+ // We will start all available threads, even if we decide that the
+ // active_workers will be fewer. The extra ones will just bail out
+ // immediately.
+ g1h->set_par_threads(active_workers);
+ g1h->workers()->run_task(&remarkTask);
+ g1h->set_par_threads(0);
+
SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
guarantee(has_overflown() ||
satb_mq_set.completed_buffers_num() == 0,
@@ -3268,30 +3205,20 @@
void work(uint worker_id) {
AggregateCountDataHRClosure cl(_g1h, _cm_card_bm, _max_worker_id);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- _g1h->heap_region_par_iterate(&cl, worker_id, &_hrclaimer);
- } else {
- _g1h->heap_region_iterate(&cl);
- }
+ _g1h->heap_region_par_iterate(&cl, worker_id, &_hrclaimer);
}
};
void ConcurrentMark::aggregate_count_data() {
- int n_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
- _g1h->workers()->active_workers() :
- 1);
+ int n_workers = _g1h->workers()->active_workers();
G1AggregateCountDataTask g1_par_agg_task(_g1h, this, &_card_bm,
_max_worker_id, n_workers);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- _g1h->set_par_threads(n_workers);
- _g1h->workers()->run_task(&g1_par_agg_task);
- _g1h->set_par_threads(0);
- } else {
- g1_par_agg_task.work(0);
- }
+ _g1h->set_par_threads(n_workers);
+ _g1h->workers()->run_task(&g1_par_agg_task);
+ _g1h->set_par_threads(0);
_g1h->allocation_context_stats().update_at_remark();
}
@@ -3419,9 +3346,7 @@
}
void ConcurrentMark::print_worker_threads_on(outputStream* st) const {
- if (use_parallel_marking_threads()) {
- _parallel_workers->print_worker_threads_on(st);
- }
+ _parallel_workers->print_worker_threads_on(st);
}
void ConcurrentMark::print_on_error(outputStream* st) const {
@@ -3942,32 +3867,17 @@
CMObjectClosure oc(this);
SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- satb_mq_set.set_par_closure(_worker_id, &oc);
- } else {
- satb_mq_set.set_closure(&oc);
- }
+ satb_mq_set.set_closure(_worker_id, &oc);
// This keeps claiming and applying the closure to completed buffers
// until we run out of buffers or we need to abort.
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- while (!has_aborted() &&
- satb_mq_set.par_apply_closure_to_completed_buffer(_worker_id)) {
- if (_cm->verbose_medium()) {
- gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id);
- }
- statsOnly( ++_satb_buffers_processed );
- regular_clock_call();
+ while (!has_aborted() &&
+ satb_mq_set.apply_closure_to_completed_buffer(_worker_id)) {
+ if (_cm->verbose_medium()) {
+ gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id);
}
- } else {
- while (!has_aborted() &&
- satb_mq_set.apply_closure_to_completed_buffer()) {
- if (_cm->verbose_medium()) {
- gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id);
- }
- statsOnly( ++_satb_buffers_processed );
- regular_clock_call();
- }
+ statsOnly( ++_satb_buffers_processed );
+ regular_clock_call();
}
_draining_satb_buffers = false;
@@ -3976,11 +3886,7 @@
concurrent() ||
satb_mq_set.completed_buffers_num() == 0, "invariant");
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- satb_mq_set.set_par_closure(_worker_id, NULL);
- } else {
- satb_mq_set.set_closure(NULL);
- }
+ satb_mq_set.set_closure(_worker_id, NULL);
// again, this was a potentially expensive operation, decrease the
// limits to get the regular clock call early
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -519,15 +519,6 @@
double cleanup_sleep_factor() { return _cleanup_sleep_factor; }
double cleanup_task_overhead() { return _cleanup_task_overhead;}
- bool use_parallel_marking_threads() const {
- assert(parallel_marking_threads() <=
- max_parallel_marking_threads(), "sanity");
- assert((_parallel_workers == NULL && parallel_marking_threads() == 0) ||
- parallel_marking_threads() > 0,
- "parallel workers not set up correctly");
- return _parallel_workers != NULL;
- }
-
HeapWord* finger() { return _finger; }
bool concurrent() { return _concurrent; }
uint active_tasks() { return _active_tasks; }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -28,6 +28,7 @@
#endif
#include "precompiled.hpp"
+#include "classfile/metadataOnStackMark.hpp"
#include "classfile/stringTable.hpp"
#include "code/codeCache.hpp"
#include "code/icBuffer.hpp"
@@ -1438,36 +1439,31 @@
}
// Rebuild remembered sets of all regions.
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- uint n_workers =
- AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
- workers()->active_workers(),
- Threads::number_of_non_daemon_threads());
- assert(UseDynamicNumberOfGCThreads ||
- n_workers == workers()->total_workers(),
- "If not dynamic should be using all the workers");
- workers()->set_active_workers(n_workers);
- // Set parallel threads in the heap (_n_par_threads) only
- // before a parallel phase and always reset it to 0 after
- // the phase so that the number of parallel threads does
- // no get carried forward to a serial phase where there
- // may be code that is "possibly_parallel".
- set_par_threads(n_workers);
-
- ParRebuildRSTask rebuild_rs_task(this);
- assert(UseDynamicNumberOfGCThreads ||
- workers()->active_workers() == workers()->total_workers(),
- "Unless dynamic should use total workers");
- // Use the most recent number of active workers
- assert(workers()->active_workers() > 0,
- "Active workers not properly set");
- set_par_threads(workers()->active_workers());
- workers()->run_task(&rebuild_rs_task);
- set_par_threads(0);
- } else {
- RebuildRSOutOfRegionClosure rebuild_rs(this);
- heap_region_iterate(&rebuild_rs);
- }
+ uint n_workers =
+ AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
+ workers()->active_workers(),
+ Threads::number_of_non_daemon_threads());
+ assert(UseDynamicNumberOfGCThreads ||
+ n_workers == workers()->total_workers(),
+ "If not dynamic should be using all the workers");
+ workers()->set_active_workers(n_workers);
+ // Set parallel threads in the heap (_n_par_threads) only
+ // before a parallel phase and always reset it to 0 after
+ // the phase so that the number of parallel threads does
+ // no get carried forward to a serial phase where there
+ // may be code that is "possibly_parallel".
+ set_par_threads(n_workers);
+
+ ParRebuildRSTask rebuild_rs_task(this);
+ assert(UseDynamicNumberOfGCThreads ||
+ workers()->active_workers() == workers()->total_workers(),
+ "Unless dynamic should use total workers");
+ // Use the most recent number of active workers
+ assert(workers()->active_workers() > 0,
+ "Active workers not properly set");
+ set_par_threads(workers()->active_workers());
+ workers()->run_task(&rebuild_rs_task);
+ set_par_threads(0);
// Rebuild the strong code root lists for each region
rebuild_strong_code_roots();
@@ -2482,6 +2478,7 @@
unsigned int gc_count_before;
unsigned int old_marking_count_before;
+ unsigned int full_gc_count_before;
bool retry_gc;
do {
@@ -2492,6 +2489,7 @@
// Read the GC count while holding the Heap_lock
gc_count_before = total_collections();
+ full_gc_count_before = total_full_collections();
old_marking_count_before = _old_marking_cycles_started;
}
@@ -2536,7 +2534,7 @@
VMThread::execute(&op);
} else {
// Schedule a Full GC.
- VM_G1CollectFull op(gc_count_before, old_marking_count_before, cause);
+ VM_G1CollectFull op(gc_count_before, full_gc_count_before, cause);
VMThread::execute(&op);
}
}
@@ -2678,27 +2676,25 @@
// Then thread t will start at region floor ((t * n) / p)
result = g1_policy()->collection_set();
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- uint cs_size = g1_policy()->cset_region_length();
- uint active_workers = workers()->active_workers();
- assert(UseDynamicNumberOfGCThreads ||
- active_workers == workers()->total_workers(),
- "Unless dynamic should use total workers");
-
- uint end_ind = (cs_size * worker_i) / active_workers;
- uint start_ind = 0;
-
- if (worker_i > 0 &&
- _worker_cset_start_region_time_stamp[worker_i - 1] == gc_time_stamp) {
- // Previous workers starting region is valid
- // so let's iterate from there
- start_ind = (cs_size * (worker_i - 1)) / active_workers;
- result = _worker_cset_start_region[worker_i - 1];
- }
-
- for (uint i = start_ind; i < end_ind; i++) {
- result = result->next_in_collection_set();
- }
+ uint cs_size = g1_policy()->cset_region_length();
+ uint active_workers = workers()->active_workers();
+ assert(UseDynamicNumberOfGCThreads ||
+ active_workers == workers()->total_workers(),
+ "Unless dynamic should use total workers");
+
+ uint end_ind = (cs_size * worker_i) / active_workers;
+ uint start_ind = 0;
+
+ if (worker_i > 0 &&
+ _worker_cset_start_region_time_stamp[worker_i - 1] == gc_time_stamp) {
+ // Previous workers starting region is valid
+ // so let's iterate from there
+ start_ind = (cs_size * (worker_i - 1)) / active_workers;
+ result = _worker_cset_start_region[worker_i - 1];
+ }
+
+ for (uint i = start_ind; i < end_ind; i++) {
+ result = result->next_in_collection_set();
}
// Note: the calculated starting heap region may be NULL
@@ -3373,9 +3369,7 @@
}
void G1CollectedHeap::print_gc_threads_on(outputStream* st) const {
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- workers()->print_worker_threads_on(st);
- }
+ workers()->print_worker_threads_on(st);
_cmThread->print_on(st);
st->cr();
_cm->print_worker_threads_on(st);
@@ -3386,9 +3380,7 @@
}
void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const {
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- workers()->threads_do(tc);
- }
+ workers()->threads_do(tc);
tc->do_thread(_cmThread);
_cg1r->threads_do(tc);
if (G1StringDedup::is_enabled()) {
@@ -3683,7 +3675,7 @@
print_taskqueue_stats_hdr(st);
TaskQueueStats totals;
- const int n = workers() != NULL ? workers()->total_workers() : 1;
+ const int n = workers()->total_workers();
for (int i = 0; i < n; ++i) {
st->print("%3d ", i); task_queue(i)->stats.print(st); st->cr();
totals += task_queue(i)->stats;
@@ -3694,7 +3686,7 @@
}
void G1CollectedHeap::reset_taskqueue_stats() {
- const int n = workers() != NULL ? workers()->total_workers() : 1;
+ const int n = workers()->total_workers();
for (int i = 0; i < n; ++i) {
task_queue(i)->stats.reset();
}
@@ -3792,8 +3784,7 @@
TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
- int active_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
- workers()->active_workers() : 1);
+ int active_workers = workers()->active_workers();
double pause_start_sec = os::elapsedTime();
g1_policy()->phase_times()->note_gc_start(active_workers);
log_gc_header();
@@ -4787,12 +4778,10 @@
int _symbols_processed;
int _symbols_removed;
- bool _do_in_parallel;
public:
G1StringSymbolTableUnlinkTask(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols) :
AbstractGangTask("String/Symbol Unlinking"),
_is_alive(is_alive),
- _do_in_parallel(G1CollectedHeap::use_parallel_gc_threads()),
_process_strings(process_strings), _strings_processed(0), _strings_removed(0),
_process_symbols(process_symbols), _symbols_processed(0), _symbols_removed(0) {
@@ -4807,10 +4796,10 @@
}
~G1StringSymbolTableUnlinkTask() {
- guarantee(!_process_strings || !_do_in_parallel || StringTable::parallel_claimed_index() >= _initial_string_table_size,
+ guarantee(!_process_strings || StringTable::parallel_claimed_index() >= _initial_string_table_size,
err_msg("claim value %d after unlink less than initial string table size %d",
StringTable::parallel_claimed_index(), _initial_string_table_size));
- guarantee(!_process_symbols || !_do_in_parallel || SymbolTable::parallel_claimed_index() >= _initial_symbol_table_size,
+ guarantee(!_process_symbols || SymbolTable::parallel_claimed_index() >= _initial_symbol_table_size,
err_msg("claim value %d after unlink less than initial symbol table size %d",
SymbolTable::parallel_claimed_index(), _initial_symbol_table_size));
@@ -4824,28 +4813,19 @@
}
void work(uint worker_id) {
- if (_do_in_parallel) {
- int strings_processed = 0;
- int strings_removed = 0;
- int symbols_processed = 0;
- int symbols_removed = 0;
- if (_process_strings) {
- StringTable::possibly_parallel_unlink(_is_alive, &strings_processed, &strings_removed);
- Atomic::add(strings_processed, &_strings_processed);
- Atomic::add(strings_removed, &_strings_removed);
- }
- if (_process_symbols) {
- SymbolTable::possibly_parallel_unlink(&symbols_processed, &symbols_removed);
- Atomic::add(symbols_processed, &_symbols_processed);
- Atomic::add(symbols_removed, &_symbols_removed);
- }
- } else {
- if (_process_strings) {
- StringTable::unlink(_is_alive, &_strings_processed, &_strings_removed);
- }
- if (_process_symbols) {
- SymbolTable::unlink(&_symbols_processed, &_symbols_removed);
- }
+ int strings_processed = 0;
+ int strings_removed = 0;
+ int symbols_processed = 0;
+ int symbols_removed = 0;
+ if (_process_strings) {
+ StringTable::possibly_parallel_unlink(_is_alive, &strings_processed, &strings_removed);
+ Atomic::add(strings_processed, &_strings_processed);
+ Atomic::add(strings_removed, &_strings_removed);
+ }
+ if (_process_symbols) {
+ SymbolTable::possibly_parallel_unlink(&symbols_processed, &symbols_removed);
+ Atomic::add(symbols_processed, &_symbols_processed);
+ Atomic::add(symbols_removed, &_symbols_removed);
}
}
@@ -5013,6 +4993,10 @@
clean_nmethod(claimed_nmethods[i]);
}
}
+
+ // The nmethod cleaning helps out and does the CodeCache part of MetadataOnStackMark.
+ // Need to retire the buffers now that this thread has stopped cleaning nmethods.
+ MetadataOnStackMark::retire_buffer_for_thread(Thread::current());
}
void work_second_pass(uint worker_id) {
@@ -5065,6 +5049,9 @@
// G1 specific cleanup work that has
// been moved here to be done in parallel.
ik->clean_dependent_nmethods();
+ if (JvmtiExport::has_redefined_a_class()) {
+ InstanceKlass::purge_previous_versions(ik);
+ }
}
void work() {
@@ -5099,8 +5086,18 @@
_klass_cleaning_task(is_alive) {
}
+ void pre_work_verification() {
+ assert(!MetadataOnStackMark::has_buffer_for_thread(Thread::current()), "Should be empty");
+ }
+
+ void post_work_verification() {
+ assert(!MetadataOnStackMark::has_buffer_for_thread(Thread::current()), "Should be empty");
+ }
+
// The parallel work done by all worker threads.
void work(uint worker_id) {
+ pre_work_verification();
+
// Do first pass of code cache cleaning.
_code_cache_task.work_first_pass(worker_id);
@@ -5119,6 +5116,8 @@
// Clean all klasses that were not unloaded.
_klass_cleaning_task.work();
+
+ post_work_verification();
}
};
@@ -5127,33 +5126,23 @@
bool process_strings,
bool process_symbols,
bool class_unloading_occurred) {
- uint n_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
- workers()->active_workers() : 1);
+ uint n_workers = workers()->active_workers();
G1ParallelCleaningTask g1_unlink_task(is_alive, process_strings, process_symbols,
n_workers, class_unloading_occurred);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- set_par_threads(n_workers);
- workers()->run_task(&g1_unlink_task);
- set_par_threads(0);
- } else {
- g1_unlink_task.work(0);
- }
+ set_par_threads(n_workers);
+ workers()->run_task(&g1_unlink_task);
+ set_par_threads(0);
}
void G1CollectedHeap::unlink_string_and_symbol_table(BoolObjectClosure* is_alive,
bool process_strings, bool process_symbols) {
{
- uint n_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
- _g1h->workers()->active_workers() : 1);
+ uint n_workers = _g1h->workers()->active_workers();
G1StringSymbolTableUnlinkTask g1_unlink_task(is_alive, process_strings, process_symbols);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- set_par_threads(n_workers);
- workers()->run_task(&g1_unlink_task);
- set_par_threads(0);
- } else {
- g1_unlink_task.work(0);
- }
+ set_par_threads(n_workers);
+ workers()->run_task(&g1_unlink_task);
+ set_par_threads(0);
}
if (G1StringDedup::is_enabled()) {
@@ -5171,11 +5160,7 @@
double start_time = os::elapsedTime();
RedirtyLoggedCardTableEntryClosure cl;
- if (G1CollectedHeap::heap()->use_parallel_gc_threads()) {
- _queue->par_apply_closure_to_all_completed_buffers(&cl);
- } else {
- _queue->apply_closure_to_all_completed_buffers(&cl);
- }
+ _queue->par_apply_closure_to_all_completed_buffers(&cl);
G1GCPhaseTimes* timer = G1CollectedHeap::heap()->g1_policy()->phase_times();
timer->record_redirty_logged_cards_time_ms(worker_id, (os::elapsedTime() - start_time) * 1000.0);
@@ -5186,18 +5171,13 @@
void G1CollectedHeap::redirty_logged_cards() {
double redirty_logged_cards_start = os::elapsedTime();
- uint n_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
- _g1h->workers()->active_workers() : 1);
+ uint n_workers = _g1h->workers()->active_workers();
G1RedirtyLoggedCardsTask redirty_task(&dirty_card_queue_set());
dirty_card_queue_set().reset_for_par_iteration();
- if (use_parallel_gc_threads()) {
- set_par_threads(n_workers);
- workers()->run_task(&redirty_task);
- set_par_threads(0);
- } else {
- redirty_task.work(0);
- }
+ set_par_threads(n_workers);
+ workers()->run_task(&redirty_task);
+ set_par_threads(0);
DirtyCardQueueSet& dcq = JavaThread::dirty_card_queue_set();
dcq.merge_bufferlists(&dirty_card_queue_set());
@@ -5587,20 +5567,14 @@
// referents points to another object which is also referenced by an
// object discovered by the STW ref processor.
- assert(!G1CollectedHeap::use_parallel_gc_threads() ||
- no_of_gc_workers == workers()->active_workers(),
- "Need to reset active GC workers");
+ assert(no_of_gc_workers == workers()->active_workers(), "Need to reset active GC workers");
set_par_threads(no_of_gc_workers);
G1ParPreserveCMReferentsTask keep_cm_referents(this,
no_of_gc_workers,
_task_queues);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- workers()->run_task(&keep_cm_referents);
- } else {
- keep_cm_referents.work(0);
- }
+ workers()->run_task(&keep_cm_referents);
set_par_threads(0);
@@ -5727,21 +5701,15 @@
hot_card_cache->set_use_cache(false);
uint n_workers;
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- n_workers =
- AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
- workers()->active_workers(),
- Threads::number_of_non_daemon_threads());
- assert(UseDynamicNumberOfGCThreads ||
- n_workers == workers()->total_workers(),
- "If not dynamic should be using all the workers");
- workers()->set_active_workers(n_workers);
- set_par_threads(n_workers);
- } else {
- assert(n_par_threads() == 0,
- "Should be the original non-parallel value");
- n_workers = 1;
- }
+ n_workers =
+ AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
+ workers()->active_workers(),
+ Threads::number_of_non_daemon_threads());
+ assert(UseDynamicNumberOfGCThreads ||
+ n_workers == workers()->total_workers(),
+ "If not dynamic should be using all the workers");
+ workers()->set_active_workers(n_workers);
+ set_par_threads(n_workers);
G1ParTask g1_par_task(this, _task_queues);
@@ -5760,18 +5728,13 @@
ClassLoaderDataGraph::clear_claimed_marks();
}
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- // The individual threads will set their evac-failure closures.
- if (PrintTerminationStats) G1ParScanThreadState::print_termination_stats_hdr();
- // These tasks use ShareHeap::_process_strong_tasks
- assert(UseDynamicNumberOfGCThreads ||
- workers()->active_workers() == workers()->total_workers(),
- "If not dynamic should be using all the workers");
- workers()->run_task(&g1_par_task);
- } else {
- g1_par_task.set_for_termination(n_workers);
- g1_par_task.work(0);
- }
+ // The individual threads will set their evac-failure closures.
+ if (PrintTerminationStats) G1ParScanThreadState::print_termination_stats_hdr();
+ // These tasks use ShareHeap::_process_strong_tasks
+ assert(UseDynamicNumberOfGCThreads ||
+ workers()->active_workers() == workers()->total_workers(),
+ "If not dynamic should be using all the workers");
+ workers()->run_task(&g1_par_task);
end_par_time_sec = os::elapsedTime();
// Closing the inner scope will execute the destructor
@@ -6077,22 +6040,9 @@
// Iterate over the dirty cards region list.
G1ParCleanupCTTask cleanup_task(ct_bs, this);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- set_par_threads();
- workers()->run_task(&cleanup_task);
- set_par_threads(0);
- } else {
- while (_dirty_cards_region_list) {
- HeapRegion* r = _dirty_cards_region_list;
- cleanup_task.clear_cards(r);
- _dirty_cards_region_list = r->get_next_dirty_cards_region();
- if (_dirty_cards_region_list == r) {
- // The last region.
- _dirty_cards_region_list = NULL;
- }
- r->set_next_dirty_cards_region(NULL);
- }
- }
+ set_par_threads();
+ workers()->run_task(&cleanup_task);
+ set_par_threads(0);
#ifndef PRODUCT
if (G1VerifyCTCleanup || VerifyAfterGC) {
G1VerifyCardTableCleanup cleanup_verifier(this, ct_bs);
@@ -6632,7 +6582,6 @@
void G1CollectedHeap::set_par_threads() {
// Don't change the number of workers. Use the value previously set
// in the workgroup.
- assert(G1CollectedHeap::use_parallel_gc_threads(), "shouldn't be here otherwise");
uint n_workers = workers()->active_workers();
assert(UseDynamicNumberOfGCThreads ||
n_workers == workers()->total_workers(),
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -84,8 +84,7 @@
};
G1CollectorPolicy::G1CollectorPolicy() :
- _parallel_gc_threads(G1CollectedHeap::use_parallel_gc_threads()
- ? ParallelGCThreads : 1),
+ _parallel_gc_threads(ParallelGCThreads),
_recent_gc_times_ms(new TruncatedSeq(NumPrevPausesForHeuristics)),
_stop_world_start(0.0),
@@ -1544,32 +1543,6 @@
}
}
-class KnownGarbageClosure: public HeapRegionClosure {
- G1CollectedHeap* _g1h;
- CollectionSetChooser* _hrSorted;
-
-public:
- KnownGarbageClosure(CollectionSetChooser* hrSorted) :
- _g1h(G1CollectedHeap::heap()), _hrSorted(hrSorted) { }
-
- bool doHeapRegion(HeapRegion* r) {
- // We only include humongous regions in collection
- // sets when concurrent mark shows that their contained object is
- // unreachable.
-
- // Do we have any marking information for this region?
- if (r->is_marked()) {
- // We will skip any region that's currently used as an old GC
- // alloc region (we should not consider those for collection
- // before we fill them up).
- if (_hrSorted->should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
- _hrSorted->add_region(r);
- }
- }
- return false;
- }
-};
-
class ParKnownGarbageHRClosure: public HeapRegionClosure {
G1CollectedHeap* _g1h;
CSetChooserParUpdater _cset_updater;
@@ -1617,34 +1590,29 @@
_collectionSetChooser->clear();
uint region_num = _g1->num_regions();
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- const uint OverpartitionFactor = 4;
- uint WorkUnit;
- // The use of MinChunkSize = 8 in the original code
- // causes some assertion failures when the total number of
- // region is less than 8. The code here tries to fix that.
- // Should the original code also be fixed?
- if (no_of_gc_threads > 0) {
- const uint MinWorkUnit = MAX2(region_num / no_of_gc_threads, 1U);
- WorkUnit = MAX2(region_num / (no_of_gc_threads * OverpartitionFactor),
- MinWorkUnit);
- } else {
- assert(no_of_gc_threads > 0,
- "The active gc workers should be greater than 0");
- // In a product build do something reasonable to avoid a crash.
- const uint MinWorkUnit = MAX2(region_num / (uint) ParallelGCThreads, 1U);
- WorkUnit =
- MAX2(region_num / (uint) (ParallelGCThreads * OverpartitionFactor),
- MinWorkUnit);
- }
- _collectionSetChooser->prepare_for_par_region_addition(_g1->num_regions(),
- WorkUnit);
- ParKnownGarbageTask parKnownGarbageTask(_collectionSetChooser, WorkUnit, (uint) no_of_gc_threads);
- _g1->workers()->run_task(&parKnownGarbageTask);
+ const uint OverpartitionFactor = 4;
+ uint WorkUnit;
+ // The use of MinChunkSize = 8 in the original code
+ // causes some assertion failures when the total number of
+ // region is less than 8. The code here tries to fix that.
+ // Should the original code also be fixed?
+ if (no_of_gc_threads > 0) {
+ const uint MinWorkUnit = MAX2(region_num / no_of_gc_threads, 1U);
+ WorkUnit = MAX2(region_num / (no_of_gc_threads * OverpartitionFactor),
+ MinWorkUnit);
} else {
- KnownGarbageClosure knownGarbagecl(_collectionSetChooser);
- _g1->heap_region_iterate(&knownGarbagecl);
+ assert(no_of_gc_threads > 0,
+ "The active gc workers should be greater than 0");
+ // In a product build do something reasonable to avoid a crash.
+ const uint MinWorkUnit = MAX2(region_num / (uint) ParallelGCThreads, 1U);
+ WorkUnit =
+ MAX2(region_num / (uint) (ParallelGCThreads * OverpartitionFactor),
+ MinWorkUnit);
}
+ _collectionSetChooser->prepare_for_par_region_addition(_g1->num_regions(),
+ WorkUnit);
+ ParKnownGarbageTask parKnownGarbageTask(_collectionSetChooser, WorkUnit, (uint) no_of_gc_threads);
+ _g1->workers()->run_task(&parKnownGarbageTask);
_collectionSetChooser->sort_regions();
--- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -292,36 +292,25 @@
if (_root_region_scan_wait_time_ms > 0.0) {
print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
}
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- print_stats(1, "Parallel Time", _cur_collection_par_time_ms, _active_gc_threads);
- _last_gc_worker_start_times_ms.print(2, "GC Worker Start (ms)");
- _last_ext_root_scan_times_ms.print(2, "Ext Root Scanning (ms)");
- if (_last_satb_filtering_times_ms.sum() > 0.0) {
- _last_satb_filtering_times_ms.print(2, "SATB Filtering (ms)");
- }
- _last_update_rs_times_ms.print(2, "Update RS (ms)");
- _last_update_rs_processed_buffers.print(3, "Processed Buffers");
- _last_scan_rs_times_ms.print(2, "Scan RS (ms)");
- _last_strong_code_root_scan_times_ms.print(2, "Code Root Scanning (ms)");
- _last_obj_copy_times_ms.print(2, "Object Copy (ms)");
- _last_termination_times_ms.print(2, "Termination (ms)");
- if (G1Log::finest()) {
- _last_termination_attempts.print(3, "Termination Attempts");
- }
- _last_gc_worker_other_times_ms.print(2, "GC Worker Other (ms)");
- _last_gc_worker_times_ms.print(2, "GC Worker Total (ms)");
- _last_gc_worker_end_times_ms.print(2, "GC Worker End (ms)");
- } else {
- _last_ext_root_scan_times_ms.print(1, "Ext Root Scanning (ms)");
- if (_last_satb_filtering_times_ms.sum() > 0.0) {
- _last_satb_filtering_times_ms.print(1, "SATB Filtering (ms)");
- }
- _last_update_rs_times_ms.print(1, "Update RS (ms)");
- _last_update_rs_processed_buffers.print(2, "Processed Buffers");
- _last_scan_rs_times_ms.print(1, "Scan RS (ms)");
- _last_strong_code_root_scan_times_ms.print(1, "Code Root Scanning (ms)");
- _last_obj_copy_times_ms.print(1, "Object Copy (ms)");
+ print_stats(1, "Parallel Time", _cur_collection_par_time_ms, _active_gc_threads);
+ _last_gc_worker_start_times_ms.print(2, "GC Worker Start (ms)");
+ _last_ext_root_scan_times_ms.print(2, "Ext Root Scanning (ms)");
+ if (_last_satb_filtering_times_ms.sum() > 0.0) {
+ _last_satb_filtering_times_ms.print(2, "SATB Filtering (ms)");
}
+ _last_update_rs_times_ms.print(2, "Update RS (ms)");
+ _last_update_rs_processed_buffers.print(3, "Processed Buffers");
+ _last_scan_rs_times_ms.print(2, "Scan RS (ms)");
+ _last_strong_code_root_scan_times_ms.print(2, "Code Root Scanning (ms)");
+ _last_obj_copy_times_ms.print(2, "Object Copy (ms)");
+ _last_termination_times_ms.print(2, "Termination (ms)");
+ if (G1Log::finest()) {
+ _last_termination_attempts.print(3, "Termination Attempts");
+ }
+ _last_gc_worker_other_times_ms.print(2, "GC Worker Other (ms)");
+ _last_gc_worker_times_ms.print(2, "GC Worker Total (ms)");
+ _last_gc_worker_end_times_ms.print(2, "GC Worker End (ms)");
+
print_stats(1, "Code Root Fixup", _cur_collection_code_root_fixup_time_ms);
print_stats(1, "Code Root Purge", _cur_strong_code_root_purge_time_ms);
if (G1StringDedup::is_enabled()) {
--- a/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -43,7 +43,7 @@
_hot_cache_idx = 0;
// For refining the cards in the hot cache in parallel
- _hot_cache_par_chunk_size = (ParallelGCThreads > 0 ? ClaimChunkSize : _hot_cache_size);
+ _hot_cache_par_chunk_size = ClaimChunkSize;
_hot_cache_par_claimed_idx = 0;
_card_counts.initialize(card_counts_storage);
@@ -119,7 +119,7 @@
// RSet updating while within an evacuation pause.
// In this case worker_i should be the id of a GC worker thread
assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint");
- assert(worker_i < (ParallelGCThreads == 0 ? 1 : ParallelGCThreads),
+ assert(worker_i < ParallelGCThreads,
err_msg("incorrect worker id: %u", worker_i));
into_cset_dcq->enqueue(card_ptr);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -80,7 +80,6 @@
_prev_period_summary()
{
_seq_task = new SubTasksDone(NumSeqTasks);
- guarantee(n_workers() > 0, "There should be some workers");
_cset_rs_update_cl = NEW_C_HEAP_ARRAY(OopsInHeapRegionClosure*, n_workers(), mtGC);
for (uint i = 0; i < n_workers(); i++) {
_cset_rs_update_cl[i] = NULL;
@@ -282,7 +281,7 @@
// is during RSet updating within an evacuation pause.
// In this case worker_i should be the id of a GC worker thread.
assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
- assert(worker_i < (ParallelGCThreads == 0 ? 1 : ParallelGCThreads), "should be a GC worker");
+ assert(worker_i < ParallelGCThreads, "should be a GC worker");
if (_g1rs->refine_card(card_ptr, worker_i, true)) {
// 'card_ptr' contains references that point into the collection
@@ -343,8 +342,6 @@
// DirtyCardQueueSet that is used to manage RSet updates
DirtyCardQueue into_cset_dcq(&_g1->into_cset_dirty_card_queue_set());
- assert((ParallelGCThreads > 0) || worker_i == 0, "invariant");
-
updateRS(&into_cset_dcq, worker_i);
scanRS(oc, code_root_cl, worker_i);
@@ -420,12 +417,7 @@
}
};
-void G1RemSet::scrub(BitMap* region_bm, BitMap* card_bm) {
- ScrubRSClosure scrub_cl(region_bm, card_bm);
- _g1->heap_region_iterate(&scrub_cl);
-}
-
-void G1RemSet::scrub_par(BitMap* region_bm, BitMap* card_bm, uint worker_num, HeapRegionClaimer *hrclaimer) {
+void G1RemSet::scrub(BitMap* region_bm, BitMap* card_bm, uint worker_num, HeapRegionClaimer *hrclaimer) {
ScrubRSClosure scrub_cl(region_bm, card_bm);
_g1->heap_region_par_iterate(&scrub_cl, worker_num, hrclaimer);
}
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -124,14 +124,10 @@
// Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region
// or card, respectively, such that a region or card with a corresponding
// 0 bit contains no part of any live object. Eliminates any remembered
- // set entries that correspond to dead heap ranges.
- void scrub(BitMap* region_bm, BitMap* card_bm);
-
- // Like the above, but assumes is called in parallel: "worker_num" is the
- // parallel thread id of the current thread, and "hrclaimer" is the shared
- // HeapRegionClaimer that should be used to claim heap regions.
- void scrub_par(BitMap* region_bm, BitMap* card_bm,
- uint worker_num, HeapRegionClaimer* hrclaimer);
+ // set entries that correspond to dead heap ranges. "worker_num" is the
+ // parallel thread id of the current thread, and "hrclaimer" is the
+ // HeapRegionClaimer that should be used.
+ void scrub(BitMap* region_bm, BitMap* card_bm, uint worker_num, HeapRegionClaimer* hrclaimer);
// Refine the card corresponding to "card_ptr".
// If check_for_refs_into_cset is true, a true result is returned
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -31,11 +31,7 @@
#include "oops/oop.inline.hpp"
inline uint G1RemSet::n_workers() {
- if (_g1->workers() != NULL) {
- return _g1->workers()->total_workers();
- } else {
- return 1;
- }
+ return _g1->workers()->total_workers();
}
template <class T>
--- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -154,14 +154,10 @@
double fixup_start = os::elapsedTime();
G1StringDedupUnlinkOrOopsDoTask task(is_alive, keep_alive, allow_resize_and_rehash);
- if (G1CollectedHeap::use_parallel_gc_threads()) {
- G1CollectedHeap* g1h = G1CollectedHeap::heap();
- g1h->set_par_threads();
- g1h->workers()->run_task(&task);
- g1h->set_par_threads(0);
- } else {
- task.work(0);
- }
+ G1CollectedHeap* g1h = G1CollectedHeap::heap();
+ g1h->set_par_threads();
+ g1h->workers()->run_task(&task);
+ g1h->set_par_threads(0);
double fixup_time_ms = (os::elapsedTime() - fixup_start) * 1000.0;
g1p->phase_times()->record_string_dedup_fixup_time(fixup_time_ms);
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -202,7 +202,7 @@
#endif // _MSC_VER
SATBMarkQueueSet::SATBMarkQueueSet() :
- PtrQueueSet(), _closure(NULL), _par_closures(NULL),
+ PtrQueueSet(), _closures(NULL),
_shared_satb_queue(this, true /*perm*/) { }
void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
@@ -210,9 +210,7 @@
Mutex* lock) {
PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
_shared_satb_queue.set_lock(lock);
- if (ParallelGCThreads > 0) {
- _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads, mtGC);
- }
+ _closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads, mtGC);
}
void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
@@ -276,17 +274,13 @@
shared_satb_queue()->filter();
}
-void SATBMarkQueueSet::set_closure(ObjectClosure* closure) {
- _closure = closure;
+void SATBMarkQueueSet::set_closure(uint worker, ObjectClosure* closure) {
+ assert(_closures != NULL, "Precondition");
+ assert(worker < ParallelGCThreads, "Worker index must be in range [0...ParallelGCThreads)");
+ _closures[worker] = closure;
}
-void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) {
- assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition");
- _par_closures[i] = par_closure;
-}
-
-bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par,
- uint worker) {
+bool SATBMarkQueueSet::apply_closure_to_completed_buffer(uint worker) {
BufferNode* nd = NULL;
{
MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
@@ -298,7 +292,7 @@
if (_n_completed_buffers == 0) _process_completed = false;
}
}
- ObjectClosure* cl = (par ? _par_closures[worker] : _closure);
+ ObjectClosure* cl = _closures[worker];
if (nd != NULL) {
void **buf = BufferNode::make_buffer_from_node(nd);
ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -78,16 +78,10 @@
};
class SATBMarkQueueSet: public PtrQueueSet {
- ObjectClosure* _closure;
- ObjectClosure** _par_closures; // One per ParGCThread.
+ ObjectClosure** _closures; // One per ParGCThread.
ObjPtrQueue _shared_satb_queue;
- // Utility function to support sequential and parallel versions. If
- // "par" is true, then "worker" is the par thread id; if "false", worker
- // is ignored.
- bool apply_closure_to_completed_buffer_work(bool par, uint worker);
-
#ifdef ASSERT
void dump_active_states(bool expected_active);
void verify_active_states(bool expected_active);
@@ -111,26 +105,16 @@
// Filter all the currently-active SATB buffers.
void filter_thread_buffers();
- // Register "blk" as "the closure" for all queues. Only one such closure
- // is allowed. The "apply_closure_to_completed_buffer" method will apply
- // this closure to a completed buffer, and "iterate_closure_all_threads"
+ // Register closure for the given worker thread. The "apply_closure_to_completed_buffer"
+ // method will apply this closure to a completed buffer, and "iterate_closure_all_threads"
// applies it to partially-filled buffers (the latter should only be done
// with the world stopped).
- void set_closure(ObjectClosure* closure);
- // Set the parallel closures: pointer is an array of pointers to
- // closures, one for each parallel GC thread.
- void set_par_closure(int i, ObjectClosure* closure);
+ void set_closure(uint worker, ObjectClosure* closure);
// If there exists some completed buffer, pop it, then apply the
// registered closure to all its elements, and return true. If no
// completed buffers exist, return false.
- bool apply_closure_to_completed_buffer() {
- return apply_closure_to_completed_buffer_work(false, 0);
- }
- // Parallel version of the above.
- bool par_apply_closure_to_completed_buffer(uint worker) {
- return apply_closure_to_completed_buffer_work(true, worker);
- }
+ bool apply_closure_to_completed_buffer(uint worker);
// Apply the given closure on enqueued and currently-active buffers
// respectively. Both methods are read-only, i.e., they do not
--- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -60,7 +60,7 @@
VM_G1CollectFull(unsigned int gc_count_before,
unsigned int full_gc_count_before,
GCCause::Cause cause)
- : VM_GC_Operation(gc_count_before, cause, full_gc_count_before) { }
+ : VM_GC_Operation(gc_count_before, cause, full_gc_count_before, true) { }
virtual VMOp_Type type() const { return VMOp_G1CollectFull; }
virtual void doit();
virtual const char* name() const {
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -479,7 +479,7 @@
_next_gen.par_oop_since_save_marks_iterate_done(i);
}
- if (UseConcMarkSweepGC && ParallelGCThreads > 0) {
+ if (UseConcMarkSweepGC) {
// We need to call this even when ResizeOldPLAB is disabled
// so as to avoid breaking some asserts. While we may be able
// to avoid this by reorganizing the code a bit, I am loathe
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -47,11 +47,6 @@
// Do basic sizing work
GenCollectorPolicy::initialize_flags();
- assert(UseSerialGC ||
- !FLAG_IS_DEFAULT(ParallelGCThreads) ||
- (ParallelGCThreads > 0),
- "ParallelGCThreads should be set before flag initialization");
-
// The survivor ratio's are calculated "raw", unlike the
// default gc, which adds 2 to the ratio value. We need to
// make sure the values are valid before using them.
--- a/hotspot/src/share/vm/memory/freeBlockDictionary.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/memory/freeBlockDictionary.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -43,12 +43,10 @@
template <class Chunk> void FreeBlockDictionary<Chunk>::verify_par_locked() const {
#ifdef ASSERT
- if (ParallelGCThreads > 0) {
- Thread* my_thread = Thread::current();
- if (my_thread->is_GC_task_thread()) {
- assert(par_lock() != NULL, "Should be using locking?");
- assert_lock_strong(par_lock());
- }
+ Thread* my_thread = Thread::current();
+ if (my_thread->is_GC_task_thread()) {
+ assert(par_lock() != NULL, "Should be using locking?");
+ assert_lock_strong(par_lock());
}
#endif // ASSERT
}
--- a/hotspot/src/share/vm/memory/freeList.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/memory/freeList.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -287,11 +287,14 @@
return false;
}
-#ifndef PRODUCT
+#ifdef ASSERT
template <class Chunk>
void FreeList<Chunk>::assert_proper_lock_protection_work() const {
- assert(protecting_lock() != NULL, "Don't call this directly");
- assert(ParallelGCThreads > 0, "Don't call this directly");
+ // Nothing to do if the list has no assigned protecting lock
+ if (protecting_lock() == NULL) {
+ return;
+ }
+
Thread* thr = Thread::current();
if (thr->is_VM_thread() || thr->is_ConcurrentGC_thread()) {
// assert that we are holding the freelist lock
--- a/hotspot/src/share/vm/memory/freeList.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/memory/freeList.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -56,15 +56,12 @@
#ifdef ASSERT
Mutex* _protecting_lock;
+ void assert_proper_lock_protection_work() const;
#endif
// Asserts false if the protecting lock (if any) is not held.
- void assert_proper_lock_protection_work() const PRODUCT_RETURN;
void assert_proper_lock_protection() const {
-#ifdef ASSERT
- if (_protecting_lock != NULL)
- assert_proper_lock_protection_work();
-#endif
+ DEBUG_ONLY(assert_proper_lock_protection_work());
}
void increment_count() {
--- a/hotspot/src/share/vm/memory/sharedHeap.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/memory/sharedHeap.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -68,11 +68,9 @@
vm_exit_during_initialization("Failed necessary allocation.");
}
_sh = this; // ch is static, should be set only once.
- if ((UseParNewGC ||
- (UseConcMarkSweepGC && (CMSParallelInitialMarkEnabled ||
- CMSParallelRemarkEnabled)) ||
- UseG1GC) &&
- ParallelGCThreads > 0) {
+ if (UseParNewGC ||
+ UseG1GC ||
+ (UseConcMarkSweepGC && (CMSParallelInitialMarkEnabled || CMSParallelRemarkEnabled) && use_parallel_gc_threads())) {
_workers = new FlexibleWorkGang("Parallel GC Threads", ParallelGCThreads,
/* are_GC_task_threads */true,
/* are_ConcurrentGC_threads */false);
--- a/hotspot/src/share/vm/oops/constantPool.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/oops/constantPool.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -1779,11 +1779,22 @@
void ConstantPool::set_on_stack(const bool value) {
if (value) {
- _flags |= _on_stack;
+ int old_flags = *const_cast<volatile int *>(&_flags);
+ while ((old_flags & _on_stack) == 0) {
+ int new_flags = old_flags | _on_stack;
+ int result = Atomic::cmpxchg(new_flags, &_flags, old_flags);
+
+ if (result == old_flags) {
+ // Succeeded.
+ MetadataOnStackMark::record(this, Thread::current());
+ return;
+ }
+ old_flags = result;
+ }
} else {
+ // Clearing is done single-threadedly.
_flags &= ~_on_stack;
}
- if (value) MetadataOnStackMark::record(this);
}
// JSR 292 support for patching constant pool oops after the class is linked and
--- a/hotspot/src/share/vm/oops/method.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/oops/method.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -1862,9 +1862,12 @@
void Method::set_on_stack(const bool value) {
// Set both the method itself and its constant pool. The constant pool
// on stack means some method referring to it is also on the stack.
- _access_flags.set_on_stack(value);
constants()->set_on_stack(value);
- if (value) MetadataOnStackMark::record(this);
+
+ bool succeeded = _access_flags.set_on_stack(value);
+ if (value && succeeded) {
+ MetadataOnStackMark::record(this, Thread::current());
+ }
}
// Called when the class loader is unloaded to make all methods weak.
--- a/hotspot/src/share/vm/prims/jni.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/prims/jni.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -3861,6 +3861,7 @@
void TestBitMap_test();
void TestAsUtf8();
void Test_linked_list();
+void TestChunkedList_test();
#if INCLUDE_ALL_GCS
void TestOldFreeSpaceCalculation_test();
void TestG1BiasedArray_test();
@@ -3894,6 +3895,7 @@
run_unit_test(TestAsUtf8());
run_unit_test(ObjectMonitor::sanity_checks());
run_unit_test(Test_linked_list());
+ run_unit_test(TestChunkedList_test());
#if INCLUDE_VM_STRUCTS
run_unit_test(VMStructs::test());
#endif
--- a/hotspot/src/share/vm/runtime/arguments.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -3782,27 +3782,33 @@
bool settings_file_specified = false;
bool needs_hotspotrc_warning = false;
- ArgumentsExt::process_options(args);
-
const char* flags_file;
int index;
for (index = 0; index < args->nOptions; index++) {
const JavaVMOption *option = args->options + index;
+ if (ArgumentsExt::process_options(option)) {
+ continue;
+ }
if (match_option(option, "-XX:Flags=", &tail)) {
flags_file = tail;
settings_file_specified = true;
+ continue;
}
if (match_option(option, "-XX:+PrintVMOptions", &tail)) {
PrintVMOptions = true;
+ continue;
}
if (match_option(option, "-XX:-PrintVMOptions", &tail)) {
PrintVMOptions = false;
+ continue;
}
if (match_option(option, "-XX:+IgnoreUnrecognizedVMOptions", &tail)) {
IgnoreUnrecognizedVMOptions = true;
+ continue;
}
if (match_option(option, "-XX:-IgnoreUnrecognizedVMOptions", &tail)) {
IgnoreUnrecognizedVMOptions = false;
+ continue;
}
if (match_option(option, "-XX:+PrintFlagsInitial", &tail)) {
CommandLineFlags::printFlags(tty, false);
@@ -3824,6 +3830,7 @@
} else {
vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL);
}
+ continue;
}
#endif
--- a/hotspot/src/share/vm/runtime/arguments_ext.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/runtime/arguments_ext.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -34,7 +34,10 @@
static inline bool check_gc_consistency_user();
static inline bool check_gc_consistency_ergo();
static inline bool check_vm_args_consistency();
- static void process_options(const JavaVMInitArgs* args) {}
+ // The argument processing extension. Returns true if there is
+ // no additional parsing needed in Arguments::parse() for the option.
+ // Otherwise returns false.
+ static inline bool process_options(const JavaVMOption *option) { return false; }
};
void ArgumentsExt::select_gc_ergonomically() {
--- a/hotspot/src/share/vm/runtime/thread.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/runtime/thread.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -201,6 +201,8 @@
// This initial value ==> never claimed.
_oops_do_parity = 0;
+ _metadata_on_stack_buffer = NULL;
+
// the handle mark links itself to last_handle_mark
new HandleMark(this);
--- a/hotspot/src/share/vm/runtime/thread.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/runtime/thread.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -42,11 +42,10 @@
#include "runtime/threadLocalStorage.hpp"
#include "runtime/thread_ext.hpp"
#include "runtime/unhandledOops.hpp"
-#include "utilities/macros.hpp"
-
#include "trace/traceBackend.hpp"
#include "trace/traceMacros.hpp"
#include "utilities/exceptions.hpp"
+#include "utilities/macros.hpp"
#include "utilities/top.hpp"
#if INCLUDE_ALL_GCS
#include "gc_implementation/g1/dirtyCardQueue.hpp"
@@ -83,6 +82,10 @@
class ThreadClosure;
class IdealGraphPrinter;
+class Metadata;
+template <class T, MEMFLAGS F> class ChunkedList;
+typedef ChunkedList<Metadata*, mtInternal> MetadataOnStackBuffer;
+
DEBUG_ONLY(class ResourceMark;)
class WorkerThread;
@@ -255,6 +258,9 @@
jlong _allocated_bytes; // Cumulative number of bytes allocated on
// the Java heap
+ // Thread-local buffer used by MetadataOnStackMark.
+ MetadataOnStackBuffer* _metadata_on_stack_buffer;
+
TRACE_DATA _trace_data; // Thread-local data for tracing
ThreadExt _ext;
@@ -490,7 +496,10 @@
// creation fails due to lack of memory, too many threads etc.
bool set_as_starting_thread();
- protected:
+ void set_metadata_on_stack_buffer(MetadataOnStackBuffer* buffer) { _metadata_on_stack_buffer = buffer; }
+ MetadataOnStackBuffer* metadata_on_stack_buffer() const { return _metadata_on_stack_buffer; }
+
+protected:
// OS data associated with the thread
OSThread* _osthread; // Platform-specific thread information
--- a/hotspot/src/share/vm/utilities/accessFlags.cpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/utilities/accessFlags.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -47,6 +47,21 @@
} while(f != old_flags);
}
+// Returns true iff this thread succeeded setting the bit.
+bool AccessFlags::atomic_set_one_bit(jint bit) {
+ // Atomically update the flags with the bit given
+ jint old_flags, new_flags, f;
+ bool is_setting_bit = false;
+ do {
+ old_flags = _flags;
+ new_flags = old_flags | bit;
+ is_setting_bit = old_flags != new_flags;
+ f = Atomic::cmpxchg(new_flags, &_flags, old_flags);
+ } while(f != old_flags);
+
+ return is_setting_bit;
+}
+
#if !defined(PRODUCT) || INCLUDE_JVMTI
void AccessFlags::print_on(outputStream* st) const {
--- a/hotspot/src/share/vm/utilities/accessFlags.hpp Sat Nov 01 14:40:09 2014 +0300
+++ b/hotspot/src/share/vm/utilities/accessFlags.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -172,6 +172,7 @@
// Atomic update of flags
void atomic_set_bits(jint bits);
+ bool atomic_set_one_bit(jint bit);
void atomic_clear_bits(jint bits);
private:
@@ -233,12 +234,13 @@
atomic_set_bits(JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE);
}
- void set_on_stack(const bool value)
+ bool set_on_stack(const bool value)
{
if (value) {
- atomic_set_bits(JVM_ACC_ON_STACK);
+ return atomic_set_one_bit(JVM_ACC_ON_STACK);
} else {
atomic_clear_bits(JVM_ACC_ON_STACK);
+ return true; // Ignored
}
}
// Conversion
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/utilities/chunkedList.cpp Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, 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 "precompiled.hpp"
+#include "utilities/chunkedList.hpp"
+#include "utilities/debug.hpp"
+
+/////////////// Unit tests ///////////////
+
+#ifndef PRODUCT
+
+template <typename T>
+class TestChunkedList {
+ typedef ChunkedList<T, mtOther> ChunkedListT;
+
+ public:
+ static void testEmpty() {
+ ChunkedListT buffer;
+ assert(buffer.size() == 0, "assert");
+ }
+
+ static void testFull() {
+ ChunkedListT buffer;
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ buffer.push((T)i);
+ }
+ assert(buffer.size() == ChunkedListT::BufferSize, "assert");
+ assert(buffer.is_full(), "assert");
+ }
+
+ static void testSize() {
+ ChunkedListT buffer;
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ assert(buffer.size() == i, "assert");
+ buffer.push((T)i);
+ assert(buffer.size() == i + 1, "assert");
+ }
+ }
+
+ static void testClear() {
+ ChunkedListT buffer;
+
+ buffer.clear();
+ assert(buffer.size() == 0, "assert");
+
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
+ buffer.push((T)i);
+ }
+ buffer.clear();
+ assert(buffer.size() == 0, "assert");
+
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ buffer.push((T)i);
+ }
+ buffer.clear();
+ assert(buffer.size() == 0, "assert");
+ }
+
+ static void testAt() {
+ ChunkedListT buffer;
+
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ buffer.push((T)i);
+ assert(buffer.at(i) == (T)i, "assert");
+ }
+
+ for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+ assert(buffer.at(i) == (T)i, "assert");
+ }
+ }
+
+ static void test() {
+ testEmpty();
+ testFull();
+ testSize();
+ testClear();
+ testAt();
+ }
+};
+
+class Metadata;
+
+void TestChunkedList_test() {
+ TestChunkedList<Metadata*>::test();
+ TestChunkedList<size_t>::test();
+}
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/utilities/chunkedList.hpp Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, 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_UTILITIES_CHUNKED_LIST_HPP
+#define SHARE_VM_UTILITIES_CHUNKED_LIST_HPP
+
+#include "memory/allocation.hpp"
+#include "utilities/debug.hpp"
+
+template <class T, MEMFLAGS F> class ChunkedList : public CHeapObj<F> {
+ template <class U> friend class TestChunkedList;
+
+ static const size_t BufferSize = 64;
+
+ T _values[BufferSize];
+ T* _top;
+
+ ChunkedList<T, F>* _next_used;
+ ChunkedList<T, F>* _next_free;
+
+ T const * end() const {
+ return &_values[BufferSize];
+ }
+
+ public:
+ ChunkedList<T, F>() : _top(_values), _next_used(NULL), _next_free(NULL) {}
+
+ bool is_full() const {
+ return _top == end();
+ }
+
+ void clear() {
+ _top = _values;
+ // Don't clear the next pointers since that would interfere
+ // with other threads trying to iterate through the lists.
+ }
+
+ void push(T m) {
+ assert(!is_full(), "Buffer is full");
+ *_top = m;
+ _top++;
+ }
+
+ void set_next_used(ChunkedList<T, F>* buffer) { _next_used = buffer; }
+ void set_next_free(ChunkedList<T, F>* buffer) { _next_free = buffer; }
+
+ ChunkedList<T, F>* next_used() const { return _next_used; }
+ ChunkedList<T, F>* next_free() const { return _next_free; }
+
+ size_t size() const {
+ return pointer_delta(_top, _values, sizeof(T));
+ }
+
+ T at(size_t i) {
+ assert(i < size(), err_msg("IOOBE i: " SIZE_FORMAT " size(): " SIZE_FORMAT, i, size()));
+ return _values[i];
+ }
+};
+
+#endif // SHARE_VM_UTILITIES_CHUNKED_LIST_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/CommandLine/TestVMOptions.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, 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 8060256
+ * @summary Test various command line options
+ * @library /testlibrary
+ * @run main TestVMOptions
+ */
+
+import com.oracle.java.testlibrary.*;
+import java.io.File;
+
+public class TestVMOptions {
+ public static void main(String[] args) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:bogus",
+ "-XX:+IgnoreUnrecognizedVMOptions",
+ "-XX:+PrintFlagsInitial");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("bool PrintGCDetails");
+
+ pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:-PrintVMOptions", "-version");
+ output = new OutputAnalyzer(pb.start());
+ output.shouldContain("java version");
+
+ File dir = new File(System.getProperty("test.src", "."));
+ File file = new File(dir, "flagfile.txt");
+ String s = file.getAbsolutePath();
+ pb = ProcessTools.createJavaProcessBuilder("-XX:Flags="+s);
+ output = new OutputAnalyzer(pb.start());
+ output.shouldContain("VM option '-IgnoreUnrecognizedVMOptions'");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/CommandLine/flagfile.txt Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,1 @@
++PrintVMOptions -IgnoreUnrecognizedVMOptions
--- a/jaxp/.hgtags Sat Nov 01 14:40:09 2014 +0300
+++ b/jaxp/.hgtags Mon Nov 03 10:11:10 2014 -0800
@@ -279,3 +279,4 @@
6b343b9b7a7008f5f699a2d99881163cab7a2986 jdk9-b34
b9370464572fc663a38956047aa612d6e7854c3d jdk9-b35
61b4c9acaa58e482db6601ec5dc4fc3d2d8dbb55 jdk9-b36
+48e4ec70cc1c8651e4a0324d91f193c4edd83af9 jdk9-b37
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/io/UTF8Reader.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/io/UTF8Reader.java Mon Nov 03 10:11:10 2014 -0800
@@ -529,6 +529,16 @@
invalidByte(4, 4, b2);
}
+ // check if output buffer is large enough to hold 2 surrogate chars
+ if (out + 1 >= ch.length) {
+ fBuffer[0] = (byte)b0;
+ fBuffer[1] = (byte)b1;
+ fBuffer[2] = (byte)b2;
+ fBuffer[3] = (byte)b3;
+ fOffset = 4;
+ return out - offset;
+ }
+
// decode bytes into surrogate characters
int uuuuu = ((b0 << 2) & 0x001C) | ((b1 >> 4) & 0x0003);
if (uuuuu > 0x10) {
--- a/jaxws/.hgtags Sat Nov 01 14:40:09 2014 +0300
+++ b/jaxws/.hgtags Mon Nov 03 10:11:10 2014 -0800
@@ -282,3 +282,4 @@
28ea43d925f1e5250976097a2977dd3e66e11f0b jdk9-b34
afe0c89e2edbdfb1a7ceff3d9b3ff46c4186202f jdk9-b35
84803c3be7f79d29c7dc40749d7743675f64107a jdk9-b36
+90de6ecbff46386a3f9d6f7ca876e7aa6381f50a jdk9-b37
--- a/jdk/.hgtags Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/.hgtags Mon Nov 03 10:11:10 2014 -0800
@@ -279,3 +279,4 @@
21568031434d7a9dbb0cc6516cc3183d349c2253 jdk9-b34
e549291a0227031310fa91c574891f892d27f959 jdk9-b35
cdcf2e599e42935c2d1d19a24bb19e808aeb43b5 jdk9-b36
+27c3345d6dce39a22c262f30bb1f0e0b00c3709e jdk9-b37
--- a/jdk/make/copy/Copy-java.base.gmk Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/copy/Copy-java.base.gmk Mon Nov 03 10:11:10 2014 -0800
@@ -48,22 +48,6 @@
################################################################################
-CALENDARS_SRC := $(JDK_TOPDIR)/src/java.base/share/conf
-
-$(LIB_DST_DIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties
- $(call install-file)
-
-BASE_CONF_FILES += $(LIB_DST_DIR)/calendars.properties
-
-$(LIB_DST_DIR)/hijrah-config-umalqura.properties: $(CALENDARS_SRC)/hijrah-config-umalqura.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
-
-BASE_CONF_FILES += $(LIB_DST_DIR)/hijrah-config-umalqura.properties
-
-################################################################################
-
ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)
TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf
--- a/jdk/make/copy/Copy-java.desktop.gmk Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/copy/Copy-java.desktop.gmk Mon Nov 03 10:11:10 2014 -0800
@@ -67,8 +67,11 @@
FREETYPE_TARGET_LIB := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/$(call SHARED_LIBRARY,freetype).6
endif
+ # We can't use $(install-file) in this rule because it preserves symbolic links and
+ # libfreetype.so is usually a symbolic link to something like libfreetype.so.6 on Unix.
$(FREETYPE_TARGET_LIB): $(FREETYPE_BUNDLE_LIB_PATH)/$(call SHARED_LIBRARY,freetype)
- $(install-file)
+ $(MKDIR) -p $(@D)
+ $(CP) $< $@
ifeq ($(OPENJDK_BUILD_OS), windows)
$(CHMOD) +rx $@
endif
--- a/jdk/make/data/tzdata/VERSION Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/data/tzdata/VERSION Mon Nov 03 10:11:10 2014 -0800
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2014g
+tzdata2014i
--- a/jdk/make/data/tzdata/africa Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/data/tzdata/africa Mon Nov 03 10:11:10 2014 -0800
@@ -133,23 +133,13 @@
# See Africa/Lagos.
# Botswana
-# From Paul Eggert (2013-02-21):
-# Milne says they were regulated by the Cape Town Signal in 1899;
-# assume they switched to 2:00 when Cape Town did.
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Gaborone 1:43:40 - LMT 1885
- 1:30 - SAST 1903 Mar
- 2:00 - CAT 1943 Sep 19 2:00
- 2:00 1:00 CAST 1944 Mar 19 2:00
- 2:00 - CAT
+# See Africa/Maputo.
# Burkina Faso
# See Africa/Abidjan.
# Burundi
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Bujumbura 1:57:28 - LMT 1890
- 2:00 - CAT
+# See Africa/Maputo.
# Cameroon
# See Africa/Lagos.
@@ -184,10 +174,7 @@
3:00 - EAT
# Democratic Republic of the Congo
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Lubumbashi 1:49:52 - LMT 1897 Nov 9
- 2:00 - CAT
-# The above is for the eastern part; see Africa/Lagos for the western part.
+# See Africa/Lagos for the western part and Africa/Maputo for the eastern.
# Republic of the Congo
# See Africa/Lagos.
@@ -339,7 +326,7 @@
# Egypt is to change back to Daylight system on May 15
# http://english.ahram.org.eg/NewsContent/1/64/100735/Egypt/Politics-/Egypts-government-to-reapply-daylight-saving-time-.aspx
-# From Gunther Vermier (2015-05-13):
+# From Gunther Vermier (2014-05-13):
# our Egypt office confirms that the change will be at 15 May "midnight" (24:00)
# From Imed Chihi (2014-06-04):
@@ -489,11 +476,7 @@
3:00 - EAT
# Lesotho
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Maseru 1:50:00 - LMT 1903 Mar
- 2:00 - SAST 1943 Sep 19 2:00
- 2:00 1:00 SAST 1944 Mar 19 2:00
- 2:00 - SAST
+# See Africa/Johannesburg.
# Liberia
# From Paul Eggert (2006-03-22):
@@ -575,9 +558,7 @@
3:00 - EAT
# Malawi
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Blantyre 2:20:00 - LMT 1903 Mar
- 2:00 - CAT
+# See Africa/Maputo.
# Mali
# Mauritania
@@ -987,6 +968,13 @@
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Maputo 2:10:20 - LMT 1903 Mar
2:00 - CAT
+Link Africa/Maputo Africa/Blantyre # Malawi
+Link Africa/Maputo Africa/Bujumbura # Burundi
+Link Africa/Maputo Africa/Gaborone # Botswana
+Link Africa/Maputo Africa/Harare # Zimbabwe
+Link Africa/Maputo Africa/Kigali # Rwanda
+Link Africa/Maputo Africa/Lubumbashi # E Dem. Rep. of Congo
+Link Africa/Maputo Africa/Lusaka # Zambia
# Namibia
# The 1994-04-03 transition is from Shanks & Pottenger.
@@ -1054,9 +1042,7 @@
# Tromelin - inhabited until at least 1958
# Rwanda
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Kigali 2:00:16 - LMT 1935 Jun
- 2:00 - CAT
+# See Africa/Maputo.
# St Helena
# See Africa/Abidjan.
@@ -1100,6 +1086,9 @@
Zone Africa/Johannesburg 1:52:00 - LMT 1892 Feb 8
1:30 - SAST 1903 Mar
2:00 SA SAST
+Link Africa/Johannesburg Africa/Maseru # Lesotho
+Link Africa/Johannesburg Africa/Mbabane # Swaziland
+#
# Marion and Prince Edward Is
# scientific station since 1947
# no information
@@ -1127,9 +1116,7 @@
Link Africa/Khartoum Africa/Juba
# Swaziland
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Mbabane 2:04:24 - LMT 1903 Mar
- 2:00 - SAST
+# See Africa/Johannesburg.
# Tanzania
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -1250,11 +1237,5 @@
3:00 - EAT
# Zambia
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Lusaka 1:53:08 - LMT 1903 Mar
- 2:00 - CAT
-
# Zimbabwe
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Harare 2:04:12 - LMT 1903 Mar
- 2:00 - CAT
+# See Africa/Maputo.
--- a/jdk/make/data/tzdata/asia Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/data/tzdata/asia Mon Nov 03 10:11:10 2014 -0800
@@ -70,10 +70,11 @@
# 3:30 IRST IRDT Iran
# 4:00 GST Gulf*
# 5:30 IST India
-# 7:00 ICT Indochina*
+# 7:00 ICT Indochina, most times and locations*
# 7:00 WIB west Indonesia (Waktu Indonesia Barat)
# 8:00 WITA central Indonesia (Waktu Indonesia Tengah)
# 8:00 CST China
+# 8:00 IDT Indochina, 1943-45, 1947-55, 1960-75 (some locations)*
# 8:00 JWST Western Standard Time (Japan, 1896/1937)*
# 9:00 JCST Central Standard Time (Japan, 1896/1937)
# 9:00 WIT east Indonesia (Waktu Indonesia Timur)
@@ -294,12 +295,8 @@
6:30 - MMT # Myanmar Time
# Cambodia
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Phnom_Penh 6:59:40 - LMT 1906 Jun 9
- 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT?
- 7:00 - ICT 1912 May
- 8:00 - ICT 1931 May
- 7:00 - ICT
+# See Asia/Bangkok.
+
# China
@@ -916,6 +913,10 @@
# Indonesia
#
+# From Paul Eggert (2014-09-06):
+# The 1876 Report of the Secretary of the [US] Navy, p 306 says that Batavia
+# civil time was 7:07:12.5; round to even for Jakarta.
+#
# From Gwillim Law (2001-05-28), overriding Shanks & Pottenger:
# http://www.sumatera-inc.com/go_to_invest/about_indonesia.asp#standtime
# says that Indonesia's time zones changed on 1988-01-01. Looking at some
@@ -1733,12 +1734,8 @@
3:00 - AST
# Laos
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Vientiane 6:50:24 - LMT 1906 Jun 9 # or Viangchan
- 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT?
- 7:00 - ICT 1912 May
- 8:00 - ICT 1931 May
- 7:00 - ICT
+# See Asia/Bangkok.
+
# Lebanon
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
@@ -2751,6 +2748,8 @@
Zone Asia/Bangkok 6:42:04 - LMT 1880
6:42:04 - BMT 1920 Apr # Bangkok Mean Time
7:00 - ICT
+Link Asia/Bangkok Asia/Phnom_Penh # Cambodia
+Link Asia/Bangkok Asia/Vientiane # Laos
# Turkmenistan
# From Shanks & Pottenger.
@@ -2788,22 +2787,65 @@
# Vietnam
-# From Paul Eggert (2013-02-21):
+# From Paul Eggert (2014-10-04):
# Milne gives 7:16:56 for the meridian of Saigon in 1899, as being
# used in Lower Laos, Cambodia, and Annam. But this is quite a ways
# from Saigon's location. For now, ignore this and stick with Shanks
-# and Pottenger.
+# and Pottenger for LMT before 1906.
# From Arthur David Olson (2008-03-18):
# The English-language name of Vietnam's most populous city is "Ho Chi Minh
# City"; use Ho_Chi_Minh below to avoid a name of more than 14 characters.
-# From Shanks & Pottenger:
+# From Paul Eggert (2014-10-21) after a heads-up from Trần Ngọc Quân:
+# Trần Tiến Bình's authoritative book "Lịch Việt Nam: thế kỷ XX-XXI (1901-2100)"
+# (Nhà xuất bản Văn Hoá - Thông Tin, Hanoi, 2005), pp 49-50,
+# is quoted verbatim in:
+# http://www.thoigian.com.vn/?mPage=P80D01
+# is translated by Brian Inglis in:
+# http://mm.icann.org/pipermail/tz/2014-October/021654.html
+# and is the basis for the information below.
+#
+# The 1906 transition was effective July 1 and standardized Indochina to
+# Phù Liễn Observatory, legally 104 deg. 17'17" east of Paris.
+# It's unclear whether this meant legal Paris Mean Time (00:09:21) or
+# the Paris Meridian (2 deg. 20'14.03" E); the former yields 07:06:30.1333...
+# and the latter 07:06:29.333... so either way it rounds to 07:06:30,
+# which is used below even though the modern-day Phù Liễn Observatory
+# is closer to 07:06:31. Abbreviate Phù Liễn Mean Time as PLMT.
+#
+# The following transitions occurred in Indochina in general (before 1954)
+# and in South Vietnam in particular (after 1954):
+# To 07:00 on 1911-05-01.
+# To 08:00 on 1942-12-31 at 23:00.
+# To 09:00 in 1945-03-14 at 23:00.
+# To 07:00 on 1945-09-02 in Vietnam.
+# To 08:00 on 1947-04-01 in French-controlled Indochina.
+# To 07:00 on 1955-07-01 in South Vietnam.
+# To 08:00 on 1959-12-31 at 23:00 in South Vietnam.
+# To 07:00 on 1975-06-13 in South Vietnam.
+#
+# Trần cites the following sources; it's unclear which supplied the info above.
+#
+# Hoàng Xuân Hãn: "Lịch và lịch Việt Nam". Tập san Khoa học Xã hội,
+# No. 9, Paris, February 1982.
+#
+# Lê Thành Lân: "Lịch và niên biểu lịch sử hai mươi thế kỷ (0001-2010)",
+# NXB Thống kê, Hanoi, 2000.
+#
+# Lê Thành Lân: "Lịch hai thế kỷ (1802-2010) và các lịch vĩnh cửu",
+# NXB Thuận Hoá, Huế, 1995.
+
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jun 9
- 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT?
- 7:00 - ICT 1912 May
- 8:00 - ICT 1931 May
+Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1
+ 7:06:30 - PLMT 1911 May 1
+ 7:00 - ICT 1942 Dec 31 23:00
+ 8:00 - IDT 1945 Mar 14 23:00
+ 9:00 - JST 1945 Sep 2
+ 7:00 - ICT 1947 Apr 1
+ 8:00 - IDT 1955 Jul 1
+ 7:00 - ICT 1959 Dec 31 23:00
+ 8:00 - IDT 1975 Jun 13
7:00 - ICT
# Yemen
--- a/jdk/make/data/tzdata/australasia Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/data/tzdata/australasia Mon Nov 03 10:11:10 2014 -0800
@@ -354,20 +354,27 @@
# Fiji will end DST on 2014-01-19 02:00:
# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVINGS-TO-END-THIS-MONTH-%281%29.aspx
-# From Paul Eggert (2014-01-10):
-# For now, guess that Fiji springs forward the Sunday before the fourth
-# Monday in October, and springs back the penultimate Sunday in January.
-# This is ad hoc, but matches recent practice.
+# From Ken Rylander (2014-10-20):
+# DST will start Nov. 2 this year.
+# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-NOVEMBER-2ND.aspx
+
+# From Paul Eggert (2014-10-20):
+# For now, guess DST from 02:00 the first Sunday in November to
+# 03:00 the first Sunday on or after January 18. Although ad hoc, it
+# matches this year's plan and seems more likely to match future
+# practice than guessing no DST.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S
Rule Fiji 1999 2000 - Feb lastSun 3:00 0 -
Rule Fiji 2009 only - Nov 29 2:00 1:00 S
Rule Fiji 2010 only - Mar lastSun 3:00 0 -
-Rule Fiji 2010 max - Oct Sun>=21 2:00 1:00 S
+Rule Fiji 2010 2013 - Oct Sun>=21 2:00 1:00 S
Rule Fiji 2011 only - Mar Sun>=1 3:00 0 -
Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 -
-Rule Fiji 2014 max - Jan Sun>=18 2:00 0 -
+Rule Fiji 2014 only - Jan Sun>=18 2:00 0 -
+Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 S
+Rule Fiji 2015 max - Jan Sun>=18 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva
12:00 Fiji FJ%sT # Fiji Time
@@ -542,6 +549,30 @@
Zone Pacific/Port_Moresby 9:48:40 - LMT 1880
9:48:32 - PMMT 1895 # Port Moresby Mean Time
10:00 - PGT # Papua New Guinea Time
+#
+# From Paul Eggert (2014-10-13):
+# Base the Bougainville entry on the Arawa-Kieta region, which appears to have
+# the most people even though it was devastated in the Bougainville Civil War.
+#
+# Although Shanks gives 1942-03-15 / 1943-11-01 for JST, these dates
+# are apparently rough guesswork from the starts of military campaigns.
+# The World War II entries below are instead based on Arawa-Kieta.
+# The Japanese occupied Kieta in July 1942,
+# according to the Pacific War Online Encyclopedia
+# http://pwencycl.kgbudge.com/B/o/Bougainville.htm
+# and seem to have controlled it until their 1945-08-21 surrender.
+#
+# The Autonomous Region of Bougainville plans to switch from UTC+10 to UTC+11
+# on 2014-12-28 at 02:00. They call UTC+11 "Bougainville Standard Time";
+# abbreviate this as BST. See:
+# http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/
+#
+Zone Pacific/Bougainville 10:22:16 - LMT 1880
+ 9:48:32 - PMMT 1895
+ 10:00 - PGT 1942 Jul
+ 9:00 - JST 1945 Aug 21
+ 10:00 - PGT 2014 Dec 28 2:00
+ 11:00 - BST
# Pitcairn
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -826,6 +857,7 @@
# 10:00 AEST AEDT Eastern Australia
# 10:00 ChST Chamorro
# 10:30 LHST LHDT Lord Howe*
+# 11:00 BST Bougainville*
# 11:30 NZMT NZST New Zealand through 1945
# 12:00 NZST NZDT New Zealand 1946-present
# 12:15 CHAST Chatham through 1945*
--- a/jdk/make/data/tzdata/europe Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/data/tzdata/europe Mon Nov 03 10:11:10 2014 -0800
@@ -91,10 +91,11 @@
# 0:00 WET WEST WEMT Western Europe
# 0:19:32.13 AMT NST Amsterdam, Netherlands Summer (1835-1937)*
# 0:20 NET NEST Netherlands (1937-1940)*
+# 1:00 BST British Standard (1968-1971)
# 1:00 CET CEST CEMT Central Europe
# 1:00:14 SET Swedish (1879-1899)*
# 2:00 EET EEST Eastern Europe
-# 3:00 FET Further-eastern Europe*
+# 3:00 FET Further-eastern Europe (2011-2014)*
# 3:00 MSK MSD MSM* Moscow
# From Peter Ilieve (1994-12-04),
@@ -746,6 +747,13 @@
# http://www.belta.by/ru/all_news/society/V-Belarusi-otmenjaetsja-perexod-na-sezonnoe-vremja_i_572952.html
# http://naviny.by/rubrics/society/2011/09/16/ic_articles_116_175144/
# http://news.tut.by/society/250578.html
+#
+# From Alexander Bokovoy (2014-10-09):
+# Belarussian government decided against changing to winter time....
+# http://eng.belta.by/all_news/society/Belarus-decides-against-adjusting-time-in-Russias-wake_i_76335.html
+# From Paul Eggert (2014-10-08):
+# Hence Belarus can share time zone abbreviations with Moscow again.
+#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Minsk 1:50:16 - LMT 1880
1:50 - MMT 1924 May 2 # Minsk Mean Time
@@ -758,7 +766,8 @@
2:00 - EET 1992 Mar 29 0:00s
2:00 1:00 EEST 1992 Sep 27 0:00s
2:00 Russia EE%sT 2011 Mar 27 2:00s
- 3:00 - FET
+ 3:00 - FET 2014 Oct 26 1:00s
+ 3:00 - MSK
# Belgium
#
@@ -2524,7 +2533,7 @@
# The Kemerovo region will remain at UTC+7 through the 2014-10-26 change, thus
# realigning itself with KRAT.
-Zone Asia/Novokuznetsk 5:48:48 - NMT 1920 Jan 6
+Zone Asia/Novokuznetsk 5:48:48 - LMT 1924 May 1
6:00 - KRAT 1930 Jun 21 # Krasnoyarsk Time
7:00 Russia KRA%sT 1991 Mar 31 2:00s
6:00 Russia KRA%sT 1992 Jan 19 2:00s
--- a/jdk/make/data/tzdata/northamerica Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/data/tzdata/northamerica Mon Nov 03 10:11:10 2014 -0800
@@ -300,6 +300,12 @@
# time zone, but we do go by the Eastern time zone because so many people work
# in Columbus."
+# From Paul Eggert (2014-09-06):
+# Monthly Notices of the Royal Astronomical Society 44, 4 (1884-02-08), 208
+# says that New York City Hall time was 3 minutes 58.4 seconds fast of
+# Eastern time (i.e., -4:56:01.6) just before the 1883 switch. Round to the
+# nearest second.
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER
Rule NYC 1920 only - Mar lastSun 2:00 1:00 D
Rule NYC 1920 only - Oct lastSun 2:00 0 S
@@ -1118,17 +1124,16 @@
# An amendment to the Interpretation Act was registered on February 19/2007....
# http://action.attavik.ca/home/justice-gn/attach/2007/gaz02part2.pdf
-# From Paul Eggert (2006-04-25):
+# From Paul Eggert (2014-10-18):
# H. David Matthews and Mary Vincent's map
# "It's about TIME", _Canadian Geographic_ (September-October 1998)
-# http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp
+# http://www.canadiangeographic.ca/Magazine/SO98/alacarte.asp
# contains detailed boundaries for regions observing nonstandard
# time and daylight saving time arrangements in Canada circa 1998.
#
-# INMS, the Institute for National Measurement Standards in Ottawa, has
-# information about standard and daylight saving time zones in Canada.
-# http://inms-ienm.nrc-cnrc.gc.ca/en/time_services/daylight_saving_e.php
-# (updated periodically).
+# National Research Council Canada maintains info about time zones and DST.
+# http://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html
+# http://www.nrc-cnrc.gc.ca/eng/services/time/faq/index.html#Q5
# Its unofficial information is often taken from Matthews and Vincent.
# From Paul Eggert (2006-06-27):
@@ -1993,10 +1998,7 @@
# [Also see <http://www.nunatsiaq.com/nunavut/nvt10309_06.html> (2001-03-09).]
# From Gwillim Law (2005-05-21):
-# According to maps at
-# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SWE.jpg
-# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SSE.jpg
-# (both dated 2003), and
+# According to ...
# http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp
# (from a 1998 Canadian Geographic article), the de facto and de jure time
# for Southampton Island (at the north end of Hudson Bay) is UTC-5 all year
@@ -2005,9 +2007,11 @@
# predates the creation of Nunavut, it probably goes back many years....
# The Inuktitut name of Coral Harbour is Sallit, but it's rarely used.
#
-# From Paul Eggert (2005-07-26):
+# From Paul Eggert (2014-10-17):
# For lack of better information, assume that Southampton Island observed
-# daylight saving only during wartime.
+# daylight saving only during wartime. Gwillim Law's email also
+# mentioned maps now maintained by National Research Council Canada;
+# see above for an up-to-date link.
# From Chris Walton (2007-03-01):
# ... the community of Resolute (located on Cornwallis Island in
@@ -3008,10 +3012,21 @@
# Shanks & Pottenger give -5:07:12, but Milne records -5:07:10.41 from an
# unspecified official document, and says "This time is used throughout the
# island". Go with Milne. Round to the nearest second as required by zic.
+#
+# Shanks & Pottenger give April 28 for the 1974 spring-forward transition, but
+# Lance Neita writes that Prime Minister Michael Manley decreed it January 5.
+# Assume Neita meant Jan 6 02:00, the same as the US. Neita also writes that
+# Manley's supporters associated this act with Manley's nickname "Joshua"
+# (recall that in the Bible the sun stood still at Joshua's request),
+# and with the Rod of Correction which Manley said he had received from
+# Haile Selassie, Emperor of Ethiopia. See:
+# Neita L. The politician in all of us. Jamaica Observer 2014-09-20
+# http://www.jamaicaobserver.com/columns/The-politician-in-all-of-us_17573647
+#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Jamaica -5:07:11 - LMT 1890 # Kingston
-5:07:11 - KMT 1912 Feb # Kingston Mean Time
- -5:00 - EST 1974 Apr 28 2:00
+ -5:00 - EST 1974
-5:00 US E%sT 1984
-5:00 - EST
--- a/jdk/make/data/tzdata/zone.tab Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/data/tzdata/zone.tab Mon Nov 03 10:11:10 2014 -0800
@@ -330,7 +330,8 @@
PF -1732-14934 Pacific/Tahiti Society Islands
PF -0900-13930 Pacific/Marquesas Marquesas Islands
PF -2308-13457 Pacific/Gambier Gambier Islands
-PG -0930+14710 Pacific/Port_Moresby
+PG -0930+14710 Pacific/Port_Moresby most locations
+PG -0613+15534 Pacific/Bougainville Bougainville
PH +1435+12100 Asia/Manila
PK +2452+06703 Asia/Karachi
PL +5215+02100 Europe/Warsaw
--- a/jdk/make/profile-includes.txt Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/make/profile-includes.txt Mon Nov 03 10:11:10 2014 -0800
@@ -54,14 +54,12 @@
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
- calendars.properties \
classlist \
ext/localedata.jar \
ext/meta-index \
ext/sunec.jar \
ext/sunjce_provider.jar \
ext/sunpkcs11.jar \
- hijrah-config-umalqura.properties \
jce.jar \
jsse.jar \
logging.properties \
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java Mon Nov 03 10:11:10 2014 -0800
@@ -44,6 +44,10 @@
super(type, chooseDelegatingForm(target));
}
+ protected DelegatingMethodHandle(MethodType type, LambdaForm form) {
+ super(type, form);
+ }
+
/** Define this to extract the delegated target which supplies the invocation behavior. */
abstract protected MethodHandle getTarget();
@@ -88,14 +92,31 @@
return makeReinvokerForm(target, MethodTypeForm.LF_DELEGATE, DelegatingMethodHandle.class, NF_getTarget);
}
+ static LambdaForm makeReinvokerForm(MethodHandle target,
+ int whichCache,
+ Object constraint,
+ NamedFunction getTargetFn) {
+ String debugString;
+ switch(whichCache) {
+ case MethodTypeForm.LF_REBIND: debugString = "BMH.reinvoke"; break;
+ case MethodTypeForm.LF_DELEGATE: debugString = "MH.delegate"; break;
+ default: debugString = "MH.reinvoke"; break;
+ }
+ // No pre-action needed.
+ return makeReinvokerForm(target, whichCache, constraint, debugString, true, getTargetFn, null);
+ }
/** Create a LF which simply reinvokes a target of the given basic type. */
static LambdaForm makeReinvokerForm(MethodHandle target,
int whichCache,
Object constraint,
- NamedFunction getTargetFn) {
+ String debugString,
+ boolean forceInline,
+ NamedFunction getTargetFn,
+ NamedFunction preActionFn) {
MethodType mtype = target.type().basicType();
boolean customized = (whichCache < 0 ||
mtype.parameterSlotCount() > MethodType.MAX_MH_INVOKER_ARITY);
+ boolean hasPreAction = (preActionFn != null);
LambdaForm form;
if (!customized) {
form = mtype.form().cachedLambdaForm(whichCache);
@@ -105,12 +126,16 @@
final int ARG_BASE = 1;
final int ARG_LIMIT = ARG_BASE + mtype.parameterCount();
int nameCursor = ARG_LIMIT;
+ final int PRE_ACTION = hasPreAction ? nameCursor++ : -1;
final int NEXT_MH = customized ? -1 : nameCursor++;
final int REINVOKE = nameCursor++;
LambdaForm.Name[] names = LambdaForm.arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
assert(names.length == nameCursor);
names[THIS_DMH] = names[THIS_DMH].withConstraint(constraint);
Object[] targetArgs;
+ if (hasPreAction) {
+ names[PRE_ACTION] = new LambdaForm.Name(preActionFn, names[THIS_DMH]);
+ }
if (customized) {
targetArgs = Arrays.copyOfRange(names, ARG_BASE, ARG_LIMIT, Object[].class);
names[REINVOKE] = new LambdaForm.Name(target, targetArgs); // the invoker is the target itself
@@ -120,20 +145,14 @@
targetArgs[0] = names[NEXT_MH]; // overwrite this MH with next MH
names[REINVOKE] = new LambdaForm.Name(mtype, targetArgs);
}
- String debugString;
- switch(whichCache) {
- case MethodTypeForm.LF_REBIND: debugString = "BMH.reinvoke"; break;
- case MethodTypeForm.LF_DELEGATE: debugString = "MH.delegate"; break;
- default: debugString = "MH.reinvoke"; break;
- }
- form = new LambdaForm(debugString, ARG_LIMIT, names);
+ form = new LambdaForm(debugString, ARG_LIMIT, names, forceInline);
if (!customized) {
form = mtype.form().setCachedLambdaForm(whichCache, form);
}
return form;
}
- private static final NamedFunction NF_getTarget;
+ static final NamedFunction NF_getTarget;
static {
try {
NF_getTarget = new NamedFunction(DelegatingMethodHandle.class
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Mon Nov 03 10:11:10 2014 -0800
@@ -628,8 +628,13 @@
// Mark this method as a compiled LambdaForm
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Compiled;", true);
- // Force inlining of this invoker method.
- mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
+ if (lambdaForm.forceInline) {
+ // Force inlining of this invoker method.
+ mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
+ } else {
+ mv.visitAnnotation("Ljava/lang/invoke/DontInline;", true);
+ }
+
// iterate over the form's names, generating bytecode instructions for each
// start iterating at the first name following the arguments
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Mon Nov 03 10:11:10 2014 -0800
@@ -119,6 +119,7 @@
class LambdaForm {
final int arity;
final int result;
+ final boolean forceInline;
@Stable final Name[] names;
final String debugName;
MemberName vmentry; // low-level behavior, or null if not yet prepared
@@ -243,11 +244,16 @@
LambdaForm(String debugName,
int arity, Name[] names, int result) {
+ this(debugName, arity, names, result, true);
+ }
+ LambdaForm(String debugName,
+ int arity, Name[] names, int result, boolean forceInline) {
assert(namesOK(arity, names));
this.arity = arity;
this.result = fixResult(result, names);
this.names = names.clone();
this.debugName = fixDebugName(debugName);
+ this.forceInline = forceInline;
int maxOutArity = normalize();
if (maxOutArity > MethodType.MAX_MH_INVOKER_ARITY) {
// Cannot use LF interpreter on very high arity expressions.
@@ -255,17 +261,23 @@
compileToBytecode();
}
}
-
LambdaForm(String debugName,
int arity, Name[] names) {
- this(debugName,
- arity, names, LAST_RESULT);
+ this(debugName, arity, names, LAST_RESULT, true);
}
-
+ LambdaForm(String debugName,
+ int arity, Name[] names, boolean forceInline) {
+ this(debugName, arity, names, LAST_RESULT, forceInline);
+ }
LambdaForm(String debugName,
Name[] formals, Name[] temps, Name result) {
this(debugName,
- formals.length, buildNames(formals, temps, result), LAST_RESULT);
+ formals.length, buildNames(formals, temps, result), LAST_RESULT, true);
+ }
+ LambdaForm(String debugName,
+ Name[] formals, Name[] temps, Name result, boolean forceInline) {
+ this(debugName,
+ formals.length, buildNames(formals, temps, result), LAST_RESULT, forceInline);
}
private static Name[] buildNames(Name[] formals, Name[] temps, Name result) {
@@ -279,6 +291,10 @@
}
private LambdaForm(String sig) {
+ this(sig, true);
+ }
+
+ private LambdaForm(String sig, boolean forceInline) {
// Make a blank lambda form, which returns a constant zero or null.
// It is used as a template for managing the invocation of similar forms that are non-empty.
// Called only from getPreparedForm.
@@ -287,6 +303,7 @@
this.result = (signatureReturn(sig) == V_TYPE ? -1 : arity);
this.names = buildEmptyNames(arity, sig);
this.debugName = "LF.zero";
+ this.forceInline = forceInline;
assert(nameRefsAreLegal());
assert(isEmpty());
assert(sig.equals(basicTypeSignature())) : sig + " != " + basicTypeSignature();
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Mon Nov 03 10:11:10 2014 -0800
@@ -1438,10 +1438,9 @@
/*non-public*/
void updateForm(LambdaForm newForm) {
if (form == newForm) return;
- assert(this instanceof DirectMethodHandle && this.internalMemberName().isStatic());
- // ISSUE: Should we have a memory fence here?
+ newForm.prepare(); // as in MethodHandle.<init>
UNSAFE.putObject(this, FORM_OFFSET, newForm);
- this.form.prepare(); // as in MethodHandle.<init>
+ UNSAFE.fullFence();
}
private static final long FORM_OFFSET;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Mon Nov 03 10:11:10 2014 -0800
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.function.Function;
import sun.invoke.empty.Empty;
import sun.invoke.util.ValueConversions;
@@ -713,10 +714,11 @@
LambdaForm form = makeGuardWithTestForm(basicType);
BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL();
BoundMethodHandle mh;
+
try {
mh = (BoundMethodHandle)
data.constructor().invokeBasic(type, form,
- (Object) test, (Object) target, (Object) fallback);
+ (Object) test, (Object) profile(target), (Object) profile(fallback));
} catch (Throwable ex) {
throw uncaughtException(ex);
}
@@ -724,6 +726,129 @@
return mh;
}
+
+ static
+ MethodHandle profile(MethodHandle target) {
+ if (DONT_INLINE_THRESHOLD >= 0) {
+ return makeBlockInlningWrapper(target);
+ } else {
+ return target;
+ }
+ }
+
+ /**
+ * Block inlining during JIT-compilation of a target method handle if it hasn't been invoked enough times.
+ * Corresponding LambdaForm has @DontInline when compiled into bytecode.
+ */
+ static
+ MethodHandle makeBlockInlningWrapper(MethodHandle target) {
+ LambdaForm lform = PRODUCE_BLOCK_INLINING_FORM.apply(target);
+ return new CountingWrapper(target, lform,
+ PRODUCE_BLOCK_INLINING_FORM, PRODUCE_REINVOKER_FORM,
+ DONT_INLINE_THRESHOLD);
+ }
+
+ /** Constructs reinvoker lambda form which block inlining during JIT-compilation for a particular method handle */
+ private static final Function<MethodHandle, LambdaForm> PRODUCE_BLOCK_INLINING_FORM = new Function<MethodHandle, LambdaForm>() {
+ @Override
+ public LambdaForm apply(MethodHandle target) {
+ return DelegatingMethodHandle.makeReinvokerForm(target,
+ MethodTypeForm.LF_DELEGATE_BLOCK_INLINING, CountingWrapper.class, "reinvoker.dontInline", false,
+ DelegatingMethodHandle.NF_getTarget, CountingWrapper.NF_maybeStopCounting);
+ }
+ };
+
+ /** Constructs simple reinvoker lambda form for a particular method handle */
+ private static final Function<MethodHandle, LambdaForm> PRODUCE_REINVOKER_FORM = new Function<MethodHandle, LambdaForm>() {
+ @Override
+ public LambdaForm apply(MethodHandle target) {
+ return DelegatingMethodHandle.makeReinvokerForm(target,
+ MethodTypeForm.LF_DELEGATE, DelegatingMethodHandle.class, DelegatingMethodHandle.NF_getTarget);
+ }
+ };
+
+ /**
+ * Counting method handle. It has 2 states: counting and non-counting.
+ * It is in counting state for the first n invocations and then transitions to non-counting state.
+ * Behavior in counting and non-counting states is determined by lambda forms produced by
+ * countingFormProducer & nonCountingFormProducer respectively.
+ */
+ static class CountingWrapper extends DelegatingMethodHandle {
+ private final MethodHandle target;
+ private int count;
+ private Function<MethodHandle, LambdaForm> countingFormProducer;
+ private Function<MethodHandle, LambdaForm> nonCountingFormProducer;
+ private volatile boolean isCounting;
+
+ private CountingWrapper(MethodHandle target, LambdaForm lform,
+ Function<MethodHandle, LambdaForm> countingFromProducer,
+ Function<MethodHandle, LambdaForm> nonCountingFormProducer,
+ int count) {
+ super(target.type(), lform);
+ this.target = target;
+ this.count = count;
+ this.countingFormProducer = countingFromProducer;
+ this.nonCountingFormProducer = nonCountingFormProducer;
+ this.isCounting = (count > 0);
+ }
+
+ @Hidden
+ @Override
+ protected MethodHandle getTarget() {
+ return target;
+ }
+
+ @Override
+ public MethodHandle asTypeUncached(MethodType newType) {
+ MethodHandle newTarget = target.asType(newType);
+ MethodHandle wrapper;
+ if (isCounting) {
+ LambdaForm lform;
+ lform = countingFormProducer.apply(target);
+ wrapper = new CountingWrapper(newTarget, lform, countingFormProducer, nonCountingFormProducer, DONT_INLINE_THRESHOLD);
+ } else {
+ wrapper = newTarget; // no need for a counting wrapper anymore
+ }
+ return (asTypeCache = wrapper);
+ }
+
+ boolean countDown() {
+ if (count <= 0) {
+ // Try to limit number of updates. MethodHandle.updateForm() doesn't guarantee LF update visibility.
+ if (isCounting) {
+ isCounting = false;
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ --count;
+ return false;
+ }
+ }
+
+ @Hidden
+ static void maybeStopCounting(Object o1) {
+ CountingWrapper wrapper = (CountingWrapper) o1;
+ if (wrapper.countDown()) {
+ // Reached invocation threshold. Replace counting behavior with a non-counting one.
+ LambdaForm lform = wrapper.nonCountingFormProducer.apply(wrapper.target);
+ lform.compileToBytecode(); // speed up warmup by avoiding LF interpretation again after transition
+ wrapper.updateForm(lform);
+ }
+ }
+
+ static final NamedFunction NF_maybeStopCounting;
+ static {
+ Class<?> THIS_CLASS = CountingWrapper.class;
+ try {
+ NF_maybeStopCounting = new NamedFunction(THIS_CLASS.getDeclaredMethod("maybeStopCounting", Object.class));
+ } catch (ReflectiveOperationException ex) {
+ throw newInternalError(ex);
+ }
+ }
+ }
+
static
LambdaForm makeGuardWithTestForm(MethodType basicType) {
LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_GWT);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java Mon Nov 03 10:11:10 2014 -0800
@@ -47,10 +47,11 @@
static final boolean TRACE_METHOD_LINKAGE;
static final boolean USE_LAMBDA_FORM_EDITOR;
static final int COMPILE_THRESHOLD;
+ static final int DONT_INLINE_THRESHOLD;
static final int PROFILE_LEVEL;
static {
- final Object[] values = { false, false, false, false, false, null, null };
+ final Object[] values = new Object[8];
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
@@ -59,7 +60,8 @@
values[3] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE");
values[4] = Boolean.getBoolean("java.lang.invoke.MethodHandle.USE_LF_EDITOR");
values[5] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", 30);
- values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0);
+ values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", 30);
+ values[7] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0);
return null;
}
});
@@ -69,7 +71,8 @@
TRACE_METHOD_LINKAGE = (Boolean) values[3];
USE_LAMBDA_FORM_EDITOR = (Boolean) values[4];
COMPILE_THRESHOLD = (Integer) values[5];
- PROFILE_LEVEL = (Integer) values[6];
+ DONT_INLINE_THRESHOLD = (Integer) values[6];
+ PROFILE_LEVEL = (Integer) values[7];
}
/** Tell if any of the debugging switches are turned on.
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java Mon Nov 03 10:11:10 2014 -0800
@@ -63,24 +63,25 @@
final @Stable LambdaForm[] lambdaForms;
// Indexes into lambdaForms:
static final int
- LF_INVVIRTUAL = 0, // DMH invokeVirtual
- LF_INVSTATIC = 1,
- LF_INVSPECIAL = 2,
- LF_NEWINVSPECIAL = 3,
- LF_INVINTERFACE = 4,
- LF_INVSTATIC_INIT = 5, // DMH invokeStatic with <clinit> barrier
- LF_INTERPRET = 6, // LF interpreter
- LF_REBIND = 7, // BoundMethodHandle
- LF_DELEGATE = 8, // DelegatingMethodHandle
- LF_EX_LINKER = 9, // invokeExact_MT (for invokehandle)
- LF_EX_INVOKER = 10, // MHs.invokeExact
- LF_GEN_LINKER = 11, // generic invoke_MT (for invokehandle)
- LF_GEN_INVOKER = 12, // generic MHs.invoke
- LF_CS_LINKER = 13, // linkToCallSite_CS
- LF_MH_LINKER = 14, // linkToCallSite_MH
- LF_GWC = 15, // guardWithCatch (catchException)
- LF_GWT = 16, // guardWithTest
- LF_LIMIT = 17;
+ LF_INVVIRTUAL = 0, // DMH invokeVirtual
+ LF_INVSTATIC = 1,
+ LF_INVSPECIAL = 2,
+ LF_NEWINVSPECIAL = 3,
+ LF_INVINTERFACE = 4,
+ LF_INVSTATIC_INIT = 5, // DMH invokeStatic with <clinit> barrier
+ LF_INTERPRET = 6, // LF interpreter
+ LF_REBIND = 7, // BoundMethodHandle
+ LF_DELEGATE = 8, // DelegatingMethodHandle
+ LF_DELEGATE_BLOCK_INLINING = 9, // Counting DelegatingMethodHandle w/ @DontInline
+ LF_EX_LINKER = 10, // invokeExact_MT (for invokehandle)
+ LF_EX_INVOKER = 11, // MHs.invokeExact
+ LF_GEN_LINKER = 12, // generic invoke_MT (for invokehandle)
+ LF_GEN_INVOKER = 13, // generic MHs.invoke
+ LF_CS_LINKER = 14, // linkToCallSite_CS
+ LF_MH_LINKER = 15, // linkToCallSite_MH
+ LF_GWC = 16, // guardWithCatch (catchException)
+ LF_GWT = 17, // guardWithTest
+ LF_LIMIT = 18;
/** Return the type corresponding uniquely (1-1) to this MT-form.
* It might have any primitive returns or arguments, but will have no references except Object.
--- a/jdk/src/java.base/share/classes/java/lang/ref/Finalizer.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/ref/Finalizer.java Mon Nov 03 10:11:10 2014 -0800
@@ -122,18 +122,18 @@
AccessController.doPrivileged(
new PrivilegedAction<Void>() {
public Void run() {
- ThreadGroup tg = Thread.currentThread().getThreadGroup();
- for (ThreadGroup tgn = tg;
- tgn != null;
- tg = tgn, tgn = tg.getParent());
- Thread sft = new Thread(tg, proc, "Secondary finalizer");
- sft.start();
- try {
- sft.join();
- } catch (InterruptedException x) {
- /* Ignore */
- }
- return null;
+ ThreadGroup tg = Thread.currentThread().getThreadGroup();
+ for (ThreadGroup tgn = tg;
+ tgn != null;
+ tg = tgn, tgn = tg.getParent());
+ Thread sft = new Thread(tg, proc, "Secondary finalizer");
+ sft.start();
+ try {
+ sft.join();
+ } catch (InterruptedException x) {
+ Thread.currentThread().interrupt();
+ }
+ return null;
}});
}
@@ -146,6 +146,7 @@
forkSecondaryFinalizer(new Runnable() {
private volatile boolean running;
public void run() {
+ // in case of recursive call to run()
if (running)
return;
final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
@@ -168,6 +169,7 @@
forkSecondaryFinalizer(new Runnable() {
private volatile boolean running;
public void run() {
+ // in case of recursive call to run()
if (running)
return;
final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
@@ -189,6 +191,7 @@
super(g, "Finalizer");
}
public void run() {
+ // in case of recursive call to run()
if (running)
return;
--- a/jdk/src/java.base/share/classes/java/nio/Buffer.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/nio/Buffer.java Mon Nov 03 10:11:10 2014 -0800
@@ -239,7 +239,7 @@
* @throws IllegalArgumentException
* If the preconditions on <tt>newPosition</tt> do not hold
*/
- public final Buffer position(int newPosition) {
+ public Buffer position(int newPosition) {
if ((newPosition > limit) || (newPosition < 0))
throw new IllegalArgumentException();
position = newPosition;
@@ -270,7 +270,7 @@
* @throws IllegalArgumentException
* If the preconditions on <tt>newLimit</tt> do not hold
*/
- public final Buffer limit(int newLimit) {
+ public Buffer limit(int newLimit) {
if ((newLimit > capacity) || (newLimit < 0))
throw new IllegalArgumentException();
limit = newLimit;
@@ -284,7 +284,7 @@
*
* @return This buffer
*/
- public final Buffer mark() {
+ public Buffer mark() {
mark = position;
return this;
}
@@ -300,7 +300,7 @@
* @throws InvalidMarkException
* If the mark has not been set
*/
- public final Buffer reset() {
+ public Buffer reset() {
int m = mark;
if (m < 0)
throw new InvalidMarkException();
@@ -325,7 +325,7 @@
*
* @return This buffer
*/
- public final Buffer clear() {
+ public Buffer clear() {
position = 0;
limit = capacity;
mark = -1;
@@ -353,7 +353,7 @@
*
* @return This buffer
*/
- public final Buffer flip() {
+ public Buffer flip() {
limit = position;
position = 0;
mark = -1;
@@ -375,7 +375,7 @@
*
* @return This buffer
*/
- public final Buffer rewind() {
+ public Buffer rewind() {
position = 0;
mark = -1;
return this;
--- a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java Mon Nov 03 10:11:10 2014 -0800
@@ -208,4 +208,76 @@
private native boolean isLoaded0(long address, long length, int pageCount);
private native void load0(long address, long length);
private native void force0(FileDescriptor fd, long address, long length);
+
+ // -- Covariant return type overrides
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer position(int newPosition) {
+ super.position(newPosition);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer limit(int newLimit) {
+ super.limit(newLimit);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer mark() {
+ super.mark();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer reset() {
+ super.reset();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer clear() {
+ super.clear();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer flip() {
+ super.flip();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer rewind() {
+ super.rewind();
+ return this;
+ }
}
--- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template Mon Nov 03 10:11:10 2014 -0800
@@ -1025,6 +1025,106 @@
return offset;
}
+ // -- Covariant return type overrides
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer position(int newPosition) {
+ super.position(newPosition);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer limit(int newLimit) {
+ super.limit(newLimit);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer mark() {
+ super.mark();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer reset() {
+ super.reset();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer clear() {
+ super.clear();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer flip() {
+ super.flip();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer rewind() {
+ super.rewind();
+ return this;
+ }
+
/**
* Compacts this buffer <i>(optional operation)</i>.
*
--- a/jdk/src/java.base/share/classes/java/nio/file/Files.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/nio/file/Files.java Mon Nov 03 10:11:10 2014 -0800
@@ -303,7 +303,7 @@
* is a {@link java.nio.channels.FileChannel}.
*
* <p> <b>Usage Examples:</b>
- * <pre>
+ * <pre>{@code
* Path path = ...
*
* // open file for reading
@@ -314,9 +314,10 @@
* WritableByteChannel wbc = Files.newByteChannel(path, EnumSet.of(CREATE,APPEND));
*
* // create file with initial permissions, opening it for both reading and writing
- * {@code FileAttribute<Set<PosixFilePermission>> perms = ...}
- * SeekableByteChannel sbc = Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms);
- * </pre>
+ * FileAttribute<Set<PosixFilePermission>> perms = ...
+ * SeekableByteChannel sbc =
+ * Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms);
+ * }</pre>
*
* @param path
* the path to the file to open or create
@@ -1702,7 +1703,8 @@
* Alternatively, suppose we want to read file's POSIX attributes without
* following symbolic links:
* <pre>
- * PosixFileAttributes attrs = Files.readAttributes(path, PosixFileAttributes.class, NOFOLLOW_LINKS);
+ * PosixFileAttributes attrs =
+ * Files.readAttributes(path, PosixFileAttributes.class, NOFOLLOW_LINKS);
* </pre>
*
* @param <A>
@@ -2840,6 +2842,8 @@
* @return a new buffered writer, with default buffer size, to write text
* to the file
*
+ * @throws IllegalArgumentException
+ * if {@code options} contains an invalid combination of options
* @throws IOException
* if an I/O error occurs opening or creating the file
* @throws UnsupportedOperationException
@@ -2880,6 +2884,8 @@
* @return a new buffered writer, with default buffer size, to write text
* to the file
*
+ * @throws IllegalArgumentException
+ * if {@code options} contains an invalid combination of options
* @throws IOException
* if an I/O error occurs opening or creating the file
* @throws UnsupportedOperationException
@@ -2891,7 +2897,9 @@
*
* @since 1.8
*/
- public static BufferedWriter newBufferedWriter(Path path, OpenOption... options) throws IOException {
+ public static BufferedWriter newBufferedWriter(Path path, OpenOption... options)
+ throws IOException
+ {
return newBufferedWriter(path, StandardCharsets.UTF_8, options);
}
@@ -3273,6 +3281,8 @@
*
* @return the path
*
+ * @throws IllegalArgumentException
+ * if {@code options} contains an invalid combination of options
* @throws IOException
* if an I/O error occurs writing to or creating the file
* @throws UnsupportedOperationException
@@ -3330,6 +3340,8 @@
*
* @return the path
*
+ * @throws IllegalArgumentException
+ * if {@code options} contains an invalid combination of options
* @throws IOException
* if an I/O error occurs writing to or creating the file, or the
* text cannot be encoded using the specified charset
@@ -3376,6 +3388,8 @@
*
* @return the path
*
+ * @throws IllegalArgumentException
+ * if {@code options} contains an invalid combination of options
* @throws IOException
* if an I/O error occurs writing to or creating the file, or the
* text cannot be encoded as {@code UTF-8}
@@ -3452,7 +3466,7 @@
final Iterator<Path> delegate = ds.iterator();
// Re-wrap DirectoryIteratorException to UncheckedIOException
- Iterator<Path> it = new Iterator<Path>() {
+ Iterator<Path> iterator = new Iterator<Path>() {
@Override
public boolean hasNext() {
try {
@@ -3471,7 +3485,9 @@
}
};
- return StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, Spliterator.DISTINCT), false)
+ Spliterator<Path> spliterator =
+ Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT);
+ return StreamSupport.stream(spliterator, false)
.onClose(asUncheckedRunnable(ds));
} catch (Error|RuntimeException e) {
try {
@@ -3572,7 +3588,9 @@
{
FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options);
try {
- return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT), false)
+ Spliterator<FileTreeWalker.Event> spliterator =
+ Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT);
+ return StreamSupport.stream(spliterator, false)
.onClose(iterator::close)
.map(entry -> entry.file());
} catch (Error|RuntimeException e) {
@@ -3685,7 +3703,9 @@
{
FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options);
try {
- return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT), false)
+ Spliterator<FileTreeWalker.Event> spliterator =
+ Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT);
+ return StreamSupport.stream(spliterator, false)
.onClose(iterator::close)
.filter(entry -> matcher.test(entry.file(), entry.attributes()))
.map(entry -> entry.file());
--- a/jdk/src/java.base/share/classes/java/nio/file/package-info.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/nio/file/package-info.java Mon Nov 03 10:11:10 2014 -0800
@@ -86,8 +86,8 @@
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method of any class or interface in this package will cause a {@link
* java.lang.NullPointerException NullPointerException} to be thrown. Additionally,
- * invoking a method with a collection containing a {@code null} element will
- * cause a {@code NullPointerException}, unless otherwise specified. </p>
+ * invoking a method with an array or collection containing a {@code null} element
+ * will cause a {@code NullPointerException}, unless otherwise specified. </p>
*
* <p> Unless otherwise noted, methods that attempt to access the file system
* will throw {@link java.nio.file.ClosedFileSystemException} when invoked on
--- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Mon Nov 03 10:11:10 2014 -0800
@@ -61,13 +61,14 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.security.AccessController;
-import java.security.PrivilegedActionException;
+import java.security.PrivilegedAction;
import java.time.Clock;
import java.time.DateTimeException;
import java.time.Instant;
@@ -145,29 +146,8 @@
* property resource that defines the {@code ID}, the {@code calendar type},
* the start of the calendar, the alignment with the
* ISO calendar, and the length of each month for a range of years.
- * The variants are identified in the {@code calendars.properties} file.
- * The new properties are prefixed with {@code "calendars.hijrah."}:
- * <table cellpadding="2" border="0" summary="Configuration of Hijrah Calendar Variants">
- * <thead>
- * <tr class="tableSubHeadingColor">
- * <th class="colFirst" align="left">Property Name</th>
- * <th class="colFirst" align="left">Property value</th>
- * <th class="colLast" align="left">Description </th>
- * </tr>
- * </thead>
- * <tbody>
- * <tr class="altColor">
- * <td>calendars.hijrah.{ID}</td>
- * <td>The property resource defining the {@code {ID}} variant</td>
- * <td>The property resource is located with the {@code calendars.properties} file</td>
- * </tr>
- * <tr class="rowColor">
- * <td>calendars.hijrah.{ID}.type</td>
- * <td>The calendar type</td>
- * <td>LDML defines the calendar type names</td>
- * </tr>
- * </tbody>
- * </table>
+ * The variants are loaded by HijrahChronology as a resource from
+ * hijrah-config-<calendar type>.properties.
* <p>
* The Hijrah property resource is a set of properties that describe the calendar.
* The syntax is defined by {@code java.util.Properties#load(Reader)}.
@@ -279,91 +259,41 @@
* Computed by {@link #createEpochMonths}.
*/
private transient int maxYearLength;
- /**
- * A reference to the properties stored in
- * ${java.home}/lib/calendars.properties
- */
- private final transient static Properties calendarProperties;
/**
- * Prefix of property names for Hijrah calendar variants.
+ * Prefix of resource names for Hijrah calendar variants.
*/
- private static final String PROP_PREFIX = "calendar.hijrah.";
- /**
- * Suffix of property names containing the calendar type of a variant.
- */
- private static final String PROP_TYPE_SUFFIX = ".type";
+ private static final String RESOURCE_PREFIX = "hijrah-config-";
/**
- * Static initialization of the predefined calendars found in the
- * lib/calendars.properties file.
+ * Suffix of resource names for Hijrah calendar variants.
+ */
+ private static final String RESOURCE_SUFFIX = ".properties";
+
+ /**
+ * Static initialization of the built-in calendars.
+ * The data is not loaded until it is used.
*/
static {
- try {
- calendarProperties = sun.util.calendar.BaseCalendar.getCalendarProperties();
- } catch (IOException ioe) {
- throw new InternalError("Can't initialize lib/calendars.properties", ioe);
- }
-
- try {
- INSTANCE = new HijrahChronology("Hijrah-umalqura");
- // Register it by its aliases
- AbstractChronology.registerChrono(INSTANCE, "Hijrah");
- AbstractChronology.registerChrono(INSTANCE, "islamic");
- } catch (DateTimeException ex) {
- // Absence of Hijrah calendar is fatal to initializing this class.
- PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono");
- logger.severe("Unable to initialize Hijrah calendar: Hijrah-umalqura", ex);
- throw new RuntimeException("Unable to initialize Hijrah-umalqura calendar", ex.getCause());
- }
- registerVariants();
+ INSTANCE = new HijrahChronology("Hijrah-umalqura", "islamic-umalqura");
+ // Register it by its aliases
+ AbstractChronology.registerChrono(INSTANCE, "Hijrah");
+ AbstractChronology.registerChrono(INSTANCE, "islamic");
}
/**
- * For each Hijrah variant listed, create the HijrahChronology and register it.
- * Exceptions during initialization are logged but otherwise ignored.
+ * Create a HijrahChronology for the named variant and type.
+ *
+ * @param id the id of the calendar
+ * @param calType the typeId of the calendar
+ * @throws IllegalArgumentException if the id or typeId is empty
*/
- private static void registerVariants() {
- for (String name : calendarProperties.stringPropertyNames()) {
- if (name.startsWith(PROP_PREFIX)) {
- String id = name.substring(PROP_PREFIX.length());
- if (id.indexOf('.') >= 0) {
- continue; // no name or not a simple name of a calendar
- }
- if (id.equals(INSTANCE.getId())) {
- continue; // do not duplicate the default
- }
- try {
- // Create and register the variant
- HijrahChronology chrono = new HijrahChronology(id);
- AbstractChronology.registerChrono(chrono);
- } catch (DateTimeException ex) {
- // Log error and continue
- PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono");
- logger.severe("Unable to initialize Hijrah calendar: " + id, ex);
- }
- }
- }
- }
-
- /**
- * Create a HijrahChronology for the named variant.
- * The resource and calendar type are retrieved from properties
- * in the {@code calendars.properties}.
- * The property names are {@code "calendar.hijrah." + id}
- * and {@code "calendar.hijrah." + id + ".type"}
- * @param id the id of the calendar
- * @throws DateTimeException if the calendar type is missing from the properties file.
- * @throws IllegalArgumentException if the id is empty
- */
- private HijrahChronology(String id) throws DateTimeException {
+ private HijrahChronology(String id, String calType) {
if (id.isEmpty()) {
throw new IllegalArgumentException("calendar id is empty");
}
- String propName = PROP_PREFIX + id + PROP_TYPE_SUFFIX;
- String calType = calendarProperties.getProperty(propName);
- if (calType == null || calType.isEmpty()) {
- throw new DateTimeException("calendarType is missing or empty for: " + propName);
+ if (calType.isEmpty()) {
+ throw new IllegalArgumentException("calendar typeId is empty");
}
this.typeId = id;
this.calendarType = calType;
@@ -866,30 +796,26 @@
/**
* Return the configuration properties from the resource.
* <p>
- * The default location of the variant configuration resource is:
+ * The location of the variant configuration resource is:
* <pre>
- * "$java.home/lib/" + resource-name
+ * "/java/time/chrono/hijrah-config-" + calendarType + ".properties"
* </pre>
*
- * @param resource the name of the calendar property resource
+ * @param calendarType the calendarType of the calendar variant
* @return a Properties containing the properties read from the resource.
* @throws Exception if access to the property resource fails
*/
- private static Properties readConfigProperties(final String resource) throws Exception {
- try {
- return AccessController
- .doPrivileged((java.security.PrivilegedExceptionAction<Properties>)
- () -> {
- String libDir = System.getProperty("java.home") + File.separator + "lib";
- File file = new File(libDir, resource);
- Properties props = new Properties();
- try (InputStream is = new FileInputStream(file)) {
- props.load(is);
- }
- return props;
- });
- } catch (PrivilegedActionException pax) {
- throw pax.getException();
+ private Properties readConfigProperties(final String calendarType) throws Exception {
+ String resourceName = RESOURCE_PREFIX + calendarType + RESOURCE_SUFFIX;
+ PrivilegedAction<InputStream> getResourceAction = () -> HijrahChronology.class.getResourceAsStream(resourceName);
+ FilePermission perm = new FilePermission("<<ALL FILES>>", "read");
+ try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm)) {
+ if (is == null) {
+ throw new RuntimeException("Hijrah calendar resource not found: /java/time/chrono/" + resourceName);
+ }
+ Properties props = new Properties();
+ props.load(is);
+ return props;
}
}
@@ -906,9 +832,7 @@
*/
private void loadCalendarData() {
try {
- String resourceName = calendarProperties.getProperty(PROP_PREFIX + typeId);
- Objects.requireNonNull(resourceName, "Resource missing for calendar: " + PROP_PREFIX + typeId);
- Properties props = readConfigProperties(resourceName);
+ Properties props = readConfigProperties(calendarType);
Map<Integer, int[]> years = new HashMap<>();
int minYear = Integer.MAX_VALUE;
@@ -937,7 +861,7 @@
default:
try {
// Everything else is either a year or invalid
- int year = Integer.valueOf(key);
+ int year = Integer.parseInt(key);
int[] months = parseMonths((String) entry.getValue());
years.put(year, months);
maxYear = Math.max(maxYear, year);
@@ -1045,7 +969,7 @@
}
for (int i = 0; i < 12; i++) {
try {
- months[i] = Integer.valueOf(numbers[i]);
+ months[i] = Integer.parseInt(numbers[i]);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("bad key: " + numbers[i]);
}
@@ -1067,9 +991,9 @@
throw new IllegalArgumentException("date must be yyyy-MM-dd");
}
int[] ymd = new int[3];
- ymd[0] = Integer.valueOf(string.substring(0, 4));
- ymd[1] = Integer.valueOf(string.substring(5, 7));
- ymd[2] = Integer.valueOf(string.substring(8, 10));
+ ymd[0] = Integer.parseInt(string, 0, 4, 10);
+ ymd[1] = Integer.parseInt(string, 5, 7, 10);
+ ymd[2] = Integer.parseInt(string, 8, 10, 10);
return ymd;
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("date must be yyyy-MM-dd", ex);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/time/chrono/hijrah-config-islamic-umalqura.properties Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,369 @@
+# 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. 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 properties file defines a Hijrah calendar variant.
+#
+# Fields:
+#
+# <version> ::= 'version' '=' <version string>
+# <id> ::= 'id' '=' <id string>
+# <type> ::= 'type' '=' <type string>
+# <iso-start> ::= 'iso-start' '=' <start date in the ISO calendar>
+# <year> ::= <yyyy> '=' <nn nn nn nn nn nn nn nn nn nn nn nn>
+#
+# version ... (Required)
+#
+# id ... (Required)
+# Identifies the Java Chronology
+#
+# type ... (Required)
+# Identifies the type of calendar in the standard calendar ID scheme
+# iso-start ... (Required)
+# Specifies the corresponding ISO date to the first Hijrah day
+# in the defined range of dates
+#
+# year ... (Required)
+# Number of days for each month of a Hijrah year
+# * Each line defines a year. The years must be in chronological
+# order and no gap is allowed.
+# * Each line is in the form indicated above. <yyyy> is a Hijrah year and
+# nn is the number of days for a month listed in the order of the months.
+# * Each year must have 12 months.
+# * Each month should be 29 or 30 days long.
+# * There must be one or more space characters between the months.
+#
+
+# Version of this definition
+version=1.8.0_1
+
+# Java chronology ID
+id=Hijrah-umalqura
+
+# Standard calendar type specification
+type=islamic-umalqura
+
+# defines the corresponding ISO date to the earliest Hijrah date
+iso-start=1882-11-12
+
+# 1 2 3 4 5 6 7 8 9 10 11 12
+1300=30 29 30 29 30 29 30 29 30 29 30 29
+1301=30 30 29 30 29 30 29 30 29 30 29 29
+1302=30 30 30 29 30 30 29 29 30 29 29 30
+1303=29 30 30 29 30 30 29 30 29 30 29 29
+1304=29 30 30 29 30 30 30 29 30 29 30 29
+1305=29 29 30 30 29 30 30 29 30 30 29 29
+1306=30 29 30 29 30 29 30 29 30 30 29 30
+1307=29 30 29 30 29 30 29 30 29 30 29 30
+1308=29 30 30 29 30 29 30 29 30 29 29 30
+1309=29 30 30 30 30 29 29 30 29 29 30 29
+1310=30 29 30 30 30 29 30 29 30 29 29 30
+1311=29 30 29 30 30 30 29 30 29 30 29 29
+1312=30 29 30 29 30 30 29 30 30 29 30 29
+1313=29 30 29 30 29 30 29 30 30 30 29 29
+1314=30 30 29 30 29 29 30 29 30 30 29 30
+1315=29 30 30 29 30 29 29 30 29 30 29 30
+1316=29 30 30 30 29 30 29 29 30 29 30 29
+1317=30 29 30 30 29 30 29 30 29 30 29 29
+1318=30 29 30 30 29 30 30 29 30 29 30 29
+1319=29 30 29 30 30 29 30 29 30 30 29 30
+1320=29 30 29 29 30 29 30 29 30 30 30 29
+1321=30 29 30 29 29 30 29 29 30 30 30 30
+1322=29 30 29 30 29 29 29 30 29 30 30 30
+1323=29 30 30 29 30 29 29 29 30 29 30 30
+1324=29 30 30 29 30 29 30 29 29 30 29 30
+1325=30 29 30 29 30 30 29 30 29 30 29 30
+1326=29 29 30 29 30 30 29 30 29 30 30 29
+1327=30 29 29 30 29 30 29 30 30 29 30 30
+1328=29 30 29 29 30 29 29 30 30 30 29 30
+1329=30 29 30 29 29 30 29 29 30 30 29 30
+1330=30 30 29 30 29 29 30 29 29 30 30 29
+1331=30 30 29 30 30 29 29 30 29 30 29 30
+1332=29 30 29 30 30 29 30 29 30 30 29 29
+1333=30 29 29 30 30 29 30 30 29 30 30 29
+1334=29 29 30 29 30 29 30 30 30 29 30 29
+1335=30 29 30 29 29 30 29 30 30 29 30 30
+1336=29 30 29 30 29 29 30 29 30 29 30 30
+1337=30 29 30 29 30 29 29 30 29 30 29 30
+1338=29 30 30 29 30 30 29 29 30 29 30 29
+1339=30 29 30 29 30 30 30 29 30 29 29 30
+1340=29 29 30 29 30 30 30 30 29 30 29 29
+1341=30 29 29 30 29 30 30 30 29 30 30 29
+1342=29 29 30 29 30 29 30 30 29 30 30 29
+1343=30 29 29 30 29 30 29 30 29 30 30 29
+1344=30 29 30 29 30 30 29 29 30 29 30 29
+1345=30 29 30 30 30 29 30 29 29 30 29 29
+1346=30 29 30 30 30 30 29 30 29 29 30 29
+1347=29 30 29 30 30 30 29 30 30 29 29 30
+1348=29 29 30 29 30 30 29 30 30 30 29 29
+1349=30 29 29 30 29 30 30 29 30 30 29 30
+1350=29 30 29 30 29 30 29 29 30 30 29 30
+1351=30 29 30 29 30 29 30 29 29 30 29 30
+1352=30 29 30 30 29 30 29 30 29 29 30 29
+1353=30 29 30 30 30 29 30 29 29 30 29 30
+1354=29 30 29 30 30 29 30 30 29 30 29 29
+1355=30 29 29 30 30 29 30 30 29 30 30 29
+1356=29 30 29 30 29 30 29 30 29 30 30 30
+1357=29 29 30 29 30 29 29 30 29 30 30 30
+1358=29 30 29 30 29 30 29 29 30 29 30 30
+1359=29 30 30 29 30 29 30 29 29 29 30 30
+1360=29 30 30 30 29 30 29 30 29 29 30 29
+1361=30 29 30 30 29 30 30 29 29 30 29 30
+1362=29 30 29 30 29 30 30 29 30 29 30 29
+1363=30 29 30 29 30 29 30 29 30 29 30 30
+1364=29 30 29 30 29 29 30 29 30 29 30 30
+1365=30 30 29 29 30 29 29 30 29 30 29 30
+1366=30 30 29 30 29 30 29 29 30 29 30 29
+1367=30 30 29 30 30 29 30 29 29 30 29 30
+1368=29 30 29 30 30 30 29 29 30 29 30 29
+1369=30 29 30 29 30 30 29 30 29 30 30 29
+1370=30 29 29 30 29 30 29 30 29 30 30 30
+1371=29 30 29 29 30 29 30 29 30 29 30 30
+1372=30 29 29 30 29 30 29 29 30 29 30 30
+1373=30 29 30 29 30 29 30 29 29 30 29 30
+1374=30 29 30 30 29 30 29 30 29 29 30 29
+1375=30 29 30 30 29 30 30 29 30 29 30 29
+1376=29 30 29 30 29 30 30 30 29 30 29 30
+1377=29 29 30 29 29 30 30 30 29 30 30 29
+1378=30 29 29 29 30 29 30 30 29 30 30 30
+1379=29 30 29 29 29 30 29 30 30 29 30 30
+1380=29 30 29 30 29 30 29 30 29 30 29 30
+1381=29 30 29 30 30 29 30 29 30 29 29 30
+1382=29 30 29 30 30 29 30 30 29 30 29 29
+1383=30 29 29 30 30 30 29 30 30 29 30 29
+1384=29 30 29 29 30 30 29 30 30 30 29 30
+1385=29 29 30 29 29 30 30 29 30 30 30 29
+1386=30 29 29 30 29 29 30 30 29 30 30 29
+1387=30 29 30 29 30 29 30 29 30 29 30 29
+1388=30 30 29 30 29 30 29 30 29 30 29 29
+1389=30 30 29 30 30 29 30 30 29 29 30 29
+1390=29 30 29 30 30 30 29 30 29 30 29 30
+1391=29 29 30 29 30 30 29 30 30 29 30 29
+1392=30 29 29 30 29 30 29 30 30 29 30 30
+1393=29 30 29 29 30 29 30 29 30 29 30 30
+1394=30 29 30 29 29 30 29 30 29 30 29 30
+1395=30 29 30 30 29 30 29 29 30 29 29 30
+1396=30 29 30 30 29 30 30 29 29 30 29 29
+1397=30 29 30 30 29 30 30 30 29 29 29 30
+1398=29 30 29 30 30 29 30 30 29 30 29 29
+1399=30 29 30 29 30 29 30 30 29 30 29 30
+1400=30 29 30 29 29 30 29 30 29 30 29 30
+1401=30 30 29 30 29 29 30 29 29 30 29 30
+1402=30 30 30 29 30 29 29 30 29 29 30 29
+1403=30 30 30 29 30 30 29 29 30 29 29 30
+1404=29 30 30 29 30 30 29 30 29 30 29 29
+1405=30 29 30 29 30 30 30 29 30 29 29 30
+1406=30 29 29 30 29 30 30 29 30 29 30 30
+1407=29 30 29 29 30 29 30 29 30 29 30 30
+1408=30 29 30 29 30 29 29 30 29 29 30 30
+1409=30 30 29 30 29 30 29 29 30 29 29 30
+1410=30 30 29 30 30 29 30 29 29 30 29 29
+1411=30 30 29 30 30 29 30 30 29 29 30 29
+1412=30 29 30 29 30 29 30 30 30 29 29 30
+1413=29 30 29 29 30 29 30 30 30 29 30 29
+1414=30 29 30 29 29 30 29 30 30 29 30 30
+1415=29 30 29 30 29 29 30 29 30 29 30 30
+1416=30 29 30 29 30 29 29 30 29 30 29 30
+1417=30 29 30 30 29 29 30 29 30 29 30 29
+1418=30 29 30 30 29 30 29 30 29 30 29 30
+1419=29 30 29 30 29 30 29 30 30 30 29 29
+1420=29 30 29 29 30 29 30 30 30 30 29 30
+1421=29 29 30 29 29 29 30 30 30 30 29 30
+1422=30 29 29 30 29 29 29 30 30 30 29 30
+1423=30 29 30 29 30 29 29 30 29 30 29 30
+1424=30 29 30 30 29 30 29 29 30 29 30 29
+1425=30 29 30 30 29 30 29 30 30 29 30 29
+1426=29 30 29 30 29 30 30 29 30 30 29 30
+1427=29 29 30 29 30 29 30 30 29 30 30 29
+1428=30 29 29 30 29 29 30 30 30 29 30 30
+1429=29 30 29 29 30 29 29 30 30 29 30 30
+1430=29 30 30 29 29 30 29 30 29 30 29 30
+1431=29 30 30 29 30 29 30 29 30 29 29 30
+1432=29 30 30 30 29 30 29 30 29 30 29 29
+1433=30 29 30 30 29 30 30 29 30 29 30 29
+1434=29 30 29 30 29 30 30 29 30 30 29 29
+1435=30 29 30 29 30 29 30 29 30 30 29 30
+1436=29 30 29 30 29 30 29 30 29 30 29 30
+1437=30 29 30 30 29 29 30 29 30 29 29 30
+1438=30 29 30 30 30 29 29 30 29 29 30 29
+1439=30 29 30 30 30 29 30 29 30 29 29 30
+1440=29 30 29 30 30 30 29 30 29 30 29 29
+1441=30 29 30 29 30 30 29 30 30 29 30 29
+1442=29 30 29 30 29 30 29 30 30 29 30 29
+1443=30 29 30 29 30 29 30 29 30 29 30 30
+1444=29 30 29 30 30 29 29 30 29 30 29 30
+1445=29 30 30 30 29 30 29 29 30 29 29 30
+1446=29 30 30 30 29 30 30 29 29 30 29 29
+1447=30 29 30 30 30 29 30 29 30 29 30 29
+1448=29 30 29 30 30 29 30 30 29 30 29 30
+1449=29 29 30 29 30 29 30 30 29 30 30 29
+1450=30 29 30 29 29 30 29 30 29 30 30 29
+1451=30 30 30 29 29 30 29 29 30 30 29 30
+1452=30 29 30 30 29 29 30 29 29 30 29 30
+1453=30 29 30 30 29 30 29 30 29 29 30 29
+1454=30 29 30 30 29 30 30 29 30 29 30 29
+1455=29 30 29 30 30 29 30 29 30 30 29 30
+1456=29 29 30 29 30 29 30 29 30 30 30 29
+1457=30 29 29 30 29 29 30 29 30 30 30 30
+1458=29 30 29 29 30 29 29 30 29 30 30 30
+1459=29 30 30 29 29 30 29 29 30 29 30 30
+1460=29 30 30 29 30 29 30 29 29 30 29 30
+1461=29 30 30 29 30 29 30 29 30 30 29 29
+1462=30 29 30 29 30 30 29 30 29 30 30 29
+1463=29 30 29 30 29 30 29 30 30 30 29 30
+1464=29 30 29 29 30 29 29 30 30 30 29 30
+1465=30 29 30 29 29 30 29 29 30 30 29 30
+1466=30 30 29 30 29 29 29 30 29 30 30 29
+1467=30 30 29 30 30 29 29 30 29 30 29 30
+1468=29 30 29 30 30 29 30 29 30 29 30 29
+1469=29 30 29 30 30 29 30 30 29 30 29 30
+1470=29 29 30 29 30 30 29 30 30 29 30 29
+1471=30 29 29 30 29 30 29 30 30 29 30 30
+1472=29 30 29 29 30 29 30 29 30 30 29 30
+1473=29 30 29 30 30 29 29 30 29 30 29 30
+1474=29 30 30 29 30 30 29 29 30 29 30 29
+1475=29 30 30 29 30 30 30 29 29 30 29 29
+1476=30 29 30 29 30 30 30 29 30 29 30 29
+1477=29 30 29 29 30 30 30 30 29 30 29 30
+1478=29 29 30 29 30 29 30 30 29 30 30 29
+1479=30 29 29 30 29 30 29 30 29 30 30 29
+1480=30 29 30 29 30 29 30 29 30 29 30 29
+1481=30 29 30 30 29 30 29 30 29 30 29 29
+1482=30 29 30 30 30 30 29 30 29 29 30 29
+1483=29 30 29 30 30 30 29 30 30 29 29 30
+1484=29 29 30 29 30 30 30 29 30 29 30 29
+1485=30 29 29 30 29 30 30 29 30 30 29 30
+1486=29 30 29 29 30 29 30 29 30 30 29 30
+1487=30 29 30 29 30 29 29 30 29 30 29 30
+1488=30 29 30 30 29 30 29 29 30 29 30 29
+1489=30 29 30 30 30 29 30 29 29 30 29 30
+1490=29 30 29 30 30 29 30 30 29 29 30 29
+1491=30 29 29 30 30 29 30 30 29 30 29 30
+1492=29 30 29 29 30 30 29 30 29 30 30 29
+1493=30 29 30 29 30 29 29 30 29 30 30 30
+1494=29 30 29 30 29 30 29 29 29 30 30 30
+1495=29 30 30 29 30 29 29 30 29 29 30 30
+1496=29 30 30 30 29 30 29 29 30 29 29 30
+1497=30 29 30 30 29 30 29 30 29 30 29 30
+1498=29 30 29 30 29 30 30 29 30 29 30 29
+1499=30 29 30 29 29 30 30 29 30 29 30 30
+1500=29 30 29 30 29 29 30 29 30 29 30 30
+1501=30 29 30 29 30 29 29 29 30 29 30 30
+1502=30 30 29 30 29 30 29 29 29 30 30 29
+1503=30 30 29 30 30 29 30 29 29 29 30 30
+1504=29 30 29 30 30 30 29 29 30 29 30 29
+1505=30 29 30 29 30 30 29 30 29 30 30 29
+1506=29 30 29 29 30 30 29 30 30 29 30 30
+1507=29 29 30 29 29 30 30 29 30 29 30 30
+1508=30 29 29 30 29 30 29 29 30 29 30 30
+1509=30 29 30 29 30 29 30 29 29 30 29 30
+1510=30 29 30 30 29 30 29 30 29 29 30 29
+1511=30 29 30 30 29 30 30 29 30 29 29 30
+1512=29 30 29 30 29 30 30 30 29 30 29 30
+1513=29 29 29 30 29 30 30 30 29 30 30 29
+1514=30 29 29 29 30 29 30 30 29 30 30 30
+1515=29 29 30 29 29 30 29 30 30 29 30 30
+1516=29 30 29 30 29 29 30 29 30 29 30 30
+1517=29 30 29 30 29 30 30 29 29 30 29 30
+1518=29 30 29 30 30 29 30 30 29 30 29 29
+1519=30 29 29 30 30 30 29 30 30 29 30 29
+1520=29 30 29 29 30 30 30 29 30 30 29 30
+1521=29 29 29 30 29 30 30 29 30 30 29 30
+1522=30 29 29 29 30 29 30 30 29 30 30 29
+1523=30 29 30 29 30 29 30 29 29 30 30 29
+1524=30 30 29 30 29 30 29 30 29 29 30 29
+1525=30 30 29 30 30 29 30 29 30 29 29 30
+1526=29 30 29 30 30 30 29 30 29 30 29 29
+1527=30 29 30 29 30 30 29 30 30 29 30 29
+1528=30 29 29 30 29 30 29 30 30 29 30 30
+1529=29 30 29 29 30 29 30 29 30 29 30 30
+1530=29 30 30 29 29 30 29 30 29 29 30 30
+1531=29 30 30 30 29 29 30 29 30 29 29 30
+1532=29 30 30 30 29 30 30 29 29 29 30 29
+1533=30 29 30 30 30 29 30 29 30 29 29 30
+1534=29 30 29 30 30 29 30 30 29 29 30 29
+1535=30 29 30 29 30 29 30 30 29 30 29 30
+1536=29 30 29 30 29 30 29 30 29 30 29 30
+1537=30 29 30 30 29 29 30 29 29 30 29 30
+1538=30 30 29 30 30 29 29 30 29 29 30 29
+1539=30 30 30 29 30 30 29 29 30 29 29 30
+1540=29 30 30 29 30 30 29 30 29 29 30 29
+1541=30 29 30 29 30 30 30 29 30 29 29 30
+1542=29 30 29 30 29 30 30 29 30 29 30 30
+1543=29 30 29 29 30 29 30 29 30 29 30 30
+1544=30 29 30 29 29 30 29 30 29 30 29 30
+1545=30 30 29 30 29 29 30 29 30 29 29 30
+1546=30 30 29 30 29 30 29 30 29 30 29 29
+1547=30 30 29 30 30 29 30 29 30 29 30 29
+1548=30 29 29 30 30 29 30 30 29 30 29 30
+1549=29 30 29 29 30 29 30 30 30 29 30 29
+1550=30 29 30 29 29 29 30 30 30 29 30 30
+1551=29 30 29 29 30 29 29 30 30 29 30 30
+1552=30 29 30 29 29 30 29 29 30 30 29 30
+1553=30 29 30 29 30 29 30 29 30 29 30 29
+1554=30 29 30 29 30 30 29 30 29 30 29 30
+1555=29 29 30 29 30 30 29 30 30 29 30 29
+1556=30 29 29 30 29 30 29 30 30 30 29 30
+1557=29 30 29 29 29 30 29 30 30 30 30 29
+1558=30 29 30 29 29 29 30 29 30 30 30 29
+1559=30 30 29 29 30 29 29 30 30 29 30 29
+1560=30 30 29 30 29 30 29 30 29 30 29 30
+1561=29 30 30 29 30 29 30 30 29 29 30 29
+1562=29 30 30 29 30 29 30 30 30 29 29 30
+1563=29 30 29 29 30 29 30 30 30 29 30 29
+1564=30 29 30 29 29 30 29 30 30 30 29 30
+1565=29 30 29 30 29 29 30 29 30 30 29 30
+1566=30 29 30 29 30 29 29 30 29 30 29 30
+1567=30 29 30 30 29 30 29 30 29 29 30 29
+1568=30 29 30 30 30 29 30 29 30 29 29 29
+1569=30 29 30 30 30 29 30 30 29 30 29 29
+1570=29 30 29 30 30 29 30 30 30 29 29 30
+1571=29 29 30 29 30 30 29 30 30 29 30 29
+1572=30 29 29 30 29 30 29 30 30 29 30 29
+1573=30 29 30 30 29 30 29 29 30 29 30 29
+1574=30 30 29 30 30 29 30 29 29 30 29 29
+1575=30 30 30 29 30 30 29 30 29 29 29 30
+1576=29 30 30 29 30 30 30 29 30 29 29 29
+1577=30 29 30 30 29 30 30 29 30 29 30 29
+1578=29 30 29 30 29 30 30 29 30 30 29 30
+1579=29 30 29 30 29 29 30 30 29 30 29 30
+1580=29 30 30 29 30 29 29 30 29 30 29 30
+1581=30 30 29 30 29 30 29 29 30 29 30 29
+1582=30 30 29 30 30 29 30 29 30 29 29 29
+1583=30 30 29 30 30 30 29 30 29 30 29 29
+1584=29 30 30 29 30 30 29 30 30 29 30 29
+1585=29 30 29 30 29 30 29 30 30 29 30 30
+1586=29 29 30 29 30 29 29 30 30 30 29 30
+1587=29 30 30 29 29 29 30 29 30 29 30 30
+1588=30 29 30 30 29 29 29 30 29 30 29 30
+1589=30 29 30 30 29 30 29 29 30 29 30 29
+1590=30 29 30 30 30 29 29 30 29 30 29 30
+1591=29 30 29 30 30 29 30 29 30 29 30 29
+1592=30 29 30 29 30 29 30 29 30 30 30 29
+1593=30 29 29 30 29 29 30 29 30 30 30 29
+1594=30 30 29 29 30 29 29 29 30 30 30 30
+1595=29 30 29 30 29 29 30 29 29 30 30 30
+1596=29 30 30 29 30 29 29 30 29 30 29 30
+1597=29 30 30 29 30 29 30 29 30 29 30 29
+1598=30 29 30 29 30 30 29 30 29 30 30 29
+1599=29 30 29 30 29 30 29 30 30 30 29 30
+1600=29 29 30 29 30 29 29 30 30 30 29 30
--- a/jdk/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java Mon Nov 03 10:11:10 2014 -0800
@@ -97,8 +97,7 @@
*
* This implementation uses
* sun.util.calendar.LocalGregorianCalendar to perform most of the
- * calendar calculations. LocalGregorianCalendar is configurable
- * and reads <JRE_HOME>/lib/calendars.properties at the start-up.
+ * calendar calculations.
*/
/**
--- a/jdk/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Mon Nov 03 10:11:10 2014 -0800
@@ -247,7 +247,7 @@
return null;
thread = NativeThread.current();
for (;;) {
- n = accept0(this.fd, newfd, isaa);
+ n = accept(this.fd, newfd, isaa);
if ((n == IOStatus.INTERRUPTED) && isOpen())
continue;
break;
@@ -410,6 +410,18 @@
return sb.toString();
}
+ /**
+ * Accept a connection on a socket.
+ *
+ * @implNote Wrap native call to allow instrumentation.
+ */
+ private int accept(FileDescriptor ssfd, FileDescriptor newfd,
+ InetSocketAddress[] isaa)
+ throws IOException
+ {
+ return accept0(ssfd, newfd, isaa);
+ }
+
// -- Native methods --
// Accepts a new connection, setting the given file descriptor to refer to
--- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherBox.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherBox.java Mon Nov 03 10:11:10 2014 -0800
@@ -560,7 +560,7 @@
+ newLen);
hd.encodeBuffer(
- (ByteBuffer)bb.duplicate().position(pos), System.out);
+ bb.duplicate().position(pos), System.out);
} catch (IOException e) { }
}
@@ -790,7 +790,7 @@
// The padding data should be filled with the padding length value.
int[] results = checkPadding(
- (ByteBuffer)bb.duplicate().position(offset + newLen),
+ bb.duplicate().position(offset + newLen),
(byte)(padLen & 0xFF));
if (protocolVersion.v >= ProtocolVersion.TLS10.v) {
if (results[0] != 0) { // padding data has invalid bytes
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EngineInputRecord.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/EngineInputRecord.java Mon Nov 03 10:11:10 2014 -0800
@@ -349,8 +349,7 @@
/*
* Copy data out of buffer, it's ready to go.
*/
- ByteBuffer netBB = (ByteBuffer)
- (ByteBuffer.allocate(len).put(buf, 0, len).flip());
+ ByteBuffer netBB = ByteBuffer.allocate(len).put(buf, 0, len).flip();
engine.writer.putOutboundDataSync(netBB);
}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EngineOutputRecord.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/EngineOutputRecord.java Mon Nov 03 10:11:10 2014 -0800
@@ -113,9 +113,7 @@
/*
* Copy data out of buffer, it's ready to go.
*/
- ByteBuffer netBB = (ByteBuffer)
- ByteBuffer.allocate(len).put(buf, off, len).flip();
-
+ ByteBuffer netBB = ByteBuffer.allocate(len).put(buf, off, len).flip();
writer.putOutboundData(netBB);
}
--- a/jdk/src/java.base/share/classes/sun/util/calendar/CalendarSystem.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/sun/util/calendar/CalendarSystem.java Mon Nov 03 10:11:10 2014 -0800
@@ -177,44 +177,6 @@
return (cs == null) ? cal : cs;
}
- /**
- * Returns a {@link Properties} loaded from lib/calendars.properties.
- *
- * @return a {@link Properties} loaded from lib/calendars.properties
- * @throws IOException if an error occurred when reading from the input stream
- * @throws IllegalArgumentException if the input stream contains any malformed
- * Unicode escape sequences
- */
- public static Properties getCalendarProperties() throws IOException {
- Properties calendarProps = null;
- try {
- String homeDir = AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("java.home"));
- final String fname = homeDir + File.separator + "lib" + File.separator
- + "calendars.properties";
- calendarProps = AccessController.doPrivileged(new PrivilegedExceptionAction<Properties>() {
- @Override
- public Properties run() throws IOException {
- Properties props = new Properties();
- try (FileInputStream fis = new FileInputStream(fname)) {
- props.load(fis);
- }
- return props;
- }
- });
- } catch (PrivilegedActionException e) {
- Throwable cause = e.getCause();
- if (cause instanceof IOException) {
- throw (IOException) cause;
- } else if (cause instanceof IllegalArgumentException) {
- throw (IllegalArgumentException) cause;
- }
- // Should not happen
- throw new InternalError(cause);
- }
- return calendarProps;
- }
-
//////////////////////////////// Calendar API //////////////////////////////////
/**
--- a/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/java.base/share/conf/calendars.properties Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-# Copyright (c) 2005, 2014, 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. 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.
-#
-
-#
-# Hijrah calendars
-#
-calendar.hijrah.Hijrah-umalqura: hijrah-config-umalqura.properties
-calendar.hijrah.Hijrah-umalqura.type: islamic-umalqura
--- a/jdk/src/java.base/share/conf/hijrah-config-umalqura.properties Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,369 +0,0 @@
-# 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. 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 properties file defines a Hijrah calendar variant.
-#
-# Fields:
-#
-# <version> ::= 'version' '=' <version string>
-# <id> ::= 'id' '=' <id string>
-# <type> ::= 'type' '=' <type string>
-# <iso-start> ::= 'iso-start' '=' <start date in the ISO calendar>
-# <year> ::= <yyyy> '=' <nn nn nn nn nn nn nn nn nn nn nn nn>
-#
-# version ... (Required)
-#
-# id ... (Required)
-# Identifies the Java Chronology
-#
-# type ... (Required)
-# Identifies the type of calendar in the standard calendar ID scheme
-# iso-start ... (Required)
-# Specifies the corresponding ISO date to the first Hijrah day
-# in the defined range of dates
-#
-# year ... (Required)
-# Number of days for each month of a Hijrah year
-# * Each line defines a year. The years must be in chronological
-# order and no gap is allowed.
-# * Each line is in the form indicated above. <yyyy> is a Hijrah year and
-# nn is the number of days for a month listed in the order of the months.
-# * Each year must have 12 months.
-# * Each month should be 29 or 30 days long.
-# * There must be one or more space characters between the months.
-#
-
-# Version of this definition
-version=1.8.0_1
-
-# Java chronology ID
-id=Hijrah-umalqura
-
-# Standard calendar type specification
-type=islamic-umalqura
-
-# defines the corresponding ISO date to the earliest Hijrah date
-iso-start=1882-11-12
-
-# 1 2 3 4 5 6 7 8 9 10 11 12
-1300=30 29 30 29 30 29 30 29 30 29 30 29
-1301=30 30 29 30 29 30 29 30 29 30 29 29
-1302=30 30 30 29 30 30 29 29 30 29 29 30
-1303=29 30 30 29 30 30 29 30 29 30 29 29
-1304=29 30 30 29 30 30 30 29 30 29 30 29
-1305=29 29 30 30 29 30 30 29 30 30 29 29
-1306=30 29 30 29 30 29 30 29 30 30 29 30
-1307=29 30 29 30 29 30 29 30 29 30 29 30
-1308=29 30 30 29 30 29 30 29 30 29 29 30
-1309=29 30 30 30 30 29 29 30 29 29 30 29
-1310=30 29 30 30 30 29 30 29 30 29 29 30
-1311=29 30 29 30 30 30 29 30 29 30 29 29
-1312=30 29 30 29 30 30 29 30 30 29 30 29
-1313=29 30 29 30 29 30 29 30 30 30 29 29
-1314=30 30 29 30 29 29 30 29 30 30 29 30
-1315=29 30 30 29 30 29 29 30 29 30 29 30
-1316=29 30 30 30 29 30 29 29 30 29 30 29
-1317=30 29 30 30 29 30 29 30 29 30 29 29
-1318=30 29 30 30 29 30 30 29 30 29 30 29
-1319=29 30 29 30 30 29 30 29 30 30 29 30
-1320=29 30 29 29 30 29 30 29 30 30 30 29
-1321=30 29 30 29 29 30 29 29 30 30 30 30
-1322=29 30 29 30 29 29 29 30 29 30 30 30
-1323=29 30 30 29 30 29 29 29 30 29 30 30
-1324=29 30 30 29 30 29 30 29 29 30 29 30
-1325=30 29 30 29 30 30 29 30 29 30 29 30
-1326=29 29 30 29 30 30 29 30 29 30 30 29
-1327=30 29 29 30 29 30 29 30 30 29 30 30
-1328=29 30 29 29 30 29 29 30 30 30 29 30
-1329=30 29 30 29 29 30 29 29 30 30 29 30
-1330=30 30 29 30 29 29 30 29 29 30 30 29
-1331=30 30 29 30 30 29 29 30 29 30 29 30
-1332=29 30 29 30 30 29 30 29 30 30 29 29
-1333=30 29 29 30 30 29 30 30 29 30 30 29
-1334=29 29 30 29 30 29 30 30 30 29 30 29
-1335=30 29 30 29 29 30 29 30 30 29 30 30
-1336=29 30 29 30 29 29 30 29 30 29 30 30
-1337=30 29 30 29 30 29 29 30 29 30 29 30
-1338=29 30 30 29 30 30 29 29 30 29 30 29
-1339=30 29 30 29 30 30 30 29 30 29 29 30
-1340=29 29 30 29 30 30 30 30 29 30 29 29
-1341=30 29 29 30 29 30 30 30 29 30 30 29
-1342=29 29 30 29 30 29 30 30 29 30 30 29
-1343=30 29 29 30 29 30 29 30 29 30 30 29
-1344=30 29 30 29 30 30 29 29 30 29 30 29
-1345=30 29 30 30 30 29 30 29 29 30 29 29
-1346=30 29 30 30 30 30 29 30 29 29 30 29
-1347=29 30 29 30 30 30 29 30 30 29 29 30
-1348=29 29 30 29 30 30 29 30 30 30 29 29
-1349=30 29 29 30 29 30 30 29 30 30 29 30
-1350=29 30 29 30 29 30 29 29 30 30 29 30
-1351=30 29 30 29 30 29 30 29 29 30 29 30
-1352=30 29 30 30 29 30 29 30 29 29 30 29
-1353=30 29 30 30 30 29 30 29 29 30 29 30
-1354=29 30 29 30 30 29 30 30 29 30 29 29
-1355=30 29 29 30 30 29 30 30 29 30 30 29
-1356=29 30 29 30 29 30 29 30 29 30 30 30
-1357=29 29 30 29 30 29 29 30 29 30 30 30
-1358=29 30 29 30 29 30 29 29 30 29 30 30
-1359=29 30 30 29 30 29 30 29 29 29 30 30
-1360=29 30 30 30 29 30 29 30 29 29 30 29
-1361=30 29 30 30 29 30 30 29 29 30 29 30
-1362=29 30 29 30 29 30 30 29 30 29 30 29
-1363=30 29 30 29 30 29 30 29 30 29 30 30
-1364=29 30 29 30 29 29 30 29 30 29 30 30
-1365=30 30 29 29 30 29 29 30 29 30 29 30
-1366=30 30 29 30 29 30 29 29 30 29 30 29
-1367=30 30 29 30 30 29 30 29 29 30 29 30
-1368=29 30 29 30 30 30 29 29 30 29 30 29
-1369=30 29 30 29 30 30 29 30 29 30 30 29
-1370=30 29 29 30 29 30 29 30 29 30 30 30
-1371=29 30 29 29 30 29 30 29 30 29 30 30
-1372=30 29 29 30 29 30 29 29 30 29 30 30
-1373=30 29 30 29 30 29 30 29 29 30 29 30
-1374=30 29 30 30 29 30 29 30 29 29 30 29
-1375=30 29 30 30 29 30 30 29 30 29 30 29
-1376=29 30 29 30 29 30 30 30 29 30 29 30
-1377=29 29 30 29 29 30 30 30 29 30 30 29
-1378=30 29 29 29 30 29 30 30 29 30 30 30
-1379=29 30 29 29 29 30 29 30 30 29 30 30
-1380=29 30 29 30 29 30 29 30 29 30 29 30
-1381=29 30 29 30 30 29 30 29 30 29 29 30
-1382=29 30 29 30 30 29 30 30 29 30 29 29
-1383=30 29 29 30 30 30 29 30 30 29 30 29
-1384=29 30 29 29 30 30 29 30 30 30 29 30
-1385=29 29 30 29 29 30 30 29 30 30 30 29
-1386=30 29 29 30 29 29 30 30 29 30 30 29
-1387=30 29 30 29 30 29 30 29 30 29 30 29
-1388=30 30 29 30 29 30 29 30 29 30 29 29
-1389=30 30 29 30 30 29 30 30 29 29 30 29
-1390=29 30 29 30 30 30 29 30 29 30 29 30
-1391=29 29 30 29 30 30 29 30 30 29 30 29
-1392=30 29 29 30 29 30 29 30 30 29 30 30
-1393=29 30 29 29 30 29 30 29 30 29 30 30
-1394=30 29 30 29 29 30 29 30 29 30 29 30
-1395=30 29 30 30 29 30 29 29 30 29 29 30
-1396=30 29 30 30 29 30 30 29 29 30 29 29
-1397=30 29 30 30 29 30 30 30 29 29 29 30
-1398=29 30 29 30 30 29 30 30 29 30 29 29
-1399=30 29 30 29 30 29 30 30 29 30 29 30
-1400=30 29 30 29 29 30 29 30 29 30 29 30
-1401=30 30 29 30 29 29 30 29 29 30 29 30
-1402=30 30 30 29 30 29 29 30 29 29 30 29
-1403=30 30 30 29 30 30 29 29 30 29 29 30
-1404=29 30 30 29 30 30 29 30 29 30 29 29
-1405=30 29 30 29 30 30 30 29 30 29 29 30
-1406=30 29 29 30 29 30 30 29 30 29 30 30
-1407=29 30 29 29 30 29 30 29 30 29 30 30
-1408=30 29 30 29 30 29 29 30 29 29 30 30
-1409=30 30 29 30 29 30 29 29 30 29 29 30
-1410=30 30 29 30 30 29 30 29 29 30 29 29
-1411=30 30 29 30 30 29 30 30 29 29 30 29
-1412=30 29 30 29 30 29 30 30 30 29 29 30
-1413=29 30 29 29 30 29 30 30 30 29 30 29
-1414=30 29 30 29 29 30 29 30 30 29 30 30
-1415=29 30 29 30 29 29 30 29 30 29 30 30
-1416=30 29 30 29 30 29 29 30 29 30 29 30
-1417=30 29 30 30 29 29 30 29 30 29 30 29
-1418=30 29 30 30 29 30 29 30 29 30 29 30
-1419=29 30 29 30 29 30 29 30 30 30 29 29
-1420=29 30 29 29 30 29 30 30 30 30 29 30
-1421=29 29 30 29 29 29 30 30 30 30 29 30
-1422=30 29 29 30 29 29 29 30 30 30 29 30
-1423=30 29 30 29 30 29 29 30 29 30 29 30
-1424=30 29 30 30 29 30 29 29 30 29 30 29
-1425=30 29 30 30 29 30 29 30 30 29 30 29
-1426=29 30 29 30 29 30 30 29 30 30 29 30
-1427=29 29 30 29 30 29 30 30 29 30 30 29
-1428=30 29 29 30 29 29 30 30 30 29 30 30
-1429=29 30 29 29 30 29 29 30 30 29 30 30
-1430=29 30 30 29 29 30 29 30 29 30 29 30
-1431=29 30 30 29 30 29 30 29 30 29 29 30
-1432=29 30 30 30 29 30 29 30 29 30 29 29
-1433=30 29 30 30 29 30 30 29 30 29 30 29
-1434=29 30 29 30 29 30 30 29 30 30 29 29
-1435=30 29 30 29 30 29 30 29 30 30 29 30
-1436=29 30 29 30 29 30 29 30 29 30 29 30
-1437=30 29 30 30 29 29 30 29 30 29 29 30
-1438=30 29 30 30 30 29 29 30 29 29 30 29
-1439=30 29 30 30 30 29 30 29 30 29 29 30
-1440=29 30 29 30 30 30 29 30 29 30 29 29
-1441=30 29 30 29 30 30 29 30 30 29 30 29
-1442=29 30 29 30 29 30 29 30 30 29 30 29
-1443=30 29 30 29 30 29 30 29 30 29 30 30
-1444=29 30 29 30 30 29 29 30 29 30 29 30
-1445=29 30 30 30 29 30 29 29 30 29 29 30
-1446=29 30 30 30 29 30 30 29 29 30 29 29
-1447=30 29 30 30 30 29 30 29 30 29 30 29
-1448=29 30 29 30 30 29 30 30 29 30 29 30
-1449=29 29 30 29 30 29 30 30 29 30 30 29
-1450=30 29 30 29 29 30 29 30 29 30 30 29
-1451=30 30 30 29 29 30 29 29 30 30 29 30
-1452=30 29 30 30 29 29 30 29 29 30 29 30
-1453=30 29 30 30 29 30 29 30 29 29 30 29
-1454=30 29 30 30 29 30 30 29 30 29 30 29
-1455=29 30 29 30 30 29 30 29 30 30 29 30
-1456=29 29 30 29 30 29 30 29 30 30 30 29
-1457=30 29 29 30 29 29 30 29 30 30 30 30
-1458=29 30 29 29 30 29 29 30 29 30 30 30
-1459=29 30 30 29 29 30 29 29 30 29 30 30
-1460=29 30 30 29 30 29 30 29 29 30 29 30
-1461=29 30 30 29 30 29 30 29 30 30 29 29
-1462=30 29 30 29 30 30 29 30 29 30 30 29
-1463=29 30 29 30 29 30 29 30 30 30 29 30
-1464=29 30 29 29 30 29 29 30 30 30 29 30
-1465=30 29 30 29 29 30 29 29 30 30 29 30
-1466=30 30 29 30 29 29 29 30 29 30 30 29
-1467=30 30 29 30 30 29 29 30 29 30 29 30
-1468=29 30 29 30 30 29 30 29 30 29 30 29
-1469=29 30 29 30 30 29 30 30 29 30 29 30
-1470=29 29 30 29 30 30 29 30 30 29 30 29
-1471=30 29 29 30 29 30 29 30 30 29 30 30
-1472=29 30 29 29 30 29 30 29 30 30 29 30
-1473=29 30 29 30 30 29 29 30 29 30 29 30
-1474=29 30 30 29 30 30 29 29 30 29 30 29
-1475=29 30 30 29 30 30 30 29 29 30 29 29
-1476=30 29 30 29 30 30 30 29 30 29 30 29
-1477=29 30 29 29 30 30 30 30 29 30 29 30
-1478=29 29 30 29 30 29 30 30 29 30 30 29
-1479=30 29 29 30 29 30 29 30 29 30 30 29
-1480=30 29 30 29 30 29 30 29 30 29 30 29
-1481=30 29 30 30 29 30 29 30 29 30 29 29
-1482=30 29 30 30 30 30 29 30 29 29 30 29
-1483=29 30 29 30 30 30 29 30 30 29 29 30
-1484=29 29 30 29 30 30 30 29 30 29 30 29
-1485=30 29 29 30 29 30 30 29 30 30 29 30
-1486=29 30 29 29 30 29 30 29 30 30 29 30
-1487=30 29 30 29 30 29 29 30 29 30 29 30
-1488=30 29 30 30 29 30 29 29 30 29 30 29
-1489=30 29 30 30 30 29 30 29 29 30 29 30
-1490=29 30 29 30 30 29 30 30 29 29 30 29
-1491=30 29 29 30 30 29 30 30 29 30 29 30
-1492=29 30 29 29 30 30 29 30 29 30 30 29
-1493=30 29 30 29 30 29 29 30 29 30 30 30
-1494=29 30 29 30 29 30 29 29 29 30 30 30
-1495=29 30 30 29 30 29 29 30 29 29 30 30
-1496=29 30 30 30 29 30 29 29 30 29 29 30
-1497=30 29 30 30 29 30 29 30 29 30 29 30
-1498=29 30 29 30 29 30 30 29 30 29 30 29
-1499=30 29 30 29 29 30 30 29 30 29 30 30
-1500=29 30 29 30 29 29 30 29 30 29 30 30
-1501=30 29 30 29 30 29 29 29 30 29 30 30
-1502=30 30 29 30 29 30 29 29 29 30 30 29
-1503=30 30 29 30 30 29 30 29 29 29 30 30
-1504=29 30 29 30 30 30 29 29 30 29 30 29
-1505=30 29 30 29 30 30 29 30 29 30 30 29
-1506=29 30 29 29 30 30 29 30 30 29 30 30
-1507=29 29 30 29 29 30 30 29 30 29 30 30
-1508=30 29 29 30 29 30 29 29 30 29 30 30
-1509=30 29 30 29 30 29 30 29 29 30 29 30
-1510=30 29 30 30 29 30 29 30 29 29 30 29
-1511=30 29 30 30 29 30 30 29 30 29 29 30
-1512=29 30 29 30 29 30 30 30 29 30 29 30
-1513=29 29 29 30 29 30 30 30 29 30 30 29
-1514=30 29 29 29 30 29 30 30 29 30 30 30
-1515=29 29 30 29 29 30 29 30 30 29 30 30
-1516=29 30 29 30 29 29 30 29 30 29 30 30
-1517=29 30 29 30 29 30 30 29 29 30 29 30
-1518=29 30 29 30 30 29 30 30 29 30 29 29
-1519=30 29 29 30 30 30 29 30 30 29 30 29
-1520=29 30 29 29 30 30 30 29 30 30 29 30
-1521=29 29 29 30 29 30 30 29 30 30 29 30
-1522=30 29 29 29 30 29 30 30 29 30 30 29
-1523=30 29 30 29 30 29 30 29 29 30 30 29
-1524=30 30 29 30 29 30 29 30 29 29 30 29
-1525=30 30 29 30 30 29 30 29 30 29 29 30
-1526=29 30 29 30 30 30 29 30 29 30 29 29
-1527=30 29 30 29 30 30 29 30 30 29 30 29
-1528=30 29 29 30 29 30 29 30 30 29 30 30
-1529=29 30 29 29 30 29 30 29 30 29 30 30
-1530=29 30 30 29 29 30 29 30 29 29 30 30
-1531=29 30 30 30 29 29 30 29 30 29 29 30
-1532=29 30 30 30 29 30 30 29 29 29 30 29
-1533=30 29 30 30 30 29 30 29 30 29 29 30
-1534=29 30 29 30 30 29 30 30 29 29 30 29
-1535=30 29 30 29 30 29 30 30 29 30 29 30
-1536=29 30 29 30 29 30 29 30 29 30 29 30
-1537=30 29 30 30 29 29 30 29 29 30 29 30
-1538=30 30 29 30 30 29 29 30 29 29 30 29
-1539=30 30 30 29 30 30 29 29 30 29 29 30
-1540=29 30 30 29 30 30 29 30 29 29 30 29
-1541=30 29 30 29 30 30 30 29 30 29 29 30
-1542=29 30 29 30 29 30 30 29 30 29 30 30
-1543=29 30 29 29 30 29 30 29 30 29 30 30
-1544=30 29 30 29 29 30 29 30 29 30 29 30
-1545=30 30 29 30 29 29 30 29 30 29 29 30
-1546=30 30 29 30 29 30 29 30 29 30 29 29
-1547=30 30 29 30 30 29 30 29 30 29 30 29
-1548=30 29 29 30 30 29 30 30 29 30 29 30
-1549=29 30 29 29 30 29 30 30 30 29 30 29
-1550=30 29 30 29 29 29 30 30 30 29 30 30
-1551=29 30 29 29 30 29 29 30 30 29 30 30
-1552=30 29 30 29 29 30 29 29 30 30 29 30
-1553=30 29 30 29 30 29 30 29 30 29 30 29
-1554=30 29 30 29 30 30 29 30 29 30 29 30
-1555=29 29 30 29 30 30 29 30 30 29 30 29
-1556=30 29 29 30 29 30 29 30 30 30 29 30
-1557=29 30 29 29 29 30 29 30 30 30 30 29
-1558=30 29 30 29 29 29 30 29 30 30 30 29
-1559=30 30 29 29 30 29 29 30 30 29 30 29
-1560=30 30 29 30 29 30 29 30 29 30 29 30
-1561=29 30 30 29 30 29 30 30 29 29 30 29
-1562=29 30 30 29 30 29 30 30 30 29 29 30
-1563=29 30 29 29 30 29 30 30 30 29 30 29
-1564=30 29 30 29 29 30 29 30 30 30 29 30
-1565=29 30 29 30 29 29 30 29 30 30 29 30
-1566=30 29 30 29 30 29 29 30 29 30 29 30
-1567=30 29 30 30 29 30 29 30 29 29 30 29
-1568=30 29 30 30 30 29 30 29 30 29 29 29
-1569=30 29 30 30 30 29 30 30 29 30 29 29
-1570=29 30 29 30 30 29 30 30 30 29 29 30
-1571=29 29 30 29 30 30 29 30 30 29 30 29
-1572=30 29 29 30 29 30 29 30 30 29 30 29
-1573=30 29 30 30 29 30 29 29 30 29 30 29
-1574=30 30 29 30 30 29 30 29 29 30 29 29
-1575=30 30 30 29 30 30 29 30 29 29 29 30
-1576=29 30 30 29 30 30 30 29 30 29 29 29
-1577=30 29 30 30 29 30 30 29 30 29 30 29
-1578=29 30 29 30 29 30 30 29 30 30 29 30
-1579=29 30 29 30 29 29 30 30 29 30 29 30
-1580=29 30 30 29 30 29 29 30 29 30 29 30
-1581=30 30 29 30 29 30 29 29 30 29 30 29
-1582=30 30 29 30 30 29 30 29 30 29 29 29
-1583=30 30 29 30 30 30 29 30 29 30 29 29
-1584=29 30 30 29 30 30 29 30 30 29 30 29
-1585=29 30 29 30 29 30 29 30 30 29 30 30
-1586=29 29 30 29 30 29 29 30 30 30 29 30
-1587=29 30 30 29 29 29 30 29 30 29 30 30
-1588=30 29 30 30 29 29 29 30 29 30 29 30
-1589=30 29 30 30 29 30 29 29 30 29 30 29
-1590=30 29 30 30 30 29 29 30 29 30 29 30
-1591=29 30 29 30 30 29 30 29 30 29 30 29
-1592=30 29 30 29 30 29 30 29 30 30 30 29
-1593=30 29 29 30 29 29 30 29 30 30 30 29
-1594=30 30 29 29 30 29 29 29 30 30 30 30
-1595=29 30 29 30 29 29 30 29 29 30 30 30
-1596=29 30 30 29 30 29 29 30 29 30 29 30
-1597=29 30 30 29 30 29 30 29 30 29 30 29
-1598=30 29 30 29 30 30 29 30 29 30 30 29
-1599=29 30 29 30 29 30 29 30 30 30 29 30
-1600=29 29 30 29 30 29 29 30 30 30 29 30
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java Mon Nov 03 10:11:10 2014 -0800
@@ -141,7 +141,7 @@
Throwable exc = null;
try {
begin();
- int n = accept0(this.fd, newfd, isaa);
+ int n = accept(this.fd, newfd, isaa);
// spurious wakeup, is this possible?
if (n == IOStatus.UNAVAILABLE) {
@@ -277,7 +277,7 @@
try {
begin();
- int n = accept0(this.fd, newfd, isaa);
+ int n = accept(this.fd, newfd, isaa);
if (n == IOStatus.UNAVAILABLE) {
// need calling context when there is security manager as
@@ -332,6 +332,18 @@
}
}
+ /**
+ * Accept a connection on a socket.
+ *
+ * @implNote Wrap native call to allow instrumentation.
+ */
+ private int accept(FileDescriptor ssfd, FileDescriptor newfd,
+ InetSocketAddress[] isaa)
+ throws IOException
+ {
+ return accept0(ssfd, newfd, isaa);
+ }
+
// -- Native methods --
private static native void initIDs();
--- a/jdk/src/jdk.deploy.osx/macosx/classes/apple/security/KeychainStore.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.deploy.osx/macosx/classes/apple/security/KeychainStore.java Mon Nov 03 10:11:10 2014 -0800
@@ -140,7 +140,8 @@
* password to recover it.
*
* @param alias the alias name
- * @param password the password for recovering the key
+ * @param password the password for recovering the key. This password is
+ * used internally as the key is exported in a PKCS12 format.
*
* @return the requested key, or null if the given alias does not exist
* or does not identify a <i>key entry</i>.
@@ -155,6 +156,20 @@
{
permissionCheck();
+ // An empty password is rejected by MacOS API, no private key data
+ // is exported. If no password is passed (as is the case when
+ // this implementation is used as browser keystore in various
+ // deployment scenarios like Webstart, JFX and applets), create
+ // a dummy password so MacOS API is happy.
+ if (password == null || password.length == 0) {
+ // Must not be a char array with only a 0, as this is an empty
+ // string.
+ if (random == null) {
+ random = new SecureRandom();
+ }
+ password = Long.toString(random.nextLong()).toCharArray();
+ }
+
Object entry = entries.get(alias.toLowerCase());
if (entry == null || !(entry instanceof KeyEntry)) {
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", TRUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java Mon Nov 03 10:11:10 2014 -0800
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java Mon Nov 03 10:11:10 2014 -0800
@@ -831,7 +831,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -919,6 +919,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/test/com/sun/jdi/OptionTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/com/sun/jdi/OptionTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, 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
@@ -34,9 +34,11 @@
*/
import java.net.ServerSocket;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class OptionTest extends Object {
- private Process subprocess;
+ private static final Pattern TRANSPORT_ERROR_PTRN = Pattern.compile("^ERROR: transport error .+$", Pattern.MULTILINE);
private int subprocessStatus;
private static final String CR = System.getProperty("line.separator");
private static final int BUFFERSIZE = 4096;
@@ -153,7 +155,7 @@
OptionTest myTest = new OptionTest();
String results [] = myTest.run(VMConnection.insertDebuggeeVMOptions(cmds));
if (!(results[RETSTAT].equals("0")) ||
- (results[STDERR].startsWith("ERROR:"))) {
+ (TRANSPORT_ERROR_PTRN.matcher(results[STDERR]).find())) {
throw new Exception("Test failed: jdwp doesn't like " + cmds[1]);
}
}
@@ -179,7 +181,7 @@
OptionTest myTest = new OptionTest();
String results[] = myTest.run(VMConnection.insertDebuggeeVMOptions(cmds));
- if (!results[RETSTAT].equals("0") && results[STDERR].startsWith("ERROR:")) {
+ if (!results[RETSTAT].equals("0") && TRANSPORT_ERROR_PTRN.matcher(results[STDERR]).find()) {
// We got expected error, test passed
}
else {
--- a/jdk/test/java/io/FileDescriptor/Finalize.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/java/io/FileDescriptor/Finalize.java Mon Nov 03 10:11:10 2014 -0800
@@ -245,9 +245,10 @@
* write to fc2 - when fos1 is gc'ed and finalizer is run,
* write to fc2 should not fail
*/
- bb = ByteBuffer.allocateDirect(data.length);
- bb = bb.put(data);
- bb = (ByteBuffer) bb.flip();
+ bb = ByteBuffer.allocateDirect(data.length)
+ .put(data)
+ .flip();
+
ret = fc2.write(bb);
System.out.println("Wrote:" + ret + " bytes to fc2");
fc2.close();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/System/finalization/FinInterrupt.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, 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 4354680
+ * @summary runFinalization() should not clear or ignore interrupt bit
+ * @run main FinInterrupt
+ */
+
+public class FinInterrupt {
+ public static void main(String[] args) throws Exception {
+ Thread.currentThread().interrupt();
+ System.runFinalization();
+ if (Thread.interrupted()) {
+ System.out.println("Passed: interrupt bit was still set.");
+ } else {
+ throw new AssertionError("interrupt bit was cleared");
+ }
+ }
+}
--- a/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThread.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThread.java Mon Nov 03 10:11:10 2014 -0800
@@ -28,7 +28,7 @@
*
* @build jdk.testlibrary.* DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
* @run shell ../MakeJAR3.sh DummyAgent
- * @run main TestDaemonThreadLauncher /timeout=240
+ * @run main/timeout=240 TestDaemonThreadLauncher
*
*/
import java.io.File;
--- a/jdk/test/java/nio/charset/CharsetEncoder/Flush.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/java/nio/charset/CharsetEncoder/Flush.java Mon Nov 03 10:11:10 2014 -0800
@@ -35,7 +35,7 @@
public class Flush {
private static byte[] contents(ByteBuffer bb) {
byte[] contents = new byte[bb.position()];
- ((ByteBuffer)(bb.duplicate().flip())).get(contents);
+ bb.duplicate().flip().get(contents);
return contents;
}
--- a/jdk/test/java/sql/TEST.properties Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-# JDBC unit tests uses TestNG
-TestNG.dirs = .
-
--- a/jdk/test/java/sql/test/sql/BatchUpdateExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.ObjectInputStream;
-import java.sql.BatchUpdateException;
-import java.sql.SQLException;
-import java.util.Arrays;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.SerializedBatchUpdateException;
-import util.BaseTest;
-
-public class BatchUpdateExceptionTests extends BaseTest {
-
- private final int[] uc = {1, 2, 3};
- private final long[] luc = {1, 2, 3};
-
- private final String testSrcDir = System.getProperty("test.src", ".")
- + File.separatorChar;
-
- /**
- * Create BatchUpdateException and setting all objects to null
- */
- @Test
- public void test() {
- BatchUpdateException be = new BatchUpdateException(null,
- null, errorCode, (int[]) null, null);
- assertTrue(be.getMessage() == null && be.getSQLState() == null
- && be.getUpdateCounts() == null && be.getCause() == null
- && be.getLargeUpdateCounts() == null
- && be.getErrorCode() == errorCode);
- }
-
- /**
- * Create BatchUpdateException with no-arg constructor
- */
- @Test
- public void test1() {
- BatchUpdateException ex = new BatchUpdateException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getUpdateCounts() == null
- && ex.getLargeUpdateCounts() == null);
- }
-
- /**
- * Create BatchUpdateException with null Throwable
- */
- @Test
- public void test2() {
- BatchUpdateException ex = new BatchUpdateException((Throwable) null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getUpdateCounts() == null
- && ex.getLargeUpdateCounts() == null);
- }
-
- /**
- * Create BatchUpdateException with message and update counts
- */
- @Test
- public void test3() {
-
- BatchUpdateException ex = new BatchUpdateException(reason, uc);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with update counts
- */
- @Test
- public void test4() {
- BatchUpdateException ex = new BatchUpdateException(uc);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with Throwable and update counts
- */
- @Test
- public void test5() {
- BatchUpdateException ex = new BatchUpdateException(uc, t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with message, Throwable, and update counts
- */
- @Test
- public void test6() {
- BatchUpdateException ex = new BatchUpdateException(reason, uc, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with message, SQLState, Throwable, and update
- * counts
- */
- @Test
- public void test7() {
- BatchUpdateException ex = new BatchUpdateException(reason, state, uc, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with message, SQLState, errorCode code
- * Throwable, and update counts
- */
- @Test
- public void test8() {
- BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
- uc, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with message, SQLState, errorCode code
- * Throwable, and long [] update counts
- */
- @Test
- public void test9() {
- BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
- luc, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Validate that a copy of the update counts array is made
- */
- @Test
- public void test10() {
- int[] uc1 = {1, 2};
- BatchUpdateException ex = new BatchUpdateException(uc1);
- assertTrue(Arrays.equals(ex.getUpdateCounts(), uc1));
- uc1[0] = 6689;
- assertFalse(Arrays.equals(ex.getUpdateCounts(), uc1));
- }
-
- /**
- * Validate that if null is specified for the update count, it is returned
- * as null
- */
- @Test
- public void test11() {
- BatchUpdateException ex = new BatchUpdateException((int[]) null);
- assertTrue(ex.getMessage() == null && ex.getSQLState() == null
- && ex.getErrorCode() == 0 && ex.getUpdateCounts() == null
- && ex.getLargeUpdateCounts() == null);
- }
-
- /**
- * Serialize a BatchUpdateException and make sure you can read it back
- * properly
- */
- @Test
- public void test12() throws Exception {
- BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
- uc, t);
- BatchUpdateException bue
- = createSerializedException(be);
- assertTrue(reason.equals(bue.getMessage())
- && bue.getSQLState().equals(state)
- && cause.equals(bue.getCause().toString())
- && bue.getErrorCode() == errorCode
- && Arrays.equals(bue.getLargeUpdateCounts(), luc)
- && Arrays.equals(bue.getUpdateCounts(), uc));
- }
-
-
-
- /**
- * De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can
- * read it back properly
- */
- @Test
- public void test13() throws Exception {
- String reason1 = "This was the error msg";
- String state1 = "user defined sqlState";
- String cause1 = "java.lang.Throwable: throw 1";
- int errorCode1 = 99999;
- Throwable t = new Throwable("throw 1");
- int[] uc1 = {1, 2, 21};
- long[] luc1 = {1, 2, 21};
-
- ObjectInputStream ois = new ObjectInputStream(
- new ByteArrayInputStream(SerializedBatchUpdateException.DATA));
- BatchUpdateException bue = (BatchUpdateException) ois.readObject();
- assertTrue(reason1.equals(bue.getMessage())
- && bue.getSQLState().equals(state1)
- && bue.getErrorCode() == errorCode1
- && cause1.equals(bue.getCause().toString())
- && Arrays.equals(bue.getLargeUpdateCounts(), luc1)
- && Arrays.equals(bue.getUpdateCounts(), uc1));
- }
-
- /**
- * Serialize a BatchUpdateException with an Integer.MAX_VALUE + 1 and
- * validate you can read it back properly
- */
- @Test
- public void test14() throws Exception {
- int[] uc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
- long[] luc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
- BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
- luc1, t);
- BatchUpdateException bue
- = createSerializedException(be);
- assertTrue(reason.equals(bue.getMessage())
- && bue.getSQLState().equals(state)
- && cause.equals(bue.getCause().toString())
- && bue.getErrorCode() == errorCode
- && Arrays.equals(bue.getLargeUpdateCounts(), luc1)
- && Arrays.equals(bue.getUpdateCounts(), uc1));
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test15() {
- BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
- BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
- BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test16() {
- BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
- BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
- BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- SQLException sqe = ex;
- int num = 0;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
-}
--- a/jdk/test/java/sql/test/sql/DataTruncationTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.DataTruncation;
-import java.sql.SQLException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class DataTruncationTests extends BaseTest {
-
- private final String READ_TRUNCATION = "01004";
- private final String WRITE_TRUNCATION = "22001";
- private final String dtReason = "Data truncation";
- private final int dterrorCode = 0;
- private final String[] dtmsgs = {dtReason, "cause 1", dtReason,
- dtReason, "cause 2"};
- private boolean onRead = false;
- private final boolean parameter = false;
- private final int index = 21;
- private final int dataSize = 25;
- private final int transferSize = 10;
-
- /**
- * Create DataTruncation object indicating a truncation on read
- */
- @Test
- public void test() {
- onRead = true;
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Create DataTruncation object indicating a truncation on write
- */
- @Test
- public void test1() {
- onRead = false;
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(WRITE_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Create DataTruncation object indicating a truncation on read with a
- * Throwable
- */
- @Test
- public void test2() {
- onRead = true;
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && cause.equals(e.getCause().toString())
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Create DataTruncation object indicating a truncation on read with null
- * specified for the Throwable
- */
- @Test
- public void test3() {
- onRead = true;;
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, null);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Create DataTruncation object indicating a truncation on read and you can
- * pass a -1 for the index
- */
- @Test
- public void test4() {
- onRead = true;
- int negIndex = -1;
- DataTruncation e = new DataTruncation(negIndex, parameter, onRead,
- dataSize, transferSize);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == negIndex);
- }
-
- /**
- * Serialize a DataTruncation and make sure you can read it back properly
- */
- @Test
- public void test5() throws Exception {
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- DataTruncation ex1 = createSerializedException(e);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * for-each loop
- */
- @Test
- public void test11() {
- DataTruncation ex = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t1);
- DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(dtmsgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * traditional while loop
- */
- @Test
- public void test12() {
- DataTruncation ex = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t1);
- DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(dtmsgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(dtmsgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/DateTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,373 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.Date;
-import java.time.Instant;
-import java.time.LocalDate;
-import static org.testng.Assert.*;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class DateTests extends BaseTest {
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid Date string
- */
- @Test(dataProvider = "invalidDateValues",
- expectedExceptions = IllegalArgumentException.class)
- public void test(String d) throws Exception {
- Date.valueOf(d);
- }
-
- /*
- * Test that a date created from a date string is equal to the value
- * returned from toString()
- */
- @Test(dataProvider = "validDateValues")
- public void test00(String d, String expectedD) {
- Date d1 = Date.valueOf(d);
- Date d2 = Date.valueOf(expectedD);
- assertTrue(d1.equals(d2) && d2.equals(d1)
- && d1.toString().equals(expectedD), "Error d1 != d2");
- }
-
- /*
- * Validate that a Date.after() returns false when same date is compared
- */
- @Test
- public void test01() {
- Date d = Date.valueOf("1961-08-30");
- assertFalse(d.after(d), "Error d.after(d) = true");
- }
-
- /*
- * Validate that a Date.after() returns true when later date is compared to
- * earlier date
- */
- @Test
- public void test2() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(System.currentTimeMillis());
- assertTrue(d2.after(d), "Error d2.after(d) = false");
- }
-
- /*
- * Validate that a Date.after() returns false when earlier date is compared
- * to later date
- */
- @Test
- public void test3() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertFalse(d.after(d2), "Error d.after(d2) = true");
- }
-
- /*
- * Validate that a Date.after() returns false when date compared to another
- * date created from the original date
- */
- @Test
- public void test4() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertFalse(d.after(d2), "Error d.after(d2) = true");
- assertFalse(d2.after(d), "Error d2.after(d) = true");
- }
-
- /*
- * Validate that a Date.before() returns false when same date is compared
- */
- @Test
- public void test5() {
- Date d = Date.valueOf("1961-08-30");
- assertFalse(d.before(d), "Error d.before(d) = true");
- }
-
- /*
- * Validate that a Date.before() returns true when earlier date is compared
- * to later date
- */
- @Test
- public void test6() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(System.currentTimeMillis());
- assertTrue(d.before(d2), "Error d.before(d2) = false");
- }
-
- /*
- * Validate that a Date.before() returns false when later date is compared
- * to earlier date
- */
- @Test
- public void test7() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertFalse(d2.before(d), "Error d2.before(d) = true");
- }
-
- /*
- * Validate that a Date.before() returns false when date compared to another
- * date created from the original date
- */
- @Test
- public void test8() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertFalse(d.before(d2), "Error d.before(d2) = true");
- assertFalse(d2.before(d), "Error d2.before(d) = true");
- }
-
- /*
- * Validate that a Date.compareTo returns 0 when both Date objects are the
- * same
- */
- @Test
- public void test9() {
- Date d = Date.valueOf("1961-08-30");
- assertTrue(d.compareTo(d) == 0, "Error d.compareTo(d) !=0");
- }
-
- /*
- * Validate that a Date.compareTo returns 0 when both Date objects represent
- * the same date
- */
- @Test
- public void test10() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertTrue(d.compareTo(d2) == 0, "Error d.compareTo(d2) !=0");
- }
-
- /*
- * Validate that a Date.compareTo returns -1 when comparing a date to a
- * later date
- */
- @Test
- public void test11() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(System.currentTimeMillis());
- assertTrue(d.compareTo(d2) == -1, "Error d.compareTo(d2) != -1");
- }
-
- /*
- * Validate that a Date.compareTo returns 1 when comparing a date to an
- * earlier date
- */
- @Test
- public void test12() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(System.currentTimeMillis());
- assertTrue(d2.compareTo(d) == 1, "Error d.compareTo(d2) != 1");
- }
-
- /*
- * Validate that a Date made from a LocalDate are equal
- */
- @Test
- public void test13() {
- Date d = Date.valueOf("1961-08-30");
- LocalDate ldt = d.toLocalDate();
- Date d2 = Date.valueOf(ldt);
- assertTrue(d.equals(d2), "Error d != d2");
- }
-
- /*
- * Validate that a Date LocalDate value, made from a LocalDate are equal
- */
- @Test
- public void test14() {
- LocalDate ldt = LocalDate.now();
- Date d = Date.valueOf(ldt);
- assertTrue(ldt.equals(d.toLocalDate()),
- "Error LocalDate values are not equal");
- }
-
- /*
- * Validate an NPE occurs when a null LocalDate is passed to valueOf
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test15() throws Exception {
- LocalDate ld = null;
- Date.valueOf(ld);
- }
-
- /*
- * Validate an UnsupportedOperationException occurs when toInstant() is
- * called
- */
- @Test(expectedExceptions = UnsupportedOperationException.class)
- public void test16() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- Instant instant = d.toInstant();
- }
-
- /*
- * Validate that two Date objects are equal when one is created from the
- * toString() of the other
- */
- @Test
- public void test17() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = Date.valueOf(d.toString());
- assertTrue(d.equals(d2) && d2.equals(d), "Error d != d2");
- }
-
- /*
- * Validate that two Date values one created using valueOf and another via a
- * constructor are equal
- */
- @Test
- public void test18() {
-
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(61, 7, 30);
- assertTrue(d.equals(d2), "Error d != d2");
- }
-
- /*
- * Validate that two Date values one created using getTime() of the other
- * are equal
- */
- @Test
- public void test19() {
-
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertTrue(d.equals(d2), "Error d != d2");
- }
-
- /*
- * Validate that a Date value is equal to itself
- */
- @Test
- public void test20() {
-
- Date d = Date.valueOf("1961-08-30");
- assertTrue(d.equals(d), "Error d != d");
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getHours
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test21() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.getHours();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getMinutes
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test22() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.getMinutes();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getSeconds
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test23() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.getSeconds();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setHours
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test24() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.setHours(8);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setMinutes
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test25() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.setMinutes(0);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setSeconds
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test26() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.setSeconds(0);
- }
-
- /*
- * DataProvider used to provide Date which are not valid and are used
- * to validate that an IllegalArgumentException will be thrown from the
- * valueOf method
- */
- @DataProvider(name = "invalidDateValues")
- private Object[][] invalidDateValues() {
- return new Object[][]{
- {"20009-11-01"},
- {"09-11-01"},
- {"-11-01"},
- {"2009-111-01"},
- {"2009--01"},
- {"2009-13-01"},
- {"2009-11-011"},
- {"2009-11-"},
- {"2009-11-00"},
- {"2009-11-33"},
- {"--"},
- {""},
- {null},
- {"-"},
- {"2009"},
- {"2009-01"},
- {"---"},
- {"2009-13--1"},
- {"1900-1-0"},
- {"2009-01-01 10:50:01"},
- {"1996-12-10 12:26:19.1"},
- {"10:50:01"}
- };
- }
-
- /*
- * DataProvider used to provide Dates which are valid and are used
- * to validate that an IllegalArgumentException will not be thrown from the
- * valueOf method and the corect value from toString() is returned
- */
- @DataProvider(name = "validDateValues")
- private Object[][] validDateValues() {
- return new Object[][]{
- {"2009-08-30", "2009-08-30"},
- {"2009-01-8", "2009-01-08"},
- {"2009-1-01", "2009-01-01"},
- {"2009-1-1", "2009-01-01"}
-
- };
- }
-}
--- a/jdk/test/java/sql/test/sql/DriverManagerPermissionsTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.security.AccessControlException;
-import java.security.Policy;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import util.BaseTest;
-import util.StubDriver;
-import util.TestPolicy;
-
-public class DriverManagerPermissionsTests extends BaseTest {
-
- private static Policy policy;
- private static SecurityManager sm;
-
- /*
- * Install a SecurityManager along with a base Policy to allow testNG to run
- */
- @BeforeClass
- public static void setUpClass() throws Exception {
- setPolicy(new TestPolicy());
- System.setSecurityManager(new SecurityManager());
- }
-
- /*
- * Install the original Policy and SecurityManager
- */
- @AfterClass
- public static void tearDownClass() throws Exception {
- System.setSecurityManager(sm);
- setPolicy(policy);
- }
-
- /*
- * Save off the original Policy and SecurityManager
- */
- public DriverManagerPermissionsTests() {
- policy = Policy.getPolicy();
- sm = System.getSecurityManager();
- }
-
- /*
- * Validate that AccessControlException is thrown if SQLPermission("setLog")
- * has not been granted
- */
- @Test(expectedExceptions = AccessControlException.class)
- public void test() {
- setPolicy(new TestPolicy());
- DriverManager.setLogStream(null);
- }
-
- /*
- * Validate that setLogStream succeeds if SQLPermission("setLog") has been
- * granted
- */
- @Test
- public void test1() {
- Policy.setPolicy(new TestPolicy("setLog"));
- DriverManager.setLogStream(null);
- }
-
- /*
- * Validate that setLogStream succeeds if AllPermissions has been granted
- */
- @Test
- public void test2() {
- setPolicy(new TestPolicy("all"));
- DriverManager.setLogStream(null);
- }
-
- /*
- * Validate that AccessControlException is thrown if SQLPermission("setLog")
- * has not been granted
- */
- @Test(expectedExceptions = AccessControlException.class)
- public void test4() {
- setPolicy(new TestPolicy());
- DriverManager.setLogWriter(null);
- }
-
- /*
- * Validate that setLogWriter succeeds if SQLPermission("setLog") has been
- * granted
- */
- @Test
- public void test5() {
- setPolicy(new TestPolicy("setLog"));
- DriverManager.setLogWriter(null);
- }
-
- /*
- * Validate that setLogWriter succeeds if AllPermissions has been granted
- */
- @Test
- public void test6() {
- setPolicy(new TestPolicy("all"));
- DriverManager.setLogWriter(null);
- }
-
- /*
- * Validate that AccessControlException is thrown if
- * SQLPermission("deregisterDriver") has not been granted
- */
- @Test(expectedExceptions = AccessControlException.class)
- public void test7() throws SQLException {
- setPolicy(new TestPolicy());
- DriverManager.deregisterDriver(new StubDriver());
- }
-
- /*
- * Validate that deregisterDriver succeeds if
- * SQLPermission("deregisterDriver") has been granted
- */
- @Test
- public void test8() throws SQLException {
- setPolicy(new TestPolicy("deregisterDriver"));
- DriverManager.deregisterDriver(new StubDriver());
- }
-
- /*
- * Validate that deregisterDriver succeeds if AllPermissions has been
- * granted
- */
- @Test
- public void test9() throws SQLException {
- setPolicy(new TestPolicy("all"));
- DriverManager.deregisterDriver(new StubDriver());
- }
-}
--- a/jdk/test/java/sql/test/sql/DriverManagerTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayReader;
-import java.io.CharArrayWriter;
-import java.io.File;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.Properties;
-import static org.testng.Assert.*;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import util.StubDriver;
-
-public class DriverManagerTests {
-
- private final String StubDriverURL = "jdbc:tennis:boy";
- private final String StubDriverDAURL = "jdbc:luckydog:tennis";
- private final String InvalidURL = "jdbc:cardio:tennis";
- private String[] results = {"output", "more output", "and more", "the end"};
- private String noOutput = "should not find this";
-
- public DriverManagerTests() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @BeforeMethod
- public void setUpMethod() throws Exception {
- removeAllDrivers();
- }
-
- @AfterMethod
- public void tearDownMethod() throws Exception {
- }
-
- /**
- * Utility method to remove all registered drivers
- */
- private static void removeAllDrivers() {
- java.util.Enumeration e = DriverManager.getDrivers();
- while (e.hasMoreElements()) {
- try {
- DriverManager.deregisterDriver((Driver) (e.nextElement()));
- } catch (SQLException ex) {
- System.out.print(ex.getMessage());
- }
- }
- }
-
- /**
- * Utility method to see if a driver is registered
- */
- private boolean isDriverRegistered(Driver d) {
- boolean foundDriver = false;
- java.util.Enumeration e = DriverManager.getDrivers();
- while (e.hasMoreElements()) {
- if (d == (Driver) e.nextElement()) {
- foundDriver = true;
- break;
- }
- }
- return foundDriver;
- }
-
- /**
- * Validate that values set using setLoginTimeout will be returned by
- * getLoginTimeout
- */
- @Test
- public void test() {
- int[] vals = {-1, 0, 5};
- for (int val : vals) {
- DriverManager.setLoginTimeout(val);
- assertEquals(val, DriverManager.getLoginTimeout());
- }
- }
-
- /**
- * Validate that NullPointerException is thrown when null is passed to
- * registerDriver
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test1() throws Exception {
- Driver d = null;
- DriverManager.registerDriver(d);
- }
-
- /**
- * Validate that NullPointerException is thrown when null is passed to
- * registerDriver
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test2() throws Exception {
- Driver d = null;
- DriverManager.registerDriver(d, null);
- }
-
- /**
- * Validate that a null value allows for deRegisterDriver to return
- */
- @Test
- public void test3() throws Exception {
- DriverManager.deregisterDriver(null);
-
- }
-
- /**
- * Validate that SQLException is thrown when there is no Driver to service
- * the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test4() throws Exception {
- DriverManager.getConnection(InvalidURL);
- }
-
- /**
- * Validate that SQLException is thrown when there is no Driver to service
- * the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test5() throws Exception {
- DriverManager.getConnection(InvalidURL, new Properties());
- }
-
- /**
- * Validate that SQLException is thrown when there is no Driver to service
- * the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test6() throws Exception {
- DriverManager.getConnection(InvalidURL, "LuckyDog", "tennisanyone");
- }
-
- /**
- * Validate that SQLException is thrown when null is passed for the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test7() throws Exception {
- DriverManager.getConnection(null);
- }
-
- /**
- * Validate that SQLException is thrown when null is passed for the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test8() throws Exception {
- DriverManager.getConnection(null, new Properties());
- }
-
- /**
- * Validate that SQLException is thrown when null is passed for the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test9() throws Exception {
- DriverManager.getConnection(null, "LuckyDog", "tennisanyone");
- }
-
- /**
- * Validate that SQLException is thrown when there is no Driver to service
- * the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test10() throws Exception {
- DriverManager.getDriver(InvalidURL);
- }
-
- /**
- * Validate that SQLException is thrown when null is passed for the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test11() throws Exception {
- DriverManager.getDriver(null);
- }
-
- /**
- * Validate that a non-null Driver is returned by getDriver when a valid URL
- * is specified
- */
- @Test
- public void test12() throws Exception {
-
- DriverManager.registerDriver(new StubDriver());
- assertTrue(DriverManager.getDriver(StubDriverURL) != null);
- }
-
- /**
- * Validate that SQLException is thrown when the URL is not valid for any of
- * the registered drivers
- */
- @Test(expectedExceptions = SQLException.class)
- public void test13() throws Exception {
- DriverManager.registerDriver(new StubDriver());
- DriverManager.getDriver(InvalidURL);
- }
-
- /**
- * Validate that a Connection object is returned when a valid URL is
- * specified to getConnection
- *
- */
- @Test
- public void test14() throws Exception {
-
- DriverManager.registerDriver(new StubDriver());
- assertTrue(
- DriverManager.getConnection(StubDriverURL) != null);
- assertTrue(DriverManager.getConnection(StubDriverURL,
- "LuckyDog", "tennisanyone") != null);
- Properties props = new Properties();
- props.put("user", "LuckyDog");
- props.put("password", "tennisanyone");
- assertTrue(
- DriverManager.getConnection(StubDriverURL,
- props) != null);
- }
-
- /**
- * Register a driver and make sure you find it via its URL. Deregister the
- * driver and validate it is not longer registered
- *
- * @throws Exception
- */
- @Test()
- public void test15() throws Exception {
- DriverManager.registerDriver(new StubDriver());
- Driver d = DriverManager.getDriver(StubDriverURL);
- assertTrue(d != null);
- assertTrue(isDriverRegistered(d));
- DriverManager.deregisterDriver(d);
- assertFalse(isDriverRegistered(d));
- }
-
- /**
- * Validate that DriverAction.release is called when a driver is registered
- * via registerDriver(Driver, DriverAction)
- *
- * @throws Exception
- */
- @Test
- public void test16() throws Exception {
- File file = new File(util.StubDriverDA.DriverActionCalled);
- file.delete();
- assertFalse(file.exists());
- Driver d = null;
- Class.forName("util.StubDriverDA");
- d = DriverManager.getDriver(StubDriverDAURL);
- DriverManager.deregisterDriver(d);
- assertFalse(isDriverRegistered(d), "Driver is registered");
- assertTrue(file.exists());
- }
-
- /**
- * Create a PrintStream and use to send output via DriverManager.println
- * Validate that if you disable the stream, the output sent is not present
- */
- @Test
- public void tests17() throws Exception {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(os);
- DriverManager.setLogStream(ps);
- assertTrue(DriverManager.getLogStream() == ps);
-
- DriverManager.println(results[0]);
- DriverManager.setLogStream((PrintStream) null);
- assertTrue(DriverManager.getLogStream() == null);
- DriverManager.println(noOutput);
- DriverManager.setLogStream(ps);
- DriverManager.println(results[1]);
- DriverManager.println(results[2]);
- DriverManager.println(results[3]);
- DriverManager.setLogStream((PrintStream) null);
- DriverManager.println(noOutput);
-
- /*
- * Check we do not get the output when the stream is disabled
- */
- InputStreamReader is
- = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
- BufferedReader reader = new BufferedReader(is);
- for (String result : results) {
- assertTrue(result.equals(reader.readLine()));
- }
- }
-
- /**
- * Create a PrintWriter and use to to send output via DriverManager.println
- * Validate that if you disable the writer, the output sent is not present
- */
- @Test
- public void tests18() throws Exception {
- CharArrayWriter cw = new CharArrayWriter();
- PrintWriter pw = new PrintWriter(cw);
- DriverManager.setLogWriter(pw);
- assertTrue(DriverManager.getLogWriter() == pw);
-
- DriverManager.println(results[0]);
- DriverManager.setLogWriter(null);
- assertTrue(DriverManager.getLogWriter() == null);
- DriverManager.println(noOutput);
- DriverManager.setLogWriter(pw);
- DriverManager.println(results[1]);
- DriverManager.println(results[2]);
- DriverManager.println(results[3]);
- DriverManager.setLogWriter(null);
- DriverManager.println(noOutput);
-
- /*
- * Check we do not get the output when the stream is disabled
- */
- BufferedReader reader
- = new BufferedReader(new CharArrayReader(cw.toCharArray()));
- for (String result : results) {
- assertTrue(result.equals(reader.readLine()));
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLClientInfoExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,227 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.ClientInfoStatus;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.util.HashMap;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLClientInfoExceptionTests extends BaseTest {
-
- private final HashMap<String, ClientInfoStatus> map = new HashMap<>();
-
- public SQLClientInfoExceptionTests() {
- map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
- map.put("21", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
- }
-
- /**
- * Create SQLClientInfoException and setting all objects to null
- */
- @Test
- public void test() {
- SQLClientInfoException e = new SQLClientInfoException(null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == 0
- && e.getFailedProperties() == null);
- }
-
- /**
- * Create SQLClientInfoException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLClientInfoException ex = new SQLClientInfoException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties() == null);
- }
-
- /**
- * Create SQLClientInfoException with null Throwable
- */
- @Test
- public void test2() {
-
- SQLClientInfoException ex = new SQLClientInfoException(map, null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message
- */
- @Test
- public void test3() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, map);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with null Throwable
- */
- @Test
- public void test4() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, map, null);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message, and SQLState
- */
- @Test
- public void test5() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, state,
- map);
-
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message, and SQLState
- */
- @Test
- public void test6() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, state,
- map, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message, SQLState, errorCode, and
- * Throwable
- */
- @Test
- public void test7() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, state,
- errorCode, map);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message, SQLState, and error code
- */
- @Test
- public void test8() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, state,
- errorCode, map, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Serialize a SQLClientInfoException and make sure you can read it back
- * properly
- */
- @Test
- public void test10() throws Exception {
- SQLClientInfoException e = new SQLClientInfoException(reason, state,
- errorCode, map, t);
- SQLClientInfoException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode
- && ex1.getFailedProperties().equals(map));
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * for-each loop
- */
- @Test
- public void test11() {
- SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
- map, t1);
- SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
- map);
- SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
- map, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * traditional while loop
- */
- @Test
- public void test12() {
- SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
- map, t1);
- SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
- map);
- SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
- map, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLDataExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLDataException;
-import java.sql.SQLException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLDataExceptionTests extends BaseTest {
-
- /**
- * Create SQLDataException and setting all objects to null
- */
- @Test
- public void test() {
- SQLDataException e = new SQLDataException(null, null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLDataException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLDataException ex = new SQLDataException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with message
- */
- @Test
- public void test2() {
- SQLDataException ex = new SQLDataException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLDataException ex = new SQLDataException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLDataException ex = new SQLDataException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLDataException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLDataException ex = new SQLDataException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLDataException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLDataException ex = new SQLDataException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLDataException ex = new SQLDataException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with null Throwable
- */
- @Test
- public void test8() {
- SQLDataException ex = new SQLDataException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with Throwable
- */
- @Test
- public void test9() {
- SQLDataException ex = new SQLDataException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLDataException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLDataException e = new SQLDataException(reason, state, errorCode, t);
- SQLDataException ex1 = createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLDataException ex = new SQLDataException("Exception 1", t1);
- SQLDataException ex1 = new SQLDataException("Exception 2");
- SQLDataException ex2 = new SQLDataException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLDataException ex = new SQLDataException("Exception 1", t1);
- SQLDataException ex1 = new SQLDataException("Exception 2");
- SQLDataException ex2 = new SQLDataException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLDataException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLDataException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLExceptionTests extends BaseTest {
-
- /**
- * Create SQLException and setting all objects to null
- */
- @Test
- public void test() {
- SQLException e = new SQLException(null, null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLException ex = new SQLException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with message
- */
- @Test
- public void test2() {
- SQLException ex = new SQLException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLException ex = new SQLException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLException ex = new SQLException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLException ex = new SQLException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLException ex = new SQLException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLException ex = new SQLException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with null Throwable
- */
- @Test
- public void test8() {
- SQLException ex = new SQLException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with Throwable
- */
- @Test
- public void test9() {
- SQLException ex = new SQLException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLException e = new SQLException(reason, state, errorCode, t);
- SQLException ex1 = createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLException ex = new SQLException("Exception 1", t1);
- SQLException ex1 = new SQLException("Exception 2");
- SQLException ex2 = new SQLException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLException ex = new SQLException("Exception 1", t1);
- SQLException ex1 = new SQLException("Exception 2");
- SQLException ex2 = new SQLException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- while (ex != null) {
- assertTrue(msgs[num++].equals(ex.getMessage()));
- Throwable c = ex.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- ex = ex.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLFeatureNotSupportedExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLFeatureNotSupportedExceptionTests extends BaseTest {
-
- /**
- * Create SQLFeatureNotSupportedException and setting all objects to null
- */
- @Test
- public void test() {
- SQLFeatureNotSupportedException e =
- new SQLFeatureNotSupportedException(null, null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message
- */
- @Test
- public void test2() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with null Throwable
- */
- @Test
- public void test8() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException((Throwable) null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with Throwable
- */
- @Test
- public void test9() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLFeatureNotSupportedException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLFeatureNotSupportedException e =
- new SQLFeatureNotSupportedException(reason, state, errorCode, t);
- SQLFeatureNotSupportedException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException("Exception 1", t1);
- SQLFeatureNotSupportedException ex1 =
- new SQLFeatureNotSupportedException("Exception 2");
- SQLFeatureNotSupportedException ex2 =
- new SQLFeatureNotSupportedException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException("Exception 1", t1);
- SQLFeatureNotSupportedException ex1 =
- new SQLFeatureNotSupportedException("Exception 2");
- SQLFeatureNotSupportedException ex2 =
- new SQLFeatureNotSupportedException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLFeatureNotSupportedException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLFeatureNotSupportedException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLIntegrityConstraintViolationExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,235 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLIntegrityConstraintViolationException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLIntegrityConstraintViolationExceptionTests extends BaseTest {
-
- /**
- * Create SQLIntegrityConstraintViolationException and setting all objects to null
- */
- @Test
- public void test() {
- SQLIntegrityConstraintViolationException e =
- new SQLIntegrityConstraintViolationException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message
- */
- @Test
- public void test2() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with null Throwable
- */
- @Test
- public void test8() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with Throwable
- */
- @Test
- public void test9() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLIntegrityConstraintViolationException and make sure
- * you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLIntegrityConstraintViolationException e =
- new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
- SQLIntegrityConstraintViolationException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException("Exception 1", t1);
- SQLIntegrityConstraintViolationException ex1 =
- new SQLIntegrityConstraintViolationException("Exception 2");
- SQLIntegrityConstraintViolationException ex2 =
- new SQLIntegrityConstraintViolationException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException("Exception 1", t1);
- SQLIntegrityConstraintViolationException ex1 =
- new SQLIntegrityConstraintViolationException("Exception 2");
- SQLIntegrityConstraintViolationException ex2 =
- new SQLIntegrityConstraintViolationException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLIntegrityConstraintViolationException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,239 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLInvalidAuthorizationSpecException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLInvalidAuthorizationSpecExceptionTests extends BaseTest {
-
- /**
- * Create SQLInvalidAuthorizationSpecException and setting all objects to
- * null
- */
- @Test
- public void test() {
- SQLInvalidAuthorizationSpecException e
- = new SQLInvalidAuthorizationSpecException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message
- */
- @Test
- public void test2() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, SQLState, and
- * error code
- */
- @Test
- public void test4() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, SQLState,
- * errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, SQLState, and
- * Throwable
- */
- @Test
- public void test6() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with null Throwable
- */
- @Test
- public void test8() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException((Throwable) null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with Throwable
- */
- @Test
- public void test9() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLInvalidAuthorizationSpecException and make sure you can
- * read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLInvalidAuthorizationSpecException e
- = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
- SQLInvalidAuthorizationSpecException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * for-each loop
- */
- @Test
- public void test11() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
- SQLInvalidAuthorizationSpecException ex1
- = new SQLInvalidAuthorizationSpecException("Exception 2");
- SQLInvalidAuthorizationSpecException ex2
- = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * traditional while loop
- */
- @Test
- public void test12() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
- SQLInvalidAuthorizationSpecException ex1
- = new SQLInvalidAuthorizationSpecException("Exception 2");
- SQLInvalidAuthorizationSpecException ex2
- = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException and validate it is an
- * instance of SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLInvalidAuthorizationSpecException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLNonTransientConnectionExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,235 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLNonTransientConnectionException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLNonTransientConnectionExceptionTests extends BaseTest {
-
- /**
- * Create SQLNonTransientConnectionException and setting all objects to null
- */
- @Test
- public void test() {
- SQLNonTransientConnectionException e =
- new SQLNonTransientConnectionException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientConnectionException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message
- */
- @Test
- public void test2() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with null Throwable
- */
- @Test
- public void test8() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with Throwable
- */
- @Test
- public void test9() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLNonTransientConnectionException and make sure you can
- * read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLNonTransientConnectionException e =
- new SQLNonTransientConnectionException(reason, state, errorCode, t);
- SQLNonTransientConnectionException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException("Exception 1", t1);
- SQLNonTransientConnectionException ex1 =
- new SQLNonTransientConnectionException("Exception 2");
- SQLNonTransientConnectionException ex2 =
- new SQLNonTransientConnectionException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException("Exception 1", t1);
- SQLNonTransientConnectionException ex1 =
- new SQLNonTransientConnectionException("Exception 2");
- SQLNonTransientConnectionException ex2 =
- new SQLNonTransientConnectionException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLNonTransientConnectionException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLNonTransientConnectionException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLNonTransientExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLNonTransientExceptionTests extends BaseTest {
-
- /**
- * Create SQLNonTransientException and setting all objects to null
- */
- @Test
- public void test() {
- SQLNonTransientException e = new SQLNonTransientException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLNonTransientException ex = new SQLNonTransientException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with message
- */
- @Test
- public void test2() {
- SQLNonTransientException ex = new SQLNonTransientException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLNonTransientException ex = new SQLNonTransientException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with message, SQLState, and error code
- */
- @Test
- public void test4() {;
- SQLNonTransientException ex =
- new SQLNonTransientException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLNonTransientException ex =
- new SQLNonTransientException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLNonTransientException ex = new SQLNonTransientException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLNonTransientException ex = new SQLNonTransientException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with null Throwable
- */
- @Test
- public void test8() {
- SQLNonTransientException ex = new SQLNonTransientException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with Throwable
- */
- @Test
- public void test9() {
- SQLNonTransientException ex = new SQLNonTransientException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLNonTransientException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLNonTransientException e =
- new SQLNonTransientException(reason, state, errorCode, t);
- SQLNonTransientException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
- SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
- SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
- SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
- SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLRecoverableExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLRecoverableException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLRecoverableExceptionTests extends BaseTest {
-
- /**
- * Create SQLRecoverableException and setting all objects to null
- */
- @Test
- public void test() {
- SQLRecoverableException e = new SQLRecoverableException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLRecoverableException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLRecoverableException ex = new SQLRecoverableException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with message
- */
- @Test
- public void test2() {
- SQLRecoverableException ex = new SQLRecoverableException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLRecoverableException ex = new SQLRecoverableException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLRecoverableException ex =
- new SQLRecoverableException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLRecoverableException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLRecoverableException ex =
- new SQLRecoverableException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLRecoverableException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLRecoverableException ex = new SQLRecoverableException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLRecoverableException ex = new SQLRecoverableException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with null Throwable
- */
- @Test
- public void test8() {
- SQLRecoverableException ex = new SQLRecoverableException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with Throwable
- */
- @Test
- public void test9() {
- SQLRecoverableException ex = new SQLRecoverableException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLRecoverableException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLRecoverableException e =
- new SQLRecoverableException(reason, state, errorCode, t);
- SQLRecoverableException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
- SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
- SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
- SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
- SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLSyntaxErrorExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLNonTransientException;
-import java.sql.SQLSyntaxErrorException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLSyntaxErrorExceptionTests extends BaseTest {
-
- /**
- * Create SQLSyntaxErrorException and setting all objects to null
- */
- @Test
- public void test() {
- SQLSyntaxErrorException e = new SQLSyntaxErrorException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLSyntaxErrorException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with message
- */
- @Test
- public void test2() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLSyntaxErrorException ex =
- new SQLSyntaxErrorException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLSyntaxErrorException ex =
- new SQLSyntaxErrorException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with null Throwable
- */
- @Test
- public void test8() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with Throwable
- */
- @Test
- public void test9() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLSyntaxErrorException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
-
- SQLSyntaxErrorException e =
- new SQLSyntaxErrorException(reason, state, errorCode, t);
- SQLSyntaxErrorException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
- SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
- SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
- SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
- SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLSyntaxErrorException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLSyntaxErrorException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLTimeoutExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLTimeoutException;
-import java.sql.SQLTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLTimeoutExceptionTests extends BaseTest {
-
- /**
- * Create SQLTimeoutException and setting all objects to null
- */
- @Test
- public void test() {
- SQLTimeoutException e = new SQLTimeoutException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTimeoutException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLTimeoutException ex = new SQLTimeoutException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with message
- */
- @Test
- public void test2() {
- SQLTimeoutException ex = new SQLTimeoutException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTimeoutException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTimeoutException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with null Throwable
- */
- @Test
- public void test8() {
- SQLTimeoutException ex = new SQLTimeoutException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with Throwable
- */
- @Test
- public void test9() {
- SQLTimeoutException ex = new SQLTimeoutException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLTimeoutException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLTimeoutException e =
- new SQLTimeoutException(reason, state, errorCode, t);
- SQLTimeoutException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
- SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
- SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
- SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
- SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLTimeoutException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLTimeoutException();
- assertTrue(ex instanceof SQLTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLTransactionRollbackExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLTransactionRollbackException;
-import java.sql.SQLTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLTransactionRollbackExceptionTests extends BaseTest {
-
- /**
- * Create SQLTransactionRollbackException and setting all objects to null
- */
- @Test
- public void test() {
- SQLTransactionRollbackException e =
- new SQLTransactionRollbackException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransactionRollbackException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLTransactionRollbackException ex = new SQLTransactionRollbackException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with message
- */
- @Test
- public void test2() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with null Throwable
- */
- @Test
- public void test8() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with Throwable
- */
- @Test
- public void test9() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLTransactionRollbackException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLTransactionRollbackException e =
- new SQLTransactionRollbackException(reason, state, errorCode, t);
- SQLTransactionRollbackException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException("Exception 1", t1);
- SQLTransactionRollbackException ex1 =
- new SQLTransactionRollbackException("Exception 2");
- SQLTransactionRollbackException ex2 =
- new SQLTransactionRollbackException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException("Exception 1", t1);
- SQLTransactionRollbackException ex1 =
- new SQLTransactionRollbackException("Exception 2");
- SQLTransactionRollbackException ex2 =
- new SQLTransactionRollbackException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLTransactionRollbackException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLTransactionRollbackException();
- assertTrue(ex instanceof SQLTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLTransientConnectionExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLTransientConnectionException;
-import java.sql.SQLTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLTransientConnectionExceptionTests extends BaseTest {
-
- /**
- * Create SQLTransientConnectionException and setting all objects to null
- */
- @Test
- public void test() {
- SQLTransientConnectionException e =
- new SQLTransientConnectionException( null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientConnectionException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLTransientConnectionException ex = new SQLTransientConnectionException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with message
- */
- @Test
- public void test2() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with message, SQLState, and error code
- */
- @Test
- public void test4() {;
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientConnectionException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientConnectionException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with null Throwable
- */
- @Test
- public void test8() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with Throwable
- */
- @Test
- public void test9() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLTransientConnectionException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLTransientConnectionException e =
- new SQLTransientConnectionException(reason, state, errorCode, t);
- SQLTransientConnectionException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException("Exception 1", t1);
- SQLTransientConnectionException ex1 =
- new SQLTransientConnectionException("Exception 2");
- SQLTransientConnectionException ex2 =
- new SQLTransientConnectionException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException("Exception 1", t1);
- SQLTransientConnectionException ex1 =
- new SQLTransientConnectionException("Exception 2");
- SQLTransientConnectionException ex2 =
- new SQLTransientConnectionException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLTransientConnectionException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLTransientConnectionException();
- assertTrue(ex instanceof SQLTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLTransientExceptionTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLTransientExceptionTests extends BaseTest {
-
- /**
- * Create SQLTransientException and setting all objects to null
- */
- @Test
- public void test() {
- SQLTransientException e = new SQLTransientException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLTransientException ex = new SQLTransientException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with message
- */
- @Test
- public void test2() {
- SQLTransientException ex = new SQLTransientException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLTransientException ex = new SQLTransientException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLTransientException ex = new SQLTransientException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLTransientException ex =
- new SQLTransientException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLTransientException ex = new SQLTransientException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLTransientException ex = new SQLTransientException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with null Throwable
- */
- @Test
- public void test8() {
- SQLTransientException ex = new SQLTransientException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with Throwable
- */
- @Test
- public void test9() {
- SQLTransientException ex = new SQLTransientException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLTransientException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLTransientException e =
- new SQLTransientException(reason, state, errorCode, t);
- SQLTransientException ex1 = createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLTransientException ex = new SQLTransientException("Exception 1", t1);
- SQLTransientException ex1 = new SQLTransientException("Exception 2");
- SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLTransientException ex = new SQLTransientException("Exception 1", t1);
- SQLTransientException ex1 = new SQLTransientException("Exception 2");
- SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLWarningTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,249 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLWarningTests extends BaseTest {
-
- private final String[] warnings = {"Warning 1", "cause 1", "Warning 2",
- "Warning 3", "cause 2"};
-
- /**
- * Create SQLWarning and setting all objects to null
- */
- @Test
- public void test() {
- SQLWarning e = new SQLWarning(null, null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLWarning with no-arg constructor
- */
- @Test
- public void test1() {
- SQLWarning ex = new SQLWarning();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with message
- */
- @Test
- public void test2() {
- SQLWarning ex = new SQLWarning(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with message, and SQLState
- */
- @Test
- public void test3() {
-
- SQLWarning ex = new SQLWarning(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLWarning ex = new SQLWarning(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLWarning with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLWarning ex = new SQLWarning(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLWarning with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLWarning ex = new SQLWarning(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with message, and Throwable
- */
- @Test
- public void test7() {
- SQLWarning ex = new SQLWarning(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with null Throwable
- */
- @Test
- public void test8() {
- SQLWarning ex = new SQLWarning((Throwable) null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with Throwable
- */
- @Test
- public void test9() {
- SQLWarning ex = new SQLWarning(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLWarning and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLWarning e = new SQLWarning(reason, state, errorCode, t);
- SQLWarning ex1 = createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * for-each loop
- */
- @Test
- public void test11() {
- SQLWarning ex = new SQLWarning("Exception 1", t1);
- SQLWarning ex1 = new SQLWarning("Exception 2");
- SQLWarning ex2 = new SQLWarning("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * traditional while loop
- */
- @Test
- public void test12() {
- SQLWarning ex = new SQLWarning("Exception 1", t1);
- SQLWarning ex1 = new SQLWarning("Exception 2");
- SQLWarning ex2 = new SQLWarning("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Validate that the ordering of the returned SQLWarning is correct using
- * for-each loop
- */
- @Test
- public void test13() {
- SQLWarning ex = new SQLWarning("Warning 1", t1);
- SQLWarning ex1 = new SQLWarning("Warning 2");
- SQLWarning ex2 = new SQLWarning("Warning 3", t2);
- ex.setNextWarning(ex1);
- ex.setNextWarning(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(warnings[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned SQLWarning is correct using
- * traditional while loop
- */
- @Test
- public void test14() {
- SQLWarning ex = new SQLWarning("Warning 1", t1);
- SQLWarning ex1 = new SQLWarning("Warning 2");
- SQLWarning ex2 = new SQLWarning("Warning 3", t2);
- ex.setNextWarning(ex1);
- ex.setNextWarning(ex2);
- int num = 0;
- SQLWarning sqe = ex;
- while (sqe != null) {
- assertTrue(warnings[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextWarning();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/TimeTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,348 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.Time;
-import java.time.LocalTime;
-import static org.testng.Assert.*;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class TimeTests extends BaseTest {
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getYear
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test01() {
- Time t = Time.valueOf("08:30:59");
- t.getYear();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getMonth
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test02() {
- Time t = Time.valueOf("08:30:59");
- t.getMonth();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getDay
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test03() {
- Time t = Time.valueOf("08:30:59");
- t.getDay();
- }
-
- /**
- * Validate an IllegalArgumentException is thrown for calling getDate
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test04() {
- Time t = Time.valueOf("08:30:59");
- t.getDate();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setYear
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test05() {
- Time t = Time.valueOf("08:30:59");
- t.setYear(8);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setMonth
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test06() {
- Time t = Time.valueOf("08:30:59");
- t.setMonth(8);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setDate
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test07() {
- Time t = Time.valueOf("08:30:59");
- t.setDate(30);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getDate
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test08() {
- Time t = Time.valueOf("08:30:59");
- t.getDate();
- }
-
- /*
- * Validate that a Time made from a toLocalTime() LocalTime are equal
- */
- @Test
- public void test09() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = Time.valueOf(t.toLocalTime());
- assertTrue(t.equals(t2), "Error t != t2");
- }
-
- /*
- * Validate that a Time LocalTime value, made from a LocalTime are equal
- */
- @Test
- public void test10() {
- LocalTime lt = LocalTime.of(8, 30, 59);
- Time t = Time.valueOf(lt);
- System.out.println("lt=" + lt + ",t=" + t.toLocalTime());
- assertTrue(lt.equals(t.toLocalTime()),
- "Error LocalTime values are not equal");
- }
-
- /*
- * Validate an NPE occurs when a null LocalDate is passed to valueOf
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test11() throws Exception {
- LocalTime ld = null;
- Time.valueOf(ld);
- }
-
- /*
- * Validate an UnsupportedOperationException occurs when toInstant() is
- * called
- */
- @Test(expectedExceptions = UnsupportedOperationException.class)
- public void test12() throws Exception {
- Time t = new Time(System.currentTimeMillis());
- t.toInstant();
- }
-
- /*
- * Validate that two Time objects are equal when one is created from the
- * toString() of the other and that the correct value is returned from
- * toString()
- */
- @Test(dataProvider = "validTimeValues")
- public void test13(String time, String expected) {
- Time t1 = Time.valueOf(time);
- Time t2 = Time.valueOf(t1.toString());
- assertTrue(t1.equals(t2) && t2.equals(t1)
- && t1.toString().equals(expected), "Error t1 != t2");
- }
-
- /*
- * Validate that two Time values one created using valueOf and another via a
- * constructor are equal
- */
- @Test
- public void test14() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(8, 30, 59);
- assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
- }
-
- /*
- * Validate that two Time values one created using valueOf and another via a
- * constructor are equal
- */
- @Test
- public void test15() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime());
- assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid Time string
- */
- @Test(dataProvider = "invalidTimeValues",
- expectedExceptions = IllegalArgumentException.class)
- public void test16(String time) throws Exception {
- Time.valueOf(time);
- }
-
- /*
- * Validate that Time.after() returns false when same date is compared
- */
- @Test
- public void test17() {
- Time t = Time.valueOf("08:30:59");
- assertFalse(t.after(t), "Error t.after(t) = true");
- }
-
- /*
- * Validate that Time.after() returns true when later date is compared to
- * earlier date
- */
- @Test
- public void test18() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(System.currentTimeMillis());
- assertTrue(t2.after(t), "Error t2.after(t) = false");
- }
-
- /*
- * Validate that Time.after() returns false when earlier date is compared to
- * itself
- */
- @Test
- public void test19() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime());
- assertFalse(t.after(t2), "Error t.after(t2) = true");
- assertFalse(t2.after(t), "Error t2.after(t) = true");
- }
-
- /*
- * Validate that Time.before() returns false when same date is compared
- */
- @Test
- public void test20() {
- Time t = Time.valueOf("08:30:59");
- assertFalse(t.before(t), "Error t.before(t) = true");
- }
-
- /*
- * Validate that Time.before() returns true when earlier date is compared to
- * later date
- */
- @Test
- public void test21() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(System.currentTimeMillis());
- assertTrue(t.before(t2), "Error t.before(t2) = false");
- }
-
- /*
- * Validate that Time.before() returns false when earlier date is compared
- * to itself
- */
- @Test
- public void test22() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime());
- assertFalse(t.before(t2), "Error t.after(t2) = true");
- assertFalse(t2.before(t), "Error t2.after(t) = true");
- }
-
- /*
- * Validate that Time.compareTo returns 0 when both Date objects are the
- * same
- */
- @Test
- public void test23() {
- Time t = Time.valueOf("08:30:59");
- assertTrue(t.compareTo(t) == 0, "Error t.compareTo(t) !=0");
- }
-
- /*
- * Validate thatTime.compareTo returns 0 when both Time objects are the same
- */
- @Test
- public void test24() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime());
- assertTrue(t.compareTo(t2) == 0, "Error t.compareTo(t2) !=0");
- }
-
- /*
- * Validate that Time.compareTo returns 1 when comparing a later Time to an
- * earlier Time
- */
- @Test
- public void test25() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime() + 1);
- assertTrue(t2.compareTo(t) == 1, "Error t2.compareTo(t) !=1");
- }
-
- /*
- * Validate thatTime.compareTo returns 1 when comparing a later Time to an
- * earlier Time
- */
- @Test
- public void test26() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime() + 1);
- assertTrue(t.compareTo(t2) == -1, "Error t.compareTo(t2) != -1");
- }
-
- /*
- * DataProvider used to provide Time values which are not valid and are used
- * to validate that an IllegalArgumentException will be thrown from the
- * valueOf method
- */
- @DataProvider(name = "invalidTimeValues")
- private Object[][] invalidTimeValues() {
- return new Object[][]{
- {"2009-11-01 10:50:01"},
- {"1961-08-30 10:50:01.1"},
- {"1961-08-30"},
- {"00:00:00."},
- {"10:50:0.1"},
- {":00:00"},
- {"00::00"},
- {"00:00:"},
- {"::"},
- {" : : "},
- {"0a:00:00"},
- {"00:bb:00"},
- {"00:01:cc"},
- {"08:10:Batman"},
- {"08:10:10:10"},
- {"08:10"},
- {"a:b:c"},
- {null},
- {"8:"}
- };
- }
-
- /*
- * DataProvider used to provide Time values which are valid and are used
- * to validate that an IllegalArgumentException will not be thrown from the
- * valueOf method. It also contains the expected return value from
- * toString()
- */
- @DataProvider(name = "validTimeValues")
- private Object[][] validTimeValues() {
- return new Object[][]{
- {"10:50:01", "10:50:01"},
- {"01:1:1", "01:01:01"},
- {"01:01:1", "01:01:01"},
- {"1:01:1", "01:01:01"},
- {"2:02:02", "02:02:02"},
- {"2:02:2", "02:02:02"},
- {"10:50:1", "10:50:01"},
- {"00:00:00", "00:00:00"},
- {"08:30:59", "08:30:59"},
- {"9:0:1", "09:00:01"}
- };
- }
-}
--- a/jdk/test/java/sql/test/sql/TimestampTests.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,777 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.Calendar;
-import java.util.TimeZone;
-import static org.testng.Assert.*;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class TimestampTests extends BaseTest {
-
- private static TimeZone defaultTimeZone = null;
-
- /*
- * Need to set and use a custom TimeZone which does not
- * observe daylight savings time for this test.
- */
- @BeforeClass
- public static void setUpClass() throws Exception {
- defaultTimeZone = TimeZone.getDefault();
- TimeZone tzone = TimeZone.getTimeZone("GMT+01");
- assertFalse(tzone.observesDaylightTime());
- TimeZone.setDefault(tzone);
- }
-
- /*
- * Conservatively reset the default time zone after test.
- */
- @AfterClass
- public static void tearDownClass() throws Exception {
- TimeZone.setDefault(defaultTimeZone);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid Timestamp
- */
- @Test(dataProvider = "invalidTimestampValues",
- expectedExceptions = IllegalArgumentException.class)
- public void test(String ts) throws Exception {
- Timestamp.valueOf(ts);
- }
-
- /*
- * Validate that two Timestamp are equal when the leading 0 in seconds is
- * omitted
- */
- @Test
- public void test01() throws Exception {
- String testTS = "2009-01-01 10:50:00";
- String ExpectedTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate two Timestamps created from the same string are equal
- */
- @Test
- public void test02() throws Exception {
- String testTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(testTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one with leading 0s for month and day
- * equals same string without the leading 0s.
- */
- @Test
- public void test03() throws Exception {
- String testTS = "2009-1-1 10:50:0";
- String ExpectedTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one with leading 0s for day omitted
- * are equal
- */
- @Test
- public void test04() throws Exception {
- String testTS = "2009-01-1 10:50:0";
- String ExpectedTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one with leading 0s for month omitted
- * and both with leading 0s for seconds omitted are equal
- */
- @Test
- public void test05() throws Exception {
- String testTS = "2009-1-01 10:50:0";
- String ExpectedTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one with leading 0s for month omitted
- */
- @Test
- public void test06() throws Exception {
- String testTS = "2005-1-01 10:20:50.00";
- String ExpectedTS = "2005-01-01 10:20:50.00";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one created using valueOf and another
- * via a constructor are equal
- */
- @Test
- public void test07() {
-
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.001");
- Timestamp ts2 = new Timestamp(96, 11, 13, 14, 15, 25, 1000000);
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one created using valueOf and another
- * via a constructor are equal
- */
- @Test
- public void test08() {
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.001");
- Timestamp ts2 = new Timestamp(ts1.getTime());
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one created using valueOf and another
- * via a constructor are equal
- */
- @Test
- public void test09() {
-
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.0");
- Timestamp ts2 = new Timestamp(96, 11, 13, 14, 15, 25, 0);
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that a Timestamp cannot be equal to null
- */
- @Test
- public void test10() {
-
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 14:15:25.745634");
- Timestamp ts2 = null;
- assertFalse(ts1.equals(ts2), "Error ts1 == null");
- }
-
- /*
- * Validate that a Timestamp is equal to another timestamp created with the
- * using the same value but not equal to a Timestamp which is one day later
- */
- @Test
- public void test11() {
-
- Timestamp ts1 = Timestamp.valueOf("1996-12-10 12:26:19.12");
- Timestamp ts2 = Timestamp.valueOf("1996-12-10 12:26:19.12");
- Timestamp ts3 = Timestamp.valueOf("1996-12-11 12:24:19.12");
- assertTrue(ts1.equals(ts2) && ts2.equals(ts1), "Error ts1 != ts2");
- assertFalse(ts1.equals(ts3) && ts3.equals(ts1), "Error ts1 == ts3");
-
- }
-
- /*
- * Validate that a Timestamp is equal to itself
- */
- @Test
- public void test12() {
- Timestamp ts1 = Timestamp.valueOf("1996-10-15 12:26:19.12");
- assertTrue(ts1.equals(ts1), "Error ts1 != ts1");
- }
-
- /*
- * Validate that two Timestamps are equal when one is created from the
- * toString() of the other
- */
- @Test(dataProvider = "validTimestampValues")
- public void test13(String ts, String expectedTS) {
- Timestamp ts1 = Timestamp.valueOf(ts);
- Timestamp ts2 = Timestamp.valueOf(ts1.toString());
- assertTrue(ts1.equals(ts2) && ts2.equals(ts1)
- && ts1.toString().equals(expectedTS), "Error ts1 != ts2");
- }
-
- // Before Tests
- /*
- * Validate that Timestamp ts1 is before Timestamp ts2
- */
- @Test
- public void test14() {
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
- Timestamp ts2 = Timestamp.valueOf("1996-12-13 15:15:25.645634");
- assertTrue(ts1.before(ts2), "Error ts1 not before ts2");
- }
-
- /*
- * Validate that Timestamp ts1 is before Timestamp ts2
- */
- @Test
- public void test15() {
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 14:15:25");
- Timestamp ts2 = Timestamp.valueOf("1999-12-13 15:15:25");
- assertTrue(ts1.before(ts2), "Error ts1 not before ts2");
- }
-
- /*
- * Validate that Timestamp ts1 is before Timestamp ts2
- */
- @Test
- public void test16() {
-
- Timestamp ts1 = Timestamp.valueOf("1999-12-13 14:15:25.745634");
- Timestamp ts2 = Timestamp.valueOf("1999-11-13 15:15:25.645634");
- assertFalse(ts1.before(ts2), "Error ts1 before ts2");
- }
-
- /*
- * Validate that a NullPointerException is thrown if a null is passed to
- * the before method
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test17() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
- ts1.before(null);
- }
-
- /*
- * Validate a Timestamp cannot be before itself
- */
- @Test
- public void test18() {
- Timestamp ts1 = Timestamp.valueOf("1999-11-10 12:26:19.3456543");
- assertFalse(ts1.before(ts1), "Error ts1 before ts1!");
- }
-
- /*
- * Create 3 Timestamps and make sure the 1st is before the other two
- * Timestamps which are each greater than the one before it
- */
- @Test
- public void test19() {
-
- Timestamp ts1 = new Timestamp(1234560000);
- Timestamp ts2 = new Timestamp(1234567000);
- Timestamp ts3 = new Timestamp(1234569000);
- assertTrue(ts1.before(ts2) && ts2.before(ts3) && ts1.before(ts3));
- }
-
- /*
- * Validate that Timestamp ts1 is not after Timestamp ts2
- */
- @Test
- public void test20() {
- Timestamp ts1 = Timestamp.valueOf("1999-12-13 14:15:25.745634");
- Timestamp ts2 = Timestamp.valueOf("1999-12-13 15:15:25.645634");
- assertFalse(ts1.after(ts2), "Error ts1 is after ts2");
-
- }
-
- /*
- * Validate that Timestamp ts1 is after Timestamp ts2
- */
- @Test
- public void test21() {
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
- Timestamp ts2 = Timestamp.valueOf("1996-11-13 15:15:25.645634");
- assertTrue(ts1.after(ts2), "Error ts1 not after ts2");
- }
-
- /*
- * Validate that a NullPointerException is thrown if a null is passed to the
- * after method
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test22() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- ts1.after(null);
- }
-
- /*
- * Validate that a Timestamp cannot be after itself
- */
- @Test
- public void test23() {
- Timestamp ts1 = Timestamp.valueOf("1999-11-10 12:26:19.3456543");
- assertFalse(ts1.after(ts1), "Error ts1 is after itself");
- }
-
- /*
- * Validate that a Timestamp after() works correctly with Timestamp created
- * using milliseconds
- */
- @Test
- public void test24() {
-
- Timestamp ts1 = new Timestamp(1234568000);
- Timestamp ts2 = new Timestamp(1234565000);
- Timestamp ts3 = new Timestamp(1234562000);
- assertTrue(ts1.after(ts2) && ts2.after(ts3) && ts1.after(ts3));
- }
-
- /*
- * Validate compareTo returns 0 for Timestamps that are the same
- */
- @Test
- public void test25() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = new Timestamp(ts1.getTime());
- assertTrue(ts1.compareTo(ts2) == 0, "Error ts1 != ts2");
- }
-
- /*
- * Validate compareTo returns -1 for when the 1st Timestamp is earlier than
- * the 2nd Timestamp
- */
- @Test
- public void test26() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = new Timestamp(ts1.getTime() + 1000);
- assertTrue(ts1.compareTo(ts2) == -1, "Error ts1 not before ts2");
- assertTrue(ts2.compareTo(ts1) == 1, "Error ts1 is not before ts2");
- }
-
- /*
- * Validate compareTo returns 1 for when the 1st Timestamp is later than the
- * 2nd Timestamp
- */
- @Test
- public void test27() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = new Timestamp(ts1.getTime() - 1000);
- assertTrue(ts1.compareTo(ts2) == 1, "Error ts1 not after ts2");
- assertTrue(ts2.compareTo(ts1) == -1, "Error ts1 not after ts2");
- }
-
- /*
- * Validate compareTo returns 0 for Timestamps that are the same
- */
- @Test
- public void test28() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- java.util.Date ts2 = new java.util.Date(ts1.getTime());
- assertTrue(ts1.compareTo(ts2) == 0, "Error ts1 != ts2");
- }
-
- /*
- * Validate compareTo returns 0 for Timestamps that are the same
- */
- @Test
- public void test29() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- java.util.Date d = new java.util.Date(ts1.getTime());
- assertFalse(ts1.equals(d), "Error ts1 == d");
- }
-
- /*
- * Validate compareTo returns 0 for Timestamps that are the same
- */
- @Test
- public void test30() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- java.util.Date d = new Timestamp(ts1.getTime());
- assertTrue(ts1.equals(d), "Error ts1 != d");
- }
-
- /*
- * Validate equals returns false when a Date object is passed to equals
- */
- @Test
- public void test31() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Date d = new Date(ts1.getTime());
- assertFalse(ts1.equals(d), "Error ts1 != d");
- }
-
- /*
- * Validate equals returns false when a Date object is passed to equals
- */
- @Test
- public void test32() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- java.util.Date d = new Date(ts1.getTime());
- assertFalse(ts1.equals(d), "Error ts1 != d");
- }
-
- /*
- * Validate equals returns false when a Time object is passed to equals
- */
- @Test
- public void test33() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Time t1 = new Time(ts1.getTime());
- assertFalse(ts1.equals(t1), "Error ts1 == t1");
- }
-
- /*
- * Validate equals returns false when a String object is passed to equals
- */
- @Test
- public void test34() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- assertFalse(ts1.equals("1966-08-30 08:08:08"), "Error ts1 == a String");
- }
-
- /*
- * Validate getTime() returns the same value from 2 timeStamps created by
- */
- @Test
- public void test35() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = Timestamp.valueOf("1966-08-30 08:08:08");
- assertTrue(ts2.getTime() == ts1.getTime(),
- "ts1.getTime() != ts2.getTime()");
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate getTime() returns the same value from 2 timeStamps when
- * setTime() is used to specify the same value for both Timestamps
- */
- @Test
- public void test36() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts2.setTime(ts1.getTime());
- assertTrue(ts2.getTime() == ts1.getTime(),
- "ts1.getTime() != ts2.getTime()");
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid nanos value
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test38() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts1.setNanos(-1);
-
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid nanos value
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test39() throws Exception {
- int nanos = 999999999;
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts1.setNanos(nanos + 1);
- }
-
- /*
- * Validate you can set nanos to 999999999
- */
- @Test
- public void test40() throws Exception {
- int nanos = 999999999;
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts1.setNanos(nanos);
- assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
- }
-
- /*
- * Validate you can set nanos to 0
- */
- @Test
- public void test41() throws Exception {
- int nanos = 0;
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts1.setNanos(nanos);
- assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
- }
-
- /*
- * Validate that a Timestamp made from a LocalDateTime are equal
- */
- @Test
- public void test42() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- LocalDateTime ldt = ts1.toLocalDateTime();
- Timestamp ts2 = Timestamp.valueOf(ldt);
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that a Timestamp LocalDateTime value, made from a LocalDateTime
- * are equal
- */
- @Test
- public void test43() throws Exception {
- LocalDateTime ldt = LocalDateTime.now();
- Timestamp ts2 = Timestamp.valueOf(ldt);
- assertTrue(ldt.equals(ts2.toLocalDateTime()),
- "Error LocalDateTime values are not equal");
- }
-
- /*
- * Validate an NPE occurs when a null LocalDateTime is passed to valueOF
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test44() throws Exception {
- LocalDateTime ldt = null;
- Timestamp.valueOf(ldt);
- }
-
- /*
- * Validate that a Timestamp made from a Instant are equal
- */
- @Test
- public void test45() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- Instant instant = ts1.toInstant();
- Timestamp ts2 = Timestamp.from(instant);
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that a Timestamp made from a Instant are equal
- */
- @Test
- public void test46() throws Exception {
- Instant instant = Instant.now();
- Timestamp ts2 = Timestamp.from(instant);
- assertTrue(instant.equals(ts2.toInstant()),
- "Error Instant values do not match");
- }
-
- /*
- * Validate an NPE occurs when a null instant is passed to from
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test47() throws Exception {
- Instant instant = null;
- Timestamp.from(instant);
- }
-
- // Added SQE tests
- /*
- * Create a Timestamp and a 2nd Timestamp that is 1 month earlier and
- * validate that it is not before or after the original Timestamp
- */
- @Test
- public void test48() {
- Calendar cal = Calendar.getInstance();
- Timestamp ts1 = new Timestamp(System.currentTimeMillis());
- cal.setTimeInMillis(ts1.getTime());
- cal.add(Calendar.MONTH, -1);
- cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
- Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
- assertFalse(ts1.before(ts2) || ts2.after(ts1));
- }
-
- /*
- * Create two Timestamps and validate that compareTo returns 1 to indicate
- * the 1st Timestamp is greater than the 2nd Timestamp
- */
- @Test
- public void test49() {
- Calendar cal = Calendar.getInstance();
- Timestamp ts1 = new Timestamp(System.currentTimeMillis());
- cal.setTimeInMillis(ts1.getTime());
- cal.add(Calendar.MONTH, -1);
- cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
- Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
- assertTrue(ts1.compareTo(ts2) == 1);
- }
-
- /*
- * Create two Timestamps and validate that the 1st Timestamp is not equal to
- * the 2nd Timestamp but equal to itself
- */
- @Test
- public void test50() {
- Calendar cal = Calendar.getInstance();
- Timestamp ts1 = new Timestamp(System.currentTimeMillis());
- cal.setTimeInMillis(ts1.getTime());
- cal.add(Calendar.MONTH, -1);
- cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
- Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
- assertTrue(!ts1.equals(ts2) && ts1.equals(ts1));
- }
-
- /*
- * Validate that two Timestamps are equal when one is created from the
- * toString() of the other
- */
- @Test(dataProvider = "validateNanos")
- public void test51(String ts, int nanos) {
- Timestamp ts1 = Timestamp.valueOf(ts);
- Timestamp ts2 = Timestamp.valueOf(ts1.toString());
- assertTrue(ts1.getNanos() == nanos && ts1.equals(ts2),
- "Error with Nanos");
- }
-
- @Test(dataProvider = "validTimestampLongValues")
- public void test52(long value, String ts) {
- Timestamp ts1 = new Timestamp(value);
- assertEquals(ts1.toString(), ts, "ts1.toString() != ts");
- }
-
- /*
- * DataProvider used to provide Timestamps which are not valid and are used
- * to validate that an IllegalArgumentException will be thrown from the
- * valueOf method
- */
- @DataProvider(name = "invalidTimestampValues")
- private Object[][] invalidTimestampValues() {
- return new Object[][]{
- {"2009-11-01-01 10:50:01"},
- {"aaaa-11-01-01 10:50"},
- {"aaaa-11-01 10:50"},
- {"1961--30 00:00:00"},
- {"--30 00:00:00"},
- {"-- 00:00:00"},
- {"1961-1- 00:00:00"},
- {"2009-11-01"},
- {"10:50:01"},
- {"1961-a-30 00:00:00"},
- {"1961-01-bb 00:00:00"},
- {"1961-08-30 00:00:00."},
- {"1961-08-30 :00:00"},
- {"1961-08-30 00::00"},
- {"1961-08-30 00:00:"},
- {"1961-08-30 ::"},
- {"1961-08-30 0a:00:00"},
- {"1961-08-30 00:bb:00"},
- {"1961-08-30 00:01:cc"},
- {"1961-08-30 00:00:00.01a"},
- {"1961-08-30 00:00:00.a"},
- {"1996-12-10 12:26:19.1234567890"},
- {null}
- };
- }
-
- /*
- * DataProvider used to provide Timestamps which are valid and are used
- * to validate that an IllegalArgumentException will not be thrown from the
- * valueOf method and the corect value from toString() is returned
- */
- @DataProvider(name = "validTimestampValues")
- private Object[][] validTimestampValues() {
- return new Object[][]{
- {"1961-08-30 00:00:00", "1961-08-30 00:00:00.0"},
- {"1961-08-30 11:22:33", "1961-08-30 11:22:33.0"},
- {"1961-8-30 00:00:00", "1961-08-30 00:00:00.0"},
- {"1966-08-1 00:00:00", "1966-08-01 00:00:00.0"},
- {"1996-12-10 12:26:19.1", "1996-12-10 12:26:19.1"},
- {"1996-12-10 12:26:19.12", "1996-12-10 12:26:19.12"},
- {"1996-12-10 12:26:19.123", "1996-12-10 12:26:19.123"},
- {"1996-12-10 12:26:19.1234", "1996-12-10 12:26:19.1234"},
- {"1996-12-10 12:26:19.12345", "1996-12-10 12:26:19.12345"},
- {"1996-12-10 12:26:19.123456", "1996-12-10 12:26:19.123456"},
- {"1996-12-10 12:26:19.1234567", "1996-12-10 12:26:19.1234567"},
- {"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
- {"1996-12-10 12:26:19.123456789", "1996-12-10 12:26:19.123456789"},
- {"1996-12-10 12:26:19.000000001", "1996-12-10 12:26:19.000000001"},
- {"1996-12-10 12:26:19.000000012", "1996-12-10 12:26:19.000000012"},
- {"1996-12-10 12:26:19.000000123", "1996-12-10 12:26:19.000000123"},
- {"1996-12-10 12:26:19.000001234", "1996-12-10 12:26:19.000001234"},
- {"1996-12-10 12:26:19.000012345", "1996-12-10 12:26:19.000012345"},
- {"1996-12-10 12:26:19.000123456", "1996-12-10 12:26:19.000123456"},
- {"1996-12-10 12:26:19.001234567", "1996-12-10 12:26:19.001234567"},
- {"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
- {"1996-12-10 12:26:19.0", "1996-12-10 12:26:19.0"},
- {"1996-12-10 12:26:19.01230", "1996-12-10 12:26:19.0123"}
- };
- }
-
- @DataProvider(name = "validTimestampLongValues")
- private Object[][] validTimestampLongValues() {
- return new Object[][]{
- {1L, "1970-01-01 01:00:00.001"},
- {-3600*1000L - 1, "1969-12-31 23:59:59.999"},
- {-(20000L*365*24*60*60*1000), "18018-08-28 01:00:00.0"},
- {Timestamp.valueOf("1961-08-30 11:22:33").getTime(), "1961-08-30 11:22:33.0"},
- {Timestamp.valueOf("1961-08-30 11:22:33.54321000").getTime(), "1961-08-30 11:22:33.543"}, // nanoprecision lost
- {new Timestamp(114, 10, 10, 10, 10, 10, 100000000).getTime(), "2014-11-10 10:10:10.1"},
- {new Timestamp(0, 10, 10, 10, 10, 10, 100000).getTime(), "1900-11-10 10:10:10.0"}, // nanoprecision lost
- {new Date(114, 10, 10).getTime(), "2014-11-10 00:00:00.0"},
- {new Date(0, 10, 10).getTime(), "1900-11-10 00:00:00.0"},
- {LocalDateTime.of(1960, 10, 10, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
- .toInstant().toEpochMilli(), "1960-10-10 19:10:10.0"},
-
- // millisecond timestamps wraps around at year 1, so Long.MIN_VALUE looks similar
- // Long.MAX_VALUE, while actually representing 292278994 BCE
- {Long.MIN_VALUE, "292278994-08-17 08:12:55.192"},
- {Long.MAX_VALUE + 1, "292278994-08-17 08:12:55.192"},
- {Long.MAX_VALUE, "292278994-08-17 08:12:55.807"},
- {Long.MIN_VALUE - 1, "292278994-08-17 08:12:55.807"},
-
- // wrap around point near 0001-01-01, test that we never get a negative year:
- {-(1970L*365*24*60*60*1000), "0001-04-25 01:00:00.0"},
- {-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L), "0001-12-31 01:00:00.0"},
- {-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L - 23*60*60*1000L), "0001-01-01 00:00:00.0"},
-
- {LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
- .toInstant().toEpochMilli() - 2*24*60*60*1000L, "0001-01-01 19:03:08.0"}, // 1 BCE
- {LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
- .toInstant().toEpochMilli() - 3*24*60*60*1000L, "0002-12-31 19:03:08.0"} // 2 BCE
- };
- }
-
- /*
- * DataProvider used to provide Timestamp and Nanos values in order to
- * validate that the correct Nanos value is generated from the specified
- * Timestamp
- */
- @DataProvider(name = "validateNanos")
- private Object[][] validateNanos() {
- return new Object[][]{
- {"1961-08-30 00:00:00", 0},
- {"1996-12-10 12:26:19.1", 100000000},
- {"1996-12-10 12:26:19.12", 120000000},
- {"1996-12-10 12:26:19.123", 123000000},
- {"1996-12-10 12:26:19.1234", 123400000},
- {"1996-12-10 12:26:19.12345", 123450000},
- {"1996-12-10 12:26:19.123456", 123456000},
- {"1996-12-10 12:26:19.1234567", 123456700},
- {"1996-12-10 12:26:19.12345678", 123456780},
- {"1996-12-10 12:26:19.123456789", 123456789},
- {"1996-12-10 12:26:19.000000001", 1},
- {"1996-12-10 12:26:19.000000012", 12},
- {"1996-12-10 12:26:19.000000123", 123},
- {"1996-12-10 12:26:19.000001234", 1234},
- {"1996-12-10 12:26:19.000012345", 12345},
- {"1996-12-10 12:26:19.000123456", 123456},
- {"1996-12-10 12:26:19.001234567", 1234567},
- {"1996-12-10 12:26:19.012345678", 12345678},
- {"1996-12-10 12:26:19.0", 0},
- {"1996-12-10 12:26:19.01230", 12300000}
- };
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/TEST.properties Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,3 @@
+# JDBC unit tests uses TestNG
+TestNG.dirs = .
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/BatchUpdateExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.ObjectInputStream;
+import java.sql.BatchUpdateException;
+import java.sql.SQLException;
+import java.util.Arrays;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.SerializedBatchUpdateException;
+import util.BaseTest;
+
+public class BatchUpdateExceptionTests extends BaseTest {
+
+ private final int[] uc = {1, 2, 3};
+ private final long[] luc = {1, 2, 3};
+
+ private final String testSrcDir = System.getProperty("test.src", ".")
+ + File.separatorChar;
+
+ /**
+ * Create BatchUpdateException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ BatchUpdateException be = new BatchUpdateException(null,
+ null, errorCode, (int[]) null, null);
+ assertTrue(be.getMessage() == null && be.getSQLState() == null
+ && be.getUpdateCounts() == null && be.getCause() == null
+ && be.getLargeUpdateCounts() == null
+ && be.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create BatchUpdateException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ BatchUpdateException ex = new BatchUpdateException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getUpdateCounts() == null
+ && ex.getLargeUpdateCounts() == null);
+ }
+
+ /**
+ * Create BatchUpdateException with null Throwable
+ */
+ @Test
+ public void test2() {
+ BatchUpdateException ex = new BatchUpdateException((Throwable) null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getUpdateCounts() == null
+ && ex.getLargeUpdateCounts() == null);
+ }
+
+ /**
+ * Create BatchUpdateException with message and update counts
+ */
+ @Test
+ public void test3() {
+
+ BatchUpdateException ex = new BatchUpdateException(reason, uc);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with update counts
+ */
+ @Test
+ public void test4() {
+ BatchUpdateException ex = new BatchUpdateException(uc);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with Throwable and update counts
+ */
+ @Test
+ public void test5() {
+ BatchUpdateException ex = new BatchUpdateException(uc, t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with message, Throwable, and update counts
+ */
+ @Test
+ public void test6() {
+ BatchUpdateException ex = new BatchUpdateException(reason, uc, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with message, SQLState, Throwable, and update
+ * counts
+ */
+ @Test
+ public void test7() {
+ BatchUpdateException ex = new BatchUpdateException(reason, state, uc, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with message, SQLState, errorCode code
+ * Throwable, and update counts
+ */
+ @Test
+ public void test8() {
+ BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
+ uc, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with message, SQLState, errorCode code
+ * Throwable, and long [] update counts
+ */
+ @Test
+ public void test9() {
+ BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
+ luc, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Validate that a copy of the update counts array is made
+ */
+ @Test
+ public void test10() {
+ int[] uc1 = {1, 2};
+ BatchUpdateException ex = new BatchUpdateException(uc1);
+ assertTrue(Arrays.equals(ex.getUpdateCounts(), uc1));
+ uc1[0] = 6689;
+ assertFalse(Arrays.equals(ex.getUpdateCounts(), uc1));
+ }
+
+ /**
+ * Validate that if null is specified for the update count, it is returned
+ * as null
+ */
+ @Test
+ public void test11() {
+ BatchUpdateException ex = new BatchUpdateException((int[]) null);
+ assertTrue(ex.getMessage() == null && ex.getSQLState() == null
+ && ex.getErrorCode() == 0 && ex.getUpdateCounts() == null
+ && ex.getLargeUpdateCounts() == null);
+ }
+
+ /**
+ * Serialize a BatchUpdateException and make sure you can read it back
+ * properly
+ */
+ @Test
+ public void test12() throws Exception {
+ BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
+ uc, t);
+ BatchUpdateException bue
+ = createSerializedException(be);
+ assertTrue(reason.equals(bue.getMessage())
+ && bue.getSQLState().equals(state)
+ && cause.equals(bue.getCause().toString())
+ && bue.getErrorCode() == errorCode
+ && Arrays.equals(bue.getLargeUpdateCounts(), luc)
+ && Arrays.equals(bue.getUpdateCounts(), uc));
+ }
+
+
+
+ /**
+ * De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can
+ * read it back properly
+ */
+ @Test
+ public void test13() throws Exception {
+ String reason1 = "This was the error msg";
+ String state1 = "user defined sqlState";
+ String cause1 = "java.lang.Throwable: throw 1";
+ int errorCode1 = 99999;
+ Throwable t = new Throwable("throw 1");
+ int[] uc1 = {1, 2, 21};
+ long[] luc1 = {1, 2, 21};
+
+ ObjectInputStream ois = new ObjectInputStream(
+ new ByteArrayInputStream(SerializedBatchUpdateException.DATA));
+ BatchUpdateException bue = (BatchUpdateException) ois.readObject();
+ assertTrue(reason1.equals(bue.getMessage())
+ && bue.getSQLState().equals(state1)
+ && bue.getErrorCode() == errorCode1
+ && cause1.equals(bue.getCause().toString())
+ && Arrays.equals(bue.getLargeUpdateCounts(), luc1)
+ && Arrays.equals(bue.getUpdateCounts(), uc1));
+ }
+
+ /**
+ * Serialize a BatchUpdateException with an Integer.MAX_VALUE + 1 and
+ * validate you can read it back properly
+ */
+ @Test
+ public void test14() throws Exception {
+ int[] uc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
+ long[] luc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
+ BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
+ luc1, t);
+ BatchUpdateException bue
+ = createSerializedException(be);
+ assertTrue(reason.equals(bue.getMessage())
+ && bue.getSQLState().equals(state)
+ && cause.equals(bue.getCause().toString())
+ && bue.getErrorCode() == errorCode
+ && Arrays.equals(bue.getLargeUpdateCounts(), luc1)
+ && Arrays.equals(bue.getUpdateCounts(), uc1));
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test15() {
+ BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
+ BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
+ BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test16() {
+ BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
+ BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
+ BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ SQLException sqe = ex;
+ int num = 0;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/DataTruncationTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.DataTruncation;
+import java.sql.SQLException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class DataTruncationTests extends BaseTest {
+
+ private final String READ_TRUNCATION = "01004";
+ private final String WRITE_TRUNCATION = "22001";
+ private final String dtReason = "Data truncation";
+ private final int dterrorCode = 0;
+ private final String[] dtmsgs = {dtReason, "cause 1", dtReason,
+ dtReason, "cause 2"};
+ private boolean onRead = false;
+ private final boolean parameter = false;
+ private final int index = 21;
+ private final int dataSize = 25;
+ private final int transferSize = 10;
+
+ /**
+ * Create DataTruncation object indicating a truncation on read
+ */
+ @Test
+ public void test() {
+ onRead = true;
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Create DataTruncation object indicating a truncation on write
+ */
+ @Test
+ public void test1() {
+ onRead = false;
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(WRITE_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Create DataTruncation object indicating a truncation on read with a
+ * Throwable
+ */
+ @Test
+ public void test2() {
+ onRead = true;
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && cause.equals(e.getCause().toString())
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Create DataTruncation object indicating a truncation on read with null
+ * specified for the Throwable
+ */
+ @Test
+ public void test3() {
+ onRead = true;;
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, null);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Create DataTruncation object indicating a truncation on read and you can
+ * pass a -1 for the index
+ */
+ @Test
+ public void test4() {
+ onRead = true;
+ int negIndex = -1;
+ DataTruncation e = new DataTruncation(negIndex, parameter, onRead,
+ dataSize, transferSize);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == negIndex);
+ }
+
+ /**
+ * Serialize a DataTruncation and make sure you can read it back properly
+ */
+ @Test
+ public void test5() throws Exception {
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ DataTruncation ex1 = createSerializedException(e);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test11() {
+ DataTruncation ex = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t1);
+ DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(dtmsgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test12() {
+ DataTruncation ex = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t1);
+ DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(dtmsgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(dtmsgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/DateTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,373 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.Date;
+import java.time.Instant;
+import java.time.LocalDate;
+import static org.testng.Assert.*;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class DateTests extends BaseTest {
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid Date string
+ */
+ @Test(dataProvider = "invalidDateValues",
+ expectedExceptions = IllegalArgumentException.class)
+ public void test(String d) throws Exception {
+ Date.valueOf(d);
+ }
+
+ /*
+ * Test that a date created from a date string is equal to the value
+ * returned from toString()
+ */
+ @Test(dataProvider = "validDateValues")
+ public void test00(String d, String expectedD) {
+ Date d1 = Date.valueOf(d);
+ Date d2 = Date.valueOf(expectedD);
+ assertTrue(d1.equals(d2) && d2.equals(d1)
+ && d1.toString().equals(expectedD), "Error d1 != d2");
+ }
+
+ /*
+ * Validate that a Date.after() returns false when same date is compared
+ */
+ @Test
+ public void test01() {
+ Date d = Date.valueOf("1961-08-30");
+ assertFalse(d.after(d), "Error d.after(d) = true");
+ }
+
+ /*
+ * Validate that a Date.after() returns true when later date is compared to
+ * earlier date
+ */
+ @Test
+ public void test2() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(System.currentTimeMillis());
+ assertTrue(d2.after(d), "Error d2.after(d) = false");
+ }
+
+ /*
+ * Validate that a Date.after() returns false when earlier date is compared
+ * to later date
+ */
+ @Test
+ public void test3() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertFalse(d.after(d2), "Error d.after(d2) = true");
+ }
+
+ /*
+ * Validate that a Date.after() returns false when date compared to another
+ * date created from the original date
+ */
+ @Test
+ public void test4() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertFalse(d.after(d2), "Error d.after(d2) = true");
+ assertFalse(d2.after(d), "Error d2.after(d) = true");
+ }
+
+ /*
+ * Validate that a Date.before() returns false when same date is compared
+ */
+ @Test
+ public void test5() {
+ Date d = Date.valueOf("1961-08-30");
+ assertFalse(d.before(d), "Error d.before(d) = true");
+ }
+
+ /*
+ * Validate that a Date.before() returns true when earlier date is compared
+ * to later date
+ */
+ @Test
+ public void test6() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(System.currentTimeMillis());
+ assertTrue(d.before(d2), "Error d.before(d2) = false");
+ }
+
+ /*
+ * Validate that a Date.before() returns false when later date is compared
+ * to earlier date
+ */
+ @Test
+ public void test7() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertFalse(d2.before(d), "Error d2.before(d) = true");
+ }
+
+ /*
+ * Validate that a Date.before() returns false when date compared to another
+ * date created from the original date
+ */
+ @Test
+ public void test8() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertFalse(d.before(d2), "Error d.before(d2) = true");
+ assertFalse(d2.before(d), "Error d2.before(d) = true");
+ }
+
+ /*
+ * Validate that a Date.compareTo returns 0 when both Date objects are the
+ * same
+ */
+ @Test
+ public void test9() {
+ Date d = Date.valueOf("1961-08-30");
+ assertTrue(d.compareTo(d) == 0, "Error d.compareTo(d) !=0");
+ }
+
+ /*
+ * Validate that a Date.compareTo returns 0 when both Date objects represent
+ * the same date
+ */
+ @Test
+ public void test10() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertTrue(d.compareTo(d2) == 0, "Error d.compareTo(d2) !=0");
+ }
+
+ /*
+ * Validate that a Date.compareTo returns -1 when comparing a date to a
+ * later date
+ */
+ @Test
+ public void test11() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(System.currentTimeMillis());
+ assertTrue(d.compareTo(d2) == -1, "Error d.compareTo(d2) != -1");
+ }
+
+ /*
+ * Validate that a Date.compareTo returns 1 when comparing a date to an
+ * earlier date
+ */
+ @Test
+ public void test12() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(System.currentTimeMillis());
+ assertTrue(d2.compareTo(d) == 1, "Error d.compareTo(d2) != 1");
+ }
+
+ /*
+ * Validate that a Date made from a LocalDate are equal
+ */
+ @Test
+ public void test13() {
+ Date d = Date.valueOf("1961-08-30");
+ LocalDate ldt = d.toLocalDate();
+ Date d2 = Date.valueOf(ldt);
+ assertTrue(d.equals(d2), "Error d != d2");
+ }
+
+ /*
+ * Validate that a Date LocalDate value, made from a LocalDate are equal
+ */
+ @Test
+ public void test14() {
+ LocalDate ldt = LocalDate.now();
+ Date d = Date.valueOf(ldt);
+ assertTrue(ldt.equals(d.toLocalDate()),
+ "Error LocalDate values are not equal");
+ }
+
+ /*
+ * Validate an NPE occurs when a null LocalDate is passed to valueOf
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test15() throws Exception {
+ LocalDate ld = null;
+ Date.valueOf(ld);
+ }
+
+ /*
+ * Validate an UnsupportedOperationException occurs when toInstant() is
+ * called
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void test16() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ Instant instant = d.toInstant();
+ }
+
+ /*
+ * Validate that two Date objects are equal when one is created from the
+ * toString() of the other
+ */
+ @Test
+ public void test17() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = Date.valueOf(d.toString());
+ assertTrue(d.equals(d2) && d2.equals(d), "Error d != d2");
+ }
+
+ /*
+ * Validate that two Date values one created using valueOf and another via a
+ * constructor are equal
+ */
+ @Test
+ public void test18() {
+
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(61, 7, 30);
+ assertTrue(d.equals(d2), "Error d != d2");
+ }
+
+ /*
+ * Validate that two Date values one created using getTime() of the other
+ * are equal
+ */
+ @Test
+ public void test19() {
+
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertTrue(d.equals(d2), "Error d != d2");
+ }
+
+ /*
+ * Validate that a Date value is equal to itself
+ */
+ @Test
+ public void test20() {
+
+ Date d = Date.valueOf("1961-08-30");
+ assertTrue(d.equals(d), "Error d != d");
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getHours
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test21() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.getHours();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getMinutes
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test22() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.getMinutes();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getSeconds
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test23() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.getSeconds();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setHours
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test24() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.setHours(8);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setMinutes
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test25() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.setMinutes(0);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setSeconds
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test26() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.setSeconds(0);
+ }
+
+ /*
+ * DataProvider used to provide Date which are not valid and are used
+ * to validate that an IllegalArgumentException will be thrown from the
+ * valueOf method
+ */
+ @DataProvider(name = "invalidDateValues")
+ private Object[][] invalidDateValues() {
+ return new Object[][]{
+ {"20009-11-01"},
+ {"09-11-01"},
+ {"-11-01"},
+ {"2009-111-01"},
+ {"2009--01"},
+ {"2009-13-01"},
+ {"2009-11-011"},
+ {"2009-11-"},
+ {"2009-11-00"},
+ {"2009-11-33"},
+ {"--"},
+ {""},
+ {null},
+ {"-"},
+ {"2009"},
+ {"2009-01"},
+ {"---"},
+ {"2009-13--1"},
+ {"1900-1-0"},
+ {"2009-01-01 10:50:01"},
+ {"1996-12-10 12:26:19.1"},
+ {"10:50:01"}
+ };
+ }
+
+ /*
+ * DataProvider used to provide Dates which are valid and are used
+ * to validate that an IllegalArgumentException will not be thrown from the
+ * valueOf method and the corect value from toString() is returned
+ */
+ @DataProvider(name = "validDateValues")
+ private Object[][] validDateValues() {
+ return new Object[][]{
+ {"2009-08-30", "2009-08-30"},
+ {"2009-01-8", "2009-01-08"},
+ {"2009-1-01", "2009-01-01"},
+ {"2009-1-1", "2009-01-01"}
+
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/DriverManagerPermissionsTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.security.AccessControlException;
+import java.security.Policy;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import util.BaseTest;
+import util.StubDriver;
+import util.TestPolicy;
+
+public class DriverManagerPermissionsTests extends BaseTest {
+
+ private static Policy policy;
+ private static SecurityManager sm;
+
+ /*
+ * Install a SecurityManager along with a base Policy to allow testNG to run
+ */
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ setPolicy(new TestPolicy());
+ System.setSecurityManager(new SecurityManager());
+ }
+
+ /*
+ * Install the original Policy and SecurityManager
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ System.setSecurityManager(sm);
+ setPolicy(policy);
+ }
+
+ /*
+ * Save off the original Policy and SecurityManager
+ */
+ public DriverManagerPermissionsTests() {
+ policy = Policy.getPolicy();
+ sm = System.getSecurityManager();
+ }
+
+ /*
+ * Validate that AccessControlException is thrown if SQLPermission("setLog")
+ * has not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test() {
+ setPolicy(new TestPolicy());
+ DriverManager.setLogStream(null);
+ }
+
+ /*
+ * Validate that setLogStream succeeds if SQLPermission("setLog") has been
+ * granted
+ */
+ @Test
+ public void test1() {
+ Policy.setPolicy(new TestPolicy("setLog"));
+ DriverManager.setLogStream(null);
+ }
+
+ /*
+ * Validate that setLogStream succeeds if AllPermissions has been granted
+ */
+ @Test
+ public void test2() {
+ setPolicy(new TestPolicy("all"));
+ DriverManager.setLogStream(null);
+ }
+
+ /*
+ * Validate that AccessControlException is thrown if SQLPermission("setLog")
+ * has not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test4() {
+ setPolicy(new TestPolicy());
+ DriverManager.setLogWriter(null);
+ }
+
+ /*
+ * Validate that setLogWriter succeeds if SQLPermission("setLog") has been
+ * granted
+ */
+ @Test
+ public void test5() {
+ setPolicy(new TestPolicy("setLog"));
+ DriverManager.setLogWriter(null);
+ }
+
+ /*
+ * Validate that setLogWriter succeeds if AllPermissions has been granted
+ */
+ @Test
+ public void test6() {
+ setPolicy(new TestPolicy("all"));
+ DriverManager.setLogWriter(null);
+ }
+
+ /*
+ * Validate that AccessControlException is thrown if
+ * SQLPermission("deregisterDriver") has not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test7() throws SQLException {
+ setPolicy(new TestPolicy());
+ DriverManager.deregisterDriver(new StubDriver());
+ }
+
+ /*
+ * Validate that deregisterDriver succeeds if
+ * SQLPermission("deregisterDriver") has been granted
+ */
+ @Test
+ public void test8() throws SQLException {
+ setPolicy(new TestPolicy("deregisterDriver"));
+ DriverManager.deregisterDriver(new StubDriver());
+ }
+
+ /*
+ * Validate that deregisterDriver succeeds if AllPermissions has been
+ * granted
+ */
+ @Test
+ public void test9() throws SQLException {
+ setPolicy(new TestPolicy("all"));
+ DriverManager.deregisterDriver(new StubDriver());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/DriverManagerTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Properties;
+import static org.testng.Assert.*;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import util.StubDriver;
+
+public class DriverManagerTests {
+
+ private final String StubDriverURL = "jdbc:tennis:boy";
+ private final String StubDriverDAURL = "jdbc:luckydog:tennis";
+ private final String InvalidURL = "jdbc:cardio:tennis";
+ private String[] results = {"output", "more output", "and more", "the end"};
+ private String noOutput = "should not find this";
+
+ public DriverManagerTests() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @BeforeMethod
+ public void setUpMethod() throws Exception {
+ removeAllDrivers();
+ }
+
+ @AfterMethod
+ public void tearDownMethod() throws Exception {
+ }
+
+ /**
+ * Utility method to remove all registered drivers
+ */
+ private static void removeAllDrivers() {
+ java.util.Enumeration e = DriverManager.getDrivers();
+ while (e.hasMoreElements()) {
+ try {
+ DriverManager.deregisterDriver((Driver) (e.nextElement()));
+ } catch (SQLException ex) {
+ System.out.print(ex.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Utility method to see if a driver is registered
+ */
+ private boolean isDriverRegistered(Driver d) {
+ boolean foundDriver = false;
+ java.util.Enumeration e = DriverManager.getDrivers();
+ while (e.hasMoreElements()) {
+ if (d == (Driver) e.nextElement()) {
+ foundDriver = true;
+ break;
+ }
+ }
+ return foundDriver;
+ }
+
+ /**
+ * Validate that values set using setLoginTimeout will be returned by
+ * getLoginTimeout
+ */
+ @Test
+ public void test() {
+ int[] vals = {-1, 0, 5};
+ for (int val : vals) {
+ DriverManager.setLoginTimeout(val);
+ assertEquals(val, DriverManager.getLoginTimeout());
+ }
+ }
+
+ /**
+ * Validate that NullPointerException is thrown when null is passed to
+ * registerDriver
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test1() throws Exception {
+ Driver d = null;
+ DriverManager.registerDriver(d);
+ }
+
+ /**
+ * Validate that NullPointerException is thrown when null is passed to
+ * registerDriver
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test2() throws Exception {
+ Driver d = null;
+ DriverManager.registerDriver(d, null);
+ }
+
+ /**
+ * Validate that a null value allows for deRegisterDriver to return
+ */
+ @Test
+ public void test3() throws Exception {
+ DriverManager.deregisterDriver(null);
+
+ }
+
+ /**
+ * Validate that SQLException is thrown when there is no Driver to service
+ * the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test4() throws Exception {
+ DriverManager.getConnection(InvalidURL);
+ }
+
+ /**
+ * Validate that SQLException is thrown when there is no Driver to service
+ * the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test5() throws Exception {
+ DriverManager.getConnection(InvalidURL, new Properties());
+ }
+
+ /**
+ * Validate that SQLException is thrown when there is no Driver to service
+ * the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test6() throws Exception {
+ DriverManager.getConnection(InvalidURL, "LuckyDog", "tennisanyone");
+ }
+
+ /**
+ * Validate that SQLException is thrown when null is passed for the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test7() throws Exception {
+ DriverManager.getConnection(null);
+ }
+
+ /**
+ * Validate that SQLException is thrown when null is passed for the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test8() throws Exception {
+ DriverManager.getConnection(null, new Properties());
+ }
+
+ /**
+ * Validate that SQLException is thrown when null is passed for the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test9() throws Exception {
+ DriverManager.getConnection(null, "LuckyDog", "tennisanyone");
+ }
+
+ /**
+ * Validate that SQLException is thrown when there is no Driver to service
+ * the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test10() throws Exception {
+ DriverManager.getDriver(InvalidURL);
+ }
+
+ /**
+ * Validate that SQLException is thrown when null is passed for the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test11() throws Exception {
+ DriverManager.getDriver(null);
+ }
+
+ /**
+ * Validate that a non-null Driver is returned by getDriver when a valid URL
+ * is specified
+ */
+ @Test
+ public void test12() throws Exception {
+
+ DriverManager.registerDriver(new StubDriver());
+ assertTrue(DriverManager.getDriver(StubDriverURL) != null);
+ }
+
+ /**
+ * Validate that SQLException is thrown when the URL is not valid for any of
+ * the registered drivers
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test13() throws Exception {
+ DriverManager.registerDriver(new StubDriver());
+ DriverManager.getDriver(InvalidURL);
+ }
+
+ /**
+ * Validate that a Connection object is returned when a valid URL is
+ * specified to getConnection
+ *
+ */
+ @Test
+ public void test14() throws Exception {
+
+ DriverManager.registerDriver(new StubDriver());
+ assertTrue(
+ DriverManager.getConnection(StubDriverURL) != null);
+ assertTrue(DriverManager.getConnection(StubDriverURL,
+ "LuckyDog", "tennisanyone") != null);
+ Properties props = new Properties();
+ props.put("user", "LuckyDog");
+ props.put("password", "tennisanyone");
+ assertTrue(
+ DriverManager.getConnection(StubDriverURL,
+ props) != null);
+ }
+
+ /**
+ * Register a driver and make sure you find it via its URL. Deregister the
+ * driver and validate it is not longer registered
+ *
+ * @throws Exception
+ */
+ @Test()
+ public void test15() throws Exception {
+ DriverManager.registerDriver(new StubDriver());
+ Driver d = DriverManager.getDriver(StubDriverURL);
+ assertTrue(d != null);
+ assertTrue(isDriverRegistered(d));
+ DriverManager.deregisterDriver(d);
+ assertFalse(isDriverRegistered(d));
+ }
+
+ /**
+ * Validate that DriverAction.release is called when a driver is registered
+ * via registerDriver(Driver, DriverAction)
+ *
+ * @throws Exception
+ */
+ @Test
+ public void test16() throws Exception {
+ File file = new File(util.StubDriverDA.DriverActionCalled);
+ file.delete();
+ assertFalse(file.exists());
+ Driver d = null;
+ Class.forName("util.StubDriverDA");
+ d = DriverManager.getDriver(StubDriverDAURL);
+ DriverManager.deregisterDriver(d);
+ assertFalse(isDriverRegistered(d), "Driver is registered");
+ assertTrue(file.exists());
+ }
+
+ /**
+ * Create a PrintStream and use to send output via DriverManager.println
+ * Validate that if you disable the stream, the output sent is not present
+ */
+ @Test
+ public void tests17() throws Exception {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(os);
+ DriverManager.setLogStream(ps);
+ assertTrue(DriverManager.getLogStream() == ps);
+
+ DriverManager.println(results[0]);
+ DriverManager.setLogStream((PrintStream) null);
+ assertTrue(DriverManager.getLogStream() == null);
+ DriverManager.println(noOutput);
+ DriverManager.setLogStream(ps);
+ DriverManager.println(results[1]);
+ DriverManager.println(results[2]);
+ DriverManager.println(results[3]);
+ DriverManager.setLogStream((PrintStream) null);
+ DriverManager.println(noOutput);
+
+ /*
+ * Check we do not get the output when the stream is disabled
+ */
+ InputStreamReader is
+ = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
+ BufferedReader reader = new BufferedReader(is);
+ for (String result : results) {
+ assertTrue(result.equals(reader.readLine()));
+ }
+ }
+
+ /**
+ * Create a PrintWriter and use to to send output via DriverManager.println
+ * Validate that if you disable the writer, the output sent is not present
+ */
+ @Test
+ public void tests18() throws Exception {
+ CharArrayWriter cw = new CharArrayWriter();
+ PrintWriter pw = new PrintWriter(cw);
+ DriverManager.setLogWriter(pw);
+ assertTrue(DriverManager.getLogWriter() == pw);
+
+ DriverManager.println(results[0]);
+ DriverManager.setLogWriter(null);
+ assertTrue(DriverManager.getLogWriter() == null);
+ DriverManager.println(noOutput);
+ DriverManager.setLogWriter(pw);
+ DriverManager.println(results[1]);
+ DriverManager.println(results[2]);
+ DriverManager.println(results[3]);
+ DriverManager.setLogWriter(null);
+ DriverManager.println(noOutput);
+
+ /*
+ * Check we do not get the output when the stream is disabled
+ */
+ BufferedReader reader
+ = new BufferedReader(new CharArrayReader(cw.toCharArray()));
+ for (String result : results) {
+ assertTrue(result.equals(reader.readLine()));
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLClientInfoExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.ClientInfoStatus;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLClientInfoExceptionTests extends BaseTest {
+
+ private final HashMap<String, ClientInfoStatus> map = new HashMap<>();
+
+ public SQLClientInfoExceptionTests() {
+ map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
+ map.put("21", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
+ }
+
+ /**
+ * Create SQLClientInfoException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLClientInfoException e = new SQLClientInfoException(null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == 0
+ && e.getFailedProperties() == null);
+ }
+
+ /**
+ * Create SQLClientInfoException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLClientInfoException ex = new SQLClientInfoException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties() == null);
+ }
+
+ /**
+ * Create SQLClientInfoException with null Throwable
+ */
+ @Test
+ public void test2() {
+
+ SQLClientInfoException ex = new SQLClientInfoException(map, null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message
+ */
+ @Test
+ public void test3() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, map);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with null Throwable
+ */
+ @Test
+ public void test4() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, map, null);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message, and SQLState
+ */
+ @Test
+ public void test5() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, state,
+ map);
+
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message, and SQLState
+ */
+ @Test
+ public void test6() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, state,
+ map, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message, SQLState, errorCode, and
+ * Throwable
+ */
+ @Test
+ public void test7() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, state,
+ errorCode, map);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message, SQLState, and error code
+ */
+ @Test
+ public void test8() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, state,
+ errorCode, map, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Serialize a SQLClientInfoException and make sure you can read it back
+ * properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLClientInfoException e = new SQLClientInfoException(reason, state,
+ errorCode, map, t);
+ SQLClientInfoException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode
+ && ex1.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
+ map, t1);
+ SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
+ map);
+ SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
+ map, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
+ map, t1);
+ SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
+ map);
+ SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
+ map, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLDataExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLDataException;
+import java.sql.SQLException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLDataExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLDataException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLDataException e = new SQLDataException(null, null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLDataException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLDataException ex = new SQLDataException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with message
+ */
+ @Test
+ public void test2() {
+ SQLDataException ex = new SQLDataException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLDataException ex = new SQLDataException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLDataException ex = new SQLDataException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLDataException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLDataException ex = new SQLDataException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLDataException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLDataException ex = new SQLDataException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLDataException ex = new SQLDataException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLDataException ex = new SQLDataException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLDataException ex = new SQLDataException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLDataException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLDataException e = new SQLDataException(reason, state, errorCode, t);
+ SQLDataException ex1 = createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLDataException ex = new SQLDataException("Exception 1", t1);
+ SQLDataException ex1 = new SQLDataException("Exception 2");
+ SQLDataException ex2 = new SQLDataException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLDataException ex = new SQLDataException("Exception 1", t1);
+ SQLDataException ex1 = new SQLDataException("Exception 2");
+ SQLDataException ex2 = new SQLDataException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLDataException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLDataException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLException e = new SQLException(null, null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLException ex = new SQLException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with message
+ */
+ @Test
+ public void test2() {
+ SQLException ex = new SQLException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLException ex = new SQLException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLException ex = new SQLException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLException ex = new SQLException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLException ex = new SQLException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLException ex = new SQLException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLException ex = new SQLException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLException ex = new SQLException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLException e = new SQLException(reason, state, errorCode, t);
+ SQLException ex1 = createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLException ex = new SQLException("Exception 1", t1);
+ SQLException ex1 = new SQLException("Exception 2");
+ SQLException ex2 = new SQLException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLException ex = new SQLException("Exception 1", t1);
+ SQLException ex1 = new SQLException("Exception 2");
+ SQLException ex2 = new SQLException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ while (ex != null) {
+ assertTrue(msgs[num++].equals(ex.getMessage()));
+ Throwable c = ex.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ ex = ex.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLFeatureNotSupportedExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLFeatureNotSupportedExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLFeatureNotSupportedException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLFeatureNotSupportedException e =
+ new SQLFeatureNotSupportedException(null, null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message
+ */
+ @Test
+ public void test2() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException((Throwable) null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLFeatureNotSupportedException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLFeatureNotSupportedException e =
+ new SQLFeatureNotSupportedException(reason, state, errorCode, t);
+ SQLFeatureNotSupportedException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException("Exception 1", t1);
+ SQLFeatureNotSupportedException ex1 =
+ new SQLFeatureNotSupportedException("Exception 2");
+ SQLFeatureNotSupportedException ex2 =
+ new SQLFeatureNotSupportedException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException("Exception 1", t1);
+ SQLFeatureNotSupportedException ex1 =
+ new SQLFeatureNotSupportedException("Exception 2");
+ SQLFeatureNotSupportedException ex2 =
+ new SQLFeatureNotSupportedException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLFeatureNotSupportedException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLIntegrityConstraintViolationExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLIntegrityConstraintViolationException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLIntegrityConstraintViolationExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLIntegrityConstraintViolationException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLIntegrityConstraintViolationException e =
+ new SQLIntegrityConstraintViolationException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message
+ */
+ @Test
+ public void test2() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLIntegrityConstraintViolationException and make sure
+ * you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLIntegrityConstraintViolationException e =
+ new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
+ SQLIntegrityConstraintViolationException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException("Exception 1", t1);
+ SQLIntegrityConstraintViolationException ex1 =
+ new SQLIntegrityConstraintViolationException("Exception 2");
+ SQLIntegrityConstraintViolationException ex2 =
+ new SQLIntegrityConstraintViolationException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException("Exception 1", t1);
+ SQLIntegrityConstraintViolationException ex1 =
+ new SQLIntegrityConstraintViolationException("Exception 2");
+ SQLIntegrityConstraintViolationException ex2 =
+ new SQLIntegrityConstraintViolationException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLIntegrityConstraintViolationException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLInvalidAuthorizationSpecException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLInvalidAuthorizationSpecExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException and setting all objects to
+ * null
+ */
+ @Test
+ public void test() {
+ SQLInvalidAuthorizationSpecException e
+ = new SQLInvalidAuthorizationSpecException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message
+ */
+ @Test
+ public void test2() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, SQLState, and
+ * error code
+ */
+ @Test
+ public void test4() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, SQLState,
+ * errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, SQLState, and
+ * Throwable
+ */
+ @Test
+ public void test6() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException((Throwable) null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLInvalidAuthorizationSpecException and make sure you can
+ * read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLInvalidAuthorizationSpecException e
+ = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
+ SQLInvalidAuthorizationSpecException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
+ SQLInvalidAuthorizationSpecException ex1
+ = new SQLInvalidAuthorizationSpecException("Exception 2");
+ SQLInvalidAuthorizationSpecException ex2
+ = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
+ SQLInvalidAuthorizationSpecException ex1
+ = new SQLInvalidAuthorizationSpecException("Exception 2");
+ SQLInvalidAuthorizationSpecException ex2
+ = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException and validate it is an
+ * instance of SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLInvalidAuthorizationSpecException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLNonTransientConnectionExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLNonTransientConnectionException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLNonTransientConnectionExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLNonTransientConnectionException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLNonTransientConnectionException e =
+ new SQLNonTransientConnectionException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message
+ */
+ @Test
+ public void test2() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLNonTransientConnectionException and make sure you can
+ * read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLNonTransientConnectionException e =
+ new SQLNonTransientConnectionException(reason, state, errorCode, t);
+ SQLNonTransientConnectionException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException("Exception 1", t1);
+ SQLNonTransientConnectionException ex1 =
+ new SQLNonTransientConnectionException("Exception 2");
+ SQLNonTransientConnectionException ex2 =
+ new SQLNonTransientConnectionException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException("Exception 1", t1);
+ SQLNonTransientConnectionException ex1 =
+ new SQLNonTransientConnectionException("Exception 2");
+ SQLNonTransientConnectionException ex2 =
+ new SQLNonTransientConnectionException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLNonTransientConnectionException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLNonTransientExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLNonTransientExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLNonTransientException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLNonTransientException e = new SQLNonTransientException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLNonTransientException ex = new SQLNonTransientException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with message
+ */
+ @Test
+ public void test2() {
+ SQLNonTransientException ex = new SQLNonTransientException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLNonTransientException ex = new SQLNonTransientException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {;
+ SQLNonTransientException ex =
+ new SQLNonTransientException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLNonTransientException ex =
+ new SQLNonTransientException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLNonTransientException ex = new SQLNonTransientException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLNonTransientException ex = new SQLNonTransientException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLNonTransientException ex = new SQLNonTransientException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLNonTransientException ex = new SQLNonTransientException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLNonTransientException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLNonTransientException e =
+ new SQLNonTransientException(reason, state, errorCode, t);
+ SQLNonTransientException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
+ SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
+ SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
+ SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
+ SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLRecoverableExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLRecoverableException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLRecoverableExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLRecoverableException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLRecoverableException e = new SQLRecoverableException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLRecoverableException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLRecoverableException ex = new SQLRecoverableException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with message
+ */
+ @Test
+ public void test2() {
+ SQLRecoverableException ex = new SQLRecoverableException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLRecoverableException ex = new SQLRecoverableException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLRecoverableException ex =
+ new SQLRecoverableException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLRecoverableException ex =
+ new SQLRecoverableException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLRecoverableException ex = new SQLRecoverableException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLRecoverableException ex = new SQLRecoverableException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLRecoverableException ex = new SQLRecoverableException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLRecoverableException ex = new SQLRecoverableException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLRecoverableException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLRecoverableException e =
+ new SQLRecoverableException(reason, state, errorCode, t);
+ SQLRecoverableException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
+ SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
+ SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
+ SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
+ SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLSyntaxErrorExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLNonTransientException;
+import java.sql.SQLSyntaxErrorException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLSyntaxErrorExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLSyntaxErrorException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLSyntaxErrorException e = new SQLSyntaxErrorException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message
+ */
+ @Test
+ public void test2() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLSyntaxErrorException ex =
+ new SQLSyntaxErrorException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLSyntaxErrorException ex =
+ new SQLSyntaxErrorException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLSyntaxErrorException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+
+ SQLSyntaxErrorException e =
+ new SQLSyntaxErrorException(reason, state, errorCode, t);
+ SQLSyntaxErrorException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
+ SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
+ SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
+ SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
+ SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLSyntaxErrorException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLSyntaxErrorException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLTimeoutExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLTimeoutException;
+import java.sql.SQLTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLTimeoutExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLTimeoutException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLTimeoutException e = new SQLTimeoutException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTimeoutException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLTimeoutException ex = new SQLTimeoutException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with message
+ */
+ @Test
+ public void test2() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLTimeoutException ex = new SQLTimeoutException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLTimeoutException ex = new SQLTimeoutException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLTimeoutException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLTimeoutException e =
+ new SQLTimeoutException(reason, state, errorCode, t);
+ SQLTimeoutException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
+ SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
+ SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
+ SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
+ SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLTimeoutException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLTimeoutException();
+ assertTrue(ex instanceof SQLTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLTransactionRollbackExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLTransactionRollbackException;
+import java.sql.SQLTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLTransactionRollbackExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLTransactionRollbackException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLTransactionRollbackException e =
+ new SQLTransactionRollbackException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLTransactionRollbackException ex = new SQLTransactionRollbackException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message
+ */
+ @Test
+ public void test2() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLTransactionRollbackException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLTransactionRollbackException e =
+ new SQLTransactionRollbackException(reason, state, errorCode, t);
+ SQLTransactionRollbackException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException("Exception 1", t1);
+ SQLTransactionRollbackException ex1 =
+ new SQLTransactionRollbackException("Exception 2");
+ SQLTransactionRollbackException ex2 =
+ new SQLTransactionRollbackException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException("Exception 1", t1);
+ SQLTransactionRollbackException ex1 =
+ new SQLTransactionRollbackException("Exception 2");
+ SQLTransactionRollbackException ex2 =
+ new SQLTransactionRollbackException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLTransactionRollbackException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLTransactionRollbackException();
+ assertTrue(ex instanceof SQLTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLTransientConnectionExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLTransientConnectionException;
+import java.sql.SQLTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLTransientConnectionExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLTransientConnectionException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLTransientConnectionException e =
+ new SQLTransientConnectionException( null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLTransientConnectionException ex = new SQLTransientConnectionException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message
+ */
+ @Test
+ public void test2() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {;
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLTransientConnectionException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLTransientConnectionException e =
+ new SQLTransientConnectionException(reason, state, errorCode, t);
+ SQLTransientConnectionException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException("Exception 1", t1);
+ SQLTransientConnectionException ex1 =
+ new SQLTransientConnectionException("Exception 2");
+ SQLTransientConnectionException ex2 =
+ new SQLTransientConnectionException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException("Exception 1", t1);
+ SQLTransientConnectionException ex1 =
+ new SQLTransientConnectionException("Exception 2");
+ SQLTransientConnectionException ex2 =
+ new SQLTransientConnectionException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLTransientConnectionException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLTransientConnectionException();
+ assertTrue(ex instanceof SQLTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLTransientExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLTransientExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLTransientException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLTransientException e = new SQLTransientException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLTransientException ex = new SQLTransientException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with message
+ */
+ @Test
+ public void test2() {
+ SQLTransientException ex = new SQLTransientException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLTransientException ex = new SQLTransientException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLTransientException ex = new SQLTransientException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLTransientException ex =
+ new SQLTransientException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLTransientException ex = new SQLTransientException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLTransientException ex = new SQLTransientException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLTransientException ex = new SQLTransientException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLTransientException ex = new SQLTransientException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLTransientException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLTransientException e =
+ new SQLTransientException(reason, state, errorCode, t);
+ SQLTransientException ex1 = createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLTransientException ex = new SQLTransientException("Exception 1", t1);
+ SQLTransientException ex1 = new SQLTransientException("Exception 2");
+ SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLTransientException ex = new SQLTransientException("Exception 1", t1);
+ SQLTransientException ex1 = new SQLTransientException("Exception 2");
+ SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLWarningTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLWarningTests extends BaseTest {
+
+ private final String[] warnings = {"Warning 1", "cause 1", "Warning 2",
+ "Warning 3", "cause 2"};
+
+ /**
+ * Create SQLWarning and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLWarning e = new SQLWarning(null, null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLWarning with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLWarning ex = new SQLWarning();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with message
+ */
+ @Test
+ public void test2() {
+ SQLWarning ex = new SQLWarning(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with message, and SQLState
+ */
+ @Test
+ public void test3() {
+
+ SQLWarning ex = new SQLWarning(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLWarning ex = new SQLWarning(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLWarning with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLWarning ex = new SQLWarning(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLWarning with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLWarning ex = new SQLWarning(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLWarning ex = new SQLWarning(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLWarning ex = new SQLWarning((Throwable) null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLWarning ex = new SQLWarning(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLWarning and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLWarning e = new SQLWarning(reason, state, errorCode, t);
+ SQLWarning ex1 = createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLWarning ex = new SQLWarning("Exception 1", t1);
+ SQLWarning ex1 = new SQLWarning("Exception 2");
+ SQLWarning ex2 = new SQLWarning("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLWarning ex = new SQLWarning("Exception 1", t1);
+ SQLWarning ex1 = new SQLWarning("Exception 2");
+ SQLWarning ex2 = new SQLWarning("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned SQLWarning is correct using
+ * for-each loop
+ */
+ @Test
+ public void test13() {
+ SQLWarning ex = new SQLWarning("Warning 1", t1);
+ SQLWarning ex1 = new SQLWarning("Warning 2");
+ SQLWarning ex2 = new SQLWarning("Warning 3", t2);
+ ex.setNextWarning(ex1);
+ ex.setNextWarning(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(warnings[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned SQLWarning is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test14() {
+ SQLWarning ex = new SQLWarning("Warning 1", t1);
+ SQLWarning ex1 = new SQLWarning("Warning 2");
+ SQLWarning ex2 = new SQLWarning("Warning 3", t2);
+ ex.setNextWarning(ex1);
+ ex.setNextWarning(ex2);
+ int num = 0;
+ SQLWarning sqe = ex;
+ while (sqe != null) {
+ assertTrue(warnings[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextWarning();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/TimeTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,348 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.Time;
+import java.time.LocalTime;
+import static org.testng.Assert.*;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class TimeTests extends BaseTest {
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getYear
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test01() {
+ Time t = Time.valueOf("08:30:59");
+ t.getYear();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getMonth
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test02() {
+ Time t = Time.valueOf("08:30:59");
+ t.getMonth();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getDay
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test03() {
+ Time t = Time.valueOf("08:30:59");
+ t.getDay();
+ }
+
+ /**
+ * Validate an IllegalArgumentException is thrown for calling getDate
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test04() {
+ Time t = Time.valueOf("08:30:59");
+ t.getDate();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setYear
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test05() {
+ Time t = Time.valueOf("08:30:59");
+ t.setYear(8);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setMonth
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test06() {
+ Time t = Time.valueOf("08:30:59");
+ t.setMonth(8);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setDate
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test07() {
+ Time t = Time.valueOf("08:30:59");
+ t.setDate(30);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getDate
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test08() {
+ Time t = Time.valueOf("08:30:59");
+ t.getDate();
+ }
+
+ /*
+ * Validate that a Time made from a toLocalTime() LocalTime are equal
+ */
+ @Test
+ public void test09() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = Time.valueOf(t.toLocalTime());
+ assertTrue(t.equals(t2), "Error t != t2");
+ }
+
+ /*
+ * Validate that a Time LocalTime value, made from a LocalTime are equal
+ */
+ @Test
+ public void test10() {
+ LocalTime lt = LocalTime.of(8, 30, 59);
+ Time t = Time.valueOf(lt);
+ System.out.println("lt=" + lt + ",t=" + t.toLocalTime());
+ assertTrue(lt.equals(t.toLocalTime()),
+ "Error LocalTime values are not equal");
+ }
+
+ /*
+ * Validate an NPE occurs when a null LocalDate is passed to valueOf
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test11() throws Exception {
+ LocalTime ld = null;
+ Time.valueOf(ld);
+ }
+
+ /*
+ * Validate an UnsupportedOperationException occurs when toInstant() is
+ * called
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void test12() throws Exception {
+ Time t = new Time(System.currentTimeMillis());
+ t.toInstant();
+ }
+
+ /*
+ * Validate that two Time objects are equal when one is created from the
+ * toString() of the other and that the correct value is returned from
+ * toString()
+ */
+ @Test(dataProvider = "validTimeValues")
+ public void test13(String time, String expected) {
+ Time t1 = Time.valueOf(time);
+ Time t2 = Time.valueOf(t1.toString());
+ assertTrue(t1.equals(t2) && t2.equals(t1)
+ && t1.toString().equals(expected), "Error t1 != t2");
+ }
+
+ /*
+ * Validate that two Time values one created using valueOf and another via a
+ * constructor are equal
+ */
+ @Test
+ public void test14() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(8, 30, 59);
+ assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
+ }
+
+ /*
+ * Validate that two Time values one created using valueOf and another via a
+ * constructor are equal
+ */
+ @Test
+ public void test15() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime());
+ assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid Time string
+ */
+ @Test(dataProvider = "invalidTimeValues",
+ expectedExceptions = IllegalArgumentException.class)
+ public void test16(String time) throws Exception {
+ Time.valueOf(time);
+ }
+
+ /*
+ * Validate that Time.after() returns false when same date is compared
+ */
+ @Test
+ public void test17() {
+ Time t = Time.valueOf("08:30:59");
+ assertFalse(t.after(t), "Error t.after(t) = true");
+ }
+
+ /*
+ * Validate that Time.after() returns true when later date is compared to
+ * earlier date
+ */
+ @Test
+ public void test18() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(System.currentTimeMillis());
+ assertTrue(t2.after(t), "Error t2.after(t) = false");
+ }
+
+ /*
+ * Validate that Time.after() returns false when earlier date is compared to
+ * itself
+ */
+ @Test
+ public void test19() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime());
+ assertFalse(t.after(t2), "Error t.after(t2) = true");
+ assertFalse(t2.after(t), "Error t2.after(t) = true");
+ }
+
+ /*
+ * Validate that Time.before() returns false when same date is compared
+ */
+ @Test
+ public void test20() {
+ Time t = Time.valueOf("08:30:59");
+ assertFalse(t.before(t), "Error t.before(t) = true");
+ }
+
+ /*
+ * Validate that Time.before() returns true when earlier date is compared to
+ * later date
+ */
+ @Test
+ public void test21() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(System.currentTimeMillis());
+ assertTrue(t.before(t2), "Error t.before(t2) = false");
+ }
+
+ /*
+ * Validate that Time.before() returns false when earlier date is compared
+ * to itself
+ */
+ @Test
+ public void test22() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime());
+ assertFalse(t.before(t2), "Error t.after(t2) = true");
+ assertFalse(t2.before(t), "Error t2.after(t) = true");
+ }
+
+ /*
+ * Validate that Time.compareTo returns 0 when both Date objects are the
+ * same
+ */
+ @Test
+ public void test23() {
+ Time t = Time.valueOf("08:30:59");
+ assertTrue(t.compareTo(t) == 0, "Error t.compareTo(t) !=0");
+ }
+
+ /*
+ * Validate thatTime.compareTo returns 0 when both Time objects are the same
+ */
+ @Test
+ public void test24() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime());
+ assertTrue(t.compareTo(t2) == 0, "Error t.compareTo(t2) !=0");
+ }
+
+ /*
+ * Validate that Time.compareTo returns 1 when comparing a later Time to an
+ * earlier Time
+ */
+ @Test
+ public void test25() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime() + 1);
+ assertTrue(t2.compareTo(t) == 1, "Error t2.compareTo(t) !=1");
+ }
+
+ /*
+ * Validate thatTime.compareTo returns 1 when comparing a later Time to an
+ * earlier Time
+ */
+ @Test
+ public void test26() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime() + 1);
+ assertTrue(t.compareTo(t2) == -1, "Error t.compareTo(t2) != -1");
+ }
+
+ /*
+ * DataProvider used to provide Time values which are not valid and are used
+ * to validate that an IllegalArgumentException will be thrown from the
+ * valueOf method
+ */
+ @DataProvider(name = "invalidTimeValues")
+ private Object[][] invalidTimeValues() {
+ return new Object[][]{
+ {"2009-11-01 10:50:01"},
+ {"1961-08-30 10:50:01.1"},
+ {"1961-08-30"},
+ {"00:00:00."},
+ {"10:50:0.1"},
+ {":00:00"},
+ {"00::00"},
+ {"00:00:"},
+ {"::"},
+ {" : : "},
+ {"0a:00:00"},
+ {"00:bb:00"},
+ {"00:01:cc"},
+ {"08:10:Batman"},
+ {"08:10:10:10"},
+ {"08:10"},
+ {"a:b:c"},
+ {null},
+ {"8:"}
+ };
+ }
+
+ /*
+ * DataProvider used to provide Time values which are valid and are used
+ * to validate that an IllegalArgumentException will not be thrown from the
+ * valueOf method. It also contains the expected return value from
+ * toString()
+ */
+ @DataProvider(name = "validTimeValues")
+ private Object[][] validTimeValues() {
+ return new Object[][]{
+ {"10:50:01", "10:50:01"},
+ {"01:1:1", "01:01:01"},
+ {"01:01:1", "01:01:01"},
+ {"1:01:1", "01:01:01"},
+ {"2:02:02", "02:02:02"},
+ {"2:02:2", "02:02:02"},
+ {"10:50:1", "10:50:01"},
+ {"00:00:00", "00:00:00"},
+ {"08:30:59", "08:30:59"},
+ {"9:0:1", "09:00:01"}
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/TimestampTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,777 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Calendar;
+import java.util.TimeZone;
+import static org.testng.Assert.*;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class TimestampTests extends BaseTest {
+
+ private static TimeZone defaultTimeZone = null;
+
+ /*
+ * Need to set and use a custom TimeZone which does not
+ * observe daylight savings time for this test.
+ */
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ defaultTimeZone = TimeZone.getDefault();
+ TimeZone tzone = TimeZone.getTimeZone("GMT+01");
+ assertFalse(tzone.observesDaylightTime());
+ TimeZone.setDefault(tzone);
+ }
+
+ /*
+ * Conservatively reset the default time zone after test.
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ TimeZone.setDefault(defaultTimeZone);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid Timestamp
+ */
+ @Test(dataProvider = "invalidTimestampValues",
+ expectedExceptions = IllegalArgumentException.class)
+ public void test(String ts) throws Exception {
+ Timestamp.valueOf(ts);
+ }
+
+ /*
+ * Validate that two Timestamp are equal when the leading 0 in seconds is
+ * omitted
+ */
+ @Test
+ public void test01() throws Exception {
+ String testTS = "2009-01-01 10:50:00";
+ String ExpectedTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate two Timestamps created from the same string are equal
+ */
+ @Test
+ public void test02() throws Exception {
+ String testTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(testTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one with leading 0s for month and day
+ * equals same string without the leading 0s.
+ */
+ @Test
+ public void test03() throws Exception {
+ String testTS = "2009-1-1 10:50:0";
+ String ExpectedTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one with leading 0s for day omitted
+ * are equal
+ */
+ @Test
+ public void test04() throws Exception {
+ String testTS = "2009-01-1 10:50:0";
+ String ExpectedTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one with leading 0s for month omitted
+ * and both with leading 0s for seconds omitted are equal
+ */
+ @Test
+ public void test05() throws Exception {
+ String testTS = "2009-1-01 10:50:0";
+ String ExpectedTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one with leading 0s for month omitted
+ */
+ @Test
+ public void test06() throws Exception {
+ String testTS = "2005-1-01 10:20:50.00";
+ String ExpectedTS = "2005-01-01 10:20:50.00";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one created using valueOf and another
+ * via a constructor are equal
+ */
+ @Test
+ public void test07() {
+
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.001");
+ Timestamp ts2 = new Timestamp(96, 11, 13, 14, 15, 25, 1000000);
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one created using valueOf and another
+ * via a constructor are equal
+ */
+ @Test
+ public void test08() {
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.001");
+ Timestamp ts2 = new Timestamp(ts1.getTime());
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one created using valueOf and another
+ * via a constructor are equal
+ */
+ @Test
+ public void test09() {
+
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.0");
+ Timestamp ts2 = new Timestamp(96, 11, 13, 14, 15, 25, 0);
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that a Timestamp cannot be equal to null
+ */
+ @Test
+ public void test10() {
+
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 14:15:25.745634");
+ Timestamp ts2 = null;
+ assertFalse(ts1.equals(ts2), "Error ts1 == null");
+ }
+
+ /*
+ * Validate that a Timestamp is equal to another timestamp created with the
+ * using the same value but not equal to a Timestamp which is one day later
+ */
+ @Test
+ public void test11() {
+
+ Timestamp ts1 = Timestamp.valueOf("1996-12-10 12:26:19.12");
+ Timestamp ts2 = Timestamp.valueOf("1996-12-10 12:26:19.12");
+ Timestamp ts3 = Timestamp.valueOf("1996-12-11 12:24:19.12");
+ assertTrue(ts1.equals(ts2) && ts2.equals(ts1), "Error ts1 != ts2");
+ assertFalse(ts1.equals(ts3) && ts3.equals(ts1), "Error ts1 == ts3");
+
+ }
+
+ /*
+ * Validate that a Timestamp is equal to itself
+ */
+ @Test
+ public void test12() {
+ Timestamp ts1 = Timestamp.valueOf("1996-10-15 12:26:19.12");
+ assertTrue(ts1.equals(ts1), "Error ts1 != ts1");
+ }
+
+ /*
+ * Validate that two Timestamps are equal when one is created from the
+ * toString() of the other
+ */
+ @Test(dataProvider = "validTimestampValues")
+ public void test13(String ts, String expectedTS) {
+ Timestamp ts1 = Timestamp.valueOf(ts);
+ Timestamp ts2 = Timestamp.valueOf(ts1.toString());
+ assertTrue(ts1.equals(ts2) && ts2.equals(ts1)
+ && ts1.toString().equals(expectedTS), "Error ts1 != ts2");
+ }
+
+ // Before Tests
+ /*
+ * Validate that Timestamp ts1 is before Timestamp ts2
+ */
+ @Test
+ public void test14() {
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
+ Timestamp ts2 = Timestamp.valueOf("1996-12-13 15:15:25.645634");
+ assertTrue(ts1.before(ts2), "Error ts1 not before ts2");
+ }
+
+ /*
+ * Validate that Timestamp ts1 is before Timestamp ts2
+ */
+ @Test
+ public void test15() {
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 14:15:25");
+ Timestamp ts2 = Timestamp.valueOf("1999-12-13 15:15:25");
+ assertTrue(ts1.before(ts2), "Error ts1 not before ts2");
+ }
+
+ /*
+ * Validate that Timestamp ts1 is before Timestamp ts2
+ */
+ @Test
+ public void test16() {
+
+ Timestamp ts1 = Timestamp.valueOf("1999-12-13 14:15:25.745634");
+ Timestamp ts2 = Timestamp.valueOf("1999-11-13 15:15:25.645634");
+ assertFalse(ts1.before(ts2), "Error ts1 before ts2");
+ }
+
+ /*
+ * Validate that a NullPointerException is thrown if a null is passed to
+ * the before method
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test17() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
+ ts1.before(null);
+ }
+
+ /*
+ * Validate a Timestamp cannot be before itself
+ */
+ @Test
+ public void test18() {
+ Timestamp ts1 = Timestamp.valueOf("1999-11-10 12:26:19.3456543");
+ assertFalse(ts1.before(ts1), "Error ts1 before ts1!");
+ }
+
+ /*
+ * Create 3 Timestamps and make sure the 1st is before the other two
+ * Timestamps which are each greater than the one before it
+ */
+ @Test
+ public void test19() {
+
+ Timestamp ts1 = new Timestamp(1234560000);
+ Timestamp ts2 = new Timestamp(1234567000);
+ Timestamp ts3 = new Timestamp(1234569000);
+ assertTrue(ts1.before(ts2) && ts2.before(ts3) && ts1.before(ts3));
+ }
+
+ /*
+ * Validate that Timestamp ts1 is not after Timestamp ts2
+ */
+ @Test
+ public void test20() {
+ Timestamp ts1 = Timestamp.valueOf("1999-12-13 14:15:25.745634");
+ Timestamp ts2 = Timestamp.valueOf("1999-12-13 15:15:25.645634");
+ assertFalse(ts1.after(ts2), "Error ts1 is after ts2");
+
+ }
+
+ /*
+ * Validate that Timestamp ts1 is after Timestamp ts2
+ */
+ @Test
+ public void test21() {
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
+ Timestamp ts2 = Timestamp.valueOf("1996-11-13 15:15:25.645634");
+ assertTrue(ts1.after(ts2), "Error ts1 not after ts2");
+ }
+
+ /*
+ * Validate that a NullPointerException is thrown if a null is passed to the
+ * after method
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test22() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ ts1.after(null);
+ }
+
+ /*
+ * Validate that a Timestamp cannot be after itself
+ */
+ @Test
+ public void test23() {
+ Timestamp ts1 = Timestamp.valueOf("1999-11-10 12:26:19.3456543");
+ assertFalse(ts1.after(ts1), "Error ts1 is after itself");
+ }
+
+ /*
+ * Validate that a Timestamp after() works correctly with Timestamp created
+ * using milliseconds
+ */
+ @Test
+ public void test24() {
+
+ Timestamp ts1 = new Timestamp(1234568000);
+ Timestamp ts2 = new Timestamp(1234565000);
+ Timestamp ts3 = new Timestamp(1234562000);
+ assertTrue(ts1.after(ts2) && ts2.after(ts3) && ts1.after(ts3));
+ }
+
+ /*
+ * Validate compareTo returns 0 for Timestamps that are the same
+ */
+ @Test
+ public void test25() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = new Timestamp(ts1.getTime());
+ assertTrue(ts1.compareTo(ts2) == 0, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate compareTo returns -1 for when the 1st Timestamp is earlier than
+ * the 2nd Timestamp
+ */
+ @Test
+ public void test26() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = new Timestamp(ts1.getTime() + 1000);
+ assertTrue(ts1.compareTo(ts2) == -1, "Error ts1 not before ts2");
+ assertTrue(ts2.compareTo(ts1) == 1, "Error ts1 is not before ts2");
+ }
+
+ /*
+ * Validate compareTo returns 1 for when the 1st Timestamp is later than the
+ * 2nd Timestamp
+ */
+ @Test
+ public void test27() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = new Timestamp(ts1.getTime() - 1000);
+ assertTrue(ts1.compareTo(ts2) == 1, "Error ts1 not after ts2");
+ assertTrue(ts2.compareTo(ts1) == -1, "Error ts1 not after ts2");
+ }
+
+ /*
+ * Validate compareTo returns 0 for Timestamps that are the same
+ */
+ @Test
+ public void test28() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ java.util.Date ts2 = new java.util.Date(ts1.getTime());
+ assertTrue(ts1.compareTo(ts2) == 0, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate compareTo returns 0 for Timestamps that are the same
+ */
+ @Test
+ public void test29() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ java.util.Date d = new java.util.Date(ts1.getTime());
+ assertFalse(ts1.equals(d), "Error ts1 == d");
+ }
+
+ /*
+ * Validate compareTo returns 0 for Timestamps that are the same
+ */
+ @Test
+ public void test30() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ java.util.Date d = new Timestamp(ts1.getTime());
+ assertTrue(ts1.equals(d), "Error ts1 != d");
+ }
+
+ /*
+ * Validate equals returns false when a Date object is passed to equals
+ */
+ @Test
+ public void test31() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Date d = new Date(ts1.getTime());
+ assertFalse(ts1.equals(d), "Error ts1 != d");
+ }
+
+ /*
+ * Validate equals returns false when a Date object is passed to equals
+ */
+ @Test
+ public void test32() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ java.util.Date d = new Date(ts1.getTime());
+ assertFalse(ts1.equals(d), "Error ts1 != d");
+ }
+
+ /*
+ * Validate equals returns false when a Time object is passed to equals
+ */
+ @Test
+ public void test33() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Time t1 = new Time(ts1.getTime());
+ assertFalse(ts1.equals(t1), "Error ts1 == t1");
+ }
+
+ /*
+ * Validate equals returns false when a String object is passed to equals
+ */
+ @Test
+ public void test34() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ assertFalse(ts1.equals("1966-08-30 08:08:08"), "Error ts1 == a String");
+ }
+
+ /*
+ * Validate getTime() returns the same value from 2 timeStamps created by
+ */
+ @Test
+ public void test35() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = Timestamp.valueOf("1966-08-30 08:08:08");
+ assertTrue(ts2.getTime() == ts1.getTime(),
+ "ts1.getTime() != ts2.getTime()");
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate getTime() returns the same value from 2 timeStamps when
+ * setTime() is used to specify the same value for both Timestamps
+ */
+ @Test
+ public void test36() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts2.setTime(ts1.getTime());
+ assertTrue(ts2.getTime() == ts1.getTime(),
+ "ts1.getTime() != ts2.getTime()");
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid nanos value
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test38() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts1.setNanos(-1);
+
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid nanos value
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test39() throws Exception {
+ int nanos = 999999999;
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts1.setNanos(nanos + 1);
+ }
+
+ /*
+ * Validate you can set nanos to 999999999
+ */
+ @Test
+ public void test40() throws Exception {
+ int nanos = 999999999;
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts1.setNanos(nanos);
+ assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
+ }
+
+ /*
+ * Validate you can set nanos to 0
+ */
+ @Test
+ public void test41() throws Exception {
+ int nanos = 0;
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts1.setNanos(nanos);
+ assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
+ }
+
+ /*
+ * Validate that a Timestamp made from a LocalDateTime are equal
+ */
+ @Test
+ public void test42() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ LocalDateTime ldt = ts1.toLocalDateTime();
+ Timestamp ts2 = Timestamp.valueOf(ldt);
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that a Timestamp LocalDateTime value, made from a LocalDateTime
+ * are equal
+ */
+ @Test
+ public void test43() throws Exception {
+ LocalDateTime ldt = LocalDateTime.now();
+ Timestamp ts2 = Timestamp.valueOf(ldt);
+ assertTrue(ldt.equals(ts2.toLocalDateTime()),
+ "Error LocalDateTime values are not equal");
+ }
+
+ /*
+ * Validate an NPE occurs when a null LocalDateTime is passed to valueOF
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test44() throws Exception {
+ LocalDateTime ldt = null;
+ Timestamp.valueOf(ldt);
+ }
+
+ /*
+ * Validate that a Timestamp made from a Instant are equal
+ */
+ @Test
+ public void test45() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ Instant instant = ts1.toInstant();
+ Timestamp ts2 = Timestamp.from(instant);
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that a Timestamp made from a Instant are equal
+ */
+ @Test
+ public void test46() throws Exception {
+ Instant instant = Instant.now();
+ Timestamp ts2 = Timestamp.from(instant);
+ assertTrue(instant.equals(ts2.toInstant()),
+ "Error Instant values do not match");
+ }
+
+ /*
+ * Validate an NPE occurs when a null instant is passed to from
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test47() throws Exception {
+ Instant instant = null;
+ Timestamp.from(instant);
+ }
+
+ // Added SQE tests
+ /*
+ * Create a Timestamp and a 2nd Timestamp that is 1 month earlier and
+ * validate that it is not before or after the original Timestamp
+ */
+ @Test
+ public void test48() {
+ Calendar cal = Calendar.getInstance();
+ Timestamp ts1 = new Timestamp(System.currentTimeMillis());
+ cal.setTimeInMillis(ts1.getTime());
+ cal.add(Calendar.MONTH, -1);
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
+ assertFalse(ts1.before(ts2) || ts2.after(ts1));
+ }
+
+ /*
+ * Create two Timestamps and validate that compareTo returns 1 to indicate
+ * the 1st Timestamp is greater than the 2nd Timestamp
+ */
+ @Test
+ public void test49() {
+ Calendar cal = Calendar.getInstance();
+ Timestamp ts1 = new Timestamp(System.currentTimeMillis());
+ cal.setTimeInMillis(ts1.getTime());
+ cal.add(Calendar.MONTH, -1);
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
+ assertTrue(ts1.compareTo(ts2) == 1);
+ }
+
+ /*
+ * Create two Timestamps and validate that the 1st Timestamp is not equal to
+ * the 2nd Timestamp but equal to itself
+ */
+ @Test
+ public void test50() {
+ Calendar cal = Calendar.getInstance();
+ Timestamp ts1 = new Timestamp(System.currentTimeMillis());
+ cal.setTimeInMillis(ts1.getTime());
+ cal.add(Calendar.MONTH, -1);
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
+ assertTrue(!ts1.equals(ts2) && ts1.equals(ts1));
+ }
+
+ /*
+ * Validate that two Timestamps are equal when one is created from the
+ * toString() of the other
+ */
+ @Test(dataProvider = "validateNanos")
+ public void test51(String ts, int nanos) {
+ Timestamp ts1 = Timestamp.valueOf(ts);
+ Timestamp ts2 = Timestamp.valueOf(ts1.toString());
+ assertTrue(ts1.getNanos() == nanos && ts1.equals(ts2),
+ "Error with Nanos");
+ }
+
+ @Test(dataProvider = "validTimestampLongValues")
+ public void test52(long value, String ts) {
+ Timestamp ts1 = new Timestamp(value);
+ assertEquals(ts1.toString(), ts, "ts1.toString() != ts");
+ }
+
+ /*
+ * DataProvider used to provide Timestamps which are not valid and are used
+ * to validate that an IllegalArgumentException will be thrown from the
+ * valueOf method
+ */
+ @DataProvider(name = "invalidTimestampValues")
+ private Object[][] invalidTimestampValues() {
+ return new Object[][]{
+ {"2009-11-01-01 10:50:01"},
+ {"aaaa-11-01-01 10:50"},
+ {"aaaa-11-01 10:50"},
+ {"1961--30 00:00:00"},
+ {"--30 00:00:00"},
+ {"-- 00:00:00"},
+ {"1961-1- 00:00:00"},
+ {"2009-11-01"},
+ {"10:50:01"},
+ {"1961-a-30 00:00:00"},
+ {"1961-01-bb 00:00:00"},
+ {"1961-08-30 00:00:00."},
+ {"1961-08-30 :00:00"},
+ {"1961-08-30 00::00"},
+ {"1961-08-30 00:00:"},
+ {"1961-08-30 ::"},
+ {"1961-08-30 0a:00:00"},
+ {"1961-08-30 00:bb:00"},
+ {"1961-08-30 00:01:cc"},
+ {"1961-08-30 00:00:00.01a"},
+ {"1961-08-30 00:00:00.a"},
+ {"1996-12-10 12:26:19.1234567890"},
+ {null}
+ };
+ }
+
+ /*
+ * DataProvider used to provide Timestamps which are valid and are used
+ * to validate that an IllegalArgumentException will not be thrown from the
+ * valueOf method and the corect value from toString() is returned
+ */
+ @DataProvider(name = "validTimestampValues")
+ private Object[][] validTimestampValues() {
+ return new Object[][]{
+ {"1961-08-30 00:00:00", "1961-08-30 00:00:00.0"},
+ {"1961-08-30 11:22:33", "1961-08-30 11:22:33.0"},
+ {"1961-8-30 00:00:00", "1961-08-30 00:00:00.0"},
+ {"1966-08-1 00:00:00", "1966-08-01 00:00:00.0"},
+ {"1996-12-10 12:26:19.1", "1996-12-10 12:26:19.1"},
+ {"1996-12-10 12:26:19.12", "1996-12-10 12:26:19.12"},
+ {"1996-12-10 12:26:19.123", "1996-12-10 12:26:19.123"},
+ {"1996-12-10 12:26:19.1234", "1996-12-10 12:26:19.1234"},
+ {"1996-12-10 12:26:19.12345", "1996-12-10 12:26:19.12345"},
+ {"1996-12-10 12:26:19.123456", "1996-12-10 12:26:19.123456"},
+ {"1996-12-10 12:26:19.1234567", "1996-12-10 12:26:19.1234567"},
+ {"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
+ {"1996-12-10 12:26:19.123456789", "1996-12-10 12:26:19.123456789"},
+ {"1996-12-10 12:26:19.000000001", "1996-12-10 12:26:19.000000001"},
+ {"1996-12-10 12:26:19.000000012", "1996-12-10 12:26:19.000000012"},
+ {"1996-12-10 12:26:19.000000123", "1996-12-10 12:26:19.000000123"},
+ {"1996-12-10 12:26:19.000001234", "1996-12-10 12:26:19.000001234"},
+ {"1996-12-10 12:26:19.000012345", "1996-12-10 12:26:19.000012345"},
+ {"1996-12-10 12:26:19.000123456", "1996-12-10 12:26:19.000123456"},
+ {"1996-12-10 12:26:19.001234567", "1996-12-10 12:26:19.001234567"},
+ {"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
+ {"1996-12-10 12:26:19.0", "1996-12-10 12:26:19.0"},
+ {"1996-12-10 12:26:19.01230", "1996-12-10 12:26:19.0123"}
+ };
+ }
+
+ @DataProvider(name = "validTimestampLongValues")
+ private Object[][] validTimestampLongValues() {
+ return new Object[][]{
+ {1L, "1970-01-01 01:00:00.001"},
+ {-3600*1000L - 1, "1969-12-31 23:59:59.999"},
+ {-(20000L*365*24*60*60*1000), "18018-08-28 01:00:00.0"},
+ {Timestamp.valueOf("1961-08-30 11:22:33").getTime(), "1961-08-30 11:22:33.0"},
+ {Timestamp.valueOf("1961-08-30 11:22:33.54321000").getTime(), "1961-08-30 11:22:33.543"}, // nanoprecision lost
+ {new Timestamp(114, 10, 10, 10, 10, 10, 100000000).getTime(), "2014-11-10 10:10:10.1"},
+ {new Timestamp(0, 10, 10, 10, 10, 10, 100000).getTime(), "1900-11-10 10:10:10.0"}, // nanoprecision lost
+ {new Date(114, 10, 10).getTime(), "2014-11-10 00:00:00.0"},
+ {new Date(0, 10, 10).getTime(), "1900-11-10 00:00:00.0"},
+ {LocalDateTime.of(1960, 10, 10, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
+ .toInstant().toEpochMilli(), "1960-10-10 19:10:10.0"},
+
+ // millisecond timestamps wraps around at year 1, so Long.MIN_VALUE looks similar
+ // Long.MAX_VALUE, while actually representing 292278994 BCE
+ {Long.MIN_VALUE, "292278994-08-17 08:12:55.192"},
+ {Long.MAX_VALUE + 1, "292278994-08-17 08:12:55.192"},
+ {Long.MAX_VALUE, "292278994-08-17 08:12:55.807"},
+ {Long.MIN_VALUE - 1, "292278994-08-17 08:12:55.807"},
+
+ // wrap around point near 0001-01-01, test that we never get a negative year:
+ {-(1970L*365*24*60*60*1000), "0001-04-25 01:00:00.0"},
+ {-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L), "0001-12-31 01:00:00.0"},
+ {-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L - 23*60*60*1000L), "0001-01-01 00:00:00.0"},
+
+ {LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
+ .toInstant().toEpochMilli() - 2*24*60*60*1000L, "0001-01-01 19:03:08.0"}, // 1 BCE
+ {LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
+ .toInstant().toEpochMilli() - 3*24*60*60*1000L, "0002-12-31 19:03:08.0"} // 2 BCE
+ };
+ }
+
+ /*
+ * DataProvider used to provide Timestamp and Nanos values in order to
+ * validate that the correct Nanos value is generated from the specified
+ * Timestamp
+ */
+ @DataProvider(name = "validateNanos")
+ private Object[][] validateNanos() {
+ return new Object[][]{
+ {"1961-08-30 00:00:00", 0},
+ {"1996-12-10 12:26:19.1", 100000000},
+ {"1996-12-10 12:26:19.12", 120000000},
+ {"1996-12-10 12:26:19.123", 123000000},
+ {"1996-12-10 12:26:19.1234", 123400000},
+ {"1996-12-10 12:26:19.12345", 123450000},
+ {"1996-12-10 12:26:19.123456", 123456000},
+ {"1996-12-10 12:26:19.1234567", 123456700},
+ {"1996-12-10 12:26:19.12345678", 123456780},
+ {"1996-12-10 12:26:19.123456789", 123456789},
+ {"1996-12-10 12:26:19.000000001", 1},
+ {"1996-12-10 12:26:19.000000012", 12},
+ {"1996-12-10 12:26:19.000000123", 123},
+ {"1996-12-10 12:26:19.000001234", 1234},
+ {"1996-12-10 12:26:19.000012345", 12345},
+ {"1996-12-10 12:26:19.000123456", 123456},
+ {"1996-12-10 12:26:19.001234567", 1234567},
+ {"1996-12-10 12:26:19.012345678", 12345678},
+ {"1996-12-10 12:26:19.0", 0},
+ {"1996-12-10 12:26:19.01230", 12300000}
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/BaseTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.security.Policy;
+import java.sql.JDBCType;
+import java.sql.SQLException;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+
+public class BaseTest {
+
+ protected final String reason = "reason";
+ protected final String state = "SQLState";
+ protected final String cause = "java.lang.Throwable: cause";
+ protected final Throwable t = new Throwable("cause");
+ protected final Throwable t1 = new Throwable("cause 1");
+ protected final Throwable t2 = new Throwable("cause 2");
+ protected final int errorCode = 21;
+ protected final String[] msgs = {"Exception 1", "cause 1", "Exception 2",
+ "Exception 3", "cause 2"};
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @BeforeMethod
+ public void setUpMethod() throws Exception {
+ }
+
+ @AfterMethod
+ public void tearDownMethod() throws Exception {
+ }
+
+ /*
+ * Take some form of SQLException, serialize and deserialize it
+ */
+ @SuppressWarnings("unchecked")
+ protected <T extends SQLException> T
+ createSerializedException(T ex)
+ throws IOException, ClassNotFoundException {
+ return (T) serializeDeserializeObject(ex);
+ }
+
+ /*
+ * Utility method to serialize and deserialize an object
+ */
+ @SuppressWarnings("unchecked")
+ protected <T> T serializeDeserializeObject(T o)
+ throws IOException, ClassNotFoundException {
+ T o1;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+ oos.writeObject(o);
+ }
+ try (ObjectInputStream ois
+ = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
+ o1 = (T) ois.readObject();
+ }
+ return o1;
+ }
+
+ /*
+ * Utility Method used to set the current Policy
+ */
+ protected static void setPolicy(Policy p) {
+ Policy.setPolicy(p);
+ }
+
+ /*
+ * DataProvider used to specify the value to set and check for
+ * methods using boolean values
+ */
+ @DataProvider(name = "trueFalse")
+ protected Object[][] trueFalse() {
+ return new Object[][]{
+ {true},
+ {false}
+ };
+ }
+
+ /*
+ * DataProvider used to specify the standard JDBC Types
+ */
+ @DataProvider(name = "jdbcTypes")
+ protected Object[][] jdbcTypes() {
+ Object[][] o = new Object[JDBCType.values().length][1];
+ int pos = 0;
+ for (JDBCType c : JDBCType.values()) {
+ o[pos++][0] = c.getVendorTypeNumber();
+ }
+ return o;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/DriverActionImpl.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.sql.DriverAction;
+
+/**
+ * Simple implementation of DriverAction which calls back into the Driver when
+ * release is called.
+ */
+class DriverActionImpl implements DriverAction {
+
+ public DriverActionImpl(StubDriverDA d) {
+ driver = d;
+ }
+
+ private final StubDriverDA driver;
+
+ @Override
+ public void deregister() {
+ driver.release();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/SerializedBatchUpdateException.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+public class SerializedBatchUpdateException {
+ /**
+ * Serialized BatchUpdateException from JDBC 4.0 with the following values
+ * reason = "This was the error msg"
+ * SQLState = "user defined sqlState"
+ * vendor Code = 99999
+ * Update Counts = {1, 2, 21}
+ * cause = = "java.lang.Throwable: throw 1"
+ */
+ public static byte[] DATA = {
+ (byte) 0xac, (byte) 0xed, (byte) 0x0, (byte) 0x5, (byte) 0x73, (byte) 0x72, (byte) 0x0, (byte) 0x1d, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x2e, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x55, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65,
+ (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x52, (byte) 0xf4, (byte) 0x73, (byte) 0xc0, (byte) 0xc1, (byte) 0x8b, (byte) 0xe, (byte) 0x5d, (byte) 0x3, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x0, (byte) 0x10, (byte) 0x6c, (byte) 0x6f, (byte) 0x6e, (byte) 0x67, (byte) 0x55, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x6f, (byte) 0x75,
+ (byte) 0x6e, (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x4a, (byte) 0x5b, (byte) 0x0, (byte) 0xc, (byte) 0x75, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x6f, (byte) 0x75, (byte) 0x6e, (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x49, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x15,
+ (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x2e, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x1d, (byte) 0xa1, (byte) 0xe9, (byte) 0x30, (byte) 0xdb, (byte) 0x3e, (byte) 0x75, (byte) 0xdc, (byte) 0x2, (byte) 0x0, (byte) 0x3,
+ (byte) 0x49, (byte) 0x0, (byte) 0xa, (byte) 0x76, (byte) 0x65, (byte) 0x6e, (byte) 0x64, (byte) 0x6f, (byte) 0x72, (byte) 0x43, (byte) 0x6f, (byte) 0x64, (byte) 0x65, (byte) 0x4c, (byte) 0x0, (byte) 0x8, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x12, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
+ (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0x4, (byte) 0x6e, (byte) 0x65, (byte) 0x78, (byte) 0x74, (byte) 0x74, (byte) 0x0, (byte) 0x17, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x73, (byte) 0x71, (byte) 0x6c,
+ (byte) 0x2f, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x3b, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x13, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65,
+ (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0xd0, (byte) 0xfd, (byte) 0x1f, (byte) 0x3e, (byte) 0x1a, (byte) 0x3b, (byte) 0x1c, (byte) 0xc4, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x13, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x54, (byte) 0x68,
+ (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0xd5, (byte) 0xc6, (byte) 0x35, (byte) 0x27, (byte) 0x39, (byte) 0x77, (byte) 0xb8, (byte) 0xcb, (byte) 0x3, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0x5, (byte) 0x63, (byte) 0x61, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x15, (byte) 0x4c, (byte) 0x6a, (byte) 0x61,
+ (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x54, (byte) 0x68, (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0xd, (byte) 0x64, (byte) 0x65, (byte) 0x74, (byte) 0x61, (byte) 0x69, (byte) 0x6c, (byte) 0x4d, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x61,
+ (byte) 0x67, (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x5b, (byte) 0x0, (byte) 0xa, (byte) 0x73, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x1e, (byte) 0x5b, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c, (byte) 0x61,
+ (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0x14, (byte) 0x73, (byte) 0x75, (byte) 0x70, (byte) 0x70, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,
+ (byte) 0x65, (byte) 0x64, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x10, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x75, (byte) 0x74, (byte) 0x69, (byte) 0x6c, (byte) 0x2f, (byte) 0x4c, (byte) 0x69, (byte) 0x73, (byte) 0x74, (byte) 0x3b, (byte) 0x78,
+ (byte) 0x70, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x7, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0xc, (byte) 0x74, (byte) 0x0, (byte) 0x7, (byte) 0x74, (byte) 0x68, (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x20, (byte) 0x31, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x1e, (byte) 0x5b, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
+ (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x3b, (byte) 0x2, (byte) 0x46, (byte) 0x2a, (byte) 0x3c, (byte) 0x3c, (byte) 0xfd, (byte) 0x22, (byte) 0x39,
+ (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x73, (byte) 0x72, (byte) 0x0, (byte) 0x1b, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63,
+ (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x61, (byte) 0x9, (byte) 0xc5, (byte) 0x9a, (byte) 0x26, (byte) 0x36, (byte) 0xdd, (byte) 0x85, (byte) 0x2, (byte) 0x0, (byte) 0x4, (byte) 0x49, (byte) 0x0, (byte) 0xa, (byte) 0x6c, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x4e, (byte) 0x75, (byte) 0x6d, (byte) 0x62, (byte) 0x65, (byte) 0x72,
+ (byte) 0x4c, (byte) 0x0, (byte) 0xe, (byte) 0x64, (byte) 0x65, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x43, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0x8, (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x4e, (byte) 0x61, (byte) 0x6d,
+ (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0xa, (byte) 0x6d, (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6f, (byte) 0x64, (byte) 0x4e, (byte) 0x61, (byte) 0x6d, (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x23, (byte) 0x74, (byte) 0x0,
+ (byte) 0x17, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x74, (byte) 0x0, (byte) 0x1c, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x74,
+ (byte) 0x65, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x2e, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x74, (byte) 0x0, (byte) 0x9, (byte) 0x77, (byte) 0x72, (byte) 0x69, (byte) 0x74, (byte) 0x65, (byte) 0x54,
+ (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1a, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x74, (byte) 0x0, (byte) 0x4, (byte) 0x6d, (byte) 0x61, (byte) 0x69, (byte) 0x6e, (byte) 0x70, (byte) 0x78,
+ (byte) 0x74, (byte) 0x0, (byte) 0x16, (byte) 0x54, (byte) 0x68, (byte) 0x69, (byte) 0x73, (byte) 0x20, (byte) 0x77, (byte) 0x61, (byte) 0x73, (byte) 0x20, (byte) 0x74, (byte) 0x68, (byte) 0x65, (byte) 0x20, (byte) 0x65, (byte) 0x72, (byte) 0x72, (byte) 0x6f, (byte) 0x72, (byte) 0x20, (byte) 0x6d, (byte) 0x73, (byte) 0x67, (byte) 0x75, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0xe, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x28, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x14, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e,
+ (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1a, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x16, (byte) 0x70, (byte) 0x78, (byte) 0x0, (byte) 0x1, (byte) 0x86, (byte) 0x9f, (byte) 0x74, (byte) 0x0, (byte) 0x15, (byte) 0x75, (byte) 0x73,
+ (byte) 0x65, (byte) 0x72, (byte) 0x20, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x70, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x4a, (byte) 0x78, (byte) 0x20, (byte) 0x4, (byte) 0xb5, (byte) 0x12, (byte) 0xb1,
+ (byte) 0x75, (byte) 0x93, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x49, (byte) 0x4d, (byte) 0xba, (byte) 0x60, (byte) 0x26, (byte) 0x76, (byte) 0xea, (byte) 0xb2, (byte) 0xa5, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x78
+ };
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/StubConnection.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+
+public class StubConnection implements Connection {
+
+ @Override
+ public Statement createStatement() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String nativeSQL(String sql) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setAutoCommit(boolean autoCommit) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean getAutoCommit() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void commit() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void rollback() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void close() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public DatabaseMetaData getMetaData() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isReadOnly() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setCatalog(String catalog) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getCatalog() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTransactionIsolation(int level) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getTransactionIsolation() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Map<String, Class<?>> getTypeMap() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setHoldability(int holdability) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getHoldability() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Savepoint setSavepoint() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Savepoint setSavepoint(String name) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void rollback(Savepoint savepoint) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Clob createClob() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Blob createBlob() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public NClob createNClob() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLXML createSQLXML() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isValid(int timeout) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClientInfo(String name, String value) throws SQLClientInfoException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClientInfo(Properties properties) throws SQLClientInfoException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getClientInfo(String name) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Properties getClientInfo() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setSchema(String schema) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getSchema() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void abort(Executor executor) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getNetworkTimeout() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/StubDriver.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+public class StubDriver implements Driver {
+
+ public StubDriver() {
+ }
+
+ @Override
+ public Connection connect(String url, Properties info) throws SQLException {
+ if (acceptsURL(url)) {
+ return new StubConnection();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean acceptsURL(String url) throws SQLException {
+ return url.matches("^jdbc:tennis:.*");
+ }
+
+ @Override
+ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getMajorVersion() {
+ return 1;
+ }
+
+ @Override
+ public int getMinorVersion() {
+ return 0;
+ }
+
+ @Override
+ public boolean jdbcCompliant() {
+ return true;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/StubDriverDA.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.DriverAction;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Simple java.sql.Driver stub class that registers the driver via a static
+ * block with a DriverAction Implementation
+ * @author ljanders
+ */
+public class StubDriverDA extends StubDriver {
+
+ public static final String DriverActionCalled = "DriverActionCalled.txt";
+
+ static DriverAction da;
+
+ static {
+ try {
+ DriverManager.registerDriver(new StubDriverDA(), da);
+ } catch (SQLException ex) {
+ Logger.getLogger(StubDriverDA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ public StubDriverDA() {
+ da = new DriverActionImpl(this);
+ }
+
+ @Override
+ public boolean acceptsURL(String url) throws SQLException {
+ return url.matches("^jdbc:luckydog:.*");
+ }
+
+ /**
+ * This method will write out a text file when called by the
+ * DriverActionImpl.release method when DriverManager.deregisterDriver
+ * is called. This is used by DriverManagerTests to validate that
+ * DriverAction.release was called
+ */
+ protected void release() {
+ File file = new File(DriverActionCalled);
+ try {
+ file.createNewFile();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/TestPolicy.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.FilePermission;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.security.SecurityPermission;
+import java.sql.SQLPermission;
+import java.util.Enumeration;
+import java.util.PropertyPermission;
+import java.util.StringJoiner;
+import java.util.logging.LoggingPermission;
+
+/*
+ * Simple Policy class that supports the required Permissions to validate the
+ * JDBC concrete classes
+ */
+public class TestPolicy extends Policy {
+
+ final PermissionCollection permissions = new Permissions();
+
+ /**
+ * Constructor which sets the minimum permissions allowing testNG to work
+ * with a SecurityManager
+ */
+ public TestPolicy() {
+ setMinimalPermissions();
+ }
+
+ /*
+ * Constructor which determines which permissions are defined for this
+ * Policy used by the JDBC tests Possible values are: all (ALLPermissions),
+ * setLog (SQLPemission("setLog"), deregisterDriver
+ * (SQLPermission("deregisterDriver") (SQLPermission("deregisterDriver"),
+ * setSyncFactory(SQLPermission(setSyncFactory), and also
+ * LoggerPermission("control", null) when setting a Level
+ *
+ * @param policy Permissions to set
+ */
+ public TestPolicy(String policy) {
+
+ switch (policy) {
+ case "all":
+ permissions.add(new AllPermission());
+ break;
+ case "setLog":
+ setMinimalPermissions();
+ permissions.add(new SQLPermission("setLog"));
+ break;
+ case "deregisterDriver":
+ setMinimalPermissions();
+ permissions.add(new SQLPermission("deregisterDriver"));
+ break;
+ case "setSyncFactory":
+ setMinimalPermissions();
+ permissions.add(new SQLPermission("setSyncFactory"));
+ break;
+ case "setSyncFactoryLogger":
+ setMinimalPermissions();
+ permissions.add(new SQLPermission("setSyncFactory"));
+ permissions.add(new LoggingPermission("control", null));
+ break;
+ default:
+ setMinimalPermissions();
+ }
+ }
+
+ /*
+ * Defines the minimal permissions required by testNG when running these
+ * tests
+ */
+ private void setMinimalPermissions() {
+ permissions.add(new SecurityPermission("getPolicy"));
+ permissions.add(new SecurityPermission("setPolicy"));
+ permissions.add(new RuntimePermission("getClassLoader"));
+ permissions.add(new RuntimePermission("setSecurityManager"));
+ permissions.add(new RuntimePermission("createSecurityManager"));
+ permissions.add(new PropertyPermission("testng.show.stack.frames",
+ "read"));
+ permissions.add(new PropertyPermission("line.separator", "read"));
+ permissions.add(new PropertyPermission("fileStringBuffer", "read"));
+ permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
+ permissions.add(new PropertyPermission("java.io.tmpdir", "read"));
+ permissions.add(new FilePermission("<<ALL FILES>>",
+ "read, write, delete"));
+ }
+
+ /*
+ * Overloaded methods from the Policy class
+ */
+ @Override
+ public String toString() {
+ StringJoiner sj = new StringJoiner("\n", "policy: ", "");
+ Enumeration<Permission> perms = permissions.elements();
+ while (perms.hasMoreElements()) {
+ sj.add(perms.nextElement().toString());
+ }
+ return sj.toString();
+
+ }
+
+ @Override
+ public PermissionCollection getPermissions(ProtectionDomain domain) {
+ return permissions;
+ }
+
+ @Override
+ public PermissionCollection getPermissions(CodeSource codesource) {
+ return permissions;
+ }
+
+ @Override
+ public boolean implies(ProtectionDomain domain, Permission perm) {
+ return permissions.implies(perm);
+ }
+}
--- a/jdk/test/java/sql/util/BaseTest.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.security.Policy;
-import java.sql.JDBCType;
-import java.sql.SQLException;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-
-public class BaseTest {
-
- protected final String reason = "reason";
- protected final String state = "SQLState";
- protected final String cause = "java.lang.Throwable: cause";
- protected final Throwable t = new Throwable("cause");
- protected final Throwable t1 = new Throwable("cause 1");
- protected final Throwable t2 = new Throwable("cause 2");
- protected final int errorCode = 21;
- protected final String[] msgs = {"Exception 1", "cause 1", "Exception 2",
- "Exception 3", "cause 2"};
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @BeforeMethod
- public void setUpMethod() throws Exception {
- }
-
- @AfterMethod
- public void tearDownMethod() throws Exception {
- }
-
- /*
- * Take some form of SQLException, serialize and deserialize it
- */
- @SuppressWarnings("unchecked")
- protected <T extends SQLException> T
- createSerializedException(T ex)
- throws IOException, ClassNotFoundException {
- return (T) serializeDeserializeObject(ex);
- }
-
- /*
- * Utility method to serialize and deserialize an object
- */
- @SuppressWarnings("unchecked")
- protected <T> T serializeDeserializeObject(T o)
- throws IOException, ClassNotFoundException {
- T o1;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
- oos.writeObject(o);
- }
- try (ObjectInputStream ois
- = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
- o1 = (T) ois.readObject();
- }
- return o1;
- }
-
- /*
- * Utility Method used to set the current Policy
- */
- protected static void setPolicy(Policy p) {
- Policy.setPolicy(p);
- }
-
- /*
- * DataProvider used to specify the value to set and check for
- * methods using boolean values
- */
- @DataProvider(name = "trueFalse")
- protected Object[][] trueFalse() {
- return new Object[][]{
- {true},
- {false}
- };
- }
-
- /*
- * DataProvider used to specify the standard JDBC Types
- */
- @DataProvider(name = "jdbcTypes")
- protected Object[][] jdbcTypes() {
- Object[][] o = new Object[JDBCType.values().length][1];
- int pos = 0;
- for (JDBCType c : JDBCType.values()) {
- o[pos++][0] = c.getVendorTypeNumber();
- }
- return o;
- }
-}
--- a/jdk/test/java/sql/util/DriverActionImpl.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.sql.DriverAction;
-
-/**
- * Simple implementation of DriverAction which calls back into the Driver when
- * release is called.
- */
-class DriverActionImpl implements DriverAction {
-
- public DriverActionImpl(StubDriverDA d) {
- driver = d;
- }
-
- private final StubDriverDA driver;
-
- @Override
- public void deregister() {
- driver.release();
- }
-}
--- a/jdk/test/java/sql/util/SerializedBatchUpdateException.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-public class SerializedBatchUpdateException {
- /**
- * Serialized BatchUpdateException from JDBC 4.0 with the following values
- * reason = "This was the error msg"
- * SQLState = "user defined sqlState"
- * vendor Code = 99999
- * Update Counts = {1, 2, 21}
- * cause = = "java.lang.Throwable: throw 1"
- */
- public static byte[] DATA = {
- (byte) 0xac, (byte) 0xed, (byte) 0x0, (byte) 0x5, (byte) 0x73, (byte) 0x72, (byte) 0x0, (byte) 0x1d, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x2e, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x55, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65,
- (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x52, (byte) 0xf4, (byte) 0x73, (byte) 0xc0, (byte) 0xc1, (byte) 0x8b, (byte) 0xe, (byte) 0x5d, (byte) 0x3, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x0, (byte) 0x10, (byte) 0x6c, (byte) 0x6f, (byte) 0x6e, (byte) 0x67, (byte) 0x55, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x6f, (byte) 0x75,
- (byte) 0x6e, (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x4a, (byte) 0x5b, (byte) 0x0, (byte) 0xc, (byte) 0x75, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x6f, (byte) 0x75, (byte) 0x6e, (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x49, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x15,
- (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x2e, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x1d, (byte) 0xa1, (byte) 0xe9, (byte) 0x30, (byte) 0xdb, (byte) 0x3e, (byte) 0x75, (byte) 0xdc, (byte) 0x2, (byte) 0x0, (byte) 0x3,
- (byte) 0x49, (byte) 0x0, (byte) 0xa, (byte) 0x76, (byte) 0x65, (byte) 0x6e, (byte) 0x64, (byte) 0x6f, (byte) 0x72, (byte) 0x43, (byte) 0x6f, (byte) 0x64, (byte) 0x65, (byte) 0x4c, (byte) 0x0, (byte) 0x8, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x12, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0x4, (byte) 0x6e, (byte) 0x65, (byte) 0x78, (byte) 0x74, (byte) 0x74, (byte) 0x0, (byte) 0x17, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x73, (byte) 0x71, (byte) 0x6c,
- (byte) 0x2f, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x3b, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x13, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65,
- (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0xd0, (byte) 0xfd, (byte) 0x1f, (byte) 0x3e, (byte) 0x1a, (byte) 0x3b, (byte) 0x1c, (byte) 0xc4, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x13, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x54, (byte) 0x68,
- (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0xd5, (byte) 0xc6, (byte) 0x35, (byte) 0x27, (byte) 0x39, (byte) 0x77, (byte) 0xb8, (byte) 0xcb, (byte) 0x3, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0x5, (byte) 0x63, (byte) 0x61, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x15, (byte) 0x4c, (byte) 0x6a, (byte) 0x61,
- (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x54, (byte) 0x68, (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0xd, (byte) 0x64, (byte) 0x65, (byte) 0x74, (byte) 0x61, (byte) 0x69, (byte) 0x6c, (byte) 0x4d, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x61,
- (byte) 0x67, (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x5b, (byte) 0x0, (byte) 0xa, (byte) 0x73, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x1e, (byte) 0x5b, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c, (byte) 0x61,
- (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0x14, (byte) 0x73, (byte) 0x75, (byte) 0x70, (byte) 0x70, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,
- (byte) 0x65, (byte) 0x64, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x10, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x75, (byte) 0x74, (byte) 0x69, (byte) 0x6c, (byte) 0x2f, (byte) 0x4c, (byte) 0x69, (byte) 0x73, (byte) 0x74, (byte) 0x3b, (byte) 0x78,
- (byte) 0x70, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x7, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0xc, (byte) 0x74, (byte) 0x0, (byte) 0x7, (byte) 0x74, (byte) 0x68, (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x20, (byte) 0x31, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x1e, (byte) 0x5b, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x3b, (byte) 0x2, (byte) 0x46, (byte) 0x2a, (byte) 0x3c, (byte) 0x3c, (byte) 0xfd, (byte) 0x22, (byte) 0x39,
- (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x73, (byte) 0x72, (byte) 0x0, (byte) 0x1b, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63,
- (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x61, (byte) 0x9, (byte) 0xc5, (byte) 0x9a, (byte) 0x26, (byte) 0x36, (byte) 0xdd, (byte) 0x85, (byte) 0x2, (byte) 0x0, (byte) 0x4, (byte) 0x49, (byte) 0x0, (byte) 0xa, (byte) 0x6c, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x4e, (byte) 0x75, (byte) 0x6d, (byte) 0x62, (byte) 0x65, (byte) 0x72,
- (byte) 0x4c, (byte) 0x0, (byte) 0xe, (byte) 0x64, (byte) 0x65, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x43, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0x8, (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x4e, (byte) 0x61, (byte) 0x6d,
- (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0xa, (byte) 0x6d, (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6f, (byte) 0x64, (byte) 0x4e, (byte) 0x61, (byte) 0x6d, (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x23, (byte) 0x74, (byte) 0x0,
- (byte) 0x17, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x74, (byte) 0x0, (byte) 0x1c, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x74,
- (byte) 0x65, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x2e, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x74, (byte) 0x0, (byte) 0x9, (byte) 0x77, (byte) 0x72, (byte) 0x69, (byte) 0x74, (byte) 0x65, (byte) 0x54,
- (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1a, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x74, (byte) 0x0, (byte) 0x4, (byte) 0x6d, (byte) 0x61, (byte) 0x69, (byte) 0x6e, (byte) 0x70, (byte) 0x78,
- (byte) 0x74, (byte) 0x0, (byte) 0x16, (byte) 0x54, (byte) 0x68, (byte) 0x69, (byte) 0x73, (byte) 0x20, (byte) 0x77, (byte) 0x61, (byte) 0x73, (byte) 0x20, (byte) 0x74, (byte) 0x68, (byte) 0x65, (byte) 0x20, (byte) 0x65, (byte) 0x72, (byte) 0x72, (byte) 0x6f, (byte) 0x72, (byte) 0x20, (byte) 0x6d, (byte) 0x73, (byte) 0x67, (byte) 0x75, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0xe, (byte) 0x0,
- (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x28, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x14, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e,
- (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1a, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x16, (byte) 0x70, (byte) 0x78, (byte) 0x0, (byte) 0x1, (byte) 0x86, (byte) 0x9f, (byte) 0x74, (byte) 0x0, (byte) 0x15, (byte) 0x75, (byte) 0x73,
- (byte) 0x65, (byte) 0x72, (byte) 0x20, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x70, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x4a, (byte) 0x78, (byte) 0x20, (byte) 0x4, (byte) 0xb5, (byte) 0x12, (byte) 0xb1,
- (byte) 0x75, (byte) 0x93, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
- (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x49, (byte) 0x4d, (byte) 0xba, (byte) 0x60, (byte) 0x26, (byte) 0x76, (byte) 0xea, (byte) 0xb2, (byte) 0xa5, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0,
- (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x78
- };
-}
--- a/jdk/test/java/sql/util/StubConnection.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,315 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.NClob;
-import java.sql.PreparedStatement;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.SQLXML;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.sql.Struct;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.Executor;
-
-public class StubConnection implements Connection {
-
- @Override
- public Statement createStatement() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public CallableStatement prepareCall(String sql) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String nativeSQL(String sql) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setAutoCommit(boolean autoCommit) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean getAutoCommit() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void commit() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void rollback() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void close() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isClosed() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public DatabaseMetaData getMetaData() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setReadOnly(boolean readOnly) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isReadOnly() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setCatalog(String catalog) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getCatalog() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setTransactionIsolation(int level) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getTransactionIsolation() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public SQLWarning getWarnings() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void clearWarnings() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Map<String, Class<?>> getTypeMap() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setHoldability(int holdability) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getHoldability() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Savepoint setSavepoint() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Savepoint setSavepoint(String name) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void rollback(Savepoint savepoint) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void releaseSavepoint(Savepoint savepoint) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Clob createClob() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Blob createBlob() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public NClob createNClob() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public SQLXML createSQLXML() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isValid(int timeout) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setClientInfo(String name, String value) throws SQLClientInfoException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setClientInfo(Properties properties) throws SQLClientInfoException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getClientInfo(String name) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Properties getClientInfo() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setSchema(String schema) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getSchema() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void abort(Executor executor) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getNetworkTimeout() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public <T> T unwrap(Class<T> iface) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isWrapperFor(Class<?> iface) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
--- a/jdk/test/java/sql/util/StubDriver.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-public class StubDriver implements Driver {
-
- public StubDriver() {
- }
-
- @Override
- public Connection connect(String url, Properties info) throws SQLException {
- if (acceptsURL(url)) {
- return new StubConnection();
- }
- return null;
- }
-
- @Override
- public boolean acceptsURL(String url) throws SQLException {
- return url.matches("^jdbc:tennis:.*");
- }
-
- @Override
- public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getMajorVersion() {
- return 1;
- }
-
- @Override
- public int getMinorVersion() {
- return 0;
- }
-
- @Override
- public boolean jdbcCompliant() {
- return true;
- }
-
- @Override
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
--- a/jdk/test/java/sql/util/StubDriverDA.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.File;
-import java.io.IOException;
-import java.sql.DriverAction;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Simple java.sql.Driver stub class that registers the driver via a static
- * block with a DriverAction Implementation
- * @author ljanders
- */
-public class StubDriverDA extends StubDriver {
-
- public static final String DriverActionCalled = "DriverActionCalled.txt";
-
- static DriverAction da;
-
- static {
- try {
- DriverManager.registerDriver(new StubDriverDA(), da);
- } catch (SQLException ex) {
- Logger.getLogger(StubDriverDA.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public StubDriverDA() {
- da = new DriverActionImpl(this);
- }
-
- @Override
- public boolean acceptsURL(String url) throws SQLException {
- return url.matches("^jdbc:luckydog:.*");
- }
-
- /**
- * This method will write out a text file when called by the
- * DriverActionImpl.release method when DriverManager.deregisterDriver
- * is called. This is used by DriverManagerTests to validate that
- * DriverAction.release was called
- */
- protected void release() {
- File file = new File(DriverActionCalled);
- try {
- file.createNewFile();
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-}
--- a/jdk/test/java/sql/util/TestPolicy.java Sat Nov 01 14:40:09 2014 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.FilePermission;
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.Policy;
-import java.security.ProtectionDomain;
-import java.security.SecurityPermission;
-import java.sql.SQLPermission;
-import java.util.Enumeration;
-import java.util.PropertyPermission;
-import java.util.StringJoiner;
-
-/*
- * Simple Policy class that supports the required Permissions to validate the
- * JDBC concrete classes
- */
-public class TestPolicy extends Policy {
-
- final PermissionCollection permissions = new Permissions();
-
- /**
- * Constructor which sets the minimum permissions allowing testNG to work
- * with a SecurityManager
- */
- public TestPolicy() {
- setMinimalPermissions();
- }
-
- /*
- * Constructor which determines which permissions are defined for this
- * Policy used by the JDBC tests Possible values are: all (ALLPermissions),
- * setLog (SQLPemission("setLog"), deregisterDriver
- * (SQLPermission("deregisterDriver") (SQLPermission("deregisterDriver"),
- * and setSyncFactory(SQLPermission(setSyncFactory),
- *
- * @param policy Permissions to set
- */
- public TestPolicy(String policy) {
-
- switch (policy) {
- case "all":
- permissions.add(new AllPermission());
- break;
- case "setLog":
- setMinimalPermissions();
- permissions.add(new SQLPermission("setLog"));
- break;
- case "deregisterDriver":
- setMinimalPermissions();
- permissions.add(new SQLPermission("deregisterDriver"));
- break;
- case "setSyncFactory":
- setMinimalPermissions();
- permissions.add(new SQLPermission("setSyncFactory"));
- break;
- default:
- setMinimalPermissions();
- }
- }
-
- /*
- * Defines the minimal permissions required by testNG when running these
- * tests
- */
- private void setMinimalPermissions() {
- permissions.add(new SecurityPermission("getPolicy"));
- permissions.add(new SecurityPermission("setPolicy"));
- permissions.add(new RuntimePermission("getClassLoader"));
- permissions.add(new RuntimePermission("setSecurityManager"));
- permissions.add(new RuntimePermission("createSecurityManager"));
- permissions.add(new PropertyPermission("testng.show.stack.frames",
- "read"));
- permissions.add(new PropertyPermission("line.separator", "read"));
- permissions.add(new PropertyPermission("fileStringBuffer", "read"));
- permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
- permissions.add(new PropertyPermission("java.io.tmpdir", "read"));
- permissions.add(new FilePermission("<<ALL FILES>>",
- "read, write, delete"));
- }
-
- /*
- * Overloaded methods from the Policy class
- */
- @Override
- public String toString() {
- StringJoiner sj = new StringJoiner("\n", "policy: ", "");
- Enumeration<Permission> perms = permissions.elements();
- while (perms.hasMoreElements()) {
- sj.add(perms.nextElement().toString());
- }
- return sj.toString();
-
- }
-
- @Override
- public PermissionCollection getPermissions(ProtectionDomain domain) {
- return permissions;
- }
-
- @Override
- public PermissionCollection getPermissions(CodeSource codesource) {
- return permissions;
- }
-
- @Override
- public boolean implies(ProtectionDomain domain, Permission perm) {
- return permissions.implies(perm);
- }
-}
--- a/jdk/test/javax/sql/testng/TEST.properties Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/javax/sql/testng/TEST.properties Mon Nov 03 10:11:10 2014 -0800
@@ -1,4 +1,4 @@
# JDBC unit tests uses TestNG
TestNG.dirs= .
othervm.dirs= .
-lib.dirs = /java/sql/
+lib.dirs = /java/sql/testng
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/test/rowset/spi/SyncFactoryExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2014, 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 test.rowset.spi;
+
+import java.sql.SQLException;
+import javax.sql.rowset.spi.SyncFactoryException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SyncFactoryExceptionTests extends BaseTest {
+
+ /*
+ * Create SyncFactoryException with no-arg constructor
+ */
+ @Test
+ public void test01() {
+ SyncFactoryException ex = new SyncFactoryException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /*
+ * Create SyncFactoryException with message
+ */
+ @Test
+ public void test02() {
+ SyncFactoryException ex = new SyncFactoryException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /*
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test03() {
+ SyncFactoryException ex = new SyncFactoryException("Exception 1");
+ ex.initCause(t1);
+ SyncFactoryException ex1 = new SyncFactoryException("Exception 2");
+ SyncFactoryException ex2 = new SyncFactoryException("Exception 3");
+ ex2.initCause(t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /*
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test04() {
+ SQLException ex = new SyncFactoryException("Exception 1");
+ ex.initCause(t1);
+ SyncFactoryException ex1 = new SyncFactoryException("Exception 2");
+ SyncFactoryException ex2 = new SyncFactoryException("Exception 3");
+ ex2.initCause(t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ while (ex != null) {
+ assertTrue(msgs[num++].equals(ex.getMessage()));
+ Throwable c = ex.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ ex = ex.getNextException();
+ }
+ }
+
+ /*
+ * Serialize a SyncFactoryException and make sure you can read it back properly
+ */
+ @Test
+ public void test05() throws Exception {
+ SyncFactoryException e = new SyncFactoryException(reason);
+ SyncFactoryException ex1 = createSerializedException(e);
+ assertTrue(ex1.getMessage().equals(reason)
+ && ex1.getSQLState() == null
+ && ex1.getCause() == null
+ && ex1.getErrorCode() == 0);
+ }
+}
--- a/jdk/test/javax/sql/testng/test/rowset/spi/SyncFactoryPermissionsTests.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/javax/sql/testng/test/rowset/spi/SyncFactoryPermissionsTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -27,13 +27,13 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import javax.sql.rowset.spi.SyncFactory;
+import javax.sql.rowset.spi.SyncFactoryException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import util.BaseTest;
+import util.StubContext;
import util.TestPolicy;
public class SyncFactoryPermissionsTests extends BaseTest {
@@ -41,6 +41,7 @@
Context ctx;
private static Policy policy;
private static SecurityManager sm;
+ private final Logger alogger = Logger.getLogger(this.getClass().getName());
/*
* Install a SeeurityManager along with a base Policy to allow testNG to run
@@ -67,13 +68,7 @@
public SyncFactoryPermissionsTests() {
policy = Policy.getPolicy();
sm = System.getSecurityManager();
-
- try {
- ctx = new InitialContext();
- } catch (NamingException ex) {
- Logger.getLogger(SyncFactoryPermissionsTests.class.getName()).
- log(Level.SEVERE, null, ex);
- }
+ ctx = new StubContext();
}
/*
@@ -87,12 +82,20 @@
}
/*
+ * Validate that a SyncFactoryException is thrown if the Logger is null
+ */
+ @Test(expectedExceptions = SyncFactoryException.class)
+ public void test00() throws SyncFactoryException {
+ Logger l = SyncFactory.getLogger();
+ }
+
+ /*
* Validate that setJNDIContext succeeds if SQLPermission("setSyncFactory")
* has been granted
*/
@Test
- public void test1() throws Exception {
- Policy.setPolicy(new TestPolicy("setSyncFactory"));
+ public void test01() throws Exception {
+ setPolicy(new TestPolicy("setSyncFactory"));
SyncFactory.setJNDIContext(ctx);
}
@@ -100,8 +103,77 @@
* Validate that setJNDIContext succeeds if AllPermissions has been granted
*/
@Test
- public void test2() throws Exception {
+ public void test02() throws Exception {
setPolicy(new TestPolicy("all"));
SyncFactory.setJNDIContext(ctx);
}
+
+ /*
+ * Validate that AccessControlException is thrown if
+ * SQLPermission("setSyncFactory") has not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test03() throws Exception {
+ setPolicy(new TestPolicy());
+ SyncFactory.setLogger(alogger);
+ }
+
+ /*
+ * Validate that setLogger succeeds if SQLPermission("setSyncFactory")
+ * has been granted
+ */
+ @Test
+ public void test04() throws Exception {
+ setPolicy(new TestPolicy("setSyncFactory"));
+ SyncFactory.setLogger(alogger);
+ }
+
+ /*
+ * Validate that setLogger succeeds if AllPermissions has been granted
+ */
+ @Test
+ public void test05() throws Exception {
+ setPolicy(new TestPolicy("all"));
+ SyncFactory.setLogger(alogger);
+ }
+
+ /*
+ * Validate that AccessControlException is thrown if
+ * SQLPermission("setSyncFactory") has not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test06() throws Exception {
+ setPolicy(new TestPolicy());
+ SyncFactory.setLogger(alogger, Level.INFO);
+ }
+
+ /*
+ * Validate that AccessControlException is thrown if
+ * SQLPermission("setSyncFactory") and LoggingPermission("control", null)
+ * have not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test07() throws Exception {
+ setPolicy(new TestPolicy("setSyncFactory"));
+ SyncFactory.setLogger(alogger, Level.INFO);
+ }
+
+ /*
+ * Validate that setLogger succeeds if SQLPermission("setSyncFactory")
+ * has been granted
+ */
+ @Test
+ public void test08() throws Exception {
+ setPolicy(new TestPolicy("setSyncFactoryLogger"));
+ SyncFactory.setLogger(alogger, Level.INFO);
+ }
+
+ /*
+ * Validate that setLogger succeeds if AllPermissions has been granted
+ */
+ @Test
+ public void test09() throws Exception {
+ setPolicy(new TestPolicy("all"));
+ SyncFactory.setLogger(alogger, Level.INFO);
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/test/rowset/spi/SyncFactoryTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2014, 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 test.rowset.spi;
+
+import com.sun.rowset.providers.RIOptimisticProvider;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.naming.Context;
+import javax.sql.rowset.spi.SyncFactory;
+import javax.sql.rowset.spi.SyncFactoryException;
+import javax.sql.rowset.spi.SyncProvider;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import util.PropertyStubProvider;
+import util.StubSyncProvider;
+import util.StubContext;
+
+//com.sun.jndi.ldap.LdapCtxFactory
+public class SyncFactoryTests {
+ private static String origFactory;
+
+ private final String stubProvider = "util.StubSyncProvider";
+ private final String propertyStubProvider = "util.PropertyStubProvider";
+ private final Logger alogger = Logger.getLogger(this.getClass().getName());
+ // Initial providers including those set via a property
+ List<String> initialProviders;
+ // All providers including those specifically registered
+ List<String> allProviders;
+ private Context ctx= null;
+
+ public SyncFactoryTests() {
+
+ // Add a provider via a property
+ System.setProperty("rowset.provider.classname", propertyStubProvider);
+ initialProviders = Arrays.asList(
+ "com.sun.rowset.providers.RIOptimisticProvider",
+ "com.sun.rowset.providers.RIXMLProvider",
+ propertyStubProvider);
+ allProviders = new ArrayList<>();
+ allProviders.addAll(initialProviders);
+ allProviders.add(stubProvider);
+ ctx = new StubContext();
+ }
+
+ @BeforeMethod
+ public void setUpMethod() throws Exception {
+ // Make sure the provider provider that is registered is removed
+ // before each run
+ SyncFactory.unregisterProvider(stubProvider);
+ }
+
+ /*
+ * Validate a non-null factory is returned
+ */
+ @Test
+ public void test() throws SyncFactoryException {
+ SyncFactory syncFactory = SyncFactory.getSyncFactory();
+ assertTrue(syncFactory != null);
+ }
+
+ /*
+ * Check that the correct SyncProvider is returned for the specified
+ * providerID for the provider registered via a property
+ */
+ @Test
+ public void test00() throws SyncFactoryException {
+ SyncProvider p = SyncFactory.getInstance(propertyStubProvider);
+ assertTrue(p instanceof PropertyStubProvider);
+ }
+
+ /*
+ * Check that the correct SyncProvider is returned for the specified
+ * providerID
+ */
+ @Test
+ public void test01() throws SyncFactoryException {
+ SyncFactory.registerProvider(stubProvider);
+ SyncProvider p = SyncFactory.getInstance(stubProvider);
+ assertTrue(p instanceof StubSyncProvider);
+ }
+
+ /*
+ * Check that the Default SyncProvider is returned if an empty String is
+ * passed or if an invalid providerID is specified
+ */
+ @Test
+ public void test02() throws SyncFactoryException {
+ SyncProvider p = SyncFactory.getInstance("");
+ assertTrue(p instanceof RIOptimisticProvider);
+ // Attempt to get an invalid provider and get the default provider
+ p = SyncFactory.getInstance("util.InvalidSyncProvider");
+ assertTrue(p instanceof RIOptimisticProvider);
+ }
+
+ /*
+ * Validate that a SyncFactoryException is thrown if the ProviderID is null
+ */
+ @Test(expectedExceptions = SyncFactoryException.class)
+ public void test03() throws SyncFactoryException {
+ SyncProvider p = SyncFactory.getInstance(null);
+ }
+
+ /*
+ * Validate that a SyncFactoryException is thrown if the Logger is null
+ */
+ @Test(expectedExceptions = SyncFactoryException.class,enabled=true)
+ public void test04() throws SyncFactoryException {
+ Logger l = SyncFactory.getLogger();
+ }
+
+ /*
+ * Validate that the correct logger is returned by getLogger
+ */
+ @Test
+ public void test05() throws SyncFactoryException {
+ SyncFactory.setLogger(alogger);
+ Logger l = SyncFactory.getLogger();
+ assertTrue(l.equals(alogger));
+ }
+
+ /*
+ * Validate that the correct logger is returned by getLogger
+ */
+ @Test
+ public void test06() throws SyncFactoryException {
+ SyncFactory.setLogger(alogger, Level.INFO);
+ Logger l = SyncFactory.getLogger();
+ assertTrue(l.equals(alogger));
+ }
+
+ /*
+ * Validate that a driver that is registered is returned by
+ * getRegisteredProviders and if it is unregistered, that it is
+ * not returned by getRegisteredProviders
+ */
+ @Test
+ public void test07() throws SyncFactoryException {
+
+ // Validate that only the default providers and any specified via
+ // a System property are available
+ validateProviders(initialProviders);
+
+ // Register a provider and make sure it is avaiable
+ SyncFactory.registerProvider(stubProvider);
+ validateProviders(allProviders);
+
+ // Check that if a provider is unregistered, it does not show as
+ // registered
+ SyncFactory.unregisterProvider(stubProvider);
+ validateProviders(initialProviders);
+ }
+
+ /*
+ * Validate that setJNDIContext throws a SyncFactoryException if the
+ * context is null
+ */
+ @Test(expectedExceptions = SyncFactoryException.class, enabled=true)
+ public void test08() throws Exception {
+ SyncFactory.setJNDIContext(null);
+ }
+
+ /*
+ * Validate that setJNDIContext succeeds
+ */
+ @Test(enabled=true)
+ public void test09() throws Exception {
+ SyncFactory.setJNDIContext(ctx);
+ }
+
+ /*
+ * Utility method to validate the expected providers are regsitered
+ */
+ private void validateProviders(List<String> expectedProviders)
+ throws SyncFactoryException {
+ List<String> results = new ArrayList<>();
+ Enumeration<SyncProvider> providers = SyncFactory.getRegisteredProviders();
+
+ while (providers.hasMoreElements()) {
+ SyncProvider p = providers.nextElement();
+ results.add(p.getProviderID());
+ }
+ assertTrue(expectedProviders.containsAll(results)
+ && results.size() == expectedProviders.size());
+ }
+
+ /*
+ * Utility method to dump out SyncProvider info for a registered provider
+ */
+ private void showImpl(SyncProvider impl) {
+ System.out.println("Provider implementation:"
+ + "\nVendor: " + impl.getVendor()
+ + "\nVersion: " + impl.getVersion()
+ + "\nProviderID: " + impl.getProviderID());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/test/rowset/spi/SyncProviderExceptionTests.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2014, 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 test.rowset.spi;
+
+import com.sun.rowset.internal.SyncResolverImpl;
+import java.sql.SQLException;
+import javax.sql.rowset.spi.SyncProviderException;
+import static org.testng.Assert.*;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import util.BaseTest;
+import util.StubSyncResolver;
+
+public class SyncProviderExceptionTests extends BaseTest {
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ System.out.println(System.getProperty("java.naming.factory.initial"));
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+ /*
+ * Create SyncProviderException with no-arg constructor
+ */
+ @Test
+ public void test() {
+ SyncProviderException ex = new SyncProviderException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getSyncResolver() instanceof SyncResolverImpl);
+ }
+
+ /*
+ * Create SyncProviderException with no-arg constructor and
+ * call setSyncResolver to indicate the SyncResolver to use
+ */
+ @Test
+ public void test01() {
+ SyncProviderException ex = new SyncProviderException();
+ ex.setSyncResolver(new StubSyncResolver());
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getSyncResolver() instanceof StubSyncResolver);
+ }
+
+ /*
+ * Create SyncProviderException with message
+ */
+ @Test
+ public void test02() {
+ SyncProviderException ex = new SyncProviderException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getSyncResolver() instanceof SyncResolverImpl);
+ }
+
+ /*
+ * Create SyncProviderException with message and
+ * call setSyncResolver to indicate the SyncResolver to use
+ */
+ @Test
+ public void test03() {
+ SyncProviderException ex = new SyncProviderException(reason);
+ ex.setSyncResolver(new StubSyncResolver());
+
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getSyncResolver() instanceof StubSyncResolver);
+ }
+
+ /*
+ * Create SyncProviderException with and specify the SyncResolver to use
+ */
+ @Test
+ public void test04() {
+ SyncProviderException ex = new SyncProviderException(new StubSyncResolver());
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getSyncResolver() instanceof StubSyncResolver);
+ }
+
+ /*
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test05() {
+ SyncProviderException ex = new SyncProviderException("Exception 1");
+ ex.initCause(t1);
+ SyncProviderException ex1 = new SyncProviderException("Exception 2");
+ SyncProviderException ex2 = new SyncProviderException("Exception 3");
+ ex2.initCause(t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /*
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test06() {
+ SQLException ex = new SyncProviderException("Exception 1");
+ ex.initCause(t1);
+ SyncProviderException ex1 = new SyncProviderException("Exception 2");
+ SyncProviderException ex2 = new SyncProviderException("Exception 3");
+ ex2.initCause(t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ while (ex != null) {
+ assertTrue(msgs[num++].equals(ex.getMessage()));
+ Throwable c = ex.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ ex = ex.getNextException();
+ }
+ }
+
+ /*
+ * Serialize a SyncProviderException and make sure you can read it back properly
+ */
+ @Test
+ public void test07() throws Exception {
+ SyncProviderException e = new SyncProviderException(reason);
+ SyncProviderException ex1 = createSerializedException(e);
+ assertTrue(ex1.getMessage().equals(reason)
+ && ex1.getSQLState() == null
+ && ex1.getCause() == null
+ && ex1.getErrorCode() == 0
+ && ex1.getSyncResolver() instanceof SyncResolverImpl, ex1.getSyncResolver().getClass().getName());
+ }
+
+ /*
+ * Serialize a SyncProviderException and make sure you can read it back properly
+ */
+ @Test
+ public void test08() throws Exception {
+ SyncProviderException e = new SyncProviderException(reason);
+ e.setSyncResolver(new StubSyncResolver());
+
+ SyncProviderException ex1 = createSerializedException(e);
+ assertTrue(ex1.getMessage().equals(reason)
+ && ex1.getSQLState() == null
+ && ex1.getCause() == null
+ && ex1.getErrorCode() == 0
+ && ex1.getSyncResolver() instanceof StubSyncResolver);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/PropertyStubProvider.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+public class PropertyStubProvider extends StubSyncProvider {
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/StubContext.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.util.Hashtable;
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+@SuppressWarnings("unchecked")
+public class StubContext implements Context {
+
+ @Override
+ public Object lookup(Name name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object lookup(String name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public void bind(Name name, Object obj) throws NamingException {
+
+ }
+
+ @Override
+ public void bind(String name, Object obj) throws NamingException {
+
+ }
+
+ @Override
+ public void rebind(Name name, Object obj) throws NamingException {
+
+ }
+
+ @Override
+ public void rebind(String name, Object obj) throws NamingException {
+
+ }
+
+ @Override
+ public void unbind(Name name) throws NamingException {
+
+ }
+
+ @Override
+ public void unbind(String name) throws NamingException {
+
+ }
+
+ @Override
+ public void rename(Name oldName, Name newName) throws NamingException {
+
+ }
+
+ @Override
+ public void rename(String oldName, String newName) throws NamingException {
+
+ }
+
+ @Override
+ public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+ return new NamingEnumerationStub();
+ }
+
+ @Override
+ public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+ return new NamingEnumerationStub();
+ }
+
+ @Override
+ public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+ return new NamingEnumerationStub();
+ }
+
+ @Override
+ public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+ return new NamingEnumerationStub();
+ }
+
+ @Override
+ public void destroySubcontext(Name name) throws NamingException {
+
+ }
+
+ @Override
+ public void destroySubcontext(String name) throws NamingException {
+
+ }
+
+ @Override
+ public Context createSubcontext(Name name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Context createSubcontext(String name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object lookupLink(Name name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object lookupLink(String name) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public NameParser getNameParser(Name name) throws NamingException {
+ return new NameParserStub();
+ }
+
+ @Override
+ public NameParser getNameParser(String name) throws NamingException {
+ return new NameParserStub();
+ }
+
+ @Override
+ public Name composeName(Name name, Name prefix) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public String composeName(String name, String prefix) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Object removeFromEnvironment(String propName) throws NamingException {
+ return null;
+ }
+
+ @Override
+ public Hashtable<?, ?> getEnvironment() throws NamingException {
+ return new Hashtable();
+ }
+
+ @Override
+ public void close() throws NamingException {
+
+ }
+
+ @Override
+ public String getNameInNamespace() throws NamingException {
+ return null;
+ }
+
+ class NamingEnumerationStub implements NamingEnumeration {
+
+ @Override
+ public Object next() throws NamingException {
+ return null;
+ }
+
+ @Override
+ public boolean hasMore() throws NamingException {
+ return false;
+ }
+
+ @Override
+ public void close() throws NamingException {
+
+ }
+
+ @Override
+ public boolean hasMoreElements() {
+ return false;
+ }
+
+ @Override
+ public Object nextElement() {
+ return null;
+ }
+
+ }
+
+ class NameParserStub implements NameParser {
+
+ @Override
+ public Name parse(String name) throws NamingException {
+ return null;
+ }
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/StubSyncProvider.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import javax.sql.RowSetReader;
+import javax.sql.RowSetWriter;
+import javax.sql.rowset.spi.SyncProvider;
+import javax.sql.rowset.spi.SyncProviderException;
+
+public class StubSyncProvider extends SyncProvider {
+
+ /**
+ * The unique provider identifier.
+ */
+ private String providerID = "util.StubSyncProvider";
+
+ /**
+ * The vendor name of this SyncProvider implementation
+ */
+ private String vendorName = "Oracle Corporation";
+
+ /**
+ * The version number of this SyncProvider implementation
+ */
+ private String versionNumber = "1.0";
+
+ @Override
+ public String getProviderID() {
+ return providerID;
+ }
+
+ @Override
+ public RowSetReader getRowSetReader() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public RowSetWriter getRowSetWriter() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getProviderGrade() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDataSourceLock(int datasource_lock) throws SyncProviderException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getDataSourceLock() throws SyncProviderException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int supportsUpdatableView() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getVersion() {
+ return versionNumber;
+ }
+
+ @Override
+ public String getVendor() {
+ return vendorName;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/StubSyncResolver.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,1616 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+import javax.sql.RowSetListener;
+import javax.sql.rowset.spi.SyncResolver;
+
+public class StubSyncResolver implements SyncResolver, Serializable {
+
+ @Override
+ public int getStatus() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getConflictValue(int index) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getConflictValue(String columnName) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setResolvedValue(int index, Object obj) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setResolvedValue(String columnName, Object obj) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean nextConflict() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean previousConflict() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getUrl() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setUrl(String url) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getDataSourceName() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDataSourceName(String name) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getUsername() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setUsername(String name) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getPassword() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setPassword(String password) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getTransactionIsolation() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTransactionIsolation(int level) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Map<String, Class<?>> getTypeMap() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getCommand() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setCommand(String cmd) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setReadOnly(boolean value) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getMaxFieldSize() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setMaxFieldSize(int max) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getMaxRows() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setMaxRows(int max) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean getEscapeProcessing() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setEscapeProcessing(boolean enable) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getQueryTimeout() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setQueryTimeout(int seconds) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setType(int type) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setConcurrency(int concurrency) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNull(int parameterIndex, int sqlType) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNull(String parameterName, int sqlType) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNull(String parameterName, int sqlType, String typeName) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBoolean(int parameterIndex, boolean x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBoolean(String parameterName, boolean x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setByte(int parameterIndex, byte x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setByte(String parameterName, byte x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setShort(int parameterIndex, short x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setShort(String parameterName, short x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setInt(int parameterIndex, int x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setInt(String parameterName, int x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setLong(int parameterIndex, long x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setLong(String parameterName, long x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setFloat(int parameterIndex, float x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setFloat(String parameterName, float x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDouble(int parameterIndex, double x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDouble(String parameterName, double x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setString(int parameterIndex, String x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setString(String parameterName, String x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBytes(int parameterIndex, byte[] x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBytes(String parameterName, byte[] x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDate(int parameterIndex, Date x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTime(int parameterIndex, Time x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTimestamp(String parameterName, Timestamp x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setAsciiStream(String parameterName, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBinaryStream(String parameterName, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setCharacterStream(String parameterName, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setObject(String parameterName, Object x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setObject(int parameterIndex, Object x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setRef(int i, Ref x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBlob(int i, Blob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBlob(String parameterName, Blob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setBlob(String parameterName, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClob(int i, Clob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClob(int parameterIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClob(String parameterName, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClob(String parameterName, Clob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClob(String parameterName, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setArray(int i, Array x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDate(String parameterName, Date x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDate(String parameterName, Date x, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTime(String parameterName, Time x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTime(String parameterName, Time x, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void clearParameters() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void execute() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void addRowSetListener(RowSetListener listener) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void removeRowSetListener(RowSetListener listener) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setRowId(int parameterIndex, RowId x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setRowId(String parameterName, RowId x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNString(int parameterIndex, String value) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNString(String parameterName, String value) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNCharacterStream(String parameterName, Reader value) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNClob(String parameterName, NClob value) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNClob(String parameterName, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNClob(String parameterName, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNClob(int parameterIndex, NClob value) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNClob(int parameterIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setURL(int parameterIndex, URL x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean next() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void close() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean wasNull() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getString(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean getBoolean(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public byte getByte(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public short getShort(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getInt(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public long getLong(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public float getFloat(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public double getDouble(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public byte[] getBytes(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Date getDate(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Time getTime(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getString(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean getBoolean(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public byte getByte(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public short getShort(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getInt(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public long getLong(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public float getFloat(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public double getDouble(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public byte[] getBytes(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Date getDate(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Time getTime(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Timestamp getTimestamp(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getAsciiStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getUnicodeStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getBinaryStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getCursorName() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public ResultSetMetaData getMetaData() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getObject(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getObject(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int findColumn(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getCharacterStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isBeforeFirst() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isAfterLast() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isFirst() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isLast() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void beforeFirst() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void afterLast() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean first() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean last() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean absolute(int row) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean relative(int rows) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean previous() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setFetchDirection(int direction) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getFetchDirection() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setFetchSize(int rows) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getFetchSize() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getType() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getConcurrency() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean rowUpdated() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean rowInserted() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean rowDeleted() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNull(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateByte(int columnIndex, byte x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateShort(int columnIndex, short x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateInt(int columnIndex, int x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateLong(int columnIndex, long x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateFloat(int columnIndex, float x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateDouble(int columnIndex, double x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateString(int columnIndex, String x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateDate(int columnIndex, Date x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateTime(int columnIndex, Time x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateObject(int columnIndex, Object x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNull(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBoolean(String columnLabel, boolean x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateByte(String columnLabel, byte x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateShort(String columnLabel, short x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateInt(String columnLabel, int x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateLong(String columnLabel, long x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateFloat(String columnLabel, float x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateDouble(String columnLabel, double x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateString(String columnLabel, String x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBytes(String columnLabel, byte[] x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateDate(String columnLabel, Date x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateTime(String columnLabel, Time x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateObject(String columnLabel, Object x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void insertRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void deleteRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void refreshRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void cancelRowUpdates() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void moveToInsertRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void moveToCurrentRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Statement getStatement() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Ref getRef(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Blob getBlob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Clob getClob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Array getArray(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Ref getRef(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Blob getBlob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Clob getClob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Array getArray(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public URL getURL(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public URL getURL(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRef(int columnIndex, Ref x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRef(String columnLabel, Ref x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, Blob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, Blob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Clob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Clob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateArray(int columnIndex, Array x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateArray(String columnLabel, Array x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public RowId getRowId(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getHoldability() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNString(int columnIndex, String nString) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNString(String columnLabel, String nString) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public NClob getNClob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public NClob getNClob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getNString(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getNString(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/jaxp/testng/parse/jdk7156085/UTF8ReaderBug.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2014 Google, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package parse.jdk7156085;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.helpers.DefaultHandler;
+import org.testng.annotations.Test;
+
+/**
+ * JDK-7156085: ArrayIndexOutOfBoundsException throws in UTF8Reader of SAXParser
+ * https://bugs.openjdk.java.net/browse/JDK-7156085
+ *
+ * XERCESJ-1257: buffer overflow in UTF8Reader for characters out of BMP
+ * https://issues.apache.org/jira/browse/XERCESJ-1257
+ */
+public class UTF8ReaderBug {
+ @Test
+ public void shouldAcceptSupplementaryCharacters() throws Throwable {
+ StringBuilder b = new StringBuilder("<xml>");
+ for(int i = 5; i < 8223; i++) {
+ b.append(' ');
+ }
+ // Add surrogate characters which overflow the buffer. This shows the need to place an
+ // overflow check at --
+ // com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:544)
+ b.append("\uD835\uDC37");
+ b.append("</xml>");
+ sendToParser(b.toString());
+ }
+
+ private static void sendToParser(String b) throws Throwable {
+ byte[] input = b.getBytes("UTF-8");
+ ByteArrayInputStream in = new ByteArrayInputStream(input);
+
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ SAXParser p = spf.newSAXParser();
+ p.parse(new InputSource(in), new DefaultHandler());
+ }
+}
--- a/jdk/test/sun/nio/cs/TestUTF_16.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/sun/nio/cs/TestUTF_16.java Mon Nov 03 10:11:10 2014 -0800
@@ -150,7 +150,7 @@
if (CoderResult.OVERFLOW !=
Charset.forName("UTF_16")
.newDecoder()
- .decode((ByteBuffer)(ByteBuffer.allocate(4)
+ .decode((ByteBuffer.allocate(4)
.put(new byte[]
{(byte)0xd8,(byte)0x00,
(byte)0xdc,(byte)0x01})
--- a/jdk/test/sun/nio/cs/TestUTF_32.java Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/sun/nio/cs/TestUTF_32.java Mon Nov 03 10:11:10 2014 -0800
@@ -184,7 +184,7 @@
if (CoderResult.OVERFLOW !=
Charset.forName("UTF_32")
.newDecoder()
- .decode((ByteBuffer)(ByteBuffer.allocate(4)
+ .decode((ByteBuffer.allocate(4)
.put(new byte[]
{(byte)0,(byte)1, (byte)0,(byte)01})
.flip()),
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/tools/keytool/ExportPrivateKeyNoPwd.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014, 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.security.*;
+
+/*
+ * Export a private key from the named keychain entry without supplying a
+ * password. See JDK-8062264.
+ *
+ * NOTE: Keychain access controls must already have been lowered to permit
+ * the target entry to be accessed.
+ */
+public class ExportPrivateKeyNoPwd {
+
+ public static final void main(String[] args) throws Exception {
+
+ if (args.length != 1) {
+ throw new Exception(
+ "ExportPrivateKeyNoPwd: must supply name of a keystore entry");
+ }
+ String alias = args[0];
+
+ KeyStore ks = KeyStore.getInstance("KeychainStore");
+ System.out.println("ExportPrivateKeyNoPwd: loading keychains...");
+ ks.load(null, null);
+
+ System.out.println("ExportPrivateKeyNoPwd: exporting key...");
+ Key key = ks.getKey(alias, null);
+ if (key instanceof PrivateKey) {
+ System.out.println("ExportPrivateKeyNoPwd: exported " +
+ key.getAlgorithm() + " private key from '" + alias + "'");
+ } else {
+ throw new Exception("Error exporting private key from keychain");
+ }
+ }
+}
+
--- a/jdk/test/sun/security/tools/keytool/ListKeychainStore.sh Sat Nov 01 14:40:09 2014 +0300
+++ b/jdk/test/sun/security/tools/keytool/ListKeychainStore.sh Mon Nov 03 10:11:10 2014 -0800
@@ -22,7 +22,7 @@
#
# @test
-# @bug 7133495 8041740
+# @bug 7133495 8041740 8062264
# @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry
if [ "${TESTJAVA}" = "" ] ; then
@@ -30,6 +30,9 @@
TESTJAVA=`dirname $JAVAC_CMD`/..
fi
+if [ "${TESTSRC}" = "" ] ; then
+ TESTSRC="."
+fi
if [ "${TESTCLASSES}" = "" ] ; then
TESTCLASSES=`pwd`
fi
@@ -59,10 +62,6 @@
COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
echo "Found $COUNT private key entries in the Keychain keystores"
-if [ $COUNT -gt 1 ]; then
- exit 0
-fi
-
# Create a temporary PKCS12 keystore containing 3 public/private keypairs
RESULT=`$CLEANUP_P12`
@@ -107,8 +106,9 @@
echo "Unlocked the temporary keychain"
# Import the keypairs from the PKCS12 keystore into the keychain
+# (The '-A' option is used to lower the temporary keychain's access controls)
-security import $TEMPORARY_P12 -k $TEMPORARY_KC -f pkcs12 -P $PWD
+security import $TEMPORARY_P12 -k $TEMPORARY_KC -f pkcs12 -P $PWD -A
if [ $? -ne 0 ]; then
echo "Error: cannot import keypairs from PKCS12 keystore into the keychain"
RESULT=`$CLEANUP_P12`
@@ -128,26 +128,39 @@
# Recount the number of private key entries in the Keychain keystores
-COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
-echo "Found $COUNT private key entries in the Keychain keystore"
-if [ $COUNT -lt 3 ]; then
- echo "Error: expected >2 private key entries in the Keychain keystores"
+RECOUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
+echo "Found $RECOUNT private key entries in the Keychain keystore"
+if [ $RECOUNT -lt `expr $COUNT + 3` ]; then
+ echo "Error: expected >$COUNT private key entries in the Keychain keystores"
RESULT=`$CLEANUP_P12`
RESULT=`$CLEANUP_KC`
exit 5
fi
+# Export a private key from the keychain (without supplying a password)
+# Access controls have already been lowered (see 'security import ... -A' above)
+
+${TESTJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/ExportPrivateKeyNoPwd.java || exit 6
+echo | ${TESTJAVA}/bin/java ${TESTVMOPTS} ExportPrivateKeyNoPwd x
+if [ $? -ne 0 ]; then
+ echo "Error exporting private key from the temporary keychain"
+ RESULT=`$CLEANUP_P12`
+ RESULT=`$CLEANUP_KC`
+ exit 6
+fi
+echo "Exported a private key from the temporary keychain"
+
RESULT=`$CLEANUP_P12`
if [ $? -ne 0 ]; then
echo "Error: cannot remove the temporary PKCS12 keystore"
- exit 6
+ exit 7
fi
echo "Removed the temporary PKCS12 keystore"
RESULT=`$CLEANUP_KC`
if [ $? -ne 0 ]; then
echo "Error: cannot remove the temporary keychain"
- exit 7
+ exit 8
fi
echo "Removed the temporary keychain"
--- a/langtools/.hgtags Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/.hgtags Mon Nov 03 10:11:10 2014 -0800
@@ -279,3 +279,4 @@
e18407fcede818b30709913784cb6b904030531d jdk9-b34
b8e7bbdd806465a916e64413c283075ceb0a782c jdk9-b35
c536541235e566701ff772700c15de14b75e2979 jdk9-b36
+478972d90f7bf5002615c5b2fb1ec3e0338fcadd jdk9-b37
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Mon Nov 03 10:11:10 2014 -0800
@@ -76,6 +76,7 @@
*/
public class JavacFileManager extends BaseFileManager implements StandardJavaFileManager {
+ @SuppressWarnings("cast")
public static char[] toArray(CharBuffer buffer) {
if (buffer.hasArray())
return ((CharBuffer)buffer.compact().flip()).array();
@@ -129,6 +130,8 @@
if (register)
context.put(JavaFileManager.class, this);
setContext(context);
+ if (System.getProperty("show.fm.open.close") != null)
+ System.err.println("JavacFileManager.open " + this.hashCode());
}
/**
@@ -570,6 +573,8 @@
*/
@DefinedBy(Api.COMPILER)
public void close() {
+ if (System.getProperty("show.fm.open.close") != null)
+ System.err.println("JavacFileManager.close " + this.hashCode());
for (Iterator<Archive> i = archives.values().iterator(); i.hasNext(); ) {
Archive a = i.next();
i.remove();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/CRTable.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/CRTable.java Mon Nov 03 10:11:10 2014 -0800
@@ -517,6 +517,13 @@
result = sr;
}
+ @Override
+ public void visitTypeUnion(JCTypeUnion tree) {
+ SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
+ sr.mergeWith(csp(tree.alternatives));
+ result = sr;
+ }
+
public void visitWildcard(JCWildcard tree) {
result = null;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/BaseFileManager.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/BaseFileManager.java Mon Nov 03 10:11:10 2014 -0800
@@ -235,6 +235,7 @@
return encName;
}
+ @SuppressWarnings("cast")
public CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
String encodingName = getEncodingName();
CharsetDecoder decoder;
@@ -315,6 +316,7 @@
* @return a byte buffer containing the contents of the stream
* @throws IOException if an error occurred while reading the stream
*/
+ @SuppressWarnings("cast")
public ByteBuffer makeByteBuffer(InputStream in)
throws IOException {
int limit = in.available();
@@ -343,6 +345,7 @@
/**
* A single-element cache of direct byte buffers.
*/
+ @SuppressWarnings("cast")
private static class ByteBufferCache {
private ByteBuffer cached;
ByteBuffer get(int capacity) {
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java Mon Nov 03 10:11:10 2014 -0800
@@ -88,6 +88,9 @@
*/
private boolean apiMode;
+ private JavaFileManager fileManager;
+ private boolean closeFileManagerOnExit;
+
Start(String programName,
PrintWriter errWriter,
PrintWriter warnWriter,
@@ -239,6 +242,12 @@
messager.error(Messager.NOPOS, "main.fatal.exception");
failed = true;
} finally {
+ if (fileManager != null && closeFileManagerOnExit) {
+ try {
+ fileManager.close();
+ } catch (IOException ignore) {
+ }
+ }
messager.exitNotice();
messager.flush();
}
@@ -270,7 +279,8 @@
}
- JavaFileManager fileManager = context.get(JavaFileManager.class);
+ fileManager = context.get(JavaFileManager.class);
+
setDocletInvoker(docletClass, fileManager, argv);
compOpts = Options.instance(context);
@@ -333,6 +343,7 @@
if (fileManager == null) {
JavacFileManager.preRegister(context);
fileManager = context.get(JavaFileManager.class);
+ closeFileManagerOnExit = true;
}
if (fileManager instanceof BaseFileManager) {
((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
--- a/langtools/test/tools/all/RunCodingRules.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/all/RunCodingRules.java Mon Nov 03 10:11:10 2014 -0800
@@ -77,41 +77,42 @@
}
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = javaCompiler.getStandardFileManager(null, null, null);
- DiagnosticListener<JavaFileObject> noErrors = diagnostic -> {
- Assert.check(diagnostic.getKind() != Diagnostic.Kind.ERROR, diagnostic.toString());
- };
+ try (StandardJavaFileManager fm = javaCompiler.getStandardFileManager(null, null, null)) {
+ DiagnosticListener<JavaFileObject> noErrors = diagnostic -> {
+ Assert.check(diagnostic.getKind() != Diagnostic.Kind.ERROR, diagnostic.toString());
+ };
- List<File> crulesFiles = Files.walk(crulesDir)
- .filter(entry -> entry.getFileName().toString().endsWith(".java"))
- .filter(entry -> entry.getParent().endsWith("crules"))
- .map(entry -> entry.toFile())
- .collect(Collectors.toList());
+ List<File> crulesFiles = Files.walk(crulesDir)
+ .filter(entry -> entry.getFileName().toString().endsWith(".java"))
+ .filter(entry -> entry.getParent().endsWith("crules"))
+ .map(entry -> entry.toFile())
+ .collect(Collectors.toList());
- Path crulesTarget = targetDir.resolve("crules");
- Files.createDirectories(crulesTarget);
- List<String> crulesOptions = Arrays.asList("-d", crulesTarget.toString());
- javaCompiler.getTask(null, fm, noErrors, crulesOptions, null,
- fm.getJavaFileObjectsFromFiles(crulesFiles)).call();
- Path registration = crulesTarget.resolve("META-INF/services/com.sun.source.util.Plugin");
- Files.createDirectories(registration.getParent());
- try (Writer metaInfServices = Files.newBufferedWriter(registration, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
- metaInfServices.write("crules.CodingRulesAnalyzerPlugin\n");
- }
+ Path crulesTarget = targetDir.resolve("crules");
+ Files.createDirectories(crulesTarget);
+ List<String> crulesOptions = Arrays.asList("-d", crulesTarget.toString());
+ javaCompiler.getTask(null, fm, noErrors, crulesOptions, null,
+ fm.getJavaFileObjectsFromFiles(crulesFiles)).call();
+ Path registration = crulesTarget.resolve("META-INF/services/com.sun.source.util.Plugin");
+ Files.createDirectories(registration.getParent());
+ try (Writer metaInfServices = Files.newBufferedWriter(registration, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
+ metaInfServices.write("crules.CodingRulesAnalyzerPlugin\n");
+ }
- List<File> sources = sourceDirs.stream()
- .flatMap(dir -> silentFilesWalk(dir))
- .filter(entry -> entry.getFileName().toString().endsWith(".java"))
- .map(p -> p.toFile())
- .collect(Collectors.toList());
+ List<File> sources = sourceDirs.stream()
+ .flatMap(dir -> silentFilesWalk(dir))
+ .filter(entry -> entry.getFileName().toString().endsWith(".java"))
+ .map(p -> p.toFile())
+ .collect(Collectors.toList());
- Path sourceTarget = targetDir.resolve("classes");
- Files.createDirectories(sourceTarget);
- String processorPath = crulesTarget.toString() + File.pathSeparator + crulesDir.toString();
- List<String> options = Arrays.asList("-d", sourceTarget.toString(),
- "-processorpath", processorPath, "-Xplugin:coding_rules");
- javaCompiler.getTask(null, fm, noErrors, options, null,
- fm.getJavaFileObjectsFromFiles(sources)).call();
+ Path sourceTarget = targetDir.resolve("classes");
+ Files.createDirectories(sourceTarget);
+ String processorPath = crulesTarget.toString() + File.pathSeparator + crulesDir.toString();
+ List<String> options = Arrays.asList("-d", sourceTarget.toString(),
+ "-processorpath", processorPath, "-Xplugin:coding_rules");
+ javaCompiler.getTask(null, fm, noErrors, options, null,
+ fm.getJavaFileObjectsFromFiles(sources)).call();
+ }
}
Stream<Path> silentFilesWalk(Path dir) throws IllegalStateException {
--- a/langtools/test/tools/javac/6341866/T6341866.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/6341866/T6341866.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -113,58 +113,59 @@
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
MyDiagListener dl = new MyDiagListener();
- StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
+ try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
- // Note: class A references class B, so compile A if we want implicit compilation
- File file = (implicitType != ImplicitType.NONE) ? a_java : b_java;
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
-
- //System.err.println("compile: " + opts + " " + files);
+ // Note: class A references class B, so compile A if we want implicit compilation
+ File file = (implicitType != ImplicitType.NONE) ? a_java : b_java;
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
- boolean ok = javac.getTask(null, fm, dl, opts, null, files).call();
- if (!ok) {
- error("compilation failed");
- return false;
- }
+ //System.err.println("compile: " + opts + " " + files);
- // check implicit compilation results if necessary
- if (implicitType != ImplicitType.NONE) {
- boolean expectClass = (implicitType != ImplicitType.OPT_NONE);
- if (b_class.exists() != expectClass) {
- if (b_class.exists())
- error("B implicitly compiled unexpectedly");
- else
- error("B not impliictly compiled");
+ boolean ok = javac.getTask(null, fm, dl, opts, null, files).call();
+ if (!ok) {
+ error("compilation failed");
return false;
}
- }
+
+ // check implicit compilation results if necessary
+ if (implicitType != ImplicitType.NONE) {
+ boolean expectClass = (implicitType != ImplicitType.OPT_NONE);
+ if (b_class.exists() != expectClass) {
+ if (b_class.exists())
+ error("B implicitly compiled unexpectedly");
+ else
+ error("B not impliictly compiled");
+ return false;
+ }
+ }
- // check message key results
- String expectKey = null;
- if (implicitType == ImplicitType.OPT_UNSET) {
- switch (annoType) {
- case SERVICE:
- expectKey = "compiler.warn.proc.use.proc.or.implicit";
- break;
- case SPECIFY:
- expectKey = "compiler.warn.proc.use.implicit";
- break;
+ // check message key results
+ String expectKey = null;
+ if (implicitType == ImplicitType.OPT_UNSET) {
+ switch (annoType) {
+ case SERVICE:
+ expectKey = "compiler.warn.proc.use.proc.or.implicit";
+ break;
+ case SPECIFY:
+ expectKey = "compiler.warn.proc.use.implicit";
+ break;
+ }
}
+
+ if (expectKey == null) {
+ if (dl.diagCodes.size() != 0) {
+ error("no diagnostics expected");
+ return false;
+ }
+ } else {
+ if (!(dl.diagCodes.size() == 1 && dl.diagCodes.get(0).equals(expectKey))) {
+ error("unexpected diagnostics generated");
+ return false;
+ }
+ }
+
+ return true;
}
-
- if (expectKey == null) {
- if (dl.diagCodes.size() != 0) {
- error("no diagnostics expected");
- return false;
- }
- } else {
- if (!(dl.diagCodes.size() == 1 && dl.diagCodes.get(0).equals(expectKey))) {
- error("unexpected diagnostics generated");
- return false;
- }
- }
-
- return true;
}
static void createProcessorServices(String name) throws IOException {
--- a/langtools/test/tools/javac/6400872/T6400872.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/6400872/T6400872.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -58,8 +58,7 @@
throws IOException {
System.err.println("compile...");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
- try {
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
Iterable<? extends JavaFileObject> fileObjects =
fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
@@ -78,8 +77,6 @@
compiler.getTask(null, fm, null, options, null, fileObjects);
if (!task.call())
throw new AssertionError("compilation failed");
- } finally {
- fm.close();
}
}
--- a/langtools/test/tools/javac/6402516/Checker.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/6402516/Checker.java Mon Nov 03 10:11:10 2014 -0800
@@ -54,25 +54,26 @@
};
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(getFiles(testSrc, fileNames));
- task = tool.getTask(null, fm, dl, null, null, files);
- Iterable<? extends CompilationUnitTree> units = task.parse();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(getFiles(testSrc, fileNames));
+ task = tool.getTask(null, fm, dl, null, null, files);
+ Iterable<? extends CompilationUnitTree> units = task.parse();
- if (errors)
- throw new AssertionError("errors occurred creating trees");
+ if (errors)
+ throw new AssertionError("errors occurred creating trees");
- ScopeScanner s = new ScopeScanner();
- for (CompilationUnitTree unit: units) {
- TreePath p = new TreePath(unit);
- s.scan(p, getTrees());
- additionalChecks(getTrees(), unit);
+ ScopeScanner s = new ScopeScanner();
+ for (CompilationUnitTree unit: units) {
+ TreePath p = new TreePath(unit);
+ s.scan(p, getTrees());
+ additionalChecks(getTrees(), unit);
+ }
+ task = null;
+
+ if (errors)
+ throw new AssertionError("errors occurred checking scopes");
}
- task = null;
-
- if (errors)
- throw new AssertionError("errors occurred checking scopes");
}
// default impl: split ref at ";" and call checkLocal(scope, ref_segment) on scope and its enclosing scopes
--- a/langtools/test/tools/javac/6440583/T6440583.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/6440583/T6440583.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,30 +40,31 @@
String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes", ".");
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
- JavacTask task = tool.getTask(null, fm, null, null, null, files);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
+ JavacTask task = tool.getTask(null, fm, null, null, null, files);
- Iterable<? extends Tree> trees = task.parse();
+ Iterable<? extends Tree> trees = task.parse();
- TreeScanner<Boolean,Void> checker = new TreeScanner<Boolean,Void>() {
- public Boolean visitErroneous(ErroneousTree tree, Void ignore) {
- JCErroneous etree = (JCErroneous) tree;
- List<? extends Tree> errs = etree.getErrorTrees();
- System.err.println("errs: " + errs);
- if (errs == null || errs.size() == 0)
- throw new AssertionError("no error trees found");
- found = true;
- return true;
- }
- };
+ TreeScanner<Boolean,Void> checker = new TreeScanner<Boolean,Void>() {
+ public Boolean visitErroneous(ErroneousTree tree, Void ignore) {
+ JCErroneous etree = (JCErroneous) tree;
+ List<? extends Tree> errs = etree.getErrorTrees();
+ System.err.println("errs: " + errs);
+ if (errs == null || errs.size() == 0)
+ throw new AssertionError("no error trees found");
+ found = true;
+ return true;
+ }
+ };
- for (Tree tree: trees)
- checker.scan(tree, null);
+ for (Tree tree: trees)
+ checker.scan(tree, null);
- if (!found)
- throw new AssertionError("no ErroneousTree nodes found");
+ if (!found)
+ throw new AssertionError("no ErroneousTree nodes found");
+ }
}
private static boolean found;
--- a/langtools/test/tools/javac/6902720/Test.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/6902720/Test.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, 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
@@ -54,38 +54,39 @@
void test(File test) throws Exception {
JavacTool tool1 = JavacTool.create();
- StandardJavaFileManager fm = tool1.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(test);
+ try (StandardJavaFileManager fm = tool1.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(test);
- // parse test file into a tree, and write it out to a stringbuffer using Pretty
- JavacTask t1 = tool1.getTask(null, fm, null, null, null, files);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- Iterable<? extends CompilationUnitTree> trees = t1.parse();
- for (CompilationUnitTree tree: trees) {
- new Pretty(pw, true).printExpr((JCTree) tree);
- }
- pw.close();
+ // parse test file into a tree, and write it out to a stringbuffer using Pretty
+ JavacTask t1 = tool1.getTask(null, fm, null, null, null, files);
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ Iterable<? extends CompilationUnitTree> trees = t1.parse();
+ for (CompilationUnitTree tree: trees) {
+ new Pretty(pw, true).printExpr((JCTree) tree);
+ }
+ pw.close();
- final String out = sw.toString();
- System.err.println("generated code:\n" + out + "\n");
+ final String out = sw.toString();
+ System.err.println("generated code:\n" + out + "\n");
- // verify the generated code is valid Java by compiling it
- JavacTool tool2 = JavacTool.create();
- JavaFileObject fo = new SimpleJavaFileObject(URI.create("output"), JavaFileObject.Kind.SOURCE) {
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors) {
- return out;
- }
- };
- JavacTask t2 = tool2.getTask(null, fm, null, null, null, Collections.singleton(fo));
- boolean ok = t2.call();
- if (!ok)
- throw new Exception("compilation of generated code failed");
+ // verify the generated code is valid Java by compiling it
+ JavacTool tool2 = JavacTool.create();
+ JavaFileObject fo = new SimpleJavaFileObject(URI.create("output"), JavaFileObject.Kind.SOURCE) {
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return out;
+ }
+ };
+ JavacTask t2 = tool2.getTask(null, fm, null, null, null, Collections.singleton(fo));
+ boolean ok = t2.call();
+ if (!ok)
+ throw new Exception("compilation of generated code failed");
- File expectedClass = new File(test.getName().replace(".java", ".class"));
- if (!expectedClass.exists())
- throw new Exception(expectedClass + " not found");
+ File expectedClass = new File(test.getName().replace(".java", ".class"));
+ if (!expectedClass.exists())
+ throw new Exception(expectedClass + " not found");
+ }
}
}
--- a/langtools/test/tools/javac/7003595/T7003595.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/7003595/T7003595.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,9 +49,6 @@
/** global decls ***/
- // Create a single file manager and reuse it for each compile to save time.
- static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
-
//statistics
static int checkCount = 0;
@@ -112,15 +109,18 @@
}
public static void main(String... args) throws Exception {
- for (ClassKind ck1 : ClassKind.values()) {
- String cname1 = "C1";
- for (ClassKind ck2 : ClassKind.values()) {
- if (!ck1.isAllowed(ck2)) continue;
- String cname2 = "C2";
- for (ClassKind ck3 : ClassKind.values()) {
- if (!ck2.isAllowed(ck3)) continue;
- String cname3 = "C3";
- new T7003595(new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
+ // Create a single file manager and reuse it for each compile to save time.
+ try (StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null)) {
+ for (ClassKind ck1 : ClassKind.values()) {
+ String cname1 = "C1";
+ for (ClassKind ck2 : ClassKind.values()) {
+ if (!ck1.isAllowed(ck2)) continue;
+ String cname2 = "C2";
+ for (ClassKind ck3 : ClassKind.values()) {
+ if (!ck2.isAllowed(ck3)) continue;
+ String cname3 = "C3";
+ new T7003595(fm, new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
+ }
}
}
}
@@ -132,8 +132,10 @@
ClassKind[] cks;
String[] cnames;
+ StandardJavaFileManager fm;
- T7003595(ClassKind[] cks, String[] cnames) {
+ T7003595(StandardJavaFileManager fm, ClassKind[] cks, String[] cnames) {
+ this.fm = fm;
this.cks = cks;
this.cnames = cnames;
}
--- a/langtools/test/tools/javac/7079713/TestCircularClassfile.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/7079713/TestCircularClassfile.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,13 +100,14 @@
public static void main(String... args) throws Exception {
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
- int count = 0;
- for (SourceKind sk1 : SourceKind.values()) {
- for (SourceKind sk2 : SourceKind.values()) {
- for (TestKind tk : TestKind.values()) {
- for (ClientKind ck : ClientKind.values()) {
- new TestCircularClassfile("sub_"+count++, sk1, sk2, tk, ck).check(comp, fm);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
+ int count = 0;
+ for (SourceKind sk1 : SourceKind.values()) {
+ for (SourceKind sk2 : SourceKind.values()) {
+ for (TestKind tk : TestKind.values()) {
+ for (ClientKind ck : ClientKind.values()) {
+ new TestCircularClassfile("sub_"+count++, sk1, sk2, tk, ck).check(comp, fm);
+ }
}
}
}
--- a/langtools/test/tools/javac/7142086/T7142086.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/7142086/T7142086.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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,11 @@
void run(List<JavaFileObject> sources) throws Exception {
DiagnosticChecker dc = new DiagnosticChecker();
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
- JavacTask ct = (JavacTask)comp.getTask(null, fm, dc,
- null, null, sources);
- ct.analyze();
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
+ JavacTask ct = (JavacTask)comp.getTask(null, fm, dc,
+ null, null, sources);
+ ct.analyze();
+ }
}
static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
--- a/langtools/test/tools/javac/NoStringToLower.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/NoStringToLower.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -54,31 +54,32 @@
*/
boolean run(String... args) throws Exception {
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- JavaFileManager fm = c.getStandardFileManager(null, null, null);
- JavaFileManager.Location javacLoc = findJavacLocation(fm);
- String[] pkgs = {
- "javax.annotation.processing",
- "javax.lang.model",
- "javax.tools",
- "com.sun.source",
- "com.sun.tools.classfile",
- "com.sun.tools.doclet",
- "com.sun.tools.doclint",
- "com.sun.tools.javac",
- "com.sun.tools.javadoc",
- "com.sun.tools.javah",
- "com.sun.tools.javap",
- "com.sun.tools.jdeps",
- "com.sun.tools.sjavac"
- };
- for (String pkg: pkgs) {
- for (JavaFileObject fo: fm.list(javacLoc,
- pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
- scan(fo);
+ try (JavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ JavaFileManager.Location javacLoc = findJavacLocation(fm);
+ String[] pkgs = {
+ "javax.annotation.processing",
+ "javax.lang.model",
+ "javax.tools",
+ "com.sun.source",
+ "com.sun.tools.classfile",
+ "com.sun.tools.doclet",
+ "com.sun.tools.doclint",
+ "com.sun.tools.javac",
+ "com.sun.tools.javadoc",
+ "com.sun.tools.javah",
+ "com.sun.tools.javap",
+ "com.sun.tools.jdeps",
+ "com.sun.tools.sjavac"
+ };
+ for (String pkg: pkgs) {
+ for (JavaFileObject fo: fm.list(javacLoc,
+ pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
+ scan(fo);
+ }
}
+
+ return (errors == 0);
}
-
- return (errors == 0);
}
// depending on how the test is run, javac may be on bootclasspath or classpath
--- a/langtools/test/tools/javac/Paths/6638501/JarFromManifestFailure.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/Paths/6638501/JarFromManifestFailure.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, 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,28 +71,29 @@
}
}
- static void compile(File classOutDir, Iterable<File> classPath, File... files) {
+ static void compile(File classOutDir, Iterable<File> classPath, File... files) throws IOException {
System.err.println("compile...");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> fileObjects =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> fileObjects =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
- List<String> options = new ArrayList<String>();
- if (classOutDir != null) {
- options.add("-d");
- options.add(classOutDir.getPath());
+ List<String> options = new ArrayList<String>();
+ if (classOutDir != null) {
+ options.add("-d");
+ options.add(classOutDir.getPath());
+ }
+ if (classPath != null) {
+ options.add("-classpath");
+ options.add(join(classPath, File.pathSeparator));
+ }
+ options.add("-verbose");
+
+ JavaCompiler.CompilationTask task =
+ compiler.getTask(null, fm, null, options, null, fileObjects);
+ if (!task.call())
+ throw new AssertionError("compilation failed");
}
- if (classPath != null) {
- options.add("-classpath");
- options.add(join(classPath, File.pathSeparator));
- }
- options.add("-verbose");
-
- JavaCompiler.CompilationTask task =
- compiler.getTask(null, fm, null, options, null, fileObjects);
- if (!task.call())
- throw new AssertionError("compilation failed");
}
static void jar(File jar, Iterable<File> classPath, File base, File... files)
--- a/langtools/test/tools/javac/Paths/TestCompileJARInClassPath.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/Paths/TestCompileJARInClassPath.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, 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,17 +116,18 @@
javax.tools.JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
- StandardJavaFileManager stdFileManager = javac.getStandardFileManager(diagnostics, null, null);
+ try (StandardJavaFileManager stdFileManager = javac.getStandardFileManager(diagnostics, null, null)) {
- List<File> files = new ArrayList<>();
- files.add(clientJarFile);
+ List<File> files = new ArrayList<>();
+ files.add(clientJarFile);
- stdFileManager.setLocation(StandardLocation.CLASS_PATH, files);
+ stdFileManager.setLocation(StandardLocation.CLASS_PATH, files);
+
+ Iterable<? extends JavaFileObject> sourceFiles = stdFileManager.getJavaFileObjects(sourceFileToCompile);
- Iterable<? extends JavaFileObject> sourceFiles = stdFileManager.getJavaFileObjects(sourceFileToCompile);
-
- if (!javac.getTask(null, stdFileManager, diagnostics, null, null, sourceFiles).call()) {
- throw new AssertionError("compilation failed");
+ if (!javac.getTask(null, stdFileManager, diagnostics, null, null, sourceFiles).call()) {
+ throw new AssertionError("compilation failed");
+ }
}
}
}
--- a/langtools/test/tools/javac/T6265400.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6265400.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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,10 +44,11 @@
throw new NullPointerException(SILLY_BILLY);
}
};
- StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromStrings(Arrays.asList("badfile.java"));
- javac.getTask(null, fm, dl, null, null, files).call();
+ try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromStrings(Arrays.asList("badfile.java"));
+ javac.getTask(null, fm, dl, null, null, files).call();
+ }
}
catch (RuntimeException e) {
Throwable cause = e.getCause();
--- a/langtools/test/tools/javac/T6340549.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6340549.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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,13 +44,14 @@
try {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
- jfm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
+ try (StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) {
+ jfm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
- for (JavaFileObject jfo : jfm.list(StandardLocation.CLASS_PATH,
- "", EnumSet.of(Kind.OTHER), false)) {
- if (new File(jfo.getName()).isDirectory()) {
- throw new AssertionError("Found directory: " + jfo);
+ for (JavaFileObject jfo : jfm.list(StandardLocation.CLASS_PATH,
+ "", EnumSet.of(Kind.OTHER), false)) {
+ if (new File(jfo.getName()).isDirectory()) {
+ throw new AssertionError("Found directory: " + jfo);
+ }
}
}
} finally {
--- a/langtools/test/tools/javac/T6351767.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6351767.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -38,52 +38,52 @@
public static void main(String... args) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- JavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
+ try (JavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) {
- // test null
- try {
- jfm.list(StandardLocation.SOURCE_PATH, null, EnumSet.of(Kind.SOURCE), false);
- error("NPE not thrown");
- }
- catch (NullPointerException e) {
- // expected
- }
+ // test null
+ try {
+ jfm.list(StandardLocation.SOURCE_PATH, null, EnumSet.of(Kind.SOURCE), false);
+ error("NPE not thrown");
+ }
+ catch (NullPointerException e) {
+ // expected
+ }
- // test null fileKinds
- try {
- jfm.list(StandardLocation.SOURCE_PATH, "", null, false);
- error("NPE not thrown");
- }
- catch (NullPointerException e) {
- // expected
- }
+ // test null fileKinds
+ try {
+ jfm.list(StandardLocation.SOURCE_PATH, "", null, false);
+ error("NPE not thrown");
+ }
+ catch (NullPointerException e) {
+ // expected
+ }
- // test good package
- boolean found = false;
- for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH,
- "java.lang",
- EnumSet.of(Kind.CLASS),
- false)) {
- System.err.println("found " + jfo.toUri());
- if (jfo.isNameCompatible("Object", Kind.CLASS))
- found = true;
- }
- if (!found)
- error("expected file, java/lang/Object.class, not found");
+ // test good package
+ boolean found = false;
+ for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH,
+ "java.lang",
+ EnumSet.of(Kind.CLASS),
+ false)) {
+ System.err.println("found " + jfo.toUri());
+ if (jfo.isNameCompatible("Object", Kind.CLASS))
+ found = true;
+ }
+ if (!found)
+ error("expected file, java/lang/Object.class, not found");
- found = false;
- // test good package (VM name)
- for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH,
- "java/lang",
- EnumSet.of(Kind.CLASS),
- false)) {
- System.err.println("found " + jfo.toUri());
- if (jfo.isNameCompatible("Object", Kind.CLASS))
- found = true;
+ found = false;
+ // test good package (VM name)
+ for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH,
+ "java/lang",
+ EnumSet.of(Kind.CLASS),
+ false)) {
+ System.err.println("found " + jfo.toUri());
+ if (jfo.isNameCompatible("Object", Kind.CLASS))
+ found = true;
+ }
+ if (!found)
+ error("expected file, java/lang/Object.class, not found");
}
- if (!found)
- error("expected file, java/lang/Object.class, not found");
-
}
static void error(String msg) {
--- a/langtools/test/tools/javac/T6361619.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6361619.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,17 +57,18 @@
}
};
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- Iterable<? extends JavaFileObject> f =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir,
- self + ".java")));
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ Iterable<? extends JavaFileObject> f =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir,
+ self + ".java")));
- JavacTask task = tool.getTask(out, fm, dl, flags, null, f);
- MyTaskListener tl = new MyTaskListener(task);
- task.setTaskListener(tl);
+ JavacTask task = tool.getTask(out, fm, dl, flags, null, f);
+ MyTaskListener tl = new MyTaskListener(task);
+ task.setTaskListener(tl);
- // should complete, without exceptions
- task.call();
+ // should complete, without exceptions
+ task.call();
+ }
}
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) {
--- a/langtools/test/tools/javac/T6395974.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6395974.java Mon Nov 03 10:11:10 2014 -0800
@@ -44,24 +44,25 @@
String testSrc = System.getProperty("test.src");
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- Iterable<?extends JavaFileObject> f =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self + ".java")));
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ Iterable<?extends JavaFileObject> f =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self + ".java")));
- PrintWriter out = new PrintWriter(System.err, true);
+ PrintWriter out = new PrintWriter(System.err, true);
- JavacTaskImpl task = (JavacTaskImpl) tool.getTask(out,
- fm,
- null,
- Arrays.asList("-processor",
- "Foo.java"),
- null,
- f);
+ JavacTaskImpl task = (JavacTaskImpl) tool.getTask(out,
+ fm,
+ null,
+ Arrays.asList("-processor",
+ "Foo.java"),
+ null,
+ f);
- MyTaskListener tl = new MyTaskListener();
- task.setTaskListener(tl);
+ MyTaskListener tl = new MyTaskListener();
+ task.setTaskListener(tl);
- task.call();
+ task.call();
+ }
}
static class MyTaskListener implements TaskListener {
--- a/langtools/test/tools/javac/T6397044.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6397044.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,14 +42,15 @@
String srcDir = System.getProperty("test.src", ".");
String self = T6397044.class.getName();
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files
- = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcDir, self + ".java")));
- JavacTask task = tool.getTask(null, fm, null, null, null, files);
- Iterable<? extends CompilationUnitTree> trees = task.parse();
- Checker checker = new Checker();
- for (CompilationUnitTree tree: trees)
- checker.check(tree);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files
+ = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcDir, self + ".java")));
+ JavacTask task = tool.getTask(null, fm, null, null, null, files);
+ Iterable<? extends CompilationUnitTree> trees = task.parse();
+ Checker checker = new Checker();
+ for (CompilationUnitTree tree: trees)
+ checker.check(tree);
+ }
}
public int x_public;
--- a/langtools/test/tools/javac/T6397286.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6397286.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,29 +40,30 @@
String self = T6397286.class.getName();
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
- JavacTask task = tool.getTask(null, fm, null, null, null, files);
- task.setTaskListener(new TaskListener() {
- public void started(TaskEvent e) {
- throw new TaskEventError(e);
- }
- public void finished(TaskEvent e) {
+ JavacTask task = tool.getTask(null, fm, null, null, null, files);
+ task.setTaskListener(new TaskListener() {
+ public void started(TaskEvent e) {
+ throw new TaskEventError(e);
+ }
+ public void finished(TaskEvent e) {
+ }
+ });
+
+ try {
+ task.call();
+ throw new AssertionError("no exception thrown");
+ } catch (RuntimeException e) {
+ if (e.getCause() instanceof TaskEventError) {
+ TaskEventError tee = (TaskEventError) e.getCause();
+ System.err.println("Exception thrown for " + tee.event + " as expected");
+ } else {
+ e.printStackTrace();
+ throw new AssertionError("TaskEventError not thrown");
}
- });
-
- try {
- task.call();
- throw new AssertionError("no exception thrown");
- } catch (RuntimeException e) {
- if (e.getCause() instanceof TaskEventError) {
- TaskEventError tee = (TaskEventError) e.getCause();
- System.err.println("Exception thrown for " + tee.event + " as expected");
- } else {
- e.printStackTrace();
- throw new AssertionError("TaskEventError not thrown");
}
}
}
--- a/langtools/test/tools/javac/T6403466.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6403466.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -51,24 +51,25 @@
public static void main(String[] args) throws IOException {
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
+
+ Iterable<String> options = Arrays.asList("-processorpath", testClassDir,
+ "-processor", self,
+ "-s", ".",
+ "-d", ".");
+ JavacTask task = tool.getTask(out, fm, null, options, null, files);
- Iterable<String> options = Arrays.asList("-processorpath", testClassDir,
- "-processor", self,
- "-s", ".",
- "-d", ".");
- JavacTask task = tool.getTask(out, fm, null, options, null, files);
+ VerifyingTaskListener vtl = new VerifyingTaskListener(new File(testSrcDir, self + ".out"));
+ task.setTaskListener(vtl);
- VerifyingTaskListener vtl = new VerifyingTaskListener(new File(testSrcDir, self + ".out"));
- task.setTaskListener(vtl);
+ if (!task.call())
+ throw new AssertionError("compilation failed");
- if (!task.call())
- throw new AssertionError("compilation failed");
-
- if (vtl.iter.hasNext() || vtl.errors)
- throw new AssertionError("comparison against golden file failed.");
+ if (vtl.iter.hasNext() || vtl.errors)
+ throw new AssertionError("comparison against golden file failed.");
+ }
}
public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
--- a/langtools/test/tools/javac/T6406771.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6406771.java Mon Nov 03 10:11:10 2014 -0800
@@ -33,21 +33,22 @@
// White-space after this point does not matter
- public static void main(String[] args) {
+ public static void main(String[] args) throws IOException {
String self = T6406771.class.getName();
String testSrc = System.getProperty("test.src");
String testClasses = System.getProperty("test.classes");
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next();
- List<String> opts = Arrays.asList("-d", ".", "-processorpath", testClasses, "-processor", self, "-proc:only");
+ List<String> opts = Arrays.asList("-d", ".", "-processorpath", testClasses, "-processor", self, "-proc:only");
- JavacTask task = tool.getTask(null, fm, null, opts, null, Arrays.asList(f));
+ JavacTask task = tool.getTask(null, fm, null, opts, null, Arrays.asList(f));
- if (!task.call())
- throw new AssertionError("failed");
+ if (!task.call())
+ throw new AssertionError("failed");
+ }
}
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment rEnv) {
--- a/langtools/test/tools/javac/T6407066.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6407066.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -37,20 +37,21 @@
String testClasses = System.getProperty("test.classes", ".");
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager jfm = tool.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager jfm = tool.getStandardFileManager(null, null, null)) {
- List<File> path = new ArrayList<File>();
- path.add(new File("BadDirectory"));
- path.add(new File(testSrc));
- path.add(new File("BadFile.jar"));
+ List<File> path = new ArrayList<File>();
+ path.add(new File("BadDirectory"));
+ path.add(new File(testSrc));
+ path.add(new File("BadFile.jar"));
- jfm.setLocation(StandardLocation.SOURCE_PATH, path);
+ jfm.setLocation(StandardLocation.SOURCE_PATH, path);
- List<File> path2 = new ArrayList<File>();
- for (File f: jfm.getLocation(StandardLocation.SOURCE_PATH))
- path2.add(f);
+ List<File> path2 = new ArrayList<File>();
+ for (File f: jfm.getLocation(StandardLocation.SOURCE_PATH))
+ path2.add(f);
- if (!path.equals(path2))
- throw new AssertionError("path not preserved");
+ if (!path.equals(path2))
+ throw new AssertionError("path not preserved");
+ }
}
}
--- a/langtools/test/tools/javac/T6410706.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6410706.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,21 +44,22 @@
String testClasses = System.getProperty("test.classes", ".");
JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener();
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(testClasses)));
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6410706.class.getName()+".java")));
- JavacTask task = tool.getTask(null, fm, dl, null, null, files);
- task.parse();
- task.analyze();
- task.generate();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(testClasses)));
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6410706.class.getName()+".java")));
+ JavacTask task = tool.getTask(null, fm, dl, null, null, files);
+ task.parse();
+ task.analyze();
+ task.generate();
- // expect 2 notes:
- // Note: T6410706.java uses or overrides a deprecated API.
- // Note: Recompile with -Xlint:deprecation for details.
+ // expect 2 notes:
+ // Note: T6410706.java uses or overrides a deprecated API.
+ // Note: Recompile with -Xlint:deprecation for details.
- if (dl.notes != 2)
- throw new AssertionError(dl.notes + " notes given");
+ if (dl.notes != 2)
+ throw new AssertionError(dl.notes + " notes given");
+ }
}
private static class MyDiagListener implements DiagnosticListener<JavaFileObject>
--- a/langtools/test/tools/javac/T6458823/T6458823.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6458823/T6458823.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,33 +55,34 @@
}
DiagnosticCollector<JavaFileObject> diagColl =
new DiagnosticCollector<JavaFileObject>();
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
- List<String> options = new ArrayList<String>();
- options.add("-processor");
- options.add("MyProcessor");
- options.add("-proc:only");
- List<File> files = new ArrayList<File>();
- files.add(new File(T6458823.class.getResource("TestClass.java").toURI()));
- final CompilationTask task = compiler.getTask(null, fm, diagColl,
- options, null, fm.getJavaFileObjectsFromFiles(files));
- task.call();
- int diagCount = 0;
- for (Diagnostic<? extends JavaFileObject> diag : diagColl.getDiagnostics()) {
- if (diag.getKind() != Diagnostic.Kind.WARNING) {
- throw new AssertionError("Only warnings expected");
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ List<String> options = new ArrayList<String>();
+ options.add("-processor");
+ options.add("MyProcessor");
+ options.add("-proc:only");
+ List<File> files = new ArrayList<File>();
+ files.add(new File(T6458823.class.getResource("TestClass.java").toURI()));
+ final CompilationTask task = compiler.getTask(null, fm, diagColl,
+ options, null, fm.getJavaFileObjectsFromFiles(files));
+ task.call();
+ int diagCount = 0;
+ for (Diagnostic<? extends JavaFileObject> diag : diagColl.getDiagnostics()) {
+ if (diag.getKind() != Diagnostic.Kind.WARNING) {
+ throw new AssertionError("Only warnings expected");
+ }
+ System.out.println(diag);
+ if (diag.getPosition() == Diagnostic.NOPOS) {
+ throw new AssertionError("No position info in message");
+ }
+ if (diag.getSource() == null) {
+ throw new AssertionError("No source info in message");
+ }
+ diagCount++;
}
- System.out.println(diag);
- if (diag.getPosition() == Diagnostic.NOPOS) {
- throw new AssertionError("No position info in message");
+ if (diagCount != 2) {
+ throw new AssertionError("unexpected number of warnings: " +
+ diagCount + ", expected: 2");
}
- if (diag.getSource() == null) {
- throw new AssertionError("No source info in message");
- }
- diagCount++;
- }
- if (diagCount != 2) {
- throw new AssertionError("unexpected number of warnings: " +
- diagCount + ", expected: 2");
}
}
}
--- a/langtools/test/tools/javac/T6665791.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6665791.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,29 +47,30 @@
write(test_java, test);
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager manager =
- compiler.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> units = manager.getJavaFileObjects(test_java);
- final StringWriter sw = new StringWriter();
- JavacTask task = (JavacTask) compiler.getTask(sw, manager, null, null,
- null, units);
+ try (StandardJavaFileManager manager =
+ compiler.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> units = manager.getJavaFileObjects(test_java);
+ final StringWriter sw = new StringWriter();
+ JavacTask task = (JavacTask) compiler.getTask(sw, manager, null, null,
+ null, units);
- new TreeScanner<Boolean, Void>() {
- @Override
- public Boolean visitClass(ClassTree arg0, Void arg1) {
- sw.write(arg0.toString());
- return super.visitClass(arg0, arg1);
- }
- }.scan(task.parse(), null);
+ new TreeScanner<Boolean, Void>() {
+ @Override
+ public Boolean visitClass(ClassTree arg0, Void arg1) {
+ sw.write(arg0.toString());
+ return super.visitClass(arg0, arg1);
+ }
+ }.scan(task.parse(), null);
- System.out.println("output:");
- System.out.println(sw.toString());
- String found = sw.toString().replaceAll("\\s+", " ").trim();
- String expect = test.replaceAll("\\s+", " ").trim();
- if (!expect.equals(found)) {
- System.out.println("expect: " + expect);
- System.out.println("found: " + found);
- throw new Exception("unexpected output");
+ System.out.println("output:");
+ System.out.println(sw.toString());
+ String found = sw.toString().replaceAll("\\s+", " ").trim();
+ String expect = test.replaceAll("\\s+", " ").trim();
+ if (!expect.equals(found)) {
+ System.out.println("expect: " + expect);
+ System.out.println("found: " + found);
+ throw new Exception("unexpected output");
+ }
}
}
--- a/langtools/test/tools/javac/T6705935.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6705935.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, 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,46 +45,47 @@
java_home = java_home.getParentFile();
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
- //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));
+ try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));
+
+ for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
+ "java.lang",
+ Collections.singleton(JavaFileObject.Kind.CLASS),
+ false)) {
+ test++;
- for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
- "java.lang",
- Collections.singleton(JavaFileObject.Kind.CLASS),
- false)) {
- test++;
+ if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
+ System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
+ skip++;
+ continue;
+ }
- if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
- System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
- skip++;
- continue;
+ //System.err.println(fo.getName());
+ String p = fo.getName();
+ int bra = p.indexOf("(");
+ int ket = p.indexOf(")");
+ //System.err.println(bra + "," + ket + "," + p.length());
+ if (bra == -1 || ket != p.length() -1)
+ throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
+ String part1 = p.substring(0, bra);
+ String part2 = p.substring(bra + 1, ket);
+ //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
+ if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
+ throw new Exception("bad path: " + p);
+
}
- //System.err.println(fo.getName());
- String p = fo.getName();
- int bra = p.indexOf("(");
- int ket = p.indexOf(")");
- //System.err.println(bra + "," + ket + "," + p.length());
- if (bra == -1 || ket != p.length() -1)
- throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
- String part1 = p.substring(0, bra);
- String part2 = p.substring(bra + 1, ket);
- //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
- if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
- throw new Exception("bad path: " + p);
+ if (test == 0)
+ throw new Exception("no files found");
- }
-
- if (test == 0)
- throw new Exception("no files found");
+ if (skip == 0)
+ System.out.println(test + " files found");
+ else
+ System.out.println(test + " files found, " + skip + " files skipped");
- if (skip == 0)
- System.out.println(test + " files found");
- else
- System.out.println(test + " files found, " + skip + " files skipped");
-
- if (test == skip)
- System.out.println("Warning: all files skipped; no platform classes found in zip files.");
+ if (test == skip)
+ System.out.println("Warning: all files skipped; no platform classes found in zip files.");
+ }
}
private <T> List<T> asList(Iterable<? extends T> items) {
--- a/langtools/test/tools/javac/T6900149.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6900149.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -37,14 +37,15 @@
DiagnosticCollector<JavaFileObject> diag =
new DiagnosticCollector<JavaFileObject>();
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm =
- compiler.getStandardFileManager(null, null, null);
- File emptyFile = createTempFile("Empty.java");
- File[] files = new File[] { emptyFile, emptyFile };
- CompilationTask task = compiler.getTask(null, fm, diag,
- null, null, fm.getJavaFileObjects(files));
- if (! task.call()) {
- throw new AssertionError("compilation failed");
+ try (StandardJavaFileManager fm =
+ compiler.getStandardFileManager(null, null, null)) {
+ File emptyFile = createTempFile("Empty.java");
+ File[] files = new File[] { emptyFile, emptyFile };
+ CompilationTask task = compiler.getTask(null, fm, diag,
+ null, null, fm.getJavaFileObjects(files));
+ if (! task.call()) {
+ throw new AssertionError("compilation failed");
+ }
}
}
--- a/langtools/test/tools/javac/T6956462/T6956462.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6956462/T6956462.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,14 +44,15 @@
if (compiler == null) {
throw new RuntimeException("can't get javax.tools.JavaCompiler!");
}
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
- List<File> files = new ArrayList<File>();
- files.add(new File(T6956462.class.getResource("TestClass.java").toURI()));
- final CompilationTask task = compiler.getTask(null, fm, null,
- null, null, fm.getJavaFileObjectsFromFiles(files));
- JavacTask javacTask = (JavacTask) task;
- for (CompilationUnitTree cu : javacTask.parse()) {
- cu.accept(new MyVisitor(javacTask), null);
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ List<File> files = new ArrayList<File>();
+ files.add(new File(T6956462.class.getResource("TestClass.java").toURI()));
+ final CompilationTask task = compiler.getTask(null, fm, null,
+ null, null, fm.getJavaFileObjectsFromFiles(files));
+ JavacTask javacTask = (JavacTask) task;
+ for (CompilationUnitTree cu : javacTask.parse()) {
+ cu.accept(new MyVisitor(javacTask), null);
+ }
}
}
--- a/langtools/test/tools/javac/T6956638.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T6956638.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,34 +96,35 @@
List<String> compileOptions = Arrays.asList("-d", classesDir.getPath());
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<JavaFileObject>();
- StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnosticCollector, null, null);
- Iterable<? extends JavaFileObject> sourceFileObjects = fileManager.getJavaFileObjects(sourceFiles);
- System.err.println("1- javac given java source JavaFileObjects " + sourceFileObjects);
- JavaCompiler.CompilationTask task = compiler.getTask(compilerOutputStream, fileManager, null, compileOptions, null, sourceFileObjects);
- JavacTask javacTask = (JavacTask) task;
+ try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnosticCollector, null, null)) {
+ Iterable<? extends JavaFileObject> sourceFileObjects = fileManager.getJavaFileObjects(sourceFiles);
+ System.err.println("1- javac given java source JavaFileObjects " + sourceFileObjects);
+ JavaCompiler.CompilationTask task = compiler.getTask(compilerOutputStream, fileManager, null, compileOptions, null, sourceFileObjects);
+ JavacTask javacTask = (JavacTask) task;
- Iterable<? extends CompilationUnitTree> parsedTrees = javacTask.parse();
- Iterable<? extends Element> analyzedTrees = javacTask.analyze();
- Iterable<? extends JavaFileObject> generatedFiles = javacTask.generate();
+ Iterable<? extends CompilationUnitTree> parsedTrees = javacTask.parse();
+ Iterable<? extends Element> analyzedTrees = javacTask.analyze();
+ Iterable<? extends JavaFileObject> generatedFiles = javacTask.generate();
- System.err.println("2- parsed:" + size(parsedTrees) + " analysed:" + size(analyzedTrees) + " generated:" + size(generatedFiles));
+ System.err.println("2- parsed:" + size(parsedTrees) + " analysed:" + size(analyzedTrees) + " generated:" + size(generatedFiles));
- System.err.print("3-");
- for (JavaFileObject f : generatedFiles)
- System.err.print(" " + f);
- System.err.println("");
+ System.err.print("3-");
+ for (JavaFileObject f : generatedFiles)
+ System.err.print(" " + f);
+ System.err.println("");
- System.err.print("5-");
- for (File f : classesDir.listFiles())
- System.err.print(" " + f);
- System.err.println("");
+ System.err.print("5-");
+ for (File f : classesDir.listFiles())
+ System.err.print(" " + f);
+ System.err.println("");
- System.err.println("----");
- System.err.println(compilerOutputStream.toString());
+ System.err.println("----");
+ System.err.println(compilerOutputStream.toString());
- if (size(generatedFiles) != size(parsedTrees)) {
- throw new Exception("wrong number of files generated: " + size(generatedFiles)
- + " expected: " + size(parsedTrees));
+ if (size(generatedFiles) != size(parsedTrees)) {
+ throw new Exception("wrong number of files generated: " + size(generatedFiles)
+ + " expected: " + size(parsedTrees));
+ }
}
}
--- a/langtools/test/tools/javac/T7142672/Bug.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T7142672/Bug.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -58,28 +58,29 @@
}
};
- StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null);
+ try (StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null)) {
- List<String> opts = new ArrayList<String>();
- opts.add("-proc:only");
- opts.add("-processor");
- opts.add("AnnoProcessor");
+ List<String> opts = new ArrayList<String>();
+ opts.add("-proc:only");
+ opts.add("-processor");
+ opts.add("AnnoProcessor");
- boolean xxx;
+ boolean xxx;
- System.err.println("\n-- " + name);
- task2 = javac.getTask(pw, sjfm, dl, opts, Arrays.asList(name), null);
- xxx = task2.call();
+ System.err.println("\n-- " + name);
+ task2 = javac.getTask(pw, sjfm, dl, opts, Arrays.asList(name), null);
+ xxx = task2.call();
- String out = sw.toString();
- System.err.println(out);
- if (out.contains("Assert")) {
- System.err.println("--Failed: Assertion failure");
- System.exit(1);
- }
- if (!out.contains(expectedMsg)) {
- System.err.println("--Failed: Expected diagnostic not found");
- System.exit(1);
+ String out = sw.toString();
+ System.err.println(out);
+ if (out.contains("Assert")) {
+ System.err.println("--Failed: Assertion failure");
+ System.exit(1);
+ }
+ if (!out.contains(expectedMsg)) {
+ System.err.println("--Failed: Expected diagnostic not found");
+ System.exit(1);
+ }
}
}
}
--- a/langtools/test/tools/javac/T7159016.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T7159016.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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 javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import javax.tools.JavaCompiler;
+import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
public class T7159016 {
@@ -58,11 +59,13 @@
w.close();
}
JavaCompiler jc = ToolProvider.getSystemJavaCompiler();
- JavaCompiler.CompilationTask task = jc.getTask(null, null, null, null, null,
- jc.getStandardFileManager(null, null, null).getJavaFileObjects(src));
- task.setProcessors(Collections.singleton(new Proc()));
- if (!task.call()) {
- throw new Error("Test failed");
+ try (StandardJavaFileManager fm = jc.getStandardFileManager(null, null, null)) {
+ JavaCompiler.CompilationTask task = jc.getTask(null, fm, null, null, null,
+ fm.getJavaFileObjects(src));
+ task.setProcessors(Collections.singleton(new Proc()));
+ if (!task.call()) {
+ throw new Error("Test failed");
+ }
}
}
--- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -179,18 +179,19 @@
ConstantPoolException,
InvalidDescriptor {
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- JavaFileManager.Location location =
- StandardLocation.locationFor(resource.getPath());
- fm.setLocation(location, com.sun.tools.javac.util.List.of(
- new File(resource.getPath())));
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ JavaFileManager.Location location =
+ StandardLocation.locationFor(resource.getPath());
+ fm.setLocation(location, com.sun.tools.javac.util.List.of(
+ new File(resource.getPath())));
- for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
- String className = fm.inferBinaryName(location, file);
- int index = className.lastIndexOf('.');
- String pckName = index == -1 ? "" : className.substring(0, index);
- if (shouldAnalyzePackage(pckName)) {
- analyzeClassFile(ClassFile.read(file.openInputStream()));
+ for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
+ String className = fm.inferBinaryName(location, file);
+ int index = className.lastIndexOf('.');
+ String pckName = index == -1 ? "" : className.substring(0, index);
+ if (shouldAnalyzePackage(pckName)) {
+ analyzeClassFile(ClassFile.read(file.openInputStream()));
+ }
}
}
}
--- a/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -132,73 +132,74 @@
throws IOException {
Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg);
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> fos =
- fm.getJavaFileObjectsFromFiles(
- Arrays.asList(new File(System.getProperty("test.src"),
- this.getClass().getName() + ".java")));
- JavacTask task = (JavacTask) c.getTask(null, fm, null,
- Arrays.asList("-d", System.getProperty("user.dir")), null, fos);
+ try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> fos =
+ fm.getJavaFileObjectsFromFiles(
+ Arrays.asList(new File(System.getProperty("test.src"),
+ this.getClass().getName() + ".java")));
+ JavacTask task = (JavacTask) c.getTask(null, fm, null,
+ Arrays.asList("-d", System.getProperty("user.dir")), null, fos);
+
+ BasicJavacTask impl = (BasicJavacTask)task;
+ Context context = impl.getContext();
+ final Names names = Names.instance(context);
+
+ task.addTaskListener(new TaskListener() {
- BasicJavacTask impl = (BasicJavacTask)task;
- Context context = impl.getContext();
- final Names names = Names.instance(context);
+ @Override
+ public void started(TaskEvent e) {}
- task.addTaskListener(new TaskListener() {
+ @Override
+ public void finished(TaskEvent e) {
+ class TheTreeScanner extends TreeScanner {
+ boolean foundAndCorrect = false;
- @Override
- public void started(TaskEvent e) {}
+ @Override
+ public void visitMethodDef(JCTree.JCMethodDecl tree) {
+ ClassSymbol clazz = (ClassSymbol)tree.sym.owner;
+ if (clazz.owner.name.toString().equals(classOwnerName) &&
+ tree.sym.name == names.init) {
- @Override
- public void finished(TaskEvent e) {
- class TheTreeScanner extends TreeScanner {
- boolean foundAndCorrect = false;
+ int currentParamPos = 0;
+ int paramArrayIndex = 0;
- @Override
- public void visitMethodDef(JCTree.JCMethodDecl tree) {
- ClassSymbol clazz = (ClassSymbol)tree.sym.owner;
- if (clazz.owner.name.toString().equals(classOwnerName) &&
- tree.sym.name == names.init) {
-
- int currentParamPos = 0;
- int paramArrayIndex = 0;
+ List<VarSymbol> params = tree.sym.params;
+ while (params.nonEmpty() && paramArrayIndex < paramsToCheck.size()) {
+ VarSymbol param = params.head;
+ if (currentParamPos == paramsToCheck.get(paramArrayIndex)) {
+ if (!param.name.toString()
+ .equals(paramNames.get(paramArrayIndex))) {
+ error(paramNameNotCopiedAssertionMsg);
+ }
+ paramArrayIndex++;
+ }
+ currentParamPos++;
+ params = params.tail;
+ }
+ foundAndCorrect = paramArrayIndex >= paramsToCheck.size();
+ }
+ super.visitMethodDef(tree);
+ }
+ }
- List<VarSymbol> params = tree.sym.params;
- while (params.nonEmpty() && paramArrayIndex < paramsToCheck.size()) {
- VarSymbol param = params.head;
- if (currentParamPos == paramsToCheck.get(paramArrayIndex)) {
- if (!param.name.toString()
- .equals(paramNames.get(paramArrayIndex))) {
- error(paramNameNotCopiedAssertionMsg);
- }
- paramArrayIndex++;
- }
- currentParamPos++;
- params = params.tail;
- }
- foundAndCorrect = paramArrayIndex >= paramsToCheck.size();
+ if (e.getKind() == TaskEvent.Kind.ANALYZE) {
+ CompilationUnitTree compUnitTree = e.getCompilationUnit();
+ boolean foundAndCorrect = false;
+ for (Tree tree : compUnitTree.getTypeDecls()) {
+ TheTreeScanner scanner = new TheTreeScanner();
+ scanner.scan((JCTree) tree);
+ foundAndCorrect = foundAndCorrect | scanner.foundAndCorrect;
}
- super.visitMethodDef(tree);
+ if (!foundAndCorrect) {
+ error(seekMethodNotFound);
+ }
}
}
+ });
- if (e.getKind() == TaskEvent.Kind.ANALYZE) {
- CompilationUnitTree compUnitTree = e.getCompilationUnit();
- boolean foundAndCorrect = false;
- for (Tree tree : compUnitTree.getTypeDecls()) {
- TheTreeScanner scanner = new TheTreeScanner();
- scanner.scan((JCTree) tree);
- foundAndCorrect = foundAndCorrect | scanner.foundAndCorrect;
- }
- if (!foundAndCorrect) {
- error(seekMethodNotFound);
- }
- }
+ if (!task.call()) {
+ error(compilationFailed);
}
- });
-
- if (!task.call()) {
- error(compilationFailed);
}
}
--- a/langtools/test/tools/javac/TryWithResources/InterruptedExceptionTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/TryWithResources/InterruptedExceptionTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -117,16 +117,17 @@
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (XlintOption xlint : XlintOption.values()) {
- for (SuppressLevel suppress_decl : SuppressLevel.values()) {
- for (SuppressLevel suppress_use : SuppressLevel.values()) {
- for (ClassKind ck : ClassKind.values()) {
- for (ExceptionKind ek_decl : ExceptionKind.values()) {
- for (ExceptionKind ek_use : ExceptionKind.values()) {
- new InterruptedExceptionTest(xlint, suppress_decl,
- suppress_use, ck, ek_decl, ek_use).run(comp, fm);
+ for (XlintOption xlint : XlintOption.values()) {
+ for (SuppressLevel suppress_decl : SuppressLevel.values()) {
+ for (SuppressLevel suppress_use : SuppressLevel.values()) {
+ for (ClassKind ck : ClassKind.values()) {
+ for (ExceptionKind ek_decl : ExceptionKind.values()) {
+ for (ExceptionKind ek_use : ExceptionKind.values()) {
+ new InterruptedExceptionTest(xlint, suppress_decl,
+ suppress_use, ck, ek_decl, ek_use).run(comp, fm);
+ }
}
}
}
--- a/langtools/test/tools/javac/TryWithResources/UnusedResourcesTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/TryWithResources/UnusedResourcesTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -161,20 +161,24 @@
}
public static void main(String... args) throws Exception {
- for (XlintOption xlint : XlintOption.values()) {
- for (SuppressLevel suppressLevel : SuppressLevel.values()) {
- for (ResourceUsage usage1 : ResourceUsage.values()) {
- for (ResourceUsage usage2 : ResourceUsage.values()) {
- for (ResourceUsage usage3 : ResourceUsage.values()) {
- test(xlint,
- suppressLevel,
- usage1,
- usage2,
- usage3);
+ try {
+ for (XlintOption xlint : XlintOption.values()) {
+ for (SuppressLevel suppressLevel : SuppressLevel.values()) {
+ for (ResourceUsage usage1 : ResourceUsage.values()) {
+ for (ResourceUsage usage2 : ResourceUsage.values()) {
+ for (ResourceUsage usage3 : ResourceUsage.values()) {
+ test(xlint,
+ suppressLevel,
+ usage1,
+ usage2,
+ usage3);
+ }
}
}
}
}
+ } finally {
+ fm.close();
}
}
--- a/langtools/test/tools/javac/annotations/neg/8022765/VerifyAnnotationsAttributed.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/annotations/neg/8022765/VerifyAnnotationsAttributed.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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,38 +41,39 @@
File testSrc = new File(System.getProperty("test.src"));
File testFile = new File(testSrc, args[0]);
if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source");
- JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
- JavacTask task = JavacTool.create().getTask(null,
- fm,
- null,
- Collections.<String>emptyList(),
- null,
- fm.getJavaFileObjects(testFile));
- final Trees trees = Trees.instance(task);
- final CompilationUnitTree cut = task.parse().iterator().next();
- task.analyze();
+ try (JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null)) {
+ JavacTask task = JavacTool.create().getTask(null,
+ fm,
+ null,
+ Collections.<String>emptyList(),
+ null,
+ fm.getJavaFileObjects(testFile));
+ final Trees trees = Trees.instance(task);
+ final CompilationUnitTree cut = task.parse().iterator().next();
+ task.analyze();
- //ensure all the annotation attributes are annotated meaningfully
- //all the attributes in the test file should contain either an identifier
- //or a select, so only checking those for a reasonable Element/Symbol.
- new TreePathScanner<Void, Void>() {
- @Override
- public Void visitIdentifier(IdentifierTree node, Void p) {
- verifyAttributedMeaningfully();
- return super.visitIdentifier(node, p);
- }
- @Override
- public Void visitMemberSelect(MemberSelectTree node, Void p) {
- verifyAttributedMeaningfully();
- return super.visitMemberSelect(node, p);
- }
- private void verifyAttributedMeaningfully() {
- Element el = trees.getElement(getCurrentPath());
+ //ensure all the annotation attributes are annotated meaningfully
+ //all the attributes in the test file should contain either an identifier
+ //or a select, so only checking those for a reasonable Element/Symbol.
+ new TreePathScanner<Void, Void>() {
+ @Override
+ public Void visitIdentifier(IdentifierTree node, Void p) {
+ verifyAttributedMeaningfully();
+ return super.visitIdentifier(node, p);
+ }
+ @Override
+ public Void visitMemberSelect(MemberSelectTree node, Void p) {
+ verifyAttributedMeaningfully();
+ return super.visitMemberSelect(node, p);
+ }
+ private void verifyAttributedMeaningfully() {
+ Element el = trees.getElement(getCurrentPath());
- if (el == null || el.getKind() == ElementKind.OTHER) {
- throw new IllegalStateException("Not attributed properly: " + getCurrentPath().getParentPath().getLeaf());
+ if (el == null || el.getKind() == ElementKind.OTHER) {
+ throw new IllegalStateException("Not attributed properly: " + getCurrentPath().getParentPath().getLeaf());
+ }
}
- }
- }.scan(cut, null);
+ }.scan(cut, null);
+ }
}
}
--- a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -102,29 +102,31 @@
throw new RuntimeException("can't get javax.tools.JavaCompiler!");
}
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
-
- // Assuming filesCount can maximum be 2 and if true, one file is package-info.java
- if (isPkgInfoPresent(files)) {
- JavacTask task = (JavacTask) compiler.getTask(null, fm, diagnostics, null, null, files);
- try {
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
- task.generate();
- } catch (IOException ioe) {
- throw new RuntimeException("Compilation failed for package level tests", ioe);
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ // Assuming filesCount can maximum be 2 and if true, one file is package-info.java
+ if (isPkgInfoPresent(files)) {
+ JavacTask task = (JavacTask) compiler.getTask(null, fm, diagnostics, null, null, files);
+ try {
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
+ task.generate();
+ } catch (IOException ioe) {
+ throw new RuntimeException("Compilation failed for package level tests", ioe);
+ }
+ int err = 0;
+ for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
+ if(d.getKind() == Diagnostic.Kind.ERROR) {
+ err++;
+ }
+ }
+ ok = (err == 0);
+ } else {
+ CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
+ ok = task.call();
}
- int err = 0;
- for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
- if(d.getKind() == Diagnostic.Kind.ERROR) {
- err++;
- }
- }
- ok = (err == 0);
- } else {
- CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
- ok = task.call();
+ return ok;
+ } catch (IOException e) {
+ throw new Error(e);
}
- return ok;
}
static private boolean isPkgInfoPresent(Iterable<? extends JavaFileObject> files) {
--- a/langtools/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,18 +46,18 @@
public static void main(String[] args) throws Exception {
PrintWriter out = new PrintWriter(System.out, true);
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File testSrc = new File(System.getProperty("test.src"));
- Iterable<? extends JavaFileObject> f =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "AnnotatedArrayOrder.java")));
- JavacTask task = tool.getTask(out, fm, null, null, null, f);
- Iterable<? extends CompilationUnitTree> trees = task.parse();
- out.flush();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File testSrc = new File(System.getProperty("test.src"));
+ Iterable<? extends JavaFileObject> f =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "AnnotatedArrayOrder.java")));
+ JavacTask task = tool.getTask(out, fm, null, null, null, f);
+ Iterable<? extends CompilationUnitTree> trees = task.parse();
+ out.flush();
- Scanner s = new Scanner();
- for (CompilationUnitTree t: trees)
- s.scan(t, null);
-
+ Scanner s = new Scanner();
+ for (CompilationUnitTree t: trees)
+ s.scan(t, null);
+ }
}
private static class Scanner extends TreeScanner<Void,Void> {
--- a/langtools/test/tools/javac/annotations/typeAnnotations/api/ArrayCreationTree.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/api/ArrayCreationTree.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,18 +48,18 @@
public static void main(String[] args) throws Exception {
PrintWriter out = new PrintWriter(System.out, true);
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File testSrc = new File(System.getProperty("test.src"));
- Iterable<? extends JavaFileObject> f =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayCreationTree.java")));
- JavacTask task = tool.getTask(out, fm, null, null, null, f);
- Iterable<? extends CompilationUnitTree> trees = task.parse();
- out.flush();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File testSrc = new File(System.getProperty("test.src"));
+ Iterable<? extends JavaFileObject> f =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayCreationTree.java")));
+ JavacTask task = tool.getTask(out, fm, null, null, null, f);
+ Iterable<? extends CompilationUnitTree> trees = task.parse();
+ out.flush();
- Scanner s = new Scanner();
- for (CompilationUnitTree t: trees)
- s.scan(t, null);
-
+ Scanner s = new Scanner();
+ for (CompilationUnitTree t: trees)
+ s.scan(t, null);
+ }
}
private static class Scanner extends TreeScanner<Void,Void> {
--- a/langtools/test/tools/javac/annotations/typeAnnotations/api/ArrayPositionConsistency.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/api/ArrayPositionConsistency.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,18 +47,18 @@
public static void main(String[] args) throws Exception {
PrintWriter out = new PrintWriter(System.out, true);
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File testSrc = new File(System.getProperty("test.src"));
- Iterable<? extends JavaFileObject> f =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayPositionConsistency.java")));
- JavacTask task = tool.getTask(out, fm, null, null, null, f);
- Iterable<? extends CompilationUnitTree> trees = task.parse();
- out.flush();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File testSrc = new File(System.getProperty("test.src"));
+ Iterable<? extends JavaFileObject> f =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayPositionConsistency.java")));
+ JavacTask task = tool.getTask(out, fm, null, null, null, f);
+ Iterable<? extends CompilationUnitTree> trees = task.parse();
+ out.flush();
- Scanner s = new Scanner();
- for (CompilationUnitTree t: trees)
- s.scan(t, null);
-
+ Scanner s = new Scanner();
+ for (CompilationUnitTree t: trees)
+ s.scan(t, null);
+ }
}
private static class Scanner extends TreeScanner<Void,Void> {
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CheckErrorsForSource7.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CheckErrorsForSource7.java Mon Nov 03 10:11:10 2014 -0800
@@ -72,77 +72,78 @@
File testSrc = new File(System.getProperty("test.src"));
File testFile = new File(testSrc, args[0]);
if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source");
- JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+ try (JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null)) {
- //gather spans of the @TA annotations into typeAnnotationSpans:
- JavacTask task = JavacTool.create().getTask(null,
- fm,
- null,
- Collections.<String>emptyList(),
- null,
- fm.getJavaFileObjects(testFile));
- final Trees trees = Trees.instance(task);
- final CompilationUnitTree cut = task.parse().iterator().next();
- final List<int[]> typeAnnotationSpans = new ArrayList<>();
+ //gather spans of the @TA annotations into typeAnnotationSpans:
+ JavacTask task = JavacTool.create().getTask(null,
+ fm,
+ null,
+ Collections.<String>emptyList(),
+ null,
+ fm.getJavaFileObjects(testFile));
+ final Trees trees = Trees.instance(task);
+ final CompilationUnitTree cut = task.parse().iterator().next();
+ final List<int[]> typeAnnotationSpans = new ArrayList<>();
- new TreePathScanner<Void, Void>() {
- @Override
- public Void visitAnnotation(AnnotationTree node, Void p) {
- if (node.getAnnotationType().getKind() == Kind.IDENTIFIER &&
- ((IdentifierTree) node.getAnnotationType()).getName().contentEquals("TA")) {
- int start = (int) trees.getSourcePositions().getStartPosition(cut, node);
- int end = (int) trees.getSourcePositions().getEndPosition(cut, node);
- typeAnnotationSpans.add(new int[] {start, end});
+ new TreePathScanner<Void, Void>() {
+ @Override
+ public Void visitAnnotation(AnnotationTree node, Void p) {
+ if (node.getAnnotationType().getKind() == Kind.IDENTIFIER &&
+ ((IdentifierTree) node.getAnnotationType()).getName().contentEquals("TA")) {
+ int start = (int) trees.getSourcePositions().getStartPosition(cut, node);
+ int end = (int) trees.getSourcePositions().getEndPosition(cut, node);
+ typeAnnotationSpans.add(new int[] {start, end});
+ }
+ return null;
}
- return null;
- }
- }.scan(cut, null);
+ }.scan(cut, null);
- //sort the spans in the reverse order, to simplify removing them from the source:
- Collections.sort(typeAnnotationSpans, new Comparator<int[]>() {
- @Override
- public int compare(int[] o1, int[] o2) {
- return o2[0] - o1[0];
- }
- });
+ //sort the spans in the reverse order, to simplify removing them from the source:
+ Collections.sort(typeAnnotationSpans, new Comparator<int[]>() {
+ @Override
+ public int compare(int[] o1, int[] o2) {
+ return o2[0] - o1[0];
+ }
+ });
- //verify the errors are produce correctly:
- String originalSource = cut.getSourceFile().getCharContent(false).toString();
+ //verify the errors are produce correctly:
+ String originalSource = cut.getSourceFile().getCharContent(false).toString();
- for (int[] toKeep : typeAnnotationSpans) {
- //prepare updated source code by removing all the annotations except the toKeep one:
- String updated = originalSource;
+ for (int[] toKeep : typeAnnotationSpans) {
+ //prepare updated source code by removing all the annotations except the toKeep one:
+ String updated = originalSource;
- for (int[] span : typeAnnotationSpans) {
- if (span == toKeep) continue;
+ for (int[] span : typeAnnotationSpans) {
+ if (span == toKeep) continue;
- updated = updated.substring(0, span[0]) + updated.substring(span[1]);
- }
+ updated = updated.substring(0, span[0]) + updated.substring(span[1]);
+ }
- //parse and verify:
- JavaFileObject updatedFile = new TestFO(cut.getSourceFile().toUri(), updated);
- DiagnosticCollector<JavaFileObject> errors = new DiagnosticCollector<>();
- JavacTask task2 = JavacTool.create().getTask(null,
- fm,
- errors,
- Arrays.asList("-source", "7"),
- null,
- Arrays.asList(updatedFile));
- task2.parse();
+ //parse and verify:
+ JavaFileObject updatedFile = new TestFO(cut.getSourceFile().toUri(), updated);
+ DiagnosticCollector<JavaFileObject> errors = new DiagnosticCollector<>();
+ JavacTask task2 = JavacTool.create().getTask(null,
+ fm,
+ errors,
+ Arrays.asList("-source", "7"),
+ null,
+ Arrays.asList(updatedFile));
+ task2.parse();
+
+ boolean found = false;
- boolean found = false;
-
- for (Diagnostic<? extends JavaFileObject> d : errors.getDiagnostics()) {
- if (d.getKind() == Diagnostic.Kind.ERROR && EXPECTED_ERRORS.contains(d.getCode())) {
- if (found) {
- throw new IllegalStateException("More than one expected error found.");
+ for (Diagnostic<? extends JavaFileObject> d : errors.getDiagnostics()) {
+ if (d.getKind() == Diagnostic.Kind.ERROR && EXPECTED_ERRORS.contains(d.getCode())) {
+ if (found) {
+ throw new IllegalStateException("More than one expected error found.");
+ }
+ found = true;
}
- found = true;
}
+
+ if (!found)
+ throw new IllegalStateException("Did not produce proper errors for: " + updated);
}
-
- if (!found)
- throw new IllegalStateException("Did not produce proper errors for: " + updated);
}
}
--- a/langtools/test/tools/javac/api/6406133/T6406133.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6406133/T6406133.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, 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
@@ -106,6 +106,8 @@
}
public static void main(String... args) throws Exception {
- new T6406133().test();
+ try (T6406133 t = new T6406133()) {
+ t.test();
+ }
}
}
--- a/langtools/test/tools/javac/api/6410643/T6410643.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6410643/T6410643.java Mon Nov 03 10:11:10 2014 -0800
@@ -31,6 +31,7 @@
* @run main T6410643
*/
+import java.io.IOException;
import javax.tools.JavaFileObject;
import static java.util.Collections.singleton;
@@ -68,7 +69,10 @@
testGetTask(s, s, f);
System.err.println("Test result: PASSED");
}
- public static void main(String... args) {
- new T6410643().test(args);
+
+ public static void main(String... args) throws IOException {
+ try (T6410643 t = new T6410643()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6411310/T6411310.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6411310/T6411310.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -54,6 +54,8 @@
}
public static void main(String... args) throws IOException {
- new T6411310().test(args);
+ try (T6411310 t = new T6411310()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6411333/T6411333.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6411333/T6411333.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,10 @@
testRelativeUri("util/List.java", false);
testRelativeUri("/util/List.java", true);
}
- public static void main(String... args) {
- new T6411333().test(args);
+
+ public static void main(String... args) throws IOException {
+ try (T6411333 t = new T6411333()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6412656/T6412656.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6412656/T6412656.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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 @@
* @run main T6412656
*/
+import java.io.IOException;
import java.util.Set;
import java.util.Collections;
import javax.lang.model.element.TypeElement;
@@ -52,8 +53,10 @@
System.out.println("OK");
}
- public static void main(String... args) {
- new T6412656().test(args);
+ public static void main(String... args) throws IOException {
+ try (T6412656 t = new T6412656()) {
+ t.test(args);
+ }
}
@SupportedAnnotationTypes("*")
--- a/langtools/test/tools/javac/api/6415780/T6415780.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6415780/T6415780.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
* @run main T6415780
*/
+import java.io.IOException;
import static javax.tools.StandardLocation.CLASS_PATH;
public class T6415780 extends ToolTester {
@@ -39,8 +40,9 @@
System.out.println(fm.getClassLoader(CLASS_PATH).toString()); // null-check
}
- public static void main(String... args) {
- T6415780 tester = new T6415780();
- tester.test();
+ public static void main(String... args) throws IOException {
+ try (T6415780 tester = new T6415780()) {
+ tester.test();
+ }
}
}
--- a/langtools/test/tools/javac/api/6418694/T6418694.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6418694/T6418694.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
* @run main T6418694
*/
+import java.io.IOException;
import javax.tools.StandardLocation;
public class T6418694 extends ToolTester {
@@ -52,7 +53,9 @@
}
}
}
- public static void main(String... args) {
- new T6418694().test(args);
+ public static void main(String... args) throws IOException {
+ try (T6418694 t = new T6418694()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6420409/T6420409.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6420409/T6420409.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,21 +46,22 @@
public static void main(String... args) throws IOException {
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
- final StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- fm.setLocation(SOURCE_PATH, Arrays.asList(test_classes)); // switcheroo !!!
- fm.setLocation(CLASS_PATH, Arrays.asList(test_src));
- fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
- final Iterable<? extends JavaFileObject> compilationUnits =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(test_src, "T6420409.java")));
- tool.getTask(null,
- fm,
- null,
- Arrays.asList("-proc:none"),
- null,
- compilationUnits).call();
- test(fm.getLocation(CLASS_PATH), test_src, CLASS_PATH);
- test(fm.getLocation(SOURCE_PATH), test_classes, SOURCE_PATH);
- test(fm.getLocation(CLASS_OUTPUT), test_classes, CLASS_OUTPUT);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ fm.setLocation(SOURCE_PATH, Arrays.asList(test_classes)); // switcheroo !!!
+ fm.setLocation(CLASS_PATH, Arrays.asList(test_src));
+ fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
+ final Iterable<? extends JavaFileObject> compilationUnits =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(test_src, "T6420409.java")));
+ tool.getTask(null,
+ fm,
+ null,
+ Arrays.asList("-proc:none"),
+ null,
+ compilationUnits).call();
+ test(fm.getLocation(CLASS_PATH), test_src, CLASS_PATH);
+ test(fm.getLocation(SOURCE_PATH), test_classes, SOURCE_PATH);
+ test(fm.getLocation(CLASS_OUTPUT), test_classes, CLASS_OUTPUT);
+ }
}
static void test(Iterable<? extends File> path, File file, Location location) {
--- a/langtools/test/tools/javac/api/6420464/T6420464.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6420464/T6420464.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -38,15 +38,16 @@
public static void main(String... args) throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager mgr = compiler.getStandardFileManager(null, null, null);
- mgr.setLocation(StandardLocation.SOURCE_PATH, Collections.singleton(test_src));
- JavaFileObject f = mgr.getJavaFileForInput(StandardLocation.SOURCE_PATH,
- "T6420464",
- JavaFileObject.Kind.SOURCE);
- if (!f.isNameCompatible("T6420464", JavaFileObject.Kind.SOURCE))
- throw new AssertionError("isNameCompatible(SOURCE) fails on " + f.toUri());
- if (f.isNameCompatible("T6420464", JavaFileObject.Kind.OTHER))
- throw new AssertionError("isNameCompatible(OTHER) fails on " + f.toUri());
- System.out.println("OK");
+ try (StandardJavaFileManager mgr = compiler.getStandardFileManager(null, null, null)) {
+ mgr.setLocation(StandardLocation.SOURCE_PATH, Collections.singleton(test_src));
+ JavaFileObject f = mgr.getJavaFileForInput(StandardLocation.SOURCE_PATH,
+ "T6420464",
+ JavaFileObject.Kind.SOURCE);
+ if (!f.isNameCompatible("T6420464", JavaFileObject.Kind.SOURCE))
+ throw new AssertionError("isNameCompatible(SOURCE) fails on " + f.toUri());
+ if (f.isNameCompatible("T6420464", JavaFileObject.Kind.OTHER))
+ throw new AssertionError("isNameCompatible(OTHER) fails on " + f.toUri());
+ System.out.println("OK");
+ }
}
}
--- a/langtools/test/tools/javac/api/6421111/T6421111.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6421111/T6421111.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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.io.File;
+import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.Collections;
@@ -101,8 +102,10 @@
return SourceVersion.latest();
}
}
- public static void main(String... args) {
- new T6421111().test(args);
+ public static void main(String... args) throws IOException {
+ try (T6421111 t = new T6421111()) {
+ t.test(args);
+ }
}
public static AssertionError error(String format, Object... args) {
return new AssertionError(String.format(format, args));
--- a/langtools/test/tools/javac/api/6421756/T6421756.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6421756/T6421756.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
* @run main T6421756
*/
+import java.io.IOException;
import java.util.Collections;
public class T6421756 extends ToolTester {
@@ -44,7 +45,9 @@
System.out.println("OK: got expected error " + e.getLocalizedMessage());
}
}
- public static void main(String... args) {
- new T6421756().test(args);
+ public static void main(String... args) throws IOException {
+ try (T6421756 t = new T6421756()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6422215/T6422215.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6422215/T6422215.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,7 +46,9 @@
System.out.println("OK: caught expected exception: " + e.getLocalizedMessage());
}
}
- public static void main(String... args) {
- new T6422215().test(args);
+ public static void main(String... args) throws IOException {
+ try (T6422215 t = new T6422215()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6422327/T6422327.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6422327/T6422327.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
*/
import java.io.File;
+import java.io.IOException;
public class T6422327 extends ToolTester {
void test(String... args) {
@@ -43,7 +44,9 @@
System.err.println("OK, got expected exception: " + e.getLocalizedMessage());
}
}
- public static void main(String... args) {
- new T6422327().test(args);
+ public static void main(String... args) throws IOException {
+ try (T6422327 t = new T6422327()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6423003/T6423003.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6423003/T6423003.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
* @run main T6423003
*/
+import java.io.IOException;
import java.util.Arrays;
public class T6423003 extends ToolTester {
@@ -44,7 +45,9 @@
}
throw new AssertionError("Expected IllegalStateException not thrown");
}
- public static void main(String... args) {
- new T6423003().test(args);
+ public static void main(String... args) throws IOException {
+ try (T6423003 t = new T6423003()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6431257/T6431257.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6431257/T6431257.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,8 @@
}
public static void main(String... args) throws IOException {
- new T6431257().test(args);
+ try (T6431257 t = new T6431257()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6431435/T6431435.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6431435/T6431435.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,18 +39,19 @@
String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes", ".");
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
- fm.setLocation(StandardLocation.SOURCE_PATH, Arrays.asList(new File(testSrc)));
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
- new File(testSrc, "A.java")));
- JavacTask task = tool.getTask(null, fm, null, null, null, files);
- boolean ok = true;
- ok &= check("parse", task.parse(), 1); // A.java
- ok &= check("analyze", task.analyze(), 3); // A, Foo, p.B
- ok &= check("generate", task.generate(), 5); // A, Foo, Foo$Baz, Foo$1, p.B
- if (!ok)
- throw new AssertionError("Test failed");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+ fm.setLocation(StandardLocation.SOURCE_PATH, Arrays.asList(new File(testSrc)));
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
+ new File(testSrc, "A.java")));
+ JavacTask task = tool.getTask(null, fm, null, null, null, files);
+ boolean ok = true;
+ ok &= check("parse", task.parse(), 1); // A.java
+ ok &= check("analyze", task.analyze(), 3); // A, Foo, p.B
+ ok &= check("generate", task.generate(), 5); // A, Foo, Foo$Baz, Foo$1, p.B
+ if (!ok)
+ throw new AssertionError("Test failed");
+ }
}
private static boolean check(String name, Iterable<?> iter, int expect) {
--- a/langtools/test/tools/javac/api/6437349/T6437349.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6437349/T6437349.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -51,6 +51,8 @@
throw new AssertionError();
}
public static void main(String... args) throws IOException {
- new T6437349().test(args);
+ try (T6437349 t = new T6437349()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6437999/T6437999.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6437999/T6437999.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,6 +86,8 @@
throw new AssertionError("Error in UTF-8 mode");
}
public static void main(String... args) throws IOException {
- new T6437999().test(args);
+ try (T6437999 t = new T6437999()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6440333/T6440333.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6440333/T6440333.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,8 @@
}
}
public static void main(String... args) throws IOException {
- new T6440333().test(args);
+ try (T6440333 t = new T6440333()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6440528/T6440528.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6440528/T6440528.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -66,6 +66,8 @@
}
public static void main(String... args) throws Exception {
- new T6440528().test(args);
+ try (T6440528 t = new T6440528()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6468404/T6468404.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6468404/T6468404.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -88,8 +88,10 @@
if (!task.call())
throw new AssertionError();
}
- public static void main(String... args) {
- new T6468404().test(args);
+ public static void main(String... args) throws IOException {
+ try (T6468404 t = new T6468404()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/6731573/T6731573.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6731573/T6731573.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, 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
@@ -106,6 +106,8 @@
}
public static void main(String... args) throws Exception {
- new T6731573().test();
+ try (T6731573 t = new T6731573()) {
+ t.test();
+ }
}
}
--- a/langtools/test/tools/javac/api/6733837/T6733837.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/6733837/T6733837.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, 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 @@
* @run main T6733837
*/
+import java.io.IOException;
import java.io.StringWriter;
import java.io.PrintWriter;
import java.net.URI;
@@ -43,8 +44,10 @@
public class T6733837 extends ToolTester {
- public static void main(String... args) {
- new T6733837().exec();
+ public static void main(String... args) throws IOException {
+ try (T6733837 t = new T6733837()) {
+ t.exec();
+ }
}
public void exec() {
--- a/langtools/test/tools/javac/api/7086261/T7086261.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/7086261/T7086261.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -66,10 +66,11 @@
void test() throws Throwable {
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
- JavaFileManager jfm = javac.getStandardFileManager(null, null, null);
- JavaCompiler.CompilationTask task =
- javac.getTask(null, jfm, new DiagnosticChecker(), null, null, Arrays.asList(new ErroneousSource()));
- task.call();
+ try (JavaFileManager jfm = javac.getStandardFileManager(null, null, null)) {
+ JavaCompiler.CompilationTask task =
+ javac.getTask(null, jfm, new DiagnosticChecker(), null, null, Arrays.asList(new ErroneousSource()));
+ task.call();
+ }
}
public static void main(String[] args) throws Throwable {
--- a/langtools/test/tools/javac/api/8007344/Test.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/8007344/Test.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,14 +83,15 @@
File testSrc = new File(System.getProperty("test.src"));
File thisFile = new File(testSrc, getClass().getName() + ".java");
JavacTool javac = JavacTool.create();
- StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
- Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
- testAnnoProcessor(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
- testTaskListener(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
+ try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+ Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
+ testAnnoProcessor(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
+ testTaskListener(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ }
}
void testAnnoProcessor(JavacTool javac, StandardJavaFileManager fm,
--- a/langtools/test/tools/javac/api/Sibling.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/Sibling.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,17 +39,18 @@
public class Sibling {
public static void main(String... args) throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
- JavaFileObject sibling =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File("Test.java")))
- .iterator().next();
- JavaFileObject classFile = fm.getJavaFileForOutput(CLASS_OUTPUT,
- "foo.bar.baz.Test",
- CLASS,
- sibling);
- File file = new File("Test.class").getAbsoluteFile();
- if (!classFile.toUri().equals(file.toURI()))
- throw new AssertionError("Expected " + file.toURI() + ", got " +
- classFile.toUri());
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ JavaFileObject sibling =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File("Test.java")))
+ .iterator().next();
+ JavaFileObject classFile = fm.getJavaFileForOutput(CLASS_OUTPUT,
+ "foo.bar.baz.Test",
+ CLASS,
+ sibling);
+ File file = new File("Test.class").getAbsoluteFile();
+ if (!classFile.toUri().equals(file.toURI()))
+ throw new AssertionError("Expected " + file.toURI() + ", got " +
+ classFile.toUri());
+ }
}
}
--- a/langtools/test/tools/javac/api/T6258271.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6258271.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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,7 @@
import javax.tools.*;
public class T6258271 {
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
public void report(Diagnostic<? extends JavaFileObject> message) {
@@ -43,9 +43,10 @@
System.out.println(message);
}
};
- StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromStrings(Arrays.asList("nofile.java"));
- javac.getTask(null, fm, dl, null, null, files).call();
+ try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromStrings(Arrays.asList("nofile.java"));
+ javac.getTask(null, fm, dl, null, null, files).call();
+ }
}
}
--- a/langtools/test/tools/javac/api/T6265137.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6265137.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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,11 +29,12 @@
*/
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import javax.tools.*;
public class T6265137 {
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
public void report(Diagnostic<? extends JavaFileObject> message) {
@@ -45,10 +46,11 @@
System.out.flush();
}
};
- StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
- String srcdir = System.getProperty("test.src");
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6265137a.java")));
- javac.getTask(null, fm, dl, Arrays.asList("-target","9"), null, files).call();
+ try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
+ String srcdir = System.getProperty("test.src");
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6265137a.java")));
+ javac.getTask(null, fm, dl, Arrays.asList("-target","9"), null, files).call();
+ }
}
}
--- a/langtools/test/tools/javac/api/T6306137.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6306137.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -87,10 +87,18 @@
}
}
+ void close() throws IOException {
+ fm.close();
+ }
+
public static void main(String[] args) throws IOException {
T6306137 self = new T6306137();
- self.test("utf-8", true);
- self.test("ascii", false);
- self.test("utf-8", true);
+ try {
+ self.test("utf-8", true);
+ self.test("ascii", false);
+ self.test("utf-8", true);
+ } finally {
+ self.close();
+ }
}
}
--- a/langtools/test/tools/javac/api/T6345974.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6345974.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,17 +45,18 @@
public static void main(String[] args) throws Exception {
PrintWriter out = new PrintWriter(System.out, true);
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File testSrc = new File(System.getProperty("test.src"));
- Iterable<? extends JavaFileObject> f =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "T6345974.java")));
- JavacTask task = tool.getTask(out, fm, null, null, null, f);
- Iterable<? extends CompilationUnitTree> trees = task.parse();
- out.flush();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File testSrc = new File(System.getProperty("test.src"));
+ Iterable<? extends JavaFileObject> f =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "T6345974.java")));
+ JavacTask task = tool.getTask(out, fm, null, null, null, f);
+ Iterable<? extends CompilationUnitTree> trees = task.parse();
+ out.flush();
- Scanner s = new Scanner();
- for (CompilationUnitTree t: trees)
- s.scan(t, null);
+ Scanner s = new Scanner();
+ for (CompilationUnitTree t: trees)
+ s.scan(t, null);
+ }
}
private static class Scanner extends TreeScanner<Void,Void> {
--- a/langtools/test/tools/javac/api/T6357331.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6357331.java Mon Nov 03 10:11:10 2014 -0800
@@ -33,42 +33,43 @@
public class T6357331
{
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
PrintWriter out = new PrintWriter(new StringWriter());
List<String> opts = Arrays.asList("-d", ".");
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File thisFile = new File(System.getProperty("test.src"), "T6357331.java");
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
- final JavacTask task = (JavacTask) (tool.getTask(out, fm, null, opts, null, files));
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File thisFile = new File(System.getProperty("test.src"), "T6357331.java");
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
+ final JavacTask task = (JavacTask) (tool.getTask(out, fm, null, opts, null, files));
- // set a listener to verify that IllegalStateException is not thrown
- // during the compilation
- task.setTaskListener(new TaskListener() {
- public void started(TaskEvent e) {
- task.getElements();
- task.getTypes();
- }
- public void finished(TaskEvent e) { }
- });
+ // set a listener to verify that IllegalStateException is not thrown
+ // during the compilation
+ task.setTaskListener(new TaskListener() {
+ public void started(TaskEvent e) {
+ task.getElements();
+ task.getTypes();
+ }
+ public void finished(TaskEvent e) { }
+ });
+
+ task.call();
- task.call();
+ // now the compilation is over, we expect IllegalStateException (not NPE)
+ try {
+ task.getElements();
+ throw new AssertionError("IllegalStateException not thrown");
+ }
+ catch (IllegalStateException e) {
+ // expected
+ }
- // now the compilation is over, we expect IllegalStateException (not NPE)
- try {
- task.getElements();
- throw new AssertionError("IllegalStateException not thrown");
- }
- catch (IllegalStateException e) {
- // expected
- }
-
- try {
- task.getTypes();
- throw new AssertionError("IllegalStateException not thrown");
- }
- catch (IllegalStateException e) {
- // expected
+ try {
+ task.getTypes();
+ throw new AssertionError("IllegalStateException not thrown");
+ }
+ catch (IllegalStateException e) {
+ // expected
+ }
}
}
}
--- a/langtools/test/tools/javac/api/T6358786.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6358786.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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,16 +44,17 @@
public class T6358786 {
public static void main(String... args) throws IOException {
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- String srcdir = System.getProperty("test.src");
- File file = new File(srcdir, args[0]);
- JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file)));
- Elements elements = task.getElements();
- for (TypeElement clazz : task.enter(task.parse())) {
- String doc = elements.getDocComment(clazz);
- if (doc == null)
- throw new AssertionError(clazz.getSimpleName() + ": no doc comment");
- System.out.format("%s: %s%n", clazz.getSimpleName(), doc);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ String srcdir = System.getProperty("test.src");
+ File file = new File(srcdir, args[0]);
+ JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file)));
+ Elements elements = task.getElements();
+ for (TypeElement clazz : task.enter(task.parse())) {
+ String doc = elements.getDocComment(clazz);
+ if (doc == null)
+ throw new AssertionError(clazz.getSimpleName() + ": no doc comment");
+ System.out.format("%s: %s%n", clazz.getSimpleName(), doc);
+ }
}
}
}
--- a/langtools/test/tools/javac/api/T6358955.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6358955.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -36,34 +36,35 @@
public class T6358955 {
public static void main(String[] args) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) {
- File dir = new File("temp" + args.hashCode());
- if (!dir.exists())
- dir.mkdir();
- if (!dir.isDirectory())
- throw new AssertionError("Not a directory " + dir);
+ File dir = new File("temp" + args.hashCode());
+ if (!dir.exists())
+ dir.mkdir();
+ if (!dir.isDirectory())
+ throw new AssertionError("Not a directory " + dir);
- try {
- jfm.setLocation(StandardLocation.CLASS_OUTPUT,
- Arrays.asList(dir.getCanonicalFile().getParentFile()));
try {
- jfm.getFileForInput(StandardLocation.CLASS_OUTPUT, "", dir.getPath());
- throw new AssertionError("IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
- System.out.println("OK: " + e.getLocalizedMessage());
- }
- try {
- jfm.getJavaFileObjectsFromFiles(Arrays.asList(dir));
- throw new AssertionError("IllegalArgumentException not thrown");
- } catch (IllegalArgumentException e) {
- System.out.println("OK: " + e.getLocalizedMessage());
- }
- } finally {
- try {
- dir.delete(); // cleanup
- } catch (Throwable t) {
- t.printStackTrace();
+ jfm.setLocation(StandardLocation.CLASS_OUTPUT,
+ Arrays.asList(dir.getCanonicalFile().getParentFile()));
+ try {
+ jfm.getFileForInput(StandardLocation.CLASS_OUTPUT, "", dir.getPath());
+ throw new AssertionError("IllegalArgumentException not thrown");
+ } catch (IllegalArgumentException e) {
+ System.out.println("OK: " + e.getLocalizedMessage());
+ }
+ try {
+ jfm.getJavaFileObjectsFromFiles(Arrays.asList(dir));
+ throw new AssertionError("IllegalArgumentException not thrown");
+ } catch (IllegalArgumentException e) {
+ System.out.println("OK: " + e.getLocalizedMessage());
+ }
+ } finally {
+ try {
+ dir.delete(); // cleanup
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
}
}
}
--- a/langtools/test/tools/javac/api/T6392782.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6392782.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -38,21 +38,22 @@
public static void main(String... args) throws IOException {
String testSrc = System.getProperty("test.src", ".");
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6392782.class.getName()+".java")));
- JavacTask task = tool.getTask(null, fm, null, null, null, files);
- Iterable<? extends Tree> trees = task.parse();
- TreeScanner<Integer,Void> scanner = new MyScanner();
- check(scanner, 6, scanner.scan(trees, null));
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6392782.class.getName()+".java")));
+ JavacTask task = tool.getTask(null, fm, null, null, null, files);
+ Iterable<? extends Tree> trees = task.parse();
+ TreeScanner<Integer,Void> scanner = new MyScanner();
+ check(scanner, 6, scanner.scan(trees, null));
- CountNodes nodeCounter = new CountNodes();
- // 359 nodes with the regular parser; 360 nodes with EndPosParser
- // We automatically switch to EndPosParser when calling JavacTask.parse()
- check(nodeCounter, 360, nodeCounter.scan(trees, null));
+ CountNodes nodeCounter = new CountNodes();
+ // 359 nodes with the regular parser; 360 nodes with EndPosParser
+ // We automatically switch to EndPosParser when calling JavacTask.parse()
+ check(nodeCounter, 362, nodeCounter.scan(trees, null));
- CountIdentifiers idCounter = new CountIdentifiers();
- check(idCounter, 107, idCounter.scan(trees, null));
+ CountIdentifiers idCounter = new CountIdentifiers();
+ check(idCounter, 107, idCounter.scan(trees, null));
+ }
}
private static void check(TreeScanner<?,?> scanner, int expect, int found) {
--- a/langtools/test/tools/javac/api/T6397104.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6397104.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -65,16 +65,15 @@
void test(boolean hasLocation, File siblingFile, String relName, String expectedPath)
throws Exception
{
- StandardJavaFileManager fm;
- if (hasLocation) {
- for (Location location : StandardLocation.values()) {
- fm = tool.getStandardFileManager(null, null, null);
- fm.setLocation(location, Arrays.asList(new File(".")));
- test(fm, location, siblingFile, relName, expectedPath);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ if (hasLocation) {
+ for (Location location : StandardLocation.values()) {
+ fm.setLocation(location, Arrays.asList(new File(".")));
+ test(fm, location, siblingFile, relName, expectedPath);
+ }
+ } else {
+ test(fm, CLASS_OUTPUT, siblingFile, relName, expectedPath);
}
- } else {
- fm = tool.getStandardFileManager(null, null, null);
- test(fm, CLASS_OUTPUT, siblingFile, relName, expectedPath);
}
}
--- a/langtools/test/tools/javac/api/T6400205.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6400205.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,22 +28,24 @@
* @author Peter von der Ah\u00e9
*/
+import java.io.IOException;
import javax.tools.*;
import static javax.tools.StandardLocation.*;
public class T6400205 {
- public static void main(String... args) {
- JavaFileManager fm =
- ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
- try {
- fm.getClassLoader(null);
- throw new AssertionError("NullPointerException not thrown");
- } catch (NullPointerException e) {
- // expected result
+ public static void main(String... args) throws IOException {
+ try (JavaFileManager fm =
+ ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
+ try {
+ fm.getClassLoader(null);
+ throw new AssertionError("NullPointerException not thrown");
+ } catch (NullPointerException e) {
+ // expected result
+ }
+ ClassLoader cl = fm.getClassLoader(locationFor("bogus"));
+ if (cl != null)
+ throw new AssertionError("non-null class loader for bogus location");
+ System.err.println("Test PASSED.");
}
- ClassLoader cl = fm.getClassLoader(locationFor("bogus"));
- if (cl != null)
- throw new AssertionError("non-null class loader for bogus location");
- System.err.println("Test PASSED.");
}
}
--- a/langtools/test/tools/javac/api/T6400207.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6400207.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,28 +61,29 @@
}
public static void main(String... args) throws Exception {
- JavaFileManager fm =
- ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
- JavaFileManager.Location bogusLocation = locationFor("bogus");
- JavaFileManager.Location knownLocation = CLASS_PATH;
- String packageName = "java.lang";
- Set<JavaFileObject.Kind> kinds = EnumSet.of(CLASS);
+ try (JavaFileManager fm =
+ ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
+ JavaFileManager.Location bogusLocation = locationFor("bogus");
+ JavaFileManager.Location knownLocation = CLASS_PATH;
+ String packageName = "java.lang";
+ Set<JavaFileObject.Kind> kinds = EnumSet.of(CLASS);
- for (StandardLocation location : StandardLocation.values()) {
- if (location != locationFor(location.getName()))
- throw new AssertionError(location + " != locationFor(" +
- location.getName() + ")");
+ for (StandardLocation location : StandardLocation.values()) {
+ if (location != locationFor(location.getName()))
+ throw new AssertionError(location + " != locationFor(" +
+ location.getName() + ")");
+ }
+
+ testList(fm, null, null, null);
+ testList(fm, bogusLocation, packageName, kinds);
+ testList(fm, knownLocation, packageName, kinds);
+ testList(fm, null, packageName, kinds);
+ testList(fm, knownLocation, null, kinds);
+ testList(fm, knownLocation, packageName, null);
+ testList(fm, bogusLocation, null, kinds);
+ testList(fm, bogusLocation, packageName, null);
+
+ System.err.println("Test PASSED.");
}
-
- testList(fm, null, null, null);
- testList(fm, bogusLocation, packageName, kinds);
- testList(fm, knownLocation, packageName, kinds);
- testList(fm, null, packageName, kinds);
- testList(fm, knownLocation, null, kinds);
- testList(fm, knownLocation, packageName, null);
- testList(fm, bogusLocation, null, kinds);
- testList(fm, bogusLocation, packageName, null);
-
- System.err.println("Test PASSED.");
}
}
--- a/langtools/test/tools/javac/api/T6412669.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6412669.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,22 +64,23 @@
//System.err.println("toolsClasses: " + toolsClasses);
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses, toolsClasses));
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6412669.class.getName()+".java")));
- String[] opts = { "-proc:only", "-processor", T6412669.class.getName()};
- StringWriter sw = new StringWriter();
- JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files);
- boolean ok = task.call();
- String out = sw.toString();
- if (!out.isEmpty())
- System.err.println(out);
- if (!ok)
- throw new AssertionError("compilation of test program failed");
- // verify we found an annotated element to exercise the SourcePositions API
- if (!out.contains("processing element"))
- throw new AssertionError("expected text not found in compilation output");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses, toolsClasses));
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6412669.class.getName()+".java")));
+ String[] opts = { "-proc:only", "-processor", T6412669.class.getName()};
+ StringWriter sw = new StringWriter();
+ JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files);
+ boolean ok = task.call();
+ String out = sw.toString();
+ if (!out.isEmpty())
+ System.err.println(out);
+ if (!ok)
+ throw new AssertionError("compilation of test program failed");
+ // verify we found an annotated element to exercise the SourcePositions API
+ if (!out.contains("processing element"))
+ throw new AssertionError("expected text not found in compilation output");
+ }
}
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
--- a/langtools/test/tools/javac/api/T6419926.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6419926.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,17 +35,18 @@
public class T6419926 {
public static void main(String[] argv) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>(), null, null);
- System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
- mgr.setLocation(StandardLocation.CLASS_OUTPUT,
- Collections.singleton(new File(".")));
+ try (StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>(), null, null)) {
+ System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
+ mgr.setLocation(StandardLocation.CLASS_OUTPUT,
+ Collections.singleton(new File(".")));
- FileObject fo = mgr.getFileForOutput(StandardLocation.CLASS_OUTPUT,
- "", "file.to.delete", null);
- URI uri = fo.toUri();
- System.out.println( uri );
+ FileObject fo = mgr.getFileForOutput(StandardLocation.CLASS_OUTPUT,
+ "", "file.to.delete", null);
+ URI uri = fo.toUri();
+ System.out.println( uri );
- if (!"file".equals(uri.getScheme()))
- throw new Exception("unexpected scheme for uri: " + uri.getScheme());
+ if (!"file".equals(uri.getScheme()))
+ throw new Exception("unexpected scheme for uri: " + uri.getScheme());
+ }
}
}
--- a/langtools/test/tools/javac/api/T6430241.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6430241.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -134,21 +134,22 @@
System.err.println("test task API: " + pcp);
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
- if (pcp != null)
- fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp);
+ if (pcp != null)
+ fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp);
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(testFile);
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(testFile);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- JavacTask task = tool.getTask(pw, fm, null, null, null, files);
- boolean ok = task.call();
- String out = showOutput(sw.toString());
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ JavacTask task = tool.getTask(pw, fm, null, null, null, files);
+ boolean ok = task.call();
+ String out = showOutput(sw.toString());
- checkCompilationOK(ok);
- checkOutput(out, expectWarnings);
+ checkCompilationOK(ok);
+ checkOutput(out, expectWarnings);
+ }
}
//----- utility methods
--- a/langtools/test/tools/javac/api/T6431879.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6431879.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,18 +39,18 @@
String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes", ".");
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6431879.class.getName()+".java")));
- JavacTask task = tool.getTask(null, fm, null, null, null, files);
- Iterable<? extends CompilationUnitTree> trees = task.parse();
- TreeScanner<Void,Trees> dependencyScanner = new DependencyScanner();
- Trees treeUtil = Trees.instance(task);
- for (CompilationUnitTree unit : trees) {
- //System.err.println("scan " + unit);
- dependencyScanner.scan(unit, treeUtil);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6431879.class.getName()+".java")));
+ JavacTask task = tool.getTask(null, fm, null, null, null, files);
+ Iterable<? extends CompilationUnitTree> trees = task.parse();
+ TreeScanner<Void,Trees> dependencyScanner = new DependencyScanner();
+ Trees treeUtil = Trees.instance(task);
+ for (CompilationUnitTree unit : trees) {
+ //System.err.println("scan " + unit);
+ dependencyScanner.scan(unit, treeUtil);
+ }
}
-
}
private static class DependencyScanner<R,P> extends TreePathScanner<R,P> {
--- a/langtools/test/tools/javac/api/T6483788.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6483788.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, 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,14 +42,15 @@
void run() throws Exception {
File jar = createJar();
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
- fm.setLocation(StandardLocation.CLASS_PATH, Collections.singleton(jar));
- JavaFileObject fo = fm.getJavaFileForInput(StandardLocation.CLASS_PATH, "dummy", JavaFileObject.Kind.CLASS);
- System.err.println("file: " + fo);
- URI uri = fo.toUri();
- System.err.println("uri: " + uri);
- if (uri.toString().contains(" "))
- throw new Exception("unexpected space character found");
+ try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ fm.setLocation(StandardLocation.CLASS_PATH, Collections.singleton(jar));
+ JavaFileObject fo = fm.getJavaFileForInput(StandardLocation.CLASS_PATH, "dummy", JavaFileObject.Kind.CLASS);
+ System.err.println("file: " + fo);
+ URI uri = fo.toUri();
+ System.err.println("uri: " + uri);
+ if (uri.toString().contains(" "))
+ throw new Exception("unexpected space character found");
+ }
}
File createJar() throws IOException {
--- a/langtools/test/tools/javac/api/T6501502.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/T6501502.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, 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,16 +46,18 @@
// we test a number of platform-independent paths.
void run() throws Exception {
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- fm = c.getStandardFileManager(null, null, null);
- System.err.println(System.getProperties());
- File tmpDir = new File(System.getProperty("java.io.tmpdir"));
- File testSrcDir = new File(System.getProperty("test.src"));
- File testClassesDir = new File(System.getProperty("test.classes"));
- test(new File("abc.tmp"));
- test(new File(tmpDir, "bad.file"));
- test(new File(testSrcDir, "T6501501.java"));
- test(new File(testClassesDir, "T6501501.class"));
- test(new File("a b"));
+ try (StandardJavaFileManager sfm = c.getStandardFileManager(null, null, null)) {
+ fm = sfm;
+ System.err.println(System.getProperties());
+ File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+ File testSrcDir = new File(System.getProperty("test.src"));
+ File testClassesDir = new File(System.getProperty("test.classes"));
+ test(new File("abc.tmp"));
+ test(new File(tmpDir, "bad.file"));
+ test(new File(testSrcDir, "T6501501.java"));
+ test(new File(testClassesDir, "T6501501.class"));
+ test(new File("a b"));
+ }
}
void test(File f) throws Exception {
--- a/langtools/test/tools/javac/api/TestClientCodeWrapper.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestClientCodeWrapper.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,34 +56,36 @@
*/
void run() throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- defaultFileManager = compiler.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ defaultFileManager = fm;
- for (Method m: getMethodsExcept(JavaFileManager.class, "close", "getJavaFileForInput")) {
- test(m);
- }
+ for (Method m: getMethodsExcept(JavaFileManager.class, "close", "getJavaFileForInput")) {
+ test(m);
+ }
- for (Method m: getMethodsExcept(FileObject.class, "delete")) {
- test(m);
- }
+ for (Method m: getMethodsExcept(FileObject.class, "delete")) {
+ test(m);
+ }
- for (Method m: getMethods(JavaFileObject.class)) {
- test(m);
- }
+ for (Method m: getMethods(JavaFileObject.class)) {
+ test(m);
+ }
- for (Method m: getMethodsExcept(Processor.class, "getCompletions")) {
- test(m);
- }
+ for (Method m: getMethodsExcept(Processor.class, "getCompletions")) {
+ test(m);
+ }
- for (Method m: DiagnosticListener.class.getDeclaredMethods()) {
- test(m);
+ for (Method m: DiagnosticListener.class.getDeclaredMethods()) {
+ test(m);
+ }
+
+ for (Method m: TaskListener.class.getDeclaredMethods()) {
+ test(m);
+ }
+
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
}
-
- for (Method m: TaskListener.class.getDeclaredMethods()) {
- test(m);
- }
-
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
}
/** Get a sorted set of the methods declared on a class. */
--- a/langtools/test/tools/javac/api/TestDocComments.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestDocComments.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -52,23 +52,23 @@
File file = new File(testSrc, "TestDocComments.java");
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
-
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- Iterable<? extends JavaFileObject> fileObjects = fm.getJavaFileObjects(file);
- JavacTask task = tool.getTask(pw, fm, null, null, null, fileObjects);
- Iterable<? extends CompilationUnitTree> units = task.parse();
- Trees trees = Trees.instance(task);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ Iterable<? extends JavaFileObject> fileObjects = fm.getJavaFileObjects(file);
+ JavacTask task = tool.getTask(pw, fm, null, null, null, fileObjects);
+ Iterable<? extends CompilationUnitTree> units = task.parse();
+ Trees trees = Trees.instance(task);
- CommentScanner s = new CommentScanner();
- int n = s.scan(units, trees);
+ CommentScanner s = new CommentScanner();
+ int n = s.scan(units, trees);
- if (n != 12)
- error("Unexpected number of doc comments found: " + n);
+ if (n != 12)
+ error("Unexpected number of doc comments found: " + n);
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ }
}
/**
--- a/langtools/test/tools/javac/api/TestGetElementReference.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestGetElementReference.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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,31 +50,32 @@
public static void main(String... args) throws IOException {
File source = new File(System.getProperty("test.src", "."), "TestGetElementReferenceData.java").getAbsoluteFile();
- StandardJavaFileManager fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
- DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
- JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, Arrays.asList("-Xjcov"), null, fm.getJavaFileObjects(source));
- Trees trees = Trees.instance(ct);
- CompilationUnitTree cut = ct.parse().iterator().next();
+ try (StandardJavaFileManager fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
+ DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
+ JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, Arrays.asList("-Xjcov"), null, fm.getJavaFileObjects(source));
+ Trees trees = Trees.instance(ct);
+ CompilationUnitTree cut = ct.parse().iterator().next();
- ct.analyze();
+ ct.analyze();
- for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
- if (d.getKind() == Diagnostic.Kind.ERROR) {
- throw new IllegalStateException("Should have been attributed without errors: " + diagnostics.getDiagnostics());
+ for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
+ if (d.getKind() == Diagnostic.Kind.ERROR) {
+ throw new IllegalStateException("Should have been attributed without errors: " + diagnostics.getDiagnostics());
+ }
}
- }
- Pattern p = Pattern.compile("/\\*getElement:(.*?)\\*/");
- Matcher m = p.matcher(cut.getSourceFile().getCharContent(false));
+ Pattern p = Pattern.compile("/\\*getElement:(.*?)\\*/");
+ Matcher m = p.matcher(cut.getSourceFile().getCharContent(false));
- while (m.find()) {
- TreePath tp = pathFor(trees, cut, m.start() - 1);
- Element found = trees.getElement(tp);
- String expected = m.group(1);
- String actual = found != null ? found.getKind() + ":" + symbolToString(found) : "<null>";
+ while (m.find()) {
+ TreePath tp = pathFor(trees, cut, m.start() - 1);
+ Element found = trees.getElement(tp);
+ String expected = m.group(1);
+ String actual = found != null ? found.getKind() + ":" + symbolToString(found) : "<null>";
- if (!expected.equals(actual)) {
- throw new IllegalStateException("expected=" + expected + "; actual=" + actual);
+ if (!expected.equals(actual)) {
+ throw new IllegalStateException("expected=" + expected + "; actual=" + actual);
+ }
}
}
}
--- a/langtools/test/tools/javac/api/TestGetScope.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestGetScope.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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 @@
import com.sun.source.tree.IdentifierTree;
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -51,24 +52,25 @@
@SupportedAnnotationTypes("*")
public class TestGetScope extends AbstractProcessor {
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
new TestGetScope().run();
}
- public void run() {
+ public void run() throws IOException {
File srcDir = new File(System.getProperty("test.src"));
File thisFile = new File(srcDir, getClass().getName() + ".java");
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
- List<String> opts = Arrays.asList("-proc:only", "-doe");
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
- JavacTask t = (JavacTask) c.getTask(null, fm, null, opts, null, files);
- t.setProcessors(Collections.singleton(this));
- boolean ok = t.call();
- if (!ok)
- throw new Error("compilation failed");
+ List<String> opts = Arrays.asList("-proc:only", "-doe");
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
+ JavacTask t = (JavacTask) c.getTask(null, fm, null, opts, null, files);
+ t.setProcessors(Collections.singleton(this));
+ boolean ok = t.call();
+ if (!ok)
+ throw new Error("compilation failed");
+ }
}
@Override
--- a/langtools/test/tools/javac/api/TestJavacTask.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestJavacTask.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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,8 +41,8 @@
public class TestJavacTask {
static final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ static final StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
static JavacTaskImpl getTask(File... file) {
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
Iterable<? extends JavaFileObject> files =
fm.getJavaFileObjectsFromFiles(Arrays.asList(file));
return (JavacTaskImpl)compiler.getTask(null, fm, null, null, null, files);
@@ -69,7 +69,11 @@
}
public static void main(String... args) throws IOException {
- basicTest(args);
- checkKindError();
+ try {
+ basicTest(args);
+ checkKindError();
+ } finally {
+ fm.close();
+ }
}
}
--- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java Mon Nov 03 10:11:10 2014 -0800
@@ -115,7 +115,9 @@
public static void main(String... args) throws IOException {
String srcdir = System.getProperty("test.src");
- new TestJavacTaskScanner(new File(srcdir, args[0])).run();
+ try (TestJavacTaskScanner t = new TestJavacTaskScanner(new File(srcdir, args[0]))) {
+ t.run();
+ }
}
private void testGetAllMembers(TypeElement clazz) {
--- a/langtools/test/tools/javac/api/TestJavacTask_Lock.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestJavacTask_Lock.java Mon Nov 03 10:11:10 2014 -0800
@@ -67,15 +67,18 @@
void run() throws Exception {
comp = ToolProvider.getSystemJavaCompiler();
fm = comp.getStandardFileManager(null, null, null);
-
- for (MethodKind first: MethodKind.values()) {
- for (MethodKind second: MethodKind.values()) {
- test(first, second);
+ try {
+ for (MethodKind first: MethodKind.values()) {
+ for (MethodKind second: MethodKind.values()) {
+ test(first, second);
+ }
}
+
+ if (errors > 0)
+ throw new Exception(errors + " errors found");
+ } finally {
+ fm.close();
}
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
}
void test(MethodKind first, MethodKind second) {
--- a/langtools/test/tools/javac/api/TestJavacTask_Multiple.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestJavacTask_Multiple.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,16 +68,19 @@
void run() throws Exception {
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
- for (TestKind tk: TestKind.values()) {
- test(comp, fm, tk);
- }
+ try {
+ for (TestKind tk: TestKind.values()) {
+ test(comp, fm, tk);
+ }
- int expect = TestKind.values().length * MAX_TASKS;
- if (count != expect) {
- throw new Exception("Unexpected number of tests completed: " + count
- + ", expected: " + expect);
+ int expect = TestKind.values().length * MAX_TASKS;
+ if (count != expect) {
+ throw new Exception("Unexpected number of tests completed: " + count
+ + ", expected: " + expect);
+ }
+ } finally {
+ fm.close();
}
-
}
void test(JavaCompiler comp, StandardJavaFileManager fm, TestKind tk) {
--- a/langtools/test/tools/javac/api/TestJavacTask_ParseAttrGen.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestJavacTask_ParseAttrGen.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,14 +45,17 @@
void run() throws Exception {
comp = ToolProvider.getSystemJavaCompiler();
fm = comp.getStandardFileManager(null, null, null);
-
- final boolean[] booleanValues = { false, true };
- for (boolean pk: booleanValues) {
- for (boolean ak: booleanValues) {
- for (boolean gk: booleanValues) {
- test(pk, ak, gk);
+ try {
+ final boolean[] booleanValues = { false, true };
+ for (boolean pk: booleanValues) {
+ for (boolean ak: booleanValues) {
+ for (boolean gk: booleanValues) {
+ test(pk, ak, gk);
+ }
}
}
+ } finally {
+ fm.close();
}
}
--- a/langtools/test/tools/javac/api/TestResolveError.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestResolveError.java Mon Nov 03 10:11:10 2014 -0800
@@ -51,7 +51,9 @@
*/
public class TestResolveError extends ToolTester {
public static void main(String... args) throws Exception {
- new TestResolveError().run();
+ try (TestResolveError t = new TestResolveError()) {
+ t.run();
+ }
}
void run() throws Exception {
--- a/langtools/test/tools/javac/api/TestSearchPaths.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestSearchPaths.java Mon Nov 03 10:11:10 2014 -0800
@@ -76,30 +76,33 @@
void run() throws Exception {
compiler = ToolProvider.getSystemJavaCompiler();
fileManager = compiler.getStandardFileManager(null, null, null);
-
- // basic output path
- testClassOutput();
+ try {
+ // basic output path
+ testClassOutput();
- // basic search paths
- testClassPath();
- testSourcePath();
- testPlatformClassPath();
+ // basic search paths
+ testClassPath();
+ testSourcePath();
+ testPlatformClassPath();
+
+ // annotation processing
+ testAnnotationProcessorPath();
+ testSourceOutput();
- // annotation processing
- testAnnotationProcessorPath();
- testSourceOutput();
-
- // javah equivalent
- testNativeHeaderOutput();
+ // javah equivalent
+ testNativeHeaderOutput();
- // future-proof: guard against new StandardLocations being added
- if (!tested.equals(EnumSet.allOf(StandardLocation.class))) {
- error("not all standard locations have been tested");
- out.println("not yet tested: " + EnumSet.complementOf(tested));
- }
+ // future-proof: guard against new StandardLocations being added
+ if (!tested.equals(EnumSet.allOf(StandardLocation.class))) {
+ error("not all standard locations have been tested");
+ out.println("not yet tested: " + EnumSet.complementOf(tested));
+ }
- if (errors > 0) {
- throw new Exception(errors + " errors occurred");
+ if (errors > 0) {
+ throw new Exception(errors + " errors occurred");
+ }
+ } finally {
+ fileManager.close();
}
}
--- a/langtools/test/tools/javac/api/TestTreePath.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestTreePath.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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
@@ -105,17 +105,18 @@
public void run() throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fileManager
- = compiler.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> tests
- = fileManager.getJavaFileObjects(writeTestFile());
+ try (StandardJavaFileManager fileManager
+ = compiler.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> tests
+ = fileManager.getJavaFileObjects(writeTestFile());
- JavaCompiler.CompilationTask task =
- ToolProvider.getSystemJavaCompiler().getTask(
- null, null, null,
- Arrays.asList("-processor", this.getClass().getName()), null,
- tests);
- task.call();
+ JavaCompiler.CompilationTask task =
+ ToolProvider.getSystemJavaCompiler().getTask(
+ null, null, null,
+ Arrays.asList("-processor", this.getClass().getName()), null,
+ tests);
+ task.call();
+ }
}
public static void main(String[] args) throws IOException {
--- a/langtools/test/tools/javac/api/TestTrees.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/TestTrees.java Mon Nov 03 10:11:10 2014 -0800
@@ -74,29 +74,30 @@
}
};
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
- Iterable<String> opts = Arrays.asList("-d", ".", "-XDcompilePolicy=simple");
+ Iterable<String> opts = Arrays.asList("-d", ".", "-XDcompilePolicy=simple");
- System.err.println("simple compilation, no processing");
- JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
- task.setTaskListener(new MyTaskListener(task));
- if (!task.call())
- throw new AssertionError("compilation failed");
+ System.err.println("simple compilation, no processing");
+ JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
+ task.setTaskListener(new MyTaskListener(task));
+ if (!task.call())
+ throw new AssertionError("compilation failed");
- opts = Arrays.asList("-d", ".", "-processorpath", testClassDir, "-processor", self,
- "-XDcompilePolicy=simple");
+ opts = Arrays.asList("-d", ".", "-processorpath", testClassDir, "-processor", self,
+ "-XDcompilePolicy=simple");
- System.err.println();
- System.err.println("compilation with processing");
- task = tool.getTask(out, fm, dl,opts, null, files);
- if (!task.call())
- throw new AssertionError("compilation failed");
+ System.err.println();
+ System.err.println("compilation with processing");
+ task = tool.getTask(out, fm, dl,opts, null, files);
+ if (!task.call())
+ throw new AssertionError("compilation failed");
- if (errors > 0)
- throw new AssertionError(errors + " errors occurred");
+ if (errors > 0)
+ throw new AssertionError(errors + " errors occurred");
+ }
}
void testElement(Trees trees, Element e) {
--- a/langtools/test/tools/javac/api/guide/Test.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/guide/Test.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,7 +80,9 @@
}
public static void main(String... args) throws Exception {
- new Test().test(args);
+ try (Test t = new Test()) {
+ t.test(args);
+ }
}
}
--- a/langtools/test/tools/javac/api/lib/ToolTester.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/lib/ToolTester.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,7 +31,7 @@
import static javax.tools.StandardLocation.SOURCE_PATH;
import static javax.tools.StandardLocation.CLASS_OUTPUT;
-public class ToolTester {
+public class ToolTester implements AutoCloseable {
public final File test_src = new File(System.getProperty("test.src", "."));
public final File test_classes = new File(System.getProperty("test.classes", "."));
public final List<File> test_class_path = pathToFiles(System.getProperty("test.class.path"),
@@ -77,4 +77,9 @@
result.addAll(b);
return result;
}
+
+ @Override
+ public void close() throws IOException {
+ fm.close();
+ }
}
--- a/langtools/test/tools/javac/api/taskListeners/CompileEvent.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/taskListeners/CompileEvent.java Mon Nov 03 10:11:10 2014 -0800
@@ -73,18 +73,19 @@
assertOutput(out.toString());
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> testFileObjects = fm.getJavaFileObjects(test);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> testFileObjects = fm.getJavaFileObjects(test);
- //test events fired to listeners registered from plugins
- //when starting compiler using JavaCompiler.getTask(...).call
- List<String> options =
- Arrays.asList("-Xplugin:compile-event", "-processorpath", testClasses);
- out = new StringWriter();
- boolean compResult = comp.getTask(out, null, null, options, null, testFileObjects).call();
- if (!compResult)
- throw new AssertionError("Compilation failed unexpectedly.");
- assertOutput(out.toString());
+ //test events fired to listeners registered from plugins
+ //when starting compiler using JavaCompiler.getTask(...).call
+ List<String> options =
+ Arrays.asList("-Xplugin:compile-event", "-processorpath", testClasses);
+ out = new StringWriter();
+ boolean compResult = comp.getTask(out, null, null, options, null, testFileObjects).call();
+ if (!compResult)
+ throw new AssertionError("Compilation failed unexpectedly.");
+ assertOutput(out.toString());
+ }
}
void assertOutput(String found) {
--- a/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -44,7 +44,12 @@
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
public static void main(String... args) throws IOException {
- new EventsBalancedTest().test();
+ EventsBalancedTest t = new EventsBalancedTest();
+ try {
+ t.test();
+ } finally {
+ t.fm.close();
+ }
}
void test() throws IOException {
--- a/langtools/test/tools/javac/api/taskListeners/TestSimpleAddRemove.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/api/taskListeners/TestSimpleAddRemove.java Mon Nov 03 10:11:10 2014 -0800
@@ -203,7 +203,12 @@
}
public static void main(String... args) throws Exception {
- new TestSimpleAddRemove().run();
+ TestSimpleAddRemove t = new TestSimpleAddRemove();
+ try {
+ t.run();
+ } finally {
+ t.fm.close();
+ }
}
JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
--- a/langtools/test/tools/javac/cast/intersection/IntersectionTypeParserTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/cast/intersection/IntersectionTypeParserTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -104,35 +104,36 @@
public static void main(String... args) throws Exception {
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (CastKind ck : CastKind.values()) {
- for (TypeKind t1 : TypeKind.values()) {
- for (ArrayKind ak1 : ArrayKind.values()) {
- Type typ1 = new Type(t1, ak1);
- if (ck.nBounds == 1) {
- new IntersectionTypeParserTest(ck, typ1).run(comp, fm);
- continue;
- }
- for (TypeKind t2 : TypeKind.values()) {
- for (ArrayKind ak2 : ArrayKind.values()) {
- Type typ2 = new Type(t2, ak2);
- if (ck.nBounds == 2) {
- new IntersectionTypeParserTest(ck, typ1, typ2).run(comp, fm);
- continue;
- }
- for (TypeKind t3 : TypeKind.values()) {
- for (ArrayKind ak3 : ArrayKind.values()) {
- Type typ3 = new Type(t3, ak3);
- new IntersectionTypeParserTest(ck, typ1, typ2, typ3).run(comp, fm);
+ for (CastKind ck : CastKind.values()) {
+ for (TypeKind t1 : TypeKind.values()) {
+ for (ArrayKind ak1 : ArrayKind.values()) {
+ Type typ1 = new Type(t1, ak1);
+ if (ck.nBounds == 1) {
+ new IntersectionTypeParserTest(ck, typ1).run(comp, fm);
+ continue;
+ }
+ for (TypeKind t2 : TypeKind.values()) {
+ for (ArrayKind ak2 : ArrayKind.values()) {
+ Type typ2 = new Type(t2, ak2);
+ if (ck.nBounds == 2) {
+ new IntersectionTypeParserTest(ck, typ1, typ2).run(comp, fm);
+ continue;
+ }
+ for (TypeKind t3 : TypeKind.values()) {
+ for (ArrayKind ak3 : ArrayKind.values()) {
+ Type typ3 = new Type(t3, ak3);
+ new IntersectionTypeParserTest(ck, typ1, typ2, typ3).run(comp, fm);
+ }
}
}
}
}
}
}
+ System.out.println("Total check executed: " + checkCount);
}
- System.out.println("Total check executed: " + checkCount);
}
CastKind ck;
--- a/langtools/test/tools/javac/classreader/T7031108.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/classreader/T7031108.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,39 +68,40 @@
void run() throws Exception {
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- // step 1: compile test classes
- File cwd = new File(".");
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(cwd));
- compile(comp, fm, null, null, pC);
+ // step 1: compile test classes
+ File cwd = new File(".");
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(cwd));
+ compile(comp, fm, null, null, pC);
- // step 2: verify functioning of processor
- fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
- fm.getLocation(StandardLocation.CLASS_PATH));
- fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(cwd));
- compile(comp, fm, null, getClass().getName(), dummy);
+ // step 2: verify functioning of processor
+ fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
+ fm.getLocation(StandardLocation.CLASS_PATH));
+ fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(cwd));
+ compile(comp, fm, null, getClass().getName(), dummy);
- File pC_class = new File(new File("p"), "C.class");
- pC_class.delete();
+ File pC_class = new File(new File("p"), "C.class");
+ pC_class.delete();
- DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
- compile(comp, fm, dc, getClass().getName(), dummy);
- List<Diagnostic<? extends JavaFileObject>> diags =dc.getDiagnostics();
+ DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+ compile(comp, fm, dc, getClass().getName(), dummy);
+ List<Diagnostic<? extends JavaFileObject>> diags =dc.getDiagnostics();
- System.err.println(diags);
- switch (diags.size()) {
- case 0:
- throw new Exception("no diagnostics received");
- case 1:
- String code = diags.get(0).getCode();
- String expect = "compiler.err.proc.cant.access.1";
- if (!expect.equals(code))
- throw new Exception("unexpected diag code: " + code
- + ", expected: " + expect);
- break;
- default:
- throw new Exception("unexpected diags received");
+ System.err.println(diags);
+ switch (diags.size()) {
+ case 0:
+ throw new Exception("no diagnostics received");
+ case 1:
+ String code = diags.get(0).getCode();
+ String expect = "compiler.err.proc.cant.access.1";
+ if (!expect.equals(code))
+ throw new Exception("unexpected diag code: " + code
+ + ", expected: " + expect);
+ break;
+ default:
+ throw new Exception("unexpected diags received");
+ }
}
}
--- a/langtools/test/tools/javac/defaultMethods/DefaultMethodFlags.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/defaultMethods/DefaultMethodFlags.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -54,31 +54,32 @@
void checkDefaultMethodFlags() throws IOException {
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> fos =
- fm.getJavaFileObjectsFromFiles(
- Arrays.asList(new File(
- System.getProperty("test.src"),
- this.getClass().getSimpleName() + ".java")));
- JavacTask task = (JavacTask) c.getTask(null, fm, null, null, null, fos);
+ try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> fos =
+ fm.getJavaFileObjectsFromFiles(
+ Arrays.asList(new File(
+ System.getProperty("test.src"),
+ this.getClass().getSimpleName() + ".java")));
+ JavacTask task = (JavacTask) c.getTask(null, fm, null, null, null, fos);
- task.addTaskListener(new TaskListener() {
+ task.addTaskListener(new TaskListener() {
- @Override
- public void started(TaskEvent e) {}
+ @Override
+ public void started(TaskEvent e) {}
- @Override
- public void finished(TaskEvent e) {
- if (e.getKind() == TaskEvent.Kind.ANALYZE) {
- TypeElement te = e.getTypeElement();
- if (te.getSimpleName().toString().equals("I")) {
- checkDefaultInterface(te);
+ @Override
+ public void finished(TaskEvent e) {
+ if (e.getKind() == TaskEvent.Kind.ANALYZE) {
+ TypeElement te = e.getTypeElement();
+ if (te.getSimpleName().toString().equals("I")) {
+ checkDefaultInterface(te);
+ }
}
}
- }
- });
+ });
- task.analyze();
+ task.analyze();
+ }
}
void checkDefaultInterface(TypeElement te) {
--- a/langtools/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -123,18 +123,19 @@
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (MethodKind mk1 : MethodKind.values()) {
- for (SignatureKind sk1 : SignatureKind.values()) {
- for (BodyExpr be1 : BodyExpr.values()) {
- for (MethodKind mk2 : MethodKind.values()) {
- for (SignatureKind sk2 : SignatureKind.values()) {
- for (BodyExpr be2 : BodyExpr.values()) {
- for (MethodKind mk3 : MethodKind.values()) {
- for (SignatureKind sk3 : SignatureKind.values()) {
- for (BodyExpr be3 : BodyExpr.values()) {
- new InterfaceMethodHidingTest(mk1, mk2, mk3, sk1, sk2, sk3, be1, be2, be3).run(comp, fm);
+ for (MethodKind mk1 : MethodKind.values()) {
+ for (SignatureKind sk1 : SignatureKind.values()) {
+ for (BodyExpr be1 : BodyExpr.values()) {
+ for (MethodKind mk2 : MethodKind.values()) {
+ for (SignatureKind sk2 : SignatureKind.values()) {
+ for (BodyExpr be2 : BodyExpr.values()) {
+ for (MethodKind mk3 : MethodKind.values()) {
+ for (SignatureKind sk3 : SignatureKind.values()) {
+ for (BodyExpr be3 : BodyExpr.values()) {
+ new InterfaceMethodHidingTest(mk1, mk2, mk3, sk1, sk2, sk3, be1, be2, be3).run(comp, fm);
+ }
}
}
}
@@ -143,8 +144,8 @@
}
}
}
+ System.out.println("Total check executed: " + checkCount);
}
- System.out.println("Total check executed: " + checkCount);
}
MethodKind mk1, mk2, mk3;
--- a/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -188,20 +188,21 @@
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (VersionKind vk : VersionKind.values()) {
- for (EnclosingKind ek : EnclosingKind.values()) {
- for (MethodKind mk : MethodKind.values()) {
- for (ModifierKind modk1 : ModifierKind.values()) {
- for (ModifierKind modk2 : ModifierKind.values()) {
- new TestDefaultMethodsSyntax(vk, ek, mk, modk1, modk2).run(comp, fm);
+ for (VersionKind vk : VersionKind.values()) {
+ for (EnclosingKind ek : EnclosingKind.values()) {
+ for (MethodKind mk : MethodKind.values()) {
+ for (ModifierKind modk1 : ModifierKind.values()) {
+ for (ModifierKind modk2 : ModifierKind.values()) {
+ new TestDefaultMethodsSyntax(vk, ek, mk, modk1, modk2).run(comp, fm);
+ }
}
}
}
}
+ System.out.println("Total check executed: " + checkCount);
}
- System.out.println("Total check executed: " + checkCount);
}
VersionKind vk;
--- a/langtools/test/tools/javac/diags/CheckResourceKeys.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/diags/CheckResourceKeys.java Mon Nov 03 10:11:10 2014 -0800
@@ -313,27 +313,28 @@
Set<String> getCodeStrings() throws IOException {
Set<String> results = new TreeSet<String>();
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- JavaFileManager fm = c.getStandardFileManager(null, null, null);
- JavaFileManager.Location javacLoc = findJavacLocation(fm);
- String[] pkgs = {
- "javax.annotation.processing",
- "javax.lang.model",
- "javax.tools",
- "com.sun.source",
- "com.sun.tools.javac"
- };
- for (String pkg: pkgs) {
- for (JavaFileObject fo: fm.list(javacLoc,
- pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
- String name = fo.getName();
- // ignore resource files, and files which are not really part of javac
- if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*")
- || name.matches(".*CreateSymbols\\.class.*"))
- continue;
- scan(fo, results);
+ try (JavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ JavaFileManager.Location javacLoc = findJavacLocation(fm);
+ String[] pkgs = {
+ "javax.annotation.processing",
+ "javax.lang.model",
+ "javax.tools",
+ "com.sun.source",
+ "com.sun.tools.javac"
+ };
+ for (String pkg: pkgs) {
+ for (JavaFileObject fo: fm.list(javacLoc,
+ pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
+ String name = fo.getName();
+ // ignore resource files, and files which are not really part of javac
+ if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*")
+ || name.matches(".*CreateSymbols\\.class.*"))
+ continue;
+ scan(fo, results);
+ }
}
+ return results;
}
- return results;
}
// depending on how the test is run, javac may be on bootclasspath or classpath
--- a/langtools/test/tools/javac/doclint/DocLintTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/doclint/DocLintTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -109,44 +109,48 @@
void run() throws Exception {
javac = ToolProvider.getSystemJavaCompiler();
fm = javac.getStandardFileManager(null, null, null);
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
- file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
- @Override
- public CharSequence getCharContent(boolean ignoreEncoding) {
- return code;
- }
- };
+ try {
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+ file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncoding) {
+ return code;
+ }
+ };
- test(Collections.<String>emptyList(),
- Main.Result.OK,
- EnumSet.noneOf(Message.class));
+ test(Collections.<String>emptyList(),
+ Main.Result.OK,
+ EnumSet.noneOf(Message.class));
- test(Arrays.asList("-Xdoclint:none"),
- Main.Result.OK,
- EnumSet.noneOf(Message.class));
+ test(Arrays.asList("-Xdoclint:none"),
+ Main.Result.OK,
+ EnumSet.noneOf(Message.class));
+
+ test(Arrays.asList(rawDiags, "-Xdoclint"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
+ Main.Result.OK,
+ EnumSet.of(Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
- Main.Result.OK,
- EnumSet.of(Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR9));
- test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR9));
+ test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
+ Main.Result.CMDERR,
+ EnumSet.of(Message.OPT_BADARG));
- test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
- Main.Result.CMDERR,
- EnumSet.of(Message.OPT_BADARG));
-
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ } finally {
+ fm.close();
+ }
}
void test(List<String> opts, Main.Result expectResult, Set<Message> expectMessages) {
--- a/langtools/test/tools/javac/doctree/DocTreePathScannerTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/doctree/DocTreePathScannerTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -66,22 +66,23 @@
}
JavacTool javac = JavacTool.create();
- StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
+
+ Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
- Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+ JavacTask t = javac.getTask(null, fm, null, null, null, fos);
+ DocTrees trees = DocTrees.instance(t);
- JavacTask t = javac.getTask(null, fm, null, null, null, fos);
- DocTrees trees = DocTrees.instance(t);
+ Iterable<? extends CompilationUnitTree> units = t.parse();
- Iterable<? extends CompilationUnitTree> units = t.parse();
+ DeclScanner ds = new DeclScanner(trees);
+ for (CompilationUnitTree unit: units) {
+ ds.scan(unit, null);
+ }
- DeclScanner ds = new DeclScanner(trees);
- for (CompilationUnitTree unit: units) {
- ds.scan(unit, null);
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
}
-
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
}
void error(String msg) {
--- a/langtools/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -66,28 +66,29 @@
}
JavacTool javac = JavacTool.create();
- StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
- Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+ Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
- JavacTask t = javac.getTask(null, fm, null, null, null, fos);
- DocTrees trees = DocTrees.instance(t);
+ JavacTask t = javac.getTask(null, fm, null, null, null, fos);
+ DocTrees trees = DocTrees.instance(t);
- Iterable<? extends CompilationUnitTree> units = t.parse();
+ Iterable<? extends CompilationUnitTree> units = t.parse();
- Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class);
- DeclScanner ds = new DeclScanner(trees, found);
- for (CompilationUnitTree unit: units) {
- ds.scan(unit, null);
- }
+ Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class);
+ DeclScanner ds = new DeclScanner(trees, found);
+ for (CompilationUnitTree unit: units) {
+ ds.scan(unit, null);
+ }
- for (DocTree.Kind k: DocTree.Kind.values()) {
- if (!found.contains(k) && k != DocTree.Kind.OTHER)
- error("not found: " + k);
+ for (DocTree.Kind k: DocTree.Kind.values()) {
+ if (!found.contains(k) && k != DocTree.Kind.OTHER)
+ error("not found: " + k);
+ }
+
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
}
-
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
}
void error(String msg) {
--- a/langtools/test/tools/javac/file/T7068451.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/file/T7068451.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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 javax.tools.Diagnostic.Kind;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
@@ -75,34 +76,36 @@
System.err.println("FIRST compilation");
System.err.println();
- CompilationTask task = compiler.getTask(null, null, null, opts, null,
- compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
- task.setProcessors(Collections.singleton(new Proc("first")));
- check("compilation", task.call());
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ CompilationTask task = compiler.getTask(null, fm, null, opts, null,
+ fm.getJavaFileObjects(input));
+ task.setProcessors(Collections.singleton(new Proc("first")));
+ check("compilation", task.call());
- writeFile(tmp, "X.java", "package p; class X { { p.C.second(); } }");
+ writeFile(tmp, "X.java", "package p; class X { { p.C.second(); } }");
- //Thread.sleep(2000);
+ //Thread.sleep(2000);
- System.err.println();
- System.err.println("SECOND compilation");
- System.err.println();
+ System.err.println();
+ System.err.println("SECOND compilation");
+ System.err.println();
- task = compiler.getTask(null, null, null, opts, null,
- compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
- task.setProcessors(Collections.singleton(new Proc("second")));
- check("compilation", task.call());
+ task = compiler.getTask(null, fm, null, opts, null,
+ fm.getJavaFileObjects(input));
+ task.setProcessors(Collections.singleton(new Proc("second")));
+ check("compilation", task.call());
- //Thread.sleep(2000);
+ //Thread.sleep(2000);
- System.err.println();
- System.err.println("SECOND compilation, REPEATED");
- System.err.println();
+ System.err.println();
+ System.err.println("SECOND compilation, REPEATED");
+ System.err.println();
- task = compiler.getTask(null, null, null, opts, null,
- compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
- task.setProcessors(Collections.singleton(new Proc("second")));
- check("compilation", task.call());
+ task = compiler.getTask(null, fm, null, opts, null,
+ fm.getJavaFileObjects(input));
+ task.setProcessors(Collections.singleton(new Proc("second")));
+ check("compilation", task.call());
+ }
}
void check(String msg, boolean ok) {
--- a/langtools/test/tools/javac/flow/LVTHarness.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/flow/LVTHarness.java Mon Nov 03 10:11:10 2014 -0800
@@ -76,18 +76,21 @@
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
public static void main(String[] args) throws Exception {
+ try {
+ String testDir = System.getProperty("test.src");
+ fm.setLocation(SOURCE_PATH, Arrays.asList(new File(testDir, "tests")));
- String testDir = System.getProperty("test.src");
- fm.setLocation(SOURCE_PATH, Arrays.asList(new File(testDir, "tests")));
+ // Make sure classes are written to scratch dir.
+ fm.setLocation(CLASS_OUTPUT, Arrays.asList(new File(".")));
- // Make sure classes are written to scratch dir.
- fm.setLocation(CLASS_OUTPUT, Arrays.asList(new File(".")));
-
- for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(SOURCE), true)) {
- new LVTHarness(jfo).check();
- }
- if (nerrors > 0) {
- throw new AssertionError("Errors were found");
+ for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(SOURCE), true)) {
+ new LVTHarness(jfo).check();
+ }
+ if (nerrors > 0) {
+ throw new AssertionError("Errors were found");
+ }
+ } finally {
+ fm.close();
}
}
--- a/langtools/test/tools/javac/generics/bridges/BridgeHarness.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/generics/bridges/BridgeHarness.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -70,19 +70,23 @@
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
public static void main(String[] args) throws Exception {
- //set sourcepath
- fm.setLocation(SOURCE_PATH,
- Arrays.asList(new File(System.getProperty("test.src"), "tests")));
- //set output (-d)
- fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT,
- Arrays.asList(new File(System.getProperty("user.dir"))));
- for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
- //for each source, compile and check against annotations
- new BridgeHarness(jfo).compileAndCheck();
- }
- //if there were errors, fail
- if (nerrors > 0) {
- throw new AssertionError("Errors were found");
+ try {
+ //set sourcepath
+ fm.setLocation(SOURCE_PATH,
+ Arrays.asList(new File(System.getProperty("test.src"), "tests")));
+ //set output (-d)
+ fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT,
+ Arrays.asList(new File(System.getProperty("user.dir"))));
+ for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
+ //for each source, compile and check against annotations
+ new BridgeHarness(jfo).compileAndCheck();
+ }
+ //if there were errors, fail
+ if (nerrors > 0) {
+ throw new AssertionError("Errors were found");
+ }
+ } finally {
+ fm.close();
}
}
--- a/langtools/test/tools/javac/generics/diamond/7030150/GenericConstructorAndDiamondTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/generics/diamond/7030150/GenericConstructorAndDiamondTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -150,17 +150,17 @@
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
-
- for (BoundKind boundKind : BoundKind.values()) {
- for (ConstructorKind constructorKind : ConstructorKind.values()) {
- for (TypeArgumentKind declArgKind : TypeArgumentKind.values()) {
- for (TypeArgArity arity : TypeArgArity.values()) {
- for (TypeArgumentKind useArgKind : TypeArgumentKind.values()) {
- for (TypeArgumentKind diamondArgKind : TypeArgumentKind.values()) {
- for (ArgumentKind argKind : ArgumentKind.values()) {
- new GenericConstructorAndDiamondTest(boundKind, constructorKind,
- declArgKind, arity, useArgKind, diamondArgKind, argKind).run(comp, fm);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
+ for (BoundKind boundKind : BoundKind.values()) {
+ for (ConstructorKind constructorKind : ConstructorKind.values()) {
+ for (TypeArgumentKind declArgKind : TypeArgumentKind.values()) {
+ for (TypeArgArity arity : TypeArgArity.values()) {
+ for (TypeArgumentKind useArgKind : TypeArgumentKind.values()) {
+ for (TypeArgumentKind diamondArgKind : TypeArgumentKind.values()) {
+ for (ArgumentKind argKind : ArgumentKind.values()) {
+ new GenericConstructorAndDiamondTest(boundKind, constructorKind,
+ declArgKind, arity, useArgKind, diamondArgKind, argKind).run(comp, fm);
+ }
}
}
}
--- a/langtools/test/tools/javac/generics/diamond/7030687/ParserTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/generics/diamond/7030687/ParserTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -78,26 +78,27 @@
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (TypeQualifierArity arity : TypeQualifierArity.values()) {
- for (TypeArgumentKind tak1 : TypeArgumentKind.values()) {
- if (arity == TypeQualifierArity.ONE) {
- new ParserTest(arity, tak1).run(comp, fm);
- continue;
- }
- for (TypeArgumentKind tak2 : TypeArgumentKind.values()) {
- if (arity == TypeQualifierArity.TWO) {
- new ParserTest(arity, tak1, tak2).run(comp, fm);
+ for (TypeQualifierArity arity : TypeQualifierArity.values()) {
+ for (TypeArgumentKind tak1 : TypeArgumentKind.values()) {
+ if (arity == TypeQualifierArity.ONE) {
+ new ParserTest(arity, tak1).run(comp, fm);
continue;
}
- for (TypeArgumentKind tak3 : TypeArgumentKind.values()) {
- if (arity == TypeQualifierArity.THREE) {
- new ParserTest(arity, tak1, tak2, tak3).run(comp, fm);
+ for (TypeArgumentKind tak2 : TypeArgumentKind.values()) {
+ if (arity == TypeQualifierArity.TWO) {
+ new ParserTest(arity, tak1, tak2).run(comp, fm);
continue;
}
- for (TypeArgumentKind tak4 : TypeArgumentKind.values()) {
- new ParserTest(arity, tak1, tak2, tak3, tak4).run(comp, fm);
+ for (TypeArgumentKind tak3 : TypeArgumentKind.values()) {
+ if (arity == TypeQualifierArity.THREE) {
+ new ParserTest(arity, tak1, tak2, tak3).run(comp, fm);
+ continue;
+ }
+ for (TypeArgumentKind tak4 : TypeArgumentKind.values()) {
+ new ParserTest(arity, tak1, tak2, tak3, tak4).run(comp, fm);
+ }
}
}
}
--- a/langtools/test/tools/javac/generics/inference/7086601/T7086601b.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/generics/inference/7086601/T7086601b.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,18 +86,19 @@
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (TypeKind a1 : TypeKind.values()) {
- for (TypeKind a2 : TypeKind.values()) {
- for (TypeKind a3 : TypeKind.values()) {
- for (MethodCallKind mck : MethodCallKind.values()) {
- new T7086601b(a1, a2, a3, mck).run(comp, fm);
+ for (TypeKind a1 : TypeKind.values()) {
+ for (TypeKind a2 : TypeKind.values()) {
+ for (TypeKind a3 : TypeKind.values()) {
+ for (MethodCallKind mck : MethodCallKind.values()) {
+ new T7086601b(a1, a2, a3, mck).run(comp, fm);
+ }
}
}
}
+ System.out.println("Total check executed: " + checkCount);
}
- System.out.println("Total check executed: " + checkCount);
}
TypeKind a1;
--- a/langtools/test/tools/javac/lambda/BadLambdaExpr.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/lambda/BadLambdaExpr.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -105,18 +105,19 @@
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (ParameterListKind plk : ParameterListKind.values()) {
- for (ParameterKind pk : ParameterKind.values()) {
- for (ArrowKind ak : ArrowKind.values()) {
- for (ExprKind ek : ExprKind.values()) {
- new BadLambdaExpr(plk, pk, ak, ek).run(comp, fm);
+ for (ParameterListKind plk : ParameterListKind.values()) {
+ for (ParameterKind pk : ParameterKind.values()) {
+ for (ArrowKind ak : ArrowKind.values()) {
+ for (ExprKind ek : ExprKind.values()) {
+ new BadLambdaExpr(plk, pk, ak, ek).run(comp, fm);
+ }
}
}
}
+ System.out.println("Total check executed: " + checkCount);
}
- System.out.println("Total check executed: " + checkCount);
}
ParameterListKind plk;
--- a/langtools/test/tools/javac/lambda/TestSelfRef.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/lambda/TestSelfRef.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -114,22 +114,23 @@
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (EnclosingKind ek : EnclosingKind.values()) {
- for (SiteKind sk : SiteKind.values()) {
- if (sk == SiteKind.STATIC_INIT && ek == EnclosingKind.MEMBER_INNER)
- continue;
- for (InnerKind ik : InnerKind.values()) {
- if (ik != InnerKind.NONE && sk == SiteKind.NONE)
- break;
- for (RefKind rk : RefKind.values()) {
- new TestSelfRef(ek, sk, ik, rk).run(comp, fm);
+ for (EnclosingKind ek : EnclosingKind.values()) {
+ for (SiteKind sk : SiteKind.values()) {
+ if (sk == SiteKind.STATIC_INIT && ek == EnclosingKind.MEMBER_INNER)
+ continue;
+ for (InnerKind ik : InnerKind.values()) {
+ if (ik != InnerKind.NONE && sk == SiteKind.NONE)
+ break;
+ for (RefKind rk : RefKind.values()) {
+ new TestSelfRef(ek, sk, ik, rk).run(comp, fm);
+ }
}
}
}
+ System.out.println("Total check executed: " + checkCount);
}
- System.out.println("Total check executed: " + checkCount);
}
EnclosingKind ek;
--- a/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -185,14 +185,15 @@
public static void main(String... args) throws Exception {
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (CastInfo cInfo : allCastInfo()) {
- for (ExpressionKind ek : ExpressionKind.values()) {
- new IntersectionTargetTypeTest(cInfo, ek).run(comp, fm);
+ for (CastInfo cInfo : allCastInfo()) {
+ for (ExpressionKind ek : ExpressionKind.values()) {
+ new IntersectionTargetTypeTest(cInfo, ek).run(comp, fm);
+ }
}
+ System.out.println("Total check executed: " + checkCount);
}
- System.out.println("Total check executed: " + checkCount);
}
static List<CastInfo> allCastInfo() {
--- a/langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -250,13 +250,17 @@
}
public static void main(String[] args) throws Exception {
- for(Context ct : Context.values()) {
- for (FInterface fi : FInterface.values()) {
- for (MethodDef md: MethodDef.values()) {
- new SamConversionComboTest(fi, ct, md).test();
+ try {
+ for(Context ct : Context.values()) {
+ for (FInterface fi : FInterface.values()) {
+ for (MethodDef md: MethodDef.values()) {
+ new SamConversionComboTest(fi, ct, md).test();
+ }
}
}
+ System.out.println("total tests: " + count);
+ } finally {
+ fm.close();
}
- System.out.println("total tests: " + count);
}
}
--- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.util.Pair;
+import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.ArrayList;
@@ -41,6 +42,7 @@
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
+import org.testng.annotations.AfterSuite;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.DataProvider;
@@ -70,12 +72,19 @@
fm = comp.getStandardFileManager(null, null, null);
}
+ @AfterSuite
+ static void teardown() throws IOException {
+ fm.close();
+ }
+
public static void main(String[] args) throws Exception {
init();
for (Pair<TestKind,Hierarchy> fdtest : generateCases()) {
runTest(fdtest.fst, fdtest.snd, comp, fm);
}
+
+ teardown();
}
@Test(dataProvider = "fdCases")
--- a/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -193,27 +193,30 @@
void run() throws Exception {
javac = JavacTool.create();
fm = javac.getStandardFileManager(null, null, null);
-
- for (RunKind rk: RunKind.values()) {
- for (GenKind gk: GenKind.values()) {
- for (Method m: getClass().getDeclaredMethods()) {
- Annotation a = m.getAnnotation(Test.class);
- if (a != null) {
- init(rk, gk, m.getName());
- try {
- m.invoke(this, new Object[] { rk, gk });
- } catch (InvocationTargetException e) {
- Throwable cause = e.getCause();
- throw (cause instanceof Exception) ? ((Exception) cause) : e;
+ try {
+ for (RunKind rk: RunKind.values()) {
+ for (GenKind gk: GenKind.values()) {
+ for (Method m: getClass().getDeclaredMethods()) {
+ Annotation a = m.getAnnotation(Test.class);
+ if (a != null) {
+ init(rk, gk, m.getName());
+ try {
+ m.invoke(this, new Object[] { rk, gk });
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getCause();
+ throw (cause instanceof Exception) ? ((Exception) cause) : e;
+ }
+ System.err.println();
}
- System.err.println();
}
}
}
+ System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
+ if (errorCount > 0)
+ throw new Exception(errorCount + " errors found");
+ } finally {
+ fm.close();
}
- System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
- if (errorCount > 0)
- throw new Exception(errorCount + " errors found");
}
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/options/XjcovUnionTypeTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014, 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 8059453
+ * @summary -Xjcov causes crash with union types
+ * @compile -Xjcov XjcovUnionTypeTest.java
+ */
+
+public class XjcovUnionTypeTest {
+ public static void main(String[] args) {
+ try {
+ return;
+ } catch (IllegalStateException | IllegalArgumentException e) {
+ }
+ }
+}
--- a/langtools/test/tools/javac/options/xprefer/XPreferTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/options/xprefer/XPreferTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -45,6 +45,7 @@
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
@@ -73,27 +74,31 @@
}
final static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+ final static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
final static File OUTPUT_DIR = new File("out");
public static void main(String... args) throws Exception {
+ try {
+ // Initialize test-directories
+ OUTPUT_DIR.mkdir();
+ for (Dir dir : Dir.values())
+ dir.file.mkdir();
- // Initialize test-directories
- OUTPUT_DIR.mkdir();
- for (Dir dir : Dir.values())
- dir.file.mkdir();
-
- int testCaseCounter = 0;
+ int testCaseCounter = 0;
- for (List<Dir> dirSubset : SubseqIter.subseqsOf(Dir.values())) {
+ for (List<Dir> dirSubset : SubseqIter.subseqsOf(Dir.values())) {
+
+ if (dirSubset.isEmpty())
+ continue;
- if (dirSubset.isEmpty())
- continue;
-
- for (ImplicitOption policy : ImplicitOption.values()) {
- for (List<Dir> dirOrder : PermutationIterator.permutationsOf(dirSubset)) {
- new TestCase(dirOrder, policy, testCaseCounter++).run();
+ for (ImplicitOption policy : ImplicitOption.values()) {
+ for (List<Dir> dirOrder : PermutationIterator.permutationsOf(dirSubset)) {
+ new TestCase(dirOrder, policy, testCaseCounter++).run();
+ }
}
}
+ } finally {
+ fm.close();
}
}
@@ -234,8 +239,8 @@
if(dir == Dir.SOURCE_PATH)
return src;
// ...otherwise compile into a ".class".
- CompilationTask task = comp.getTask(null, null, null, null, null,
- comp.getStandardFileManager(null, null, null).getJavaFileObjects(src));
+ CompilationTask task = comp.getTask(null, fm, null, null, null,
+ fm.getJavaFileObjects(src));
File dest = new File(dir.file, classId + ".class");
if(!task.call() || !dest.exists())
throw new RuntimeException("Compilation failure.");
--- a/langtools/test/tools/javac/plugin/showtype/Test.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/plugin/showtype/Test.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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,21 +71,25 @@
}
void run() throws Exception {
- // compile the plugin explicitly, to a non-standard directory
- // so that we don't find it on the wrong path by accident
- pluginClasses.mkdirs();
- compile("-d", pluginClasses.getPath(), pluginSrc.getPath());
- writeFile(new File(pluginClasses, "META-INF/services/com.sun.source.util.Plugin"),
- "ShowTypePlugin\n");
- jar("cf", pluginJar.getPath(), "-C", pluginClasses.getPath(), ".");
+ try {
+ // compile the plugin explicitly, to a non-standard directory
+ // so that we don't find it on the wrong path by accident
+ pluginClasses.mkdirs();
+ compile("-d", pluginClasses.getPath(), pluginSrc.getPath());
+ writeFile(new File(pluginClasses, "META-INF/services/com.sun.source.util.Plugin"),
+ "ShowTypePlugin\n");
+ jar("cf", pluginJar.getPath(), "-C", pluginClasses.getPath(), ".");
- testCommandLine("-Xplugin:showtype", ref1);
- testCommandLine("-Xplugin:showtype PI", ref2);
- testAPI("-Xplugin:showtype", ref1);
- testAPI("-Xplugin:showtype PI", ref2);
+ testCommandLine("-Xplugin:showtype", ref1);
+ testCommandLine("-Xplugin:showtype PI", ref2);
+ testAPI("-Xplugin:showtype", ref1);
+ testAPI("-Xplugin:showtype PI", ref2);
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ } finally {
+ fm.close();
+ }
}
void testAPI(String opt, List<String> ref) throws Exception {
--- a/langtools/test/tools/javac/positions/TreeEndPosTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/positions/TreeEndPosTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -137,32 +137,33 @@
File tempDir = new File(".");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
DiagnosticCollector dc = new DiagnosticCollector();
- JavaFileManager javaFileManager = getJavaFileManager(compiler, dc);
- List<String> options = new ArrayList<>();
- options.add("-cp");
- options.add(tempDir.getPath());
- options.add("-d");
- options.add(tempDir.getPath());
- options.add("-XDshouldStopPolicy=GENERATE");
+ try (JavaFileManager javaFileManager = getJavaFileManager(compiler, dc)) {
+ List<String> options = new ArrayList<>();
+ options.add("-cp");
+ options.add(tempDir.getPath());
+ options.add("-d");
+ options.add(tempDir.getPath());
+ options.add("-XDshouldStopPolicy=GENERATE");
- List<JavaFileObject> sources = new ArrayList<>();
- sources.add(src);
- JavaCompiler.CompilationTask task =
- compiler.getTask(writer, javaFileManager,
- dc, options, null,
- sources);
- task.call();
- for (Diagnostic diagnostic : (List<Diagnostic>) dc.getDiagnostics()) {
- long actualStart = diagnostic.getStartPosition();
- long actualEnd = diagnostic.getEndPosition();
- System.out.println("Source: " + src.source);
- System.out.println("Diagnostic: " + diagnostic);
- System.out.print("Start position: Expected: " + src.startPos);
- System.out.println(", Actual: " + actualStart);
- System.out.print("End position: Expected: " + src.endPos);
- System.out.println(", Actual: " + actualEnd);
- if (src.startPos != actualStart || src.endPos != actualEnd) {
- throw new RuntimeException("error: trees don't match");
+ List<JavaFileObject> sources = new ArrayList<>();
+ sources.add(src);
+ JavaCompiler.CompilationTask task =
+ compiler.getTask(writer, javaFileManager,
+ dc, options, null,
+ sources);
+ task.call();
+ for (Diagnostic diagnostic : (List<Diagnostic>) dc.getDiagnostics()) {
+ long actualStart = diagnostic.getStartPosition();
+ long actualEnd = diagnostic.getEndPosition();
+ System.out.println("Source: " + src.source);
+ System.out.println("Diagnostic: " + diagnostic);
+ System.out.print("Start position: Expected: " + src.startPos);
+ System.out.println(", Actual: " + actualStart);
+ System.out.print("End position: Expected: " + src.endPos);
+ System.out.println(", Actual: " + actualEnd);
+ if (src.startPos != actualStart || src.endPos != actualEnd) {
+ throw new RuntimeException("error: trees don't match");
+ }
}
}
}
--- a/langtools/test/tools/javac/processing/6348193/T6348193.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/6348193/T6348193.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,35 +85,36 @@
MyDiagListener dl = new MyDiagListener();
PrintWriter out = new PrintWriter(System.err, true);
- StandardJavaFileManager fm = t.getStandardFileManager(dl, null, null);
- File file = new File(System.getProperty("test.src"), myName+".java");
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(file));
- boolean ok = t.getTask(out, null, dl, args, null, files).call();
+ try (StandardJavaFileManager fm = t.getStandardFileManager(dl, null, null)) {
+ File file = new File(System.getProperty("test.src"), myName+".java");
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(file));
+ boolean ok = t.getTask(out, null, dl, args, null, files).call();
- if (config == NoGoodBad.GOOD || proc == NoYes.YES) {
- if (secMgr == NoYes.YES) {
- if (dl.last == null)
- throw new AssertionError("Security manager installed, and processors present, "
- + " but no diagnostic received");
+ if (config == NoGoodBad.GOOD || proc == NoYes.YES) {
+ if (secMgr == NoYes.YES) {
+ if (dl.last == null)
+ throw new AssertionError("Security manager installed, and processors present, "
+ + " but no diagnostic received");
+ }
+ else {
+ if (!processed.exists())
+ throw new AssertionError("No security manager installed, and processors present, "
+ + " but no processing occurred");
+ }
+ }
+ else if (config == NoGoodBad.BAD) {
+ // TODO: should verify that no compiler crash occurred
+ // needs revised JSR199 spec
}
else {
- if (!processed.exists())
- throw new AssertionError("No security manager installed, and processors present, "
- + " but no processing occurred");
+ if (processed.exists())
+ throw new AssertionError("No processors present, but processing occurred!");
}
+
+ if (verbose)
+ System.err.println("OK");
}
- else if (config == NoGoodBad.BAD) {
- // TODO: should verify that no compiler crash occurred
- // needs revised JSR199 spec
- }
- else {
- if (processed.exists())
- throw new AssertionError("No processors present, but processing occurred!");
- }
-
- if (verbose)
- System.err.println("OK");
}
// set up or remove a service configuration file
--- a/langtools/test/tools/javac/processing/6348499/T6348499.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/6348499/T6348499.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,32 +44,33 @@
public class T6348499 {
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes");
String testClassPath = System.getProperty("test.class.path", testClasses);
String A_java = new File(testSrc, "A.java").getPath();
JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener();
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
- Iterable<String> opts = Arrays.asList("-proc:only",
- "-processor", "A",
- "-processorpath", testClassPath);
- StringWriter out = new StringWriter();
- JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
- task.call();
- String s = out.toString();
- System.err.print(s);
- // Expect the following 1 multi-line diagnostic, and no output to log
- // error: cannot access A_0
- // bad class file: A_0.class
- // illegal start of class file
- // Please remove or make sure it appears in the correct subdirectory of the classpath.
- System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
- if (dl.count != 1 || s.length() != 0)
- throw new AssertionError("unexpected output from compiler");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
+ Iterable<String> opts = Arrays.asList("-proc:only",
+ "-processor", "A",
+ "-processorpath", testClassPath);
+ StringWriter out = new StringWriter();
+ JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
+ task.call();
+ String s = out.toString();
+ System.err.print(s);
+ // Expect the following 1 multi-line diagnostic, and no output to log
+ // error: cannot access A_0
+ // bad class file: A_0.class
+ // illegal start of class file
+ // Please remove or make sure it appears in the correct subdirectory of the classpath.
+ System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
+ if (dl.count != 1 || s.length() != 0)
+ throw new AssertionError("unexpected output from compiler");
+ }
}
static class MyDiagListener implements DiagnosticListener<JavaFileObject> {
--- a/langtools/test/tools/javac/processing/6378728/T6378728.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/6378728/T6378728.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,21 +64,22 @@
}
}
- public static void main(String[] args) {
+ public static void main(String[] args) throws IOException {
// Get a compiler tool
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
String srcdir = System.getProperty("test.src");
File source = new File(srcdir, "T6378728.java");
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
- CompilationTask task =
- compiler.getTask(null,
- new ExceptionalFileManager(fm),
- null,
- Arrays.asList("-proc:only"),
- null,
- fm.getJavaFileObjectsFromFiles(Arrays.asList(source)));
- if (!task.call())
- throw new RuntimeException("Unexpected compilation failure");
+ CompilationTask task =
+ compiler.getTask(null,
+ new ExceptionalFileManager(fm),
+ null,
+ Arrays.asList("-proc:only"),
+ null,
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(source)));
+ if (!task.call())
+ throw new RuntimeException("Unexpected compilation failure");
+ }
}
}
--- a/langtools/test/tools/javac/processing/6414633/T6414633.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/6414633/T6414633.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,29 +40,30 @@
import com.sun.tools.javac.api.*;
public class T6414633 {
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes", ".");
String testClassPath = System.getProperty("test.class.path", testClasses);
JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener();
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- try {
- fm.setLocation(StandardLocation.CLASS_PATH, pathToFiles(testClassPath));
- } catch (IOException e) {
- throw new AssertionError(e);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ try {
+ fm.setLocation(StandardLocation.CLASS_PATH, pathToFiles(testClassPath));
+ } catch (IOException e) {
+ throw new AssertionError(e);
+ }
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java")));
+ String[] opts = { "-proc:only",
+ "-processor", A.class.getName() };
+ JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files);
+ task.call();
+
+ // two annotations on the same element -- expect 2 diags from the processor
+ if (dl.diags != 2)
+ throw new AssertionError(dl.diags + " diagnostics reported");
}
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java")));
- String[] opts = { "-proc:only",
- "-processor", A.class.getName() };
- JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files);
- task.call();
-
- // two annotations on the same element -- expect 2 diags from the processor
- if (dl.diags != 2)
- throw new AssertionError(dl.diags + " diagnostics reported");
}
private static List<File> pathToFiles(String path) {
--- a/langtools/test/tools/javac/processing/6430209/T6430209.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/6430209/T6430209.java Mon Nov 03 10:11:10 2014 -0800
@@ -58,22 +58,23 @@
String testClassPath = System.getProperty("test.class.path");
JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener();
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
- new File(testSrc, "test0.java"), new File(testSrc, "test1.java")));
- Iterable<String> opts = Arrays.asList("-proc:only",
- "-processor", "b6341534",
- "-processorpath", testClassPath);
- StringWriter out = new StringWriter();
- JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
- task.call();
- String s = out.toString();
- System.err.print(s);
- // Expect the following 2 diagnostics, and no output to log
- System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
- if (dl.count != 2 || s.length() != 0)
- throw new AssertionError("unexpected output from compiler");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
+ new File(testSrc, "test0.java"), new File(testSrc, "test1.java")));
+ Iterable<String> opts = Arrays.asList("-proc:only",
+ "-processor", "b6341534",
+ "-processorpath", testClassPath);
+ StringWriter out = new StringWriter();
+ JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
+ task.call();
+ String s = out.toString();
+ System.err.print(s);
+ // Expect the following 2 diagnostics, and no output to log
+ System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
+ if (dl.count != 2 || s.length() != 0)
+ throw new AssertionError("unexpected output from compiler");
+ }
}
static class MyDiagListener implements DiagnosticListener<JavaFileObject> {
--- a/langtools/test/tools/javac/processing/T6439826.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/T6439826.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,28 +40,29 @@
@SupportedAnnotationTypes("*")
public class T6439826 extends AbstractProcessor {
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes");
JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener();
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java")));
- Iterable<String> opts = Arrays.asList("-proc:only",
- "-processor", "T6439826",
- "-processorpath", testClasses);
- StringWriter out = new StringWriter();
- JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
- task.call();
- String s = out.toString();
- System.err.print(s);
- // Expect the following 2 diagnostics, and no output to log
- // Foo.java:1: illegal character: \35
- // Foo.java:1: reached end of file while parsing
- System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
- if (dl.count != 2 || s.length() != 0)
- throw new AssertionError("unexpected output from compiler");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java")));
+ Iterable<String> opts = Arrays.asList("-proc:only",
+ "-processor", "T6439826",
+ "-processorpath", testClasses);
+ StringWriter out = new StringWriter();
+ JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
+ task.call();
+ String s = out.toString();
+ System.err.print(s);
+ // Expect the following 2 diagnostics, and no output to log
+ // Foo.java:1: illegal character: \35
+ // Foo.java:1: reached end of file while parsing
+ System.err.println(dl.count + " diagnostics; " + s.length() + " characters");
+ if (dl.count != 2 || s.length() != 0)
+ throw new AssertionError("unexpected output from compiler");
+ }
}
public boolean process(Set<? extends TypeElement> annotations,
--- a/langtools/test/tools/javac/processing/errors/TestSuppression.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/errors/TestSuppression.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,41 +100,42 @@
DiagListener dl = new DiagListener();
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
- fm.setLocation(StandardLocation.CLASS_PATH,
- Arrays.asList(classesDir, new File(System.getProperty("test.classes"))));
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(classesDir));
- fm.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(gensrcDir));
- List<String> args = new ArrayList<String>();
-// args.add("-XprintProcessorInfo");
- args.add("-XprintRounds");
- args.add("-Agen=" + gen);
- if (wk == WarningKind.YES)
- args.add("-Xlint:serial");
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(x);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
+ fm.setLocation(StandardLocation.CLASS_PATH,
+ Arrays.asList(classesDir, new File(System.getProperty("test.classes"))));
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(classesDir));
+ fm.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(gensrcDir));
+ List<String> args = new ArrayList<String>();
+ // args.add("-XprintProcessorInfo");
+ args.add("-XprintRounds");
+ args.add("-Agen=" + gen);
+ if (wk == WarningKind.YES)
+ args.add("-Xlint:serial");
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(x);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- JavacTask task = tool.getTask(pw, fm, dl, args, null, files);
- task.setProcessors(Arrays.asList(new AnnoProc()));
- boolean ok = task.call();
- pw.close();
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ JavacTask task = tool.getTask(pw, fm, dl, args, null, files);
+ task.setProcessors(Arrays.asList(new AnnoProc()));
+ boolean ok = task.call();
+ pw.close();
- System.err.println("ok:" + ok + " diags:" + dl.counts);
- if (sw.toString().length() > 0) {
- System.err.println("output:\n" + sw.toString());
+ System.err.println("ok:" + ok + " diags:" + dl.counts);
+ if (sw.toString().length() > 0) {
+ System.err.println("output:\n" + sw.toString());
+ }
+
+ for (Diagnostic.Kind dk: Diagnostic.Kind.values()) {
+ Integer v = dl.counts.get(dk);
+ int found = (v == null) ? 0 : v;
+ int expect = (dk == Diagnostic.Kind.WARNING && wk == WarningKind.YES) ? gen : 0;
+ if (found != expect) {
+ error("Unexpected value for " + dk + ": expected: " + expect + " found: " + found);
+ }
+ }
+
+ System.err.println();
}
-
- for (Diagnostic.Kind dk: Diagnostic.Kind.values()) {
- Integer v = dl.counts.get(dk);
- int found = (v == null) ? 0 : v;
- int expect = (dk == Diagnostic.Kind.WARNING && wk == WarningKind.YES) ? gen : 0;
- if (found != expect) {
- error("Unexpected value for " + dk + ": expected: " + expect + " found: " + found);
- }
- }
-
- System.err.println();
}
File createDir(File parent, String name) {
--- a/langtools/test/tools/javac/processing/loader/testClose/TestClose.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -117,50 +117,51 @@
void run() throws IOException {
JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
- File classes = new File("classes");
- classes.mkdirs();
- File extraClasses = new File("extraClasses");
- extraClasses.mkdirs();
+ File classes = new File("classes");
+ classes.mkdirs();
+ File extraClasses = new File("extraClasses");
+ extraClasses.mkdirs();
- System.out.println("compiling classes to extraClasses");
- { // setup class in extraClasses
- fm.setLocation(StandardLocation.CLASS_OUTPUT,
- Collections.singleton(extraClasses));
- List<? extends JavaFileObject> files = Arrays.asList(
- new MemFile("AnnoProc.java", annoProc),
- new MemFile("Callback.java", callback));
- JavacTask task = tool.getTask(null, fm, null, null, null, files);
- check(task.call());
- }
+ System.out.println("compiling classes to extraClasses");
+ { // setup class in extraClasses
+ fm.setLocation(StandardLocation.CLASS_OUTPUT,
+ Collections.singleton(extraClasses));
+ List<? extends JavaFileObject> files = Arrays.asList(
+ new MemFile("AnnoProc.java", annoProc),
+ new MemFile("Callback.java", callback));
+ JavacTask task = tool.getTask(null, fm, null, null, null, files);
+ check(task.call());
+ }
- System.out.println("compiling dummy to classes with anno processor");
- { // use that class in a TaskListener after processing has completed
- PrintStream prev = System.out;
- String out;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (PrintStream ps = new PrintStream(baos)) {
- System.setOut(ps);
- File testClasses = new File(System.getProperty("test.classes"));
- fm.setLocation(StandardLocation.CLASS_OUTPUT,
- Collections.singleton(classes));
- fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
- Arrays.asList(extraClasses, testClasses));
- List<? extends JavaFileObject> files = Arrays.asList(
- new MemFile("my://dummy", "class Dummy { }"));
- List<String> options = Arrays.asList("-processor", "AnnoProc");
- JavacTask task = tool.getTask(null, fm, null, options, null, files);
- task.setTaskListener(this);
- check(task.call());
- } finally {
- System.setOut(prev);
- out = baos.toString();
- if (!out.isEmpty())
- System.out.println(out);
+ System.out.println("compiling dummy to classes with anno processor");
+ { // use that class in a TaskListener after processing has completed
+ PrintStream prev = System.out;
+ String out;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (PrintStream ps = new PrintStream(baos)) {
+ System.setOut(ps);
+ File testClasses = new File(System.getProperty("test.classes"));
+ fm.setLocation(StandardLocation.CLASS_OUTPUT,
+ Collections.singleton(classes));
+ fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
+ Arrays.asList(extraClasses, testClasses));
+ List<? extends JavaFileObject> files = Arrays.asList(
+ new MemFile("my://dummy", "class Dummy { }"));
+ List<String> options = Arrays.asList("-processor", "AnnoProc");
+ JavacTask task = tool.getTask(null, fm, null, options, null, files);
+ task.setTaskListener(this);
+ check(task.call());
+ } finally {
+ System.setOut(prev);
+ out = baos.toString();
+ if (!out.isEmpty())
+ System.out.println(out);
+ }
+ check(out.contains("AnnoProc$1: run()"));
+ check(out.contains("Callback: run()"));
}
- check(out.contains("AnnoProc$1: run()"));
- check(out.contains("Callback: run()"));
}
}
--- a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, 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,66 +64,67 @@
return;
}
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- fm.setLocation(CLASS_PATH, Collections.<File>emptyList());
- JavacTask javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
- Elements elements = javac.getElements();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ fm.setLocation(CLASS_PATH, Collections.<File>emptyList());
+ JavacTask javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
+ Elements elements = javac.getElements();
- final Set<String> packages = new LinkedHashSet<String>();
+ final Set<String> packages = new LinkedHashSet<String>();
- int nestedClasses = 0;
- int classes = 0;
+ int nestedClasses = 0;
+ int classes = 0;
- for (JavaFileObject file : fm.list(PLATFORM_CLASS_PATH, "", EnumSet.of(CLASS), true)) {
- String type = fm.inferBinaryName(PLATFORM_CLASS_PATH, file);
- if (type.endsWith("package-info"))
- continue;
- try {
- TypeElement elem = elements.getTypeElement(type);
- if (elem == null && type.indexOf('$') > 0) {
- nestedClasses++;
- type = null;
+ for (JavaFileObject file : fm.list(PLATFORM_CLASS_PATH, "", EnumSet.of(CLASS), true)) {
+ String type = fm.inferBinaryName(PLATFORM_CLASS_PATH, file);
+ if (type.endsWith("package-info"))
continue;
+ try {
+ TypeElement elem = elements.getTypeElement(type);
+ if (elem == null && type.indexOf('$') > 0) {
+ nestedClasses++;
+ type = null;
+ continue;
+ }
+ classes++;
+ packages.add(getPackage(elem).getQualifiedName().toString());
+ elements.getTypeElement(type).getKind(); // force completion
+ type = null;
+ } finally {
+ if (type != null)
+ System.err.println("Looking at " + type);
}
- classes++;
- packages.add(getPackage(elem).getQualifiedName().toString());
- elements.getTypeElement(type).getKind(); // force completion
- type = null;
- } finally {
- if (type != null)
- System.err.println("Looking at " + type);
+ }
+ javac = null;
+ elements = null;
+
+ javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
+ elements = javac.getElements();
+
+ for (String name : packages) {
+ PackageElement pe = elements.getPackageElement(name);
+ for (Element e : pe.getEnclosedElements()) {
+ e.getSimpleName().getClass();
+ }
}
+ /*
+ * A few sanity checks based on current values:
+ *
+ * packages: 775, classes: 12429 + 5917
+ *
+ * As the platform evolves the numbers are likely to grow
+ * monotonically but in case somebody gets a clever idea for
+ * limiting the number of packages exposed, this number might
+ * drop. So we test low values.
+ */
+ System.out.format("packages: %s, classes: %s + %s%n",
+ packages.size(), classes, nestedClasses);
+ if (classes < 9000)
+ throw new AssertionError("Too few classes in PLATFORM_CLASS_PATH ;-)");
+ if (packages.size() < 530)
+ throw new AssertionError("Too few packages in PLATFORM_CLASS_PATH ;-)");
+ if (nestedClasses < 3000)
+ throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)");
}
- javac = null;
- elements = null;
-
- javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
- elements = javac.getElements();
-
- for (String name : packages) {
- PackageElement pe = elements.getPackageElement(name);
- for (Element e : pe.getEnclosedElements()) {
- e.getSimpleName().getClass();
- }
- }
- /*
- * A few sanity checks based on current values:
- *
- * packages: 775, classes: 12429 + 5917
- *
- * As the platform evolves the numbers are likely to grow
- * monotonically but in case somebody gets a clever idea for
- * limiting the number of packages exposed, this number might
- * drop. So we test low values.
- */
- System.out.format("packages: %s, classes: %s + %s%n",
- packages.size(), classes, nestedClasses);
- if (classes < 9000)
- throw new AssertionError("Too few classes in PLATFORM_CLASS_PATH ;-)");
- if (packages.size() < 530)
- throw new AssertionError("Too few packages in PLATFORM_CLASS_PATH ;-)");
- if (nestedClasses < 3000)
- throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)");
}
/*
* If -XX:+AggressiveOpts has been used to test, the option currently
--- a/langtools/test/tools/javac/processing/model/type/BoundsTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/model/type/BoundsTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test
* @bug 6499673
* @library /tools/javac/lib
+ * @ignore 8062245 Test executes incorrect class
* @build JavacTestingAbstractProcessor BoundsTest
* @run main BoundsTest
* @summary Assertion check for TypeVariable.getUpperBound() fails
@@ -113,15 +114,19 @@
}
public void run() throws IOException {
- runOne(Intersection_name, Intersection_contents,
- Intersection_bounds, Intersection_supers);
- runOne(Single_name, Single_contents,
- Single_bounds, Single_supers);
- runOne(NoBounds_name, NoBounds_contents,
- NoBounds_bounds, NoBounds_supers);
+ try {
+ runOne(Intersection_name, Intersection_contents,
+ Intersection_bounds, Intersection_supers);
+ runOne(Single_name, Single_contents,
+ Single_bounds, Single_supers);
+ runOne(NoBounds_name, NoBounds_contents,
+ NoBounds_bounds, NoBounds_supers);
- if (0 != errors)
- throw new RuntimeException(errors + " errors occurred");
+ if (0 != errors)
+ throw new RuntimeException(errors + " errors occurred");
+ } finally {
+ fm.close();
+ }
}
public static void main(String... args) throws IOException {
--- a/langtools/test/tools/javac/processing/model/type/IntersectionPropertiesTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/model/type/IntersectionPropertiesTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -76,10 +76,14 @@
}
public void run() throws IOException {
- runOne(Intersection_name, Intersection_contents);
+ try {
+ runOne(Intersection_name, Intersection_contents);
- if (0 != errors)
- throw new RuntimeException(errors + " errors occurred");
+ if (0 != errors)
+ throw new RuntimeException(errors + " errors occurred");
+ } finally {
+ fm.close();
+ }
}
public static void main(String... args) throws IOException {
--- a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java Mon Nov 03 10:11:10 2014 -0800
@@ -104,11 +104,12 @@
}
};
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> units = fm.getJavaFileObjects(files);
- JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units);
- t.parse();
- t.analyze();
+ try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> units = fm.getJavaFileObjects(files);
+ JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units);
+ t.parse();
+ t.analyze();
+ }
}
static void test_javac_cmd(String[] opts, File[] files) {
--- a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java Mon Nov 03 10:11:10 2014 -0800
@@ -60,11 +60,12 @@
}
};
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> units = fm.getJavaFileObjects(files);
- JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units);
- t.parse();
- t.analyze();
+ try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> units = fm.getJavaFileObjects(files);
+ JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units);
+ t.parse();
+ t.analyze();
+ }
}
// -- Annotation processor: Check all PackageDecl's have a doc comment
--- a/langtools/test/tools/javac/processing/options/testCommandLineClasses/Test.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/options/testCommandLineClasses/Test.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,16 +67,17 @@
void test(List<String> names) throws Exception {
System.err.println("test: " + names);
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
- File testClasses = new File(System.getProperty("test.classes"));
- fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses));
- JavaCompiler.CompilationTask task = compiler.getTask(
- null, null, null, Arrays.asList("-proc:only"), names, null);
- task.setProcessors(Arrays.asList(new Test()));
- boolean ok = task.call();
- if (!ok)
- error("compilation failed");
- System.err.println();
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ File testClasses = new File(System.getProperty("test.classes"));
+ fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses));
+ JavaCompiler.CompilationTask task = compiler.getTask(
+ null, null, null, Arrays.asList("-proc:only"), names, null);
+ task.setProcessors(Arrays.asList(new Test()));
+ boolean ok = task.call();
+ if (!ok)
+ error("compilation failed");
+ System.err.println();
+ }
}
<T> List<T> reverse(List<T> list) {
--- a/langtools/test/tools/javac/processing/rounds/BaseClassesNotReRead.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/processing/rounds/BaseClassesNotReRead.java Mon Nov 03 10:11:10 2014 -0800
@@ -49,19 +49,20 @@
void run() throws IOException {
File sources = new File(System.getProperty("test.src"));
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files =
- fm.getJavaFileObjects(new File(sources, "BaseClassesNotReReadSource.java"));
- DiagnosticListener<JavaFileObject> noErrors = new DiagnosticListener<JavaFileObject>() {
- @Override
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- throw new IllegalStateException(diagnostic.toString());
- }
- };
- JavaFileManager manager = new OnlyOneReadFileManager(fm);
- Iterable<String> options = Arrays.asList("-processor", "BaseClassesNotReRead");
- JavacTask task = (JavacTask) compiler.getTask(null, manager, noErrors, options, null, files);
- task.analyze();
+ try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files =
+ fm.getJavaFileObjects(new File(sources, "BaseClassesNotReReadSource.java"));
+ DiagnosticListener<JavaFileObject> noErrors = new DiagnosticListener<JavaFileObject>() {
+ @Override
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ throw new IllegalStateException(diagnostic.toString());
+ }
+ };
+ JavaFileManager manager = new OnlyOneReadFileManager(fm);
+ Iterable<String> options = Arrays.asList("-processor", "BaseClassesNotReRead");
+ JavacTask task = (JavacTask) compiler.getTask(null, manager, noErrors, options, null, files);
+ task.analyze();
+ }
}
int round = 1;
--- a/langtools/test/tools/javac/profiles/ProfileOptionTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/profiles/ProfileOptionTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -236,24 +236,28 @@
/** Run all test cases. */
void run() throws Exception {
- initTestClasses();
+ try {
+ initTestClasses();
- for (Method m: getClass().getDeclaredMethods()) {
- Annotation a = m.getAnnotation(Test.class);
- if (a != null) {
- System.err.println(m.getName());
- try {
- m.invoke(this, new Object[] { });
- } catch (InvocationTargetException e) {
- Throwable cause = e.getCause();
- throw (cause instanceof Exception) ? ((Exception) cause) : e;
+ for (Method m: getClass().getDeclaredMethods()) {
+ Annotation a = m.getAnnotation(Test.class);
+ if (a != null) {
+ System.err.println(m.getName());
+ try {
+ m.invoke(this, new Object[] { });
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getCause();
+ throw (cause instanceof Exception) ? ((Exception) cause) : e;
+ }
+ System.err.println();
}
- System.err.println();
}
+
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ } finally {
+ fm.close();
}
-
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
}
void error(String msg) {
--- a/langtools/test/tools/javac/resolve/ResolveHarness.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/resolve/ResolveHarness.java Mon Nov 03 10:11:10 2014 -0800
@@ -71,13 +71,17 @@
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
public static void main(String[] args) throws Exception {
- fm.setLocation(SOURCE_PATH,
- Arrays.asList(new File(System.getProperty("test.src"), "tests")));
- for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
- new ResolveHarness(jfo).check();
- }
- if (nerrors > 0) {
- throw new AssertionError("Errors were found");
+ try {
+ fm.setLocation(SOURCE_PATH,
+ Arrays.asList(new File(System.getProperty("test.src"), "tests")));
+ for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
+ new ResolveHarness(jfo).check();
+ }
+ if (nerrors > 0) {
+ throw new AssertionError("Errors were found");
+ }
+ } finally {
+ fm.close();
}
}
--- a/langtools/test/tools/javac/tree/ClassTreeTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/ClassTreeTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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,25 +41,26 @@
void run() throws Exception {
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- List<String> opts = Collections.<String>emptyList();
- File testSrc = new File(System.getProperty("test.src"));
- File thisFile = new File(testSrc, ClassTreeTest.class.getSimpleName() + ".java");
- Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
- JavacTask task = tool.getTask(null, fm, null, opts, null, fos);
- for (CompilationUnitTree cu: task.parse()) {
- check(cu, "CLASS", Tree.Kind.CLASS);
- check(cu, "INTERFACE", Tree.Kind.INTERFACE);
- check(cu, "ENUM", Tree.Kind.ENUM);
- check(cu, "ANNOTATION_TYPE", Tree.Kind.ANNOTATION_TYPE);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ List<String> opts = Collections.<String>emptyList();
+ File testSrc = new File(System.getProperty("test.src"));
+ File thisFile = new File(testSrc, ClassTreeTest.class.getSimpleName() + ".java");
+ Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
+ JavacTask task = tool.getTask(null, fm, null, opts, null, fos);
+ for (CompilationUnitTree cu: task.parse()) {
+ check(cu, "CLASS", Tree.Kind.CLASS);
+ check(cu, "INTERFACE", Tree.Kind.INTERFACE);
+ check(cu, "ENUM", Tree.Kind.ENUM);
+ check(cu, "ANNOTATION_TYPE", Tree.Kind.ANNOTATION_TYPE);
+ }
+
+ int expected = 4;
+ if (checks != expected)
+ error("Unexpected number of checks performed; expected: " + expected + ", found: " + checks);
+
+ if (errors > 0)
+ throw new Exception(errors + " errors found");
}
-
- int expected = 4;
- if (checks != expected)
- error("Unexpected number of checks performed; expected: " + expected + ", found: " + checks);
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
}
void check(CompilationUnitTree cu, String name, Tree.Kind k) {
--- a/langtools/test/tools/javac/tree/DocCommentToplevelTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/DocCommentToplevelTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,24 +90,25 @@
public static void main(String... args) throws Exception {
//create default shared JavaCompiler - reused across multiple compilations
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
- for (PackageKind pk : PackageKind.values()) {
- for (ImportKind ik : ImportKind.values()) {
- for (ModifierKind mk1 : ModifierKind.values()) {
- for (ModifierKind mk2 : ModifierKind.values()) {
- for (ToplevelDocKind tdk : ToplevelDocKind.values()) {
- new DocCommentToplevelTest(pk, ik, mk1, mk2, tdk).run(comp, fm);
+ for (PackageKind pk : PackageKind.values()) {
+ for (ImportKind ik : ImportKind.values()) {
+ for (ModifierKind mk1 : ModifierKind.values()) {
+ for (ModifierKind mk2 : ModifierKind.values()) {
+ for (ToplevelDocKind tdk : ToplevelDocKind.values()) {
+ new DocCommentToplevelTest(pk, ik, mk1, mk2, tdk).run(comp, fm);
+ }
}
}
}
}
- }
- if (errors > 0)
- throw new AssertionError(errors + " errors found");
+ if (errors > 0)
+ throw new AssertionError(errors + " errors found");
- System.out.println(checks + " checks were made");
+ System.out.println(checks + " checks were made");
+ }
}
PackageKind pk;
--- a/langtools/test/tools/javac/tree/MissingSemicolonTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/MissingSemicolonTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -47,7 +47,7 @@
import com.sun.tools.javac.util.Context;
public class MissingSemicolonTest {
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
String testSrc = System.getProperty("test.src");
File baseDir = new File(testSrc);
boolean ok = new MissingSemicolonTest().run(baseDir, args);
@@ -56,24 +56,28 @@
}
}
- boolean run(File baseDir, String... args) {
- if (args.length == 0) {
- throw new IllegalStateException("Needs input files.");
- }
+ boolean run(File baseDir, String... args) throws IOException {
+ try {
+ if (args.length == 0) {
+ throw new IllegalStateException("Needs input files.");
+ }
- for (String arg : args) {
- File file = new File(baseDir, arg);
- if (file.exists())
- test(file);
- else
- error("File not found: " + file);
+ for (String arg : args) {
+ File file = new File(baseDir, arg);
+ if (file.exists())
+ test(file);
+ else
+ error("File not found: " + file);
+ }
+
+ System.err.println(fileCount + " files read");
+ if (errors > 0)
+ System.err.println(errors + " errors");
+
+ return errors == 0;
+ } finally {
+ fm.close();
}
-
- System.err.println(fileCount + " files read");
- if (errors > 0)
- System.err.println(errors + " errors");
-
- return errors == 0;
}
void test(File file) {
--- a/langtools/test/tools/javac/tree/PrettySimpleStringTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/PrettySimpleStringTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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,27 +46,28 @@
File testSrc = new File(System.getProperty("test.src"));
File thisFile = new File(testSrc, getClass().getName() + ".java");
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- JavacTask task = tool.getTask(null, fm, null, null, null,
- fm.getJavaFileObjects(thisFile));
- Iterable<? extends CompilationUnitTree> trees = task.parse();
- CompilationUnitTree thisTree = trees.iterator().next();
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ JavacTask task = tool.getTask(null, fm, null, null, null,
+ fm.getJavaFileObjects(thisFile));
+ Iterable<? extends CompilationUnitTree> trees = task.parse();
+ CompilationUnitTree thisTree = trees.iterator().next();
- { // test default
- String thisSrc = Pretty.toSimpleString((JCTree) thisTree);
- System.err.println(thisSrc);
- String expect = "import jav[...]} } }";
- if (!thisSrc.equals(expect)) {
- throw new Exception("unexpected result");
+ { // test default
+ String thisSrc = Pretty.toSimpleString((JCTree) thisTree);
+ System.err.println(thisSrc);
+ String expect = "import jav[...]} } }";
+ if (!thisSrc.equals(expect)) {
+ throw new Exception("unexpected result");
+ }
}
- }
- { // test explicit length
- String thisSrc = Pretty.toSimpleString((JCTree) thisTree, 32);
- System.err.println(thisSrc);
- String expect = "import java.io.Fil[...]; } } } }";
- if (!thisSrc.equals(expect)) {
- throw new Exception("unexpected result");
+ { // test explicit length
+ String thisSrc = Pretty.toSimpleString((JCTree) thisTree, 32);
+ System.err.println(thisSrc);
+ String expect = "import java.io.Fil[...]} } } } }";
+ if (!thisSrc.equals(expect)) {
+ throw new Exception("unexpected result");
+ }
}
}
}
--- a/langtools/test/tools/javac/tree/T6963934.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/T6963934.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,17 +42,18 @@
File testSrc = new File(System.getProperty("test.src"));
File thisSrc = new File(testSrc, T6963934.class.getSimpleName() + ".java");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
- JavacTask task = (JavacTask) compiler.getTask(null, fileManager, null, null, null,
- fileManager.getJavaFileObjects(thisSrc));
- CompilationUnitTree tree = task.parse().iterator().next();
- int count = 0;
- for (ImportTree importTree : tree.getImports()) {
- System.out.println(importTree);
- count++;
+ try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
+ JavacTask task = (JavacTask) compiler.getTask(null, fileManager, null, null, null,
+ fileManager.getJavaFileObjects(thisSrc));
+ CompilationUnitTree tree = task.parse().iterator().next();
+ int count = 0;
+ for (ImportTree importTree : tree.getImports()) {
+ System.out.println(importTree);
+ count++;
+ }
+ int expected = 7;
+ if (count != expected)
+ throw new Exception("unexpected number of imports found: " + count + ", expected: " + expected);
}
- int expected = 7;
- if (count != expected)
- throw new Exception("unexpected number of imports found: " + count + ", expected: " + expected);
}
}
--- a/langtools/test/tools/javac/tree/T6993305.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/T6993305.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,18 +59,19 @@
File testSrc = new File(System.getProperty("test.src"));
JavacTool tool = JavacTool.create();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+
+ File f = new File(testSrc, T6993305.class.getSimpleName() + ".java");
+ Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(f);
+ JavacTask task = tool.getTask(null, fm, null, null, null, fos);
+ Iterable<? extends CompilationUnitTree> cus = task.parse();
- File f = new File(testSrc, T6993305.class.getSimpleName() + ".java");
- Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(f);
- JavacTask task = tool.getTask(null, fm, null, null, null, fos);
- Iterable<? extends CompilationUnitTree> cus = task.parse();
+ TestScanner s = new TestScanner();
+ s.scan(cus, task);
- TestScanner s = new TestScanner();
- s.scan(cus, task);
-
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ }
}
void error(String msg) {
--- a/langtools/test/tools/javac/tree/TestToString.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/TestToString.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -63,12 +63,16 @@
}
void run() throws Exception {
- for (String s: statements) {
- test(s);
+ try {
+ for (String s: statements) {
+ test(s);
+ }
+
+ if (errors > 0)
+ throw new Exception(errors + " errors found");
+ } finally {
+ fm.close();
}
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
}
void test(String stmt) throws IOException {
--- a/langtools/test/tools/javac/tree/TreePosRoundsTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/TreePosRoundsTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -54,18 +54,19 @@
String testSrc = System.getProperty("test.src");
String testClasses = System.getProperty("test.classes");
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
- String thisName = TreePosRoundsTest.class.getName();
- File thisFile = new File(testSrc, thisName + ".java");
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
- List<String> options = Arrays.asList(
- "-proc:only",
- "-processor", thisName,
- "-processorpath", testClasses);
- CompilationTask t = c.getTask(null, fm, null, options, null, files);
- boolean ok = t.call();
- if (!ok)
- throw new Exception("processing failed");
+ try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ String thisName = TreePosRoundsTest.class.getName();
+ File thisFile = new File(testSrc, thisName + ".java");
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
+ List<String> options = Arrays.asList(
+ "-proc:only",
+ "-processor", thisName,
+ "-processorpath", testClasses);
+ CompilationTask t = c.getTask(null, fm, null, options, null, files);
+ boolean ok = t.call();
+ if (!ok)
+ throw new Exception("processing failed");
+ }
}
Filer filer;
@@ -155,6 +156,9 @@
//System.err.println(" encl: " +enclKind);
if (enclKind == Tree.Kind.CLASS || enclKind == Tree.Kind.BLOCK)
expect += ";";
+ // t-w-r- adds implicit final: remove it
+ if (enclKind == Tree.Kind.TRY && expect.startsWith("final "))
+ expect = expect.substring(6);
}
//System.err.println("expect: " + expect);
--- a/langtools/test/tools/javac/tree/TreePosTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/tree/TreePosTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -113,7 +113,7 @@
* args is the value of ${test.src}. In jtreg mode, the -r option can be
* given to change the default base directory to the root test directory.
*/
- public static void main(String... args) {
+ public static void main(String... args) throws IOException {
String testSrc = System.getProperty("test.src");
File baseDir = (testSrc == null) ? null : new File(testSrc);
boolean ok = new TreePosTest().run(baseDir, args);
@@ -133,61 +133,65 @@
* @param args command line args
* @return true if successful or in gui mode
*/
- boolean run(File baseDir, String... args) {
- if (args.length == 0) {
- usage(System.out);
- return true;
- }
+ boolean run(File baseDir, String... args) throws IOException {
+ try {
+ if (args.length == 0) {
+ usage(System.out);
+ return true;
+ }
- List<File> files = new ArrayList<File>();
- for (int i = 0; i < args.length; i++) {
- String arg = args[i];
- if (arg.equals("-encoding") && i + 1 < args.length)
- encoding = args[++i];
- else if (arg.equals("-gui"))
- gui = true;
- else if (arg.equals("-q"))
- quiet = true;
- else if (arg.equals("-v"))
- verbose = true;
- else if (arg.equals("-t") && i + 1 < args.length)
- tags.add(args[++i]);
- else if (arg.equals("-ef") && i + 1 < args.length)
- excludeFiles.add(new File(baseDir, args[++i]));
- else if (arg.equals("-et") && i + 1 < args.length)
- excludeTags.add(args[++i]);
- else if (arg.equals("-r")) {
- if (excludeFiles.size() > 0)
- throw new Error("-r must be used before -ef");
- File d = baseDir;
- while (!new File(d, "TEST.ROOT").exists()) {
- d = d.getParentFile();
- if (d == null)
- throw new Error("cannot find TEST.ROOT");
+ List<File> files = new ArrayList<File>();
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i];
+ if (arg.equals("-encoding") && i + 1 < args.length)
+ encoding = args[++i];
+ else if (arg.equals("-gui"))
+ gui = true;
+ else if (arg.equals("-q"))
+ quiet = true;
+ else if (arg.equals("-v"))
+ verbose = true;
+ else if (arg.equals("-t") && i + 1 < args.length)
+ tags.add(args[++i]);
+ else if (arg.equals("-ef") && i + 1 < args.length)
+ excludeFiles.add(new File(baseDir, args[++i]));
+ else if (arg.equals("-et") && i + 1 < args.length)
+ excludeTags.add(args[++i]);
+ else if (arg.equals("-r")) {
+ if (excludeFiles.size() > 0)
+ throw new Error("-r must be used before -ef");
+ File d = baseDir;
+ while (!new File(d, "TEST.ROOT").exists()) {
+ d = d.getParentFile();
+ if (d == null)
+ throw new Error("cannot find TEST.ROOT");
+ }
+ baseDir = d;
}
- baseDir = d;
+ else if (arg.startsWith("-"))
+ throw new Error("unknown option: " + arg);
+ else {
+ while (i < args.length)
+ files.add(new File(baseDir, args[i++]));
+ }
}
- else if (arg.startsWith("-"))
- throw new Error("unknown option: " + arg);
- else {
- while (i < args.length)
- files.add(new File(baseDir, args[i++]));
- }
- }
- for (File file: files) {
- if (file.exists())
- test(file);
- else
- error("File not found: " + file);
- }
+ for (File file: files) {
+ if (file.exists())
+ test(file);
+ else
+ error("File not found: " + file);
+ }
- if (fileCount != 1)
- System.err.println(fileCount + " files read");
- if (errors > 0)
- System.err.println(errors + " errors");
+ if (fileCount != 1)
+ System.err.println(fileCount + " files read");
+ if (errors > 0)
+ System.err.println(errors + " errors");
- return (gui || errors == 0);
+ return (gui || errors == 0);
+ } finally {
+ fm.close();
+ }
}
/**
--- a/langtools/test/tools/javac/unit/T6198196.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/unit/T6198196.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
* @author Peter von der Ah\u00e9
*/
+import java.io.IOException;
import java.util.Arrays;
import javax.tools.*;
@@ -42,21 +43,25 @@
+ filename + ") != " + result);
System.out.format("OK: endsWith(%s, %s) = %s%n", pathname, filename, result);
}
- public static void main(String[] args) {
+ public static void main(String[] args) throws IOException {
fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
- boolean windows = System.getProperty("os.name").startsWith("Windows");
- test("/x/y/z/package-info.java", pkginf, true);
- if (windows) {
- test("\\x\\y\\z\\package-info.java", pkginf, true);
- test("..\\x\\y\\z\\package-info.java", pkginf, true);
- } else {
- test("\\x\\y\\z\\package-info.java", pkginf, false);
- test("..\\x\\y\\z\\package-info.java", pkginf, false);
+ try {
+ boolean windows = System.getProperty("os.name").startsWith("Windows");
+ test("/x/y/z/package-info.java", pkginf, true);
+ if (windows) {
+ test("\\x\\y\\z\\package-info.java", pkginf, true);
+ test("..\\x\\y\\z\\package-info.java", pkginf, true);
+ } else {
+ test("\\x\\y\\z\\package-info.java", pkginf, false);
+ test("..\\x\\y\\z\\package-info.java", pkginf, false);
+ }
+ test("Package-info.java", pkginf, false);
+ test("../x/y/z/package-info.java", pkginf, true);
+ test("/x/y/z/package-info.java", pkginf, true);
+ test("x/y/z/package-info.java", pkginf, true);
+ test("package-info.java", pkginf, true);
+ } finally {
+ fm.close();
}
- test("Package-info.java", pkginf, false);
- test("../x/y/z/package-info.java", pkginf, true);
- test("/x/y/z/package-info.java", pkginf, true);
- test("x/y/z/package-info.java", pkginf, true);
- test("package-info.java", pkginf, true);
}
}
--- a/langtools/test/tools/javac/varargs/6199075/T6199075.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/varargs/6199075/T6199075.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -143,20 +143,24 @@
}
void test() throws Exception {
- for (TypeKind formal1 : TypeKind.values()) {
- VarargsMethod m1 = new VarargsMethod(formal1);
- for (TypeKind formal2 : TypeKind.values()) {
- VarargsMethod m2 = new VarargsMethod(formal2);
- for (TypeKind actual : TypeKind.values()) {
- for (ArgumentsArity argsArity : ArgumentsArity.values()) {
- compileAndCheck(m1, m2, actual, argsArity);
+ try {
+ for (TypeKind formal1 : TypeKind.values()) {
+ VarargsMethod m1 = new VarargsMethod(formal1);
+ for (TypeKind formal2 : TypeKind.values()) {
+ VarargsMethod m2 = new VarargsMethod(formal2);
+ for (TypeKind actual : TypeKind.values()) {
+ for (ArgumentsArity argsArity : ArgumentsArity.values()) {
+ compileAndCheck(m1, m2, actual, argsArity);
+ }
}
}
}
+
+ System.out.println("Total checks made: " + checkCount);
+ System.out.println("Bytecode checks made: " + bytecodeCheckCount);
+ } finally {
+ fm.close();
}
-
- System.out.println("Total checks made: " + checkCount);
- System.out.println("Bytecode checks made: " + bytecodeCheckCount);
}
// Create a single file manager and reuse it for each compile to save time.
--- a/langtools/test/tools/javac/varargs/7043922/T7043922.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/varargs/7043922/T7043922.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -146,22 +146,26 @@
static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
public static void main(String... args) throws Exception {
- for (ClassKind classKind1 : ClassKind.values()) {
- for (ConstructorKind constrKind1 : ConstructorKind.values()) {
- if (!classKind1.isConstructorOk(constrKind1)) continue;
- for (ClassKind classKind2 : ClassKind.values()) {
- for (ConstructorKind constrKind2 : ConstructorKind.values()) {
- if (!classKind2.isConstructorOk(constrKind2)) continue;
- for (ClassKind classKind3 : ClassKind.values()) {
- for (ConstructorKind constrKind3 : ConstructorKind.values()) {
- if (!classKind3.isConstructorOk(constrKind3)) continue;
- new T7043922(new ClassKind[] { classKind1, classKind2, classKind3 },
- new ConstructorKind[] { constrKind1, constrKind2, constrKind3 }).compileAndCheck();
+ try {
+ for (ClassKind classKind1 : ClassKind.values()) {
+ for (ConstructorKind constrKind1 : ConstructorKind.values()) {
+ if (!classKind1.isConstructorOk(constrKind1)) continue;
+ for (ClassKind classKind2 : ClassKind.values()) {
+ for (ConstructorKind constrKind2 : ConstructorKind.values()) {
+ if (!classKind2.isConstructorOk(constrKind2)) continue;
+ for (ClassKind classKind3 : ClassKind.values()) {
+ for (ConstructorKind constrKind3 : ConstructorKind.values()) {
+ if (!classKind3.isConstructorOk(constrKind3)) continue;
+ new T7043922(new ClassKind[] { classKind1, classKind2, classKind3 },
+ new ConstructorKind[] { constrKind1, constrKind2, constrKind3 }).compileAndCheck();
+ }
}
}
}
}
}
+ } finally {
+ fm.close();
}
}
--- a/langtools/test/tools/javac/versions/Versions.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javac/versions/Versions.java Mon Nov 03 10:11:10 2014 -0800
@@ -278,22 +278,25 @@
protected boolean compile(String sourceFile, List<String>options) {
JavaCompiler.CompilationTask jctask;
- StandardJavaFileManager fm = javacompiler.getStandardFileManager(null, null, null);
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(sourceFile);
+ try (StandardJavaFileManager fm = javacompiler.getStandardFileManager(null, null, null)) {
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(sourceFile);
- jctask = javacompiler.getTask(
- null, // Writer
- fm, // JavaFileManager
- null, // DiagnosticListener
- options, // Iterable<String>
- null, // Iterable<String> classes
- files); // Iterable<? extends JavaFileObject>
+ jctask = javacompiler.getTask(
+ null, // Writer
+ fm, // JavaFileManager
+ null, // DiagnosticListener
+ options, // Iterable<String>
+ null, // Iterable<String> classes
+ files); // Iterable<? extends JavaFileObject>
- try {
- return jctask.call();
- } catch (IllegalStateException e) {
- System.err.println(e);
- return false;
+ try {
+ return jctask.call();
+ } catch (IllegalStateException e) {
+ System.err.println(e);
+ return false;
+ }
+ } catch (IOException e) {
+ throw new Error(e);
}
}
--- a/langtools/test/tools/javadoc/CheckResourceKeys.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/CheckResourceKeys.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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
@@ -140,41 +140,42 @@
Set<String> getCodeKeys() throws IOException {
Set<String> results = new TreeSet<String>();
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
- JavaFileManager fm = c.getStandardFileManager(null, null, null);
- JavaFileManager.Location javadocLoc = findJavadocLocation(fm);
- String[] pkgs = {
- "com.sun.tools.doclets",
- "com.sun.tools.javadoc"
- };
- for (String pkg: pkgs) {
- for (JavaFileObject fo: fm.list(javadocLoc,
- pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
- String name = fo.getName();
- // ignore resource files
- if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*"))
- continue;
- scan(fo, results);
+ try (JavaFileManager fm = c.getStandardFileManager(null, null, null)) {
+ JavaFileManager.Location javadocLoc = findJavadocLocation(fm);
+ String[] pkgs = {
+ "com.sun.tools.doclets",
+ "com.sun.tools.javadoc"
+ };
+ for (String pkg: pkgs) {
+ for (JavaFileObject fo: fm.list(javadocLoc,
+ pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
+ String name = fo.getName();
+ // ignore resource files
+ if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*"))
+ continue;
+ scan(fo, results);
+ }
}
- }
- // special handling for code strings synthesized in
- // com.sun.tools.doclets.internal.toolkit.util.Util.getTypeName
- String[] extras = {
- "AnnotationType", "Class", "Enum", "Error", "Exception", "Interface"
- };
- for (String s: extras) {
- if (results.contains("doclet." + s))
- results.add("doclet." + s.toLowerCase());
+ // special handling for code strings synthesized in
+ // com.sun.tools.doclets.internal.toolkit.util.Util.getTypeName
+ String[] extras = {
+ "AnnotationType", "Class", "Enum", "Error", "Exception", "Interface"
+ };
+ for (String s: extras) {
+ if (results.contains("doclet." + s))
+ results.add("doclet." + s.toLowerCase());
+ }
+
+ // special handling for code strings synthesized in
+ // com.sun.tools.javadoc.Messager
+ results.add("javadoc.error.msg");
+ results.add("javadoc.note.msg");
+ results.add("javadoc.note.pos.msg");
+ results.add("javadoc.warning.msg");
+
+ return results;
}
-
- // special handling for code strings synthesized in
- // com.sun.tools.javadoc.Messager
- results.add("javadoc.error.msg");
- results.add("javadoc.note.msg");
- results.add("javadoc.note.pos.msg");
- results.add("javadoc.warning.msg");
-
- return results;
}
// depending on how the test is run, javadoc may be on bootclasspath or classpath
--- a/langtools/test/tools/javadoc/api/basic/DocletPathTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/DocletPathTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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,34 +59,36 @@
createSimpleJavaFileObject("DocletOnDocletPath", docletSrcText);
File docletDir = getOutDir("classes");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null);
- cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(docletDir));
- Iterable<? extends JavaFileObject> cfiles = Arrays.asList(docletSrc);
- if (!compiler.getTask(null, cfm, null, null, null, cfiles).call())
- throw new Exception("cannot compile doclet");
+ try (StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null)) {
+ cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(docletDir));
+ Iterable<? extends JavaFileObject> cfiles = Arrays.asList(docletSrc);
+ if (!compiler.getTask(null, cfm, null, null, null, cfiles).call())
+ throw new Exception("cannot compile doclet");
+ }
JavaFileObject srcFile = createSimpleJavaFileObject();
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir("api");
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- fm.setLocation(DocumentationTool.Location.DOCLET_PATH, Arrays.asList(docletDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- Iterable<String> options = Arrays.asList("-doclet", "DocletOnDocletPath");
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- DocumentationTask t = tool.getTask(pw, fm, null, null, options, files);
- boolean ok = t.call();
- String out = sw.toString();
- System.err.println(">>" + out + "<<");
- if (ok) {
- if (out.contains(TEST_STRING)) {
- System.err.println("doclet executed as expected");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir("api");
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ fm.setLocation(DocumentationTool.Location.DOCLET_PATH, Arrays.asList(docletDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ Iterable<String> options = Arrays.asList("-doclet", "DocletOnDocletPath");
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ DocumentationTask t = tool.getTask(pw, fm, null, null, options, files);
+ boolean ok = t.call();
+ String out = sw.toString();
+ System.err.println(">>" + out + "<<");
+ if (ok) {
+ if (out.contains(TEST_STRING)) {
+ System.err.println("doclet executed as expected");
+ } else {
+ error("test string not found in doclet output");
+ }
} else {
- error("test string not found in doclet output");
+ error("task failed");
}
- } else {
- error("task failed");
}
}
--- a/langtools/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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,27 +60,28 @@
public void testDiagListener() throws Exception {
JavaFileObject srcFile = createSimpleJavaFileObject("pkg/C", "package pkg; public error { }");
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
- DocumentationTask t = tool.getTask(null, fm, dc, null, null, files);
- if (t.call()) {
- throw new Exception("task succeeded unexpectedly");
- } else {
- List<String> diagCodes = new ArrayList<String>();
- for (Diagnostic d: dc.getDiagnostics()) {
- System.err.println(d);
- diagCodes.add(d.getCode());
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+ DocumentationTask t = tool.getTask(null, fm, dc, null, null, files);
+ if (t.call()) {
+ throw new Exception("task succeeded unexpectedly");
+ } else {
+ List<String> diagCodes = new ArrayList<String>();
+ for (Diagnostic d: dc.getDiagnostics()) {
+ System.err.println(d);
+ diagCodes.add(d.getCode());
+ }
+ List<String> expect = Arrays.asList(
+ "javadoc.note.msg", // Loading source file
+ "compiler.err.expected3", // class, interface, or enum expected
+ "javadoc.note.msg"); // 1 error
+ if (!diagCodes.equals(expect))
+ throw new Exception("unexpected diagnostics occurred");
+ System.err.println("diagnostics received as expected");
}
- List<String> expect = Arrays.asList(
- "javadoc.note.msg", // Loading source file
- "compiler.err.expected3", // class, interface, or enum expected
- "javadoc.note.msg"); // 1 error
- if (!diagCodes.equals(expect))
- throw new Exception("unexpected diagnostics occurred");
- System.err.println("diagnostics received as expected");
}
}
--- a/langtools/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -70,20 +70,21 @@
"pkg/C",
"package pkg; /** " + key + "*/ public class C { }");
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- DocumentationTask t = tool.getTask(null, fm, null, TestDoclet.class, null, files);
- if (t.call()) {
- System.err.println("task succeeded");
- if (TestDoclet.lastCaller.equals(String.valueOf(key)))
- System.err.println("found expected key: " + key);
- else
- error("Expected key not found");
- checkFiles(outDir, Collections.<String>emptySet());
- } else {
- throw new Exception("task failed");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ DocumentationTask t = tool.getTask(null, fm, null, TestDoclet.class, null, files);
+ if (t.call()) {
+ System.err.println("task succeeded");
+ if (TestDoclet.lastCaller.equals(String.valueOf(key)))
+ System.err.println("found expected key: " + key);
+ else
+ error("Expected key not found");
+ checkFiles(outDir, Collections.<String>emptySet());
+ } else {
+ throw new Exception("task failed");
+ }
}
}
@@ -115,20 +116,21 @@
public void testBadDoclet() throws Exception {
JavaFileObject srcFile = createSimpleJavaFileObject();
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- DocumentationTask t = tool.getTask(null, fm, null, BadDoclet.class, null, files);
- try {
- t.call();
- error("call completed without exception");
- } catch (RuntimeException e) {
- Throwable c = e.getCause();
- if (c.getClass() == UnexpectedError.class)
- System.err.println("exception caught as expected: " + c);
- else
- throw e;
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ DocumentationTask t = tool.getTask(null, fm, null, BadDoclet.class, null, files);
+ try {
+ t.call();
+ error("call completed without exception");
+ } catch (RuntimeException e) {
+ Throwable c = e.getCause();
+ if (c.getClass() == UnexpectedError.class)
+ System.err.println("exception caught as expected: " + c);
+ else
+ throw e;
+ }
}
}
--- a/langtools/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -54,16 +54,17 @@
File testSrc = new File(System.getProperty("test.src"));
File srcFile = new File(testSrc, "pkg/C.java");
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
- DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
- if (t.call()) {
- System.err.println("task succeeded");
- checkFiles(outDir, standardExpectFiles);
- } else {
- throw new Exception("task failed");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
+ DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+ if (t.call()) {
+ System.err.println("task succeeded");
+ checkFiles(outDir, standardExpectFiles);
+ } else {
+ throw new Exception("task failed");
+ }
}
}
@@ -75,16 +76,17 @@
public void testMemoryFileObject() throws Exception {
JavaFileObject srcFile = createSimpleJavaFileObject();
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
- if (t.call()) {
- System.err.println("task succeeded");
- checkFiles(outDir, standardExpectFiles);
- } else {
- throw new Exception("task failed");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+ if (t.call()) {
+ System.err.println("task succeeded");
+ checkFiles(outDir, standardExpectFiles);
+ } else {
+ throw new Exception("task failed");
+ }
}
}
@@ -96,15 +98,16 @@
File testSrc = new File(System.getProperty("test.src"));
File srcFile = new File(testSrc, "pkg/C.class"); // unacceptable file kind
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
- try {
- DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
- error("getTask succeeded, no exception thrown");
- } catch (IllegalArgumentException e) {
- System.err.println("exception caught as expected: " + e);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
+ try {
+ DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+ error("getTask succeeded, no exception thrown");
+ } catch (IllegalArgumentException e) {
+ System.err.println("exception caught as expected: " + e);
+ }
}
}
@@ -114,15 +117,16 @@
@Test
public void testNull() throws Exception {
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList((JavaFileObject) null);
- try {
- DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
- error("getTask succeeded, no exception thrown");
- } catch (NullPointerException e) {
- System.err.println("exception caught as expected: " + e);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList((JavaFileObject) null);
+ try {
+ DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+ error("getTask succeeded, no exception thrown");
+ } catch (NullPointerException e) {
+ System.err.println("exception caught as expected: " + e);
+ }
}
}
--- a/langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -54,19 +54,20 @@
public void testNoIndex() throws Exception {
JavaFileObject srcFile = createSimpleJavaFileObject();
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- Iterable<String> options = Arrays.asList("-noindex");
- DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
- if (t.call()) {
- System.err.println("task succeeded");
- Set<String> expectFiles = new TreeSet<String>(standardExpectFiles);
- expectFiles.remove("index-all.html");
- checkFiles(outDir, expectFiles);
- } else {
- error("task failed");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ Iterable<String> options = Arrays.asList("-noindex");
+ DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
+ if (t.call()) {
+ System.err.println("task succeeded");
+ Set<String> expectFiles = new TreeSet<String>(standardExpectFiles);
+ expectFiles.remove("index-all.html");
+ checkFiles(outDir, expectFiles);
+ } else {
+ error("task failed");
+ }
}
}
@@ -77,16 +78,17 @@
public void testNull() throws Exception {
JavaFileObject srcFile = createSimpleJavaFileObject();
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<String> options = Arrays.asList((String) null);
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- try {
- DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
- error("getTask succeeded, no exception thrown");
- } catch (NullPointerException e) {
- System.err.println("exception caught as expected: " + e);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<String> options = Arrays.asList((String) null);
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ try {
+ DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
+ error("getTask succeeded, no exception thrown");
+ } catch (NullPointerException e) {
+ System.err.println("exception caught as expected: " + e);
+ }
}
}
--- a/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_WriterTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -54,25 +54,26 @@
public void testWriter() throws Exception {
JavaFileObject srcFile = createSimpleJavaFileObject();
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- DocumentationTask t = tool.getTask(pw, fm, null, null, null, files);
- if (t.call()) {
- System.err.println("task succeeded");
- checkFiles(outDir, standardExpectFiles);
- String out = sw.toString();
- System.err.println(">>" + out + "<<");
- for (String f: standardExpectFiles) {
- String f1 = f.replace('/', File.separatorChar);
- if (f1.endsWith(".html") && !out.contains(f1))
- throw new Exception("expected string not found: " + f1);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ DocumentationTask t = tool.getTask(pw, fm, null, null, null, files);
+ if (t.call()) {
+ System.err.println("task succeeded");
+ checkFiles(outDir, standardExpectFiles);
+ String out = sw.toString();
+ System.err.println(">>" + out + "<<");
+ for (String f: standardExpectFiles) {
+ String f1 = f.replace('/', File.separatorChar);
+ if (f1.endsWith(".html") && !out.contains(f1))
+ throw new Exception("expected string not found: " + f1);
+ }
+ } else {
+ throw new Exception("task failed");
}
- } else {
- throw new Exception("task failed");
}
}
}
--- a/langtools/test/tools/javadoc/api/basic/JavadocTaskImplTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/JavadocTaskImplTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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,18 +56,19 @@
public void testRawCall() throws Exception {
JavaFileObject srcFile = createSimpleJavaFileObject();
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- @SuppressWarnings("rawtypes")
- Callable t = tool.getTask(null, fm, null, null, null, files);
+ @SuppressWarnings("rawtypes")
+ Callable t = tool.getTask(null, fm, null, null, null, files);
- if (t.call() == Boolean.TRUE) {
- System.err.println("task succeeded");
- } else {
- throw new Exception("task failed");
+ if (t.call() == Boolean.TRUE) {
+ System.err.println("task succeeded");
+ } else {
+ throw new Exception("task failed");
+ }
}
}
@@ -77,14 +78,15 @@
Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
Context c = new Context();
Messager.preRegister(c, "javadoc");
- StandardJavaFileManager fm = new JavacFileManager(c, true, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- DocumentationTask t = new JavadocTaskImpl(c, null, null, files);
- if (t.call()) {
- System.err.println("task succeeded");
- } else {
- throw new Exception("task failed");
+ try (StandardJavaFileManager fm = new JavacFileManager(c, true, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ DocumentationTask t = new JavadocTaskImpl(c, null, null, files);
+ if (t.call()) {
+ System.err.println("task succeeded");
+ } else {
+ throw new Exception("task failed");
+ }
}
}
@@ -94,14 +96,15 @@
Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
Context c = new Context();
Messager.preRegister(c, "javadoc");
- StandardJavaFileManager fm = new JavacFileManager(c, true, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- try {
- DocumentationTask t = new JavadocTaskImpl(c, null, null, files);;
- error("getTask succeeded, no exception thrown");
- } catch (NullPointerException e) {
- System.err.println("exception caught as expected: " + e);
+ try (StandardJavaFileManager fm = new JavacFileManager(c, true, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ try {
+ DocumentationTask t = new JavadocTaskImpl(c, null, null, files);;
+ error("getTask succeeded, no exception thrown");
+ } catch (NullPointerException e) {
+ System.err.println("exception caught as expected: " + e);
+ }
}
}
}
--- a/langtools/test/tools/javadoc/api/basic/TagletPathTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/TagletPathTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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,38 +62,40 @@
File tagletSrcFile = new File(testSrc, "taglets/UnderlineTaglet.java");
File tagletDir = getOutDir("classes");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null);
- cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tagletDir));
- Iterable<? extends JavaFileObject> cfiles = cfm.getJavaFileObjects(tagletSrcFile);
- if (!compiler.getTask(null, cfm, null, null, null, cfiles).call())
- throw new Exception("cannot compile taglet");
+ try (StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null)) {
+ cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tagletDir));
+ Iterable<? extends JavaFileObject> cfiles = cfm.getJavaFileObjects(tagletSrcFile);
+ if (!compiler.getTask(null, cfm, null, null, null, cfiles).call())
+ throw new Exception("cannot compile taglet");
+ }
JavaFileObject srcFile = createSimpleJavaFileObject("pkg/C", testSrcText);
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir("api");
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- fm.setLocation(DocumentationTool.Location.TAGLET_PATH, Arrays.asList(tagletDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- Iterable<String> options = Arrays.asList("-taglet", "UnderlineTaglet");
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- DocumentationTask t = tool.getTask(pw, fm, null, null, options, files);
- boolean ok = t.call();
- String out = sw.toString();
- System.err.println(">>" + out + "<<");
- if (ok) {
- File f = new File(outDir, "pkg/C.html");
- List<String> doc = Files.readAllLines(f.toPath(), Charset.defaultCharset());
- for (String line: doc) {
- if (line.contains("<u>" + TEST_STRING + "</u>")) {
- System.err.println("taglet executed as expected");
- return;
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir("api");
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ fm.setLocation(DocumentationTool.Location.TAGLET_PATH, Arrays.asList(tagletDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ Iterable<String> options = Arrays.asList("-taglet", "UnderlineTaglet");
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ DocumentationTask t = tool.getTask(pw, fm, null, null, options, files);
+ boolean ok = t.call();
+ String out = sw.toString();
+ System.err.println(">>" + out + "<<");
+ if (ok) {
+ File f = new File(outDir, "pkg/C.html");
+ List<String> doc = Files.readAllLines(f.toPath(), Charset.defaultCharset());
+ for (String line: doc) {
+ if (line.contains("<u>" + TEST_STRING + "</u>")) {
+ System.err.println("taglet executed as expected");
+ return;
+ }
}
+ error("expected text not found in output " + f);
+ } else {
+ error("task failed");
}
- error("expected text not found in output " + f);
- } else {
- error("task failed");
}
}
--- a/langtools/test/tools/javadoc/api/basic/Task_reuseTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/api/basic/Task_reuseTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -77,16 +77,17 @@
private DocumentationTask getAndRunTask() throws Exception {
JavaFileObject srcFile = createSimpleJavaFileObject();
DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
- StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- File outDir = getOutDir();
- fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
- Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
- DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
- if (t.call()) {
- System.err.println("task succeeded");
- return t;
- } else {
- throw new Exception("task failed");
+ try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
+ File outDir = getOutDir();
+ fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+ Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+ DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+ if (t.call()) {
+ System.err.println("task succeeded");
+ return t;
+ } else {
+ throw new Exception("task failed");
+ }
}
}
}
--- a/langtools/test/tools/javadoc/doclint/DocLintTest.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javadoc/doclint/DocLintTest.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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,60 +121,64 @@
void run() throws Exception {
javadoc = ToolProvider.getSystemDocumentationTool();
fm = javadoc.getStandardFileManager(null, null, null);
- fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
- file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
- @Override
- public CharSequence getCharContent(boolean ignoreEncoding) {
- return code;
- }
- };
+ try {
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+ file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncoding) {
+ return code;
+ }
+ };
- test(Collections.<String>emptyList(),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR9A, Message.DL_WRN12A));
+ test(Collections.<String>emptyList(),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR9A, Message.DL_WRN12A));
- test(Arrays.asList(rawDiags),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR9, Message.DL_WRN12));
+ test(Arrays.asList(rawDiags),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR9, Message.DL_WRN12));
+
+ test(Arrays.asList("-Xdoclint:none"),
+ Main.Result.OK,
+ EnumSet.of(Message.JD_WRN10, Message.JD_WRN13));
- test(Arrays.asList("-Xdoclint:none"),
- Main.Result.OK,
- EnumSet.of(Message.JD_WRN10, Message.JD_WRN13));
+ test(Arrays.asList(rawDiags, "-Xdoclint"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR9, Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR9, Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.OPT_BADQUAL));
- test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
- Main.Result.ERROR,
- EnumSet.of(Message.OPT_BADQUAL));
+ test(Arrays.asList(rawDiags, "-Xdoclint:all", "-public"),
+ Main.Result.OK,
+ EnumSet.of(Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint:all", "-public"),
- Main.Result.OK,
- EnumSet.of(Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
+ Main.Result.OK,
+ EnumSet.of(Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
- Main.Result.OK,
- EnumSet.of(Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-private"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-private"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:syntax", "-private"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
- test(Arrays.asList(rawDiags, "-Xdoclint:syntax", "-private"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
+ test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.DL_ERR9));
- test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
- Main.Result.ERROR,
- EnumSet.of(Message.DL_ERR9));
+ test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
+ Main.Result.ERROR,
+ EnumSet.of(Message.OPT_BADARG));
- test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
- Main.Result.ERROR,
- EnumSet.of(Message.OPT_BADARG));
-
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
+ if (errors > 0)
+ throw new Exception(errors + " errors occurred");
+ } finally {
+ fm.close();
+ }
}
void test(List<String> opts, Main.Result expectResult, Set<Message> expectMessages) {
--- a/langtools/test/tools/javap/T6729471.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javap/T6729471.java Mon Nov 03 10:11:10 2014 -0800
@@ -25,10 +25,7 @@
/*
* @test
* @bug 6729471
- * @summary javap should accept class files on the command line
- * @library /tools/lib
- * @build ToolBox
- * @run main T6729471
+ * @summary javap does not output inner interfaces of an interface
*/
import java.io.*;
@@ -60,26 +57,30 @@
verify(new File(testClasses, "T6729471.class").toURI().toString(),
"public static void main(java.lang.String...)");
- // jar url
- // Create a temp jar
- ToolBox tb = new ToolBox();
- tb.new JavacTask()
- .sources("class Foo { public void sayHello() {} }")
- .run();
- String foo_jar = "foo.jar";
- tb.new JarTask(foo_jar)
- .files("Foo.class")
- .run();
- File foo_jarFile = new File(foo_jar);
-
- // Verify
+ // jar url: rt.jar
+ File java_home = new File(System.getProperty("java.home"));
+ if (java_home.getName().equals("jre"))
+ java_home = java_home.getParentFile();
+ File rt_jar = new File(new File(new File(java_home, "jre"), "lib"), "rt.jar");
try {
- verify("jar:" + foo_jarFile.toURL() + "!/Foo.class",
- "public void sayHello()");
+ verify("jar:" + rt_jar.toURL() + "!/java/util/Map.class",
+ "public abstract boolean containsKey(java.lang.Object)");
} catch (MalformedURLException e) {
error(e.toString());
}
+ // jar url: ct.sym, if it exists
+ File ct_sym = new File(new File(java_home, "lib"), "ct.sym");
+ if (ct_sym.exists()) {
+ try {
+ verify("jar:" + ct_sym.toURL() + "!/META-INF/sym/rt.jar/java/util/Map.class",
+ "public abstract boolean containsKey(java.lang.Object)");
+ } catch (MalformedURLException e) {
+ error(e.toString());
+ }
+ } else
+ System.err.println("warning: ct.sym not found");
+
if (errors > 0)
throw new Error(errors + " found.");
}
--- a/langtools/test/tools/javap/TestSuperclass.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/javap/TestSuperclass.java Mon Nov 03 10:11:10 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -77,19 +77,20 @@
public static void main(String... args) throws Exception {
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
- int errors = 0;
+ try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
+ int errors = 0;
- for (ClassKind ck: ClassKind.values()) {
- for (GenericKind gk: GenericKind.values()) {
- for (SuperKind sk: SuperKind.values()) {
- errors += new TestSuperclass(ck, gk, sk).run(comp, fm);
+ for (ClassKind ck: ClassKind.values()) {
+ for (GenericKind gk: GenericKind.values()) {
+ for (SuperKind sk: SuperKind.values()) {
+ errors += new TestSuperclass(ck, gk, sk).run(comp, fm);
+ }
}
}
+
+ if (errors > 0)
+ throw new Exception(errors + " errors found");
}
-
- if (errors > 0)
- throw new Exception(errors + " errors found");
}
final ClassKind ck;
--- a/langtools/test/tools/sjavac/DependencyCollection.java Sat Nov 01 14:40:09 2014 +0300
+++ b/langtools/test/tools/sjavac/DependencyCollection.java Mon Nov 03 10:11:10 2014 -0800
@@ -59,59 +59,60 @@
Path src = Paths.get(ToolBox.testSrc, "test-input", "src");
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager fileManager = javac.getStandardFileManager(null, null, null);
- SmartFileManager smartFileManager = new SmartFileManager(fileManager);
- smartFileManager.setSymbolFileEnabled(false);
- Iterable<? extends JavaFileObject> fileObjects =
- fileManager.getJavaFileObjectsFromFiles(Arrays.asList(src.resolve("pkg/Test.java").toFile()));
- JavacTaskImpl task = (JavacTaskImpl) javac.getTask(new PrintWriter(System.out),
- smartFileManager,
- null,
- Arrays.asList("-d", "classes",
- "-sourcepath", src.toAbsolutePath().toString()),
- null,
- fileObjects);
- DependencyCollector depsCollector = new DependencyCollector();
- task.addTaskListener(depsCollector);
- task.doCall();
+ try (StandardJavaFileManager fileManager = javac.getStandardFileManager(null, null, null)) {
+ SmartFileManager smartFileManager = new SmartFileManager(fileManager);
+ smartFileManager.setSymbolFileEnabled(false);
+ Iterable<? extends JavaFileObject> fileObjects =
+ fileManager.getJavaFileObjectsFromFiles(Arrays.asList(src.resolve("pkg/Test.java").toFile()));
+ JavacTaskImpl task = (JavacTaskImpl) javac.getTask(new PrintWriter(System.out),
+ smartFileManager,
+ null,
+ Arrays.asList("-d", "classes",
+ "-sourcepath", src.toAbsolutePath().toString()),
+ null,
+ fileObjects);
+ DependencyCollector depsCollector = new DependencyCollector();
+ task.addTaskListener(depsCollector);
+ task.doCall();
- // Find pkg symbol
- PackageSymbol pkg = findPkgSymbolWithName(depsCollector.getSourcePackages(), "pkg");
- Set<PackageSymbol> foundDependencies = depsCollector.getDependenciesForPkg(pkg);
+ // Find pkg symbol
+ PackageSymbol pkg = findPkgSymbolWithName(depsCollector.getSourcePackages(), "pkg");
+ Set<PackageSymbol> foundDependencies = depsCollector.getDependenciesForPkg(pkg);
- // Print dependencies
- System.out.println("Found dependencies:");
- foundDependencies.stream()
- .sorted(Comparator.comparing(DependencyCollection::extractNumber))
- .forEach(p -> System.out.println(" " + p));
+ // Print dependencies
+ System.out.println("Found dependencies:");
+ foundDependencies.stream()
+ .sorted(Comparator.comparing(DependencyCollection::extractNumber))
+ .forEach(p -> System.out.println(" " + p));
- // Check result
- Set<Integer> found = foundDependencies.stream()
- .map(DependencyCollection::extractNumber)
- .collect(Collectors.toSet());
- found.remove(-1); // Dependencies with no number (java.lang etc)
- Set<Integer> expected = new HashSet<>();
- for (int i = 2; i <= 30; i++) {
- if (i == 15) continue; // Case 15 correspond to the type of a throw-away return value.
- expected.add(i);
- }
+ // Check result
+ Set<Integer> found = foundDependencies.stream()
+ .map(DependencyCollection::extractNumber)
+ .collect(Collectors.toSet());
+ found.remove(-1); // Dependencies with no number (java.lang etc)
+ Set<Integer> expected = new HashSet<>();
+ for (int i = 2; i <= 30; i++) {
+ if (i == 15) continue; // Case 15 correspond to the type of a throw-away return value.
+ expected.add(i);
+ }
- Set<Integer> missing = new HashSet<>(expected);
- missing.removeAll(found);
- if (missing.size() > 0) {
- System.out.println("Missing dependencies:");
- missing.forEach(i -> System.out.println(" Dependency " + i));
- }
+ Set<Integer> missing = new HashSet<>(expected);
+ missing.removeAll(found);
+ if (missing.size() > 0) {
+ System.out.println("Missing dependencies:");
+ missing.forEach(i -> System.out.println(" Dependency " + i));
+ }
- Set<Integer> unexpected = new HashSet<>(found);
- unexpected.removeAll(expected);
- if (unexpected.size() > 0) {
- System.out.println("Unexpected dependencies found:");
- unexpected.forEach(i -> System.out.println(" Dependency " + i));
+ Set<Integer> unexpected = new HashSet<>(found);
+ unexpected.removeAll(expected);
+ if (unexpected.size() > 0) {
+ System.out.println("Unexpected dependencies found:");
+ unexpected.forEach(i -> System.out.println(" Dependency " + i));
+ }
+
+ if (missing.size() > 0 || unexpected.size() > 0)
+ throw new AssertionError("Missing and/or unexpected dependencies found.");
}
-
- if (missing.size() > 0 || unexpected.size() > 0)
- throw new AssertionError("Missing and/or unexpected dependencies found.");
}
private static PackageSymbol findPkgSymbolWithName(Set<PackageSymbol> syms, String name) {
--- a/make/CompileJavaModules.gmk Sat Nov 01 14:40:09 2014 +0300
+++ b/make/CompileJavaModules.gmk Mon Nov 03 10:11:10 2014 -0800
@@ -42,7 +42,7 @@
################################################################################
-java.base_COPY := .icu .dat .spp content-types.properties
+java.base_COPY := .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties
java.base_CLEAN := intrinsic.properties
java.base_EXCLUDES += java/lang/doc-files
--- a/nashorn/.hgtags Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/.hgtags Mon Nov 03 10:11:10 2014 -0800
@@ -270,3 +270,4 @@
4ece2dad8c37f520f1ccc1cf84870f362c8eb9d6 jdk9-b34
63b8da4c958c3bbadfff082c547983f5daa50c0f jdk9-b35
10fe62bc188476abb025e55f55128cbfecf24584 jdk9-b36
+dd7bbdf81a537106cfa9227d1a9a57849cb26b4d jdk9-b37
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java Mon Nov 03 10:11:10 2014 -0800
@@ -88,7 +88,7 @@
final Property property = propertyMap.findProperty(key);
if (property != null) {
// normal property key
- property.setCurrentType(JSType.unboxedFieldType(constantValue));
+ property.setType(JSType.unboxedFieldType(constantValue));
final int slot = property.getSlot();
if (!OBJECT_FIELDS_ONLY && constantValue instanceof Number) {
jpresetValues[slot] = ObjectClassGenerator.pack((Number)constantValue);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/TypeEvaluator.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/TypeEvaluator.java Mon Nov 03 10:11:10 2014 -0800
@@ -117,7 +117,7 @@
}
final Property property = find.getProperty();
- final Class<?> propertyClass = property.getCurrentType();
+ final Class<?> propertyClass = property.getType();
if (propertyClass == null) {
// propertyClass == null means its value is Undefined. It is probably not initialized yet, so we won't make
// a type assumption yet.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java Mon Nov 03 10:11:10 2014 -0800
@@ -672,7 +672,7 @@
for (final Property prop : properties) {
if (prop.isEnumerable()) {
final Object value = sourceObj.get(prop.getKey());
- prop.setCurrentType(Object.class);
+ prop.setType(Object.class);
prop.setValue(sourceObj, sourceObj, value, false);
propList.add(prop);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java Mon Nov 03 10:11:10 2014 -0800
@@ -145,13 +145,6 @@
transient MethodHandle objectSetter;
/**
- * Current type of this object, in object only mode, this is an Object.class. In dual-fields mode
- * null means undefined, and primitive types are allowed. The reason a special type is used for
- * undefined, is that are no bits left to represent it in primitive types
- */
- private Class<?> currentType;
-
- /**
* Delegate constructor for bound properties. This is used for properties created by
* {@link ScriptRuntime#mergeScope} and the Nashorn {@code Object.bindProperties} method.
* The former is used to add a script's defined globals to the current global scope while
@@ -171,7 +164,7 @@
this.objectSetter = bindTo(property.objectSetter, delegate);
property.GETTER_CACHE = new MethodHandle[NOOF_TYPES];
// Properties created this way are bound to a delegate
- setCurrentType(property.getCurrentType());
+ setType(property.getType());
}
/**
@@ -248,7 +241,7 @@
objectGetter = getter.type() != Lookup.GET_OBJECT_TYPE ? MH.asType(getter, Lookup.GET_OBJECT_TYPE) : getter;
objectSetter = setter != null && setter.type() != Lookup.SET_OBJECT_TYPE ? MH.asType(setter, Lookup.SET_OBJECT_TYPE) : setter;
- setCurrentType(OBJECT_FIELDS_ONLY ? Object.class : getterType);
+ setType(OBJECT_FIELDS_ONLY ? Object.class : getterType);
}
/**
@@ -317,7 +310,7 @@
*/
public AccessorProperty(final String key, final int flags, final Class<?> structure, final int slot, final Class<?> initialType) {
this(key, flags, structure, slot);
- setCurrentType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
+ setType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
}
/**
@@ -330,13 +323,13 @@
protected AccessorProperty(final AccessorProperty property, final Class<?> newType) {
super(property, property.getFlags());
- this.GETTER_CACHE = newType != property.getCurrentType() ? new MethodHandle[NOOF_TYPES] : property.GETTER_CACHE;
+ this.GETTER_CACHE = newType != property.getLocalType() ? new MethodHandle[NOOF_TYPES] : property.GETTER_CACHE;
this.primitiveGetter = property.primitiveGetter;
this.primitiveSetter = property.primitiveSetter;
this.objectGetter = property.objectGetter;
this.objectSetter = property.objectSetter;
- setCurrentType(newType);
+ setType(newType);
}
/**
@@ -345,7 +338,7 @@
* @param property source property
*/
protected AccessorProperty(final AccessorProperty property) {
- this(property, property.getCurrentType());
+ this(property, property.getLocalType());
}
/**
@@ -354,7 +347,7 @@
* @param initialValue initial value
*/
protected final void setInitialValue(final ScriptObject owner, final Object initialValue) {
- setCurrentType(JSType.unboxedFieldType(initialValue));
+ setType(JSType.unboxedFieldType(initialValue));
if (initialValue instanceof Integer) {
invokeSetter(owner, ((Integer)initialValue).intValue());
} else if (initialValue instanceof Long) {
@@ -370,7 +363,7 @@
* Initialize the type of a property
*/
protected final void initializeType() {
- setCurrentType(OBJECT_FIELDS_ONLY ? Object.class : null);
+ setType(OBJECT_FIELDS_ONLY ? Object.class : null);
}
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
@@ -557,12 +550,12 @@
} else {
getter = debug(
createGetter(
- getCurrentType(),
+ getLocalType(),
type,
primitiveGetter,
objectGetter,
INVALID_PROGRAM_POINT),
- getCurrentType(),
+ getLocalType(),
type,
"get");
getterCache[i] = getter;
@@ -582,18 +575,18 @@
return debug(
createGetter(
- getCurrentType(),
+ getLocalType(),
type,
primitiveGetter,
objectGetter,
programPoint),
- getCurrentType(),
+ getLocalType(),
type,
"get");
}
private MethodHandle getOptimisticPrimitiveGetter(final Class<?> type, final int programPoint) {
- final MethodHandle g = getGetter(getCurrentType());
+ final MethodHandle g = getGetter(getLocalType());
return MH.asType(OptimisticReturnFilters.filterOptimisticReturnValue(g, type, programPoint), g.type().changeReturnType(type));
}
@@ -631,7 +624,7 @@
}
private MethodHandle generateSetter(final Class<?> forType, final Class<?> type) {
- return debug(createSetter(forType, type, primitiveSetter, objectSetter), getCurrentType(), type, "set");
+ return debug(createSetter(forType, type, primitiveSetter, objectSetter), getLocalType(), type, "set");
}
/**
@@ -639,7 +632,7 @@
* @return true if undefined
*/
protected final boolean isUndefined() {
- return getCurrentType() == null;
+ return getLocalType() == null;
}
@Override
@@ -647,7 +640,7 @@
checkUndeclared();
final int typeIndex = getAccessorTypeIndex(type);
- final int currentTypeIndex = getAccessorTypeIndex(getCurrentType());
+ final int currentTypeIndex = getAccessorTypeIndex(getLocalType());
//if we are asking for an object setter, but are still a primitive type, we might try to box it
MethodHandle mh;
@@ -656,13 +649,13 @@
final PropertyMap newMap = getWiderMap(currentMap, newProperty);
final MethodHandle widerSetter = newProperty.getSetter(type, newMap);
- final Class<?> ct = getCurrentType();
+ final Class<?> ct = getLocalType();
mh = MH.filterArguments(widerSetter, 0, MH.insertArguments(debugReplace(ct, type, currentMap, newMap) , 1, newMap));
if (ct != null && ct.isPrimitive() && !type.isPrimitive()) {
mh = ObjectClassGenerator.createGuardBoxedPrimitiveSetter(ct, generateSetter(ct, ct), mh);
}
} else {
- final Class<?> forType = isUndefined() ? type : getCurrentType();
+ final Class<?> forType = isUndefined() ? type : getLocalType();
mh = generateSetter(!forType.isPrimitive() ? Object.class : forType, type);
}
@@ -681,24 +674,13 @@
return false;
}
// Return true for currently undefined even if non-writable/configurable to allow initialization of ES6 CONST.
- return getCurrentType() == null || (getCurrentType() != Object.class && (isConfigurable() || isWritable()));
+ return getLocalType() == null || (getLocalType() != Object.class && (isConfigurable() || isWritable()));
}
private boolean needsInvalidator(final int typeIndex, final int currentTypeIndex) {
return canChangeType() && typeIndex > currentTypeIndex;
}
- @Override
- public final void setCurrentType(final Class<?> currentType) {
- assert currentType != boolean.class : "no boolean storage support yet - fix this";
- this.currentType = currentType == null ? null : currentType.isPrimitive() ? currentType : Object.class;
- }
-
- @Override
- public Class<?> getCurrentType() {
- return currentType;
- }
-
private MethodHandle debug(final MethodHandle mh, final Class<?> forType, final Class<?> type, final String tag) {
if (!Context.DEBUG || !Global.hasInstance()) {
return mh;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FindProperty.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FindProperty.java Mon Nov 03 10:11:10 2014 -0800
@@ -84,13 +84,18 @@
* @return method handle for the getter
*/
public MethodHandle getGetter(final Class<?> type, final int programPoint, final LinkRequest request) {
- final MethodHandle getter;
+ MethodHandle getter;
if (isValid(programPoint)) {
getter = property.getOptimisticGetter(type, programPoint);
} else {
getter = property.getGetter(type);
}
if (property instanceof UserAccessorProperty) {
+ getter = MH.insertArguments(getter, 1, UserAccessorProperty.getINVOKE_UA_GETTER(type, programPoint));
+ if (isValid(programPoint) && type.isPrimitive()) {
+ getter = MH.insertArguments(getter, 1, programPoint);
+ }
+ property.setType(type);
return insertAccessorsGetter((UserAccessorProperty) property, request, getter);
}
return getter;
@@ -111,7 +116,8 @@
public MethodHandle getSetter(final Class<?> type, final boolean strict, final LinkRequest request) {
MethodHandle setter = property.getSetter(type, getOwner().getMap());
if (property instanceof UserAccessorProperty) {
- setter = MH.insertArguments(setter, 1, strict ? property.getKey() : null);
+ setter = MH.insertArguments(setter, 1, UserAccessorProperty.getINVOKE_UA_SETTER(type), strict ? property.getKey() : null);
+ property.setType(type);
return insertAccessorsGetter((UserAccessorProperty) property, request, setter);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java Mon Nov 03 10:11:10 2014 -0800
@@ -102,6 +102,13 @@
/** Property field number or spill slot. */
private final int slot;
+ /**
+ * Current type of this object, in object only mode, this is an Object.class. In dual-fields mode
+ * null means undefined, and primitive types are allowed. The reason a special type is used for
+ * undefined, is that are no bits left to represent it in primitive types
+ */
+ private Class<?> type;
+
/** SwitchPoint that is invalidated when property is changed, optional */
protected transient SwitchPoint builtinSwitchPoint;
@@ -536,7 +543,7 @@
* <p>
* see {@link ObjectClassGenerator#createSetter(Class, Class, MethodHandle, MethodHandle)}
* if you are interested in the internal details of this. Note that if you
- * are running in default mode, with {@code -Dnashorn.fields.dual=true}, disabled, the setters
+ * are running with {@code -Dnashorn.fields.objects=true}, the setters
* will currently never change, as all properties are represented as Object field,
* the Object fields are Initialized to {@code ScriptRuntime.UNDEFINED} and primitives are
* boxed/unboxed upon every access, which is not necessarily optimal
@@ -569,7 +576,7 @@
@Override
public int hashCode() {
- final Class<?> type = getCurrentType();
+ final Class<?> type = getLocalType();
return Objects.hashCode(this.key) ^ flags ^ getSlot() ^ (type == null ? 0 : type.hashCode());
}
@@ -586,7 +593,7 @@
final Property otherProperty = (Property)other;
return equalsWithoutType(otherProperty) &&
- getCurrentType() == otherProperty.getCurrentType();
+ getLocalType() == otherProperty.getLocalType();
}
boolean equalsWithoutType(final Property otherProperty) {
@@ -615,7 +622,7 @@
*/
public final String toStringShort() {
final StringBuilder sb = new StringBuilder();
- final Class<?> type = getCurrentType();
+ final Class<?> type = getLocalType();
sb.append(getKey()).append(" (").append(type(type)).append(')');
return sb.toString();
}
@@ -632,7 +639,7 @@
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
- final Class<?> type = getCurrentType();
+ final Class<?> type = getLocalType();
sb.append(indent(getKey(), 20)).
append(" id=").
@@ -656,20 +663,40 @@
}
/**
- * Get the current type of this field. If you are not running with dual fields enabled,
+ * Get the current type of this property. If you are running with object fields enabled,
* this will always be Object.class. See the value representation explanation in
* {@link Property#getSetter(Class, PropertyMap)} and {@link ObjectClassGenerator}
* for more information.
*
+ * <p>Note that for user accessor properties, this returns the type of the last observed
+ * value passed to or returned by a user accessor. Use {@link #getLocalType()} to always get
+ * the type of the actual value stored in the property slot.</p>
+ *
* @return current type of property, null means undefined
*/
- public abstract Class<?> getCurrentType();
+ public final Class<?> getType() {
+ return type;
+ }
/**
- * Reset the current type of this property
- * @param currentType new current type
+ * Set the type of this property.
+ * @param type new type
*/
- public abstract void setCurrentType(final Class<?> currentType);
+ public final void setType(final Class<?> type) {
+ assert type != boolean.class : "no boolean storage support yet - fix this";
+ this.type = type == null ? null : type.isPrimitive() ? type : Object.class;
+ }
+
+ /**
+ * Get the type of the value in the local property slot. This returns the same as
+ * {@link #getType()} for normal properties, but always returns {@code Object.class}
+ * for {@link UserAccessorProperty}s as their local type is a pair of accessor references.
+ *
+ * @return the local property type
+ */
+ protected Class<?> getLocalType() {
+ return getType();
+ }
/**
* Check whether this Property can ever change its type. The default is false, and if
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Mon Nov 03 10:11:10 2014 -0800
@@ -512,7 +512,7 @@
assert sameType ||
oldProperty instanceof AccessorProperty &&
newProperty instanceof UserAccessorProperty :
- "arbitrary replaceProperty attempted " + sameType + " oldProperty=" + oldProperty.getClass() + " newProperty=" + newProperty.getClass() + " [" + oldProperty.getCurrentType() + " => " + newProperty.getCurrentType() + "]";
+ "arbitrary replaceProperty attempted " + sameType + " oldProperty=" + oldProperty.getClass() + " newProperty=" + newProperty.getClass() + " [" + oldProperty.getLocalType() + " => " + newProperty.getLocalType() + "]";
newMap.flags = flags;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Mon Nov 03 10:11:10 2014 -0800
@@ -969,7 +969,7 @@
final UserAccessorProperty uc = (UserAccessorProperty)oldProperty;
final int slot = uc.getSlot();
- assert uc.getCurrentType() == Object.class;
+ assert uc.getLocalType() == Object.class;
if (slot >= spillLength) {
uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter));
} else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java Mon Nov 03 10:11:10 2014 -0800
@@ -161,12 +161,12 @@
*/
public SpillProperty(final String key, final int flags, final int slot) {
super(key, flags, slot, primitiveGetter(slot), primitiveSetter(slot), objectGetter(slot), objectSetter(slot));
- assert !OBJECT_FIELDS_ONLY || getCurrentType() == Object.class;
+ assert !OBJECT_FIELDS_ONLY || getLocalType() == Object.class;
}
SpillProperty(final String key, final int flags, final int slot, final Class<?> initialType) {
this(key, flags, slot);
- setCurrentType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
+ setType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
}
SpillProperty(final String key, final int flags, final int slot, final ScriptObject owner, final Object initialValue) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UserAccessorProperty.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UserAccessorProperty.java Mon Nov 03 10:11:10 2014 -0800
@@ -27,16 +27,16 @@
import static jdk.nashorn.internal.lookup.Lookup.MH;
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
-import static jdk.nashorn.internal.runtime.JSType.CONVERT_OBJECT_OPTIMISTIC;
-import static jdk.nashorn.internal.runtime.JSType.getAccessorTypeIndex;
import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
+import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
+import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_PROGRAM_POINT_SHIFT;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
-import java.util.concurrent.Callable;
import jdk.nashorn.internal.lookup.Lookup;
import jdk.nashorn.internal.runtime.linker.Bootstrap;
+import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
/**
* Property with user defined getters/setters. Actual getter and setter
@@ -69,38 +69,29 @@
private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
/** Getter method handle */
- private final static MethodHandle INVOKE_GETTER_ACCESSOR = findOwnMH_S("invokeGetterAccessor", Object.class, Accessors.class, Object.class);
+ private final static MethodHandle INVOKE_OBJECT_GETTER = findOwnMH_S("invokeObjectGetter", Object.class, Accessors.class, MethodHandle.class, Object.class);
+ private final static MethodHandle INVOKE_INT_GETTER = findOwnMH_S("invokeIntGetter", int.class, Accessors.class, MethodHandle.class, int.class, Object.class);
+ private final static MethodHandle INVOKE_LONG_GETTER = findOwnMH_S("invokeLongGetter", long.class, Accessors.class, MethodHandle.class, int.class, Object.class);
+ private final static MethodHandle INVOKE_NUMBER_GETTER = findOwnMH_S("invokeNumberGetter", double.class, Accessors.class, MethodHandle.class, int.class, Object.class);
/** Setter method handle */
- private final static MethodHandle INVOKE_SETTER_ACCESSOR = findOwnMH_S("invokeSetterAccessor", void.class, Accessors.class, String.class, Object.class, Object.class);
+ private final static MethodHandle INVOKE_OBJECT_SETTER = findOwnMH_S("invokeObjectSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, Object.class);
+ private final static MethodHandle INVOKE_INT_SETTER = findOwnMH_S("invokeIntSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, int.class);
+ private final static MethodHandle INVOKE_LONG_SETTER = findOwnMH_S("invokeLongSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, long.class);
+ private final static MethodHandle INVOKE_NUMBER_SETTER = findOwnMH_S("invokeNumberSetter", void.class, Accessors.class, MethodHandle.class, String.class, Object.class, double.class);
- /** Dynamic invoker for getter */
- private static final Object GETTER_INVOKER_KEY = new Object();
-
- private static MethodHandle getINVOKE_UA_GETTER() {
- return Context.getGlobal().getDynamicInvoker(GETTER_INVOKER_KEY,
- new Callable<MethodHandle>() {
- @Override
- public MethodHandle call() {
- return Bootstrap.createDynamicInvoker("dyn:call", Object.class,
- Object.class, Object.class);
- }
- });
+ static MethodHandle getINVOKE_UA_GETTER(final Class<?> returnType, final int programPoint) {
+ if (UnwarrantedOptimismException.isValid(programPoint)) {
+ final int flags = NashornCallSiteDescriptor.CALLSITE_OPTIMISTIC | programPoint << CALLSITE_PROGRAM_POINT_SHIFT;
+ return Bootstrap.createDynamicInvoker("dyn:call", flags, returnType, Object.class, Object.class);
+ } else {
+ return Bootstrap.createDynamicInvoker("dyn:call", Object.class, Object.class, Object.class);
+ }
}
- /** Dynamic invoker for setter */
- private static Object SETTER_INVOKER_KEY = new Object();
-
- private static MethodHandle getINVOKE_UA_SETTER() {
- return Context.getGlobal().getDynamicInvoker(SETTER_INVOKER_KEY,
- new Callable<MethodHandle>() {
- @Override
- public MethodHandle call() {
- return Bootstrap.createDynamicInvoker("dyn:call", void.class,
- Object.class, Object.class, Object.class);
- }
- });
+ static MethodHandle getINVOKE_UA_SETTER(final Class<?> valueType) {
+ return Bootstrap.createDynamicInvoker("dyn:call", void.class, Object.class, Object.class, valueType);
}
/**
@@ -158,7 +149,7 @@
}
@Override
- public Class<?> getCurrentType() {
+ protected Class<?> getLocalType() {
return Object.class;
}
@@ -189,7 +180,13 @@
@Override
public Object getObjectValue(final ScriptObject self, final ScriptObject owner) {
- return invokeGetterAccessor(getAccessors((owner != null) ? owner : self), self);
+ try {
+ return invokeObjectGetter(getAccessors((owner != null) ? owner : self), getINVOKE_UA_GETTER(Object.class, INVALID_PROGRAM_POINT), self);
+ } catch (final Error | RuntimeException t) {
+ throw t;
+ } catch (final Throwable t) {
+ throw new RuntimeException(t);
+ }
}
@Override
@@ -209,41 +206,33 @@
@Override
public void setValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) {
- invokeSetterAccessor(getAccessors((owner != null) ? owner : self), strict ? getKey() : null, self, value);
+ try {
+ invokeObjectSetter(getAccessors((owner != null) ? owner : self), getINVOKE_UA_SETTER(Object.class), strict ? getKey() : null, self, value);
+ } catch (final Error | RuntimeException t) {
+ throw t;
+ } catch (final Throwable t) {
+ throw new RuntimeException(t);
+ }
}
@Override
public MethodHandle getGetter(final Class<?> type) {
//this returns a getter on the format (Accessors, Object receiver)
- return Lookup.filterReturnType(INVOKE_GETTER_ACCESSOR, type);
+ return Lookup.filterReturnType(INVOKE_OBJECT_GETTER, type);
}
@Override
public MethodHandle getOptimisticGetter(final Class<?> type, final int programPoint) {
- //fortype is always object, but in the optimistic world we have to throw
- //unwarranted optimism exception for narrower types. We can improve this
- //by checking for boxed types and unboxing them, but it is doubtful that
- //this gives us any performance, as UserAccessorProperties are typically not
- //primitives. Are there? TODO: investigate later. For now we just throw an
- //exception for narrower types than object
-
- if (type.isPrimitive()) {
- final MethodHandle getter = getGetter(Object.class);
- final MethodHandle mh =
- MH.asType(
- MH.filterReturnValue(
- getter,
- MH.insertArguments(
- CONVERT_OBJECT_OPTIMISTIC.get(getAccessorTypeIndex(type)),
- 1,
- programPoint)),
- getter.type().changeReturnType(type));
-
- return mh;
+ if (type == int.class) {
+ return INVOKE_INT_GETTER;
+ } else if (type == long.class) {
+ return INVOKE_LONG_GETTER;
+ } else if (type == double.class) {
+ return INVOKE_NUMBER_GETTER;
+ } else {
+ assert type == Object.class;
+ return INVOKE_OBJECT_GETTER;
}
-
- assert type == Object.class;
- return getGetter(type);
}
@Override
@@ -259,7 +248,16 @@
@Override
public MethodHandle getSetter(final Class<?> type, final PropertyMap currentMap) {
- return INVOKE_SETTER_ACCESSOR;
+ if (type == int.class) {
+ return INVOKE_INT_SETTER;
+ } else if (type == long.class) {
+ return INVOKE_LONG_SETTER;
+ } else if (type == double.class) {
+ return INVOKE_NUMBER_SETTER;
+ } else {
+ assert type == Object.class;
+ return INVOKE_OBJECT_SETTER;
+ }
}
@Override
@@ -282,31 +280,81 @@
// getter/setter may be inherited. If so, proto is bound during lookup. In either
// inherited or self case, slot is also bound during lookup. Actual ScriptFunction
// to be called is retrieved everytime and applied.
- private static Object invokeGetterAccessor(final Accessors gs, final Object self) {
+ @SuppressWarnings("unused")
+ private static Object invokeObjectGetter(final Accessors gs, final MethodHandle invoker, final Object self) throws Throwable {
final Object func = gs.getter;
if (func instanceof ScriptFunction) {
- try {
- return getINVOKE_UA_GETTER().invokeExact(func, self);
- } catch (final Error | RuntimeException t) {
- throw t;
- } catch (final Throwable t) {
- throw new RuntimeException(t);
- }
+ return invoker.invokeExact(func, self);
}
return UNDEFINED;
}
- private static void invokeSetterAccessor(final Accessors gs, final String name, final Object self, final Object value) {
+ @SuppressWarnings("unused")
+ private static int invokeIntGetter(final Accessors gs, final MethodHandle invoker, final int programPoint, final Object self) throws Throwable {
+ final Object func = gs.getter;
+ if (func instanceof ScriptFunction) {
+ return (int) invoker.invokeExact(func, self);
+ }
+
+ throw new UnwarrantedOptimismException(UNDEFINED, programPoint);
+ }
+
+ @SuppressWarnings("unused")
+ private static long invokeLongGetter(final Accessors gs, final MethodHandle invoker, final int programPoint, final Object self) throws Throwable {
+ final Object func = gs.getter;
+ if (func instanceof ScriptFunction) {
+ return (long) invoker.invokeExact(func, self);
+ }
+
+ throw new UnwarrantedOptimismException(UNDEFINED, programPoint);
+ }
+
+ @SuppressWarnings("unused")
+ private static double invokeNumberGetter(final Accessors gs, final MethodHandle invoker, final int programPoint, final Object self) throws Throwable {
+ final Object func = gs.getter;
+ if (func instanceof ScriptFunction) {
+ return (double) invoker.invokeExact(func, self);
+ }
+
+ throw new UnwarrantedOptimismException(UNDEFINED, programPoint);
+ }
+
+ @SuppressWarnings("unused")
+ private static void invokeObjectSetter(final Accessors gs, final MethodHandle invoker, final String name, final Object self, final Object value) throws Throwable {
final Object func = gs.setter;
if (func instanceof ScriptFunction) {
- try {
- getINVOKE_UA_SETTER().invokeExact(func, self, value);
- } catch (final Error | RuntimeException t) {
- throw t;
- } catch (final Throwable t) {
- throw new RuntimeException(t);
- }
+ invoker.invokeExact(func, self, value);
+ } else if (name != null) {
+ throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self));
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private static void invokeIntSetter(final Accessors gs, final MethodHandle invoker, final String name, final Object self, final int value) throws Throwable {
+ final Object func = gs.setter;
+ if (func instanceof ScriptFunction) {
+ invoker.invokeExact(func, self, value);
+ } else if (name != null) {
+ throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self));
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private static void invokeLongSetter(final Accessors gs, final MethodHandle invoker, final String name, final Object self, final long value) throws Throwable {
+ final Object func = gs.setter;
+ if (func instanceof ScriptFunction) {
+ invoker.invokeExact(func, self, value);
+ } else if (name != null) {
+ throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self));
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private static void invokeNumberSetter(final Accessors gs, final MethodHandle invoker, final String name, final Object self, final double value) throws Throwable {
+ final Object func = gs.setter;
+ if (func instanceof ScriptFunction) {
+ invoker.invokeExact(func, self, value);
} else if (name != null) {
throw typeError("property.has.no.setter", name, ScriptRuntime.safeToString(self));
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Mon Nov 03 10:11:10 2014 -0800
@@ -337,6 +337,20 @@
/**
* Returns a dynamic invoker for a specified dynamic operation using the public lookup. Similar to
+ * {@link #createDynamicInvoker(String, Class, Class...)} but with an additional parameter to
+ * set the call site flags of the dynamic invoker.
+ * @param opDesc Dynalink dynamic operation descriptor.
+ * @param flags the call site flags for the operation
+ * @param rtype the return type for the operation
+ * @param ptypes the parameter types for the operation
+ * @return MethodHandle for invoking the operation.
+ */
+ public static MethodHandle createDynamicInvoker(final String opDesc, final int flags, final Class<?> rtype, final Class<?>... ptypes) {
+ return bootstrap(MethodHandles.publicLookup(), opDesc, MethodType.methodType(rtype, ptypes), flags).dynamicInvoker();
+ }
+
+ /**
+ * Returns a dynamic invoker for a specified dynamic operation using the public lookup. Similar to
* {@link #createDynamicInvoker(String, Class, Class...)} but with return and parameter types composed into a
* method type in the signature. See the discussion of that method for details.
* @param opDesc Dynalink dynamic operation descriptor.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/examples/getter-setter-micro.js Mon Nov 03 10:11:10 2014 -0800
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, 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
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * A micro-benchmark for getters and setters with primitive values,
+ * alternating between ints and doubles. Introduction of primitive
+ * and optimistic user accessors in JDK-8062401 make this faster by
+ * 10x or more by allowing inlining and other optimizations to take place.
+ */
+
+var x = {
+ get m() {
+ return this._m;
+ },
+ set m(v) {
+ this._m = v;
+ },
+ get n() {
+ return this._n;
+ },
+ set n(v) {
+ this._n = v;
+ }
+};
+
+
+function bench(v1, v2, result) {
+ var start = Date.now();
+ x.n = v1;
+ for (var i = 0; i < 1e8; i++) {
+ x.m = v2;
+ if (x.m + x.n !== result) {
+ throw "wrong result";
+ }
+ }
+ print("done in", Date.now() - start, "millis");
+}
+
+for (var i = 0; i < 10; i++) {
+ bench(i, 4, 4 + i);
+}
+
+for (var i = 0; i < 10; i++) {
+ bench(i, 4.5, 4.5 + i);
+}
+
+for (var i = 0; i < 10; i++) {
+ bench(i, 5, 5 + i);
+}
+
+for (var i = 0; i < 10; i++) {
+ bench(i, 5.5, 5.5 + i);
+}
--- a/nashorn/test/script/basic/JDK-8062024.js Sat Nov 01 14:40:09 2014 +0300
+++ b/nashorn/test/script/basic/JDK-8062024.js Mon Nov 03 10:11:10 2014 -0800
@@ -25,6 +25,7 @@
* JDK-8062024: Issue with date.setFullYear when time other than midnight
*
* @test
+ * @option -timezone=Asia/Calcutta
* @run
*/