--- a/.hgtags-top-repo Thu Dec 18 19:57:48 2014 -0800
+++ b/.hgtags-top-repo Wed Jul 05 20:11:52 2017 +0200
@@ -285,3 +285,4 @@
cf136458ee747e151a27aa9ea0c1492ea55ef3e7 jdk9-b40
67395f7ca2db3b52e3a62a84888487de5cb9210a jdk9-b41
f7c11da0b0481d49cc7a65a453336c108191e821 jdk9-b42
+02ee8c65622e8bd97496d584e22fc7dcf0edc4ae jdk9-b43
--- a/common/autoconf/generated-configure.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/common/autoconf/generated-configure.sh Wed Jul 05 20:11:52 2017 +0200
@@ -4329,7 +4329,7 @@
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1418036274
+DATE_WHEN_GENERATED=1418395009
###############################################################################
#
@@ -13965,7 +13965,8 @@
# ZERO_ARCHDEF is used to enable architecture-specific code
case "${OPENJDK_TARGET_CPU}" in
- ppc*) ZERO_ARCHDEF=PPC ;;
+ ppc) ZERO_ARCHDEF=PPC32 ;;
+ ppc64) ZERO_ARCHDEF=PPC64 ;;
s390*) ZERO_ARCHDEF=S390 ;;
sparc*) ZERO_ARCHDEF=SPARC ;;
x86_64*) ZERO_ARCHDEF=AMD64 ;;
--- a/common/autoconf/platform.m4 Thu Dec 18 19:57:48 2014 -0800
+++ b/common/autoconf/platform.m4 Wed Jul 05 20:11:52 2017 +0200
@@ -367,7 +367,8 @@
# ZERO_ARCHDEF is used to enable architecture-specific code
case "${OPENJDK_TARGET_CPU}" in
- ppc*) ZERO_ARCHDEF=PPC ;;
+ ppc) ZERO_ARCHDEF=PPC32 ;;
+ ppc64) ZERO_ARCHDEF=PPC64 ;;
s390*) ZERO_ARCHDEF=S390 ;;
sparc*) ZERO_ARCHDEF=SPARC ;;
x86_64*) ZERO_ARCHDEF=AMD64 ;;
--- a/common/bin/hgforest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/common/bin/hgforest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -106,12 +106,15 @@
echo "# Mercurial command: ${command}" > ${status_output}
fi
-
-# capture command options and arguments (if any)
-command_args="${@:-}"
+# At this point all command options and args are in "$@".
+# Always use "$@" (within double quotes) to avoid breaking
+# args with spaces into separate args.
if [ ${vflag} = "true" ] ; then
- echo "# Mercurial command arguments: ${command_args}" > ${status_output}
+ echo "# Mercurial command argument count: $#" > ${status_output}
+ for cmdarg in "$@" ; do
+ echo "# Mercurial command argument: ${cmdarg}" > ${status_output}
+ done
fi
# Clean out the temporary directory that stores the pid files.
@@ -205,13 +208,14 @@
pull_default_tail=`echo ${pull_default} | sed -e 's@^.*://[^/]*/\(.*\)@\1@'`
- if [ -n "${command_args}" ] ; then
+ if [ $# -gt 0 ] ; then
# if there is an "extra sources" path then reparent "extra" repos to that path
if [ "x${pull_default}" = "x${pull_default_tail}" ] ; then
echo "ERROR: Need initial clone from non-local source" > ${status_output}
exit 1
fi
- pull_extra="${command_args}/${pull_default_tail}"
+ # assume that "extra sources" path is the first arg
+ pull_extra="${1}/${pull_default_tail}"
# determine which extra subrepos need to be cloned.
for i in ${subrepos_extra} ; do
@@ -356,8 +360,8 @@
(PYTHONUNBUFFERED=true hg${global_opts} clone ${clone_newrepo} ${i}; echo "$?" > ${tmp}/${repopidfile}.pid.rc ) 2>&1 &
else
# run the command.
- echo "cd ${i} && hg${global_opts} ${command} ${command_args}" > ${status_output}
- cd ${i} && (PYTHONUNBUFFERED=true hg${global_opts} ${command} ${command_args}; echo "$?" > ${tmp}/${repopidfile}.pid.rc ) 2>&1 &
+ echo "cd ${i} && hg${global_opts} ${command} ${@}" > ${status_output}
+ cd ${i} && (PYTHONUNBUFFERED=true hg${global_opts} ${command} "${@}"; echo "$?" > ${tmp}/${repopidfile}.pid.rc ) 2>&1 &
fi
echo $! > ${tmp}/${repopidfile}.pid
--- a/hotspot/.hgtags Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/.hgtags Wed Jul 05 20:11:52 2017 +0200
@@ -445,3 +445,4 @@
6b09b3193d731e3288e2a240c504a20d0a06c766 jdk9-b40
1d29b13e8a515a7ea3b882f140576d5d675bc11f jdk9-b41
38cb4fbd47e3472bd1b5ebac83bda96fe4869c4f jdk9-b42
+65a9747147b8090037541040ba67156ec914db6a jdk9-b43
--- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -675,7 +675,7 @@
case handle_exception_nofpu_id:
case handle_exception_id:
// At this point all registers MAY be live.
- oop_map = save_live_registers(sasm, 1 /*thread*/, id == handle_exception_nofpu_id);
+ oop_map = save_live_registers(sasm, 1 /*thread*/, id != handle_exception_nofpu_id);
break;
case handle_exception_from_callee_id: {
// At this point all registers except exception oop (RAX) and
@@ -748,7 +748,7 @@
case handle_exception_nofpu_id:
case handle_exception_id:
// Restore the registers that were saved at the beginning.
- restore_live_registers(sasm, id == handle_exception_nofpu_id);
+ restore_live_registers(sasm, id != handle_exception_nofpu_id);
break;
case handle_exception_from_callee_id:
// WIN64_ONLY: No need to add frame::arg_reg_save_area_bytes to SP
--- a/hotspot/src/os/windows/vm/os_windows.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -3074,7 +3074,7 @@
char* os::pd_reserve_memory(size_t bytes, char* addr, size_t alignment_hint) {
assert((size_t)addr % os::vm_allocation_granularity() == 0,
"reserve alignment");
- assert(bytes % os::vm_allocation_granularity() == 0, "reserve block size");
+ assert(bytes % os::vm_page_size() == 0, "reserve page size");
char* res;
// note that if UseLargePages is on, all the areas that require interleaving
// will go thru reserve_memory_special rather than thru here.
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -3108,21 +3108,39 @@
}
}
-// Transfer ownership of metadata allocated to the InstanceKlass.
-void ClassFileParser::apply_parsed_class_metadata(
- instanceKlassHandle this_klass,
- int java_fields_count, TRAPS) {
- // Assign annotations if needed
- if (_annotations != NULL || _type_annotations != NULL ||
- _fields_annotations != NULL || _fields_type_annotations != NULL) {
+// Create the Annotations object that will
+// hold the annotations array for the Klass.
+void ClassFileParser::create_combined_annotations(TRAPS) {
+ if (_annotations == NULL &&
+ _type_annotations == NULL &&
+ _fields_annotations == NULL &&
+ _fields_type_annotations == NULL) {
+ // Don't create the Annotations object unnecessarily.
+ return;
+ }
+
Annotations* annotations = Annotations::allocate(_loader_data, CHECK);
annotations->set_class_annotations(_annotations);
annotations->set_class_type_annotations(_type_annotations);
annotations->set_fields_annotations(_fields_annotations);
annotations->set_fields_type_annotations(_fields_type_annotations);
- this_klass->set_annotations(annotations);
- }
-
+
+ // This is the Annotations object that will be
+ // assigned to InstanceKlass being constructed.
+ _combined_annotations = annotations;
+
+ // The annotations arrays below has been transfered the
+ // _combined_annotations so these fields can now be cleared.
+ _annotations = NULL;
+ _type_annotations = NULL;
+ _fields_annotations = NULL;
+ _fields_type_annotations = NULL;
+}
+
+// Transfer ownership of metadata allocated to the InstanceKlass.
+void ClassFileParser::apply_parsed_class_metadata(
+ instanceKlassHandle this_klass,
+ int java_fields_count, TRAPS) {
_cp->set_pool_holder(this_klass());
this_klass->set_constants(_cp);
this_klass->set_fields(_fields, java_fields_count);
@@ -3130,6 +3148,7 @@
this_klass->set_inner_classes(_inner_classes);
this_klass->set_local_interfaces(_local_interfaces);
this_klass->set_transitive_interfaces(_transitive_interfaces);
+ this_klass->set_annotations(_combined_annotations);
// Clear out these fields so they don't get deallocated by the destructor
clear_class_metadata();
@@ -4002,6 +4021,10 @@
ClassAnnotationCollector parsed_annotations;
parse_classfile_attributes(&parsed_annotations, CHECK_(nullHandle));
+ // Finalize the Annotations metadata object,
+ // now that all annotation arrays have been created.
+ create_combined_annotations(CHECK_(nullHandle));
+
// Make sure this is the end of class file stream
guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
@@ -4302,10 +4325,27 @@
InstanceKlass::deallocate_interfaces(_loader_data, _super_klass(),
_local_interfaces, _transitive_interfaces);
- MetadataFactory::free_array<u1>(_loader_data, _annotations);
- MetadataFactory::free_array<u1>(_loader_data, _type_annotations);
- Annotations::free_contents(_loader_data, _fields_annotations);
- Annotations::free_contents(_loader_data, _fields_type_annotations);
+ if (_combined_annotations != NULL) {
+ // After all annotations arrays have been created, they are installed into the
+ // Annotations object that will be assigned to the InstanceKlass being created.
+
+ // Deallocate the Annotations object and the installed annotations arrays.
+ _combined_annotations->deallocate_contents(_loader_data);
+
+ // If the _combined_annotations pointer is non-NULL,
+ // then the other annotations fields should have been cleared.
+ assert(_annotations == NULL, "Should have been cleared");
+ assert(_type_annotations == NULL, "Should have been cleared");
+ assert(_fields_annotations == NULL, "Should have been cleared");
+ assert(_fields_type_annotations == NULL, "Should have been cleared");
+ } else {
+ // If the annotations arrays were not installed into the Annotations object,
+ // then they have to be deallocated explicitly.
+ MetadataFactory::free_array<u1>(_loader_data, _annotations);
+ MetadataFactory::free_array<u1>(_loader_data, _type_annotations);
+ Annotations::free_contents(_loader_data, _fields_annotations);
+ Annotations::free_contents(_loader_data, _fields_type_annotations);
+ }
clear_class_metadata();
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -75,6 +75,7 @@
Array<u2>* _inner_classes;
Array<Klass*>* _local_interfaces;
Array<Klass*>* _transitive_interfaces;
+ Annotations* _combined_annotations;
AnnotationArray* _annotations;
AnnotationArray* _type_annotations;
Array<AnnotationArray*>* _fields_annotations;
@@ -86,6 +87,8 @@
void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
void set_class_sde_buffer(char* x, int len) { _sde_buffer = x; _sde_length = len; }
+ void create_combined_annotations(TRAPS);
+
void init_parsed_class_attributes(ClassLoaderData* loader_data) {
_loader_data = loader_data;
_synthetic_flag = false;
@@ -110,6 +113,7 @@
_inner_classes = NULL;
_local_interfaces = NULL;
_transitive_interfaces = NULL;
+ _combined_annotations = NULL;
_annotations = _type_annotations = NULL;
_fields_annotations = _fields_type_annotations = NULL;
}
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -793,11 +793,6 @@
}
}
-CompactibleSpace*
-ConcurrentMarkSweepGeneration::first_compaction_space() const {
- return _cmsSpace;
-}
-
void ConcurrentMarkSweepGeneration::reset_after_compaction() {
// Clear the promotion information. These pointers can be adjusted
// along with all the other pointers into the heap but
@@ -808,10 +803,6 @@
}
}
-void ConcurrentMarkSweepGeneration::space_iterate(SpaceClosure* blk, bool usedOnly) {
- blk->do_space(_cmsSpace);
-}
-
void ConcurrentMarkSweepGeneration::compute_new_size() {
assert_locked_or_safepoint(Heap_lock);
@@ -882,7 +873,7 @@
expand_bytes);
}
// safe if expansion fails
- expand(expand_bytes, 0, CMSExpansionCause::_satisfy_free_ratio);
+ expand_for_gc_cause(expand_bytes, 0, CMSExpansionCause::_satisfy_free_ratio);
if (PrintGCDetails && Verbose) {
gclog_or_tty->print_cr(" Expanded free fraction %f",
((double) free()) / capacity());
@@ -1048,8 +1039,7 @@
if (res == NULL) {
// expand and retry
size_t s = _cmsSpace->expansionSpaceRequired(obj_size); // HeapWords
- expand(s*HeapWordSize, MinHeapDeltaBytes,
- CMSExpansionCause::_satisfy_promotion);
+ expand_for_gc_cause(s*HeapWordSize, MinHeapDeltaBytes, CMSExpansionCause::_satisfy_promotion);
// Since there's currently no next generation, we don't try to promote
// into a more senior generation.
assert(next_gen() == NULL, "assumption, based upon which no attempt "
@@ -2625,13 +2615,6 @@
ALL_SINCE_SAVE_MARKS_CLOSURES(CMS_SINCE_SAVE_MARKS_DEFN)
void
-ConcurrentMarkSweepGeneration::younger_refs_iterate(OopsInGenClosure* cl) {
- cl->set_generation(this);
- younger_refs_in_space_iterate(_cmsSpace, cl);
- cl->reset_generation();
-}
-
-void
ConcurrentMarkSweepGeneration::oop_iterate(ExtendedOopClosure* cl) {
if (freelistLock()->owned_by_self()) {
Generation::oop_iterate(cl);
@@ -2803,23 +2786,17 @@
CMSSynchronousYieldRequest yr;
assert(!tlab, "Can't deal with TLAB allocation");
MutexLockerEx x(freelistLock(), Mutex::_no_safepoint_check_flag);
- expand(word_size*HeapWordSize, MinHeapDeltaBytes,
- CMSExpansionCause::_satisfy_allocation);
+ expand_for_gc_cause(word_size*HeapWordSize, MinHeapDeltaBytes, CMSExpansionCause::_satisfy_allocation);
if (GCExpandToAllocateDelayMillis > 0) {
os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false);
}
return have_lock_and_allocate(word_size, tlab);
}
-// YSR: All of this generation expansion/shrinking stuff is an exact copy of
-// TenuredGeneration, which makes me wonder if we should move this
-// to CardGeneration and share it...
-bool ConcurrentMarkSweepGeneration::expand(size_t bytes, size_t expand_bytes) {
- return CardGeneration::expand(bytes, expand_bytes);
-}
-
-void ConcurrentMarkSweepGeneration::expand(size_t bytes, size_t expand_bytes,
- CMSExpansionCause::Cause cause)
+void ConcurrentMarkSweepGeneration::expand_for_gc_cause(
+ size_t bytes,
+ size_t expand_bytes,
+ CMSExpansionCause::Cause cause)
{
bool success = expand(bytes, expand_bytes);
@@ -2848,8 +2825,7 @@
return NULL;
}
// Otherwise, we try expansion.
- expand(word_sz*HeapWordSize, MinHeapDeltaBytes,
- CMSExpansionCause::_allocate_par_lab);
+ expand_for_gc_cause(word_sz*HeapWordSize, MinHeapDeltaBytes, CMSExpansionCause::_allocate_par_lab);
// Now go around the loop and try alloc again;
// A competing par_promote might beat us to the expansion space,
// so we may go around the loop again if promotion fails again.
@@ -2876,8 +2852,7 @@
return false;
}
// Otherwise, we try expansion.
- expand(refill_size_bytes, MinHeapDeltaBytes,
- CMSExpansionCause::_allocate_par_spooling_space);
+ expand_for_gc_cause(refill_size_bytes, MinHeapDeltaBytes, CMSExpansionCause::_allocate_par_spooling_space);
// Now go around the loop and try alloc again;
// A competing allocation might beat us to the expansion space,
// so we may go around the loop again if allocation fails again.
@@ -2887,77 +2862,16 @@
}
}
-
-void ConcurrentMarkSweepGeneration::shrink_by(size_t bytes) {
- assert_locked_or_safepoint(ExpandHeap_lock);
- // Shrink committed space
- _virtual_space.shrink_by(bytes);
- // Shrink space; this also shrinks the space's BOT
- _cmsSpace->set_end((HeapWord*) _virtual_space.high());
- size_t new_word_size = heap_word_size(_cmsSpace->capacity());
- // Shrink the shared block offset array
- _bts->resize(new_word_size);
- MemRegion mr(_cmsSpace->bottom(), new_word_size);
- // Shrink the card table
- Universe::heap()->barrier_set()->resize_covered_region(mr);
-
- if (Verbose && PrintGC) {
- size_t new_mem_size = _virtual_space.committed_size();
- size_t old_mem_size = new_mem_size + bytes;
- gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
- name(), old_mem_size/K, new_mem_size/K);
- }
-}
-
void ConcurrentMarkSweepGeneration::shrink(size_t bytes) {
- assert_locked_or_safepoint(Heap_lock);
- size_t size = ReservedSpace::page_align_size_down(bytes);
// Only shrink if a compaction was done so that all the free space
// in the generation is in a contiguous block at the end.
- if (size > 0 && did_compact()) {
- shrink_by(size);
- }
-}
-
-bool ConcurrentMarkSweepGeneration::grow_by(size_t bytes) {
+ if (did_compact()) {
+ CardGeneration::shrink(bytes);
+ }
+}
+
+void ConcurrentMarkSweepGeneration::assert_correct_size_change_locking() {
assert_locked_or_safepoint(Heap_lock);
- bool result = _virtual_space.expand_by(bytes);
- if (result) {
- size_t new_word_size =
- heap_word_size(_virtual_space.committed_size());
- MemRegion mr(_cmsSpace->bottom(), new_word_size);
- _bts->resize(new_word_size); // resize the block offset shared array
- Universe::heap()->barrier_set()->resize_covered_region(mr);
- // Hmmmm... why doesn't CFLS::set_end verify locking?
- // This is quite ugly; FIX ME XXX
- _cmsSpace->assert_locked(freelistLock());
- _cmsSpace->set_end((HeapWord*)_virtual_space.high());
-
- // update the space and generation capacity counters
- if (UsePerfData) {
- _space_counters->update_capacity();
- _gen_counters->update_all();
- }
-
- if (Verbose && PrintGC) {
- size_t new_mem_size = _virtual_space.committed_size();
- size_t old_mem_size = new_mem_size - bytes;
- gclog_or_tty->print_cr("Expanding %s from " SIZE_FORMAT "K by " SIZE_FORMAT "K to " SIZE_FORMAT "K",
- name(), old_mem_size/K, bytes/K, new_mem_size/K);
- }
- }
- return result;
-}
-
-bool ConcurrentMarkSweepGeneration::grow_to_reserved() {
- assert_locked_or_safepoint(Heap_lock);
- bool success = true;
- const size_t remaining_bytes = _virtual_space.uncommitted_size();
- if (remaining_bytes > 0) {
- success = grow_by(remaining_bytes);
- DEBUG_ONLY(if (!success) warning("grow to reserved failed");)
- }
- return success;
}
void ConcurrentMarkSweepGeneration::shrink_free_list_by(size_t bytes) {
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -30,9 +30,10 @@
#include "gc_implementation/shared/gcStats.hpp"
#include "gc_implementation/shared/gcWhen.hpp"
#include "gc_implementation/shared/generationCounters.hpp"
+#include "memory/cardGeneration.hpp"
#include "memory/freeBlockDictionary.hpp"
-#include "memory/generation.hpp"
#include "memory/iterator.hpp"
+#include "memory/space.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/virtualspace.hpp"
#include "services/memoryService.hpp"
@@ -171,9 +172,7 @@
// Represents a marking stack used by the CMS collector.
// Ideally this should be GrowableArray<> just like MSC's marking stack(s).
class CMSMarkStack: public CHeapObj<mtGC> {
- //
friend class CMSCollector; // To get at expansion stats further below.
- //
VirtualSpace _virtual_space; // Space for the stack
oop* _base; // Bottom of stack
@@ -1031,6 +1030,9 @@
void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;}
CMSExpansionCause::Cause expansion_cause() const { return _expansion_cause; }
+ // Accessing spaces
+ CompactibleSpace* space() const { return (CompactibleSpace*)_cmsSpace; }
+
private:
// For parallel young-gen GC support.
CMSParGCThreadState** _par_gc_thread_states;
@@ -1064,6 +1066,10 @@
double initiating_occupancy() const { return _initiating_occupancy; }
void init_initiating_occupancy(intx io, uintx tr);
+ void expand_for_gc_cause(size_t bytes, size_t expand_bytes, CMSExpansionCause::Cause cause);
+
+ void assert_correct_size_change_locking();
+
public:
ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size,
int level, CardTableRS* ct,
@@ -1100,23 +1106,14 @@
// Override
virtual void ref_processor_init();
- // Grow generation by specified size (returns false if unable to grow)
- bool grow_by(size_t bytes);
- // Grow generation to reserved size.
- bool grow_to_reserved();
-
void clear_expansion_cause() { _expansion_cause = CMSExpansionCause::_no_expansion; }
// Space enquiries
- size_t capacity() const;
- size_t used() const;
- size_t free() const;
double occupancy() const { return ((double)used())/((double)capacity()); }
size_t contiguous_available() const;
size_t unsafe_max_alloc_nogc() const;
// over-rides
- MemRegion used_region() const;
MemRegion used_region_at_save_marks() const;
// Does a "full" (forced) collection invoked on this generation collect
@@ -1127,10 +1124,6 @@
return !ScavengeBeforeFullGC;
}
- void space_iterate(SpaceClosure* blk, bool usedOnly = false);
-
- // Support for compaction
- CompactibleSpace* first_compaction_space() const;
// Adjust quantities in the generation affected by
// the compaction.
void reset_after_compaction();
@@ -1190,18 +1183,13 @@
}
// Allocation failure
- void expand(size_t bytes, size_t expand_bytes,
- CMSExpansionCause::Cause cause);
- virtual bool expand(size_t bytes, size_t expand_bytes);
void shrink(size_t bytes);
- void shrink_by(size_t bytes);
HeapWord* expand_and_par_lab_allocate(CMSParGCThreadState* ps, size_t word_sz);
bool expand_and_ensure_spooling_space(PromotionInfo* promo);
// Iteration support and related enquiries
void save_marks();
bool no_allocs_since_save_marks();
- void younger_refs_iterate(OopsInGenClosure* cl);
// Iteration support specific to CMS generations
void save_sweep_limit();
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -369,22 +369,6 @@
cmsSpace()->save_sweep_limit();
}
-inline size_t ConcurrentMarkSweepGeneration::capacity() const {
- return _cmsSpace->capacity();
-}
-
-inline size_t ConcurrentMarkSweepGeneration::used() const {
- return _cmsSpace->used();
-}
-
-inline size_t ConcurrentMarkSweepGeneration::free() const {
- return _cmsSpace->free();
-}
-
-inline MemRegion ConcurrentMarkSweepGeneration::used_region() const {
- return _cmsSpace->used_region();
-}
-
inline MemRegion ConcurrentMarkSweepGeneration::used_region_at_save_marks() const {
return _cmsSpace->used_region_at_save_marks();
}
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -352,7 +352,7 @@
}
void G1RegionMappingChangedListener::reset_from_card_cache(uint start_idx, size_t num_regions) {
- OtherRegionsTable::invalidate(start_idx, num_regions);
+ HeapRegionRemSet::invalidate_from_card_cache(start_idx, num_regions);
}
void G1RegionMappingChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -407,20 +407,8 @@
}
}
-void OtherRegionsTable::initialize(uint max_regions) {
- FromCardCache::initialize(HeapRegionRemSet::num_par_rem_sets(), max_regions);
-}
-
-void OtherRegionsTable::invalidate(uint start_idx, size_t num_regions) {
- FromCardCache::invalidate(start_idx, num_regions);
-}
-
-void OtherRegionsTable::print_from_card_cache() {
- FromCardCache::print();
-}
-
void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, uint tid) {
- uint cur_hrm_ind = hr()->hrm_index();
+ uint cur_hrm_ind = _hr->hrm_index();
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").",
@@ -434,7 +422,7 @@
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print_cr("Table for [" PTR_FORMAT "...): card %d (cache = %d)",
- hr()->bottom(), from_card,
+ _hr->bottom(), from_card,
FromCardCache::at(tid, cur_hrm_ind));
}
@@ -477,13 +465,13 @@
if (G1HRRSUseSparseTable &&
_sparse_table.add_card(from_hrm_ind, card_index)) {
if (G1RecordHRRSOops) {
- HeapRegionRemSet::record(hr(), from);
+ HeapRegionRemSet::record(_hr, from);
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print(" Added card " PTR_FORMAT " to region "
"[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n",
align_size_down(uintptr_t(from),
CardTableModRefBS::card_size),
- hr()->bottom(), from);
+ _hr->bottom(), from);
}
}
if (G1TraceHeapRegionRememberedSet) {
@@ -539,13 +527,13 @@
prt->add_reference(from);
if (G1RecordHRRSOops) {
- HeapRegionRemSet::record(hr(), from);
+ HeapRegionRemSet::record(_hr, from);
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print("Added card " PTR_FORMAT " to region "
"[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n",
align_size_down(uintptr_t(from),
CardTableModRefBS::card_size),
- hr()->bottom(), from);
+ _hr->bottom(), from);
}
}
assert(contains_reference(from), "We just added it!");
@@ -614,7 +602,7 @@
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print("Coarsened entry in region [" PTR_FORMAT "...] "
"for region [" PTR_FORMAT "...] (" SIZE_FORMAT " coarse entries).\n",
- hr()->bottom(),
+ _hr->bottom(),
max->hr()->bottom(),
_n_coarse_entries);
}
@@ -627,13 +615,11 @@
return max;
}
-
-// At present, this must be called stop-world single-threaded.
void OtherRegionsTable::scrub(CardTableModRefBS* ctbs,
BitMap* region_bm, BitMap* card_bm) {
// First eliminated garbage regions from the coarse map.
if (G1RSScrubVerbose) {
- gclog_or_tty->print_cr("Scrubbing region %u:", hr()->hrm_index());
+ gclog_or_tty->print_cr("Scrubbing region %u:", _hr->hrm_index());
}
assert(_coarse_map.size() == region_bm->size(), "Precondition");
@@ -752,7 +738,7 @@
}
void OtherRegionsTable::clear_fcc() {
- FromCardCache::clear(hr()->hrm_index());
+ FromCardCache::clear(_hr->hrm_index());
}
void OtherRegionsTable::clear() {
@@ -774,27 +760,6 @@
clear_fcc();
}
-bool OtherRegionsTable::del_single_region_table(size_t ind,
- HeapRegion* hr) {
- assert(0 <= ind && ind < _max_fine_entries, "Preconditions.");
- PerRegionTable** prev_addr = &_fine_grain_regions[ind];
- PerRegionTable* prt = *prev_addr;
- while (prt != NULL && prt->hr() != hr) {
- prev_addr = prt->collision_list_next_addr();
- prt = prt->collision_list_next();
- }
- if (prt != NULL) {
- assert(prt->hr() == hr, "Loop postcondition.");
- *prev_addr = prt->collision_list_next();
- unlink_from_all(prt);
- PerRegionTable::free(prt);
- _n_fine_entries--;
- return true;
- } else {
- return false;
- }
-}
-
bool OtherRegionsTable::contains_reference(OopOrNarrowOopStar from) const {
// Cast away const in this case.
MutexLockerEx x((Mutex*)_m, Mutex::_no_safepoint_check_flag);
@@ -975,7 +940,7 @@
_hrrs(hrrs),
_g1h(G1CollectedHeap::heap()),
_coarse_map(&hrrs->_other_regions._coarse_map),
- _bosa(hrrs->bosa()),
+ _bosa(hrrs->_bosa),
_is(Sparse),
// Set these values so that we increment to the first region.
_coarse_cur_region_index(-1),
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -162,32 +162,36 @@
// to hold _m, and the fine-grain table to be full.
PerRegionTable* delete_region_table();
- // If a PRT for "hr" is in the bucket list indicated by "ind" (which must
- // be the correct index for "hr"), delete it and return true; else return
- // false.
- bool del_single_region_table(size_t ind, HeapRegion* hr);
-
// link/add the given fine grain remembered set into the "all" list
void link_to_all(PerRegionTable * prt);
// unlink/remove the given fine grain remembered set into the "all" list
void unlink_from_all(PerRegionTable * prt);
+ bool contains_reference_locked(OopOrNarrowOopStar from) const;
+
+ // Clear the from_card_cache entries for this region.
+ void clear_fcc();
public:
+ // Create a new remembered set for the given heap region. The given mutex should
+ // be used to ensure consistency.
OtherRegionsTable(HeapRegion* hr, Mutex* m);
- HeapRegion* hr() const { return _hr; }
-
// For now. Could "expand" some tables in the future, so that this made
// sense.
void add_reference(OopOrNarrowOopStar from, uint tid);
+ // Returns whether the remembered set contains the given reference.
+ bool contains_reference(OopOrNarrowOopStar from) const;
+
// Removes any entries shown by the given bitmaps to contain only dead
- // objects.
+ // objects. Not thread safe.
+ // Set bits in the bitmaps indicate that the given region or card is live.
void scrub(CardTableModRefBS* ctbs, BitMap* region_bm, BitMap* card_bm);
- // Returns whether this remembered set (and all sub-sets) contain no entries.
+ // Returns whether this remembered set (and all sub-sets) does not contain any entry.
bool is_empty() const;
+ // Returns the number of cards contained in this remembered set.
size_t occupied() const;
size_t occ_fine() const;
size_t occ_coarse() const;
@@ -195,31 +199,17 @@
static jint n_coarsenings() { return _n_coarsenings; }
- // Returns size in bytes.
- // Not const because it takes a lock.
+ // Returns size of the actual remembered set containers in bytes.
size_t mem_size() const;
+ // Returns the size of static data in bytes.
static size_t static_mem_size();
+ // Returns the size of the free list content in bytes.
static size_t fl_mem_size();
- bool contains_reference(OopOrNarrowOopStar from) const;
- bool contains_reference_locked(OopOrNarrowOopStar from) const;
-
+ // Clear the entire contents of this remembered set.
void clear();
- // Specifically clear the from_card_cache.
- void clear_fcc();
-
void do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task);
-
- // Declare the heap size (in # of regions) to the OtherRegionsTable.
- // (Uses it to initialize from_card_cache).
- static void initialize(uint max_regions);
-
- // Declares that regions between start_idx <= i < start_idx + num_regions are
- // not in use. Make sure that any entries for these regions are invalid.
- static void invalidate(uint start_idx, size_t num_regions);
-
- static void print_from_card_cache();
};
class HeapRegionRemSet : public CHeapObj<mtGC> {
@@ -233,7 +223,6 @@
private:
G1BlockOffsetSharedArray* _bosa;
- G1BlockOffsetSharedArray* bosa() const { return _bosa; }
// A set of code blobs (nmethods) whose code contains pointers into
// the region that owns this RSet.
@@ -268,10 +257,6 @@
static uint num_par_rem_sets();
static void setup_remset_size();
- HeapRegion* hr() const {
- return _other_regions.hr();
- }
-
bool is_empty() const {
return (strong_code_roots_list_length() == 0) && _other_regions.is_empty();
}
@@ -305,8 +290,9 @@
_other_regions.add_reference(from, tid);
}
- // Removes any entries shown by the given bitmaps to contain only dead
- // objects.
+ // Removes any entries in the remembered set shown by the given bitmaps to
+ // contain only dead objects. Not thread safe.
+ // One bits in the bitmaps indicate that the given region or card is live.
void scrub(CardTableModRefBS* ctbs, BitMap* region_bm, BitMap* card_bm);
// The region is being reclaimed; clear its remset, and any mention of
@@ -397,16 +383,16 @@
// Declare the heap size (in # of regions) to the HeapRegionRemSet(s).
// (Uses it to initialize from_card_cache).
static void init_heap(uint max_regions) {
- OtherRegionsTable::initialize(max_regions);
+ FromCardCache::initialize(num_par_rem_sets(), max_regions);
}
- static void invalidate(uint start_idx, uint num_regions) {
- OtherRegionsTable::invalidate(start_idx, num_regions);
+ static void invalidate_from_card_cache(uint start_idx, size_t num_regions) {
+ FromCardCache::invalidate(start_idx, num_regions);
}
#ifndef PRODUCT
static void print_from_card_cache() {
- OtherRegionsTable::print_from_card_cache();
+ FromCardCache::print();
}
#endif
--- a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -172,6 +172,27 @@
_tenuring_threshold = tenuring_threshold;
}
+bool YoungGCTracer::should_report_promotion_in_new_plab_event() const {
+ return should_send_promotion_in_new_plab_event();
+}
+
+bool YoungGCTracer::should_report_promotion_outside_plab_event() const {
+ return should_send_promotion_outside_plab_event();
+}
+
+void YoungGCTracer::report_promotion_in_new_plab_event(Klass* klass, size_t obj_size,
+ uint age, bool tenured,
+ size_t plab_size) const {
+ assert_set_gc_id();
+ send_promotion_in_new_plab_event(klass, obj_size, age, tenured, plab_size);
+}
+
+void YoungGCTracer::report_promotion_outside_plab_event(Klass* klass, size_t obj_size,
+ uint age, bool tenured) const {
+ assert_set_gc_id();
+ send_promotion_outside_plab_event(klass, obj_size, age, tenured);
+}
+
void OldGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
assert_set_gc_id();
--- a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -156,9 +156,38 @@
void report_promotion_failed(const PromotionFailedInfo& pf_info);
void report_tenuring_threshold(const uint tenuring_threshold);
+ /*
+ * Methods for reporting Promotion in new or outside PLAB Events.
+ *
+ * The object age is always required as it is not certain that the mark word
+ * of the oop can be trusted at this stage.
+ *
+ * obj_size is the size of the promoted object in bytes.
+ *
+ * tenured should be true if the object has been promoted to the old
+ * space during this GC, if the object is copied to survivor space
+ * from young space or survivor space (aging) tenured should be false.
+ *
+ * plab_size is the size of the newly allocated PLAB in bytes.
+ */
+ bool should_report_promotion_in_new_plab_event() const;
+ bool should_report_promotion_outside_plab_event() const;
+ void report_promotion_in_new_plab_event(Klass* klass, size_t obj_size,
+ uint age, bool tenured,
+ size_t plab_size) const;
+ void report_promotion_outside_plab_event(Klass* klass, size_t obj_size,
+ uint age, bool tenured) const;
+
private:
void send_young_gc_event() const;
void send_promotion_failed_event(const PromotionFailedInfo& pf_info) const;
+ bool should_send_promotion_in_new_plab_event() const;
+ bool should_send_promotion_outside_plab_event() const;
+ void send_promotion_in_new_plab_event(Klass* klass, size_t obj_size,
+ uint age, bool tenured,
+ size_t plab_size) const;
+ void send_promotion_outside_plab_event(Klass* klass, size_t obj_size,
+ uint age, bool tenured) const;
};
class OldGCTracer : public GCTracer {
--- a/hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -111,6 +111,44 @@
}
}
+bool YoungGCTracer::should_send_promotion_in_new_plab_event() const {
+ return EventPromoteObjectInNewPLAB::is_enabled();
+}
+
+bool YoungGCTracer::should_send_promotion_outside_plab_event() const {
+ return EventPromoteObjectOutsidePLAB::is_enabled();
+}
+
+void YoungGCTracer::send_promotion_in_new_plab_event(Klass* klass, size_t obj_size,
+ uint age, bool tenured,
+ size_t plab_size) const {
+
+ EventPromoteObjectInNewPLAB event;
+ if (event.should_commit()) {
+ event.set_gcId(_shared_gc_info.gc_id().id());
+ event.set_class(klass);
+ event.set_objectSize(obj_size);
+ event.set_tenured(tenured);
+ event.set_tenuringAge(age);
+ event.set_plabSize(plab_size);
+ event.commit();
+ }
+}
+
+void YoungGCTracer::send_promotion_outside_plab_event(Klass* klass, size_t obj_size,
+ uint age, bool tenured) const {
+
+ EventPromoteObjectOutsidePLAB event;
+ if (event.should_commit()) {
+ event.set_gcId(_shared_gc_info.gc_id().id());
+ event.set_class(klass);
+ event.set_objectSize(obj_size);
+ event.set_tenured(tenured);
+ event.set_tenuringAge(age);
+ event.commit();
+ }
+}
+
void OldGCTracer::send_old_gc_event() const {
EventGCOldGarbageCollection e(UNTIMED);
if (e.should_commit()) {
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -385,6 +385,18 @@
int handler_bci;
int current_bci = bci(thread);
+ if (thread->frames_to_pop_failed_realloc() > 0) {
+ // Allocation of scalar replaced object used in this frame
+ // failed. Unconditionally pop the frame.
+ thread->dec_frames_to_pop_failed_realloc();
+ thread->set_vm_result(h_exception());
+ // If the method is synchronized we already unlocked the monitor
+ // during deoptimization so the interpreter needs to skip it when
+ // the frame is popped.
+ thread->set_do_not_unlock_if_synchronized(true);
+ return Interpreter::remove_activation_entry();
+ }
+
// Need to do this check first since when _do_not_unlock_if_synchronized
// is set, we don't want to trigger any classloading which may make calls
// into java, or surprisingly find a matching exception handler for bci 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/memory/cardGeneration.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,360 @@
+/*
+ * 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 "memory/blockOffsetTable.inline.hpp"
+#include "memory/cardGeneration.inline.hpp"
+#include "memory/gcLocker.hpp"
+#include "memory/generationSpec.hpp"
+#include "memory/genOopClosures.inline.hpp"
+#include "memory/genRemSet.hpp"
+#include "memory/iterator.hpp"
+#include "memory/memRegion.hpp"
+#include "memory/space.inline.hpp"
+#include "runtime/java.hpp"
+
+CardGeneration::CardGeneration(ReservedSpace rs, size_t initial_byte_size,
+ int level,
+ GenRemSet* remset) :
+ Generation(rs, initial_byte_size, level), _rs(remset),
+ _shrink_factor(0), _min_heap_delta_bytes(), _capacity_at_prologue(),
+ _used_at_prologue()
+{
+ HeapWord* start = (HeapWord*)rs.base();
+ size_t reserved_byte_size = rs.size();
+ assert((uintptr_t(start) & 3) == 0, "bad alignment");
+ assert((reserved_byte_size & 3) == 0, "bad alignment");
+ MemRegion reserved_mr(start, heap_word_size(reserved_byte_size));
+ _bts = new BlockOffsetSharedArray(reserved_mr,
+ heap_word_size(initial_byte_size));
+ MemRegion committed_mr(start, heap_word_size(initial_byte_size));
+ _rs->resize_covered_region(committed_mr);
+ if (_bts == NULL) {
+ vm_exit_during_initialization("Could not allocate a BlockOffsetArray");
+ }
+
+ // Verify that the start and end of this generation is the start of a card.
+ // If this wasn't true, a single card could span more than on generation,
+ // which would cause problems when we commit/uncommit memory, and when we
+ // clear and dirty cards.
+ guarantee(_rs->is_aligned(reserved_mr.start()), "generation must be card aligned");
+ if (reserved_mr.end() != Universe::heap()->reserved_region().end()) {
+ // Don't check at the very end of the heap as we'll assert that we're probing off
+ // the end if we try.
+ guarantee(_rs->is_aligned(reserved_mr.end()), "generation must be card aligned");
+ }
+ _min_heap_delta_bytes = MinHeapDeltaBytes;
+ _capacity_at_prologue = initial_byte_size;
+ _used_at_prologue = 0;
+}
+
+bool CardGeneration::grow_by(size_t bytes) {
+ assert_correct_size_change_locking();
+ bool result = _virtual_space.expand_by(bytes);
+ if (result) {
+ size_t new_word_size =
+ heap_word_size(_virtual_space.committed_size());
+ MemRegion mr(space()->bottom(), new_word_size);
+ // Expand card table
+ Universe::heap()->barrier_set()->resize_covered_region(mr);
+ // Expand shared block offset array
+ _bts->resize(new_word_size);
+
+ // Fix for bug #4668531
+ if (ZapUnusedHeapArea) {
+ MemRegion mangle_region(space()->end(),
+ (HeapWord*)_virtual_space.high());
+ SpaceMangler::mangle_region(mangle_region);
+ }
+
+ // Expand space -- also expands space's BOT
+ // (which uses (part of) shared array above)
+ space()->set_end((HeapWord*)_virtual_space.high());
+
+ // update the space and generation capacity counters
+ update_counters();
+
+ if (Verbose && PrintGC) {
+ size_t new_mem_size = _virtual_space.committed_size();
+ size_t old_mem_size = new_mem_size - bytes;
+ gclog_or_tty->print_cr("Expanding %s from " SIZE_FORMAT "K by "
+ SIZE_FORMAT "K to " SIZE_FORMAT "K",
+ name(), old_mem_size/K, bytes/K, new_mem_size/K);
+ }
+ }
+ return result;
+}
+
+bool CardGeneration::expand(size_t bytes, size_t expand_bytes) {
+ assert_locked_or_safepoint(Heap_lock);
+ if (bytes == 0) {
+ return true; // That's what grow_by(0) would return
+ }
+ size_t aligned_bytes = ReservedSpace::page_align_size_up(bytes);
+ if (aligned_bytes == 0){
+ // The alignment caused the number of bytes to wrap. An expand_by(0) will
+ // return true with the implication that an expansion was done when it
+ // was not. A call to expand implies a best effort to expand by "bytes"
+ // but not a guarantee. Align down to give a best effort. This is likely
+ // the most that the generation can expand since it has some capacity to
+ // start with.
+ aligned_bytes = ReservedSpace::page_align_size_down(bytes);
+ }
+ size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
+ bool success = false;
+ if (aligned_expand_bytes > aligned_bytes) {
+ success = grow_by(aligned_expand_bytes);
+ }
+ if (!success) {
+ success = grow_by(aligned_bytes);
+ }
+ if (!success) {
+ success = grow_to_reserved();
+ }
+ if (PrintGC && Verbose) {
+ if (success && GC_locker::is_active_and_needs_gc()) {
+ gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead");
+ }
+ }
+
+ return success;
+}
+
+bool CardGeneration::grow_to_reserved() {
+ assert_correct_size_change_locking();
+ bool success = true;
+ const size_t remaining_bytes = _virtual_space.uncommitted_size();
+ if (remaining_bytes > 0) {
+ success = grow_by(remaining_bytes);
+ DEBUG_ONLY(if (!success) warning("grow to reserved failed");)
+ }
+ return success;
+}
+
+void CardGeneration::shrink(size_t bytes) {
+ assert_correct_size_change_locking();
+
+ size_t size = ReservedSpace::page_align_size_down(bytes);
+ if (size == 0) {
+ return;
+ }
+
+ // Shrink committed space
+ _virtual_space.shrink_by(size);
+ // Shrink space; this also shrinks the space's BOT
+ space()->set_end((HeapWord*) _virtual_space.high());
+ size_t new_word_size = heap_word_size(space()->capacity());
+ // Shrink the shared block offset array
+ _bts->resize(new_word_size);
+ MemRegion mr(space()->bottom(), new_word_size);
+ // Shrink the card table
+ Universe::heap()->barrier_set()->resize_covered_region(mr);
+
+ if (Verbose && PrintGC) {
+ size_t new_mem_size = _virtual_space.committed_size();
+ size_t old_mem_size = new_mem_size + size;
+ gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
+ name(), old_mem_size/K, new_mem_size/K);
+ }
+}
+
+// No young generation references, clear this generation's cards.
+void CardGeneration::clear_remembered_set() {
+ _rs->clear(reserved());
+}
+
+// Objects in this generation may have moved, invalidate this
+// generation's cards.
+void CardGeneration::invalidate_remembered_set() {
+ _rs->invalidate(used_region());
+}
+
+void CardGeneration::compute_new_size() {
+ assert(_shrink_factor <= 100, "invalid shrink factor");
+ size_t current_shrink_factor = _shrink_factor;
+ _shrink_factor = 0;
+
+ // We don't have floating point command-line arguments
+ // Note: argument processing ensures that MinHeapFreeRatio < 100.
+ const double minimum_free_percentage = MinHeapFreeRatio / 100.0;
+ const double maximum_used_percentage = 1.0 - minimum_free_percentage;
+
+ // Compute some numbers about the state of the heap.
+ const size_t used_after_gc = used();
+ const size_t capacity_after_gc = capacity();
+
+ const double min_tmp = used_after_gc / maximum_used_percentage;
+ size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx));
+ // Don't shrink less than the initial generation size
+ minimum_desired_capacity = MAX2(minimum_desired_capacity,
+ spec()->init_size());
+ assert(used_after_gc <= minimum_desired_capacity, "sanity check");
+
+ if (PrintGC && Verbose) {
+ const size_t free_after_gc = free();
+ const double free_percentage = ((double)free_after_gc) / capacity_after_gc;
+ gclog_or_tty->print_cr("TenuredGeneration::compute_new_size: ");
+ gclog_or_tty->print_cr(" "
+ " minimum_free_percentage: %6.2f"
+ " maximum_used_percentage: %6.2f",
+ minimum_free_percentage,
+ maximum_used_percentage);
+ gclog_or_tty->print_cr(" "
+ " free_after_gc : %6.1fK"
+ " used_after_gc : %6.1fK"
+ " capacity_after_gc : %6.1fK",
+ free_after_gc / (double) K,
+ used_after_gc / (double) K,
+ capacity_after_gc / (double) K);
+ gclog_or_tty->print_cr(" "
+ " free_percentage: %6.2f",
+ free_percentage);
+ }
+
+ if (capacity_after_gc < minimum_desired_capacity) {
+ // If we have less free space than we want then expand
+ size_t expand_bytes = minimum_desired_capacity - capacity_after_gc;
+ // Don't expand unless it's significant
+ if (expand_bytes >= _min_heap_delta_bytes) {
+ expand(expand_bytes, 0); // safe if expansion fails
+ }
+ if (PrintGC && Verbose) {
+ gclog_or_tty->print_cr(" expanding:"
+ " minimum_desired_capacity: %6.1fK"
+ " expand_bytes: %6.1fK"
+ " _min_heap_delta_bytes: %6.1fK",
+ minimum_desired_capacity / (double) K,
+ expand_bytes / (double) K,
+ _min_heap_delta_bytes / (double) K);
+ }
+ return;
+ }
+
+ // No expansion, now see if we want to shrink
+ size_t shrink_bytes = 0;
+ // We would never want to shrink more than this
+ size_t max_shrink_bytes = capacity_after_gc - minimum_desired_capacity;
+
+ if (MaxHeapFreeRatio < 100) {
+ const double maximum_free_percentage = MaxHeapFreeRatio / 100.0;
+ const double minimum_used_percentage = 1.0 - maximum_free_percentage;
+ const double max_tmp = used_after_gc / minimum_used_percentage;
+ size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
+ maximum_desired_capacity = MAX2(maximum_desired_capacity,
+ spec()->init_size());
+ if (PrintGC && Verbose) {
+ gclog_or_tty->print_cr(" "
+ " maximum_free_percentage: %6.2f"
+ " minimum_used_percentage: %6.2f",
+ maximum_free_percentage,
+ minimum_used_percentage);
+ gclog_or_tty->print_cr(" "
+ " _capacity_at_prologue: %6.1fK"
+ " minimum_desired_capacity: %6.1fK"
+ " maximum_desired_capacity: %6.1fK",
+ _capacity_at_prologue / (double) K,
+ minimum_desired_capacity / (double) K,
+ maximum_desired_capacity / (double) K);
+ }
+ assert(minimum_desired_capacity <= maximum_desired_capacity,
+ "sanity check");
+
+ if (capacity_after_gc > maximum_desired_capacity) {
+ // Capacity too large, compute shrinking size
+ shrink_bytes = capacity_after_gc - maximum_desired_capacity;
+ // We don't want shrink all the way back to initSize if people call
+ // System.gc(), because some programs do that between "phases" and then
+ // we'd just have to grow the heap up again for the next phase. So we
+ // damp the shrinking: 0% on the first call, 10% on the second call, 40%
+ // on the third call, and 100% by the fourth call. But if we recompute
+ // size without shrinking, it goes back to 0%.
+ shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
+ assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
+ if (current_shrink_factor == 0) {
+ _shrink_factor = 10;
+ } else {
+ _shrink_factor = MIN2(current_shrink_factor * 4, (size_t) 100);
+ }
+ if (PrintGC && Verbose) {
+ gclog_or_tty->print_cr(" "
+ " shrinking:"
+ " initSize: %.1fK"
+ " maximum_desired_capacity: %.1fK",
+ spec()->init_size() / (double) K,
+ maximum_desired_capacity / (double) K);
+ gclog_or_tty->print_cr(" "
+ " shrink_bytes: %.1fK"
+ " current_shrink_factor: " SIZE_FORMAT
+ " new shrink factor: " SIZE_FORMAT
+ " _min_heap_delta_bytes: %.1fK",
+ shrink_bytes / (double) K,
+ current_shrink_factor,
+ _shrink_factor,
+ _min_heap_delta_bytes / (double) K);
+ }
+ }
+ }
+
+ if (capacity_after_gc > _capacity_at_prologue) {
+ // We might have expanded for promotions, in which case we might want to
+ // take back that expansion if there's room after GC. That keeps us from
+ // stretching the heap with promotions when there's plenty of room.
+ size_t expansion_for_promotion = capacity_after_gc - _capacity_at_prologue;
+ expansion_for_promotion = MIN2(expansion_for_promotion, max_shrink_bytes);
+ // We have two shrinking computations, take the largest
+ shrink_bytes = MAX2(shrink_bytes, expansion_for_promotion);
+ assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
+ if (PrintGC && Verbose) {
+ gclog_or_tty->print_cr(" "
+ " aggressive shrinking:"
+ " _capacity_at_prologue: %.1fK"
+ " capacity_after_gc: %.1fK"
+ " expansion_for_promotion: %.1fK"
+ " shrink_bytes: %.1fK",
+ capacity_after_gc / (double) K,
+ _capacity_at_prologue / (double) K,
+ expansion_for_promotion / (double) K,
+ shrink_bytes / (double) K);
+ }
+ }
+ // Don't shrink unless it's significant
+ if (shrink_bytes >= _min_heap_delta_bytes) {
+ shrink(shrink_bytes);
+ }
+}
+
+// Currently nothing to do.
+void CardGeneration::prepare_for_verify() {}
+
+void CardGeneration::space_iterate(SpaceClosure* blk,
+ bool usedOnly) {
+ blk->do_space(space());
+}
+
+void CardGeneration::younger_refs_iterate(OopsInGenClosure* blk) {
+ blk->set_generation(this);
+ younger_refs_in_space_iterate(space(), blk);
+ blk->reset_generation();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/memory/cardGeneration.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,99 @@
+/*
+ * 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_MEMORY_CARDGENERATION_HPP
+#define SHARE_VM_MEMORY_CARDGENERATION_HPP
+
+// Class CardGeneration is a generation that is covered by a card table,
+// and uses a card-size block-offset array to implement block_start.
+
+#include "memory/generation.hpp"
+
+class BlockOffsetSharedArray;
+class CompactibleSpace;
+
+class CardGeneration: public Generation {
+ friend class VMStructs;
+ protected:
+ // This is shared with other generations.
+ GenRemSet* _rs;
+ // This is local to this generation.
+ BlockOffsetSharedArray* _bts;
+
+ // Current shrinking effect: this damps shrinking when the heap gets empty.
+ size_t _shrink_factor;
+
+ size_t _min_heap_delta_bytes; // Minimum amount to expand.
+
+ // Some statistics from before gc started.
+ // These are gathered in the gc_prologue (and should_collect)
+ // to control growing/shrinking policy in spite of promotions.
+ size_t _capacity_at_prologue;
+ size_t _used_at_prologue;
+
+ CardGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
+ GenRemSet* remset);
+
+ virtual void assert_correct_size_change_locking() = 0;
+
+ virtual CompactibleSpace* space() const = 0;
+
+ public:
+
+ // Attempt to expand the generation by "bytes". Expand by at a
+ // minimum "expand_bytes". Return true if some amount (not
+ // necessarily the full "bytes") was done.
+ virtual bool expand(size_t bytes, size_t expand_bytes);
+
+ // Shrink generation with specified size
+ virtual void shrink(size_t bytes);
+
+ virtual void compute_new_size();
+
+ virtual void clear_remembered_set();
+
+ virtual void invalidate_remembered_set();
+
+ virtual void prepare_for_verify();
+
+ // Grow generation with specified size (returns false if unable to grow)
+ bool grow_by(size_t bytes);
+ // Grow generation to reserved size.
+ bool grow_to_reserved();
+
+ size_t capacity() const;
+ size_t used() const;
+ size_t free() const;
+ MemRegion used_region() const;
+
+ void space_iterate(SpaceClosure* blk, bool usedOnly = false);
+
+ void younger_refs_iterate(OopsInGenClosure* blk);
+
+ bool is_in(const void* p) const;
+
+ CompactibleSpace* first_compaction_space() const;
+};
+
+#endif // SHARE_VM_MEMORY_CARDGENERATION_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/memory/cardGeneration.inline.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,55 @@
+/*
+ * 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_MEMORY_CARDGENERATION_INLINE_HPP
+#define SHARE_VM_MEMORY_CARDGENERATION_INLINE_HPP
+
+#include "memory/cardGeneration.hpp"
+#include "memory/space.hpp"
+
+inline size_t CardGeneration::capacity() const {
+ return space()->capacity();
+}
+
+inline size_t CardGeneration::used() const {
+ return space()->used();
+}
+
+inline size_t CardGeneration::free() const {
+ return space()->free();
+}
+
+inline MemRegion CardGeneration::used_region() const {
+ return space()->used_region();
+}
+
+inline bool CardGeneration::is_in(const void* p) const {
+ return space()->is_in(p);
+}
+
+inline CompactibleSpace* CardGeneration::first_compaction_space() const {
+ return space();
+}
+
+#endif // SHARE_VM_MEMORY_CARDGENERATION_INLINE_HPP
--- a/hotspot/src/share/vm/memory/cardTableModRefBS.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/cardTableModRefBS.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -275,29 +275,26 @@
// the new_end_aligned does not intrude onto the committed
// space of another region.
int ri = 0;
- for (ri = 0; ri < _cur_covered_regions; ri++) {
- if (ri != ind) {
- if (_committed[ri].contains(new_end_aligned)) {
- // The prior check included in the assert
- // (new_end_aligned >= _committed[ri].start())
- // is redundant with the "contains" test.
- // Any region containing the new end
- // should start at or beyond the region found (ind)
- // for the new end (committed regions are not expected to
- // be proper subsets of other committed regions).
- assert(_committed[ri].start() >= _committed[ind].start(),
- "New end of committed region is inconsistent");
- new_end_aligned = _committed[ri].start();
- // new_end_aligned can be equal to the start of its
- // committed region (i.e., of "ind") if a second
- // region following "ind" also start at the same location
- // as "ind".
- assert(new_end_aligned >= _committed[ind].start(),
- "New end of committed region is before start");
- debug_only(collided = true;)
- // Should only collide with 1 region
- break;
- }
+ for (ri = ind + 1; ri < _cur_covered_regions; ri++) {
+ if (new_end_aligned > _committed[ri].start()) {
+ assert(new_end_aligned <= _committed[ri].end(),
+ "An earlier committed region can't cover a later committed region");
+ // Any region containing the new end
+ // should start at or beyond the region found (ind)
+ // for the new end (committed regions are not expected to
+ // be proper subsets of other committed regions).
+ assert(_committed[ri].start() >= _committed[ind].start(),
+ "New end of committed region is inconsistent");
+ new_end_aligned = _committed[ri].start();
+ // new_end_aligned can be equal to the start of its
+ // committed region (i.e., of "ind") if a second
+ // region following "ind" also start at the same location
+ // as "ind".
+ assert(new_end_aligned >= _committed[ind].start(),
+ "New end of committed region is before start");
+ debug_only(collided = true;)
+ // Should only collide with 1 region
+ break;
}
}
#ifdef ASSERT
--- a/hotspot/src/share/vm/memory/filemap.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/filemap.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -98,11 +98,11 @@
tty->print_cr("UseSharedSpaces: %s", msg);
}
}
+ UseSharedSpaces = false;
+ assert(current_info() != NULL, "singleton must be registered");
+ current_info()->close();
}
va_end(ap);
- UseSharedSpaces = false;
- assert(current_info() != NULL, "singleton must be registered");
- current_info()->close();
}
// Fill in the fileMapInfo structure with data about this VM instance.
--- a/hotspot/src/share/vm/memory/generation.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/generation.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -361,244 +361,3 @@
sp = sp->next_compaction_space();
}
}
-
-CardGeneration::CardGeneration(ReservedSpace rs, size_t initial_byte_size,
- int level,
- GenRemSet* remset) :
- Generation(rs, initial_byte_size, level), _rs(remset),
- _shrink_factor(0), _min_heap_delta_bytes(), _capacity_at_prologue(),
- _used_at_prologue()
-{
- HeapWord* start = (HeapWord*)rs.base();
- size_t reserved_byte_size = rs.size();
- assert((uintptr_t(start) & 3) == 0, "bad alignment");
- assert((reserved_byte_size & 3) == 0, "bad alignment");
- MemRegion reserved_mr(start, heap_word_size(reserved_byte_size));
- _bts = new BlockOffsetSharedArray(reserved_mr,
- heap_word_size(initial_byte_size));
- MemRegion committed_mr(start, heap_word_size(initial_byte_size));
- _rs->resize_covered_region(committed_mr);
- if (_bts == NULL)
- vm_exit_during_initialization("Could not allocate a BlockOffsetArray");
-
- // Verify that the start and end of this generation is the start of a card.
- // If this wasn't true, a single card could span more than on generation,
- // which would cause problems when we commit/uncommit memory, and when we
- // clear and dirty cards.
- guarantee(_rs->is_aligned(reserved_mr.start()), "generation must be card aligned");
- if (reserved_mr.end() != Universe::heap()->reserved_region().end()) {
- // Don't check at the very end of the heap as we'll assert that we're probing off
- // the end if we try.
- guarantee(_rs->is_aligned(reserved_mr.end()), "generation must be card aligned");
- }
- _min_heap_delta_bytes = MinHeapDeltaBytes;
- _capacity_at_prologue = initial_byte_size;
- _used_at_prologue = 0;
-}
-
-bool CardGeneration::expand(size_t bytes, size_t expand_bytes) {
- assert_locked_or_safepoint(Heap_lock);
- if (bytes == 0) {
- return true; // That's what grow_by(0) would return
- }
- size_t aligned_bytes = ReservedSpace::page_align_size_up(bytes);
- if (aligned_bytes == 0){
- // The alignment caused the number of bytes to wrap. An expand_by(0) will
- // return true with the implication that an expansion was done when it
- // was not. A call to expand implies a best effort to expand by "bytes"
- // but not a guarantee. Align down to give a best effort. This is likely
- // the most that the generation can expand since it has some capacity to
- // start with.
- aligned_bytes = ReservedSpace::page_align_size_down(bytes);
- }
- size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
- bool success = false;
- if (aligned_expand_bytes > aligned_bytes) {
- success = grow_by(aligned_expand_bytes);
- }
- if (!success) {
- success = grow_by(aligned_bytes);
- }
- if (!success) {
- success = grow_to_reserved();
- }
- if (PrintGC && Verbose) {
- if (success && GC_locker::is_active_and_needs_gc()) {
- gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead");
- }
- }
-
- return success;
-}
-
-
-// No young generation references, clear this generation's cards.
-void CardGeneration::clear_remembered_set() {
- _rs->clear(reserved());
-}
-
-
-// Objects in this generation may have moved, invalidate this
-// generation's cards.
-void CardGeneration::invalidate_remembered_set() {
- _rs->invalidate(used_region());
-}
-
-
-void CardGeneration::compute_new_size() {
- assert(_shrink_factor <= 100, "invalid shrink factor");
- size_t current_shrink_factor = _shrink_factor;
- _shrink_factor = 0;
-
- // We don't have floating point command-line arguments
- // Note: argument processing ensures that MinHeapFreeRatio < 100.
- const double minimum_free_percentage = MinHeapFreeRatio / 100.0;
- const double maximum_used_percentage = 1.0 - minimum_free_percentage;
-
- // Compute some numbers about the state of the heap.
- const size_t used_after_gc = used();
- const size_t capacity_after_gc = capacity();
-
- const double min_tmp = used_after_gc / maximum_used_percentage;
- size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx));
- // Don't shrink less than the initial generation size
- minimum_desired_capacity = MAX2(minimum_desired_capacity,
- spec()->init_size());
- assert(used_after_gc <= minimum_desired_capacity, "sanity check");
-
- if (PrintGC && Verbose) {
- const size_t free_after_gc = free();
- const double free_percentage = ((double)free_after_gc) / capacity_after_gc;
- gclog_or_tty->print_cr("TenuredGeneration::compute_new_size: ");
- gclog_or_tty->print_cr(" "
- " minimum_free_percentage: %6.2f"
- " maximum_used_percentage: %6.2f",
- minimum_free_percentage,
- maximum_used_percentage);
- gclog_or_tty->print_cr(" "
- " free_after_gc : %6.1fK"
- " used_after_gc : %6.1fK"
- " capacity_after_gc : %6.1fK",
- free_after_gc / (double) K,
- used_after_gc / (double) K,
- capacity_after_gc / (double) K);
- gclog_or_tty->print_cr(" "
- " free_percentage: %6.2f",
- free_percentage);
- }
-
- if (capacity_after_gc < minimum_desired_capacity) {
- // If we have less free space than we want then expand
- size_t expand_bytes = minimum_desired_capacity - capacity_after_gc;
- // Don't expand unless it's significant
- if (expand_bytes >= _min_heap_delta_bytes) {
- expand(expand_bytes, 0); // safe if expansion fails
- }
- if (PrintGC && Verbose) {
- gclog_or_tty->print_cr(" expanding:"
- " minimum_desired_capacity: %6.1fK"
- " expand_bytes: %6.1fK"
- " _min_heap_delta_bytes: %6.1fK",
- minimum_desired_capacity / (double) K,
- expand_bytes / (double) K,
- _min_heap_delta_bytes / (double) K);
- }
- return;
- }
-
- // No expansion, now see if we want to shrink
- size_t shrink_bytes = 0;
- // We would never want to shrink more than this
- size_t max_shrink_bytes = capacity_after_gc - minimum_desired_capacity;
-
- if (MaxHeapFreeRatio < 100) {
- const double maximum_free_percentage = MaxHeapFreeRatio / 100.0;
- const double minimum_used_percentage = 1.0 - maximum_free_percentage;
- const double max_tmp = used_after_gc / minimum_used_percentage;
- size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
- maximum_desired_capacity = MAX2(maximum_desired_capacity,
- spec()->init_size());
- if (PrintGC && Verbose) {
- gclog_or_tty->print_cr(" "
- " maximum_free_percentage: %6.2f"
- " minimum_used_percentage: %6.2f",
- maximum_free_percentage,
- minimum_used_percentage);
- gclog_or_tty->print_cr(" "
- " _capacity_at_prologue: %6.1fK"
- " minimum_desired_capacity: %6.1fK"
- " maximum_desired_capacity: %6.1fK",
- _capacity_at_prologue / (double) K,
- minimum_desired_capacity / (double) K,
- maximum_desired_capacity / (double) K);
- }
- assert(minimum_desired_capacity <= maximum_desired_capacity,
- "sanity check");
-
- if (capacity_after_gc > maximum_desired_capacity) {
- // Capacity too large, compute shrinking size
- shrink_bytes = capacity_after_gc - maximum_desired_capacity;
- // We don't want shrink all the way back to initSize if people call
- // System.gc(), because some programs do that between "phases" and then
- // we'd just have to grow the heap up again for the next phase. So we
- // damp the shrinking: 0% on the first call, 10% on the second call, 40%
- // on the third call, and 100% by the fourth call. But if we recompute
- // size without shrinking, it goes back to 0%.
- shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
- assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
- if (current_shrink_factor == 0) {
- _shrink_factor = 10;
- } else {
- _shrink_factor = MIN2(current_shrink_factor * 4, (size_t) 100);
- }
- if (PrintGC && Verbose) {
- gclog_or_tty->print_cr(" "
- " shrinking:"
- " initSize: %.1fK"
- " maximum_desired_capacity: %.1fK",
- spec()->init_size() / (double) K,
- maximum_desired_capacity / (double) K);
- gclog_or_tty->print_cr(" "
- " shrink_bytes: %.1fK"
- " current_shrink_factor: " SIZE_FORMAT
- " new shrink factor: " SIZE_FORMAT
- " _min_heap_delta_bytes: %.1fK",
- shrink_bytes / (double) K,
- current_shrink_factor,
- _shrink_factor,
- _min_heap_delta_bytes / (double) K);
- }
- }
- }
-
- if (capacity_after_gc > _capacity_at_prologue) {
- // We might have expanded for promotions, in which case we might want to
- // take back that expansion if there's room after GC. That keeps us from
- // stretching the heap with promotions when there's plenty of room.
- size_t expansion_for_promotion = capacity_after_gc - _capacity_at_prologue;
- expansion_for_promotion = MIN2(expansion_for_promotion, max_shrink_bytes);
- // We have two shrinking computations, take the largest
- shrink_bytes = MAX2(shrink_bytes, expansion_for_promotion);
- assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
- if (PrintGC && Verbose) {
- gclog_or_tty->print_cr(" "
- " aggressive shrinking:"
- " _capacity_at_prologue: %.1fK"
- " capacity_after_gc: %.1fK"
- " expansion_for_promotion: %.1fK"
- " shrink_bytes: %.1fK",
- capacity_after_gc / (double) K,
- _capacity_at_prologue / (double) K,
- expansion_for_promotion / (double) K,
- shrink_bytes / (double) K);
- }
- }
- // Don't shrink unless it's significant
- if (shrink_bytes >= _min_heap_delta_bytes) {
- shrink(shrink_bytes);
- }
-}
-
-// Currently nothing to do.
-void CardGeneration::prepare_for_verify() {}
-
--- a/hotspot/src/share/vm/memory/generation.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/generation.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -584,57 +584,4 @@
virtual CollectorCounters* counters() { return _gc_counters; }
};
-// Class CardGeneration is a generation that is covered by a card table,
-// and uses a card-size block-offset array to implement block_start.
-
-// class BlockOffsetArray;
-// class BlockOffsetArrayContigSpace;
-class BlockOffsetSharedArray;
-
-class CardGeneration: public Generation {
- friend class VMStructs;
- protected:
- // This is shared with other generations.
- GenRemSet* _rs;
- // This is local to this generation.
- BlockOffsetSharedArray* _bts;
-
- // current shrinking effect: this damps shrinking when the heap gets empty.
- size_t _shrink_factor;
-
- size_t _min_heap_delta_bytes; // Minimum amount to expand.
-
- // Some statistics from before gc started.
- // These are gathered in the gc_prologue (and should_collect)
- // to control growing/shrinking policy in spite of promotions.
- size_t _capacity_at_prologue;
- size_t _used_at_prologue;
-
- CardGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
- GenRemSet* remset);
-
- public:
-
- // Attempt to expand the generation by "bytes". Expand by at a
- // minimum "expand_bytes". Return true if some amount (not
- // necessarily the full "bytes") was done.
- virtual bool expand(size_t bytes, size_t expand_bytes);
-
- // Shrink generation with specified size (returns false if unable to shrink)
- virtual void shrink(size_t bytes) = 0;
-
- virtual void compute_new_size();
-
- virtual void clear_remembered_set();
-
- virtual void invalidate_remembered_set();
-
- virtual void prepare_for_verify();
-
- // Grow generation with specified size (returns false if unable to grow)
- virtual bool grow_by(size_t bytes) = 0;
- // Grow generation to reserved size.
- virtual bool grow_to_reserved() = 0;
-};
-
#endif // SHARE_VM_MEMORY_GENERATION_HPP
--- a/hotspot/src/share/vm/memory/metaspace.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/metaspace.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -3158,7 +3158,25 @@
SharedMiscDataSize = align_size_up(SharedMiscDataSize, max_alignment);
SharedMiscCodeSize = align_size_up(SharedMiscCodeSize, max_alignment);
- // the min_misc_code_size estimate is based on MetaspaceShared::generate_vtable_methods()
+ // make sure SharedReadOnlySize and SharedReadWriteSize are not less than
+ // the minimum values.
+ if (SharedReadOnlySize < MetaspaceShared::min_ro_size){
+ report_out_of_shared_space(SharedReadOnly);
+ }
+
+ if (SharedReadWriteSize < MetaspaceShared::min_rw_size){
+ report_out_of_shared_space(SharedReadWrite);
+ }
+
+ // the min_misc_data_size and min_misc_code_size estimates are based on
+ // MetaspaceShared::generate_vtable_methods()
+ uint min_misc_data_size = align_size_up(
+ MetaspaceShared::num_virtuals * MetaspaceShared::vtbl_list_size * sizeof(void*), max_alignment);
+
+ if (SharedMiscDataSize < min_misc_data_size) {
+ report_out_of_shared_space(SharedMiscData);
+ }
+
uintx min_misc_code_size = align_size_up(
(MetaspaceShared::num_virtuals * MetaspaceShared::vtbl_list_size) *
(sizeof(void*) + MetaspaceShared::vtbl_method_size) + MetaspaceShared::vtbl_common_code_size,
--- a/hotspot/src/share/vm/memory/metaspaceShared.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -969,7 +969,7 @@
#endif
// If -Xshare:on is specified, print out the error message and exit VM,
// otherwise, set UseSharedSpaces to false and continue.
- if (RequireSharedSpaces) {
+ if (RequireSharedSpaces || PrintSharedArchiveAndExit) {
vm_exit_during_initialization("Unable to use shared archive.", "Failed map_region for using -Xshare:on.");
} else {
FLAG_SET_DEFAULT(UseSharedSpaces, false);
--- a/hotspot/src/share/vm/memory/metaspaceShared.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/metaspaceShared.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -70,6 +70,11 @@
};
enum {
+ min_ro_size = NOT_LP64(8*M) LP64_ONLY(9*M), // minimum ro and rw regions sizes based on dumping
+ min_rw_size = NOT_LP64(7*M) LP64_ONLY(12*M) // of a shared archive using the default classlist
+ };
+
+ enum {
ro = 0, // read-only shared space in the heap
rw = 1, // read-write shared space in the heap
md = 2, // miscellaneous data for initializing tables, etc.
--- a/hotspot/src/share/vm/memory/tenuredGeneration.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/tenuredGeneration.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -235,34 +235,6 @@
return CardGeneration::expand(bytes, expand_bytes);
}
-
-void TenuredGeneration::shrink(size_t bytes) {
- assert_locked_or_safepoint(ExpandHeap_lock);
- size_t size = ReservedSpace::page_align_size_down(bytes);
- if (size > 0) {
- shrink_by(size);
- }
-}
-
-
-size_t TenuredGeneration::capacity() const {
- return _the_space->capacity();
-}
-
-
-size_t TenuredGeneration::used() const {
- return _the_space->used();
-}
-
-
-size_t TenuredGeneration::free() const {
- return _the_space->free();
-}
-
-MemRegion TenuredGeneration::used_region() const {
- return the_space()->used_region();
-}
-
size_t TenuredGeneration::unsafe_max_alloc_nogc() const {
return _the_space->free();
}
@@ -271,74 +243,8 @@
return _the_space->free() + _virtual_space.uncommitted_size();
}
-bool TenuredGeneration::grow_by(size_t bytes) {
+void TenuredGeneration::assert_correct_size_change_locking() {
assert_locked_or_safepoint(ExpandHeap_lock);
- bool result = _virtual_space.expand_by(bytes);
- if (result) {
- size_t new_word_size =
- heap_word_size(_virtual_space.committed_size());
- MemRegion mr(_the_space->bottom(), new_word_size);
- // Expand card table
- Universe::heap()->barrier_set()->resize_covered_region(mr);
- // Expand shared block offset array
- _bts->resize(new_word_size);
-
- // Fix for bug #4668531
- if (ZapUnusedHeapArea) {
- MemRegion mangle_region(_the_space->end(),
- (HeapWord*)_virtual_space.high());
- SpaceMangler::mangle_region(mangle_region);
- }
-
- // Expand space -- also expands space's BOT
- // (which uses (part of) shared array above)
- _the_space->set_end((HeapWord*)_virtual_space.high());
-
- // update the space and generation capacity counters
- update_counters();
-
- if (Verbose && PrintGC) {
- size_t new_mem_size = _virtual_space.committed_size();
- size_t old_mem_size = new_mem_size - bytes;
- gclog_or_tty->print_cr("Expanding %s from " SIZE_FORMAT "K by "
- SIZE_FORMAT "K to " SIZE_FORMAT "K",
- name(), old_mem_size/K, bytes/K, new_mem_size/K);
- }
- }
- return result;
-}
-
-
-bool TenuredGeneration::grow_to_reserved() {
- assert_locked_or_safepoint(ExpandHeap_lock);
- bool success = true;
- const size_t remaining_bytes = _virtual_space.uncommitted_size();
- if (remaining_bytes > 0) {
- success = grow_by(remaining_bytes);
- DEBUG_ONLY(if (!success) warning("grow to reserved failed");)
- }
- return success;
-}
-
-void TenuredGeneration::shrink_by(size_t bytes) {
- assert_locked_or_safepoint(ExpandHeap_lock);
- // Shrink committed space
- _virtual_space.shrink_by(bytes);
- // Shrink space; this also shrinks the space's BOT
- _the_space->set_end((HeapWord*) _virtual_space.high());
- size_t new_word_size = heap_word_size(_the_space->capacity());
- // Shrink the shared block offset array
- _bts->resize(new_word_size);
- MemRegion mr(_the_space->bottom(), new_word_size);
- // Shrink the card table
- Universe::heap()->barrier_set()->resize_covered_region(mr);
-
- if (Verbose && PrintGC) {
- size_t new_mem_size = _virtual_space.committed_size();
- size_t old_mem_size = new_mem_size + bytes;
- gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
- name(), old_mem_size/K, new_mem_size/K);
- }
}
// Currently nothing to do.
@@ -348,27 +254,14 @@
_the_space->object_iterate(blk);
}
-void TenuredGeneration::space_iterate(SpaceClosure* blk,
- bool usedOnly) {
- blk->do_space(_the_space);
-}
-
-void TenuredGeneration::younger_refs_iterate(OopsInGenClosure* blk) {
- blk->set_generation(this);
- younger_refs_in_space_iterate(_the_space, blk);
- blk->reset_generation();
-}
-
void TenuredGeneration::save_marks() {
_the_space->set_saved_mark();
}
-
void TenuredGeneration::reset_saved_marks() {
_the_space->reset_saved_mark();
}
-
bool TenuredGeneration::no_allocs_since_save_marks() {
return _the_space->saved_mark_at_top();
}
@@ -387,28 +280,25 @@
#undef TenuredGen_SINCE_SAVE_MARKS_ITERATE_DEFN
-
void TenuredGeneration::gc_epilogue(bool full) {
- _last_gc = WaterMark(the_space(), the_space()->top());
-
// update the generation and space performance counters
update_counters();
if (ZapUnusedHeapArea) {
- the_space()->check_mangled_unused_area_complete();
+ _the_space->check_mangled_unused_area_complete();
}
}
void TenuredGeneration::record_spaces_top() {
assert(ZapUnusedHeapArea, "Not mangling unused space");
- the_space()->set_top_for_allocations();
+ _the_space->set_top_for_allocations();
}
void TenuredGeneration::verify() {
- the_space()->verify();
+ _the_space->verify();
}
void TenuredGeneration::print_on(outputStream* st) const {
Generation::print_on(st);
st->print(" the");
- the_space()->print_on(st);
+ _the_space->print_on(st);
}
--- a/hotspot/src/share/vm/memory/tenuredGeneration.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/tenuredGeneration.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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,7 +28,7 @@
#include "gc_implementation/shared/cSpaceCounters.hpp"
#include "gc_implementation/shared/gcStats.hpp"
#include "gc_implementation/shared/generationCounters.hpp"
-#include "memory/generation.hpp"
+#include "memory/cardGeneration.hpp"
#include "utilities/macros.hpp"
// TenuredGeneration models the heap containing old (promoted/tenured) objects
@@ -42,27 +42,18 @@
friend class VM_PopulateDumpSharedSpace;
protected:
- ContiguousSpace* _the_space; // actual space holding objects
- WaterMark _last_gc; // watermark between objects allocated before
- // and after last GC.
+ ContiguousSpace* _the_space; // Actual space holding objects
GenerationCounters* _gen_counters;
CSpaceCounters* _space_counters;
- // Grow generation with specified size (returns false if unable to grow)
- virtual bool grow_by(size_t bytes);
- // Grow generation to reserved size.
- virtual bool grow_to_reserved();
- // Shrink generation with specified size (returns false if unable to shrink)
- void shrink_by(size_t bytes);
-
// Allocation failure
virtual bool expand(size_t bytes, size_t expand_bytes);
- void shrink(size_t bytes);
// Accessing spaces
- ContiguousSpace* the_space() const { return _the_space; }
+ ContiguousSpace* space() const { return _the_space; }
+ void assert_correct_size_change_locking();
public:
TenuredGeneration(ReservedSpace rs, size_t initial_byte_size,
int level, GenRemSet* remset);
@@ -81,33 +72,15 @@
return !ScavengeBeforeFullGC;
}
- inline bool is_in(const void* p) const;
-
- // Space enquiries
- size_t capacity() const;
- size_t used() const;
- size_t free() const;
-
- MemRegion used_region() const;
-
size_t unsafe_max_alloc_nogc() const;
size_t contiguous_available() const;
// Iteration
void object_iterate(ObjectClosure* blk);
- void space_iterate(SpaceClosure* blk, bool usedOnly = false);
-
- void younger_refs_iterate(OopsInGenClosure* blk);
-
- inline CompactibleSpace* first_compaction_space() const;
virtual inline HeapWord* allocate(size_t word_size, bool is_tlab);
virtual inline HeapWord* par_allocate(size_t word_size, bool is_tlab);
- // Accessing marks
- inline WaterMark top_mark();
- inline WaterMark bottom_mark();
-
#define TenuredGen_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \
void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);
TenuredGen_SINCE_SAVE_MARKS_DECL(OopsInGenClosure,_v)
--- a/hotspot/src/share/vm/memory/tenuredGeneration.inline.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/tenuredGeneration.inline.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -22,53 +22,35 @@
*
*/
-#ifndef SHARE_VM_MEMORY_GENERATION_INLINE_HPP
-#define SHARE_VM_MEMORY_GENERATION_INLINE_HPP
+#ifndef SHARE_VM_MEMORY_TENUREDGENERATION_INLINE_HPP
+#define SHARE_VM_MEMORY_TENUREDGENERATION_INLINE_HPP
-#include "memory/genCollectedHeap.hpp"
#include "memory/space.hpp"
#include "memory/tenuredGeneration.hpp"
-bool TenuredGeneration::is_in(const void* p) const {
- return the_space()->is_in(p);
-}
-
-
-WaterMark TenuredGeneration::top_mark() {
- return the_space()->top_mark();
-}
-
-CompactibleSpace*
-TenuredGeneration::first_compaction_space() const {
- return the_space();
-}
-
HeapWord* TenuredGeneration::allocate(size_t word_size,
bool is_tlab) {
assert(!is_tlab, "TenuredGeneration does not support TLAB allocation");
- return the_space()->allocate(word_size);
+ return _the_space->allocate(word_size);
}
HeapWord* TenuredGeneration::par_allocate(size_t word_size,
bool is_tlab) {
assert(!is_tlab, "TenuredGeneration does not support TLAB allocation");
- return the_space()->par_allocate(word_size);
-}
-
-WaterMark TenuredGeneration::bottom_mark() {
- return the_space()->bottom_mark();
+ return _the_space->par_allocate(word_size);
}
size_t TenuredGeneration::block_size(const HeapWord* addr) const {
- if (addr < the_space()->top()) return oop(addr)->size();
- else {
- assert(addr == the_space()->top(), "non-block head arg to block_size");
- return the_space()->end() - the_space()->top();
+ if (addr < _the_space->top()) {
+ return oop(addr)->size();
+ } else {
+ assert(addr == _the_space->top(), "non-block head arg to block_size");
+ return _the_space->end() - _the_space->top();
}
}
bool TenuredGeneration::block_is_obj(const HeapWord* addr) const {
- return addr < the_space()->top();
+ return addr < _the_space ->top();
}
-#endif // SHARE_VM_MEMORY_GENERATION_INLINE_HPP
+#endif // SHARE_VM_MEMORY_TENUREDGENERATION_INLINE_HPP
--- a/hotspot/src/share/vm/memory/universe.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/universe.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -120,6 +120,7 @@
oop Universe::_out_of_memory_error_class_metaspace = NULL;
oop Universe::_out_of_memory_error_array_size = NULL;
oop Universe::_out_of_memory_error_gc_overhead_limit = NULL;
+oop Universe::_out_of_memory_error_realloc_objects = NULL;
objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
bool Universe::_verify_in_progress = false;
@@ -191,6 +192,7 @@
f->do_oop((oop*)&_out_of_memory_error_class_metaspace);
f->do_oop((oop*)&_out_of_memory_error_array_size);
f->do_oop((oop*)&_out_of_memory_error_gc_overhead_limit);
+ f->do_oop((oop*)&_out_of_memory_error_realloc_objects);
f->do_oop((oop*)&_preallocated_out_of_memory_error_array);
f->do_oop((oop*)&_null_ptr_exception_instance);
f->do_oop((oop*)&_arithmetic_exception_instance);
@@ -575,7 +577,8 @@
(throwable() != Universe::_out_of_memory_error_metaspace) &&
(throwable() != Universe::_out_of_memory_error_class_metaspace) &&
(throwable() != Universe::_out_of_memory_error_array_size) &&
- (throwable() != Universe::_out_of_memory_error_gc_overhead_limit));
+ (throwable() != Universe::_out_of_memory_error_gc_overhead_limit) &&
+ (throwable() != Universe::_out_of_memory_error_realloc_objects));
}
@@ -1039,6 +1042,7 @@
Universe::_out_of_memory_error_array_size = k_h->allocate_instance(CHECK_false);
Universe::_out_of_memory_error_gc_overhead_limit =
k_h->allocate_instance(CHECK_false);
+ Universe::_out_of_memory_error_realloc_objects = k_h->allocate_instance(CHECK_false);
// Setup preallocated NullPointerException
// (this is currently used for a cheap & dirty solution in compiler exception handling)
@@ -1078,6 +1082,9 @@
msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK_false);
java_lang_Throwable::set_message(Universe::_out_of_memory_error_gc_overhead_limit, msg());
+ msg = java_lang_String::create_from_str("Java heap space: failed reallocation of scalar replaced objects", CHECK_false);
+ java_lang_Throwable::set_message(Universe::_out_of_memory_error_realloc_objects, msg());
+
msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
java_lang_Throwable::set_message(Universe::_arithmetic_exception_instance, msg());
--- a/hotspot/src/share/vm/memory/universe.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/memory/universe.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -157,6 +157,7 @@
static oop _out_of_memory_error_class_metaspace;
static oop _out_of_memory_error_array_size;
static oop _out_of_memory_error_gc_overhead_limit;
+ static oop _out_of_memory_error_realloc_objects;
static Array<int>* _the_empty_int_array; // Canonicalized int array
static Array<u2>* _the_empty_short_array; // Canonicalized short array
@@ -328,6 +329,7 @@
static oop out_of_memory_error_class_metaspace() { return gen_out_of_memory_error(_out_of_memory_error_class_metaspace); }
static oop out_of_memory_error_array_size() { return gen_out_of_memory_error(_out_of_memory_error_array_size); }
static oop out_of_memory_error_gc_overhead_limit() { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit); }
+ static oop out_of_memory_error_realloc_objects() { return gen_out_of_memory_error(_out_of_memory_error_realloc_objects); }
// Accessors needed for fast allocation
static Klass** boolArrayKlassObj_addr() { return &_boolArrayKlassObj; }
--- a/hotspot/src/share/vm/oops/cpCache.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/oops/cpCache.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -287,9 +287,13 @@
// the lock, so that when the losing writer returns, he can use the linked
// cache entry.
- // Use the lock from the metaspace for this, which cannot stop for safepoint.
- Mutex* metaspace_lock = cpool->pool_holder()->class_loader_data()->metaspace_lock();
- MutexLockerEx ml(metaspace_lock, Mutex::_no_safepoint_check_flag);
+ objArrayHandle resolved_references = cpool->resolved_references();
+ // Use the resolved_references() lock for this cpCache entry.
+ // resolved_references are created for all classes with Invokedynamic, MethodHandle
+ // or MethodType constant pool cache entries.
+ assert(resolved_references() != NULL,
+ "a resolved_references array should have been created for this class");
+ ObjectLocker ol(resolved_references, Thread::current());
if (!is_f1_null()) {
return;
}
@@ -336,7 +340,6 @@
// This allows us to create fewer Methods, while keeping type safety.
//
- objArrayHandle resolved_references = cpool->resolved_references();
// Store appendix, if any.
if (has_appendix) {
const int appendix_index = f2_as_index() + _indy_resolved_references_appendix_offset;
--- a/hotspot/src/share/vm/opto/castnode.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/opto/castnode.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -104,7 +104,8 @@
// Try to improve the type of the CastII if we recognize a CmpI/If
// pattern.
if (_carry_dependency) {
- if (in(0) != NULL && (in(0)->is_IfFalse() || in(0)->is_IfTrue())) {
+ if (in(0) != NULL && in(0)->in(0) != NULL && in(0)->in(0)->is_If()) {
+ assert(in(0)->is_IfFalse() || in(0)->is_IfTrue(), "should be If proj");
Node* proj = in(0);
if (proj->in(0)->in(1)->is_Bool()) {
Node* b = proj->in(0)->in(1);
--- a/hotspot/src/share/vm/opto/ifnode.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/opto/ifnode.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -820,6 +820,11 @@
static IfNode* idealize_test(PhaseGVN* phase, IfNode* iff);
+struct RangeCheck {
+ Node* ctl;
+ jint off;
+};
+
//------------------------------Ideal------------------------------------------
// Return a node which is more "ideal" than the current node. Strip out
// control copies
@@ -861,83 +866,141 @@
jint offset1;
int flip1 = is_range_check(range1, index1, offset1);
if( flip1 ) {
- Node *first_prev_dom = NULL;
-
// Try to remove extra range checks. All 'up_one_dom' gives up at merges
// so all checks we inspect post-dominate the top-most check we find.
// If we are going to fail the current check and we reach the top check
// then we are guaranteed to fail, so just start interpreting there.
- // We 'expand' the top 2 range checks to include all post-dominating
+ // We 'expand' the top 3 range checks to include all post-dominating
// checks.
- // The top 2 range checks seen
- Node *prev_chk1 = NULL;
- Node *prev_chk2 = NULL;
+ // The top 3 range checks seen
+ const int NRC =3;
+ RangeCheck prev_checks[NRC];
+ int nb_checks = 0;
+
// Low and high offsets seen so far
jint off_lo = offset1;
jint off_hi = offset1;
- // Scan for the top 2 checks and collect range of offsets
- for( int dist = 0; dist < 999; dist++ ) { // Range-Check scan limit
- if( dom->Opcode() == Op_If && // Not same opcode?
- prev_dom->in(0) == dom ) { // One path of test does dominate?
- if( dom == this ) return NULL; // dead loop
+ bool found_immediate_dominator = false;
+
+ // Scan for the top checks and collect range of offsets
+ for (int dist = 0; dist < 999; dist++) { // Range-Check scan limit
+ if (dom->Opcode() == Op_If && // Not same opcode?
+ prev_dom->in(0) == dom) { // One path of test does dominate?
+ if (dom == this) return NULL; // dead loop
// See if this is a range check
Node *index2, *range2;
jint offset2;
int flip2 = dom->as_If()->is_range_check(range2, index2, offset2);
// See if this is a _matching_ range check, checking against
// the same array bounds.
- if( flip2 == flip1 && range2 == range1 && index2 == index1 &&
- dom->outcnt() == 2 ) {
+ if (flip2 == flip1 && range2 == range1 && index2 == index1 &&
+ dom->outcnt() == 2) {
+ if (nb_checks == 0 && dom->in(1) == in(1)) {
+ // Found an immediately dominating test at the same offset.
+ // This kind of back-to-back test can be eliminated locally,
+ // and there is no need to search further for dominating tests.
+ assert(offset2 == offset1, "Same test but different offsets");
+ found_immediate_dominator = true;
+ break;
+ }
// Gather expanded bounds
off_lo = MIN2(off_lo,offset2);
off_hi = MAX2(off_hi,offset2);
- // Record top 2 range checks
- prev_chk2 = prev_chk1;
- prev_chk1 = prev_dom;
- // If we match the test exactly, then the top test covers
- // both our lower and upper bounds.
- if( dom->in(1) == in(1) )
- prev_chk2 = prev_chk1;
+ // Record top NRC range checks
+ prev_checks[nb_checks%NRC].ctl = prev_dom;
+ prev_checks[nb_checks%NRC].off = offset2;
+ nb_checks++;
}
}
prev_dom = dom;
- dom = up_one_dom( dom );
- if( !dom ) break;
+ dom = up_one_dom(dom);
+ if (!dom) break;
}
-
- // Attempt to widen the dominating range check to cover some later
- // ones. Since range checks "fail" by uncommon-trapping to the
- // interpreter, widening a check can make us speculative enter the
- // interpreter. If we see range-check deopt's, do not widen!
- if (!phase->C->allow_range_check_smearing()) return NULL;
+ if (!found_immediate_dominator) {
+ // Attempt to widen the dominating range check to cover some later
+ // ones. Since range checks "fail" by uncommon-trapping to the
+ // interpreter, widening a check can make us speculatively enter
+ // the interpreter. If we see range-check deopt's, do not widen!
+ if (!phase->C->allow_range_check_smearing()) return NULL;
- // Constant indices only need to check the upper bound.
- // Non-constance indices must check both low and high.
- if( index1 ) {
- // Didn't find 2 prior covering checks, so cannot remove anything.
- if( !prev_chk2 ) return NULL;
- // 'Widen' the offsets of the 1st and 2nd covering check
- adjust_check( prev_chk1, range1, index1, flip1, off_lo, igvn );
- // Do not call adjust_check twice on the same projection
- // as the first call may have transformed the BoolNode to a ConI
- if( prev_chk1 != prev_chk2 ) {
- adjust_check( prev_chk2, range1, index1, flip1, off_hi, igvn );
+ // Didn't find prior covering check, so cannot remove anything.
+ if (nb_checks == 0) {
+ return NULL;
}
- // Test is now covered by prior checks, dominate it out
- prev_dom = prev_chk2;
- } else {
- // Didn't find prior covering check, so cannot remove anything.
- if( !prev_chk1 ) return NULL;
- // 'Widen' the offset of the 1st and only covering check
- adjust_check( prev_chk1, range1, index1, flip1, off_hi, igvn );
- // Test is now covered by prior checks, dominate it out
- prev_dom = prev_chk1;
+ // Constant indices only need to check the upper bound.
+ // Non-constant indices must check both low and high.
+ int chk0 = (nb_checks - 1) % NRC;
+ if (index1) {
+ if (nb_checks == 1) {
+ return NULL;
+ } else {
+ // If the top range check's constant is the min or max of
+ // all constants we widen the next one to cover the whole
+ // range of constants.
+ RangeCheck rc0 = prev_checks[chk0];
+ int chk1 = (nb_checks - 2) % NRC;
+ RangeCheck rc1 = prev_checks[chk1];
+ if (rc0.off == off_lo) {
+ adjust_check(rc1.ctl, range1, index1, flip1, off_hi, igvn);
+ prev_dom = rc1.ctl;
+ } else if (rc0.off == off_hi) {
+ adjust_check(rc1.ctl, range1, index1, flip1, off_lo, igvn);
+ prev_dom = rc1.ctl;
+ } else {
+ // If the top test's constant is not the min or max of all
+ // constants, we need 3 range checks. We must leave the
+ // top test unchanged because widening it would allow the
+ // accesses it protects to successfully read/write out of
+ // bounds.
+ if (nb_checks == 2) {
+ return NULL;
+ }
+ int chk2 = (nb_checks - 3) % NRC;
+ RangeCheck rc2 = prev_checks[chk2];
+ // The top range check a+i covers interval: -a <= i < length-a
+ // The second range check b+i covers interval: -b <= i < length-b
+ if (rc1.off <= rc0.off) {
+ // if b <= a, we change the second range check to:
+ // -min_of_all_constants <= i < length-min_of_all_constants
+ // Together top and second range checks now cover:
+ // -min_of_all_constants <= i < length-a
+ // which is more restrictive than -b <= i < length-b:
+ // -b <= -min_of_all_constants <= i < length-a <= length-b
+ // The third check is then changed to:
+ // -max_of_all_constants <= i < length-max_of_all_constants
+ // so 2nd and 3rd checks restrict allowed values of i to:
+ // -min_of_all_constants <= i < length-max_of_all_constants
+ adjust_check(rc1.ctl, range1, index1, flip1, off_lo, igvn);
+ adjust_check(rc2.ctl, range1, index1, flip1, off_hi, igvn);
+ } else {
+ // if b > a, we change the second range check to:
+ // -max_of_all_constants <= i < length-max_of_all_constants
+ // Together top and second range checks now cover:
+ // -a <= i < length-max_of_all_constants
+ // which is more restrictive than -b <= i < length-b:
+ // -b < -a <= i < length-max_of_all_constants <= length-b
+ // The third check is then changed to:
+ // -max_of_all_constants <= i < length-max_of_all_constants
+ // so 2nd and 3rd checks restrict allowed values of i to:
+ // -min_of_all_constants <= i < length-max_of_all_constants
+ adjust_check(rc1.ctl, range1, index1, flip1, off_hi, igvn);
+ adjust_check(rc2.ctl, range1, index1, flip1, off_lo, igvn);
+ }
+ prev_dom = rc2.ctl;
+ }
+ }
+ } else {
+ RangeCheck rc0 = prev_checks[chk0];
+ // 'Widen' the offset of the 1st and only covering check
+ adjust_check(rc0.ctl, range1, index1, flip1, off_hi, igvn);
+ // Test is now covered by prior checks, dominate it out
+ prev_dom = rc0.ctl;
+ }
}
-
} else { // Scan for an equivalent test
Node *cmp;
@@ -1019,7 +1082,7 @@
// for lower and upper bounds.
ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate))
- prev_dom = idom;
+ prev_dom = idom;
// Now walk the current IfNode's projections.
// Loop ends when 'this' has no more uses.
--- a/hotspot/src/share/vm/opto/loopopts.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/opto/loopopts.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -241,8 +241,13 @@
ProjNode* dp_proj = dp->as_Proj();
ProjNode* unc_proj = iff->as_If()->proj_out(1 - dp_proj->_con)->as_Proj();
if (exclude_loop_predicate &&
- unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate))
+ (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) ||
+ unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_range_check))) {
+ // If this is a range check (IfNode::is_range_check), do not
+ // reorder because Compile::allow_range_check_smearing might have
+ // changed the check.
return; // Let IGVN transformation change control dependence.
+ }
IdealLoopTree *old_loop = get_loop(dp);
@@ -898,23 +903,23 @@
int n_op = n->Opcode();
// Check for an IF being dominated by another IF same test
- if( n_op == Op_If ) {
+ if (n_op == Op_If) {
Node *bol = n->in(1);
uint max = bol->outcnt();
// Check for same test used more than once?
- if( n_op == Op_If && max > 1 && bol->is_Bool() ) {
+ if (max > 1 && bol->is_Bool()) {
// Search up IDOMs to see if this IF is dominated.
Node *cutoff = get_ctrl(bol);
// Now search up IDOMs till cutoff, looking for a dominating test
Node *prevdom = n;
Node *dom = idom(prevdom);
- while( dom != cutoff ) {
- if( dom->req() > 1 && dom->in(1) == bol && prevdom->in(0) == dom ) {
+ while (dom != cutoff) {
+ if (dom->req() > 1 && dom->in(1) == bol && prevdom->in(0) == dom) {
// Replace the dominated test with an obvious true or false.
// Place it on the IGVN worklist for later cleanup.
C->set_major_progress();
- dominated_by( prevdom, n, false, true );
+ dominated_by(prevdom, n, false, true);
#ifndef PRODUCT
if( VerifyLoopOptimizations ) verify();
#endif
--- a/hotspot/src/share/vm/opto/macro.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/opto/macro.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -971,7 +971,11 @@
}
bool PhaseMacroExpand::eliminate_allocate_node(AllocateNode *alloc) {
- if (!EliminateAllocations || !alloc->_is_non_escaping) {
+ // Don't do scalar replacement if the frame can be popped by JVMTI:
+ // if reallocation fails during deoptimization we'll pop all
+ // interpreter frames for this compiled frame and that won't play
+ // nice with JVMTI popframe.
+ if (!EliminateAllocations || JvmtiExport::can_pop_frame() || !alloc->_is_non_escaping) {
return false;
}
Node* klass = alloc->in(AllocateNode::KlassNode);
--- a/hotspot/src/share/vm/prims/whitebox.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/prims/whitebox.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -74,7 +74,7 @@
static JavaThread* create_sweeper_thread(TRAPS);
static int get_blob_type(const CodeBlob* code);
static CodeHeap* get_code_heap(int blob_type);
- static CodeBlob* allocate_code_blob(int blob_type, int size);
+ static CodeBlob* allocate_code_blob(int size, int blob_type);
static int array_bytes_to_length(size_t bytes);
static void register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread,
JNINativeMethod* method_array, int method_count);
--- a/hotspot/src/share/vm/runtime/arguments.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -125,8 +125,8 @@
char* Arguments::_meta_index_dir = NULL;
char* Arguments::_ext_dirs = NULL;
-// Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string
-
+// Check if head of 'option' matches 'name', and sets 'tail' to the remaining
+// part of the option string.
static bool match_option(const JavaVMOption *option, const char* name,
const char** tail) {
int len = (int)strlen(name);
@@ -138,6 +138,32 @@
}
}
+// Check if 'option' matches 'name'. No "tail" is allowed.
+static bool match_option(const JavaVMOption *option, const char* name) {
+ const char* tail = NULL;
+ bool result = match_option(option, name, &tail);
+ if (tail != NULL && *tail == '\0') {
+ return result;
+ } else {
+ return false;
+ }
+}
+
+// Return true if any of the strings in null-terminated array 'names' matches.
+// If tail_allowed is true, then the tail must begin with a colon; otherwise,
+// the option must match exactly.
+static bool match_option(const JavaVMOption* option, const char** names, const char** tail,
+ bool tail_allowed) {
+ for (/* empty */; *names != NULL; ++names) {
+ if (match_option(option, *names, tail)) {
+ if (**tail == '\0' || tail_allowed && **tail == ':') {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
static void logOption(const char* opt) {
if (PrintVMOptions) {
jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt);
@@ -2526,21 +2552,6 @@
"-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
};
-// Return true if any of the strings in null-terminated array 'names' matches.
-// If tail_allowed is true, then the tail must begin with a colon; otherwise,
-// the option must match exactly.
-static bool match_option(const JavaVMOption* option, const char** names, const char** tail,
- bool tail_allowed) {
- for (/* empty */; *names != NULL; ++names) {
- if (match_option(option, *names, tail)) {
- if (**tail == '\0' || tail_allowed && **tail == ':') {
- return true;
- }
- }
- }
- return false;
-}
-
bool Arguments::parse_uintx(const char* value,
uintx* uintx_arg,
uintx min_size) {
@@ -2782,16 +2793,16 @@
}
#endif // !INCLUDE_JVMTI
// -Xnoclassgc
- } else if (match_option(option, "-Xnoclassgc", &tail)) {
+ } else if (match_option(option, "-Xnoclassgc")) {
FLAG_SET_CMDLINE(bool, ClassUnloading, false);
// -Xconcgc
- } else if (match_option(option, "-Xconcgc", &tail)) {
+ } else if (match_option(option, "-Xconcgc")) {
FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
// -Xnoconcgc
- } else if (match_option(option, "-Xnoconcgc", &tail)) {
+ } else if (match_option(option, "-Xnoconcgc")) {
FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
// -Xbatch
- } else if (match_option(option, "-Xbatch", &tail)) {
+ } else if (match_option(option, "-Xbatch")) {
FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
// -Xmn for compatibility with other JVM vendors
} else if (match_option(option, "-Xmn", &tail)) {
@@ -2936,28 +2947,28 @@
}
FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt);
// -green
- } else if (match_option(option, "-green", &tail)) {
+ } else if (match_option(option, "-green")) {
jio_fprintf(defaultStream::error_stream(),
"Green threads support not available\n");
return JNI_EINVAL;
// -native
- } else if (match_option(option, "-native", &tail)) {
+ } else if (match_option(option, "-native")) {
// HotSpot always uses native threads, ignore silently for compatibility
// -Xsqnopause
- } else if (match_option(option, "-Xsqnopause", &tail)) {
+ } else if (match_option(option, "-Xsqnopause")) {
// EVM option, ignore silently for compatibility
// -Xrs
- } else if (match_option(option, "-Xrs", &tail)) {
+ } else if (match_option(option, "-Xrs")) {
// Classic/EVM option, new functionality
FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true);
- } else if (match_option(option, "-Xusealtsigs", &tail)) {
+ } else if (match_option(option, "-Xusealtsigs")) {
// change default internal VM signals used - lower case for back compat
FLAG_SET_CMDLINE(bool, UseAltSigs, true);
// -Xoptimize
- } else if (match_option(option, "-Xoptimize", &tail)) {
+ } else if (match_option(option, "-Xoptimize")) {
// EVM option, ignore silently for compatibility
// -Xprof
- } else if (match_option(option, "-Xprof", &tail)) {
+ } else if (match_option(option, "-Xprof")) {
#if INCLUDE_FPROF
_has_profile = true;
#else // INCLUDE_FPROF
@@ -2966,7 +2977,7 @@
return JNI_ERR;
#endif // INCLUDE_FPROF
// -Xconcurrentio
- } else if (match_option(option, "-Xconcurrentio", &tail)) {
+ } else if (match_option(option, "-Xconcurrentio")) {
FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true);
FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1);
@@ -2974,13 +2985,13 @@
FLAG_SET_CMDLINE(uintx, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation
// -Xinternalversion
- } else if (match_option(option, "-Xinternalversion", &tail)) {
+ } else if (match_option(option, "-Xinternalversion")) {
jio_fprintf(defaultStream::output_stream(), "%s\n",
VM_Version::internal_vm_info_string());
vm_exit(0);
#ifndef PRODUCT
// -Xprintflags
- } else if (match_option(option, "-Xprintflags", &tail)) {
+ } else if (match_option(option, "-Xprintflags")) {
CommandLineFlags::printFlags(tty, false);
vm_exit(0);
#endif
@@ -3014,29 +3025,29 @@
#endif
}
// -Xint
- } else if (match_option(option, "-Xint", &tail)) {
+ } else if (match_option(option, "-Xint")) {
set_mode_flags(_int);
// -Xmixed
- } else if (match_option(option, "-Xmixed", &tail)) {
+ } else if (match_option(option, "-Xmixed")) {
set_mode_flags(_mixed);
// -Xcomp
- } else if (match_option(option, "-Xcomp", &tail)) {
+ } else if (match_option(option, "-Xcomp")) {
// for testing the compiler; turn off all flags that inhibit compilation
set_mode_flags(_comp);
// -Xshare:dump
- } else if (match_option(option, "-Xshare:dump", &tail)) {
+ } else if (match_option(option, "-Xshare:dump")) {
FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true);
set_mode_flags(_int); // Prevent compilation, which creates objects
// -Xshare:on
- } else if (match_option(option, "-Xshare:on", &tail)) {
+ } else if (match_option(option, "-Xshare:on")) {
FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
// -Xshare:auto
- } else if (match_option(option, "-Xshare:auto", &tail)) {
+ } else if (match_option(option, "-Xshare:auto")) {
FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
// -Xshare:off
- } else if (match_option(option, "-Xshare:off", &tail)) {
+ } else if (match_option(option, "-Xshare:off")) {
FLAG_SET_CMDLINE(bool, UseSharedSpaces, false);
FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
// -Xverify
@@ -3054,13 +3065,13 @@
return JNI_EINVAL;
}
// -Xdebug
- } else if (match_option(option, "-Xdebug", &tail)) {
+ } else if (match_option(option, "-Xdebug")) {
// note this flag has been used, then ignore
set_xdebug_mode(true);
// -Xnoagent
- } else if (match_option(option, "-Xnoagent", &tail)) {
+ } else if (match_option(option, "-Xnoagent")) {
// For compatibility with classic. HotSpot refuses to load the old style agent.dll.
- } else if (match_option(option, "-Xboundthreads", &tail)) {
+ } else if (match_option(option, "-Xboundthreads")) {
// Bind user level threads to kernel threads (Solaris only)
FLAG_SET_CMDLINE(bool, UseBoundThreads, true);
} else if (match_option(option, "-Xloggc:", &tail)) {
@@ -3090,14 +3101,14 @@
"check")) {
return JNI_EINVAL;
}
- } else if (match_option(option, "vfprintf", &tail)) {
+ } else if (match_option(option, "vfprintf")) {
_vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
- } else if (match_option(option, "exit", &tail)) {
+ } else if (match_option(option, "exit")) {
_exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
- } else if (match_option(option, "abort", &tail)) {
+ } else if (match_option(option, "abort")) {
_abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);
// -XX:+AggressiveHeap
- } else if (match_option(option, "-XX:+AggressiveHeap", &tail)) {
+ } else if (match_option(option, "-XX:+AggressiveHeap")) {
// This option inspects the machine and attempts to set various
// parameters to be optimal for long-running, memory allocation
@@ -3188,11 +3199,11 @@
// Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
// and the last option wins.
- } else if (match_option(option, "-XX:+NeverTenure", &tail)) {
+ } else if (match_option(option, "-XX:+NeverTenure")) {
FLAG_SET_CMDLINE(bool, NeverTenure, true);
FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1);
- } else if (match_option(option, "-XX:+AlwaysTenure", &tail)) {
+ } else if (match_option(option, "-XX:+AlwaysTenure")) {
FLAG_SET_CMDLINE(bool, NeverTenure, false);
FLAG_SET_CMDLINE(bool, AlwaysTenure, true);
FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0);
@@ -3211,17 +3222,17 @@
FLAG_SET_CMDLINE(bool, NeverTenure, false);
FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
}
- } else if (match_option(option, "-XX:+CMSPermGenSweepingEnabled", &tail) ||
- match_option(option, "-XX:-CMSPermGenSweepingEnabled", &tail)) {
+ } else if (match_option(option, "-XX:+CMSPermGenSweepingEnabled") ||
+ match_option(option, "-XX:-CMSPermGenSweepingEnabled")) {
jio_fprintf(defaultStream::error_stream(),
"Please use CMSClassUnloadingEnabled in place of "
"CMSPermGenSweepingEnabled in the future\n");
- } else if (match_option(option, "-XX:+UseGCTimeLimit", &tail)) {
+ } else if (match_option(option, "-XX:+UseGCTimeLimit")) {
FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, true);
jio_fprintf(defaultStream::error_stream(),
"Please use -XX:+UseGCOverheadLimit in place of "
"-XX:+UseGCTimeLimit in the future\n");
- } else if (match_option(option, "-XX:-UseGCTimeLimit", &tail)) {
+ } else if (match_option(option, "-XX:-UseGCTimeLimit")) {
FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, false);
jio_fprintf(defaultStream::error_stream(),
"Please use -XX:-UseGCOverheadLimit in place of "
@@ -3231,13 +3242,13 @@
// are not to be documented.
} else if (match_option(option, "-XX:MaxTLERatio=", &tail)) {
// No longer used.
- } else if (match_option(option, "-XX:+ResizeTLE", &tail)) {
+ } else if (match_option(option, "-XX:+ResizeTLE")) {
FLAG_SET_CMDLINE(bool, ResizeTLAB, true);
- } else if (match_option(option, "-XX:-ResizeTLE", &tail)) {
+ } else if (match_option(option, "-XX:-ResizeTLE")) {
FLAG_SET_CMDLINE(bool, ResizeTLAB, false);
- } else if (match_option(option, "-XX:+PrintTLE", &tail)) {
+ } else if (match_option(option, "-XX:+PrintTLE")) {
FLAG_SET_CMDLINE(bool, PrintTLAB, true);
- } else if (match_option(option, "-XX:-PrintTLE", &tail)) {
+ } else if (match_option(option, "-XX:-PrintTLE")) {
FLAG_SET_CMDLINE(bool, PrintTLAB, false);
} else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) {
// No longer used.
@@ -3253,17 +3264,17 @@
FLAG_SET_CMDLINE(uintx, TLABSize, long_tlab_size);
} else if (match_option(option, "-XX:TLEThreadRatio=", &tail)) {
// No longer used.
- } else if (match_option(option, "-XX:+UseTLE", &tail)) {
+ } else if (match_option(option, "-XX:+UseTLE")) {
FLAG_SET_CMDLINE(bool, UseTLAB, true);
- } else if (match_option(option, "-XX:-UseTLE", &tail)) {
+ } else if (match_option(option, "-XX:-UseTLE")) {
FLAG_SET_CMDLINE(bool, UseTLAB, false);
- } else if (match_option(option, "-XX:+DisplayVMOutputToStderr", &tail)) {
+ } else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) {
FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false);
FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true);
- } else if (match_option(option, "-XX:+DisplayVMOutputToStdout", &tail)) {
+ } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) {
FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
- } else if (match_option(option, "-XX:+ExtendedDTraceProbes", &tail)) {
+ } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
#if defined(DTRACE_ENABLED)
FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
@@ -3275,7 +3286,7 @@
return JNI_EINVAL;
#endif // defined(DTRACE_ENABLED)
#ifdef ASSERT
- } else if (match_option(option, "-XX:+FullGCALot", &tail)) {
+ } else if (match_option(option, "-XX:+FullGCALot")) {
FLAG_SET_CMDLINE(bool, FullGCALot, true);
// disable scavenge before parallel mark-compact
FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
@@ -3361,7 +3372,7 @@
}
FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
#if !INCLUDE_MANAGEMENT
- } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
+ } else if (match_option(option, "-XX:+ManagementServer")) {
jio_fprintf(defaultStream::error_stream(),
"ManagementServer is not supported in this VM.\n");
return JNI_ERR;
@@ -3796,23 +3807,23 @@
settings_file_specified = true;
continue;
}
- if (match_option(option, "-XX:+PrintVMOptions", &tail)) {
+ if (match_option(option, "-XX:+PrintVMOptions")) {
PrintVMOptions = true;
continue;
}
- if (match_option(option, "-XX:-PrintVMOptions", &tail)) {
+ if (match_option(option, "-XX:-PrintVMOptions")) {
PrintVMOptions = false;
continue;
}
- if (match_option(option, "-XX:+IgnoreUnrecognizedVMOptions", &tail)) {
+ if (match_option(option, "-XX:+IgnoreUnrecognizedVMOptions")) {
IgnoreUnrecognizedVMOptions = true;
continue;
}
- if (match_option(option, "-XX:-IgnoreUnrecognizedVMOptions", &tail)) {
+ if (match_option(option, "-XX:-IgnoreUnrecognizedVMOptions")) {
IgnoreUnrecognizedVMOptions = false;
continue;
}
- if (match_option(option, "-XX:+PrintFlagsInitial", &tail)) {
+ if (match_option(option, "-XX:+PrintFlagsInitial")) {
CommandLineFlags::printFlags(tty, false);
vm_exit(0);
}
@@ -3838,7 +3849,7 @@
#ifndef PRODUCT
- if (match_option(option, "-XX:+PrintFlagsWithComments", &tail)) {
+ if (match_option(option, "-XX:+PrintFlagsWithComments")) {
CommandLineFlags::printFlags(tty, true);
vm_exit(0);
}
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -176,6 +176,8 @@
assert(vf->is_compiled_frame(), "Wrong frame type");
chunk->push(compiledVFrame::cast(vf));
+ bool realloc_failures = false;
+
#ifdef COMPILER2
// Reallocate the non-escaping objects and restore their fields. Then
// relock objects if synchronization on them was eliminated.
@@ -206,19 +208,16 @@
tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT " in thread " INTPTR_FORMAT, (void *)result, thread);
}
}
- bool reallocated = false;
if (objects != NULL) {
JRT_BLOCK
- reallocated = realloc_objects(thread, &deoptee, objects, THREAD);
+ realloc_failures = realloc_objects(thread, &deoptee, objects, THREAD);
JRT_END
- }
- if (reallocated) {
- reassign_fields(&deoptee, &map, objects);
+ reassign_fields(&deoptee, &map, objects, realloc_failures);
#ifndef PRODUCT
if (TraceDeoptimization) {
ttyLocker ttyl;
tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread);
- print_objects(objects);
+ print_objects(objects, realloc_failures);
}
#endif
}
@@ -236,7 +235,7 @@
assert (cvf->scope() != NULL,"expect only compiled java frames");
GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
if (monitors->is_nonempty()) {
- relock_objects(monitors, thread);
+ relock_objects(monitors, thread, realloc_failures);
#ifndef PRODUCT
if (TraceDeoptimization) {
ttyLocker ttyl;
@@ -247,7 +246,12 @@
first = false;
tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, thread);
}
- tty->print_cr(" object <" INTPTR_FORMAT "> locked", (void *)mi->owner());
+ if (mi->owner_is_scalar_replaced()) {
+ Klass* k = java_lang_Class::as_Klass(mi->owner_klass());
+ tty->print_cr(" failed reallocation for klass %s", k->external_name());
+ } else {
+ tty->print_cr(" object <" INTPTR_FORMAT "> locked", (void *)mi->owner());
+ }
}
}
}
@@ -262,9 +266,14 @@
// out the java state residing in the vframeArray will be missed.
No_Safepoint_Verifier no_safepoint;
- vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk);
+ vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures);
+#ifdef COMPILER2
+ if (realloc_failures) {
+ pop_frames_failed_reallocs(thread, array);
+ }
+#endif
- assert(thread->vframe_array_head() == NULL, "Pending deopt!");;
+ assert(thread->vframe_array_head() == NULL, "Pending deopt!");
thread->set_vframe_array_head(array);
// Now that the vframeArray has been created if we have any deferred local writes
@@ -718,6 +727,8 @@
int exception_line = thread->exception_line();
thread->clear_pending_exception();
+ bool failures = false;
+
for (int i = 0; i < objects->length(); i++) {
assert(objects->at(i)->is_object(), "invalid debug information");
ObjectValue* sv = (ObjectValue*) objects->at(i);
@@ -727,27 +738,34 @@
if (k->oop_is_instance()) {
InstanceKlass* ik = InstanceKlass::cast(k());
- obj = ik->allocate_instance(CHECK_(false));
+ obj = ik->allocate_instance(THREAD);
} else if (k->oop_is_typeArray()) {
TypeArrayKlass* ak = TypeArrayKlass::cast(k());
assert(sv->field_size() % type2size[ak->element_type()] == 0, "non-integral array length");
int len = sv->field_size() / type2size[ak->element_type()];
- obj = ak->allocate(len, CHECK_(false));
+ obj = ak->allocate(len, THREAD);
} else if (k->oop_is_objArray()) {
ObjArrayKlass* ak = ObjArrayKlass::cast(k());
- obj = ak->allocate(sv->field_size(), CHECK_(false));
+ obj = ak->allocate(sv->field_size(), THREAD);
}
- assert(obj != NULL, "allocation failed");
+ if (obj == NULL) {
+ failures = true;
+ }
+
assert(sv->value().is_null(), "redundant reallocation");
+ assert(obj != NULL || HAS_PENDING_EXCEPTION, "allocation should succeed or we should get an exception");
+ CLEAR_PENDING_EXCEPTION;
sv->set_value(obj);
}
- if (pending_exception.not_null()) {
+ if (failures) {
+ THROW_OOP_(Universe::out_of_memory_error_realloc_objects(), failures);
+ } else if (pending_exception.not_null()) {
thread->set_pending_exception(pending_exception(), exception_file, exception_line);
}
- return true;
+ return failures;
}
// This assumes that the fields are stored in ObjectValue in the same order
@@ -885,12 +903,15 @@
// restore fields of all eliminated objects and arrays
-void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects) {
+void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures) {
for (int i = 0; i < objects->length(); i++) {
ObjectValue* sv = (ObjectValue*) objects->at(i);
KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()()));
Handle obj = sv->value();
- assert(obj.not_null(), "reallocation was missed");
+ assert(obj.not_null() || realloc_failures, "reallocation was missed");
+ if (obj.is_null()) {
+ continue;
+ }
if (k->oop_is_instance()) {
InstanceKlass* ik = InstanceKlass::cast(k());
@@ -907,34 +928,36 @@
// relock objects for which synchronization was eliminated
-void Deoptimization::relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread) {
+void Deoptimization::relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures) {
for (int i = 0; i < monitors->length(); i++) {
MonitorInfo* mon_info = monitors->at(i);
if (mon_info->eliminated()) {
- assert(mon_info->owner() != NULL, "reallocation was missed");
- Handle obj = Handle(mon_info->owner());
- markOop mark = obj->mark();
- if (UseBiasedLocking && mark->has_bias_pattern()) {
- // New allocated objects may have the mark set to anonymously biased.
- // Also the deoptimized method may called methods with synchronization
- // where the thread-local object is bias locked to the current thread.
- assert(mark->is_biased_anonymously() ||
- mark->biased_locker() == thread, "should be locked to current thread");
- // Reset mark word to unbiased prototype.
- markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age());
- obj->set_mark(unbiased_prototype);
+ assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed");
+ if (!mon_info->owner_is_scalar_replaced()) {
+ Handle obj = Handle(mon_info->owner());
+ markOop mark = obj->mark();
+ if (UseBiasedLocking && mark->has_bias_pattern()) {
+ // New allocated objects may have the mark set to anonymously biased.
+ // Also the deoptimized method may called methods with synchronization
+ // where the thread-local object is bias locked to the current thread.
+ assert(mark->is_biased_anonymously() ||
+ mark->biased_locker() == thread, "should be locked to current thread");
+ // Reset mark word to unbiased prototype.
+ markOop unbiased_prototype = markOopDesc::prototype()->set_age(mark->age());
+ obj->set_mark(unbiased_prototype);
+ }
+ BasicLock* lock = mon_info->lock();
+ ObjectSynchronizer::slow_enter(obj, lock, thread);
+ assert(mon_info->owner()->is_locked(), "object must be locked now");
}
- BasicLock* lock = mon_info->lock();
- ObjectSynchronizer::slow_enter(obj, lock, thread);
}
- assert(mon_info->owner()->is_locked(), "object must be locked now");
}
}
#ifndef PRODUCT
// print information about reallocated objects
-void Deoptimization::print_objects(GrowableArray<ScopeValue*>* objects) {
+void Deoptimization::print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures) {
fieldDescriptor fd;
for (int i = 0; i < objects->length(); i++) {
@@ -944,10 +967,15 @@
tty->print(" object <" INTPTR_FORMAT "> of type ", (void *)sv->value()());
k->print_value();
- tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize);
+ assert(obj.not_null() || realloc_failures, "reallocation was missed");
+ if (obj.is_null()) {
+ tty->print(" allocation failed");
+ } else {
+ tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize);
+ }
tty->cr();
- if (Verbose) {
+ if (Verbose && !obj.is_null()) {
k->oop_print_on(obj(), tty);
}
}
@@ -955,7 +983,7 @@
#endif
#endif // COMPILER2
-vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk) {
+vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, fr.pc(), fr.sp());
#ifndef PRODUCT
@@ -998,7 +1026,7 @@
// Since the Java thread being deoptimized will eventually adjust it's own stack,
// the vframeArray containing the unpacking information is allocated in the C heap.
// For Compiler1, the caller of the deoptimized frame is saved for use by unpack_frames().
- vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr);
+ vframeArray* array = vframeArray::allocate(thread, frame_size, chunk, reg_map, sender, caller, fr, realloc_failures);
// Compare the vframeArray to the collected vframes
assert(array->structural_compare(thread, chunk), "just checking");
@@ -1013,6 +1041,33 @@
return array;
}
+#ifdef COMPILER2
+void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) {
+ // Reallocation of some scalar replaced objects failed. Record
+ // that we need to pop all the interpreter frames for the
+ // deoptimized compiled frame.
+ assert(thread->frames_to_pop_failed_realloc() == 0, "missed frames to pop?");
+ thread->set_frames_to_pop_failed_realloc(array->frames());
+ // Unlock all monitors here otherwise the interpreter will see a
+ // mix of locked and unlocked monitors (because of failed
+ // reallocations of synchronized objects) and be confused.
+ for (int i = 0; i < array->frames(); i++) {
+ MonitorChunk* monitors = array->element(i)->monitors();
+ if (monitors != NULL) {
+ for (int j = 0; j < monitors->number_of_monitors(); j++) {
+ BasicObjectLock* src = monitors->at(j);
+ if (src->obj() != NULL) {
+ ObjectSynchronizer::fast_exit(src->obj(), src->lock(), thread);
+ }
+ }
+ array->element(i)->free_monitors(thread);
+#ifdef ASSERT
+ array->element(i)->set_removed_monitors();
+#endif
+ }
+ }
+}
+#endif
static void collect_monitors(compiledVFrame* cvf, GrowableArray<Handle>* objects_to_revoke) {
GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
--- a/hotspot/src/share/vm/runtime/deoptimization.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/deoptimization.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -125,13 +125,14 @@
static bool realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS);
static void reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type);
static void reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj);
- static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects);
- static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread);
- NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects);)
+ static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures);
+ static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures);
+ static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array);
+ NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures);)
#endif // COMPILER2
public:
- static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk);
+ static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures);
// Interface used for unpacking deoptimized frames
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -456,6 +456,7 @@
address SharedRuntime::raw_exception_handler_for_return_address(JavaThread* thread, address return_address) {
assert(frame::verify_return_pc(return_address), err_msg("must be a return address: " INTPTR_FORMAT, return_address));
+ assert(thread->frames_to_pop_failed_realloc() == 0 || Interpreter::contains(return_address), "missed frames to pop?");
// Reset method handle flag.
thread->set_is_method_handle_return(false);
--- a/hotspot/src/share/vm/runtime/thread.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/thread.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -1448,6 +1448,7 @@
_popframe_condition = popframe_inactive;
_popframe_preserved_args = NULL;
_popframe_preserved_args_size = 0;
+ _frames_to_pop_failed_realloc = 0;
pd_initialize();
}
--- a/hotspot/src/share/vm/runtime/thread.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/thread.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -908,6 +908,12 @@
// This is set to popframe_pending to signal that top Java frame should be popped immediately
int _popframe_condition;
+ // If reallocation of scalar replaced objects fails, we throw OOM
+ // and during exception propagation, pop the top
+ // _frames_to_pop_failed_realloc frames, the ones that reference
+ // failed reallocations.
+ int _frames_to_pop_failed_realloc;
+
#ifndef PRODUCT
int _jmp_ring_index;
struct {
@@ -1567,6 +1573,10 @@
void clr_pop_frame_in_process(void) { _popframe_condition &= ~popframe_processing_bit; }
#endif
+ int frames_to_pop_failed_realloc() const { return _frames_to_pop_failed_realloc; }
+ void set_frames_to_pop_failed_realloc(int nb) { _frames_to_pop_failed_realloc = nb; }
+ void dec_frames_to_pop_failed_realloc() { _frames_to_pop_failed_realloc--; }
+
private:
// Saved incoming arguments to popped frame.
// Used only when popped interpreted frame returns to deoptimized frame.
--- a/hotspot/src/share/vm/runtime/vframeArray.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/vframeArray.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -57,7 +57,7 @@
}
}
-void vframeArrayElement::fill_in(compiledVFrame* vf) {
+void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) {
// Copy the information from the compiled vframe to the
// interpreter frame we will be creating to replace vf
@@ -65,6 +65,9 @@
_method = vf->method();
_bci = vf->raw_bci();
_reexecute = vf->should_reexecute();
+#ifdef ASSERT
+ _removed_monitors = false;
+#endif
int index;
@@ -82,11 +85,15 @@
// Migrate the BasicLocks from the stack to the monitor chunk
for (index = 0; index < list->length(); index++) {
MonitorInfo* monitor = list->at(index);
- assert(!monitor->owner_is_scalar_replaced(), "object should be reallocated already");
- assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
+ assert(!monitor->owner_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
BasicObjectLock* dest = _monitors->at(index);
- dest->set_obj(monitor->owner());
- monitor->lock()->move_to(monitor->owner(), dest->lock());
+ if (monitor->owner_is_scalar_replaced()) {
+ dest->set_obj(NULL);
+ } else {
+ assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
+ dest->set_obj(monitor->owner());
+ monitor->lock()->move_to(monitor->owner(), dest->lock());
+ }
}
}
@@ -111,7 +118,7 @@
StackValue* value = locs->at(index);
switch(value->type()) {
case T_OBJECT:
- assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
+ assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
// preserve object type
_locals->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
break;
@@ -136,7 +143,7 @@
StackValue* value = exprs->at(index);
switch(value->type()) {
case T_OBJECT:
- assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
+ assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already");
// preserve object type
_expressions->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT ));
break;
@@ -287,7 +294,7 @@
_frame.patch_pc(thread, pc);
- assert (!method()->is_synchronized() || locks > 0, "synchronized methods must have monitors");
+ assert (!method()->is_synchronized() || locks > 0 || _removed_monitors, "synchronized methods must have monitors");
BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin();
for (int index = 0; index < locks; index++) {
@@ -439,7 +446,8 @@
vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
- RegisterMap *reg_map, frame sender, frame caller, frame self) {
+ RegisterMap *reg_map, frame sender, frame caller, frame self,
+ bool realloc_failures) {
// Allocate the vframeArray
vframeArray * result = (vframeArray*) AllocateHeap(sizeof(vframeArray) + // fixed part
@@ -451,19 +459,20 @@
result->_caller = caller;
result->_original = self;
result->set_unroll_block(NULL); // initialize it
- result->fill_in(thread, frame_size, chunk, reg_map);
+ result->fill_in(thread, frame_size, chunk, reg_map, realloc_failures);
return result;
}
void vframeArray::fill_in(JavaThread* thread,
int frame_size,
GrowableArray<compiledVFrame*>* chunk,
- const RegisterMap *reg_map) {
+ const RegisterMap *reg_map,
+ bool realloc_failures) {
// Set owner first, it is used when adding monitor chunks
_frame_size = frame_size;
for(int i = 0; i < chunk->length(); i++) {
- element(i)->fill_in(chunk->at(i));
+ element(i)->fill_in(chunk->at(i), realloc_failures);
}
// Copy registers for callee-saved registers
--- a/hotspot/src/share/vm/runtime/vframeArray.hpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/vframeArray.hpp Wed Jul 05 20:11:52 2017 +0200
@@ -58,6 +58,9 @@
MonitorChunk* _monitors; // active monitors for this vframe
StackValueCollection* _locals;
StackValueCollection* _expressions;
+#ifdef ASSERT
+ bool _removed_monitors;
+#endif
public:
@@ -78,7 +81,7 @@
StackValueCollection* expressions(void) const { return _expressions; }
- void fill_in(compiledVFrame* vf);
+ void fill_in(compiledVFrame* vf, bool realloc_failures);
// Formerly part of deoptimizedVFrame
@@ -99,6 +102,12 @@
bool is_bottom_frame,
int exec_mode);
+#ifdef ASSERT
+ void set_removed_monitors() {
+ _removed_monitors = true;
+ }
+#endif
+
#ifndef PRODUCT
void print(outputStream* st);
#endif /* PRODUCT */
@@ -160,13 +169,14 @@
int frames() const { return _frames; }
static vframeArray* allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
- RegisterMap* reg_map, frame sender, frame caller, frame self);
+ RegisterMap* reg_map, frame sender, frame caller, frame self,
+ bool realloc_failures);
vframeArrayElement* element(int index) { assert(is_within_bounds(index), "Bad index"); return &_elements[index]; }
// Allocates a new vframe in the array and fills the array with vframe information in chunk
- void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map);
+ void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map, bool realloc_failures);
// Returns the owner of this vframeArray
JavaThread* owner_thread() const { return _owner_thread; }
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -556,9 +556,6 @@
\
nonstatic_field(TenuredGeneration, _min_heap_delta_bytes, size_t) \
nonstatic_field(TenuredGeneration, _the_space, ContiguousSpace*) \
- nonstatic_field(TenuredGeneration, _last_gc, WaterMark) \
- \
- \
\
nonstatic_field(Space, _bottom, HeapWord*) \
nonstatic_field(Space, _end, HeapWord*) \
--- a/hotspot/src/share/vm/trace/trace.xml Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/src/share/vm/trace/trace.xml Wed Jul 05 20:11:52 2017 +0200
@@ -314,6 +314,28 @@
<value type="BYTES64" field="totalSize" label="Total Size" />
</event>
+ <!-- Promotion events, Supported GCs are Parallel Scavange, G1 and CMS with Parallel New. -->
+ <event id="PromoteObjectInNewPLAB" path="vm/gc/detailed/object_promotion_in_new_PLAB" label="Promotion in new PLAB"
+ description="Object survived scavenge and was copied to a new Promotion Local Allocation Buffer (PLAB). Supported GCs are Parallel Scavange, G1 and CMS with Parallel New. Due to promotion being done in parallel an object might be reported multiple times as the GC threads race to copy all objects."
+ has_thread="true" has_stacktrace="false" is_instant="true">
+ <value type="UINT" field="gcId" label="GC ID" relation="GC_ID" description="ID of GC during which the object was promoted"/>
+ <value type="CLASS" field="class" label="Class" description="Class of promoted object"/>
+ <value type="BYTES64" field="objectSize" label="Object Size" description="Size of promoted object"/>
+ <value type="UINT" field="tenuringAge" label="Object Tenuring Age" description="Tenuring age of a surviving object before being copied. The tenuring age of an object is a value between 0-15 and is incremented each scavange the object survives. Newly allocated objects have tenuring age 0."/>
+ <value type="BOOLEAN" field="tenured" label="Tenured" description="True if object was promoted to Old space, otherwise the object was aged and copied to a Survivor space"/>
+ <value type="BYTES64" field="plabSize" label="PLAB Size" description="Size of the allocated PLAB to which the object was copied"/>
+ </event>
+
+ <event id="PromoteObjectOutsidePLAB" path="vm/gc/detailed/object_promotion_outside_PLAB" label="Promotion outside PLAB"
+ description="Object survived scavenge and was copied directly to the heap. Supported GCs are Parallel Scavange, G1 and CMS with Parallel New. Due to promotion being done in parallel an object might be reported multiple times as the GC threads race to copy all objects."
+ has_thread="true" has_stacktrace="false" is_instant="true">
+ <value type="UINT" field="gcId" label="GC ID" relation="GC_ID" description="ID of GC during which the object was promoted"/>
+ <value type="CLASS" field="class" label="Class" description="Class of promoted object"/>
+ <value type="BYTES64" field="objectSize" label="Object Size" description="Size of promoted object"/>
+ <value type="UINT" field="tenuringAge" label="Object Tenuring Age" description="Tenuring age of a surviving object before being copied. The tenuring age of an object is a value between 0-15 and is incremented each scavange the object survives. Newly allocated objects have tenuring age 0."/>
+ <value type="BOOLEAN" field="tenured" label="Tenured" description="True if object was promoted to Old space, otherwise the object was aged and copied to a Survivor space"/>
+ </event>
+
<event id="PromotionFailed" path="vm/gc/detailed/promotion_failed" label="Promotion Failed" is_instant="true"
description="Promotion of an object failed">
<value type="UINT" field="gcId" label="GC ID" relation="GC_ID"/>
--- a/hotspot/test/Makefile Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/test/Makefile Wed Jul 05 20:11:52 2017 +0200
@@ -275,6 +275,9 @@
# Ignore tests are not run and completely silent about it
JTREG_IGNORE_OPTION = -ignore:quiet
JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION)
+# Multiply by 4 the timeout factor
+JTREG_TIMEOUT_OPTION = -timeoutFactor:4
+JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION)
# Add any extra options
JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
# Set other vm and test options
--- a/hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java Wed Jul 05 20:11:52 2017 +0200
@@ -61,6 +61,7 @@
String[] vmOpts = new String[] {
"-Xbootclasspath/p:" + testClasses,
"-Xcomp",
+ "-XX:+IgnoreUnrecognizedVMOptions",
"-XX:-VerifyDependencies",
"-XX:CompileOnly=TestMonomorphicObjectCall::callFinalize",
"-XX:CompileOnly=Object::finalizeObject",
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/exceptions/SumTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,86 @@
+/*
+ * 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 8066900
+ * @summary FP registers are not properly restored by C1 when handling exceptions
+ * @run main/othervm -Xbatch SumTest
+ *
+ */
+public class SumTest {
+ private static class Sum {
+
+ double[] sums;
+
+ /**
+ * Construct empty Sum
+ */
+ public Sum() {
+ sums = new double[0];
+ }
+
+ /**
+ * Return the sum of all numbers added to this Sum
+ *
+ * @return the sum
+ */
+ final public double getSum() {
+ double sum = 0;
+ for (final double s : sums) {
+ sum += s;
+ }
+
+ return sum;
+ }
+
+ /**
+ * Add a new number to this Sum
+ *
+ * @param a number to be added.
+ */
+ final public void add(double a) {
+ try {
+ sums[sums.length] = -1; // Cause IndexOutOfBoundsException
+ } catch (final IndexOutOfBoundsException e) {
+ final double[] oldSums = sums;
+ sums = new double[oldSums.length + 1]; // Extend sums
+ System.arraycopy(oldSums, 0, sums, 0, oldSums.length);
+ sums[oldSums.length] = a; // Append a
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ final Sum sum = new Sum();
+ for (int i = 1; i <= 10000; ++i) {
+ sum.add(1);
+ double ii = sum.getSum();
+ if (i != ii) {
+ throw new Exception("Failure: computed = " + ii + ", expected = " + i);
+ }
+ }
+ }
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckSmearing.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,436 @@
+/*
+ * 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 8066103
+ * @summary C2's range check smearing allows out of bound array accesses
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox /testlibrary/com/oracle/java/testlibrary
+ * @build TestRangeCheckSmearing
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform
+ * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearing
+ *
+ */
+
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.*;
+import sun.hotspot.WhiteBox;
+import sun.hotspot.code.NMethod;
+import com.oracle.java.testlibrary.Platform;
+
+public class TestRangeCheckSmearing {
+ private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface Args { int[] value(); }
+
+ // first range check is i + max of all constants
+ @Args({0, 8})
+ static int m1(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+9];
+ if (allaccesses) {
+ res += array[i+8];
+ res += array[i+7];
+ res += array[i+6];
+ res += array[i+5];
+ res += array[i+4];
+ res += array[i+3];
+ res += array[i+2];
+ res += array[i+1];
+ }
+ return res;
+ }
+
+ // first range check is i + min of all constants
+ @Args({0, -9})
+ static int m2(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+1];
+ if (allaccesses) {
+ res += array[i+2];
+ res += array[i+3];
+ res += array[i+4];
+ res += array[i+5];
+ res += array[i+6];
+ res += array[i+7];
+ res += array[i+8];
+ res += array[i+9];
+ }
+ return res;
+ }
+
+ // first range check is not i + min/max of all constants
+ @Args({0, 8})
+ static int m3(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ if (allaccesses) {
+ res += array[i+2];
+ res += array[i+1];
+ res += array[i+4];
+ res += array[i+5];
+ res += array[i+6];
+ res += array[i+7];
+ res += array[i+8];
+ res += array[i+9];
+ }
+ return res;
+ }
+
+ @Args({0, -9})
+ static int m4(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ if (allaccesses) {
+ res += array[i+4];
+ res += array[i+1];
+ res += array[i+2];
+ res += array[i+5];
+ res += array[i+6];
+ res += array[i+7];
+ res += array[i+8];
+ res += array[i+9];
+ }
+ return res;
+ }
+
+ @Args({0, -3})
+ static int m5(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ res += array[i+2];
+ if (allaccesses) {
+ res += array[i+1];
+ res += array[i+4];
+ res += array[i+5];
+ res += array[i+6];
+ res += array[i+7];
+ res += array[i+8];
+ res += array[i+9];
+ }
+ return res;
+ }
+
+ @Args({0, 6})
+ static int m6(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ res += array[i+4];
+ if (allaccesses) {
+ res += array[i+2];
+ res += array[i+1];
+ res += array[i+5];
+ res += array[i+6];
+ res += array[i+7];
+ res += array[i+8];
+ res += array[i+9];
+ }
+ return res;
+ }
+
+ @Args({0, 6})
+ static int m7(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ res += array[i+2];
+ res += array[i+4];
+ if (allaccesses) {
+ res += array[i+1];
+ res += array[i+5];
+ res += array[i+6];
+ res += array[i+7];
+ res += array[i+8];
+ res += array[i+9];
+ }
+ return res;
+ }
+
+ @Args({0, -3})
+ static int m8(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ res += array[i+4];
+ res += array[i+2];
+ if (allaccesses) {
+ res += array[i+1];
+ res += array[i+5];
+ res += array[i+6];
+ res += array[i+7];
+ res += array[i+8];
+ res += array[i+9];
+ }
+ return res;
+ }
+
+ @Args({6, 15})
+ static int m9(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ if (allaccesses) {
+ res += array[i-2];
+ res += array[i-1];
+ res += array[i-4];
+ res += array[i-5];
+ res += array[i-6];
+ }
+ return res;
+ }
+
+ @Args({3, 12})
+ static int m10(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ if (allaccesses) {
+ res += array[i-2];
+ res += array[i-1];
+ res += array[i-3];
+ res += array[i+4];
+ res += array[i+5];
+ res += array[i+6];
+ }
+ return res;
+ }
+
+ @Args({3, -3})
+ static int m11(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ res += array[i-2];
+ if (allaccesses) {
+ res += array[i+5];
+ res += array[i+6];
+ }
+ return res;
+ }
+
+ @Args({3, 6})
+ static int m12(int[] array, int i, boolean allaccesses) {
+ int res = 0;
+ res += array[i+3];
+ res += array[i+6];
+ if (allaccesses) {
+ res += array[i-2];
+ res += array[i-3];
+ }
+ return res;
+ }
+
+ // check that identical range check is replaced by dominating one
+ // only when correct
+ @Args({0})
+ static int m13(int[] array, int i, boolean ignore) {
+ int res = 0;
+ res += array[i+3];
+ res += array[i+3];
+ return res;
+ }
+
+ @Args({2, 0})
+ static int m14(int[] array, int i, boolean ignore) {
+ int res = 0;
+
+ res += array[i];
+ res += array[i-2];
+ res += array[i]; // If range check below were to be removed first this cannot be considered identical to first range check
+ res += array[i-1]; // range check removed so i-1 array access depends on previous check
+
+ return res;
+ }
+
+ static int[] m15_dummy = new int[10];
+ @Args({2, 0})
+ static int m15(int[] array, int i, boolean ignore) {
+ int res = 0;
+ res += array[i];
+
+ // When the loop is optimized out we don't want the
+ // array[i-1] access which is dependent on array[i]'s
+ // range check to become dependent on the identical range
+ // check above.
+
+ int[] array2 = m15_dummy;
+ int j = 0;
+ for (; j < 10; j++);
+ if (j == 10) {
+ array2 = array;
+ }
+
+ res += array2[i-2];
+ res += array2[i];
+ res += array2[i-1]; // range check removed so i-1 array access depends on previous check
+
+ return res;
+ }
+
+ @Args({2, 0})
+ static int m16(int[] array, int i, boolean ignore) {
+ int res = 0;
+
+ res += array[i];
+ res += array[i-1];
+ res += array[i-1];
+ res += array[i-2];
+
+ return res;
+ }
+
+ @Args({2, 0})
+ static int m17(int[] array, int i, boolean ignore) {
+ int res = 0;
+
+ res += array[i];
+ res += array[i-2];
+ res += array[i-2];
+ res += array[i+2];
+ res += array[i+2];
+ res += array[i-1];
+ res += array[i-1];
+
+ return res;
+ }
+
+ static public void main(String[] args) {
+ if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) {
+ throw new AssertionError("Background compilation enabled");
+ }
+ new TestRangeCheckSmearing().doTests();
+ }
+ boolean success = true;
+ boolean exception = false;
+ final int[] array = new int[10];
+ final HashMap<String,Method> tests = new HashMap<>();
+ {
+ final Class<?> TEST_PARAM_TYPES[] = { int[].class, int.class, boolean.class };
+ for (Method m : this.getClass().getDeclaredMethods()) {
+ if (m.getName().matches("m[0-9]+")) {
+ assert(Modifier.isStatic(m.getModifiers())) : m;
+ assert(m.getReturnType() == int.class) : m;
+ assert(Arrays.equals(m.getParameterTypes(), TEST_PARAM_TYPES)) : m;
+ tests.put(m.getName(), m);
+ }
+ }
+ }
+
+ void invokeTest(Method m, int[] array, int index, boolean z) {
+ try {
+ m.invoke(null, array, index, z);
+ } catch (ReflectiveOperationException roe) {
+ Throwable ex = roe.getCause();
+ if (ex instanceof ArrayIndexOutOfBoundsException)
+ throw (ArrayIndexOutOfBoundsException) ex;
+ throw new AssertionError(roe);
+ }
+ }
+
+ void doTest(String name) {
+ Method m = tests.get(name);
+ tests.remove(name);
+ int[] args = m.getAnnotation(Args.class).value();
+ int index0 = args[0], index1;
+ boolean exceptionRequired = true;
+ if (args.length == 2) {
+ index1 = args[1];
+ } else {
+ // no negative test for this one
+ assert(args.length == 1);
+ assert(name.equals("m13"));
+ exceptionRequired = false;
+ index1 = index0;
+ }
+ // Get the method compiled.
+ if (!WHITE_BOX.isMethodCompiled(m)) {
+ // If not, try to compile it with C2
+ if(!WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) {
+ // C2 compiler not available, try to compile with C1
+ WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
+ }
+ }
+ if (!WHITE_BOX.isMethodCompiled(m)) {
+ throw new RuntimeException(m + " not compiled");
+ }
+
+ // valid access
+ invokeTest(m, array, index0, true);
+
+ if (!WHITE_BOX.isMethodCompiled(m)) {
+ throw new RuntimeException(m + " deoptimized on valid array access");
+ }
+
+ exception = false;
+ boolean test_success = true;
+ try {
+ invokeTest(m, array, index1, false);
+ } catch(ArrayIndexOutOfBoundsException aioob) {
+ exception = true;
+ System.out.println("ArrayIndexOutOfBoundsException thrown in "+name);
+ }
+ if (!exception) {
+ System.out.println("ArrayIndexOutOfBoundsException was not thrown in "+name);
+ }
+
+ if (Platform.isServer()) {
+ if (exceptionRequired == WHITE_BOX.isMethodCompiled(m)) {
+ System.out.println((exceptionRequired?"Didn't deoptimized":"deoptimized") + " in "+name);
+ test_success = false;
+ }
+ }
+
+ if (exception != exceptionRequired) {
+ System.out.println((exceptionRequired?"exception required but not thrown":"not exception required but thrown") + " in "+name);
+ test_success = false;
+ }
+
+ if (!test_success) {
+ success = false;
+ System.out.println("TEST FAILED: "+name);
+ }
+
+ }
+ void doTests() {
+ doTest("m1");
+ doTest("m2");
+ doTest("m3");
+ doTest("m4");
+ doTest("m5");
+ doTest("m6");
+ doTest("m7");
+ doTest("m8");
+ doTest("m9");
+ doTest("m10");
+ doTest("m11");
+ doTest("m12");
+ doTest("m13");
+ doTest("m14");
+ doTest("m15");
+ doTest("m16");
+ doTest("m17");
+ if (!success) {
+ throw new RuntimeException("Some tests failed");
+ }
+ assert(tests.isEmpty()) : tests;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckSmearingLoopOpts.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * 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 8048170
+ * @summary Following range check smearing, range check cannot be replaced by dominating identical test.
+ * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearingLoopOpts
+ *
+ */
+public class TestRangeCheckSmearingLoopOpts {
+
+ static int dummy;
+
+ static int m1(int[] array, int i) {
+ for (;;) {
+ for (;;) {
+ if (array[i] < 0) { // range check (i+0) dominates equivalent check below
+ break;
+ }
+ i++;
+ }
+
+ // A control flow that stops IfNode::up_one_dom()
+ if ((i % 2)== 0) {
+ if ((array[i] % 2) == 0) {
+ dummy = i;
+ }
+ }
+
+ // IfNode::Ideal will rewrite some range checks if Compile::allow_range_check_smearing
+ if (array[i-1] == 9) { // range check (i-1) unchanged
+ int res = array[i-3]; // range check (i-3) unchanged
+ res += array[i]; // range check (i+0) unchanged
+ res += array[i-2]; // removed redundant range check
+ // the previous access might be hoisted by
+ // PhaseIdealLoop::split_if_with_blocks_post because
+ // it appears to have the same guard, but it also
+ // depends on the previous guards
+ return res;
+ }
+ i++;
+ }
+ }
+
+ static public void main(String[] args) {
+ int[] array = { 0, 1, 2, -3, 4, 5, -2, 7, 8, 9, -1 };
+ for (int i = 0; i < 20000; i++) {
+ m1(array, 0);
+ }
+ array[0] = -1;
+ try {
+ m1(array, 0);
+ } catch(ArrayIndexOutOfBoundsException aioobe) {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/uncommontrap/TestDeoptOOM.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,426 @@
+/*
+ * 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 6898462
+ * @summary failed reallocations of scalar replaced objects during deoptimization causes crash
+ * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=exclude,TestDeoptOOM::main -XX:CompileCommand=exclude,TestDeoptOOM::m9_1 -Xmx128M TestDeoptOOM
+ *
+ */
+
+public class TestDeoptOOM {
+
+ long f1;
+ long f2;
+ long f3;
+ long f4;
+ long f5;
+
+ static class LinkedList {
+ LinkedList l;
+ long[] array;
+ LinkedList(LinkedList l, int size) {
+ array = new long[size];
+ this.l = l;
+ }
+ }
+
+ static LinkedList ll;
+
+ static void consume_all_memory() {
+ int size = 128 * 1024 * 1024;
+ while(size > 0) {
+ try {
+ while(true) {
+ ll = new LinkedList(ll, size);
+ }
+ } catch(OutOfMemoryError oom) {
+ }
+ size = size / 2;
+ }
+ }
+
+ static void free_memory() {
+ ll = null;
+ }
+
+ static TestDeoptOOM m1(boolean deopt) {
+ try {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ if (deopt) {
+ return tdoom;
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m1");
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m2_1(boolean deopt) {
+ try {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ if (deopt) {
+ return tdoom;
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m2_1");
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m2(boolean deopt) {
+ try {
+ return m2_1(deopt);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m2");
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m3_3(boolean deopt) {
+ try {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ if (deopt) {
+ return tdoom;
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m3_3");
+ }
+ return null;
+ }
+
+ static boolean m3_2(boolean deopt) {
+ try {
+ return m3_3(deopt) != null;
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m3_2");
+ }
+ return false;
+ }
+
+ static TestDeoptOOM m3_1(boolean deopt) {
+ try {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ if (m3_2(deopt)) {
+ return tdoom;
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m3_1");
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m3(boolean deopt) {
+ try {
+ return m3_1(deopt);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m3");
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m4(boolean deopt) {
+ try {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ if (deopt) {
+ tdoom.f1 = 1l;
+ tdoom.f2 = 2l;
+ tdoom.f3 = 3l;
+ return tdoom;
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m4");
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m5(boolean deopt) {
+ try {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ synchronized(tdoom) {
+ if (deopt) {
+ return tdoom;
+ }
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m5");
+ }
+ return null;
+ }
+
+ synchronized TestDeoptOOM m6_1(boolean deopt) {
+ if (deopt) {
+ return this;
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m6(boolean deopt) {
+ try {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ return tdoom.m6_1(deopt);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m6");
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m7_1(boolean deopt, Object lock) {
+ try {
+ synchronized(lock) {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ if (deopt) {
+ return tdoom;
+ }
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m7_1");
+ }
+ return null;
+ }
+
+ static TestDeoptOOM m7(boolean deopt, Object lock) {
+ try {
+ return m7_1(deopt, lock);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m7");
+ }
+ return null;
+ }
+
+ static class A {
+ long f1;
+ long f2;
+ long f3;
+ long f4;
+ long f5;
+ }
+
+ static class B {
+ long f1;
+ long f2;
+ long f3;
+ long f4;
+ long f5;
+
+ A a;
+ }
+
+ static B m8(boolean deopt) {
+ try {
+ A a = new A();
+ B b = new B();
+ b.a = a;
+ if (deopt) {
+ return b;
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m8");
+ }
+ return null;
+ }
+
+ static void m9_1(int i) {
+ if (i > 90000) {
+ consume_all_memory();
+ }
+ }
+
+ static TestDeoptOOM m9() {
+ try {
+ for (int i = 0; i < 100000; i++) {
+ TestDeoptOOM tdoom = new TestDeoptOOM();
+ m9_1(i);
+ if (i > 90000) {
+ return tdoom;
+ }
+ }
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in m1");
+ }
+ return null;
+ }
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 20000; i++) {
+ m1(false);
+ }
+
+ consume_all_memory();
+
+ try {
+ m1(true);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main " + oom.getMessage());
+ }
+
+ free_memory();
+
+ for (int i = 0; i < 20000; i++) {
+ m2(false);
+ }
+
+ consume_all_memory();
+
+ try {
+ m2(true);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main");
+ }
+
+ free_memory();
+
+ for (int i = 0; i < 20000; i++) {
+ m3(false);
+ }
+
+ consume_all_memory();
+
+ try {
+ m3(true);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main");
+ }
+
+ free_memory();
+
+ for (int i = 0; i < 20000; i++) {
+ m4(false);
+ }
+
+ consume_all_memory();
+
+ try {
+ m4(true);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main");
+ }
+
+ free_memory();
+
+ for (int i = 0; i < 20000; i++) {
+ m5(false);
+ }
+
+ consume_all_memory();
+
+ try {
+ m5(true);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main");
+ }
+
+ free_memory();
+
+ for (int i = 0; i < 20000; i++) {
+ m6(false);
+ }
+
+ consume_all_memory();
+
+ try {
+ m6(true);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main");
+ }
+
+ free_memory();
+
+ final Object lock = new Object();
+
+ for (int i = 0; i < 20000; i++) {
+ m7(false, lock);
+ }
+
+ consume_all_memory();
+
+ try {
+ m7(true, lock);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main");
+ }
+
+ free_memory();
+
+ Thread thread = new Thread() {
+ public void run() {
+ System.out.println("Acquiring lock");
+ synchronized(lock) {
+ System.out.println("Lock acquired");
+ }
+ System.out.println("Lock released");
+ }
+ };
+ thread.start();
+ try {
+ thread.join();
+ } catch(InterruptedException ie) {
+ }
+
+ for (int i = 0; i < 20000; i++) {
+ m8(false);
+ }
+
+ consume_all_memory();
+
+ try {
+ m8(true);
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main");
+ }
+
+ free_memory();
+
+ try {
+ m9();
+ } catch(OutOfMemoryError oom) {
+ free_memory();
+ System.out.println("OOM caught in main");
+ }
+
+ free_memory();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/uncommontrap/TraceDeoptimizationNoRealloc.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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 8067144
+ * @summary -XX:+TraceDeoptimization tries to print realloc'ed objects even when there are none
+ * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:+IgnoreUnrecognizedVMOptions -XX:+TraceDeoptimization TraceDeoptimizationNoRealloc
+ *
+ */
+
+public class TraceDeoptimizationNoRealloc {
+
+ static void m(boolean some_condition) {
+ if (some_condition) {
+ return;
+ }
+ }
+
+
+ static public void main(String[] args) {
+ for (int i = 0; i < 20000; i++) {
+ m(false);
+ }
+ m(true);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestCardTablePageCommits.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+* 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 com.oracle.java.testlibrary.JDKToolFinder;
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+import com.oracle.java.testlibrary.Platform;
+
+/*
+ * @test TestCardTablePageCommits
+ * @key gc
+ * @bug 8059066
+ * @summary Tests that the card table does not commit the same page twice
+ * @library /testlibrary
+ * @run driver TestCardTablePageCommits
+ */
+public class TestCardTablePageCommits {
+ public static void main(String args[]) throws Exception {
+ // The test is run with a small heap to make sure all pages in the card
+ // table gets committed. Need 8 MB heap to trigger the bug on SPARC
+ // because of 8kB pages, assume 4 KB pages for all other CPUs.
+ String Xmx = Platform.isSparc() ? "-Xmx8m" : "-Xmx4m";
+
+ String[] opts = {Xmx, "-XX:NativeMemoryTracking=detail", "-XX:+UseParallelGC", "-version"};
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(opts);
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldHaveExitValue(0);
+ }
+}
--- a/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java Wed Jul 05 20:11:52 2017 +0200
@@ -30,40 +30,96 @@
import com.oracle.java.testlibrary.*;
public class LimitSharedSizes {
+ static enum Region {
+ RO, RW, MD, MC
+ }
+
private static class SharedSizeTestData {
public String optionName;
public String optionValue;
public String expectedErrorMsg;
- public SharedSizeTestData(String name, String value, String msg) {
- optionName = name;
+ public SharedSizeTestData(Region region, String value, String msg) {
+ optionName = getName(region);
optionValue = value;
expectedErrorMsg = msg;
}
+
+ public SharedSizeTestData(Region region, String msg) {
+ optionName = getName(region);
+ optionValue = getValue(region);
+ expectedErrorMsg = msg;
+ }
+
+ private String getName(Region region) {
+ String name;
+ switch (region) {
+ case RO:
+ name = "-XX:SharedReadOnlySize";
+ break;
+ case RW:
+ name = "-XX:SharedReadWriteSize";
+ break;
+ case MD:
+ name = "-XX:SharedMiscDataSize";
+ break;
+ case MC:
+ name = "-XX:SharedMiscCodeSize";
+ break;
+ default:
+ name = "Unknown";
+ break;
+ }
+ return name;
+ }
+
+ private String getValue(Region region) {
+ String value;
+ switch (region) {
+ case RO:
+ value = Platform.is64bit() ? "9M" : "8M";
+ break;
+ case RW:
+ value = Platform.is64bit() ? "12M" : "7M";
+ break;
+ case MD:
+ value = Platform.is64bit() ? "4M" : "2M";
+ break;
+ case MC:
+ value = "120k";
+ break;
+ default:
+ value = "0M";
+ break;
+ }
+ return value;
+ }
}
private static final SharedSizeTestData[] testTable = {
- // values in this part of the test table should cause failure
- // (shared space sizes are deliberately too small)
- new SharedSizeTestData("-XX:SharedReadOnlySize", "4M", "read only"),
- new SharedSizeTestData("-XX:SharedReadWriteSize","4M", "read write"),
-
- // Known issue, JDK-8038422 (assert() on Windows)
- // new SharedSizeTestData("-XX:SharedMiscDataSize", "500k", "miscellaneous data"),
-
- // Too small of a misc code size should not cause a vm crash.
- // It should result in the following error message:
+ // Too small of a region size should not cause a vm crash.
+ // It should result in an error message like the following:
// The shared miscellaneous code space is not large enough
// to preload requested classes. Use -XX:SharedMiscCodeSize=
// to increase the initial size of shared miscellaneous code space.
- new SharedSizeTestData("-XX:SharedMiscCodeSize", "20k", "miscellaneous code"),
+ new SharedSizeTestData(Region.RO, "4M", "read only"),
+ new SharedSizeTestData(Region.RW, "4M", "read write"),
+ new SharedSizeTestData(Region.MD, "50k", "miscellaneous data"),
+ new SharedSizeTestData(Region.MC, "20k", "miscellaneous code"),
// these values are larger than default ones, but should
// be acceptable and not cause failure
- new SharedSizeTestData("-XX:SharedReadOnlySize", "20M", null),
- new SharedSizeTestData("-XX:SharedReadWriteSize", "20M", null),
- new SharedSizeTestData("-XX:SharedMiscDataSize", "20M", null),
- new SharedSizeTestData("-XX:SharedMiscCodeSize", "20M", null)
+ new SharedSizeTestData(Region.RO, "20M", null),
+ new SharedSizeTestData(Region.RW, "20M", null),
+ new SharedSizeTestData(Region.MD, "20M", null),
+ new SharedSizeTestData(Region.MC, "20M", null),
+
+ // test with sizes which just meet the minimum required sizes
+ // the following tests also attempt to use the shared archive
+ new SharedSizeTestData(Region.RO, "UseArchive"),
+ new SharedSizeTestData(Region.RW, "UseArchive"),
+ new SharedSizeTestData(Region.MD, "UseArchive"),
+ new SharedSizeTestData(Region.MC, "UseArchive")
};
public static void main(String[] args) throws Exception {
@@ -82,10 +138,39 @@
OutputAnalyzer output = new OutputAnalyzer(pb.start());
if (td.expectedErrorMsg != null) {
- output.shouldContain("The shared " + td.expectedErrorMsg
- + " space is not large enough");
+ if (!td.expectedErrorMsg.equals("UseArchive")) {
+ output.shouldContain("The shared " + td.expectedErrorMsg
+ + " space is not large enough");
+
+ output.shouldHaveExitValue(2);
+ } else {
+ output.shouldNotContain("space is not large enough");
+ output.shouldHaveExitValue(0);
+
+ // try to use the archive
+ pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:SharedArchiveFile=./" + fileName,
+ "-XX:+PrintSharedArchiveAndExit",
+ "-version");
- output.shouldHaveExitValue(2);
+ try {
+ output = new OutputAnalyzer(pb.start());
+ output.shouldContain("archive is valid");
+ } catch (RuntimeException e) {
+ // if sharing failed due to ASLR or similar reasons,
+ // check whether sharing was attempted at all (UseSharedSpaces)
+ if ((output.getOutput().contains("Unable to use shared archive") ||
+ output.getOutput().contains("Unable to map ReadOnly shared space at required address.") ||
+ output.getOutput().contains("Unable to map ReadWrite shared space at required address.") ||
+ output.getOutput().contains("Unable to reserve shared space at required address")) &&
+ output.getExitValue() == 1) {
+ System.out.println("Unable to use shared archive: test not executed; assumed passed");
+ return;
+ }
+ }
+ output.shouldHaveExitValue(0);
+ }
} else {
output.shouldNotContain("space is not large enough");
output.shouldHaveExitValue(0);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,83 @@
+/*
+ * 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 8066670
+ * @summary Testing -XX:+PrintSharedArchiveAndExit option
+ * @library /testlibrary
+ */
+
+import com.oracle.java.testlibrary.*;
+
+public class PrintSharedArchiveAndExit {
+ public static void main(String[] args) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ try {
+ output.shouldContain("Loading classes to share");
+ output.shouldHaveExitValue(0);
+
+ // (1) With a valid archive
+ pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
+ "-XX:+PrintSharedArchiveAndExit", "-version");
+ output = new OutputAnalyzer(pb.start());
+ output.shouldContain("archive is valid");
+ output.shouldNotContain("java version"); // Should not print JVM version
+ output.shouldHaveExitValue(0); // Should report success in error code.
+
+ pb = ProcessTools.createJavaProcessBuilder(
+ "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
+ "-XX:+PrintSharedArchiveAndExit");
+ output = new OutputAnalyzer(pb.start());
+ output.shouldContain("archive is valid");
+ output.shouldNotContain("Usage:"); // Should not print JVM help message
+ output.shouldHaveExitValue(0); // Should report success in error code.
+
+ // (2) With an invalid archive (boot class path has been prepended)
+ pb = ProcessTools.createJavaProcessBuilder(
+ "-Xbootclasspath/p:foo.jar",
+ "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
+ "-XX:+PrintSharedArchiveAndExit", "-version");
+ output = new OutputAnalyzer(pb.start());
+ output.shouldContain("archive is invalid");
+ output.shouldNotContain("java version"); // Should not print JVM version
+ output.shouldHaveExitValue(1); // Should report failure in error code.
+
+ pb = ProcessTools.createJavaProcessBuilder(
+ "-Xbootclasspath/p:foo.jar",
+ "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
+ "-XX:+PrintSharedArchiveAndExit");
+ output = new OutputAnalyzer(pb.start());
+ output.shouldContain("archive is invalid");
+ output.shouldNotContain("Usage:"); // Should not print JVM help message
+ output.shouldHaveExitValue(1); // Should report failure in error code.
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ output.shouldContain("Unable to use shared archive");
+ output.shouldHaveExitValue(1);
+ }
+ }
+}
--- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Wed Jul 05 20:11:52 2017 +0200
@@ -41,12 +41,12 @@
public class Test8028623 {
- public static int à = 1;
+ public static int \u00CB = 1;
public static String dumpFile = "heap.out";
public static void main (String[] args) {
- System.out.println(Ã);
+ System.out.println(\u00CB);
try {
if (!Platform.shouldSAAttach()) {
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Thu Dec 18 19:57:48 2014 -0800
+++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Wed Jul 05 20:11:52 2017 +0200
@@ -153,6 +153,14 @@
public native int getMethodEntryBci(Executable method);
public native Object[] getNMethod(Executable method, boolean isOsr);
public native long allocateCodeBlob(int size, int type);
+ public long allocateCodeBlob(long size, int type) {
+ int intSize = (int) size;
+ if ((long) intSize != size || size < 0) {
+ throw new IllegalArgumentException(
+ "size argument has illegal value " + size);
+ }
+ return allocateCodeBlob( intSize, type);
+ }
public native void freeCodeBlob(long addr);
public void forceNMethodSweep() {
try {
--- a/jdk/.hgtags Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/.hgtags Wed Jul 05 20:11:52 2017 +0200
@@ -285,3 +285,4 @@
f1ed1540da70a066527fd043413107e47721edbf jdk9-b40
e336cbd8b15e959e70ed02f0f5e93fa76ebd4c07 jdk9-b41
6b2314173433467245261364a52fb8e347fe6342 jdk9-b42
+8c6ad41974f9ab6c33d544b088648314963f2a50 jdk9-b43
--- a/jdk/make/src/classes/build/tools/module/ModuleArchive.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/make/src/classes/build/tools/module/ModuleArchive.java Wed Jul 05 20:11:52 2017 +0200
@@ -227,10 +227,12 @@
private static String nativeDir(String filename) {
if (System.getProperty("os.name").startsWith("Windows")) {
- if (filename.endsWith(".dll"))
+ if (filename.endsWith(".dll") || filename.endsWith(".diz")
+ || filename.endsWith(".pdb") || filename.endsWith(".map")) {
return "bin";
- else
+ } else {
return "lib";
+ }
} else {
return "lib";
}
--- a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java Wed Jul 05 20:11:52 2017 +0200
@@ -758,8 +758,8 @@
if (endYear == Year.MAX_VALUE) {
endYear = startYear;
lastRules.add(new TransRule(endYear, rule));
- lastRulesStartYear = Math.max(startYear, lastRulesStartYear);
}
+ lastRulesStartYear = Math.max(startYear, lastRulesStartYear);
} else {
if (endYear == Year.MAX_VALUE) {
//endYear = zoneEnd.getYear();
--- a/jdk/src/demo/share/java2d/J2DBench/options/default.opt Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/java2d/J2DBench/options/default.opt Wed Jul 05 20:11:52 2017 +0200
@@ -5,33 +5,53 @@
global.env.runcount=5
global.env.repcount=0
global.env.testtime=2500
+global.results.workunits=units
+global.results.timeunits=sec
+global.results.ratio=unitspersec
global.dest.screen=disabled
global.dest.offscreen=disabled
global.dest.compatimg.compatimg=disabled
global.dest.compatimg.opqcompatimg=disabled
global.dest.compatimg.bmcompatimg=disabled
global.dest.compatimg.transcompatimg=disabled
-global.dest.volimg=enabled
+global.dest.volimg.volimg=enabled
+global.dest.volimg.opqvolimg=disabled
+global.dest.volimg.bmvolimg=disabled
+global.dest.volimg.transvolimg=disabled
global.dest.bufimg.IntXrgb=disabled
global.dest.bufimg.IntArgb=disabled
+global.dest.bufimg.IntArgbPre=disabled
+global.dest.bufimg.3ByteBgr=disabled
global.dest.bufimg.ByteIndexed=disabled
global.dest.bufimg.ByteGray=disabled
+global.dest.bufimg.4ByteAbgr=disabled
+global.dest.bufimg.4ByteAbgrPre=disabled
+global.dest.bufimg.custom=disabled
graphics.opts.anim=2
graphics.opts.sizes=20,250
graphics.opts.alpharule=SrcOver
+graphics.opts.transform=ident
graphics.opts.extraalpha=Both
graphics.opts.xormode=Off
graphics.opts.clip=Both
graphics.opts.renderhint=Default
-graphics.render.opts.randomcolor=Both
+graphics.render.opts.paint=single,random
graphics.render.opts.alphacolor=Off
graphics.render.opts.antialias=Both
+graphics.render.opts.stroke=width1
graphics.render.tests.drawLine=enabled
+graphics.render.tests.drawLineHoriz=disabled
+graphics.render.tests.drawLineVert=disabled
graphics.render.tests.fillRect=enabled
+graphics.render.tests.drawRect=disabled
graphics.render.tests.fillOval=enabled
+graphics.render.tests.drawOval=disabled
graphics.render.tests.fillPoly=disabled
graphics.render.tests.drawPoly=disabled
graphics.render.tests.shape.fillCubic=enabled
+graphics.render.tests.shape.drawCubic=disabled
+graphics.render.tests.shape.fillEllipse2D=disabled
+graphics.render.tests.shape.drawEllipse2D=disabled
graphics.imaging.src.offscr.opaque=disabled
graphics.imaging.src.offscr.bitmask=disabled
graphics.imaging.src.offscr.translucent=disabled
@@ -44,33 +64,98 @@
graphics.imaging.src.transcompatimg.opaque=disabled
graphics.imaging.src.transcompatimg.bitmask=disabled
graphics.imaging.src.transcompatimg.translucent=enabled
-graphics.imaging.src.volimg.opaque=disabled
-graphics.imaging.src.volimg.bitmask=disabled
-graphics.imaging.src.volimg.translucent=disabled
+graphics.imaging.src.opqvolimg.opaque=disabled
+graphics.imaging.src.opqvolimg.bitmask=disabled
+graphics.imaging.src.opqvolimg.translucent=disabled
+graphics.imaging.src.bmvolimg.opaque=disabled
+graphics.imaging.src.bmvolimg.bitmask=disabled
+graphics.imaging.src.bmvolimg.translucent=disabled
+graphics.imaging.src.transvolimg.opaque=disabled
+graphics.imaging.src.transvolimg.bitmask=disabled
+graphics.imaging.src.transvolimg.translucent=disabled
graphics.imaging.src.bufimg.IntXrgb.opaque=enabled
graphics.imaging.src.bufimg.IntXrgb.bitmask=disabled
graphics.imaging.src.bufimg.IntXrgb.translucent=disabled
graphics.imaging.src.bufimg.IntArgb.opaque=disabled
graphics.imaging.src.bufimg.IntArgb.bitmask=disabled
graphics.imaging.src.bufimg.IntArgb.translucent=enabled
+graphics.imaging.src.bufimg.IntArgbPre.opaque=disabled
+graphics.imaging.src.bufimg.IntArgbPre.bitmask=disabled
+graphics.imaging.src.bufimg.IntArgbPre.translucent=disabled
graphics.imaging.src.bufimg.ByteGray.opaque=disabled
graphics.imaging.src.bufimg.ByteGray.bitmask=disabled
graphics.imaging.src.bufimg.ByteGray.translucent=disabled
+graphics.imaging.src.bufimg.3ByteBgr.opaque=disabled
+graphics.imaging.src.bufimg.3ByteBgr.bitmask=disabled
+graphics.imaging.src.bufimg.3ByteBgr.translucent=disabled
+graphics.imaging.src.bufimg.4ByteAbgr.opaque=disabled
+graphics.imaging.src.bufimg.4ByteAbgr.bitmask=disabled
+graphics.imaging.src.bufimg.4ByteAbgr.translucent=disabled
+graphics.imaging.src.bufimg.4ByteAbgrPre.opaque=disabled
+graphics.imaging.src.bufimg.4ByteAbgrPre.bitmask=disabled
+graphics.imaging.src.bufimg.4ByteAbgrPre.translucent=disabled
graphics.imaging.src.bufimg.ByteIndexedBm.opaque=disabled
graphics.imaging.src.bufimg.ByteIndexedBm.bitmask=disabled
graphics.imaging.src.bufimg.ByteIndexedBm.translucent=disabled
-graphics.imaging.tests.drawimage=enabled
-graphics.imaging.tests.drawimagebg=disabled
-graphics.imaging.tests.drawimagescaleup=enabled
-graphics.imaging.tests.drawimagescaledown=disabled
-graphics.imaging.tests.drawimagetxform=enabled
+graphics.imaging.src.bufimg.unmanagedIntXrgb.opaque=disabled
+graphics.imaging.src.bufimg.unmanagedIntXrgb.bitmask=disabled
+graphics.imaging.src.bufimg.unmanagedIntXrgb.translucent=disabled
+graphics.imaging.src.bufimg.unmanagedIntArgb.opaque=disabled
+graphics.imaging.src.bufimg.unmanagedIntArgb.bitmask=disabled
+graphics.imaging.src.bufimg.unmanagedIntArgb.translucent=disabled
+graphics.imaging.src.bufimg.unmanagedIntArgbPre.opaque=disabled
+graphics.imaging.src.bufimg.unmanagedIntArgbPre.bitmask=disabled
+graphics.imaging.src.bufimg.unmanagedIntArgbPre.translucent=disabled
+graphics.imaging.src.bufimg.unmanaged3ByteBgr.opaque=disabled
+graphics.imaging.src.bufimg.unmanaged3ByteBgr.bitmask=disabled
+graphics.imaging.src.bufimg.unmanaged3ByteBgr.translucent=disabled
+graphics.imaging.benchmarks.opts.interpolation=Nearest neighbor
+graphics.imaging.benchmarks.opts.touchsrc=Off
+graphics.imaging.benchmarks.tests.drawimage=enabled
+graphics.imaging.benchmarks.tests.drawimagebg=disabled
+graphics.imaging.benchmarks.tests.drawimagescaleup=enabled
+graphics.imaging.benchmarks.tests.drawimagescaledown=disabled
+graphics.imaging.benchmarks.tests.drawimagescalesplit=disabled
+graphics.imaging.benchmarks.tests.drawimagetxform=enabled
+graphics.imaging.imageops.opts.op=convolve3x3zero
+graphics.imaging.imageops.tests.graphics2d.drawimageop=disabled
+graphics.imaging.imageops.tests.bufimgop.filternull=disabled
+graphics.imaging.imageops.tests.bufimgop.filtercached=disabled
+graphics.imaging.imageops.tests.rasterop.filternull=disabled
+graphics.imaging.imageops.tests.rasterop.filtercached=disabled
+graphics.misc.copytests.copyAreaVert=disabled
+graphics.misc.copytests.copyAreaHoriz=disabled
+graphics.misc.copytests.copyAreaDiag=disabled
+pixel.opts.renderto=Off
+pixel.opts.renderfrom=Off
+pixel.src.1BitBinary=disabled
+pixel.src.2BitBinary=disabled
+pixel.src.4BitBinary=disabled
+pixel.src.ByteIndexed=disabled
+pixel.src.ByteGray=disabled
+pixel.src.Short555=disabled
+pixel.src.Short565=disabled
+pixel.src.ShortGray=disabled
+pixel.src.3ByteBgr=disabled
+pixel.src.4ByteAbgr=disabled
+pixel.src.IntXrgb=disabled
+pixel.src.IntXbgr=disabled
+pixel.src.IntArgb=disabled
+pixel.bimgtests.getrgb=disabled
+pixel.bimgtests.setrgb=disabled
+pixel.rastests.getdataelem=disabled
+pixel.rastests.setdataelem=disabled
+pixel.rastests.getpixel=disabled
+pixel.rastests.setpixel=disabled
+pixel.dbtests.getelem=disabled
+pixel.dbtests.setelem=disabled
text.opts.data.tlength=32
text.opts.data.tscript=english
text.opts.font.fname=lucida
text.opts.font.fstyle=0
text.opts.font.fsize=13.0
text.opts.font.ftx=Identity
-text.opts.graphics.taa=Both
+text.opts.graphics.textaa=Off,On
text.opts.graphics.tfm=Off
text.opts.graphics.gaa=Off
text.opts.graphics.gtx=Identity
@@ -114,3 +199,66 @@
text.construction.tests.gvfromfontlayout=disabled
text.construction.tests.tlfromfont=disabled
text.construction.tests.tlfrommap=disabled
+imageio.opts.size=250
+imageio.opts.content=photo
+imageio.input.opts.general.source.file=disabled
+imageio.input.opts.general.source.url=disabled
+imageio.input.opts.general.source.byteArray=disabled
+imageio.input.opts.imageio.useCache=Off
+imageio.input.image.toolkit.opts.format=
+imageio.input.image.toolkit.tests.createImage=disabled
+imageio.input.image.imageio.opts.format=
+imageio.input.image.imageio.tests.imageioRead=disabled
+imageio.input.image.imageio.reader.opts.seekForwardOnly=On
+imageio.input.image.imageio.reader.opts.ignoreMetadata=On
+imageio.input.image.imageio.reader.opts.installListener=Off
+imageio.input.image.imageio.reader.tests.read=disabled
+imageio.input.image.imageio.reader.tests.getImageMetadata=disabled
+imageio.input.stream.tests.construct=disabled
+imageio.input.stream.tests.read=disabled
+imageio.input.stream.tests.readByteArray=disabled
+imageio.input.stream.tests.readFullyByteArray=disabled
+imageio.input.stream.tests.readBit=disabled
+imageio.input.stream.tests.readByte=disabled
+imageio.input.stream.tests.readUnsignedByte=disabled
+imageio.input.stream.tests.readShort=disabled
+imageio.input.stream.tests.readUnsignedShort=disabled
+imageio.input.stream.tests.readInt=disabled
+imageio.input.stream.tests.readUnsignedInt=disabled
+imageio.input.stream.tests.readFloat=disabled
+imageio.input.stream.tests.readLong=disabled
+imageio.input.stream.tests.readDouble=disabled
+imageio.input.stream.tests.skipBytes=disabled
+imageio.output.opts.general.dest.file=disabled
+imageio.output.opts.general.dest.byteArray=disabled
+imageio.output.opts.imageio.useCache=Off
+imageio.output.image.imageio.opts.format=
+imageio.output.image.imageio.tests.imageioWrite=disabled
+imageio.output.image.imageio.writer.opts.installListener=Off
+imageio.output.image.imageio.writer.tests.write=disabled
+imageio.output.stream.tests.construct=disabled
+imageio.output.stream.tests.write=disabled
+imageio.output.stream.tests.writeByteArray=disabled
+imageio.output.stream.tests.writeBit=disabled
+imageio.output.stream.tests.writeByte=disabled
+imageio.output.stream.tests.writeShort=disabled
+imageio.output.stream.tests.writeInt=disabled
+imageio.output.stream.tests.writeFloat=disabled
+imageio.output.stream.tests.writeLong=disabled
+imageio.output.stream.tests.writeDouble=disabled
+cmm.opts.profiles=1001
+cmm.colorconv.data.fromRGB=disabled
+cmm.colorconv.data.toRGB=disabled
+cmm.colorconv.data.fromCIEXYZ=disabled
+cmm.colorconv.data.toCIEXYZ=disabled
+cmm.colorconv.ccop.ccopOptions.size=250
+cmm.colorconv.ccop.ccopOptions.content=photo
+cmm.colorconv.ccop.ccopOptions.srcType=INT_ARGB
+cmm.colorconv.ccop.ccopOptions.dstType=INT_ARGB
+cmm.colorconv.ccop.op_img=disabled
+cmm.colorconv.ccop.op_rst=disabled
+cmm.colorconv.ccop.op_draw=disabled
+cmm.colorconv.embed.embedOptions.Images=512x512
+cmm.colorconv.embed.embd_img_read=disabled
+cmm.profiles.getHeader=disabled
+cmm.profiles.getNumComponents=disabled
--- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/Destinations.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/Destinations.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -57,6 +57,7 @@
public static Group.EnableSet destroot;
public static Group bufimgdestroot;
public static Group compatimgdestroot;
+ public static Group volimgdestroot;
public static void init() {
destroot = new Group.EnableSet(TestEnvironment.globaloptroot,
@@ -79,7 +80,16 @@
}
if (ImageTests.hasVolatileImage) {
+ volimgdestroot = new Group.EnableSet(destroot, "volimg",
+ "Output to Volatile Image");
+
+ volimgdestroot.setHorizontal();
new VolatileImg();
+ if (ImageTests.hasTransparentVolatileImage) {
+ new VolatileImg(Transparency.OPAQUE);
+ new VolatileImg(Transparency.BITMASK);
+ new VolatileImg(Transparency.TRANSLUCENT);
+ }
}
bufimgdestroot = new Group.EnableSet(destroot, "bufimg",
@@ -91,6 +101,8 @@
new BufImg(BufferedImage.TYPE_3BYTE_BGR);
new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
new BufImg(BufferedImage.TYPE_BYTE_GRAY);
+ new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
+ new BufImg(BufferedImage.TYPE_4BYTE_ABGR_PRE);
new CustomImg();
}
}
@@ -206,18 +218,62 @@
}
public static class VolatileImg extends Destinations {
+ private final int transparency;
+
+ public static final String[] ShortNames = {
+ "volimg",
+ "opqvolimg",
+ "bmvolimg",
+ "transvolimg",
+ };
+
+ public static final String[] ShortDescriptions = {
+ "Default",
+ "Opaque",
+ "Bitmask",
+ "Translucent",
+ };
+
+ public static final String[] LongDescriptions = {
+ "Default VolatileImg Image",
+ "Opaque VolatileImg Image",
+ "Bitmask VolatileImg Image",
+ "Translucent VolatileImg Image",
+ };
+
+ public static final String[] ModifierNames = {
+ "VolatileImg()",
+ "VolatileImg(Opaque)",
+ "VolatileImg(Bitmask)",
+ "VolatileImg(Translucent)",
+ };
+
public VolatileImg() {
- super(destroot, "volimg", "Output to Volatile Image", false);
+ this(0);
}
- public String getModifierValueName(Object val) {
- return "VolatileImg";
+ public VolatileImg(final int transparency) {
+ super(volimgdestroot,
+ ShortNames[transparency],
+ ShortDescriptions[transparency],
+ false);
+ this.transparency = transparency;
}
- public void setDestination(TestEnvironment env) {
+ public String getModifierValueName(final Object val) {
+ return ModifierNames[transparency];
+ }
+
+ public void setDestination(final TestEnvironment env) {
Component c = env.getCanvas();
- env.setTestImage(c.createVolatileImage(env.getWidth(),
- env.getHeight()));
+ GraphicsConfiguration gc = c.getGraphicsConfiguration();
+ int w = env.getWidth();
+ int h = env.getHeight();
+ if (transparency == 0) {
+ env.setTestImage(gc.createCompatibleVolatileImage(w, h));
+ } else {
+ env.setTestImage(gc.createCompatibleVolatileImage(w, h, transparency));
+ }
}
}
--- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/Group.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/Group.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -44,6 +44,7 @@
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.border.TitledBorder;
import java.util.NoSuchElementException;
@@ -199,7 +200,7 @@
p.add(comp);
}
}
- return p;
+ return new JScrollPane(p);
}
}
--- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java Wed Jul 05 20:11:52 2017 +0200
@@ -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.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -60,6 +60,8 @@
import javax.swing.BoxLayout;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -376,7 +378,11 @@
}
if (gui) {
- startGUI();
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ startGUI();
+ }
+ });
} else {
long start = System.currentTimeMillis();
@@ -772,6 +778,7 @@
f.getContentPane().add(p, BorderLayout.SOUTH);
f.pack();
+ f.setLocationRelativeTo(null);
f.show();
}
--- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -112,10 +112,10 @@
sizeList = new Option.IntList(groptroot, "sizes",
"Size of Operations to perform",
- new int[] {1, 20, 100, 250, 1000},
+ new int[] {1, 20, 100, 250, 1000, 4000},
new String[] {
"1x1", "20x20", "100x100", "250x250",
- "1000x1000",
+ "1000x1000", "4000x4000",
},
new String[] {
"Tiny Shapes (1x1)",
@@ -123,6 +123,7 @@
"Medium Shapes (100x100)",
"Large Shapes (250x250)",
"X-Large Shapes (1000x1000)",
+ "Huge Shapes (4000x4000)",
}, 0xa);
if (hasGraphics2D) {
String rulenames[] = {
--- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/tests/ImageTests.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/tests/ImageTests.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -53,6 +53,7 @@
import java.awt.AlphaComposite;
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
+import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ByteLookupTable;
@@ -77,6 +78,7 @@
public abstract class ImageTests extends GraphicsTests {
public static boolean hasVolatileImage;
+ public static boolean hasTransparentVolatileImage;
public static boolean hasCompatImage;
static {
@@ -89,14 +91,20 @@
hasCompatImage = true;
} catch (NoSuchMethodError e) {
}
+ try {
+ new Canvas().getMousePosition();
+ hasTransparentVolatileImage = true;
+ } catch (NoSuchMethodError e) {
+ }
}
static Group imageroot;
static Group.EnableSet imgsrcroot;
static Group.EnableSet bufimgsrcroot;
+ static Group imgbenchroot;
static Group imgtestroot;
- static Group imgoptionsroot;
+ static Group imgtestOptRoot;
static Group imageOpRoot;
static Group imageOpOptRoot;
@@ -106,6 +114,7 @@
static Group rasterOpTestRoot;
static Option opList;
static Option doTouchSrc;
+ static Option interpolation;
static String transNodeNames[] = {
null, "opaque", "bitmask", "translucent",
@@ -122,19 +131,9 @@
imgsrcroot = new Group.EnableSet(imageroot, "src",
"Image Rendering Sources");
- imgsrcroot.setBordered(true);
-
- imgoptionsroot = new Group(imgsrcroot, "options",
- "Image Source Options");
- imgoptionsroot.setBordered(true);
- doTouchSrc =
- new Option.Toggle(imgoptionsroot, "touchsrc",
- "Touch src image before every operation",
- Option.Toggle.Off);
-
- imgtestroot = new Group(imageroot, "tests",
- "Image Rendering Tests");
- imgtestroot.setBordered(true);
+ imgbenchroot = new Group(imageroot, "benchmarks",
+ "Image Rendering Benchmarks");
+ imgtestOptRoot = new Group(imgbenchroot, "opts", "Options");
new OffScreen();
@@ -144,9 +143,14 @@
new CompatImg(Transparency.BITMASK);
new CompatImg(Transparency.TRANSLUCENT);
}
-
if (hasVolatileImage) {
- new VolatileImg();
+ if (hasTransparentVolatileImage) {
+ new VolatileImg(Transparency.OPAQUE);
+ new VolatileImg(Transparency.BITMASK);
+ new VolatileImg(Transparency.TRANSLUCENT);
+ } else {
+ new VolatileImg();
+ }
}
bufimgsrcroot =
@@ -154,11 +158,15 @@
"BufferedImage Rendering Sources");
new BufImg(BufferedImage.TYPE_INT_RGB);
new BufImg(BufferedImage.TYPE_INT_ARGB);
+ new BufImg(BufferedImage.TYPE_INT_ARGB_PRE);
new BufImg(BufferedImage.TYPE_BYTE_GRAY);
new BufImg(BufferedImage.TYPE_3BYTE_BGR);
+ new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
+ new BufImg(BufferedImage.TYPE_4BYTE_ABGR_PRE);
new BmByteIndexBufImg();
new BufImg(BufferedImage.TYPE_INT_RGB, true);
new BufImg(BufferedImage.TYPE_INT_ARGB, true);
+ new BufImg(BufferedImage.TYPE_INT_ARGB_PRE, true);
new BufImg(BufferedImage.TYPE_3BYTE_BGR, true);
imageOpRoot = new Group(imageroot, "imageops",
@@ -211,12 +219,31 @@
new BufImgOpFilter(true);
new RasterOpFilter(false);
new RasterOpFilter(true);
+
+ String interpolationnames[] = {"Nearest neighbor", "Bilinear",
+ "Bicubic",};
+ interpolation =
+ new ObjectList(imgtestOptRoot, "interpolation",
+ "Interpolation",
+ interpolationnames, new Object[] {
+ RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
+ RenderingHints.VALUE_INTERPOLATION_BILINEAR,
+ RenderingHints.VALUE_INTERPOLATION_BICUBIC,
+ }, interpolationnames, interpolationnames, 1);
}
+ doTouchSrc =
+ new Option.Toggle(imgtestOptRoot, "touchsrc",
+ "Touch source image before every operation",
+ Option.Toggle.Off);
+
+ imgtestroot = new Group(imgbenchroot, "tests", "Image Rendering Tests");
+
new DrawImage();
new DrawImageBg();
new DrawImageScale("up", 1.5f);
new DrawImageScale("down", .75f);
+ new DrawImageScale("split", .5f);
new DrawImageTransform();
}
@@ -236,6 +263,7 @@
super(parent, nodeName, description);
addDependency(imgsrcroot, srcFilter);
addDependency(doTouchSrc);
+ addDependency(interpolation);
}
public GraphicsTests.Context createContext() {
@@ -248,6 +276,11 @@
ictx.src = env.getSrcImage();
ictx.touchSrc = env.isEnabled(doTouchSrc);
+ if (hasGraphics2D) {
+ Graphics2D g2d = (Graphics2D) ctx.graphics;
+ final Object modifier = env.getModifier(interpolation);
+ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, modifier);
+ }
}
public abstract static class TriStateImageType extends Group {
@@ -290,13 +323,27 @@
}
public static class VolatileImg extends TriStateImageType {
+ private final int transparency;
+
public VolatileImg() {
- super(imgsrcroot, "volimg", "Volatile Image", Transparency.OPAQUE);
+ this(0);
+ }
+
+ public VolatileImg(int transparency) {
+ super(imgsrcroot, Destinations.VolatileImg.ShortNames[transparency],
+ Destinations.VolatileImg.LongDescriptions[transparency],
+ transparency);
+ this.transparency = transparency;
}
public Image makeImage(TestEnvironment env, int w, int h) {
Canvas c = env.getCanvas();
- return c.createVolatileImage(w, h);
+ GraphicsConfiguration gc = c.getGraphicsConfiguration();
+ if (transparency == 0) {
+ return gc.createCompatibleVolatileImage(w, h);
+ } else {
+ return gc.createCompatibleVolatileImage(w, h, transparency);
+ }
}
}
--- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/tests/cmm/ColorConvertOpTests.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/tests/cmm/ColorConvertOpTests.java Wed Jul 05 20:11:52 2017 +0200
@@ -60,7 +60,7 @@
public class ColorConvertOpTests extends ColorConversionTests {
private static class ImageContent {
- static ImageContent BLANK = new ImageContent("bank", "Blank (opaque black)");
+ static ImageContent BLANK = new ImageContent("blank", "Blank (opaque black)");
static ImageContent RANDOM = new ImageContent("random", "Random");
static ImageContent VECTOR = new ImageContent("vector", "Vector Art");
static ImageContent PHOTO= new ImageContent("photo", "Photograph");
@@ -83,7 +83,7 @@
static ImageType INT_RGB = new ImageType(BufferedImage.TYPE_INT_RGB, "INT_RGB", "TYPE_INT_RGB");
static ImageType INT_BGR = new ImageType(BufferedImage.TYPE_INT_BGR, "INT_BGR", "TYPE_INT_BGR");
static ImageType BYTE_3BYTE_BGR = new ImageType(BufferedImage.TYPE_3BYTE_BGR, "3BYTE_BGR", "TYPE_3BYTE_BGR");
- static ImageType BYTE_4BYTE_ABGR = new ImageType(BufferedImage.TYPE_4BYTE_ABGR, "4BYTE_BGR", "TYPE_4BYTE_BGR");
+ static ImageType BYTE_4BYTE_ABGR = new ImageType(BufferedImage.TYPE_4BYTE_ABGR, "4BYTE_ABGR", "TYPE_4BYTE_ABGR");
static ImageType COMPATIBLE_DST = new ImageType(0, "Compatible", "Compatible destination");
private ImageType(int type, String abbr, String descr) {
@@ -130,7 +130,7 @@
for (int i = 0; i < num; i++) {
t[i] = allTypes[i];
- names[i] = t[i].toString();
+ names[i] = t[i].abbrev;
abbrev[i] = t[i].abbrev;
descr[i] = t[i].descr;
}
--- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/tests/cmm/EmbeddedProfileTests.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/tests/cmm/EmbeddedProfileTests.java Wed Jul 05 20:11:52 2017 +0200
@@ -100,7 +100,7 @@
String[] descr = new String[num];
for (int i = 0; i < num; i++) {
- names[i] = images[i].toString();
+ names[i] = images[i].abbrev;
abbrev[i] = images[i].abbrev;
descr[i] = images[i].description;
}
@@ -153,7 +153,7 @@
iis = ImageIO.createImageInputStream(url.openStream());
reader = (ImageReader) ImageIO.getImageReaders(iis).next();
} catch (IOException e) {
- throw new RuntimeException("Unable to run the becnhmark", e);
+ throw new RuntimeException("Unable to run the benchmark", e);
}
do {
--- a/jdk/src/demo/share/jfc/TableExample/TableSorter.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/demo/share/jfc/TableExample/TableSorter.java Wed Jul 05 20:11:52 2017 +0200
@@ -267,7 +267,7 @@
than assigned otherwise sister calls in the recursion might
get out of sinc. When the number of elements is three they
are partitioned so that the first set, [low, mid), has one
- element and and the second, [mid, high), has two. We skip the
+ element and the second, [mid, high), has two. We skip the
optimisation when the number of elements is three or less as
the first compare in the normal merge will produce the same
sequence of steps. This optimisation seems to be worthwhile
--- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/ClassReader.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/ClassReader.java Wed Jul 05 20:11:52 2017 +0200
@@ -497,7 +497,7 @@
code.max_locals >= TOO_BIG ||
code.getLength() >= TOO_BIG ||
name.endsWith("X")) {
- // No, we don't really know what to do this this one.
+ // No, we don't really know what to do with this one.
// Do not compress the rare and strange "u4" and "X" cases.
a = null;
}
--- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Coding.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Coding.java Wed Jul 05 20:11:52 2017 +0200
@@ -95,7 +95,7 @@
If S>0, the unsigned value of a byte sequence is regarded as a binary
integer. If any of the S low-order bits are zero, the corresponding
signed value will be non-negative. If all of the S low-order bits
- (S>0) are one, the the corresponding signed value will be negative.
+ (S>0) are one, the corresponding signed value will be negative.
The non-negative signed values are compact and monotonically increasing
(from 0) in the ordering of the corresponding unsigned values.
--- a/jdk/src/java.base/share/classes/java/io/FileInputStream.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/io/FileInputStream.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,6 +26,7 @@
package java.io;
import java.nio.channels.FileChannel;
+import java.util.concurrent.atomic.AtomicBoolean;
import sun.nio.ch.FileChannelImpl;
@@ -57,10 +58,9 @@
*/
private final String path;
- private FileChannel channel = null;
+ private volatile FileChannel channel;
- private final Object closeLock = new Object();
- private volatile boolean closed = false;
+ private final AtomicBoolean closed = new AtomicBoolean(false);
/**
* Creates a <code>FileInputStream</code> by
@@ -313,14 +313,14 @@
* @spec JSR-51
*/
public void close() throws IOException {
- synchronized (closeLock) {
- if (closed) {
- return;
- }
- closed = true;
+ if (!closed.compareAndSet(false, true)) {
+ // if compareAndSet() returns false closed was already true
+ return;
}
- if (channel != null) {
- channel.close();
+
+ FileChannel fc = channel;
+ if (fc != null) {
+ fc.close();
}
fd.closeAll(new Closeable() {
@@ -364,12 +364,23 @@
* @spec JSR-51
*/
public FileChannel getChannel() {
- synchronized (this) {
- if (channel == null) {
- channel = FileChannelImpl.open(fd, path, true, false, this);
+ FileChannel fc = this.channel;
+ if (fc == null) {
+ synchronized (this) {
+ fc = this.channel;
+ if (fc == null) {
+ this.channel = fc = FileChannelImpl.open(fd, path, true, false, this);
+ if (closed.get()) {
+ try {
+ fc.close();
+ } catch (IOException ioe) {
+ throw new InternalError(ioe); // should not happen
+ }
+ }
+ }
}
- return channel;
}
+ return fc;
}
private static native void initIDs();
--- a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,6 +26,7 @@
package java.io;
import java.nio.channels.FileChannel;
+import java.util.concurrent.atomic.AtomicBoolean;
import sun.misc.SharedSecrets;
import sun.misc.JavaIOFileDescriptorAccess;
import sun.nio.ch.FileChannelImpl;
@@ -68,7 +69,7 @@
/**
* The associated channel, initialized lazily.
*/
- private FileChannel channel;
+ private volatile FileChannel channel;
/**
* The path of the referenced file
@@ -76,8 +77,7 @@
*/
private final String path;
- private final Object closeLock = new Object();
- private volatile boolean closed = false;
+ private final AtomicBoolean closed = new AtomicBoolean(false);
/**
* Creates a file output stream to write to the file with the
@@ -341,15 +341,14 @@
* @spec JSR-51
*/
public void close() throws IOException {
- synchronized (closeLock) {
- if (closed) {
- return;
- }
- closed = true;
+ if (!closed.compareAndSet(false, true)) {
+ // if compareAndSet() returns false closed was already true
+ return;
}
- if (channel != null) {
- channel.close();
+ FileChannel fc = channel;
+ if (fc != null) {
+ fc.close();
}
fd.closeAll(new Closeable() {
@@ -394,12 +393,23 @@
* @spec JSR-51
*/
public FileChannel getChannel() {
- synchronized (this) {
- if (channel == null) {
- channel = FileChannelImpl.open(fd, path, false, true, this);
+ FileChannel fc = this.channel;
+ if (fc == null) {
+ synchronized (this) {
+ fc = this.channel;
+ if (fc == null) {
+ this.channel = fc = FileChannelImpl.open(fd, path, false, true, this);
+ if (closed.get()) {
+ try {
+ fc.close();
+ } catch (IOException ioe) {
+ throw new InternalError(ioe); // should not happen
+ }
+ }
+ }
}
- return channel;
}
+ return fc;
}
/**
--- a/jdk/src/java.base/share/classes/java/io/InputStream.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/io/InputStream.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,6 +25,8 @@
package java.io;
+import java.util.Objects;
+
/**
* This abstract class is the superclass of all classes representing
* an input stream of bytes.
@@ -48,6 +50,8 @@
// use when skipping.
private static final int MAX_SKIP_BUFFER_SIZE = 2048;
+ private static final int TRANSFER_BUFFER_SIZE = 8192;
+
/**
* Reads the next byte of data from the input stream. The value byte is
* returned as an <code>int</code> in the range <code>0</code> to
@@ -364,4 +368,40 @@
return false;
}
+ /**
+ * Reads all bytes from this input stream and writes the bytes to the
+ * given output stream in the order that they are read. On return, this
+ * input stream will be at end of stream. This method does not close either
+ * stream.
+ * <p>
+ * This method may block indefinitely reading from the input stream, or
+ * writing to the output stream. The behavior for the case where the input
+ * and/or output stream is <i>asynchronously closed</i>, or the thread
+ * interrupted during the transfer, is highly input and output stream
+ * specific, and therefore not specified.
+ * <p>
+ * If an I/O error occurs reading from the input stream or writing to the
+ * output stream, then it may do so after some bytes have been read or
+ * written. Consequently the input stream may not be at end of stream and
+ * one, or both, streams may be in an inconsistent state. It is strongly
+ * recommended that both streams be promptly closed if an I/O error occurs.
+ *
+ * @param out the output stream, non-null
+ * @return the number of bytes transferred
+ * @throws IOException if an I/O error occurs when reading or writing
+ * @throws NullPointerException if {@code out} is {@code null}
+ *
+ * @since 1.9
+ */
+ public long transferTo(OutputStream out) throws IOException {
+ Objects.requireNonNull(out, "out");
+ long transferred = 0;
+ byte[] buffer = new byte[TRANSFER_BUFFER_SIZE];
+ int read;
+ while ((read = this.read(buffer, 0, TRANSFER_BUFFER_SIZE)) >= 0) {
+ out.write(buffer, 0, read);
+ transferred += read;
+ }
+ return transferred;
+ }
}
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java Wed Jul 05 20:11:52 2017 +0200
@@ -2345,7 +2345,7 @@
skipped++;
n--;
}
- return skipped + skip(n);
+ return skipped + in.skip(n);
}
public int available() throws IOException {
--- a/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,6 +26,7 @@
package java.io;
import java.nio.channels.FileChannel;
+import java.util.concurrent.atomic.AtomicBoolean;
import sun.nio.ch.FileChannelImpl;
@@ -59,7 +60,7 @@
public class RandomAccessFile implements DataOutput, DataInput, Closeable {
private FileDescriptor fd;
- private FileChannel channel = null;
+ private volatile FileChannel channel;
private boolean rw;
/**
@@ -68,8 +69,7 @@
*/
private final String path;
- private Object closeLock = new Object();
- private volatile boolean closed = false;
+ private final AtomicBoolean closed = new AtomicBoolean(false);
private static final int O_RDONLY = 1;
private static final int O_RDWR = 2;
@@ -276,13 +276,24 @@
* @since 1.4
* @spec JSR-51
*/
- public final FileChannel getChannel() {
- synchronized (this) {
- if (channel == null) {
- channel = FileChannelImpl.open(fd, path, true, rw, this);
+ public FileChannel getChannel() {
+ FileChannel fc = this.channel;
+ if (fc == null) {
+ synchronized (this) {
+ fc = this.channel;
+ if (fc == null) {
+ this.channel = fc = FileChannelImpl.open(fd, path, true, rw, this);
+ if (closed.get()) {
+ try {
+ fc.close();
+ } catch (IOException ioe) {
+ throw new InternalError(ioe); // should not happen
+ }
+ }
+ }
}
- return channel;
}
+ return fc;
}
/**
@@ -604,14 +615,14 @@
* @spec JSR-51
*/
public void close() throws IOException {
- synchronized (closeLock) {
- if (closed) {
- return;
- }
- closed = true;
+ if (!closed.compareAndSet(false, true)) {
+ // if compareAndSet() returns false closed was already true
+ return;
}
- if (channel != null) {
- channel.close();
+
+ FileChannel fc = channel;
+ if (fc != null) {
+ fc.close();
}
fd.closeAll(new Closeable() {
--- a/jdk/src/java.base/share/classes/java/lang/Class.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java Wed Jul 05 20:11:52 2017 +0200
@@ -1529,7 +1529,7 @@
* the accessible public fields of the class or interface represented by
* this {@code Class} object.
*
- * <p> If this {@code Class} object represents a class or interface with no
+ * <p> If this {@code Class} object represents a class or interface with
* no accessible public fields, then this method returns an array of length
* 0.
*
--- a/jdk/src/java.base/share/classes/java/lang/ClassValue.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/ClassValue.java Wed Jul 05 20:11:52 2017 +0200
@@ -162,7 +162,7 @@
* observe the time-dependent states as it computes {@code V1}, etc.
* This does not remove the threat of a stale value, since there is a window of time
* between the return of {@code computeValue} in {@code T} and the installation
- * of the the new value. No user synchronization is possible during this time.
+ * of the new value. No user synchronization is possible during this time.
*
* @param type the type whose class value must be removed
* @throws NullPointerException if the argument is null
@@ -285,7 +285,7 @@
* will receive the notification without delay.
* <p>
* If version were not volatile, one thread T1 could persistently hold onto
- * a stale value this.value == V1, while while another thread T2 advances
+ * a stale value this.value == V1, while another thread T2 advances
* (under a lock) to this.value == V2. This will typically be harmless,
* but if T1 and T2 interact causally via some other channel, such that
* T1's further actions are constrained (in the JMM) to happen after
--- a/jdk/src/java.base/share/classes/java/lang/Integer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/Integer.java Wed Jul 05 20:11:52 2017 +0200
@@ -840,7 +840,7 @@
/**
* Parses the string argument as an unsigned decimal integer. The
* characters in the string must all be decimal digits, except
- * that the first character may be an an ASCII plus sign {@code
+ * that the first character may be an ASCII plus sign {@code
* '+'} ({@code '\u005Cu002B'}). The resulting integer value
* is returned, exactly as if the argument and the radix 10 were
* given as arguments to the {@link
--- a/jdk/src/java.base/share/classes/java/lang/Long.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/Long.java Wed Jul 05 20:11:52 2017 +0200
@@ -971,7 +971,7 @@
/**
* Parses the string argument as an unsigned decimal {@code long}. The
* characters in the string must all be decimal digits, except
- * that the first character may be an an ASCII plus sign {@code
+ * that the first character may be an ASCII plus sign {@code
* '+'} ({@code '\u005Cu002B'}). The resulting integer value
* is returned, exactly as if the argument and the radix 10 were
* given as arguments to the {@link
--- a/jdk/src/java.base/share/classes/java/lang/Math.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/Math.java Wed Jul 05 20:11:52 2017 +0200
@@ -2224,7 +2224,7 @@
* multiply-store result is subnormal, the next multiply will
* round it away to zero. This is done by first multiplying
* by 2 ^ (scaleFactor % n) and then multiplying several
- * times by by 2^n as needed where n is the exponent of number
+ * times by 2^n as needed where n is the exponent of number
* that is a covenient power of two. In this way, at most one
* real rounding error occurs. If the double value set is
* being used exclusively, the rounding will occur on a
@@ -2249,7 +2249,7 @@
// magnitude of a power of two so large that scaling a finite
// nonzero value by it would be guaranteed to over or
- // underflow; due to rounding, scaling down takes takes an
+ // underflow; due to rounding, scaling down takes an
// additional power of two which is reflected here
final int MAX_SCALE = DoubleConsts.MAX_EXPONENT + -DoubleConsts.MIN_EXPONENT +
DoubleConsts.SIGNIFICAND_WIDTH + 1;
@@ -2318,7 +2318,7 @@
public static float scalb(float f, int scaleFactor) {
// magnitude of a power of two so large that scaling a finite
// nonzero value by it would be guaranteed to over or
- // underflow; due to rounding, scaling down takes takes an
+ // underflow; due to rounding, scaling down takes an
// additional power of two which is reflected here
final int MAX_SCALE = FloatConsts.MAX_EXPONENT + -FloatConsts.MIN_EXPONENT +
FloatConsts.SIGNIFICAND_WIDTH + 1;
--- a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java Wed Jul 05 20:11:52 2017 +0200
@@ -750,7 +750,7 @@
* {@link Process#getErrorStream()} will return a
* <a href="#redirect-output">null input stream</a>.
*
- * <p>If the {@link #redirectErrorStream redirectErrorStream}
+ * <p>If the {@link #redirectErrorStream() redirectErrorStream}
* attribute has been set {@code true}, then the redirection set
* by this method has no effect.
*
--- a/jdk/src/java.base/share/classes/java/lang/Throwable.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/Throwable.java Wed Jul 05 20:11:52 2017 +0200
@@ -202,7 +202,7 @@
* The field is initialized to a zero-length array. A {@code
* null} value of this field indicates subsequent calls to {@link
* #setStackTrace(StackTraceElement[])} and {@link
- * #fillInStackTrace()} will be be no-ops.
+ * #fillInStackTrace()} will be no-ops.
*
* @serial
* @since 1.4
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java Wed Jul 05 20:11:52 2017 +0200
@@ -116,7 +116,7 @@
/**
* Construct a temporary unchecked instance of MethodType for use only as a key to the intern table.
* Does not check the given parameters for validity, and must be discarded after it is used as a searching key.
- * The parameters are reversed for this constructor, so that is is not accidentally used.
+ * The parameters are reversed for this constructor, so that it is not accidentally used.
*/
private MethodType(Class<?>[] ptypes, Class<?> rtype) {
this.rtype = rtype;
@@ -1006,7 +1006,7 @@
* Therefore, the number returned is the number of arguments
* <em>including</em> and <em>after</em> the given parameter,
* <em>plus</em> the number of long or double arguments
- * at or after after the argument for the given parameter.
+ * at or after the argument for the given parameter.
* <p>
* This method is included for the benefit of applications that must
* generate bytecodes that process method handles and invokedynamic.
--- a/jdk/src/java.base/share/classes/java/security/DomainCombiner.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/security/DomainCombiner.java Wed Jul 05 20:11:52 2017 +0200
@@ -92,7 +92,7 @@
* @param currentDomains the ProtectionDomains associated with the
* current execution Thread, up to the most recent
* privileged {@code ProtectionDomain}.
- * The ProtectionDomains are are listed in order of execution,
+ * The ProtectionDomains are listed in order of execution,
* with the most recently executing {@code ProtectionDomain}
* residing at the beginning of the array. This parameter may
* be {@code null} if the current execution Thread
--- a/jdk/src/java.base/share/classes/java/security/Provider.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/security/Provider.java Wed Jul 05 20:11:52 2017 +0200
@@ -1711,7 +1711,7 @@
*
* @param parameter the parameter to test
*
- * @return false if this this service cannot use the specified
+ * @return false if this service cannot use the specified
* parameter; true if it can possibly use the parameter
*
* @throws InvalidParameterException if the value of parameter is
--- a/jdk/src/java.base/share/classes/java/security/Signature.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/security/Signature.java Wed Jul 05 20:11:52 2017 +0200
@@ -776,7 +776,7 @@
/**
* Updates the data to be signed or verified using the specified
* ByteBuffer. Processes the {@code data.remaining()} bytes
- * starting at at {@code data.position()}.
+ * starting at {@code data.position()}.
* Upon return, the buffer's position will be equal to its limit;
* its limit will not have changed.
*
--- a/jdk/src/java.base/share/classes/java/security/SignatureSpi.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/security/SignatureSpi.java Wed Jul 05 20:11:52 2017 +0200
@@ -131,7 +131,7 @@
/**
* Updates the data to be signed or verified using the specified
* ByteBuffer. Processes the {@code data.remaining()} bytes
- * starting at at {@code data.position()}.
+ * starting at {@code data.position()}.
* Upon return, the buffer's position will be equal to its limit;
* its limit will not have changed.
*
--- a/jdk/src/java.base/share/classes/java/security/interfaces/DSAKeyPairGenerator.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/security/interfaces/DSAKeyPairGenerator.java Wed Jul 05 20:11:52 2017 +0200
@@ -54,7 +54,7 @@
*
* </ol>
*
- * <p>Note: it is not always necessary to do do algorithm-specific
+ * <p>Note: it is not always necessary to do algorithm-specific
* initialization for a DSA key pair generator. That is, it is not always
* necessary to call an {@code initialize} method in this interface.
* Algorithm-independent initialization using the {@code initialize} method
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Wed Jul 05 20:11:52 2017 +0200
@@ -1097,7 +1097,7 @@
* This returns an immutable formatter capable of formatting and parsing
* the ISO-8601 instant format.
* When formatting, the second-of-minute is always output.
- * The nano-of-second outputs zero, three, six or nine digits digits as necessary.
+ * The nano-of-second outputs zero, three, six or nine digits as necessary.
* When parsing, time to at least the seconds field is required.
* Fractional seconds from zero to nine are parsed.
* The localized decimal style is not used.
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Wed Jul 05 20:11:52 2017 +0200
@@ -793,7 +793,7 @@
* They are converted to a date-time with a zone-offset of UTC and formatted
* using the standard ISO-8601 format.
* With this method, formatting nano-of-second outputs zero, three, six
- * or nine digits digits as necessary.
+ * or nine digits as necessary.
* The localized decimal style is not used.
* <p>
* The instant is obtained using {@link ChronoField#INSTANT_SECONDS INSTANT_SECONDS}
--- a/jdk/src/java.base/share/classes/java/util/Arrays.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/Arrays.java Wed Jul 05 20:11:52 2017 +0200
@@ -1221,7 +1221,7 @@
*
* <p>The implementation takes equal advantage of ascending and
* descending order in its input array, and can take advantage of
- * ascending and descending order in different parts of the the same
+ * ascending and descending order in different parts of the same
* input array. It is well-suited to merging two or more sorted arrays:
* simply concatenate the arrays and sort the resulting array.
*
@@ -1280,7 +1280,7 @@
*
* <p>The implementation takes equal advantage of ascending and
* descending order in its input array, and can take advantage of
- * ascending and descending order in different parts of the the same
+ * ascending and descending order in different parts of the same
* input array. It is well-suited to merging two or more sorted arrays:
* simply concatenate the arrays and sort the resulting array.
*
@@ -1407,7 +1407,7 @@
*
* <p>The implementation takes equal advantage of ascending and
* descending order in its input array, and can take advantage of
- * ascending and descending order in different parts of the the same
+ * ascending and descending order in different parts of the same
* input array. It is well-suited to merging two or more sorted arrays:
* simply concatenate the arrays and sort the resulting array.
*
@@ -1473,7 +1473,7 @@
*
* <p>The implementation takes equal advantage of ascending and
* descending order in its input array, and can take advantage of
- * ascending and descending order in different parts of the the same
+ * ascending and descending order in different parts of the same
* input array. It is well-suited to merging two or more sorted arrays:
* simply concatenate the arrays and sort the resulting array.
*
--- a/jdk/src/java.base/share/classes/java/util/Base64.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/Base64.java Wed Jul 05 20:11:52 2017 +0200
@@ -556,7 +556,7 @@
*
* <p> It is the responsibility of the invoker of this method to make
* sure the output byte array {@code dst} has enough space for decoding
- * all bytes from the input byte array. No bytes will be be written to
+ * all bytes from the input byte array. No bytes will be written to
* the output byte array if the output byte array is not big enough.
*
* <p> If the input byte array is not in valid Base64 encoding scheme
--- a/jdk/src/java.base/share/classes/java/util/Calendar.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/Calendar.java Wed Jul 05 20:11:52 2017 +0200
@@ -2993,7 +2993,7 @@
}
/**
- * Sets the date of this {@code Calendar} with the the given date
+ * Sets the date of this {@code Calendar} with the given date
* specifiers - week year, week of year, and day of week.
*
* <p>Unlike the {@code set} method, all of the calendar fields
--- a/jdk/src/java.base/share/classes/java/util/Locale.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/Locale.java Wed Jul 05 20:11:52 2017 +0200
@@ -95,7 +95,7 @@
* <code>Locale</code> always canonicalizes to lower case.</dd>
*
* <dd>Well-formed language values have the form
- * <code>[a-zA-Z]{2,8}</code>. Note that this is not the the full
+ * <code>[a-zA-Z]{2,8}</code>. Note that this is not the full
* BCP47 language production, since it excludes extlang. They are
* not needed since modern three-letter language codes replace
* them.</dd>
@@ -1691,7 +1691,7 @@
}
/**
- * Returns a name for the the locale's script that is appropriate for display to
+ * Returns a name for the locale's script that is appropriate for display to
* the user. If possible, the name will be localized for the default
* {@link Locale.Category#DISPLAY DISPLAY} locale. Returns
* the empty string if this locale doesn't specify a script code.
--- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Wed Jul 05 20:11:52 2017 +0200
@@ -994,7 +994,7 @@
* bundle is found, the default control's {@link Control#getFallbackLocale
* getFallbackLocale} method is called, which returns the current default
* locale. A new sequence of candidate locale names is generated using this
- * locale and and searched again, as above.
+ * locale and searched again, as above.
*
* <p>If still no result bundle is found, the base name alone is looked up. If
* this still fails, a <code>MissingResourceException</code> is thrown.
--- a/jdk/src/java.base/share/classes/java/util/Spliterator.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/Spliterator.java Wed Jul 05 20:11:52 2017 +0200
@@ -84,7 +84,7 @@
* via the {@link #estimateSize} method. Ideally, as reflected in characteristic
* {@link #SIZED}, this value corresponds exactly to the number of elements
* that would be encountered in a successful traversal. However, even when not
- * exactly known, an estimated value value may still be useful to operations
+ * exactly known, an estimated value may still be useful to operations
* being performed on the source, such as helping to determine whether it is
* preferable to split further or traverse the remaining elements sequentially.
*
--- a/jdk/src/java.base/share/classes/java/util/Spliterators.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/Spliterators.java Wed Jul 05 20:11:52 2017 +0200
@@ -132,7 +132,7 @@
* @param array The array, assumed to be unmodified during use
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
* @return A spliterator for an array
* @throws NullPointerException if the given array is {@code null}
* @see Arrays#spliterator(Object[])
@@ -164,7 +164,7 @@
* @param toIndex One past the greatest index to cover
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
* @return A spliterator for an array
* @throws NullPointerException if the given array is {@code null}
* @throws ArrayIndexOutOfBoundsException if {@code fromIndex} is negative,
@@ -196,7 +196,7 @@
* @param array The array, assumed to be unmodified during use
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
* @return A spliterator for an array
* @throws NullPointerException if the given array is {@code null}
* @see Arrays#spliterator(int[])
@@ -226,7 +226,7 @@
* @param toIndex One past the greatest index to cover
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
* @return A spliterator for an array
* @throws NullPointerException if the given array is {@code null}
* @throws ArrayIndexOutOfBoundsException if {@code fromIndex} is negative,
@@ -258,7 +258,7 @@
* @param array The array, assumed to be unmodified during use
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
* @return A spliterator for an array
* @throws NullPointerException if the given array is {@code null}
* @see Arrays#spliterator(long[])
@@ -282,7 +282,7 @@
* {@code SIZED} and {@code SUBSIZED}. The caller may provide additional
* characteristics for the spliterator to report. (For example, if it is
* known the array will not be further modified, specify {@code IMMUTABLE};
- * if the array data is considered to have an an encounter order, specify
+ * if the array data is considered to have an encounter order, specify
* {@code ORDERED}). The method {@link Arrays#spliterator(long[], int, int)} can
* often be used instead, which returns a spliterator that reports
* {@code SIZED}, {@code SUBSIZED}, {@code IMMUTABLE}, and {@code ORDERED}.
@@ -292,7 +292,7 @@
* @param toIndex One past the greatest index to cover
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
* @return A spliterator for an array
* @throws NullPointerException if the given array is {@code null}
* @throws ArrayIndexOutOfBoundsException if {@code fromIndex} is negative,
@@ -324,7 +324,7 @@
* @param array The array, assumed to be unmodified during use
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
* @return A spliterator for an array
* @throws NullPointerException if the given array is {@code null}
* @see Arrays#spliterator(double[])
@@ -348,7 +348,7 @@
* {@code SIZED} and {@code SUBSIZED}. The caller may provide additional
* characteristics for the spliterator to report. (For example, if it is
* known the array will not be further modified, specify {@code IMMUTABLE};
- * if the array data is considered to have an an encounter order, specify
+ * if the array data is considered to have an encounter order, specify
* {@code ORDERED}). The method {@link Arrays#spliterator(long[], int, int)} can
* often be used instead, which returns a spliterator that reports
* {@code SIZED}, {@code SUBSIZED}, {@code IMMUTABLE}, and {@code ORDERED}.
@@ -358,7 +358,7 @@
* @param toIndex One past the greatest index to cover
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
* @return A spliterator for an array
* @throws NullPointerException if the given array is {@code null}
* @throws ArrayIndexOutOfBoundsException if {@code fromIndex} is negative,
@@ -907,7 +907,7 @@
* @param array the array, assumed to be unmodified during use
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
*/
public ArraySpliterator(Object[] array, int additionalCharacteristics) {
this(array, 0, array.length, additionalCharacteristics);
@@ -920,7 +920,7 @@
* @param fence one past the greatest index to cover
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
*/
public ArraySpliterator(Object[] array, int origin, int fence, int additionalCharacteristics) {
this.array = array;
@@ -992,7 +992,7 @@
* @param array the array, assumed to be unmodified during use
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
*/
public IntArraySpliterator(int[] array, int additionalCharacteristics) {
this(array, 0, array.length, additionalCharacteristics);
@@ -1005,7 +1005,7 @@
* @param fence one past the greatest index to cover
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
*/
public IntArraySpliterator(int[] array, int origin, int fence, int additionalCharacteristics) {
this.array = array;
@@ -1075,7 +1075,7 @@
* @param array the array, assumed to be unmodified during use
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
*/
public LongArraySpliterator(long[] array, int additionalCharacteristics) {
this(array, 0, array.length, additionalCharacteristics);
@@ -1088,7 +1088,7 @@
* @param fence one past the greatest index to cover
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
*/
public LongArraySpliterator(long[] array, int origin, int fence, int additionalCharacteristics) {
this.array = array;
@@ -1158,7 +1158,7 @@
* @param array the array, assumed to be unmodified during use
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
*/
public DoubleArraySpliterator(double[] array, int additionalCharacteristics) {
this(array, 0, array.length, additionalCharacteristics);
@@ -1171,7 +1171,7 @@
* @param fence one past the greatest index to cover
* @param additionalCharacteristics Additional spliterator characteristics
* of this spliterator's source or elements beyond {@code SIZED} and
- * {@code SUBSIZED} which are are always reported
+ * {@code SUBSIZED} which are always reported
*/
public DoubleArraySpliterator(double[] array, int origin, int fence, int additionalCharacteristics) {
this.array = array;
@@ -1698,7 +1698,7 @@
private int batch; // batch size for splits
/**
- * Creates a spliterator using the given given
+ * Creates a spliterator using the given
* collection's {@link java.util.Collection#iterator()) for traversal,
* and reporting its {@link java.util.Collection#size()) as its initial
* size.
--- a/jdk/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/spi/LocaleServiceProvider.java Wed Jul 05 20:11:52 2017 +0200
@@ -43,9 +43,8 @@
* supported by the Java runtime environment itself.
*
* <h3>Packaging of Locale Sensitive Service Provider Implementations</h3>
- * Implementations of these locale sensitive services are packaged using the
- * <a href="../../../../technotes/guides/extensions/index.html">Java Extension Mechanism</a>
- * as installed extensions. A provider identifies itself with a
+ * Implementations of these locale sensitive services can be made available
+ * by adding them to the application's class path. A provider identifies itself with a
* provider-configuration file in the resource directory META-INF/services,
* using the fully qualified provider interface class name as the file name.
* The file should contain a list of fully-qualified concrete provider class names,
--- a/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java Wed Jul 05 20:11:52 2017 +0200
@@ -204,7 +204,6 @@
/**
* Updates the CRC-32C checksum with the specified array of bytes.
*/
- @SuppressWarnings("deprecation") // Unsafe.{getInt, getLong}
private static int updateBytes(int crc, byte[] b, int off, int end) {
// Do only byte reads for arrays so short they can't be aligned
@@ -228,11 +227,11 @@
int secondHalf;
if (Unsafe.ADDRESS_SIZE == 4) {
// On 32 bit platforms read two ints instead of a single 64bit long
- firstHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
- secondHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off
+ firstHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
+ secondHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off
+ Integer.BYTES);
} else {
- long value = UNSAFE.getLong(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
+ long value = UNSAFE.getLong(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
firstHalf = (int) value;
secondHalf = (int) (value >>> 32);
--- a/jdk/src/java.base/share/classes/javax/security/auth/Policy.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/javax/security/auth/Policy.java Wed Jul 05 20:11:52 2017 +0200
@@ -76,7 +76,7 @@
* </pre>
*
* The CodeBase and Signedby components of the triplet name/value pairs
- * are optional. If they are not present, then any any codebase will match,
+ * are optional. If they are not present, then any codebase will match,
* and any signer (including unsigned code) will match.
* For Example,
*
--- a/jdk/src/java.base/share/classes/javax/security/auth/SubjectDomainCombiner.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/javax/security/auth/SubjectDomainCombiner.java Wed Jul 05 20:11:52 2017 +0200
@@ -137,7 +137,7 @@
* @param currentDomains the ProtectionDomains associated with the
* current execution Thread, up to the most recent
* privileged {@code ProtectionDomain}.
- * The ProtectionDomains are are listed in order of execution,
+ * The ProtectionDomains are listed in order of execution,
* with the most recently executing {@code ProtectionDomain}
* residing at the beginning of the array. This parameter may
* be {@code null} if the current execution Thread
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Frame.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Frame.java Wed Jul 05 20:11:52 2017 +0200
@@ -192,7 +192,7 @@
private static final int LOCAL = 0x2000000;
/**
- * Kind of the the types that are relative to the stack of an input stack
+ * Kind of the types that are relative to the stack of an input stack
* map frame. The value of such types is a position relatively to the top of
* this stack.
*/
--- a/jdk/src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java Wed Jul 05 20:11:52 2017 +0200
@@ -116,7 +116,7 @@
public void writeStartDocument() throws XMLStreamException;
/**
- * Write the XML Declaration. Defaults the the encoding to utf-8
+ * Write the XML Declaration. Defaults the encoding to utf-8
* @param version version of the xml document
* @throws XMLStreamException
*/
--- a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java Wed Jul 05 20:11:52 2017 +0200
@@ -80,7 +80,7 @@
* @param defc the class in which the proposed member is actually defined
* @param mods modifier flags for the proposed member
* @param lookupClass the class for which the access check is being made
- * @return true iff the the accessing class can access such a member
+ * @return true iff the accessing class can access such a member
*/
public static boolean isMemberAccessible(Class<?> refc, // symbolic ref class
Class<?> defc, // actual def class
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2007, 2013, 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
@@ -46,11 +46,7 @@
\ -verbose:[class|gc|jni]\n\
\ enable verbose output\n\
\ -version print product version and exit\n\
-\ -version:<value>\n\
-\ require the specified version to run\n\
\ -showversion print product version and continue\n\
-\ -jre-restrict-search | -no-jre-restrict-search\n\
-\ include/exclude user private JREs in the version search\n\
\ -? -help print this help message\n\
\ -X print help on non-standard options\n\
\ -ea[:<packagename>...|:<classname>]\n\
--- a/jdk/src/java.base/share/classes/sun/misc/JavaNioAccess.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/misc/JavaNioAccess.java Wed Jul 05 20:11:52 2017 +0200
@@ -42,7 +42,7 @@
/**
* Constructs a direct ByteBuffer referring to the block of memory starting
- * at the given memory address and and extending {@code cap} bytes.
+ * at the given memory address and extending {@code cap} bytes.
* The {@code ob} parameter is an arbitrary object that is attached
* to the resulting buffer.
*/
--- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java Wed Jul 05 20:11:52 2017 +0200
@@ -958,6 +958,8 @@
* other threads. This method is generally only useful if the
* underlying field is a Java volatile (or if an array cell, one
* that is otherwise only accessed using volatile accesses).
+ *
+ * Corresponds to C11 atomic_store_explicit(..., memory_order_release).
*/
public native void putOrderedObject(Object o, long offset, Object x);
@@ -1111,22 +1113,40 @@
/**
- * Ensures lack of reordering of loads before the fence
- * with loads or stores after the fence.
+ * Ensures that loads before the fence will not be reordered with loads and
+ * stores after the fence; a "LoadLoad plus LoadStore barrier".
+ *
+ * Corresponds to C11 atomic_thread_fence(memory_order_acquire)
+ * (an "acquire fence").
+ *
+ * A pure LoadLoad fence is not provided, since the addition of LoadStore
+ * is almost always desired, and most current hardware instructions that
+ * provide a LoadLoad barrier also provide a LoadStore barrier for free.
* @since 1.8
*/
public native void loadFence();
/**
- * Ensures lack of reordering of stores before the fence
- * with loads or stores after the fence.
+ * Ensures that loads and stores before the fence will not be reordered with
+ * stores after the fence; a "StoreStore plus LoadStore barrier".
+ *
+ * Corresponds to C11 atomic_thread_fence(memory_order_release)
+ * (a "release fence").
+ *
+ * A pure StoreStore fence is not provided, since the addition of LoadStore
+ * is almost always desired, and most current hardware instructions that
+ * provide a StoreStore barrier also provide a LoadStore barrier for free.
* @since 1.8
*/
public native void storeFence();
/**
- * Ensures lack of reordering of loads or stores before the fence
- * with loads or stores after the fence.
+ * Ensures that loads and stores before the fence will not be reordered
+ * with loads and stores after the fence. Implies the effects of both
+ * loadFence() and storeFence(), and in addition, the effect of a StoreLoad
+ * barrier.
+ *
+ * Corresponds to C11 atomic_thread_fence(memory_order_seq_cst).
* @since 1.8
*/
public native void fullFence();
--- a/jdk/src/java.base/share/classes/sun/misc/VM.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/misc/VM.java Wed Jul 05 20:11:52 2017 +0200
@@ -150,7 +150,7 @@
private static volatile boolean booted = false;
private static final Object lock = new Object();
- // Invoked by by System.initializeSystemClass just before returning.
+ // Invoked by System.initializeSystemClass just before returning.
// Subsystems that are invoked during initialization can check this
// property in order to avoid doing things that should wait until the
// application class loader has been set up.
--- a/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java Wed Jul 05 20:11:52 2017 +0200
@@ -2187,7 +2187,7 @@
return resp.get(0).substring(4);
}
// on multiple lines answers, like the ones above, remove 1st and last
- // line, concat the the others.
+ // line, concat the others.
StringBuilder sb = new StringBuilder();
for (int i = 1; i < resp.size() - 1; i++) {
sb.append(resp.get(i).substring(3));
--- a/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -110,6 +110,9 @@
// -- Standard channel operations --
protected void implCloseChannel() throws IOException {
+ if (!fd.valid())
+ return; // nothing to do
+
// Release and invalidate any locks that we still hold
if (fileLockTable != null) {
for (FileLock fl: fileLockTable.removeAll()) {
--- a/jdk/src/java.base/share/classes/sun/reflect/Label.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/Label.java Wed Jul 05 20:11:52 2017 +0200
@@ -52,7 +52,7 @@
final short patchBCI;
final int stackDepth;
}
- private List<PatchInfo> patches = new ArrayList<>();
+ private final List<PatchInfo> patches = new ArrayList<>();
public Label() {
}
--- a/jdk/src/java.base/share/classes/sun/reflect/ReflectionFactory.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/ReflectionFactory.java Wed Jul 05 20:11:52 2017 +0200
@@ -135,7 +135,7 @@
* be initialized and therefore must not be called until the
* first get/set of this field.
* @param field the field
- * @param override true if caller has overridden aaccessibility
+ * @param override true if caller has overridden accessibility
*/
public FieldAccessor newFieldAccessor(Field field, boolean override) {
checkInitted();
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java Wed Jul 05 20:11:52 2017 +0200
@@ -280,19 +280,25 @@
* be rare).
*/
private Method[] getMemberMethods() {
- if (memberMethods == null) {
- memberMethods = AccessController.doPrivileged(
- new PrivilegedAction<Method[]>() {
- public Method[] run() {
- final Method[] mm = type.getDeclaredMethods();
- validateAnnotationMethods(mm);
- AccessibleObject.setAccessible(mm, true);
- return mm;
- }
- });
+ Method[] value = memberMethods;
+ if (value == null) {
+ value = computeMemberMethods();
+ memberMethods = value;
}
- return memberMethods;
+ return value;
}
+
+ private Method[] computeMemberMethods() {
+ return AccessController.doPrivileged(
+ new PrivilegedAction<Method[]>() {
+ public Method[] run() {
+ final Method[] methods = type.getDeclaredMethods();
+ validateAnnotationMethods(methods);
+ AccessibleObject.setAccessible(methods, true);
+ return methods;
+ }});
+ }
+
private transient volatile Method[] memberMethods = null;
/**
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java Wed Jul 05 20:11:52 2017 +0200
@@ -772,7 +772,7 @@
}
/**
- * Return an appropriate exception proxy for a mismatching array
+ * Returns an appropriate exception proxy for a mismatching array
* annotation where the erroneous array has the specified tag.
*/
private static ExceptionProxy exceptionProxy(int tag) {
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java Wed Jul 05 20:11:52 2017 +0200
@@ -115,7 +115,7 @@
/**
- * Figures out if conatiner class comes before containee class among the
+ * Figures out if container class comes before containee class among the
* keys of the given map.
*
* @return true if container class is found before containee class when
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java Wed Jul 05 20:11:52 2017 +0200
@@ -55,7 +55,7 @@
private final Map<String, Object> memberDefaults;
/**
- * Member name -> Method object mapping. This (and its assoicated
+ * Member name -> Method object mapping. This (and its associated
* accessor) are used only to generate AnnotationTypeMismatchExceptions.
*/
private final Map<String, Method> members;
@@ -117,7 +117,7 @@
memberDefaults = new HashMap<String, Object>(0);
members = new HashMap<String, Method>(methods.length+1, 1.0f);
- for (Method method : methods) {
+ for (Method method : methods) {
if (method.getParameterTypes().length != 0)
throw new IllegalArgumentException(method + " has params");
String name = method.getName();
@@ -213,7 +213,7 @@
}
/**
- * Returns true if this this annotation type is inherited.
+ * Returns true if this annotation type is inherited.
*/
public boolean isInherited() {
return inherited;
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java Wed Jul 05 20:11:52 2017 +0200
@@ -36,7 +36,7 @@
class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
private static final long serialVersionUID = 7844069490309503934L;
private Method member;
- private String foundType;
+ private final String foundType;
/**
* It turns out to be convenient to construct these proxies in
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,8 +33,8 @@
*/
public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy {
private static final long serialVersionUID = -604662101303187330L;
- Class<? extends Enum<?>> enumType;
- String constName;
+ final Class<? extends Enum<?>> enumType;
+ final String constName;
public EnumConstantNotPresentExceptionProxy(Class<? extends Enum<?>> enumType,
String constName) {
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,8 +34,8 @@
*/
public class TypeNotPresentExceptionProxy extends ExceptionProxy {
private static final long serialVersionUID = 5565925172427947573L;
- String typeName;
- Throwable cause;
+ final String typeName;
+ final Throwable cause;
public TypeNotPresentExceptionProxy(String typeName, Throwable cause) {
this.typeName = typeName;
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java Wed Jul 05 20:11:52 2017 +0200
@@ -76,11 +76,11 @@
* kind. Classes produced will be those that would be loaded by the
* defining class loader of the declaration <tt>d</tt> (if <tt>d</tt>
* is a type declaration, or by the defining loader of the declaring
- * class of <tt>d</tt> otherwise.
+ * class of <tt>d</tt> otherwise.
* <p> Type variables will be created or lookup as necessary in the
* scope <tt> s</tt>.
* @param d - the generic declaration (class, interface, method or
- * constructor) that thsi factory services
+ * constructor) that this factory services
* @param s the scope in which the factory will allocate and search for
* type variables
* @return an instance of <tt>CoreReflectionFactory</tt>
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/factory/GenericsFactory.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/factory/GenericsFactory.java Wed Jul 05 20:11:52 2017 +0200
@@ -42,7 +42,7 @@
* of a specific implementation by using this interface. For example,
* repositories of generic type information are initialized with a
* factory conforming to this interface, and use it to generate the
- * tpe information they are required to provide. As a result, such
+ * type information they are required to provide. As a result, such
* repository code can be shared across different reflective systems.
*/
public interface GenericsFactory {
@@ -60,7 +60,7 @@
TypeVariable<?> makeTypeVariable(String name,
FieldTypeSignature[] bounds);
/**
- * Return an instance of the <tt>ParameterizedType</tt> interface
+ * Returns an instance of the <tt>ParameterizedType</tt> interface
* that corresponds to a generic type instantiation of the
* generic declaration <tt>declaration</tt> with actual type arguments
* <tt>typeArgs</tt>.
@@ -123,7 +123,7 @@
/**
* Returns a (possibly generic) array type.
* If the component type is a parameterized type, it must
- * only have unbounded wildcard arguemnts, otherwise
+ * only have unbounded wildcard arguments, otherwise
* a MalformedParameterizedTypeException is thrown.
* @param componentType - the component type of the array
* @return a (possibly generic) array type.
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/parser/SignatureParser.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/parser/SignatureParser.java Wed Jul 05 20:11:52 2017 +0200
@@ -227,7 +227,7 @@
* "<" FormalTypeParameter+ ">"
*/
private FormalTypeParameter[] parseFormalTypeParameters(){
- List<FormalTypeParameter> ftps = new ArrayList<>(3);
+ List<FormalTypeParameter> ftps = new ArrayList<>(3);
assert(current() == '<'); // should not have been called at all
if (current() != '<') { throw error("expected '<'");}
advance();
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/GenericArrayTypeImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/GenericArrayTypeImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -53,10 +53,10 @@
/**
- * Returns a <tt>Type</tt> object representing the component type
+ * Returns a <tt>Type</tt> object representing the component type
* of this array.
*
- * @return a <tt>Type</tt> object representing the component type
+ * @return a <tt>Type</tt> object representing the component type
* of this array
* @since 1.5
*/
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/LazyReflectiveObjectGenerator.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/LazyReflectiveObjectGenerator.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,7 +25,9 @@
package sun.reflect.generics.reflectiveObjects;
+import java.lang.reflect.Type;
import sun.reflect.generics.factory.GenericsFactory;
+import sun.reflect.generics.tree.FieldTypeSignature;
import sun.reflect.generics.visitor.Reifier;
@@ -54,4 +56,16 @@
// produce a reifying visitor (could this be typed as a TypeTreeVisitor?
protected Reifier getReifier(){return Reifier.make(getFactory());}
+ Type[] reifyBounds(FieldTypeSignature[] boundASTs) {
+ final int length = boundASTs.length;
+ final Type[] bounds = new Type[length];
+ // iterate over bound trees, reifying each in turn
+ for (int i = 0; i < length; i++) {
+ Reifier r = getReifier();
+ boundASTs[i].accept(r);
+ bounds[i] = r.getResult();
+ }
+ return bounds;
+ }
+
}
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -51,17 +51,16 @@
*/
public class TypeVariableImpl<D extends GenericDeclaration>
extends LazyReflectiveObjectGenerator implements TypeVariable<D> {
- D genericDeclaration;
- private String name;
- // upper bounds - evaluated lazily
- private Type[] bounds;
+ private final D genericDeclaration;
+ private final String name;
- // The ASTs for the bounds. We are required to evaluate the bounds
- // lazily, so we store these at least until we are first asked
- // for the bounds. This also neatly solves the
- // problem with F-bounds - you can't reify them before the formal
- // is defined.
- private FieldTypeSignature[] boundASTs;
+ /**
+ * The upper bounds. Lazily converted from FieldTypeSignature[] to Type[].
+ * We are required to evaluate the bounds lazily, so we store them as ASTs
+ * until we are first asked for them. This also neatly solves the problem
+ * with F-bounds - you can't reify them before the formal is defined.
+ */
+ private volatile Object[] bounds;
// constructor is private to enforce access through static factory
private TypeVariableImpl(D decl, String n, FieldTypeSignature[] bs,
@@ -69,18 +68,7 @@
super(f);
genericDeclaration = decl;
name = n;
- boundASTs = bs;
- }
-
- // Accessors
-
- // accessor for ASTs for bounds. Must not be called after
- // bounds have been evaluated, because we might throw the ASTs
- // away (but that is not thread-safe, is it?)
- private FieldTypeSignature[] getBoundASTs() {
- // check that bounds were not evaluated yet
- assert(bounds == null);
- return boundASTs;
+ bounds = bs;
}
/**
@@ -123,7 +111,7 @@
* <li>Otherwise, B is resolved.
* </ul>
*
- * @throws <tt>TypeNotPresentException</tt> if any of the
+ * @throws <tt>TypeNotPresentException</tt> if any of the
* bounds refers to a non-existent type declaration
* @throws <tt>MalformedParameterizedTypeException</tt> if any of the
* bounds refer to a parameterized type that cannot be instantiated
@@ -132,34 +120,23 @@
* type variable
*/
public Type[] getBounds() {
- // lazily initialize bounds if necessary
- if (bounds == null) {
- FieldTypeSignature[] fts = getBoundASTs(); // get AST
- // allocate result array; note that
- // keeping ts and bounds separate helps with threads
- Type[] ts = new Type[fts.length];
- // iterate over bound trees, reifying each in turn
- for ( int j = 0; j < fts.length; j++) {
- Reifier r = getReifier();
- fts[j].accept(r);
- ts[j] = r.getResult();
- }
- // cache result
- bounds = ts;
- // could throw away bound ASTs here; thread safety?
+ Object[] value = bounds;
+ if (value instanceof FieldTypeSignature[]) {
+ value = reifyBounds((FieldTypeSignature[])value);
+ bounds = value;
}
- return bounds.clone(); // return cached bounds
+ return (Type[])value.clone();
}
/**
- * Returns the <tt>GenericDeclaration</tt> object representing the
+ * Returns the <tt>GenericDeclaration</tt> object representing the
* generic declaration that declared this type variable.
*
* @return the generic declaration that declared this type variable.
*
* @since 1.5
*/
- public D getGenericDeclaration(){
+ public D getGenericDeclaration() {
if (genericDeclaration instanceof Class)
ReflectUtil.checkPackageAccess((Class)genericDeclaration);
else if ((genericDeclaration instanceof Method) ||
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/WildcardTypeImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/WildcardTypeImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -39,25 +39,26 @@
*/
public class WildcardTypeImpl extends LazyReflectiveObjectGenerator
implements WildcardType {
- // upper bounds - evaluated lazily
- private Type[] upperBounds;
- // lower bounds - evaluated lazily
- private Type[] lowerBounds;
- // The ASTs for the bounds. We are required to evaluate the bounds
- // lazily, so we store these at least until we are first asked
- // for the bounds. This also neatly solves the
- // problem with F-bounds - you can't reify them before the formal
- // is defined.
- private FieldTypeSignature[] upperBoundASTs;
- private FieldTypeSignature[] lowerBoundASTs;
+
+ /*
+ * We are required to evaluate the bounds lazily, so we store them as ASTs
+ * until we are first asked for them. This also neatly solves the problem
+ * with F-bounds - you can't reify them before the formal is defined.
+ */
+
+ /** The upper bounds. Lazily converted from FieldTypeSignature[] to Type[]. */
+ private volatile Object[] upperBounds;
+
+ /** The lower bounds. Lazily converted from FieldTypeSignature[] to Type[]. */
+ private volatile Object[] lowerBounds;
// constructor is private to enforce access through static factory
private WildcardTypeImpl(FieldTypeSignature[] ubs,
FieldTypeSignature[] lbs,
GenericsFactory f) {
super(f);
- upperBoundASTs = ubs;
- lowerBoundASTs = lbs;
+ upperBounds = ubs;
+ lowerBounds = lbs;
}
/**
@@ -76,27 +77,8 @@
return new WildcardTypeImpl(ubs, lbs, f);
}
- // Accessors
-
- // accessor for ASTs for upper bounds. Must not be called after upper
- // bounds have been evaluated, because we might throw the ASTs
- // away (but that is not thread-safe, is it?)
- private FieldTypeSignature[] getUpperBoundASTs() {
- // check that upper bounds were not evaluated yet
- assert(upperBounds == null);
- return upperBoundASTs;
- }
- // accessor for ASTs for lower bounds. Must not be called after lower
- // bounds have been evaluated, because we might throw the ASTs
- // away (but that is not thread-safe, is it?)
- private FieldTypeSignature[] getLowerBoundASTs() {
- // check that lower bounds were not evaluated yet
- assert(lowerBounds == null);
- return lowerBoundASTs;
- }
-
/**
- * Returns an array of <tt>Type</tt> objects representing the upper
+ * Returns an array of <tt>Type</tt> objects representing the upper
* bound(s) of this type variable. Note that if no upper bound is
* explicitly declared, the upper bound is <tt>Object</tt>.
*
@@ -117,24 +99,12 @@
* for any reason
*/
public Type[] getUpperBounds() {
- // lazily initialize bounds if necessary
- if (upperBounds == null) {
- FieldTypeSignature[] fts = getUpperBoundASTs(); // get AST
-
- // allocate result array; note that
- // keeping ts and bounds separate helps with threads
- Type[] ts = new Type[fts.length];
- // iterate over bound trees, reifying each in turn
- for ( int j = 0; j < fts.length; j++) {
- Reifier r = getReifier();
- fts[j].accept(r);
- ts[j] = r.getResult();
- }
- // cache result
- upperBounds = ts;
- // could throw away upper bound ASTs here; thread safety?
+ Object[] value = upperBounds;
+ if (value instanceof FieldTypeSignature[]) {
+ value = reifyBounds((FieldTypeSignature[])value);
+ upperBounds = value;
}
- return upperBounds.clone(); // return cached bounds
+ return (Type[])value.clone();
}
/**
@@ -160,23 +130,12 @@
* for any reason
*/
public Type[] getLowerBounds() {
- // lazily initialize bounds if necessary
- if (lowerBounds == null) {
- FieldTypeSignature[] fts = getLowerBoundASTs(); // get AST
- // allocate result array; note that
- // keeping ts and bounds separate helps with threads
- Type[] ts = new Type[fts.length];
- // iterate over bound trees, reifying each in turn
- for ( int j = 0; j < fts.length; j++) {
- Reifier r = getReifier();
- fts[j].accept(r);
- ts[j] = r.getResult();
- }
- // cache result
- lowerBounds = ts;
- // could throw away lower bound ASTs here; thread safety?
+ Object[] value = lowerBounds;
+ if (value instanceof FieldTypeSignature[]) {
+ value = reifyBounds((FieldTypeSignature[])value);
+ lowerBounds = value;
}
- return lowerBounds.clone(); // return cached bounds
+ return (Type[])value.clone();
}
public String toString() {
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/AbstractRepository.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/AbstractRepository.java Wed Jul 05 20:11:52 2017 +0200
@@ -56,7 +56,7 @@
/**
* Returns a <tt>Reifier</tt> used to convert parts of the
* AST into reflective objects.
- * @return a <tt>Reifier</tt> used to convert parts of the
+ * @return a <tt>Reifier</tt> used to convert parts of the
* AST into reflective objects
*/
protected Reifier getReifier(){return Reifier.make(getFactory());}
@@ -76,7 +76,7 @@
}
/**
- * Returns the AST for the genric type info of this entity.
+ * Returns the AST for the generic type info of this entity.
* @param s - a string representing the generic signature of this
* entity
* @return the AST for the generic type info of this entity.
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/ClassRepository.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/ClassRepository.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,12 +25,12 @@
package sun.reflect.generics.repository;
+import java.lang.reflect.Type;
import sun.reflect.generics.factory.GenericsFactory;
import sun.reflect.generics.tree.ClassSignature;
import sun.reflect.generics.tree.TypeTree;
import sun.reflect.generics.visitor.Reifier;
import sun.reflect.generics.parser.SignatureParser;
-import java.lang.reflect.Type;
/**
@@ -70,47 +70,54 @@
return new ClassRepository(rawSig, f);
}
- // public API
/*
* When queried for a particular piece of type information, the
* general pattern is to consult the corresponding cached value.
* If the corresponding field is non-null, it is returned.
* If not, it is created lazily. This is done by selecting the appropriate
* part of the tree and transforming it into a reflective object
- * using a visitor.
- * a visitor, which is created by feeding it the factory
+ * using a visitor, which is created by feeding it the factory
* with which the repository was created.
*/
public Type getSuperclass() {
- Type superclass = this.superclass;
- if (superclass == null) { // lazily initialize superclass
- Reifier r = getReifier(); // obtain visitor
- // Extract superclass subtree from AST and reify
- getTree().getSuperclass().accept(r);
- // extract result from visitor and cache it
- superclass = r.getResult();
- this.superclass = superclass;
+ Type value = superclass;
+ if (value == null) {
+ value = computeSuperclass();
+ superclass = value;
}
- return superclass; // return cached result
+ return value;
}
public Type[] getSuperInterfaces() {
- Type[] superInterfaces = this.superInterfaces;
- if (superInterfaces == null) { // lazily initialize super interfaces
- // first, extract super interface subtree(s) from AST
- TypeTree[] ts = getTree().getSuperInterfaces();
- // create array to store reified subtree(s)
- superInterfaces = new Type[ts.length];
- // reify all subtrees
- for (int i = 0; i < ts.length; i++) {
- Reifier r = getReifier(); // obtain visitor
- ts[i].accept(r);// reify subtree
- // extract result from visitor and store it
- superInterfaces[i] = r.getResult();
- }
- this.superInterfaces = superInterfaces;
+ Type[] value = superInterfaces;
+ if (value == null) {
+ value = computeSuperInterfaces();
+ superInterfaces = value;
}
- return superInterfaces.clone(); // return cached result
+ return value.clone();
+ }
+
+ private Type computeSuperclass() {
+ Reifier r = getReifier(); // obtain visitor
+ // Extract superclass subtree from AST and reify
+ getTree().getSuperclass().accept(r);
+ return r.getResult();
+ }
+
+ private Type[] computeSuperInterfaces() {
+ // first, extract super interface subtree(s) from AST
+ TypeTree[] ts = getTree().getSuperInterfaces();
+ // create array to store reified subtree(s)
+ int length = ts.length;
+ Type[] superInterfaces = new Type[length];
+ // reify all subtrees
+ for (int i = 0; i < length; i++) {
+ Reifier r = getReifier(); // obtain visitor
+ ts[i].accept(r);// reify subtree
+ // extract result from visitor and store it
+ superInterfaces[i] = r.getResult();
+ }
+ return superInterfaces;
}
}
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/ConstructorRepository.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/ConstructorRepository.java Wed Jul 05 20:11:52 2017 +0200
@@ -43,8 +43,11 @@
public class ConstructorRepository
extends GenericDeclRepository<MethodTypeSignature> {
- private Type[] paramTypes; // caches the generic parameter types info
- private Type[] exceptionTypes; // caches the generic exception types info
+ /** The generic parameter types. Lazily initialized. */
+ private volatile Type[] parameterTypes;
+
+ /** The generic exception types. Lazily initialized. */
+ private volatile Type[] exceptionTypes;
// protected, to enforce use of static factory yet allow subclassing
protected ConstructorRepository(String rawSig, GenericsFactory f) {
@@ -64,57 +67,67 @@
* @return a <tt>ConstructorRepository</tt> that manages the generic type
* information represented in the signature <tt>rawSig</tt>
*/
- public static ConstructorRepository make(String rawSig,
- GenericsFactory f) {
+ public static ConstructorRepository make(String rawSig, GenericsFactory f) {
return new ConstructorRepository(rawSig, f);
}
- // public API
-
/*
* When queried for a particular piece of type information, the
* general pattern is to consult the corresponding cached value.
* If the corresponding field is non-null, it is returned.
* If not, it is created lazily. This is done by selecting the appropriate
* part of the tree and transforming it into a reflective object
- * using a visitor.
- * a visitor, which is created by feeding it the factory
+ * using a visitor, which is created by feeding it the factory
* with which the repository was created.
*/
- public Type[] getParameterTypes(){
- if (paramTypes == null) { // lazily initialize parameter types
- // first, extract parameter type subtree(s) from AST
- TypeSignature[] pts = getTree().getParameterTypes();
- // create array to store reified subtree(s)
- Type[] ps = new Type[pts.length];
- // reify all subtrees
- for (int i = 0; i < pts.length; i++) {
- Reifier r = getReifier(); // obtain visitor
- pts[i].accept(r); // reify subtree
- // extract result from visitor and store it
- ps[i] = r.getResult();
- }
- paramTypes = ps; // cache overall result
+ public Type[] getParameterTypes() {
+ Type[] value = parameterTypes;
+ if (value == null) {
+ value = computeParameterTypes();
+ parameterTypes = value;
}
- return paramTypes.clone(); // return cached result
+ return value.clone();
+ }
+
+ public Type[] getExceptionTypes() {
+ Type[] value = exceptionTypes;
+ if (value == null) {
+ value = computeExceptionTypes();
+ exceptionTypes = value;
+ }
+ return value.clone();
}
- public Type[] getExceptionTypes(){
- if (exceptionTypes == null) { // lazily initialize exception types
- // first, extract exception type subtree(s) from AST
- FieldTypeSignature[] ets = getTree().getExceptionTypes();
- // create array to store reified subtree(s)
- Type[] es = new Type[ets.length];
- // reify all subtrees
- for (int i = 0; i < ets.length; i++) {
- Reifier r = getReifier(); // obtain visitor
- ets[i].accept(r); // reify subtree
- // extract result from visitor and store it
- es[i] = r.getResult();
- }
- exceptionTypes = es; // cache overall result
+ private Type[] computeParameterTypes() {
+ // first, extract parameter type subtree(s) from AST
+ TypeSignature[] pts = getTree().getParameterTypes();
+ // create array to store reified subtree(s)
+ int length = pts.length;
+ Type[] parameterTypes = new Type[length];
+ // reify all subtrees
+ for (int i = 0; i < length; i++) {
+ Reifier r = getReifier(); // obtain visitor
+ pts[i].accept(r); // reify subtree
+ // extract result from visitor and store it
+ parameterTypes[i] = r.getResult();
}
- return exceptionTypes.clone(); // return cached result
+ return parameterTypes;
+ }
+
+ private Type[] computeExceptionTypes() {
+ // first, extract exception type subtree(s) from AST
+ FieldTypeSignature[] ets = getTree().getExceptionTypes();
+ // create array to store reified subtree(s)
+ int length = ets.length;
+ Type[] exceptionTypes = new Type[length];
+ // reify all subtrees
+ for (int i = 0; i < length; i++) {
+ Reifier r = getReifier(); // obtain visitor
+ ets[i].accept(r); // reify subtree
+ // extract result from visitor and store it
+ exceptionTypes[i] = r.getResult();
+ }
+ return exceptionTypes;
}
}
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/FieldRepository.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/FieldRepository.java Wed Jul 05 20:11:52 2017 +0200
@@ -41,7 +41,8 @@
*/
public class FieldRepository extends AbstractRepository<TypeSignature> {
- private Type genericType; // caches the generic type info
+ /** The generic type info. Lazily initialized. */
+ private volatile Type genericType;
// protected, to enforce use of static factory yet allow subclassing
protected FieldRepository(String rawSig, GenericsFactory f) {
@@ -61,31 +62,32 @@
* @return a <tt>FieldRepository</tt> that manages the generic type
* information represented in the signature <tt>rawSig</tt>
*/
- public static FieldRepository make(String rawSig,
- GenericsFactory f) {
+ public static FieldRepository make(String rawSig, GenericsFactory f) {
return new FieldRepository(rawSig, f);
}
- // public API
-
/*
* When queried for a particular piece of type information, the
* general pattern is to consult the corresponding cached value.
* If the corresponding field is non-null, it is returned.
* If not, it is created lazily. This is done by selecting the appropriate
* part of the tree and transforming it into a reflective object
- * using a visitor.
- * a visitor, which is created by feeding it the factory
+ * using a visitor, which is created by feeding it the factory
* with which the repository was created.
*/
- public Type getGenericType(){
- if (genericType == null) { // lazily initialize generic type
- Reifier r = getReifier(); // obtain visitor
- getTree().accept(r); // reify subtree
- // extract result from visitor and cache it
- genericType = r.getResult();
+ public Type getGenericType() {
+ Type value = genericType;
+ if (value == null) {
+ value = computeGenericType();
+ genericType = value;
}
- return genericType; // return cached result
+ return value;
+ }
+
+ private Type computeGenericType() {
+ Reifier r = getReifier(); // obtain visitor
+ getTree().accept(r); // reify subtree
+ return r.getResult(); // extract result from visitor
}
}
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java Wed Jul 05 20:11:52 2017 +0200
@@ -43,13 +43,12 @@
extends AbstractRepository<S> {
/** The formal type parameters. Lazily initialized. */
- private volatile TypeVariable<?>[] typeParams;
+ private volatile TypeVariable<?>[] typeParameters;
protected GenericDeclRepository(String rawSig, GenericsFactory f) {
super(rawSig, f);
}
- // public API
/*
* When queried for a particular piece of type information, the
* general pattern is to consult the corresponding cached value.
@@ -61,25 +60,31 @@
*/
/**
- * Return the formal type parameters of this generic declaration.
+ * Returns the formal type parameters of this generic declaration.
* @return the formal type parameters of this generic declaration
*/
public TypeVariable<?>[] getTypeParameters() {
- TypeVariable<?>[] typeParams = this.typeParams;
- if (typeParams == null) { // lazily initialize type parameters
- // first, extract type parameter subtree(s) from AST
- FormalTypeParameter[] ftps = getTree().getFormalTypeParameters();
- // create array to store reified subtree(s)
- typeParams = new TypeVariable<?>[ftps.length];
- // reify all subtrees
- for (int i = 0; i < ftps.length; i++) {
- Reifier r = getReifier(); // obtain visitor
- ftps[i].accept(r); // reify subtree
- // extract result from visitor and store it
- typeParams[i] = (TypeVariable<?>) r.getResult();
- }
- this.typeParams = typeParams; // cache overall result
+ TypeVariable<?>[] value = typeParameters;
+ if (value == null) {
+ value = computeTypeParameters();
+ typeParameters = value;
}
- return typeParams.clone(); // return cached result
+ return value.clone();
+ }
+
+ private TypeVariable<?>[] computeTypeParameters() {
+ // first, extract type parameter subtree(s) from AST
+ FormalTypeParameter[] ftps = getTree().getFormalTypeParameters();
+ // create array to store reified subtree(s)
+ int length = ftps.length;
+ TypeVariable<?>[] typeParameters = new TypeVariable<?>[length];
+ // reify all subtrees
+ for (int i = 0; i < length; i++) {
+ Reifier r = getReifier(); // obtain visitor
+ ftps[i].accept(r); // reify subtree
+ // extract result from visitor and store it
+ typeParameters[i] = (TypeVariable<?>) r.getResult();
+ }
+ return typeParameters;
}
}
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/MethodRepository.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/MethodRepository.java Wed Jul 05 20:11:52 2017 +0200
@@ -39,7 +39,8 @@
*/
public class MethodRepository extends ConstructorRepository {
- private Type returnType; // caches the generic return type info
+ /** The generic return type info. Lazily initialized. */
+ private volatile Type returnType;
// private, to enforce use of static factory
private MethodRepository(String rawSig, GenericsFactory f) {
@@ -59,18 +60,21 @@
return new MethodRepository(rawSig, f);
}
- // public API
-
public Type getReturnType() {
- if (returnType == null) { // lazily initialize return type
- Reifier r = getReifier(); // obtain visitor
- // Extract return type subtree from AST and reify
- getTree().getReturnType().accept(r);
- // extract result from visitor and cache it
- returnType = r.getResult();
- }
- return returnType; // return cached result
+ Type value = returnType;
+ if (value == null) {
+ value = computeReturnType();
+ returnType = value;
+ }
+ return value;
}
+ private Type computeReturnType() {
+ Reifier r = getReifier(); // obtain visitor
+ // Extract return type subtree from AST and reify
+ getTree().getReturnType().accept(r);
+ // extract result from visitor and cache it
+ return r.getResult();
+ }
}
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/scope/AbstractScope.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/scope/AbstractScope.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,7 +29,6 @@
import java.lang.reflect.TypeVariable;
-
/**
* Abstract superclass for lazy scope objects, used when building
* factories for generic information repositories.
@@ -49,7 +48,7 @@
/**
* Constructor. Takes a reflective object whose scope the newly
* constructed instance will represent.
- * @param D - A generic declaration whose scope the newly
+ * @param decl - A generic declaration whose scope the newly
* constructed instance will represent
*/
protected AbstractScope(D decl){ recvr = decl;}
@@ -63,7 +62,7 @@
/** This method must be implemented by any concrete subclass.
* It must return the enclosing scope of this scope. If this scope
- * is a top-level scope, an instance of DummyScope must be returned.
+ * is a top-level scope, an instance of DummyScope must be returned.
* @return The enclosing scope of this scope
*/
protected abstract Scope computeEnclosingScope();
@@ -72,13 +71,13 @@
* Accessor for the enclosing scope, which is computed lazily and cached.
* @return the enclosing scope
*/
- protected Scope getEnclosingScope(){
- Scope enclosingScope = this.enclosingScope;
- if (enclosingScope == null) {
- enclosingScope = computeEnclosingScope();
- this.enclosingScope = enclosingScope;
+ protected Scope getEnclosingScope() {
+ Scope value = enclosingScope;
+ if (value == null) {
+ value = computeEnclosingScope();
+ enclosingScope = value;
}
- return enclosingScope;
+ return value;
}
/**
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/tree/Signature.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/tree/Signature.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,7 +27,7 @@
/**
* Common superinterface for generic signatures. These are the signatures
- * of complete class and method/constructor delcarations.
+ * of complete class and method/constructor declarations.
*/
public interface Signature extends Tree{
FormalTypeParameter[] getFormalTypeParameters();
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/tree/Wildcard.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/tree/Wildcard.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,8 @@
import sun.reflect.generics.visitor.TypeTreeVisitor;
public class Wildcard implements TypeArgument {
- private FieldTypeSignature[] upperBounds;
- private FieldTypeSignature[] lowerBounds;
+ private final FieldTypeSignature[] upperBounds;
+ private final FieldTypeSignature[] lowerBounds;
private Wildcard(FieldTypeSignature[] ubs, FieldTypeSignature[] lbs) {
upperBounds = ubs;
@@ -43,11 +43,11 @@
return new Wildcard(ubs, lbs);
}
- public FieldTypeSignature[] getUpperBounds(){
+ public FieldTypeSignature[] getUpperBounds() {
return upperBounds;
}
- public FieldTypeSignature[] getLowerBounds(){
+ public FieldTypeSignature[] getLowerBounds() {
if (lowerBounds.length == 1 &&
lowerBounds[0] == BottomSignature.make())
return emptyBounds;
--- a/jdk/src/java.base/share/classes/sun/reflect/generics/visitor/Reifier.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/generics/visitor/Reifier.java Wed Jul 05 20:11:52 2017 +0200
@@ -39,7 +39,7 @@
*/
public class Reifier implements TypeTreeVisitor<Type> {
private Type resultType;
- private GenericsFactory factory;
+ private final GenericsFactory factory;
private Reifier(GenericsFactory f){
factory = f;
--- a/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java Wed Jul 05 20:11:52 2017 +0200
@@ -40,6 +40,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Modifier;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import sun.misc.IOUtils;
@@ -216,17 +217,21 @@
* key in the method cache.
*/
private static class Signature {
- private String methodName;
- private Class<?>[] argClasses;
-
- private volatile int hashCode = 0;
+ private final String methodName;
+ private final Class<?>[] argClasses;
+ private final int hashCode;
Signature(Method m) {
this.methodName = m.getName();
this.argClasses = m.getParameterTypes();
+ this.hashCode = methodName.hashCode() + Arrays.hashCode(argClasses);
}
- public boolean equals(Object o2) {
+ @Override public int hashCode() {
+ return hashCode;
+ }
+
+ @Override public boolean equals(Object o2) {
if (this == o2) {
return true;
}
@@ -244,25 +249,6 @@
}
return true;
}
-
- /**
- * Hash code computed using algorithm suggested in
- * Effective Java, Item 8.
- */
- public int hashCode() {
- if (hashCode == 0) {
- int result = 17;
- result = 37 * result + methodName.hashCode();
- if (argClasses != null) {
- for (int i = 0; i < argClasses.length; i++) {
- result = 37 * result + ((argClasses[i] == null) ? 0 :
- argClasses[i].hashCode());
- }
- }
- hashCode = result;
- }
- return hashCode;
- }
}
--- a/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java Wed Jul 05 20:11:52 2017 +0200
@@ -319,7 +319,7 @@
return;
}
- // disallow any method not declared in one of the proxy intefaces
+ // disallow any method not declared in one of the proxy interfaces
throw new IllegalArgumentException("Can't handle: " + method);
}
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java Wed Jul 05 20:11:52 2017 +0200
@@ -1040,7 +1040,7 @@
}
/**
- * Evaluates the the global policy for the permissions granted to
+ * Evaluates the global policy for the permissions granted to
* the ProtectionDomain and tests whether the permission is
* granted.
*
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EphemeralKeyManager.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/EphemeralKeyManager.java Wed Jul 05 20:11:52 2017 +0200
@@ -41,7 +41,7 @@
/*
* Current cached RSA KeyPairs. Elements are never null.
- * Indexed via the the constants above.
+ * Indexed via the constants above.
*/
private final EphemeralKeyPair[] keys = new EphemeralKeyPair[] {
new EphemeralKeyPair(null),
--- a/jdk/src/java.base/share/classes/sun/security/ssl/MAC.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/MAC.java Wed Jul 05 20:11:52 2017 +0200
@@ -120,7 +120,7 @@
* @param buf compressed record on which the MAC is computed
* @param offset start of compressed record data
* @param len the size of the compressed record
- * @param isSimulated if true, simulate the the MAC computation
+ * @param isSimulated if true, simulate the MAC computation
*/
final byte[] compute(byte type, byte buf[],
int offset, int len, boolean isSimulated) {
@@ -147,7 +147,7 @@
* @param type record type
* @param bb a ByteBuffer in which the position and limit
* demarcate the data to be MAC'd.
- * @param isSimulated if true, simulate the the MAC computation
+ * @param isSimulated if true, simulate the MAC computation
*/
final byte[] compute(byte type, ByteBuffer bb, boolean isSimulated) {
if (macAlg.size == 0) {
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -77,7 +77,7 @@
* All data is routed through
* EngineInputRecord/EngineOutputRecord. However, all handshake
* data (ct_alert/ct_change_cipher_spec/ct_handshake) are passed
- * through to the the underlying InputRecord/OutputRecord, and
+ * through to the underlying InputRecord/OutputRecord, and
* the data uses the internal buffers.
*
* Application data is handled slightly different, we copy the data
@@ -158,7 +158,7 @@
* v |
* ERROR>------>----->CLOSED<--------<----+
*
- * ALSO, note that the the purpose of handshaking (renegotiation is
+ * ALSO, note that the purpose of handshaking (renegotiation is
* included) is to assign a different, and perhaps new, session to
* the connection. The SSLv3 spec is a bit confusing on that new
* protocol feature.
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -144,7 +144,7 @@
* v
* APP_CLOSED
*
- * ALSO, note that the the purpose of handshaking (renegotiation is
+ * ALSO, note that the purpose of handshaking (renegotiation is
* included) is to assign a different, and perhaps new, session to
* the connection. The SSLv3 spec is a bit confusing on that new
* protocol feature.
@@ -2190,7 +2190,7 @@
}
/**
- * Returns the the SSL Session in use by this connection. These can
+ * Returns the SSL Session in use by this connection. These can
* be long lived, and frequently correspond to an entire login session
* for some user.
*/
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java Wed Jul 05 20:11:52 2017 +0200
@@ -1467,7 +1467,7 @@
if (serverPrincipal != null) {
// When service is bound, we check ASAP. Otherwise,
// will check after client request is received
- // in in Kerberos ClientKeyExchange
+ // in Kerberos ClientKeyExchange
SecurityManager sm = System.getSecurityManager();
try {
if (sm != null) {
--- a/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java Wed Jul 05 20:11:52 2017 +0200
@@ -39,7 +39,7 @@
* algorithm type, and may also be used in other cases. Equivalence is
* defined according to OID and (where relevant) parameters.
*
- * <P>Subclasses may be used, for example when when the algorithm ID has
+ * <P>Subclasses may be used, for example when the algorithm ID has
* associated parameters which some code (e.g. code using public keys) needs
* to have parsed. Two examples of such algorithms are Diffie-Hellman key
* exchange, and the Digital Signature Standard Algorithm (DSS/DSA).
--- a/jdk/src/java.base/share/classes/sun/security/x509/GeneralName.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/x509/GeneralName.java Wed Jul 05 20:11:52 2017 +0200
@@ -221,7 +221,7 @@
/**
* Encode the name to the specified DerOutputStream.
*
- * @param out the DerOutputStream to encode the the GeneralName to.
+ * @param out the DerOutputStream to encode the GeneralName to.
* @exception IOException on encoding errors.
*/
public void encode(DerOutputStream out) throws IOException {
--- a/jdk/src/java.base/share/classes/sun/security/x509/URIName.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/x509/URIName.java Wed Jul 05 20:11:52 2017 +0200
@@ -302,7 +302,7 @@
* <p>
* RFC5280: For URIs, the constraint applies to the host part of the name.
* The constraint may specify a host or a domain. Examples would be
- * "foo.bar.com"; and ".xyz.com". When the the constraint begins with
+ * "foo.bar.com"; and ".xyz.com". When the constraint begins with
* a period, it may be expanded with one or more subdomains. That is,
* the constraint ".xyz.com" is satisfied by both abc.xyz.com and
* abc.def.xyz.com. However, the constraint ".xyz.com" is not satisfied
--- a/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java Wed Jul 05 20:11:52 2017 +0200
@@ -336,7 +336,7 @@
}
/**
- * Return an immutable List of the the AVAs contained in all the
+ * Return an immutable List of the AVAs contained in all the
* RDNs of this X500Name.
*/
public List<AVA> allAvas() {
--- a/jdk/src/java.base/share/classes/sun/text/normalizer/NormalizerBase.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/text/normalizer/NormalizerBase.java Wed Jul 05 20:11:52 2017 +0200
@@ -646,9 +646,9 @@
/**
* Compose a string.
- * The string will be composed to according the the specified mode.
+ * The string will be composed according to the specified mode.
* @param str The string to compose.
- * @param compat If true the string will be composed accoding to
+ * @param compat If true the string will be composed according to
* NFKC rules and if false will be composed according to
* NFC rules.
* @param options The only recognized option is UNICODE_3_2
@@ -694,9 +694,9 @@
/**
* Decompose a string.
- * The string will be decomposed to according the the specified mode.
+ * The string will be decomposed according to the specified mode.
* @param str The string to decompose.
- * @param compat If true the string will be decomposed accoding to NFKD
+ * @param compat If true the string will be decomposed according to NFKD
* rules and if false will be decomposed according to NFD
* rules.
* @return String The decomposed string
@@ -708,9 +708,9 @@
/**
* Decompose a string.
- * The string will be decomposed to according the the specified mode.
+ * The string will be decomposed according to the specified mode.
* @param str The string to decompose.
- * @param compat If true the string will be decomposed accoding to NFKD
+ * @param compat If true the string will be decomposed according to NFKD
* rules and if false will be decomposed according to NFD
* rules.
* @param options The normalization options, ORed together (0 for no options).
@@ -756,7 +756,7 @@
/**
* Normalize a string.
- * The string will be normalized according the the specified normalization
+ * The string will be normalized according to the specified normalization
* mode and options.
* @param src The char array to compose.
* @param srcStart Start index of the source
--- a/jdk/src/java.base/share/classes/sun/text/normalizer/UCharacterIterator.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/text/normalizer/UCharacterIterator.java Wed Jul 05 20:11:52 2017 +0200
@@ -247,7 +247,7 @@
//// for StringPrep
/**
- * Convenience method for returning the underlying text storage as as string
+ * Convenience method for returning the underlying text storage as a string
* @return the underlying text storage in the iterator as a string
* @stable ICU 2.4
*/
--- a/jdk/src/java.base/share/classes/sun/text/normalizer/UTF16.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/text/normalizer/UTF16.java Wed Jul 05 20:11:52 2017 +0200
@@ -94,7 +94,7 @@
* </li>
* <li>
* <strong>Exceptions:</strong> The error checking will throw an exception
- * if indices are out of bounds. Other than than that, all methods will
+ * if indices are out of bounds. Other than that, all methods will
* behave reasonably, even if unmatched surrogates or out-of-bounds UTF-32
* values are present. <code>UCharacter.isLegal()</code> can be used to check
* for validity if desired.
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java Wed Jul 05 20:11:52 2017 +0200
@@ -77,7 +77,8 @@
public P run() {
P delegate = null;
- for (LocaleServiceProvider provider : ServiceLoader.loadInstalled(c)) {
+ for (LocaleServiceProvider provider :
+ ServiceLoader.load(c, ClassLoader.getSystemClassLoader())) {
if (delegate == null) {
try {
delegate =
--- a/jdk/src/java.base/share/native/libjli/java.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/share/native/libjli/java.c Wed Jul 05 20:11:52 2017 +0200
@@ -169,6 +169,13 @@
static jlong initialHeapSize = 0; /* inital heap size */
/*
+ * A minimum -Xss stack size suitable for all platforms.
+ */
+#ifndef STACK_SIZE_MINIMUM
+#define STACK_SIZE_MINIMUM (32 * KB)
+#endif
+
+/*
* Entry point.
*/
int
@@ -737,7 +744,7 @@
}
/*
- * Adds a new VM option with the given given name and value.
+ * Adds a new VM option with the given name and value.
*/
void
AddOption(char *str, void *info)
@@ -766,6 +773,14 @@
jlong tmp;
if (parse_size(str + 4, &tmp)) {
threadStackSize = tmp;
+ /*
+ * Make sure the thread stack size is big enough that we won't get a stack
+ * overflow before the JVM startup code can check to make sure the stack
+ * is big enough.
+ */
+ if (threadStackSize < STACK_SIZE_MINIMUM) {
+ threadStackSize = STACK_SIZE_MINIMUM;
+ }
}
}
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/FileKey.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/FileKey.java Wed Jul 05 20:11:52 2017 +0200
@@ -38,13 +38,9 @@
private FileKey() { }
- public static FileKey create(FileDescriptor fd) {
+ public static FileKey create(FileDescriptor fd) throws IOException {
FileKey fk = new FileKey();
- try {
- fk.init(fd);
- } catch (IOException ioe) {
- throw new Error(ioe);
- }
+ fk.init(fd);
return fk;
}
--- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c Wed Jul 05 20:11:52 2017 +0200
@@ -89,7 +89,7 @@
*
* However, if the environment contains a LD_LIBRARY_PATH, this will cause the
* launcher to inspect the LD_LIBRARY_PATH. The launcher will check
- * a. if the LD_LIBRARY_PATH's first component is the the path to the desired
+ * a. if the LD_LIBRARY_PATH's first component is the path to the desired
* libjvm.so
* b. if any other libjvm.so is found in any of the paths.
* If case b is true, then the launcher will set the LD_LIBRARY_PATH to the
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c Wed Jul 05 20:11:52 2017 +0200
@@ -2070,7 +2070,7 @@
* so we switch to IPV6_ADD_MEMBERSHIP socket option.
* As of 2.4.7 kernel IPV6_ADD_MEMBERSHIP can't handle IPv4-mapped
* addresses so we have to use IP_ADD_MEMBERSHIP for IPv4 multicast
- * groups. However if the socket is an IPv6 socket then then setsockopt
+ * groups. However if the socket is an IPv6 socket then setsockopt
* should return ENOPROTOOPT. We assume this will be fixed in Linux
* at some stage.
*/
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c Wed Jul 05 20:11:52 2017 +0200
@@ -1053,7 +1053,7 @@
} else {
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
/* Bug 4086704 - If the Socket associated with this file descriptor
- * was closed (sysCloseFD), the the file descriptor is set to -1.
+ * was closed (sysCloseFD), the file descriptor is set to -1.
*/
if (fd == -1) {
JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
--- a/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c Wed Jul 05 20:11:52 2017 +0200
@@ -74,7 +74,7 @@
} else {
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
/* Bug 4086704 - If the Socket associated with this file descriptor
- * was closed (sysCloseFD), the the file descriptor is set to -1.
+ * was closed (sysCloseFD), the file descriptor is set to -1.
*/
if (fd == -1) {
JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c Wed Jul 05 20:11:52 2017 +0200
@@ -1433,7 +1433,7 @@
/*
* On Linux the receive buffer is used for both socket
- * structures and the the packet payload. The implication
+ * structures and the packet payload. The implication
* is that if SO_RCVBUF is too small then small packets
* must be discard.
*/
--- a/jdk/src/java.base/windows/classes/sun/nio/ch/FileKey.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/FileKey.java Wed Jul 05 20:11:52 2017 +0200
@@ -39,13 +39,9 @@
private FileKey() { }
- public static FileKey create(FileDescriptor fd) {
+ public static FileKey create(FileDescriptor fd) throws IOException {
FileKey fk = new FileKey();
- try {
- fk.init(fd);
- } catch (IOException ioe) {
- throw new Error(ioe);
- }
+ fk.init(fd);
return fk;
}
--- a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c Wed Jul 05 20:11:52 2017 +0200
@@ -26,7 +26,7 @@
/*
* Converts a single string command line to the traditional argc, argv.
- * There are rules which govern the breaking of the the arguments, and
+ * There are rules which govern the breaking of the arguments, and
* these rules are embodied in the regression tests below, and duplicated
* in the jdk regression tests.
*/
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c Wed Jul 05 20:11:52 2017 +0200
@@ -1159,7 +1159,7 @@
} else {
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
/* Bug 4086704 - If the Socket associated with this file descriptor
- * was closed (sysCloseFD), the the file descriptor is set to -1.
+ * was closed (sysCloseFD), the file descriptor is set to -1.
*/
if (fd == -1) {
JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java Wed Jul 05 20:11:52 2017 +0200
@@ -496,10 +496,15 @@
// This is somewhat messy. The difference here from BasicComboBoxUI.EnterAction is that
// arrow up or down does not automatically select the
@SuppressWarnings("serial") // anonymous class
- private static final Action triggerSelectionAction = new AbstractAction() {
+ private final Action triggerSelectionAction = new AbstractAction() {
public void actionPerformed(final ActionEvent e) {
triggerSelectionEvent((JComboBox)e.getSource(), e);
}
+
+ @Override
+ public boolean isEnabled() {
+ return comboBox.isPopupVisible() && super.isEnabled();
+ }
};
@SuppressWarnings("serial") // anonymous class
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java Wed Jul 05 20:11:52 2017 +0200
@@ -1300,12 +1300,12 @@
filters = (FileFilter[]) e.getNewValue();
fireContentsChanged(this, -1, -1);
} else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) {
- fireContentsChanged(this, -1, -1);
+ setSelectedItem(e.getNewValue());
}
}
public void setSelectedItem(Object filter) {
- if(filter != null) {
+ if (filter != null && !containsFileFilter(filter)) {
getFileChooser().setFileFilter((FileFilter) filter);
fireContentsChanged(this, -1, -1);
}
@@ -1353,6 +1353,10 @@
}
}
+ private boolean containsFileFilter(Object fileFilter) {
+ return Objects.equals(fileFilter, getFileChooser().getFileFilter());
+ }
+
/**
* Acts when FilterComboBox has changed the selected item.
*/
@@ -1363,7 +1367,10 @@
}
public void actionPerformed(final ActionEvent e) {
- getFileChooser().setFileFilter((FileFilter) filterComboBox.getSelectedItem());
+ Object selectedFilter = filterComboBox.getSelectedItem();
+ if (!containsFileFilter(selectedFilter)) {
+ getFileChooser().setFileFilter((FileFilter) selectedFilter);
+ }
}
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollPaneUI.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollPaneUI.java Wed Jul 05 20:11:52 2017 +0200
@@ -41,7 +41,7 @@
// This is a grody hack to trick BasicScrollPaneUI into scrolling horizontally
// when we notice that the shift key is down. This should be removed when AWT/Swing
- // becomes aware of of multi-axis scroll wheels.
+ // becomes aware of multi-axis scroll wheels.
protected class XYMouseWheelHandler extends javax.swing.plaf.basic.BasicScrollPaneUI.MouseWheelHandler {
public void mouseWheelMoved(final MouseWheelEvent e) {
JScrollBar vScrollBar = null;
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java Wed Jul 05 20:11:52 2017 +0200
@@ -1094,7 +1094,7 @@
}
/**
- * Clips the copy area to the heavywieght bounds and returns the cliped rectangle. The tricky part here is the the
+ * Clips the copy area to the heavywieght bounds and returns the cliped rectangle. The tricky part here is the
* passed arguments x, y are in the coordinate space of the sg2d/lightweight comp. In order to do the clipping we
* translate them to the coordinate space of the surface, and the returned clipped rectangle is in the coordinate
* space of the surface.
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m Wed Jul 05 20:11:52 2017 +0200
@@ -1692,7 +1692,7 @@
{
ImageSDOps *isdo = (ImageSDOps*)ops;
- // For every ImageSD_Unlock, we need to be be conservative and mark the pixels
+ // For every ImageSD_Unlock, we need to be conservative and mark the pixels
// as modified by the Sun2D renderer.
isdo->javaImageInfo[sun_java2d_OSXOffScreenSurfaceData_kNeedToSyncFromJavaPixelsIndex] = 1;
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m Wed Jul 05 20:11:52 2017 +0200
@@ -72,7 +72,7 @@
// given a UInt32 color, it tries to find that find the corresponding CGColorRef in the hash cache. If the CGColorRef
// doesn't exist or there is a collision, it creates a new one CGColorRef and put's in the cache. Then,
-// it sets with current fill/stroke color for the the CGContext passed in (qsdo->cgRef).
+// it sets with current fill/stroke color for the CGContext passed in (qsdo->cgRef).
void setCachedColor(QuartzSDOps *qsdo, UInt32 color)
{
static const CGFloat kColorConversionMultiplier = 1.0f/255.0f;
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java Wed Jul 05 20:11:52 2017 +0200
@@ -898,7 +898,7 @@
y > innerR)) {
return false;
}
- // Rotate to origin and and verify x is valid.
+ // Rotate to origin and verify x is valid.
int triangleSize = innerR * 3 / 2;
double x1 = Math.cos(angle) * x - Math.sin(angle) * y;
double y1 = Math.sin(angle) * x + Math.cos(angle) * y;
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java Wed Jul 05 20:11:52 2017 +0200
@@ -1304,7 +1304,7 @@
* Render different filters
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
- public class FilterComboBoxRenderer extends DefaultListCellRenderer implements UIResource {
+ public class FilterComboBoxRenderer extends DefaultListCellRenderer {
public String getName() {
// As SynthComboBoxRenderer's are asked for a size BEFORE they
// are parented getName is overriden to force the name to be
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java Wed Jul 05 20:11:52 2017 +0200
@@ -87,7 +87,7 @@
* @param info the description of the device
*/
/*
- * The initial mode and and only supported mode default to OMNI_ON_POLY.
+ * The initial mode and only supported mode default to OMNI_ON_POLY.
*/
protected AbstractMidiDevice(MidiDevice.Info info) {
@@ -108,7 +108,7 @@
/** Open the device from an application program.
* Setting the open reference count to -1 here prevents Transmitters and Receivers that
- * opened the the device implicitly from closing it. The only way to close the device after
+ * opened the device implicitly from closing it. The only way to close the device after
* this call is a call to close().
*/
public final void open() throws MidiUnavailableException {
--- a/jdk/src/java.desktop/share/classes/java/awt/Button.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Button.java Wed Jul 05 20:11:52 2017 +0200
@@ -609,7 +609,7 @@
* Perform the specified Action on the object
*
* @param i zero-based index of actions
- * @return true if the the action was performed; else false.
+ * @return true if the action was performed; else false.
*/
public boolean doAccessibleAction(int i) {
if (i == 0) {
--- a/jdk/src/java.desktop/share/classes/java/awt/Checkbox.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Checkbox.java Wed Jul 05 20:11:52 2017 +0200
@@ -788,7 +788,7 @@
* Perform the specified Action on the object
*
* @param i zero-based index of actions
- * @return true if the the action was performed; else false.
+ * @return true if the action was performed; else false.
*/
public boolean doAccessibleAction(int i) {
return false; // To be fully implemented in a future release
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java Wed Jul 05 20:11:52 2017 +0200
@@ -4281,7 +4281,7 @@
}
/**
- * Makes specified region of the the next available buffer visible
+ * Makes specified region of the next available buffer visible
* by either blitting or flipping.
*/
void showSubRegion(int x1, int y1, int x2, int y2) {
@@ -7431,7 +7431,7 @@
* @param id one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
* KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or
* KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
- * @return <code>true</code> if the the Set of focus traversal keys for the
+ * @return <code>true</code> if the Set of focus traversal keys for the
* given focus traversal operation has been explicitly defined for
* this Component; <code>false</code> otherwise.
* @throws IllegalArgumentException if id is not one of
--- a/jdk/src/java.desktop/share/classes/java/awt/Container.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Container.java Wed Jul 05 20:11:52 2017 +0200
@@ -3193,7 +3193,7 @@
* KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
* KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or
* KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
- * @return <code>true</code> if the the Set of focus traversal keys for the
+ * @return <code>true</code> if the Set of focus traversal keys for the
* given focus traversal operation has been explicitly defined for
* this Component; <code>false</code> otherwise.
* @throws IllegalArgumentException if id is not one of
--- a/jdk/src/java.desktop/share/classes/java/awt/EventQueue.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/EventQueue.java Wed Jul 05 20:11:52 2017 +0200
@@ -823,7 +823,7 @@
}
/**
- * Returns the the event currently being dispatched by the
+ * Returns the event currently being dispatched by the
* <code>EventQueue</code> associated with the calling thread. This is
* useful if a method needs access to the event, but was not designed to
* receive a reference to it as an argument. Note that this method should
--- a/jdk/src/java.desktop/share/classes/java/awt/FlowLayout.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/FlowLayout.java Wed Jul 05 20:11:52 2017 +0200
@@ -503,7 +503,7 @@
* @param width the width dimensions
* @param height the height dimensions
* @param rowStart the beginning of the row
- * @param rowEnd the the ending of the row
+ * @param rowEnd the ending of the row
* @param useBaseline Whether or not to align on baseline.
* @param ascent Ascent for the components. This is only valid if
* useBaseline is true.
--- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java Wed Jul 05 20:11:52 2017 +0200
@@ -1771,7 +1771,7 @@
* will be notified in the order in which they were added; the current
* KeyboardFocusManager will be notified last. Notifications will halt
* as soon as one KeyEventPostProcessor returns <code>true</code> from its
- * <code>postProcessKeyEvent</code> method. There is no limit to the the
+ * <code>postProcessKeyEvent</code> method. There is no limit to the
* total number of KeyEventPostProcessors that can be added, nor to the
* number of times that a particular KeyEventPostProcessor instance can be
* added.
@@ -2666,7 +2666,7 @@
* We allow to trigger restoreFocus() in the dispatching process
* only if we have the last request to dispatch. If the last request
* fails, focus will be restored to either the component of the last
- * previously succeeded request, or to to the focus owner that was
+ * previously succeeded request, or to the focus owner that was
* before this clearing process.
*/
if (!iter.hasNext()) {
--- a/jdk/src/java.desktop/share/classes/java/awt/List.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/List.java Wed Jul 05 20:11:52 2017 +0200
@@ -347,7 +347,7 @@
}
/**
- * Adds the specified item to the the scrolling list
+ * Adds the specified item to the scrolling list
* at the position indicated by the index. The index is
* zero-based. If the value of the index is less than zero,
* or if the value of the index is greater than or equal to
@@ -364,7 +364,7 @@
}
/**
- * Adds the specified item to the the list
+ * Adds the specified item to the list
* at the position indicated by the index.
*
* @param item the item to be added
--- a/jdk/src/java.desktop/share/classes/java/awt/MultipleGradientPaintContext.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/MultipleGradientPaintContext.java Wed Jul 05 20:11:52 2017 +0200
@@ -418,7 +418,7 @@
// each interval
gradients[i] = new int[GRADIENT_SIZE];
- // get the the 2 colors
+ // get the 2 colors
rgb1 = colors[i].getRGB();
rgb2 = colors[i+1].getRGB();
--- a/jdk/src/java.desktop/share/classes/java/awt/RadialGradientPaint.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/RadialGradientPaint.java Wed Jul 05 20:11:52 2017 +0200
@@ -94,7 +94,7 @@
* Note that some minor variations in distances may occur due to sampling at
* the granularity of a pixel.
* If no cycle method is specified, {@code NO_CYCLE} will be chosen by
- * default, which means the the last keyframe color will be used to fill the
+ * default, which means the last keyframe color will be used to fill the
* remaining area.
* <p>
* The colorSpace parameter allows the user to specify in which colorspace
--- a/jdk/src/java.desktop/share/classes/java/awt/WaitDispatchSupport.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/WaitDispatchSupport.java Wed Jul 05 20:11:52 2017 +0200
@@ -208,7 +208,7 @@
}
}, interval);
}
- // Dispose SequencedEvent we are dispatching on the the current
+ // Dispose SequencedEvent we are dispatching on the current
// AppContext, to prevent us from hang - see 4531693 for details
SequencedEvent currentSE = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
@@ -220,7 +220,7 @@
}
// In case the exit() method is called before starting
// new event pump it will post the waking event to EDT.
- // The event will be handled after the the new event pump
+ // The event will be handled after the new event pump
// starts. Thus, the enter() method will not hang.
//
// Event pump should be privileged. See 6300270.
--- a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/DataFlavor.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/DataFlavor.java Wed Jul 05 20:11:52 2017 +0200
@@ -384,7 +384,7 @@
* @param representationClass the class used to transfer data in this flavor
* @param humanPresentableName the human-readable string used to identify
* this flavor; if this parameter is <code>null</code>
- * then the value of the the MIME Content Type is used
+ * then the value of the MIME Content Type is used
* @exception NullPointerException if <code>representationClass</code> is null
*/
public DataFlavor(Class<?> representationClass, String humanPresentableName) {
@@ -418,7 +418,7 @@
* is thrown
* @param humanPresentableName the human-readable string used to identify
* this flavor; if this parameter is <code>null</code>
- * then the value of the the MIME Content Type is used
+ * then the value of the MIME Content Type is used
* @exception IllegalArgumentException if <code>mimeType</code> is
* invalid or if the class is not successfully loaded
* @exception NullPointerException if <code>mimeType</code> is null
--- a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java Wed Jul 05 20:11:52 2017 +0200
@@ -1309,7 +1309,7 @@
/**
* Set the keyChar value to indicate a logical character.
*
- * @param keyChar a char corresponding to to the combination of keystrokes
+ * @param keyChar a char corresponding to the combination of keystrokes
* that make up this event.
*/
public void setKeyChar(char keyChar) {
--- a/jdk/src/java.desktop/share/classes/java/awt/event/KeyListener.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/event/KeyListener.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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,7 +44,7 @@
*
* @see KeyAdapter
* @see KeyEvent
- * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a>
+ * @see <a href="https://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html">Tutorial: Writing a Key Listener</a>
*
* @since 1.1
*/
--- a/jdk/src/java.desktop/share/classes/java/awt/font/GlyphVector.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/GlyphVector.java Wed Jul 05 20:11:52 2017 +0200
@@ -341,7 +341,7 @@
/**
* Returns the position of the specified glyph relative to the
* origin of this <code>GlyphVector</code>.
- * If <code>glyphIndex</code> equals the number of of glyphs in
+ * If <code>glyphIndex</code> equals the number of glyphs in
* this <code>GlyphVector</code>, this method returns the position after
* the last glyph. This position is used to define the advance of
* the entire <code>GlyphVector</code>.
@@ -358,7 +358,7 @@
/**
* Sets the position of the specified glyph within this
* <code>GlyphVector</code>.
- * If <code>glyphIndex</code> equals the number of of glyphs in
+ * If <code>glyphIndex</code> equals the number of glyphs in
* this <code>GlyphVector</code>, this method sets the position after
* the last glyph. This position is used to define the advance of
* the entire <code>GlyphVector</code>.
@@ -477,7 +477,7 @@
* coordinates of the glyph numbered <code>beginGlyphIndex + position/2</code>.
* Odd numbered array entries beginning with position one are the Y
* coordinates of the glyph numbered <code>beginGlyphIndex + (position-1)/2</code>.
- * If <code>beginGlyphIndex</code> equals the number of of glyphs in
+ * If <code>beginGlyphIndex</code> equals the number of glyphs in
* this <code>GlyphVector</code>, this method gets the position after
* the last glyph and this position is used to define the advance of
* the entire <code>GlyphVector</code>.
--- a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java Wed Jul 05 20:11:52 2017 +0200
@@ -832,7 +832,7 @@
/**
* Attribute key for the embedding level of the text. Values are
* instances of <b><code>Integer</code></b>. The default value is
- * <code>null</code>, indicating that the the Bidirectional
+ * <code>null</code>, indicating that the Bidirectional
* algorithm should run without explicit embeddings.
*
* <p>Positive values 1 through 61 are <em>embedding</em> levels,
--- a/jdk/src/java.desktop/share/classes/java/awt/im/spi/package.html Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/im/spi/package.html Wed Jul 05 20:11:52 2017 +0200
@@ -55,9 +55,8 @@
<H4><A NAME="Packaging"></A>Packaging Input Methods</H4>
-<P>Input methods are packaged as installed extensions, as specified
-by the <A HREF="../../../../../technotes/guides/extensions/index.html">Extension
-Mechanism</A>. The main JAR file of an input method must contain the
+<P>Input methods can be made available by adding them to the application's
+class path. The main JAR file of an input method must contain the
file:</P>
<PRE> META-INF/services/java.awt.im.spi.InputMethodDescriptor</PRE>
--- a/jdk/src/java.desktop/share/classes/java/awt/image/ColorConvertOp.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/ColorConvertOp.java Wed Jul 05 20:11:52 2017 +0200
@@ -577,7 +577,7 @@
/**
* Returns the bounding box of the destination, given this source.
- * Note that this will be the same as the the bounding box of the
+ * Note that this will be the same as the bounding box of the
* source.
* @param src the source <code>BufferedImage</code>
* @return a <code>Rectangle2D</code> that is the bounding box
@@ -589,7 +589,7 @@
/**
* Returns the bounding box of the destination, given this source.
- * Note that this will be the same as the the bounding box of the
+ * Note that this will be the same as the bounding box of the
* source.
* @param src the source <code>Raster</code>
* @return a <code>Rectangle2D</code> that is the bounding box
--- a/jdk/src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java Wed Jul 05 20:11:52 2017 +0200
@@ -92,7 +92,7 @@
* <p>
* For instances with unsigned sample values,
* the unnormalized color/alpha component representation is only
- * supported if two conditions hold. First, sample value value 0 must
+ * supported if two conditions hold. First, sample value 0 must
* map to normalized component value 0.0 and sample value 2<sup>n</sup> - 1
* to 1.0. Second the min/max range of all color components of the
* <code>ColorSpace</code> must be 0.0 to 1.0. In this case, the
--- a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterIOException.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterIOException.java Wed Jul 05 20:11:52 2017 +0200
@@ -76,7 +76,7 @@
}
/**
- * Returns the the cause of this exception (the <code>IOException</code>
+ * Returns the cause of this exception (the <code>IOException</code>
* that terminated the print job).
*
* @return the cause of this exception.
--- a/jdk/src/java.desktop/share/classes/java/beans/Encoder.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/beans/Encoder.java Wed Jul 05 20:11:52 2017 +0200
@@ -121,7 +121,7 @@
* it is returned.
* <li>
* A persistence delegate is then looked up by the name
- * composed of the the fully qualified name of the given type
+ * composed of the fully qualified name of the given type
* and the "PersistenceDelegate" postfix.
* For example, a persistence delegate for the {@code Bean} class
* should be named {@code BeanPersistenceDelegate}
--- a/jdk/src/java.desktop/share/classes/java/beans/Transient.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/beans/Transient.java Wed Jul 05 20:11:52 2017 +0200
@@ -41,7 +41,7 @@
* indicates to encoders derived from {@link Encoder}
* that this feature should be ignored.
* <p>
- * The {@code Transient} annotation may be be used
+ * The {@code Transient} annotation may be used
* in any of the methods that are involved
* in a {@link FeatureDescriptor} subclass
* to identify the transient feature in the annotated class and its subclasses.
--- a/jdk/src/java.desktop/share/classes/javax/imageio/IIOParam.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/IIOParam.java Wed Jul 05 20:11:52 2017 +0200
@@ -442,7 +442,7 @@
}
/**
- * Returns the set of of source bands to be used. The returned
+ * Returns the set of source bands to be used. The returned
* value is that set by the most recent call to
* <code>setSourceBands</code>, or <code>null</code> if there have
* been no calls to <code>setSourceBands</code>.
--- a/jdk/src/java.desktop/share/classes/javax/imageio/event/IIOReadUpdateListener.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/event/IIOReadUpdateListener.java Wed Jul 05 20:11:52 2017 +0200
@@ -70,7 +70,7 @@
* a value of 1 means no gaps.
* @param periodY the vertical spacing between updated pixels;
* a value of 1 means no gaps.
- * @param bands an array of <code>int</code>s indicating the the
+ * @param bands an array of <code>int</code>s indicating the
* set bands that may be updated.
*/
void passStarted(ImageReader source,
@@ -187,7 +187,7 @@
* a value of 1 means no gaps.
* @param periodY the vertical spacing between updated pixels;
* a value of 1 means no gaps.
- * @param bands an array of <code>int</code>s indicating the the
+ * @param bands an array of <code>int</code>s indicating the
* set bands that may be updated.
*
* @see #passStarted
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/jpeg/JPEGQTable.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/jpeg/JPEGQTable.java Wed Jul 05 20:11:52 2017 +0200
@@ -136,7 +136,7 @@
/**
* Constructs a quantization table from the argument, which must
* contain 64 elements in natural order (not zig-zag order).
- * A copy is made of the the input array.
+ * A copy is made of the input array.
* @param table the quantization table, as an <code>int</code> array.
* @throws IllegalArgumentException if <code>table</code> is
* <code>null</code> or <code>table.length</code> is not equal to 64.
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java Wed Jul 05 20:11:52 2017 +0200
@@ -52,7 +52,7 @@
* API uses integers instead of bytes when expressing MIDI data. For example,
* the {@link #getStatus()} method of {@code MidiMessage} returns MIDI status
* bytes as integers. If you are processing MIDI data that originated outside
- * Java Sound and now is encoded as signed bytes, the bytes can can be
+ * Java Sound and now is encoded as signed bytes, the bytes can be
* converted to integers using this conversion:
*
* <center>{@code int i = (int)(byte & 0xFF)}</center>
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java Wed Jul 05 20:11:52 2017 +0200
@@ -303,7 +303,7 @@
* @param status the MIDI status byte
* @param data1 the first data byte
* @param data2 the second data byte
- * @throws InvalidMidiDataException if the the status byte, or all data
+ * @throws InvalidMidiDataException if the status byte, or all data
* bytes belonging to the message, do not specify a valid MIDI
* message
* @see #setMessage(int, int, int, int)
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Clip.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Clip.java Wed Jul 05 20:11:52 2017 +0200
@@ -178,7 +178,7 @@
/**
* Sets the first and last sample frames that will be played in the loop.
* The ending point must be greater than or equal to the starting point, and
- * both must fall within the the size of the loaded media. A value of 0 for
+ * both must fall within the size of the loaded media. A value of 0 for
* the starting point means the beginning of the loaded media. Similarly, a
* value of -1 for the ending point indicates the last frame of the media.
*
--- a/jdk/src/java.desktop/share/classes/javax/swing/AbstractButton.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/AbstractButton.java Wed Jul 05 20:11:52 2017 +0200
@@ -1474,7 +1474,7 @@
* area. If you wish to have a transparent button, such as
* an icon only button, for example, then you should set
* this to <code>false</code>. Do not call <code>setOpaque(false)</code>.
- * The default value for the the <code>contentAreaFilled</code>
+ * The default value for the <code>contentAreaFilled</code>
* property is <code>true</code>.
* <p>
* This function may cause the component's opaque property to change.
@@ -1538,7 +1538,7 @@
}
/**
- * Returns the keyboard mnemonic from the the current model.
+ * Returns the keyboard mnemonic from the current model.
* @return the keyboard mnemonic from the model
*/
public int getMnemonic() {
@@ -2562,7 +2562,7 @@
* Perform the specified Action on the object
*
* @param i zero-based index of actions
- * @return true if the the action was performed; else false.
+ * @return true if the action was performed; else false.
*/
public boolean doAccessibleAction(int i) {
if (i == 0) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/ArrayTable.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/ArrayTable.java Wed Jul 05 20:11:52 2017 +0200
@@ -51,7 +51,7 @@
/**
* Writes the passed in ArrayTable to the passed in ObjectOutputStream.
* The data is saved as an integer indicating how many key/value
- * pairs are being archived, followed by the the key/value pairs. If
+ * pairs are being archived, followed by the key/value pairs. If
* <code>table</code> is null, 0 will be written to <code>s</code>.
* <p>
* This is a convenience method that ActionMap/InputMap and
--- a/jdk/src/java.desktop/share/classes/javax/swing/Box.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/Box.java Wed Jul 05 20:11:52 2017 +0200
@@ -82,7 +82,7 @@
/**
* Creates a <code>Box</code> that displays its components
- * along the the specified axis.
+ * along the specified axis.
*
* @param axis can be {@link BoxLayout#X_AXIS},
* {@link BoxLayout#Y_AXIS},
--- a/jdk/src/java.desktop/share/classes/javax/swing/GroupLayout.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/GroupLayout.java Wed Jul 05 20:11:52 2017 +0200
@@ -2397,7 +2397,7 @@
* {@code CONSTANT_DESCENT}; otherwise the baseline is anchored to the top
* of the group.
* <p>
- * Elements aligned to the baseline are resizable if they have have
+ * Elements aligned to the baseline are resizable if they have
* a baseline resize behavior of {@code CONSTANT_ASCENT} or
* {@code CONSTANT_DESCENT}. Elements with a baseline resize
* behavior of {@code OTHER} or {@code CENTER_OFFSET} are not resizable.
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComboBox.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComboBox.java Wed Jul 05 20:11:52 2017 +0200
@@ -1320,8 +1320,8 @@
*/
public void actionPerformed(ActionEvent e) {
ComboBoxEditor editor = getEditor();
- if ((editor != null) && (e != null)
- && (editor.getEditorComponent() == e.getSource())) {
+ if ((editor != null) && (e != null) && (editor == e.getSource()
+ || editor.getEditorComponent() == e.getSource())) {
setPopupVisible(false);
getModel().setSelectedItem(editor.getItem());
String oldCommand = getActionCommand();
@@ -1919,7 +1919,7 @@
* Perform the specified Action on the object
*
* @param i zero-based index of actions
- * @return true if the the action was performed; else false.
+ * @return true if the action was performed; else false.
*/
public boolean doAccessibleAction(int i) {
if (i == 0) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Wed Jul 05 20:11:52 2017 +0200
@@ -1882,7 +1882,7 @@
}
/**
- * Sets the the horizontal alignment.
+ * Sets the horizontal alignment.
*
* @param alignmentY the new horizontal alignment
* @see #getAlignmentY
@@ -1911,7 +1911,7 @@
}
/**
- * Sets the the vertical alignment.
+ * Sets the vertical alignment.
*
* @param alignmentX the new vertical alignment
* @see #getAlignmentX
@@ -4799,7 +4799,7 @@
/**
* Notifies this component that it no longer has a parent component.
* When this method is invoked, any <code>KeyboardAction</code>s
- * set up in the the chain of parent components are removed.
+ * set up in the chain of parent components are removed.
* This method is called by the toolkit internally and should
* not be called directly by programs.
*
@@ -5575,7 +5575,7 @@
* the UI before any of the <code>JComponent</code>'s children
* (or its <code>LayoutManager</code> etc.) are written,
* and we don't want to restore the UI until the most derived
- * <code>JComponent</code> subclass has been been stored.
+ * <code>JComponent</code> subclass has been stored.
*
* @param s the <code>ObjectOutputStream</code> in which to write
*/
--- a/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java Wed Jul 05 20:11:52 2017 +0200
@@ -716,7 +716,7 @@
* like fetch the stream from a cache, monitor the progress
* of the stream, etc.
* <p>
- * This method is expected to have the the side effect of
+ * This method is expected to have the side effect of
* establishing the content type, and therefore setting the
* appropriate <code>EditorKit</code> to use for loading the stream.
* <p>
@@ -1826,7 +1826,7 @@
* Perform the specified Action on the object
*
* @param i zero-based index of actions
- * @return true if the the action was performed; else false.
+ * @return true if the action was performed; else false.
* @see #getAccessibleActionCount
*/
public boolean doAccessibleAction(int i) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java Wed Jul 05 20:11:52 2017 +0200
@@ -131,7 +131,7 @@
* <li>{@link Container#add(java.awt.Component, Object)}</li>
* <li>{@link Container#add(java.awt.Component, Object, int)}</li>
* </ul>
- * using any of of them will cause {@code UnsupportedOperationException} to be thrown,
+ * using any of them will cause {@code UnsupportedOperationException} to be thrown,
* to add a component to {@code JLayer}
* use {@link #setView(Component)} or {@link #setGlassPane(JPanel)}.
*
--- a/jdk/src/java.desktop/share/classes/javax/swing/JList.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JList.java Wed Jul 05 20:11:52 2017 +0200
@@ -140,7 +140,7 @@
* <p>
* The preferred way to listen for changes in list selection is to add
* {@code ListSelectionListener}s directly to the {@code JList}. {@code JList}
- * then takes care of listening to the the selection model and notifying your
+ * then takes care of listening to the selection model and notifying your
* listeners of change.
* <p>
* Responsibility for listening to selection changes in order to keep the list's
@@ -717,7 +717,7 @@
* <p>
* This is a JavaBeans bound property.
*
- * @param height the height to be used for for all cells in the list
+ * @param height the height to be used for all cells in the list
* @see #setPrototypeCellValue
* @see #setFixedCellWidth
* @see JComponent#addPropertyChangeListener
--- a/jdk/src/java.desktop/share/classes/javax/swing/JMenuItem.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JMenuItem.java Wed Jul 05 20:11:52 2017 +0200
@@ -178,7 +178,7 @@
}
/**
- * Inititalizes the focusability of the the <code>JMenuItem</code>.
+ * Inititalizes the focusability of the <code>JMenuItem</code>.
* <code>JMenuItem</code>'s are focusable, but subclasses may
* want to be, this provides them the opportunity to override this
* and invoke something else, or nothing at all. Refer to
--- a/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java Wed Jul 05 20:11:52 2017 +0200
@@ -330,7 +330,7 @@
public JProgressBar(int orient, int min, int max)
{
// Creating the model this way is a bit simplistic, but
- // I believe that it is the the most common usage of this
+ // I believe that it is the most common usage of this
// component - it's what people will expect.
setModel(new DefaultBoundedRangeModel(min, 0, min, max));
updateUI();
--- a/jdk/src/java.desktop/share/classes/javax/swing/JSpinner.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JSpinner.java Wed Jul 05 20:11:52 2017 +0200
@@ -447,7 +447,7 @@
* Sends a <code>ChangeEvent</code>, whose source is this
* <code>JSpinner</code>, to each <code>ChangeListener</code>.
* When a <code>ChangeListener</code> has been added
- * to the spinner, this method method is called each time
+ * to the spinner, this method is called each time
* a <code>ChangeEvent</code> is received from the model.
*
* @see #addChangeListener
@@ -1798,7 +1798,7 @@
Rectangle editorRect = at.getCharacterBounds(i);
if (editorRect != null &&
sameWindowAncestor(JSpinner.this, editor)) {
- // return rectangle in the the JSpinner bounds
+ // return rectangle in the JSpinner bounds
return SwingUtilities.convertRectangle(editor,
editorRect,
JSpinner.this);
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTree.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTree.java Wed Jul 05 20:11:52 2017 +0200
@@ -5575,7 +5575,7 @@
* object behind the TreeCellRenderer.
*
* @param i zero-based index of actions
- * @return true if the the action was performed; else false.
+ * @return true if the action was performed; else false.
*/
public boolean doAccessibleAction(int i) {
if (i < 0 || i >= getAccessibleActionCount()) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/OverlayLayout.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/OverlayLayout.java Wed Jul 05 20:11:52 2017 +0200
@@ -97,7 +97,7 @@
* this class to know when to invalidate layout.
*
* @param name the name of the component
- * @param comp the the component to be added
+ * @param comp the component to be added
*/
public void addLayoutComponent(String name, Component comp) {
invalidateLayout(comp.getParent());
--- a/jdk/src/java.desktop/share/classes/javax/swing/ScrollPaneLayout.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/ScrollPaneLayout.java Wed Jul 05 20:11:52 2017 +0200
@@ -225,7 +225,7 @@
* </ul>
*
* @param s the component identifier
- * @param c the the component to be added
+ * @param c the component to be added
* @exception IllegalArgumentException if <code>s</code> is an invalid key
*/
public void addLayoutComponent(String s, Component c)
--- a/jdk/src/java.desktop/share/classes/javax/swing/SpinnerModel.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SpinnerModel.java Wed Jul 05 20:11:52 2017 +0200
@@ -53,7 +53,7 @@
* <dd>The preceding element or null if <code>value</code> is the
* first element of the sequence.
* </dl>
- * When the the <code>value</code> property changes,
+ * When the <code>value</code> property changes,
* <code>ChangeListeners</code> are notified. <code>SpinnerModel</code> may
* choose to notify the <code>ChangeListeners</code> under other circumstances.
*
--- a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java Wed Jul 05 20:11:52 2017 +0200
@@ -167,7 +167,7 @@
}
/**
- * Looks up up the given key in our Hashtable and resolves LazyValues
+ * Looks up the given key in our Hashtable and resolves LazyValues
* or ActiveValues.
*/
private Object getFromHashtable(Object key) {
@@ -1181,7 +1181,7 @@
/**
* <code>LazyInputMap</code> will create a <code>InputMap</code>
* in its <code>createValue</code>
- * method. The bindings are passed in in the constructor.
+ * method. The bindings are passed in the constructor.
* The bindings are an array with
* the even number entries being string <code>KeyStrokes</code>
* (eg "alt SPACE") and
--- a/jdk/src/java.desktop/share/classes/javax/swing/ViewportLayout.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/ViewportLayout.java Wed Jul 05 20:11:52 2017 +0200
@@ -66,7 +66,7 @@
/**
* Adds the specified component to the layout. Not used by this class.
* @param name the name of the component
- * @param c the the component to be added
+ * @param c the component to be added
*/
public void addLayoutComponent(String name, Component c) { }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java Wed Jul 05 20:11:52 2017 +0200
@@ -1141,7 +1141,7 @@
/**
- * This is is a utility method that helps event handlers figure out where to
+ * This is a utility method that helps event handlers figure out where to
* send the focus when the popup is brought up. The standard implementation
* delegates the focus to the editor (if the combo box is editable) or to
* the JComboBox if it is not editable.
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java Wed Jul 05 20:11:52 2017 +0200
@@ -1449,7 +1449,7 @@
/**
* Returns the value at the y position. If {@code yPos} is beyond the
- * track at the the bottom or the top, this method sets the value to either
+ * track at the bottom or the top, this method sets the value to either
* the minimum or maximum value of the slider, depending on if the slider
* is inverted or not.
*
@@ -1927,7 +1927,7 @@
* The recommended approach to creating bindings is to use a
* combination of an <code>ActionMap</code>, to contain the action,
* and an <code>InputMap</code> to contain the mapping from KeyStroke
- * to action description. The InputMap is is usually described in the
+ * to action description. The InputMap is usually described in the
* LookAndFeel tables.
* <p>
* Please refer to the key bindings specification for further details.
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java Wed Jul 05 20:11:52 2017 +0200
@@ -344,7 +344,7 @@
}
// In cases where the lead is not within the search range,
- // we need to bring it within one cell for the the search
+ // we need to bring it within one cell for the search
// to work properly. Check these here.
leadRow = Math.min(Math.max(leadRow, minY - 1), maxY + 1);
leadColumn = Math.min(Math.max(leadColumn, minX - 1), maxX + 1);
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java Wed Jul 05 20:11:52 2017 +0200
@@ -137,7 +137,7 @@
/**
* Fetches the name of the keymap that will be installed/used
* by default for this UI. This is implemented to create a
- * name based upon the classname. The name is the the name
+ * name based upon the classname. The name is the name
* of the class with the package prefix removed.
*
* @return the name
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java Wed Jul 05 20:11:52 2017 +0200
@@ -245,7 +245,7 @@
}
/**
- * Returns the maximum height of the the Font from the passed in
+ * Returns the maximum height of the Font from the passed in
* SynthContext.
*
* @param context SynthContext used to determine font.
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java Wed Jul 05 20:11:52 2017 +0200
@@ -242,7 +242,7 @@
}
/**
- * Returns the the dragged column, if and only if, a drag is in
+ * Returns the dragged column, if and only if, a drag is in
* process, otherwise returns <code>null</code>.
*
* @return the dragged column, if a drag is in
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/TableColumn.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/TableColumn.java Wed Jul 05 20:11:52 2017 +0200
@@ -127,7 +127,7 @@
/**
* This object is not used internally by the drawing machinery of
* the <code>JTable</code>; identifiers may be set in the
- * <code>TableColumn</code> as as an
+ * <code>TableColumn</code> as an
* optional way to tag and locate table columns. The table package does
* not modify or invoke any methods in these identifier objects other
* than the <code>equals</code> method which is used in the
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/BoxView.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/BoxView.java Wed Jul 05 20:11:52 2017 +0200
@@ -1128,7 +1128,7 @@
* indicating the <code>View</code>s are layed out in ascending order.
* <p>
* If the receiver is laying its <code>View</code>s along the
- * <code>Y_AXIS</code>, this will will return the value from
+ * <code>Y_AXIS</code>, this will return the value from
* invoking the same method on the <code>View</code>
* responsible for rendering <code>position</code> and
* <code>bias</code>. Otherwise this will return false.
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java Wed Jul 05 20:11:52 2017 +0200
@@ -409,7 +409,7 @@
/**
- * Fetches the list of of style names.
+ * Fetches the list of style names.
*
* @return all the style names
*/
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/ElementIterator.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/ElementIterator.java Wed Jul 05 20:11:52 2017 +0200
@@ -79,7 +79,7 @@
* as well as a child index. If the
* index is -1, then the element represented
* on the stack is the element itself.
- * Otherwise, the index functions as as index
+ * Otherwise, the index functions as an index
* into the vector of children of the element.
* In this case, the item on the stack
* represents the "index"th child of the element
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java Wed Jul 05 20:11:52 2017 +0200
@@ -403,7 +403,7 @@
* This is implemented to try and locate a <code>TabSet</code>
* in the paragraph element's attribute set. If one can be
* found, its settings will be used, otherwise a default expansion
- * will be provided. The base location for for tab expansion
+ * will be provided. The base location for tab expansion
* is the left inset from the paragraphs most recent allocation
* (which is what the layout of the children is based upon).
*
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java Wed Jul 05 20:11:52 2017 +0200
@@ -385,11 +385,11 @@
int x = (int) fx;
int y = (int) fy;
if (y < alloc.y) {
- // above the area covered by this icon, so the the position
+ // above the area covered by this icon, so the position
// is assumed to be the start of the coverage for this view.
return getStartOffset();
} else if (y > alloc.y + alloc.height) {
- // below the area covered by this icon, so the the position
+ // below the area covered by this icon, so the position
// is assumed to be the end of the coverage for this view.
return getEndOffset() - 1;
} else {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java Wed Jul 05 20:11:52 2017 +0200
@@ -668,11 +668,11 @@
int x = (int) fx;
int y = (int) fy;
if (y < alloc.y) {
- // above the area covered by this icon, so the the position
+ // above the area covered by this icon, so the position
// is assumed to be the start of the coverage for this view.
return getStartOffset();
} else if (y > alloc.y + alloc.height) {
- // below the area covered by this icon, so the the position
+ // below the area covered by this icon, so the position
// is assumed to be the end of the coverage for this view.
return getEndOffset() - 1;
} else {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java Wed Jul 05 20:11:52 2017 +0200
@@ -1588,7 +1588,7 @@
/*
* HTML.Attribute.ALIGN needs special processing.
- * It can map to to 1 of many(3) possible CSS attributes
+ * It can map to 1 of many(3) possible CSS attributes
* depending on the nature of the tag the attribute is
* part off and depending on the value of the attribute.
*/
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/FormView.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/FormView.java Wed Jul 05 20:11:52 2017 +0200
@@ -37,7 +37,7 @@
* Component decorator that implements the view interface
* for form elements, <input>, <textarea>,
* and <select>. The model for the component is stored
- * as an attribute of the the element (using StyleConstants.ModelAttribute),
+ * as an attribute of the element (using StyleConstants.ModelAttribute),
* and is used to build the component of the view. The type
* of the model is assumed to of the type that would be set by
* <code>HTMLDocument.HTMLReader.FormAction</code>. If there are
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java Wed Jul 05 20:11:52 2017 +0200
@@ -1345,7 +1345,7 @@
}
/**
- * Inserts the HTML specified as a string after the the end of the
+ * Inserts the HTML specified as a string after the end of the
* given element.
*
* <p>Consider the following structure (the <code>elem</code>
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/IsindexView.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/IsindexView.java Wed Jul 05 20:11:52 2017 +0200
@@ -53,7 +53,7 @@
}
/**
- * Creates the components necessary to to implement
+ * Creates the components necessary to implement
* this view. The component returned is a <code>JPanel</code>,
* that contains the PROMPT to the left and <code>JTextField</code>
* to the right.
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/LineView.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/LineView.java Wed Jul 05 20:11:52 2017 +0200
@@ -136,7 +136,7 @@
* This is implemented to try and locate a <code>TabSet</code>
* in the paragraph element's attribute set. If one can be
* found, its settings will be used, otherwise a default expansion
- * will be provided. The base location for for tab expansion
+ * will be provided. The base location for tab expansion
* is the left inset from the paragraphs most recent allocation
* (which is what the layout of the children is based upon).
*
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/DTDConstants.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/DTDConstants.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,7 +27,7 @@
/**
* SGML constants used in a DTD. The names of the
- * constants correspond the the equivalent SGML constructs
+ * constants correspond to the equivalent SGML constructs
* as described in "The SGML Handbook" by Charles F. Goldfarb.
*
* @see DTD
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/Entity.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/Entity.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,7 +35,7 @@
/**
* An entity is described in a DTD using the ENTITY construct.
- * It defines the type and value of the the entity.
+ * It defines the type and value of the entity.
*
* @see DTD
* @author Arthur van Hoff
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/Parser.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/Parser.java Wed Jul 05 20:11:52 2017 +0200
@@ -1846,7 +1846,7 @@
if (unknown) {
// we will not see a corresponding start tag
- // on the the stack. If we are seeing an
+ // on the stack. If we are seeing an
// end tag, lets send this on as an empty
// tag with the end tag attribute set to
// true.
--- a/jdk/src/java.desktop/share/classes/javax/swing/undo/UndoManager.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/undo/UndoManager.java Wed Jul 05 20:11:52 2017 +0200
@@ -283,7 +283,7 @@
/**
- * Returns the the next significant edit to be undone if <code>undo</code>
+ * Returns the next significant edit to be undone if <code>undo</code>
* is invoked. This returns <code>null</code> if there are no edits
* to be undone.
*
@@ -302,7 +302,7 @@
}
/**
- * Returns the the next significant edit to be redone if <code>redo</code>
+ * Returns the next significant edit to be redone if <code>redo</code>
* is invoked. This returns <code>null</code> if there are no edits
* to be redone.
*
--- a/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java Wed Jul 05 20:11:52 2017 +0200
@@ -926,6 +926,15 @@
// bytes and dump them into a byte array. For text flavors, decode back
// to a String and recur to reencode according to the requested format.
} else if (flavor.isRepresentationClassInputStream()) {
+
+ // Workaround to JDK-8024061: Exception thrown when drag and drop
+ // between two components is executed quickly.
+ // and JDK-8065098: JColorChooser no longer supports drag and drop
+ // between two JVM instances
+ if (!(obj instanceof InputStream)) {
+ return new byte[0];
+ }
+
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
try (InputStream is = (InputStream)obj) {
boolean eof = false;
--- a/jdk/src/java.desktop/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java Wed Jul 05 20:11:52 2017 +0200
@@ -239,13 +239,6 @@
if (localTransferable != null) {
return localTransferable.getTransferData(df);
- } else if (df.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) {
- // Workaround to JDK-8024061: Exception thrown when drag and drop
- // between two components is executed quickly.
- // It is expected localTransferable is not null if javaJVMLocalObjectMimeType
- // is used. Executing further results in ClassCastException, so null is
- // returned here as no transfer data is available in this case.
- return null;
}
if (dropStatus != STATUS_ACCEPT || dropComplete) {
--- a/jdk/src/java.desktop/share/classes/sun/awt/im/ExecutableInputMethodManager.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/im/ExecutableInputMethodManager.java Wed Jul 05 20:11:52 2017 +0200
@@ -259,7 +259,8 @@
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() {
for (InputMethodDescriptor descriptor :
- ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
+ ServiceLoader.load(InputMethodDescriptor.class,
+ ClassLoader.getSystemClassLoader())) {
ClassLoader cl = descriptor.getClass().getClassLoader();
javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
}
--- a/jdk/src/java.desktop/share/classes/sun/font/BidiUtils.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/BidiUtils.java Wed Jul 05 20:11:52 2017 +0200
@@ -47,7 +47,7 @@
* array instead of iterating over the runs.
*
* @param levels the array to receive the character levels
- * @param start the starting offset into the the array
+ * @param start the starting offset into the array
* @throws IndexOutOfBoundsException if <code>start</code> is less than 0 or
* <code>start + getLength()</code> is greater than <code>levels.length</code>.
*/
--- a/jdk/src/java.desktop/share/classes/sun/font/Decoration.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/Decoration.java Wed Jul 05 20:11:52 2017 +0200
@@ -105,7 +105,7 @@
}
/**
- * Return a Decoration appropriate for the the given Map.
+ * Return a Decoration appropriate for the given Map.
* @param attributes the Map used to determine the Decoration
*/
public static Decoration getDecoration(Map<? extends Attribute, ?> attributes) {
--- a/jdk/src/java.desktop/share/classes/sun/font/FileFontStrike.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/FileFontStrike.java Wed Jul 05 20:11:52 2017 +0200
@@ -898,7 +898,7 @@
/* The caller of this can be trusted to return a copy of this
* return value rectangle to public API. In fact frequently it
- * can't use use this return value directly anyway.
+ * can't use this return value directly anyway.
* This returns bounds in device space. Currently the only
* caller is SGV and it converts back to user space.
* We could change things so that this code does the conversion so
--- a/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java Wed Jul 05 20:11:52 2017 +0200
@@ -214,7 +214,7 @@
* char which means it may include undecoded surrogate pairs.
* The distinction is made so that code which needs to identify all
* cases in which we do not have a simple mapping from
- * char->unicode character->glyph can be be identified.
+ * char->unicode character->glyph can be identified.
* For example measurement cannot simply sum advances of 'chars',
* the caret in editable text cannot advance one 'char' at a time, etc.
* These callers really are asking for more than whether 'layout'
--- a/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java Wed Jul 05 20:11:52 2017 +0200
@@ -575,7 +575,7 @@
* that claims to support the Microsoft Windows encoding corresponding to
* the default file.encoding property of this JRE instance.
* This narrow value is useful for Swing to decide if the font is useful
- * for the the Windows Look and Feel, or, if a composite font should be
+ * for the Windows Look and Feel, or, if a composite font should be
* used instead.
* The information used to make the decision is obtained from
* the ulCodePageRange fields in the font.
@@ -1611,7 +1611,7 @@
* all non-null file names first.
* They are added in to a map with nominally the first
* word in the name of the family as the key. In all the cases
- * we are using the the family name is a single word, and as is
+ * we are using the family name is a single word, and as is
* more or less required the family name is the initial sequence
* in a full name. So lookup first finds the matching description,
* then registers the whole family, returning the right font.
--- a/jdk/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java Wed Jul 05 20:11:52 2017 +0200
@@ -72,7 +72,7 @@
* font tables (the selector indicates which). Then layout is called,
* the contents are copied (or not), and the stack is destroyed on
* exit. So the association is between the font/script (layout engine
- * desc) and and one of a few permanent engine objects, which are
+ * desc) and one of a few permanent engine objects, which are
* handed the key when they need to process something. In the native
* case, the engine holds an index, and just passes it together with
* the key info down to native. Some default cases are the 'default
--- a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java Wed Jul 05 20:11:52 2017 +0200
@@ -154,7 +154,7 @@
/* number of table entries in the directory/offsets table */
int numTables;
- /* The contents of the the directory/offsets table */
+ /* The contents of the directory/offsets table */
DirectoryEntry []tableDirectory;
// protected byte []gposTable = null;
@@ -228,7 +228,7 @@
return false; /* useNatives is false */
} else if (nativeNames instanceof String) {
String name = (String)nativeNames;
- /* Don't do do this for Latin fonts */
+ /* Don't do this for Latin fonts */
if (name.indexOf("8859") > 0) {
checkedNatives = true;
return false;
--- a/jdk/src/java.desktop/share/classes/sun/java2d/loops/ProcessPath.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/loops/ProcessPath.java Wed Jul 05 20:11:52 2017 +0200
@@ -1418,7 +1418,7 @@
*/
);
} else {
- /* Clamping starting from first vertex of the the processed
+ /* Clamping starting from first vertex of the processed
* segment
*
* CLIPCLAMP(xMin, xMax, x1, y1, x2, y2, x3, y3, res);
@@ -1438,7 +1438,7 @@
return;
}
- /* Clamping starting from last vertex of the the processed
+ /* Clamping starting from last vertex of the processed
* segment
*
* CLIPCLAMP(xMin, xMax, x2, y2, x1, y1, x3, y3, res);
@@ -2062,7 +2062,7 @@
if (res == CRES_INVISIBLE) return;
lastClipped = IS_CLIPPED(res);
- /* Clamping starting from first vertex of the the processed
+ /* Clamping starting from first vertex of the processed
* segment
*
* CLIPCLAMP(outXMin, outXMax, x1, y1, x2, y2, x3, y3, res);
@@ -2078,7 +2078,7 @@
return;
}
- /* Clamping starting from last vertex of the the processed
+ /* Clamping starting from last vertex of the processed
* segment
*
* CLIPCLAMP(outXMin, outXMax, x2, y2, x1, y1, x3, y3, res);
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/BufferedContext.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/BufferedContext.java Wed Jul 05 20:11:52 2017 +0200
@@ -451,7 +451,7 @@
public abstract RenderQueue getRenderQueue();
/**
- * Saves the the state of this context.
+ * Saves the state of this context.
* It may reset the current context.
*
* Note: must be called while the RenderQueue lock is held.
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java Wed Jul 05 20:11:52 2017 +0200
@@ -364,8 +364,53 @@
int sx1, int sy1, int sx2, int sy2,
Color bgColor)
{
+ final AffineTransform itx;
+ try {
+ itx = tx.createInverse();
+ } catch (final NoninvertibleTransformException ignored) {
+ // Non-invertible transform means no output
+ return;
+ }
+
+ /*
+ * Find the maximum bounds on the destination that will be
+ * affected by the transformed source. First, transform all
+ * four corners of the source and then min and max the resulting
+ * destination coordinates of the transformed corners.
+ * Note that tx already has the offset to sx1,sy1 accounted
+ * for so we use the box (0, 0, sx2-sx1, sy2-sy1) as the
+ * source coordinates.
+ */
+ final double[] coords = new double[8];
+ /* corner: UL UR LL LR */
+ /* index: 0 1 2 3 4 5 6 7 */
+ /* coord: (0, 0), (w, 0), (0, h), (w, h) */
+ coords[2] = coords[6] = sx2 - sx1;
+ coords[5] = coords[7] = sy2 - sy1;
+ tx.transform(coords, 0, coords, 0, 4);
+ double ddx1, ddy1, ddx2, ddy2;
+ ddx1 = ddx2 = coords[0];
+ ddy1 = ddy2 = coords[1];
+ for (int i = 2; i < coords.length; i += 2) {
+ double d = coords[i];
+ if (ddx1 > d) ddx1 = d;
+ else if (ddx2 < d) ddx2 = d;
+ d = coords[i+1];
+ if (ddy1 > d) ddy1 = d;
+ else if (ddy2 < d) ddy2 = d;
+ }
+
Region clip = sg.getCompClip();
- SurfaceData dstData = sg.surfaceData;
+ final int dx1 = Math.max((int) Math.floor(ddx1), clip.lox);
+ final int dy1 = Math.max((int) Math.floor(ddy1), clip.loy);
+ final int dx2 = Math.min((int) Math.ceil(ddx2), clip.hix);
+ final int dy2 = Math.min((int) Math.ceil(ddy2), clip.hiy);
+ if (dx2 <= dx1 || dy2 <= dy1) {
+ // empty destination means no output
+ return;
+ }
+
+ final SurfaceData dstData = sg.surfaceData;
SurfaceData srcData = dstData.getSourceSurfaceData(img,
SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
@@ -429,56 +474,13 @@
// assert(helper != null);
}
- AffineTransform itx;
- try {
- itx = tx.createInverse();
- } catch (NoninvertibleTransformException e) {
- // Non-invertible transform means no output
- return;
- }
-
- /*
- * Find the maximum bounds on the destination that will be
- * affected by the transformed source. First, transform all
- * four corners of the source and then min and max the resulting
- * destination coordinates of the transformed corners.
- * Note that tx already has the offset to sx1,sy1 accounted
- * for so we use the box (0, 0, sx2-sx1, sy2-sy1) as the
- * source coordinates.
- */
- double coords[] = new double[8];
- /* corner: UL UR LL LR */
- /* index: 0 1 2 3 4 5 6 7 */
- /* coord: (0, 0), (w, 0), (0, h), (w, h) */
- coords[2] = coords[6] = sx2 - sx1;
- coords[5] = coords[7] = sy2 - sy1;
- tx.transform(coords, 0, coords, 0, 4);
- double ddx1, ddy1, ddx2, ddy2;
- ddx1 = ddx2 = coords[0];
- ddy1 = ddy2 = coords[1];
- for (int i = 2; i < coords.length; i += 2) {
- double d = coords[i];
- if (ddx1 > d) ddx1 = d;
- else if (ddx2 < d) ddx2 = d;
- d = coords[i+1];
- if (ddy1 > d) ddy1 = d;
- else if (ddy2 < d) ddy2 = d;
- }
- int dx1 = (int) Math.floor(ddx1);
- int dy1 = (int) Math.floor(ddy1);
- int dx2 = (int) Math.ceil(ddx2);
- int dy2 = (int) Math.ceil(ddy2);
-
SurfaceType dstType = dstData.getSurfaceType();
- MaskBlit maskblit;
- Blit blit;
if (sg.compositeState <= SunGraphics2D.COMP_ALPHA) {
/* NOTE: We either have, or we can make,
* a MaskBlit for any alpha composite type
*/
- maskblit = MaskBlit.getFromCache(SurfaceType.IntArgbPre,
- sg.imageComp,
- dstType);
+ MaskBlit maskblit = MaskBlit.getFromCache(SurfaceType.IntArgbPre,
+ sg.imageComp, dstType);
/* NOTE: We can only use the native TransformHelper
* func to go directly to the dest if both the helper
@@ -496,27 +498,19 @@
null, 0, 0);
return;
}
- blit = null;
- } else {
- /* NOTE: We either have, or we can make,
- * a Blit for any composite type, even Custom
- */
- maskblit = null;
- blit = Blit.getFromCache(SurfaceType.IntArgbPre,
- sg.imageComp,
- dstType);
}
// We need to transform to a temp image and then copy
// just the pieces that are valid data to the dest.
- BufferedImage tmpimg = new BufferedImage(dx2-dx1, dy2-dy1,
+ final int w = dx2 - dx1;
+ final int h = dy2 - dy1;
+ BufferedImage tmpimg = new BufferedImage(w, h,
BufferedImage.TYPE_INT_ARGB_PRE);
SurfaceData tmpData = SurfaceData.getPrimarySurfaceData(tmpimg);
SurfaceType tmpType = tmpData.getSurfaceType();
- MaskBlit tmpmaskblit =
- MaskBlit.getFromCache(SurfaceType.IntArgbPre,
- CompositeType.SrcNoEa,
- tmpType);
+ MaskBlit tmpmaskblit = MaskBlit.getFromCache(SurfaceType.IntArgbPre,
+ CompositeType.SrcNoEa,
+ tmpType);
/*
* The helper function fills a temporary edges buffer
* for us with the bounding coordinates of each scanline
@@ -531,7 +525,7 @@
*
* edges thus has to be h*2+2 in length
*/
- int edges[] = new int[(dy2-dy1)*2+2];
+ final int[] edges = new int[h * 2 + 2];
// It is important that edges[0]=edges[1]=0 when we call
// Transform in case it must return early and we would
// not want to render anything on an error condition.
@@ -539,35 +533,17 @@
AlphaComposite.Src, null,
itx, interpType,
sx1, sy1, sx2, sy2,
- 0, 0, dx2-dx1, dy2-dy1,
+ 0, 0, w, h,
edges, dx1, dy1);
- /*
- * Now copy the results, scanline by scanline, into the dest.
- * The edges array helps us minimize the work.
+ final Region region = Region.getInstance(dx1, dy1, dx2, dy2, edges);
+ clip = clip.getIntersection(region);
+
+ /* NOTE: We either have, or we can make,
+ * a Blit for any composite type, even Custom
*/
- int index = 2;
- for (int y = edges[0]; y < edges[1]; y++) {
- int relx1 = edges[index++];
- int relx2 = edges[index++];
- if (relx1 >= relx2) {
- continue;
- }
- if (maskblit != null) {
- maskblit.MaskBlit(tmpData, dstData,
- sg.composite, clip,
- relx1, y,
- dx1+relx1, dy1+y,
- relx2 - relx1, 1,
- null, 0, 0);
- } else {
- blit.Blit(tmpData, dstData,
- sg.composite, clip,
- relx1, y,
- dx1+relx1, dy1+y,
- relx2 - relx1, 1);
- }
- }
+ final Blit blit = Blit.getFromCache(tmpType, sg.imageComp, dstType);
+ blit.Blit(tmpData, dstData, sg.composite, clip, 0, 0, dx1, dy1, w, h);
}
// Render an image using only integer translation
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/Region.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/Region.java Wed Jul 05 20:11:52 2017 +0200
@@ -30,6 +30,8 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.RectangularShape;
+import sun.java2d.loops.TransformHelper;
+
/**
* This class encapsulates a definition of a two dimensional region which
* consists of a number of Y ranges each containing multiple X bands.
@@ -160,6 +162,15 @@
this.hiy = hiy;
}
+ private Region(int lox, int loy, int hix, int hiy, int[] bands, int end) {
+ this.lox = lox;
+ this.loy = loy;
+ this.hix = hix;
+ this.hiy = hiy;
+ this.bands = bands;
+ this.endIndex = end;
+ }
+
/**
* Returns a Region object covering the pixels which would be
* touched by a fill or clip operation on a Graphics implementation
@@ -256,6 +267,44 @@
}
/**
+ * Returns a Region object with a rectangle of interest specified by the
+ * indicated rectangular area in lox, loy, hix, hiy and edges array, which
+ * is located relative to the rectangular area. Edges array - 0,1 are y
+ * range, 2N,2N+1 are x ranges, 1 per y range.
+ *
+ * @see TransformHelper
+ */
+ static Region getInstance(final int lox, final int loy, final int hix,
+ final int hiy, final int[] edges) {
+ final int y1 = edges[0];
+ final int y2 = edges[1];
+ if (hiy <= loy || hix <= lox || y2 <= y1) {
+ return EMPTY_REGION;
+ }
+ // rowsNum * (3 + 1 * 2)
+ final int[] bands = new int[(y2 - y1) * 5];
+ int end = 0;
+ int index = 2;
+ for (int y = y1; y < y2; ++y) {
+ final int spanlox = Math.max(clipAdd(lox, edges[index++]), lox);
+ final int spanhix = Math.min(clipAdd(lox, edges[index++]), hix);
+ if (spanlox < spanhix) {
+ final int spanloy = Math.max(clipAdd(loy, y), loy);
+ final int spanhiy = Math.min(clipAdd(spanloy, 1), hiy);
+ if (spanloy < spanhiy) {
+ bands[end++] = spanloy;
+ bands[end++] = spanhiy;
+ bands[end++] = 1; // 1 span per row
+ bands[end++] = spanlox;
+ bands[end++] = spanhix;
+ }
+ }
+ }
+ return end != 0 ? new Region(lox, loy, hix, hiy, bands, end)
+ : EMPTY_REGION;
+ }
+
+ /**
* Returns a Region object with a rectangle of interest specified
* by the indicated Rectangle object.
* <p>
--- a/jdk/src/java.desktop/share/classes/sun/print/PathGraphics.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/print/PathGraphics.java Wed Jul 05 20:11:52 2017 +0200
@@ -888,7 +888,7 @@
* since it doesn't actually require "layout" (even though its
* considered a layout attribute), it just requires a fractional
* tweak to the[default]advances. So we need to specifically
- * check for tracking until such time as as we can trust
+ * check for tracking until such time as we can trust
* the GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS bit.
*/
Map<TextAttribute, ?> map = font.getAttributes();
--- a/jdk/src/java.desktop/share/classes/sun/print/PeekGraphics.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/print/PeekGraphics.java Wed Jul 05 20:11:52 2017 +0200
@@ -871,7 +871,7 @@
* paint or color, and composite attributes.
* For characters in script systems such as Hebrew and Arabic,
* the glyphs may be draw from right to left, in which case the
- * coordinate supplied is the the location of the leftmost character
+ * coordinate supplied is the location of the leftmost character
* on the baseline.
* @param iterator the iterator whose text is to be drawn
* @param x,y the coordinates where the iterator's text should be drawn.
@@ -897,7 +897,7 @@
* paint or color, and composite attributes.
* For characters in script systems such as Hebrew and Arabic,
* the glyphs may be draw from right to left, in which case the
- * coordinate supplied is the the location of the leftmost character
+ * coordinate supplied is the location of the leftmost character
* on the baseline.
* @param iterator the iterator whose text is to be drawn
* @param x,y the coordinates where the iterator's text should be drawn.
--- a/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java Wed Jul 05 20:11:52 2017 +0200
@@ -837,7 +837,7 @@
* The resolution of the page is chosen so that it
* is similar to the screen resolution.
* Except (since 1.3) when the application specifies a resolution.
- * In that case it it scaled accordingly.
+ * In that case it is scaled accordingly.
*/
public Dimension getPageDimension() {
double wid, hgt, scale;
--- a/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/print/ProxyGraphics2D.java Wed Jul 05 20:11:52 2017 +0200
@@ -744,7 +744,7 @@
* paint or color, and composite attributes.
* For characters in script systems such as Hebrew and Arabic,
* the glyphs may be draw from right to left, in which case the
- * coordinate supplied is the the location of the leftmost character
+ * coordinate supplied is the location of the leftmost character
* on the baseline.
* @param iterator the iterator whose text is to be drawn
* @param x,y the coordinates where the iterator's text should be drawn.
@@ -769,7 +769,7 @@
* paint or color, and composite attributes.
* For characters in script systems such as Hebrew and Arabic,
* the glyphs may be draw from right to left, in which case the
- * coordinate supplied is the the location of the leftmost character
+ * coordinate supplied is the location of the leftmost character
* on the baseline.
* @param iterator the iterator whose text is to be drawn
* @param x,y the coordinates where the iterator's text should be drawn.
--- a/jdk/src/java.desktop/share/classes/sun/swing/AccumulativeRunnable.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/AccumulativeRunnable.java Wed Jul 05 20:11:52 2017 +0200
@@ -64,7 +64,7 @@
* </pre>
*
* <p>
- * Say we want want to implement addDirtyRegion(Rectangle rect)
+ * Say we want to implement addDirtyRegion(Rectangle rect)
* which sends this region to the
* handleDirtyRegions(List<Rect> regiouns) on the EDT.
* addDirtyRegions better be accumulated before handling on the EDT.
--- a/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java Wed Jul 05 20:11:52 2017 +0200
@@ -79,7 +79,7 @@
}
/**
- * Renders the cached image to the the passed in <code>Graphic</code>.
+ * Renders the cached image to the passed in <code>Graphic</code>.
* If there is no cached image <code>paintToImage</code> will be invoked.
* <code>paintImage</code> is invoked to paint the cached image.
*
--- a/jdk/src/java.desktop/share/native/common/font/fontscalerdefs.h Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/common/font/fontscalerdefs.h Wed Jul 05 20:11:52 2017 +0200
@@ -87,7 +87,7 @@
#define t2kScalarAverage(a, b) (((a) + (b)) / (t2kScalar)(2))
/* managed: 1 means the glyph has a hardware cached
- * copy, and its freeing is managed by the the usual
+ * copy, and its freeing is managed by the usual
* 2D disposer code.
* A value of 0 means its either unaccelerated (and so has no cellInfos)
* or we want to free this in a different way.
--- a/jdk/src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c Wed Jul 05 20:11:52 2017 +0200
@@ -674,6 +674,9 @@
viaTexture = JNI_TRUE;
break;
#endif
+ case OGLC_VENDOR_INTEL:
+ viaTexture = JNI_TRUE;
+ break;
default:
// just use the glDrawPixels() codepath
viaTexture = JNI_FALSE;
--- a/jdk/src/java.desktop/share/native/common/java2d/opengl/OGLContext.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/common/java2d/opengl/OGLContext.c Wed Jul 05 20:11:52 2017 +0200
@@ -919,8 +919,8 @@
vcap = OGLC_VENDOR_ATI;
} else if (strncmp(vendor, "NVIDIA", 6) == 0) {
vcap = OGLC_VENDOR_NVIDIA;
- } else if (strncmp(vendor, "Sun", 3) == 0) {
- vcap = OGLC_VENDOR_SUN;
+ } else if (strncmp(vendor, "Intel", 5) == 0) {
+ vcap = OGLC_VENDOR_INTEL;
}
// REMIND: new in 7 - check if needs fixing
*caps |= ((vcap & OGLC_VCAP_MASK) << OGLC_VCAP_OFFSET);
--- a/jdk/src/java.desktop/share/native/common/java2d/opengl/OGLContext.h Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/common/java2d/opengl/OGLContext.h Wed Jul 05 20:11:52 2017 +0200
@@ -152,7 +152,7 @@
#define OGLC_VENDOR_OTHER 0
#define OGLC_VENDOR_ATI 1
#define OGLC_VENDOR_NVIDIA 2
-#define OGLC_VENDOR_SUN 3
+#define OGLC_VENDOR_INTEL 3
#define OGLC_VCAP_MASK 0x3
#define OGLC_VCAP_OFFSET 24
--- a/jdk/src/java.desktop/share/native/libawt/awt/image/gif/gifdecoder.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/libawt/awt/image/gif/gifdecoder.c Wed Jul 05 20:11:52 2017 +0200
@@ -399,7 +399,7 @@
* and therefore we have to continue looping through data
* but skip internal output loop.
*
- * In particular this is is possible when
+ * In particular this is possible when
* width of the frame is set to zero. If
* global width (i.e. width of the logical screen)
* is zero too then zero-length scanline buffer
--- a/jdk/src/java.desktop/share/native/libawt/java2d/loops/ProcessPath.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/libawt/java2d/loops/ProcessPath.c Wed Jul 05 20:11:52 2017 +0200
@@ -1418,7 +1418,7 @@
*/
);
} else {
- /* Clamping starting from first vertex of the the processed segment
+ /* Clamping starting from first vertex of the processed segment
*/
CLIPCLAMP(xMin, xMax, x1, y1, x2, y2, x3, y3, jfloat, res);
X1 = (jint)(x1*MDP_MULT);
@@ -1435,7 +1435,7 @@
return;
}
- /* Clamping starting from last vertex of the the processed segment
+ /* Clamping starting from last vertex of the processed segment
*/
CLIPCLAMP(xMin, xMax, x2, y2, x1, y1, x3, y3, jfloat, res);
@@ -2121,7 +2121,7 @@
if (res == CRES_INVISIBLE) return;
lastClipped = IS_CLIPPED(res);
- /* Clamping starting from first vertex of the the processed segment */
+ /* Clamping starting from first vertex of the processed segment */
CLIPCLAMP(outXMin, outXMax, x1, y1, x2, y2, x3, y3, jint, res);
/* Clamping only by left boundary */
@@ -2133,7 +2133,7 @@
return;
}
- /* Clamping starting from last vertex of the the processed segment */
+ /* Clamping starting from last vertex of the processed segment */
CLIPCLAMP(outXMin, outXMax, x2, y2, x1, y1, x3, y3, jint, res);
/* Checking if there was a clip by right boundary */
--- a/jdk/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Wed Jul 05 20:11:52 2017 +0200
@@ -183,7 +183,7 @@
bBuffer, offset, numBytes);
return bread;
} else {
- /* We probably hit bug bug 4845371. For reasons that
+ /* We probably hit bug 4845371. For reasons that
* are currently unclear, the call stacks after the initial
* createScaler call that read large amounts of data seem to
* be OK and can create the byte buffer above, but this code
@@ -253,7 +253,7 @@
We can consider sharing freetype library between different
scalers. However, Freetype docs suggest to use different libraries
for different threads. Also, our architecture implies that single
- FontScaler object is shared for for different sizes/transforms/styles
+ FontScaler object is shared for different sizes/transforms/styles
of the same font.
On other hand these methods can not be concurrently executed
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/LayoutEngine.h Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/LayoutEngine.h Wed Jul 05 20:11:52 2017 +0200
@@ -297,7 +297,7 @@
* This method does character to glyph mapping. The default implementation
* uses the font instance to do the mapping. It will allocate the glyph and
* character index arrays if they're not already allocated. If it allocates the
- * character index array, it will fill it it.
+ * character index array, it will fill it.
*
* This method supports right to left
* text with the ability to store the glyphs in reverse order, and by supporting
@@ -537,4 +537,3 @@
U_NAMESPACE_END
#endif
-
--- a/jdk/src/java.desktop/share/native/liblcms/LCMS.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/share/native/liblcms/LCMS.c Wed Jul 05 20:11:52 2017 +0200
@@ -879,7 +879,7 @@
cmsCloseProfile(p);
p = NULL;
} else {
- // do final check whether we can read and handle the the target tag.
+ // do final check whether we can read and handle the target tag.
const void* pTag = cmsReadTag(pfSanity, sig);
if (pTag == NULL) {
// the tag can not be cooked
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/ListHelper.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/ListHelper.java Wed Jul 05 20:11:52 2017 +0200
@@ -48,7 +48,7 @@
private final int BORDER_WIDTH; // Width of border drawn around the list
// of items
private final int ITEM_MARGIN; // Margin between the border of the list
- // of items and and item's bg, and between
+ // of items and item's bg, and between
// items
private final int TEXT_SPACE; // Space between the edge of an item and
// the text
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbeddedFramePeer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbeddedFramePeer.java Wed Jul 05 20:11:52 2017 +0200
@@ -251,7 +251,7 @@
embedder.registerAccelerator(iter.next(), i++);
}
}
- // Now we know that the the embedder is an XEmbed server, so we
+ // Now we know that the embedder is an XEmbed server, so we
// reregister the drop target to enable XDnD protocol support via
// XEmbed.
updateDropTarget();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XScrollPanePeer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XScrollPanePeer.java Wed Jul 05 20:11:52 2017 +0200
@@ -202,7 +202,7 @@
// Check to see if we hid either of the scrollbars but left
// ourselves scrolled off of the top and/or right of the pane.
- // If we did, we need to scroll to the top and/or right of of
+ // If we did, we need to scroll to the top and/or right of
// the pane to make it visible.
//
// Reminder: see if there is a better place to put this code.
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java Wed Jul 05 20:11:52 2017 +0200
@@ -287,7 +287,7 @@
}
/**
- * Deselects the the highlighted text.
+ * Deselects the highlighted text.
*/
public void deselect() {
int selStart=xtext.getSelectionStart();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Wed Jul 05 20:11:52 2017 +0200
@@ -103,11 +103,11 @@
static TreeMap<Long, XBaseWindow> winMap = new TreeMap<>();
static HashMap<Object, Object> specialPeerMap = new HashMap<>();
static HashMap<Long, Collection<XEventDispatcher>> winToDispatcher = new HashMap<>();
- private static long _display;
static UIDefaults uidefaults;
- static X11GraphicsEnvironment localEnv;
- static X11GraphicsDevice device;
- static final X11GraphicsConfig config;
+ static final X11GraphicsEnvironment localEnv;
+ private static final X11GraphicsDevice device;
+ private static final X11GraphicsConfig config;
+ private static final long display;
static int awt_multiclick_time;
static boolean securityWarningEnabled;
@@ -118,15 +118,16 @@
static {
initSecurityWarning();
if (GraphicsEnvironment.isHeadless()) {
+ localEnv = null;
+ device = null;
config = null;
+ display = 0;
} else {
localEnv = (X11GraphicsEnvironment) GraphicsEnvironment
.getLocalGraphicsEnvironment();
device = (X11GraphicsDevice) localEnv.getDefaultScreenDevice();
- config = (X11GraphicsConfig) (device.getDefaultConfiguration());
- if (device != null) {
- _display = device.getDisplay();
- }
+ config = (X11GraphicsConfig) device.getDefaultConfiguration();
+ display = device.getDisplay();
setupModifierMap();
initIDs();
setBackingStoreType();
@@ -197,10 +198,18 @@
}
}
- static Object displayLock = new Object();
-
+ /**
+ * Returns the X11 Display of the default screen device.
+ *
+ * @return X11 Display
+ * @throws AWTError thrown if local GraphicsEnvironment is null, which
+ * means we are in the headless environment
+ */
public static long getDisplay() {
- return _display;
+ if (localEnv == null) {
+ throw new AWTError("Local GraphicsEnvironment must not be null");
+ }
+ return display;
}
public static long getDefaultRootWindow() {
--- a/jdk/src/java.desktop/unix/classes/sun/font/NativeFont.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/font/NativeFont.java Wed Jul 05 20:11:52 2017 +0200
@@ -369,7 +369,7 @@
*/
// sb.replace(hPos[6]+1, hPos[7], "0");
- /* comment out this block to the the 1.4.2 behaviour */
+ /* comment out this block to the 1.4.2 behaviour */
if (hPos[0] == 0 && hPos[1] == 1) {
/* null foundry name : some linux font configuration files have
* symbol font entries like this and its just plain wrong.
--- a/jdk/src/java.desktop/unix/native/common/awt/awt_Font.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/common/awt/awt_Font.c Wed Jul 05 20:11:52 2017 +0200
@@ -587,6 +587,7 @@
Disposer_AddRecord(env, font, pDataDisposeMethod, ptr_to_jlong(fdata));
return fdata;
} else {
+ JNU_CHECK_EXCEPTION_RETURN(env, NULL);
Display *display = NULL;
struct FontData *fdata = NULL;
char fontSpec[1024];
@@ -722,7 +723,7 @@
}
/* AWT fonts are always "multifonts" and probably have been in
- * all post 1.0 releases, so this test test for multi fonts is
+ * all post 1.0 releases, so this test for multi fonts is
* probably not needed, and the singleton xfont is probably never used.
*/
if (fdata->charset_num > 0) {
--- a/jdk/src/java.desktop/unix/native/common/awt/medialib/mlib_v_ImageCopy_f.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/common/awt/medialib/mlib_v_ImageCopy_f.c Wed Jul 05 20:11:52 2017 +0200
@@ -196,7 +196,7 @@
/***************************************************************/
/*
* Either source or destination data are not 8-byte aligned.
- * And size is is in bytes.
+ * And size is in bytes.
*/
void mlib_ImageCopy_na(const mlib_u8 *sa,
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Event.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Event.c Wed Jul 05 20:11:52 2017 +0200
@@ -42,7 +42,7 @@
JNIEXPORT void JNICALL
Java_java_awt_Event_initIDs(JNIEnv *env, jclass cls)
{
- eventIDs.data = (*env)->GetFieldID(env, cls, "data", "J");
- eventIDs.consumed = (*env)->GetFieldID(env, cls, "consumed", "Z");
- eventIDs.id = (*env)->GetFieldID(env, cls, "id", "I");
+ CHECK_NULL(eventIDs.data = (*env)->GetFieldID(env, cls, "data", "J"));
+ CHECK_NULL(eventIDs.consumed = (*env)->GetFieldID(env, cls, "consumed", "Z"));
+ CHECK_NULL(eventIDs.id = (*env)->GetFieldID(env, cls, "id", "I"));
}
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,7 @@
* questions.
*/
+#include "jni_util.h"
#include "awt_p.h"
#include "awt.h"
#include "color.h"
@@ -763,6 +764,7 @@
XSetIOErrorHandler(xioerror_handler);
JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", "init", "(J)V",
ptr_to_jlong(awt_display));
+ JNU_CHECK_EXCEPTION_RETURN(env, NULL);
/* set awt_numScreens, and whether or not we're using Xinerama */
xineramaInit();
@@ -789,6 +791,7 @@
x11Screens[i].root = RootWindow(awt_display, i);
}
x11Screens[i].defaultConfig = makeDefaultConfig(env, i);
+ JNU_CHECK_EXCEPTION_RETURN(env, NULL);
}
return dpy;
@@ -1495,7 +1498,7 @@
if (aData == NULL) {
return JNI_FALSE;
}
- return (jboolean)aData->isTranslucencySupported;
+ return aData->isTranslucencySupported ? JNI_TRUE : JNI_FALSE;
#endif
}
@@ -1575,9 +1578,9 @@
jobject this)
{
#ifdef HEADLESS
- return false;
+ return JNI_FALSE;
#else
- return usingXinerama;
+ return usingXinerama ? JNI_TRUE : JNI_FALSE;
#endif /* HEADLESS */
}
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/multiVis.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/multiVis.c Wed Jul 05 20:11:52 2017 +0200
@@ -1103,7 +1103,7 @@
* of those supports a transparent
* pixel. */
int32_t *numVisuals; /* Number of XVisualInfo struct's
- * pointed to to by pVisuals. */
+ * pointed to by pVisuals. */
XVisualInfo **pVisuals; /* All of the device's visuals. */
int32_t *numOverlayVisuals; /* Number of OverlayInfo's pointed
* to by pOverlayVisuals. If this
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c Wed Jul 05 20:11:52 2017 +0200
@@ -72,6 +72,11 @@
static void quit(JNIEnv * env, jobject jpeer, gboolean isSignalHandler)
{
+ jthrowable pendingException;
+ if (pendingException = (*env)->ExceptionOccurred(env)) {
+ (*env)->ExceptionClear(env);
+ }
+
GtkWidget * dialog = (GtkWidget*)jlong_to_ptr(
(*env)->GetLongField(env, jpeer, widgetFieldID));
@@ -95,6 +100,10 @@
fp_gdk_threads_leave();
}
}
+
+ if (pendingException) {
+ (*env)->Throw(env, pendingException);
+ }
}
/*
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/wsutils.h Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/wsutils.h Wed Jul 05 20:11:52 2017 +0200
@@ -167,7 +167,7 @@
* of those supports a transparent
* pixel. */
int32_t *numVisuals, /* Number of XVisualInfo struct's
- * pointed to to by pVisuals. */
+ * pointed to by pVisuals. */
XVisualInfo **pVisuals, /* All of the device's visuals. */
int32_t *numOverlayVisuals, /* Number of OverlayInfo's pointed
* to by pOverlayVisuals. If this
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c Wed Jul 05 20:11:52 2017 +0200
@@ -77,7 +77,7 @@
#ifndef HEADLESS
extern Display* awt_init_Display(JNIEnv *env, jobject this);
-extern void freeNativeStringArray(char **array, long length);
+extern void freeNativeStringArray(char **array, jsize length);
extern char** stringArrayToNative(JNIEnv *env, jobjectArray array, jsize * ret_length);
struct XFontPeerIDs xFontPeerIDs;
--- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c Wed Jul 05 20:11:52 2017 +0200
@@ -252,7 +252,7 @@
/***************************************************************/
/*
* Either source or destination data are not 8-byte aligned.
- * And dsize is is in pixels.
+ * And dsize is in pixels.
*/
void mlib_v_ImageChannelExtract_U8_43R_D1(const mlib_u8 *src,
@@ -1182,7 +1182,7 @@
/***************************************************************/
/*
* Either source or destination data are not 8-byte aligned.
- * And size is is in pixels.
+ * And size is in pixels.
*/
void mlib_v_ImageChannelExtract_S16_43L_D1(const mlib_s16 *src,
--- a/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java Wed Jul 05 20:11:52 2017 +0200
@@ -251,7 +251,7 @@
// Get a child pidl relative to 'parent'
long childPIDL = copyFirstPIDLEntry(pIDL);
if (childPIDL != 0) {
- // Get a handle to the the rest of the ID list
+ // Get a handle to the rest of the ID list
// i,e, parent's grandchilren and down
pIDL = getNextPIDLEntry(pIDL);
if (pIDL != 0) {
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java Wed Jul 05 20:11:52 2017 +0200
@@ -110,7 +110,7 @@
protected abstract Image getBackBuffer(boolean clear);
/**
- * Updates the the window associated with this painter with the contents
+ * Updates the window associated with this painter with the contents
* of the passed image.
* The image can not be null, and NPE will be thrown if it is.
*/
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Wed Jul 05 20:11:52 2017 +0200
@@ -183,7 +183,7 @@
/**
* Initializes the Toolkit for use in an embedded environment.
*
- * @return true if the the initialization succeeded; false if it failed.
+ * @return true if the initialization succeeded; false if it failed.
* The function will fail if the Toolkit was already initialized.
* @since 1.3
*/
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -77,7 +77,7 @@
ZeroMemory(info, sizeof(ThreadGraphicsInfo));
TlsSetValue(threadInfoIndex, (LPVOID)info);
J2dTraceLn2(J2D_TRACE_VERBOSE,
- " current batch limit for for thread 0x%x is %d",
+ " current batch limit for thread 0x%x is %d",
GetCurrentThreadId(), ::GdiGetBatchLimit());
J2dTraceLn(J2D_TRACE_VERBOSE, " setting to the limit to 1");
// Fix for bug 4374079
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Debug.h Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Debug.h Wed Jul 05 20:11:52 2017 +0200
@@ -40,7 +40,7 @@
static void AssertCallback(const char * expr, const char * file,
int line);
- /* This method signals that the VM is exiting cleanly, and thus the
+ /* This method signals that the VM is exiting cleanly, and thus
the debug memory manager should dump a leaks report when the
VM has finished exiting. This method should not be called for
termination exits (such as <CTRL>-C) */
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.h Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.h Wed Jul 05 20:11:52 2017 +0200
@@ -215,7 +215,7 @@
* Hashtable<Thread, BlockedThreadStruct> - a table that contains all the
* information about non-toolkit threads with modal blocked embedded
* frames. This information includes: number of blocked embedded frames
- * created on the the thread, and mouse and modal hooks installed for
+ * created on the thread, and mouse and modal hooks installed for
* that thread. For every thread each hook is installed only once
*/
static Hashtable sm_BlockedThreads;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Palette.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Palette.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -113,7 +113,7 @@
}
/**
- * Retrieves system palette entries. Includes a workaround for for some
+ * Retrieves system palette entries. Includes a workaround for some
* video drivers which may not support the GSPE call but may return
* valid values from this procedure.
*/
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.h Wed Jul 05 20:11:52 2017 +0200
@@ -553,7 +553,7 @@
bool Terminate(bool wrongThread);
bool InvokeAndTerminate(void(_cdecl *fn)(void *), void *param);
- // waits for the the thread completion;
+ // waits for the thread completion;
// use the method after Terminate() only if Terminate() returned true
INLINE void Wait4Finish() {
::WaitForSingleObject(hFinished, INFINITE);
--- a/jdk/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp Wed Jul 05 20:11:52 2017 +0200
@@ -426,7 +426,7 @@
err = midiInStart((HMIDIIN) handle->deviceHandle);
/* $$mp 200308-11: This method is already called in ...open(). It is
- unclear why is is called again. The specification says that
+ unclear why it is called again. The specification says that
MidiDevice.getMicrosecondPosition() returns the time since the
device was opened (the spec doesn't know about start/stop).
So I guess this call is obsolete. */
--- a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c Wed Jul 05 20:11:52 2017 +0200
@@ -564,7 +564,7 @@
/*
* Evaluates all escapes in s. Assumes that escapes are well-formed
* syntactically, i.e., of the form %XX.
- * If the path does not require decoding the the original path is
+ * If the path does not require decoding the original path is
* returned. Otherwise the decoded path (heap allocated) is returned,
* along with the length of the decoded path. Note that the return
* string will not be null terminated after decoding.
--- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java Wed Jul 05 20:11:52 2017 +0200
@@ -576,7 +576,7 @@
* the selected MBeans.
*
* @param name The object name pattern identifying the MBeans to
- * be retrieved. If null or or no domain and key properties
+ * be retrieved. If null or no domain and key properties
* are specified, all the MBeans registered will be retrieved.
* @param query The query expression to be applied for selecting
* MBeans. If null no query expression will be applied for
@@ -598,7 +598,7 @@
* the names of a set of MBeans specified by pattern matching on the
* <CODE>ObjectName</CODE> and/or a Query expression, a specific
* MBean name (equivalent to testing whether an MBean is registered).
- * When the object name is null or or no domain and key properties are
+ * When the object name is null or no domain and key properties are
* specified, all objects are selected (and filtered if a query is
* specified). It returns the set of ObjectNames for the MBeans
* selected.
--- a/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java Wed Jul 05 20:11:52 2017 +0200
@@ -140,7 +140,7 @@
}
/**
- * Called to to fetch notifications from a server.
+ * Called to fetch notifications from a server.
*/
abstract protected NotificationResult fetchNotifs(long clientSequenceNumber,
int maxNotifications,
--- a/jdk/src/java.management/share/classes/com/sun/management/GarbageCollectionNotificationInfo.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.management/share/classes/com/sun/management/GarbageCollectionNotificationInfo.java Wed Jul 05 20:11:52 2017 +0200
@@ -42,7 +42,7 @@
* The notification emitted will contain the garbage collection notification
* information about the status of the memory:
* <u1>
- * <li>The name of the garbage collector used perform the collection.</li>
+ * <li>The name of the garbage collector used to perform the collection.</li>
* <li>The action performed by the garbage collector.</li>
* <li>The cause of the garbage collection action.</li>
* <li>A {@link GcInfo} object containing some statistics about the GC cycle
@@ -109,7 +109,7 @@
*
* @param gcName The name of the garbage collector used to perform the collection
* @param gcAction The name of the action performed by the garbage collector
- * @param gcCause The cause the garbage collection action
+ * @param gcCause The cause of the garbage collection action
* @param gcInfo a GcInfo object providing statistics about the GC cycle
*/
public GarbageCollectionNotificationInfo(String gcName,
@@ -152,18 +152,18 @@
}
/**
- * Returns the action of the performed by the garbage collector
+ * Returns the action performed by the garbage collector
*
- * @return the the action of the performed by the garbage collector
+ * @return the action performed by the garbage collector
*/
public String getGcAction() {
return gcAction;
}
/**
- * Returns the cause the garbage collection
+ * Returns the cause of the garbage collection
*
- * @return the the cause the garbage collection
+ * @return the cause of the garbage collection
*/
public String getGcCause() {
return gcCause;
--- a/jdk/src/java.management/share/classes/javax/management/openmbean/ArrayType.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.management/share/classes/javax/management/openmbean/ArrayType.java Wed Jul 05 20:11:52 2017 +0200
@@ -570,7 +570,7 @@
// In case this ArrayType instance describes an array of classes implementing the TabularData or CompositeData interface,
// we first check for the assignability of obj to such an array of TabularData or CompositeData,
// which ensures that:
- // . obj is of the the same dimension as this ArrayType instance,
+ // . obj is of the same dimension as this ArrayType instance,
// . it is declared as an array of elements which are either all TabularData or all CompositeData.
//
// If the assignment check is positive,
--- a/jdk/src/java.management/share/classes/javax/management/openmbean/SimpleType.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.management/share/classes/javax/management/openmbean/SimpleType.java Wed Jul 05 20:11:52 2017 +0200
@@ -244,7 +244,7 @@
/**
* Returns the hash code value for this <code>SimpleType</code> instance.
- * The hash code of a <code>SimpleType</code> instance is the the hash code of
+ * The hash code of a <code>SimpleType</code> instance is the hash code of
* the string value returned by the {@link OpenType#getClassName() getClassName} method.
* <p>
* As <code>SimpleType</code> instances are immutable, the hash code for this instance is calculated once,
--- a/jdk/src/java.management/share/classes/javax/management/openmbean/TabularDataSupport.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.management/share/classes/javax/management/openmbean/TabularDataSupport.java Wed Jul 05 20:11:52 2017 +0200
@@ -212,7 +212,7 @@
/**
* Returns <tt>true</tt> if and only if this <tt>TabularData</tt> instance contains a <tt>CompositeData</tt> value
* (ie a row) whose index is the specified <var>key</var>. If <var>key</var> cannot be cast to a one dimension array
- * of Object instances, this method simply returns <tt>false</tt>; otherwise it returns the the result of the call to
+ * of Object instances, this method simply returns <tt>false</tt>; otherwise it returns the result of the call to
* <tt>this.containsKey((Object[]) key)</tt>.
*
* @param key the index value whose presence in this <tt>TabularData</tt> instance is to be tested.
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java Wed Jul 05 20:11:52 2017 +0200
@@ -260,7 +260,7 @@
if (unsolicited == null || unsolicited.size() == 0) {
// This shouldn't really happen, but might in case
// there is a timing problem that removes a listener
- // before a fired event event reaches here.
+ // before a fired event reaches here.
return;
}
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java Wed Jul 05 20:11:52 2017 +0200
@@ -989,7 +989,7 @@
}
/*
- * Append the the second Vector onto the first Vector
+ * Append the second Vector onto the first Vector
* (v2 must be non-null)
*/
private static <T> Vector<T> appendVector(Vector<T> v1, Vector<T> v2) {
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapReferralException.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapReferralException.java Wed Jul 05 20:11:52 2017 +0200
@@ -59,7 +59,7 @@
* objects.
* <p>
* If an exception was recorded while processing a chain of
- * <tt>LdapReferralException</tt> objects then is is throw once
+ * <tt>LdapReferralException</tt> objects then it is throw once
* processing has completed.
*
* @author Vincent Ryan
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/toolkit/ctx/AtomicContext.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/toolkit/ctx/AtomicContext.java Wed Jul 05 20:11:52 2017 +0200
@@ -533,7 +533,7 @@
* This function is used when implementing a naming system that
* supports junctions. For example, when the a_list_nns(newobj)
* method is invoked, that means the caller is attempting to list the
- * the nns context of of this context. For a context that supports
+ * the nns context of this context. For a context that supports
* junctions, it by default does not have any nns. Consequently,
* a NameNotFoundException is thrown.
*/
--- a/jdk/src/java.naming/share/classes/javax/naming/ldap/Rdn.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.naming/share/classes/javax/naming/ldap/Rdn.java Wed Jul 05 20:11:52 2017 +0200
@@ -505,7 +505,7 @@
*
* @param val The non-null object to be escaped.
* @return Escaped string value.
- * @throws ClassCastException if val is is not a String or byte array.
+ * @throws ClassCastException if val is not a String or byte array.
*/
public static String escapeValue(Object val) {
return (val instanceof byte[])
--- a/jdk/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java Wed Jul 05 20:11:52 2017 +0200
@@ -981,7 +981,7 @@
private static int MAX_ATTEMPTS = 5;
/**
- * Release the the appropriate file lock (user or system).
+ * Release the appropriate file lock (user or system).
* @throws SecurityException if file access denied.
*/
private void unlockFile() {
--- a/jdk/src/java.rmi/share/classes/java/rmi/registry/LocateRegistry.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.rmi/share/classes/java/rmi/registry/LocateRegistry.java Wed Jul 05 20:11:52 2017 +0200
@@ -62,7 +62,7 @@
private LocateRegistry() {}
/**
- * Returns a reference to the the remote object <code>Registry</code> for
+ * Returns a reference to the remote object <code>Registry</code> for
* the local host on the default registry port of 1099.
*
* @return reference (a stub) to the remote object registry
@@ -76,7 +76,7 @@
}
/**
- * Returns a reference to the the remote object <code>Registry</code> for
+ * Returns a reference to the remote object <code>Registry</code> for
* the local host on the specified <code>port</code>.
*
* @param port port on which the registry accepts requests
--- a/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -336,13 +336,12 @@
* Main program to start a registry. <br>
* The port number can be specified on the command line.
*/
- @SuppressWarnings("deprecation")
public static void main(String args[])
{
// Create and install the security manager if one is not installed
// already.
if (System.getSecurityManager() == null) {
- System.setSecurityManager(new RMISecurityManager());
+ System.setSecurityManager(new SecurityManager());
}
try {
--- a/jdk/src/java.rmi/share/classes/sun/rmi/server/MarshalOutputStream.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/server/MarshalOutputStream.java Wed Jul 05 20:11:52 2017 +0200
@@ -88,7 +88,7 @@
}
/**
- * Serializes a location from which to load the the specified class.
+ * Serializes a location from which to load the specified class.
*/
protected void annotateClass(Class<?> cl) throws IOException {
writeLocation(java.rmi.server.RMIClassLoader.getClassAnnotation(cl));
--- a/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,7 +35,7 @@
* ConnectionMultiplexer manages the transparent multiplexing of
* multiple virtual connections from one endpoint to another through
* one given real connection to that endpoint. The input and output
- * streams for the the underlying real connection must be supplied.
+ * streams for the underlying real connection must be supplied.
* A callback object is also supplied to be informed of new virtual
* connections opened by the remote endpoint. After creation, the
* run() method must be called in a thread created for demultiplexing
--- a/jdk/src/java.scripting/share/classes/javax/script/ScriptContext.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.scripting/share/classes/javax/script/ScriptContext.java Wed Jul 05 20:11:52 2017 +0200
@@ -130,7 +130,7 @@
* is determined by the numeric value of the scope parameter (lowest
* scope values first.)
*
- * @param name The name of the the attribute to retrieve.
+ * @param name The name of the attribute to retrieve.
* @return The value of the attribute in the lowest scope for
* which an attribute with the given name is defined. Returns
* null if no attribute with the name exists in any scope.
--- a/jdk/src/java.scripting/share/classes/javax/script/ScriptEngineManager.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.scripting/share/classes/javax/script/ScriptEngineManager.java Wed Jul 05 20:11:52 2017 +0200
@@ -407,7 +407,7 @@
/** Map of script file extension to script engine factory. */
private HashMap<String, ScriptEngineFactory> extensionAssociations;
- /** Map of script script MIME type to script engine factory. */
+ /** Map of script MIME type to script engine factory. */
private HashMap<String, ScriptEngineFactory> mimeTypeAssociations;
/** Global bindings associated with script engines created by this manager. */
--- a/jdk/src/java.scripting/share/classes/javax/script/SimpleScriptContext.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.scripting/share/classes/javax/script/SimpleScriptContext.java Wed Jul 05 20:11:52 2017 +0200
@@ -132,7 +132,7 @@
* is determined by the numeric value of the scope parameter (lowest
* scope values first.)
*
- * @param name The name of the the attribute to retrieve.
+ * @param name The name of the attribute to retrieve.
* @return The value of the attribute in the lowest scope for
* which an attribute with the given name is defined. Returns
* null if no attribute with the name exists in any scope.
--- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java Wed Jul 05 20:11:52 2017 +0200
@@ -535,7 +535,7 @@
* allowable renew time has passed. Any other error returned by the
* KDC will also cause this method to fail.
*
- * Note: This method is not synchronized with the the accessor
+ * Note: This method is not synchronized with the accessor
* methods of this object. Hence callers need to be aware of multiple
* threads that might access this and try to renew it at the same
* time.
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java Wed Jul 05 20:11:52 2017 +0200
@@ -558,7 +558,7 @@
* @param msgProp instance of MessageProp that is used by the
* application to set the desired QOP and privacy state. Set the
* desired QOP to 0 to request the default QOP. Upon return from this
- * method, this object will contain the the actual privacy state that
+ * method, this object will contain the actual privacy state that
* was applied to the message by the underlying mechanism.
* @return a byte[] containing the token to be sent to the peer.
*
@@ -605,7 +605,7 @@
* @param msgProp instance of MessageProp that is used by the
* application to set the desired QOP and privacy state. Set the
* desired QOP to 0 to request the default QOP. Upon return from this
- * method, this object will contain the the actual privacy state that
+ * method, this object will contain the actual privacy state that
* was applied to the message by the underlying mechanism.
*
* @throws GSSException containing the following
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/TokenTracker.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/TokenTracker.java Wed Jul 05 20:11:52 2017 +0200
@@ -368,7 +368,7 @@
/**
* Returns -1 if this interval represented by this entry precedes
- * the number, 0 if the the number is contained in the interval,
+ * the number, 0 if the number is contained in the interval,
* and -1 if the interval occurs after the number.
*/
final int compareTo(int number) {
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java Wed Jul 05 20:11:52 2017 +0200
@@ -102,7 +102,7 @@
* @param useSubkey Whether the subkey is to be used to protect this
* specific application session. If this is not set then the
* session key from the ticket will be used.
- * @param checksum checksum of the the application data that accompanies
+ * @param checksum checksum of the application data that accompanies
* the KRB_AP_REQ.
* @throws KrbException for any Kerberos protocol specific error
* @throws IOException for any IO related errors
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java Wed Jul 05 20:11:52 2017 +0200
@@ -390,7 +390,7 @@
* /tmp/krb5cc_uid ; for all other platforms we use
* {user_home}/krb5cc_{user_name}
* Please note that for Windows we will use LSA to get
- * the TGT from the the default cache even before we come here;
+ * the TGT from the default cache even before we come here;
* however when we create cache we will create a cache under
* {user_home}/krb5cc_{user_name} for non-Unix platforms including
* Windows.
--- a/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java Wed Jul 05 20:11:52 2017 +0200
@@ -49,7 +49,7 @@
* for which authorization is being granted; if null, same as
* authenticationID
* @param authenticationID A non-null string representing the principal
- * being authenticated. pw is associated with with this principal.
+ * being authenticated. pw is associated with this principal.
* @param pw A non-null byte[] containing the password.
*/
PlainClient(String authorizationID, String authenticationID, byte[] pw)
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -431,7 +431,7 @@
* provider to assist in determining the choice of the synchronizaton
* provider such as:
* <ul>
- * <li><code>ROWSET_SYNC_PROVIDER</code> - the property specifying the the
+ * <li><code>ROWSET_SYNC_PROVIDER</code> - the property specifying the
* <code>SyncProvider</code> class name to be instantiated by the
* <code>SyncFacttory</code>
* <li><code>ROWSET_SYNC_VENDOR</code> - the property specifying the software
@@ -3727,7 +3727,7 @@
/*
* Each call to internalPrevious may move the cursor
- * over multiple rows, the absolute position moves one one row
+ * over multiple rows, the absolute position moves one row
*/
if (ret == true)
--absolutePos;
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/JdbcRowSetImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/JdbcRowSetImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -3993,7 +3993,7 @@
/**
* Retrieves the <code>DatabaseMetaData</code> associated with
- * the connection handle associated this this
+ * the connection handle associated with this
* <code>JdbcRowSet</code> object.
*
* @return the <code>DatabaseMetadata</code> associated
@@ -4007,7 +4007,7 @@
/**
* Retrieves the <code>ParameterMetaData</code> associated with
- * the connection handle associated this this
+ * the connection handle associated with this
* <code>JdbcRowSet</code> object.
*
* @return the <code>ParameterMetadata</code> associated
@@ -4325,7 +4325,7 @@
* the connection is created using a JDBC technology-enabled driver
* ("JDBC driver") and the <code>DriverManager</code>.
* The correct JDBC URL for the specific driver to be used can be found
- * in the driver documentation. Although there are guidelines for for how
+ * in the driver documentation. Although there are guidelines for how
* a JDBC URL is formed,
* a driver vendor can specify any <code>String</code> object except
* one with a length of <code>0</code> (an empty string).
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/JoinRowSetImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/JoinRowSetImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -1169,7 +1169,7 @@
* @return the column value; if the value is SQL <code>NULL</code>, the
* result is <code>null</code>
* @throws SQLException if the given column index is out of bounds,
- * the cursor is not on a valid row, or the the value to be
+ * the cursor is not on a valid row, or the value to be
* retrieved is not binary
*/
public byte[] getBytes(int columnIndex) throws SQLException {
@@ -4129,7 +4129,7 @@
}
/**
- * Creates an an output stream of the internal state and contents of a
+ * Creates an output stream of the internal state and contents of a
* <code>WebRowSet</code> for XML proceessing
*
* @throws SQLException if a datasource access occurs
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/WebRowSetImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/WebRowSetImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -93,7 +93,7 @@
}
/**
- * Constructs a new <code>WebRowSet</code> object initialized with the the
+ * Constructs a new <code>WebRowSet</code> object initialized with the
* synchronization SPI provider properties as specified in the <code>Hashtable</code>. If
* this hashtable is empty or is <code>null</code> the default constructor is invoked.
*
@@ -234,7 +234,7 @@
/**
* Writes this <code>WebRowSet</code> object to the given <code> OutputStream</code>
* object in XML format.
- * Creates an an output stream of the internal state and contents of a
+ * Creates an output stream of the internal state and contents of a
* <code>WebRowSet</code> for XML proceessing
*
* @throws SQLException if a datasource access error occurs
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java Wed Jul 05 20:11:52 2017 +0200
@@ -843,7 +843,7 @@
for (String pkName : primaryKeys) {
if (!isPKNameValid(pkName, rsmd)) {
- /* We came here as one of the the primary keys
+ /* We came here as one of the primary keys
* of the table is not present in the cached
* rowset object, it should be an autoincrement column
* and not included while creating CachedRowSet
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/internal/SyncResolverImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/internal/SyncResolverImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -288,7 +288,7 @@
}
/**
- * This passes a CachedRowSet as a row the the CachedRowSetWriter
+ * This passes a CachedRowSet as a row to the CachedRowSetWriter
* after the values have been resolved, back to the datasource.
*
* @param row a <code>CachedRowSet</code> object which will hold the
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/providers/package.html Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/providers/package.html Wed Jul 05 20:11:52 2017 +0200
@@ -137,7 +137,7 @@
inserted or deleted. Any method that causes a change in the rowset's values
or cursor position also notifies any object that has been registered as
a listener with the rowset. So, for example, a table that displays the rowset's
- data in an applet can can be notified of changes and make updates as they
+ data in an applet can be notified of changes and make updates as they
occur.<br>
<br>
The changes made to a rowset can be propagated back to the original data
--- a/jdk/src/java.sql/share/classes/java/sql/DriverManager.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.sql/share/classes/java/sql/DriverManager.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,7 +29,6 @@
import java.util.ServiceLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.PropertyPermission;
import java.util.concurrent.CopyOnWriteArrayList;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
@@ -89,6 +88,8 @@
private static volatile java.io.PrintStream logStream = null;
// Used in println() to synchronize logWriter
private final static Object logSync = new Object();
+ // Used in ensureDriversInitialized() to synchronize driversInitialized
+ private final static Object lockForInitDrivers = new Object();
private static volatile boolean driversInitialized;
private static final String JDBC_DRIVERS_PROPERTY = "jdbc.drivers";
@@ -280,11 +281,13 @@
println("DriverManager.getDriver(\"" + url + "\")");
+ ensureDriversInitialized();
+
Class<?> callerClass = Reflection.getCallerClass();
// Walk through the loaded registeredDrivers attempting to locate someone
// who understands the given URL.
- for (DriverInfo aDriver : getRegisteredDrivers()) {
+ for (DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if (isDriverAllowed(aDriver.driver, callerClass)) {
@@ -384,8 +387,7 @@
* @see SecurityManager#checkPermission
*/
@CallerSensitive
- public static synchronized void deregisterDriver(Driver driver)
- throws SQLException {
+ public static void deregisterDriver(Driver driver) throws SQLException {
if (driver == null) {
return;
}
@@ -398,22 +400,24 @@
println("DriverManager.deregisterDriver: " + driver);
DriverInfo aDriver = new DriverInfo(driver, null);
- if (registeredDrivers.contains(aDriver)) {
- if (isDriverAllowed(driver, Reflection.getCallerClass())) {
- DriverInfo di = registeredDrivers.get(registeredDrivers.indexOf(aDriver));
- // If a DriverAction was specified, Call it to notify the
- // driver that it has been deregistered
- if (di.action() != null) {
- di.action().deregister();
- }
- registeredDrivers.remove(aDriver);
+ synchronized (lockForInitDrivers) {
+ if (registeredDrivers.contains(aDriver)) {
+ if (isDriverAllowed(driver, Reflection.getCallerClass())) {
+ DriverInfo di = registeredDrivers.get(registeredDrivers.indexOf(aDriver));
+ // If a DriverAction was specified, Call it to notify the
+ // driver that it has been deregistered
+ if (di.action() != null) {
+ di.action().deregister();
+ }
+ registeredDrivers.remove(aDriver);
+ } else {
+ // If the caller does not have permission to load the driver then
+ // throw a SecurityException.
+ throw new SecurityException();
+ }
} else {
- // If the caller does not have permission to load the driver then
- // throw a SecurityException.
- throw new SecurityException();
+ println(" couldn't find driver to unload");
}
- } else {
- println(" couldn't find driver to unload");
}
}
@@ -430,10 +434,12 @@
public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<>();
+ ensureDriversInitialized();
+
Class<?> callerClass = Reflection.getCallerClass();
// Walk through the loaded registeredDrivers.
- for (DriverInfo aDriver : getRegisteredDrivers()) {
+ for (DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if (isDriverAllowed(aDriver.driver, callerClass)) {
@@ -558,91 +564,81 @@
}
/*
- * Return the registered java.sql.Drivers and call loadInitialDrivers
- * if needed
+ * Load the initial JDBC drivers by checking the System property
+ * jdbc.drivers and then use the {@code ServiceLoader} mechanism
*/
- private static CopyOnWriteArrayList<DriverInfo> getRegisteredDrivers() {
- // Check to see if we need to load the initial drivers
- if (!driversInitialized) {
- loadInitialDrivers();
- }
- return registeredDrivers;
-
- }
-
- /*
- * Load the initial JDBC drivers by checking the System property
- * jdbc.properties and then use the {@code ServiceLoader} mechanism
- */
- private synchronized static void loadInitialDrivers() {
- String drivers;
-
+ private static void ensureDriversInitialized() {
if (driversInitialized) {
return;
}
- try {
- drivers = AccessController.doPrivileged(new PrivilegedAction<String>() {
- public String run() {
- return System.getProperty(JDBC_DRIVERS_PROPERTY);
+ synchronized (lockForInitDrivers) {
+ if (driversInitialized) {
+ return;
+ }
+ String drivers;
+ try {
+ drivers = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(JDBC_DRIVERS_PROPERTY);
+ }
+ });
+ } catch (Exception ex) {
+ drivers = null;
+ }
+ // If the driver is packaged as a Service Provider, load it.
+ // Get all the drivers through the classloader
+ // exposed as a java.sql.Driver.class service.
+ // ServiceLoader.load() replaces the sun.misc.Providers()
+
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+
+ ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class);
+ Iterator<Driver> driversIterator = loadedDrivers.iterator();
+
+ /* Load these drivers, so that they can be instantiated.
+ * It may be the case that the driver class may not be there
+ * i.e. there may be a packaged driver with the service class
+ * as implementation of java.sql.Driver but the actual class
+ * may be missing. In that case a java.util.ServiceConfigurationError
+ * will be thrown at runtime by the VM trying to locate
+ * and load the service.
+ *
+ * Adding a try catch block to catch those runtime errors
+ * if driver not available in classpath but it's
+ * packaged as service and that service is there in classpath.
+ */
+ try {
+ while (driversIterator.hasNext()) {
+ driversIterator.next();
+ }
+ } catch (Throwable t) {
+ // Do nothing
+ }
+ return null;
}
});
- } catch (Exception ex) {
- drivers = null;
- }
- // If the driver is packaged as a Service Provider, load it.
- // Get all the drivers through the classloader
- // exposed as a java.sql.Driver.class service.
- // ServiceLoader.load() replaces the sun.misc.Providers()
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- public Void run() {
-
- ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class);
- Iterator<Driver> driversIterator = loadedDrivers.iterator();
+ println("DriverManager.initialize: jdbc.drivers = " + drivers);
- /* Load these drivers, so that they can be instantiated.
- * It may be the case that the driver class may not be there
- * i.e. there may be a packaged driver with the service class
- * as implementation of java.sql.Driver but the actual class
- * may be missing. In that case a java.util.ServiceConfigurationError
- * will be thrown at runtime by the VM trying to locate
- * and load the service.
- *
- * Adding a try catch block to catch those runtime errors
- * if driver not available in classpath but it's
- * packaged as service and that service is there in classpath.
- */
- try{
- while(driversIterator.hasNext()) {
- driversIterator.next();
+ if (drivers != null && !drivers.equals("")) {
+ String[] driversList = drivers.split(":");
+ println("number of Drivers:" + driversList.length);
+ for (String aDriver : driversList) {
+ try {
+ println("DriverManager.Initialize: loading " + aDriver);
+ Class.forName(aDriver, true,
+ ClassLoader.getSystemClassLoader());
+ } catch (Exception ex) {
+ println("DriverManager.Initialize: load failed: " + ex);
}
- } catch(Throwable t) {
- // Do nothing
}
- return null;
}
- });
- println("DriverManager.initialize: jdbc.drivers = " + drivers);
-
- if (drivers == null || drivers.equals("")) {
- return;
+ driversInitialized = true;
+ println("JDBC DriverManager initialized");
}
- String[] driversList = drivers.split(":");
- println("number of Drivers:" + driversList.length);
- for (String aDriver : driversList) {
- try {
- println("DriverManager.Initialize: loading " + aDriver);
- Class.forName(aDriver, true,
- ClassLoader.getSystemClassLoader());
- } catch (Exception ex) {
- println("DriverManager.Initialize: load failed: " + ex);
- }
- }
-
- driversInitialized = true;
- println("JDBC DriverManager initialized");
}
@@ -666,11 +662,13 @@
println("DriverManager.getConnection(\"" + url + "\")");
+ ensureDriversInitialized();
+
// Walk through the loaded registeredDrivers attempting to make a connection.
// Remember the first exception that gets raised so we can reraise it.
SQLException reason = null;
- for (DriverInfo aDriver : getRegisteredDrivers()) {
+ for (DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if (isDriverAllowed(aDriver.driver, callerCL)) {
--- a/jdk/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java Wed Jul 05 20:11:52 2017 +0200
@@ -68,7 +68,7 @@
void setKeySize(int size);
/**
- * Returns the OAEP parameters of the algorithm applied applied to the
+ * Returns the OAEP parameters of the algorithm applied to the
* cipher data.
*
* @return the OAEP parameters.
@@ -130,4 +130,3 @@
*/
void removeEncryptionMethodInformation(Element information);
}
-
--- a/jdk/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyUtils.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyUtils.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,7 +32,7 @@
import com.sun.org.apache.xml.internal.security.keys.content.X509Data;
/**
- * Utility class for for <CODE>com.sun.org.apache.xml.internal.security.keys</CODE> package.
+ * Utility class for the <CODE>com.sun.org.apache.xml.internal.security.keys</CODE> package.
*
* @author $Author: coheigea $
*/
--- a/jdk/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java Wed Jul 05 20:11:52 2017 +0200
@@ -571,7 +571,7 @@
}
/**
- * This method only works works after a call to verify.
+ * This method only works after a call to verify.
* @return the transformed output(i.e. what is going to be digested).
*/
public XMLSignatureInput getTransformsOutput() {
--- a/jdk/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c Wed Jul 05 20:11:52 2017 +0200
@@ -320,7 +320,7 @@
JNU_ThrowIOExceptionWithLastError(env, "door_call");
} else {
/*
- * door_call succeeded but the call didn't return the the expected jint.
+ * door_call succeeded but the call didn't return the expected jint.
*/
if (door_args.data_size < sizeof(jint)) {
JNU_ThrowIOException(env, "Enqueue error - reason unknown as result is truncated!");
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSACipher.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSACipher.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -159,6 +159,7 @@
}
// see JCE spec
+ @SuppressWarnings("deprecation")
protected void engineInit(int opmode, Key key,
AlgorithmParameterSpec params, SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
@@ -369,6 +370,7 @@
}
// see JCE spec
+ @SuppressWarnings("deprecation")
protected java.security.Key engineUnwrap(byte[] wrappedKey,
String algorithm,
int type) throws InvalidKeyException, NoSuchAlgorithmException {
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Config.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Config.java Wed Jul 05 20:11:52 2017 +0200
@@ -584,16 +584,24 @@
}
private String parseLine() throws IOException {
- String s = parseWord();
+ // allow quoted string as part of line
+ String s = null;
while (true) {
int token = nextToken();
if ((token == TT_EOL) || (token == TT_EOF)) {
break;
}
- if (token != TT_WORD) {
+ if (token != TT_WORD && token != '\"') {
throw excToken("Unexpected value");
}
- s = s + " " + st.sval;
+ if (s == null) {
+ s = st.sval;
+ } else {
+ s = s + " " + st.sval;
+ }
+ }
+ if (s == null) {
+ throw excToken("Unexpected empty line");
}
return s;
}
@@ -653,7 +661,9 @@
//
private String parseLibrary(String keyword) throws IOException {
- String lib = parseStringEntry(keyword);
+ checkDup(keyword);
+ parseEquals();
+ String lib = parseLine();
lib = expand(lib);
int i = lib.indexOf("/$ISA/");
if (i != -1) {
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11KeyStore.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11KeyStore.java Wed Jul 05 20:11:52 2017 +0200
@@ -1641,7 +1641,7 @@
// If the key is a token object on this token, update it instead
// of creating a duplicate key object.
- // Otherwise, treat a P11Key like any other key, if is is extractable.
+ // Otherwise, treat a P11Key like any other key, if it is extractable.
if (key instanceof P11Key) {
P11Key p11Key = (P11Key)key;
if (p11Key.tokenObject && (p11Key.token == this.token)) {
--- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java Wed Jul 05 20:11:52 2017 +0200
@@ -89,7 +89,7 @@
private static class PKCS5Padding implements Padding {
private final int blockSize;
- // buffer for storing the the potential padding bytes
+ // buffer for storing the potential padding bytes
private ByteBuffer trailingBytes = null;
PKCS5Padding(int blockSize)
--- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java Wed Jul 05 20:11:52 2017 +0200
@@ -178,6 +178,7 @@
// see JCE spec
@Override
+ @SuppressWarnings("deprecation")
protected synchronized void engineInit(int opmode, Key newKey,
AlgorithmParameterSpec params, SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
@@ -331,6 +332,7 @@
// see JCE spec
@Override
+ @SuppressWarnings("deprecation")
protected synchronized Key engineUnwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm, int wrappedKeyType)
throws InvalidKeyException, NoSuchAlgorithmException {
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2010, 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
@@ -141,8 +141,9 @@
public Arguments(String[] args) throws IllegalArgumentException {
int argc = 0;
- if (args.length < 1) {
- throw new IllegalArgumentException("invalid argument count");
+ if (args.length == 0) {
+ help = true;
+ return;
}
if ((args[0].compareTo("-?") == 0)
--- a/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/Plotter.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/Plotter.java Wed Jul 05 20:11:52 2017 +0200
@@ -838,7 +838,7 @@
private static class TimeStamps {
// Time stamps (long) are split into offsets (long) and a
// series of times from the offsets (int). A new offset is
- // stored when the the time value doesn't fit in an int
+ // stored when the time value doesn't fit in an int
// (approx every 24 days). An array of indices is used to
// define the starting point for each offset in the times
// array.
--- a/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XObject.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XObject.java Wed Jul 05 20:11:52 2017 +0200
@@ -65,7 +65,7 @@
return object;
}
- //if true the the object.hashcode is added to the label
+ //if true the object.hashcode is added to the label
public static void
useHashCodeRepresentation(boolean useHashCodeRepresentation) {
XObject.useHashCodeRepresentation = useHashCodeRepresentation;
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java Wed Jul 05 20:11:52 2017 +0200
@@ -225,7 +225,7 @@
* file contains a provider configuration file named
* <tt>com.sun.jdi.connect.spi.TransportService</tt> in the resource
* directory <tt>META-INF/services</tt>, and the provider
- * configuration file lists the the full-qualified class name of the
+ * configuration file lists the full-qualified class name of the
* TransportService implementation. A TransportService is a concrete
* sub-class of {@link com.sun.jdi.connect.spi.TransportService
* TransportService}. The format of the provider configuration file
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/AttachingConnector.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/AttachingConnector.java Wed Jul 05 20:11:52 2017 +0200
@@ -38,7 +38,7 @@
@jdk.Exported
public interface AttachingConnector extends Connector {
/**
- * Attaches to a running application and and returns a
+ * Attaches to a running application and returns a
* mirror of its VM.
* <p>
* The connector uses the given argument map in
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -238,7 +238,7 @@
}
public void stop(ObjectReference throwable) throws InvalidTypeException {
- validateMirror(throwable);
+ validateMirrorOrNull(throwable);
// Verify that the given object is a Throwable instance
List<ReferenceType> list = vm.classesByName("java.lang.Throwable");
ClassTypeImpl throwableClass = (ClassTypeImpl)list.get(0);
@@ -613,7 +613,7 @@
}
/**
- * Propagate the the thread state change information
+ * Propagate the thread state change information
* to registered listeners.
* Must be entered while synchronized on vm.state()
*/
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -1250,7 +1250,7 @@
Long key = id;
/*
- * Attempt to retrieve an existing object object reference
+ * Attempt to retrieve an existing object reference
*/
SoftObjectReference ref = objectsByID.get(key);
if (ref != null) {
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/eventHandler.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/eventHandler.c Wed Jul 05 20:11:52 2017 +0200
@@ -438,7 +438,7 @@
do {
/* The events have been reported and this
* thread is about to continue, but it may
- * have been started up up just to perform a
+ * have been started up just to perform a
* requested method invocation. If so, we do
* the invoke now and then stop again waiting
* for another continue. By then another
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/BufferedMonitoredVm.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/BufferedMonitoredVm.java Wed Jul 05 20:11:52 2017 +0200
@@ -47,7 +47,7 @@
byte[] getBytes();
/**
- * Interface to get the the size of the instrumentation buffer
+ * Interface to get the size of the instrumentation buffer
* for the target Java Virtual Machine.
*
* @return int - the size of the instrumentation buffer for the
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/HostIdentifier.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/HostIdentifier.java Wed Jul 05 20:11:52 2017 +0200
@@ -227,7 +227,7 @@
*
* The necessary components of the VmIdentifier are extracted and
* reassembled into a HostIdentifier. If a "file:" scheme (protocol)
- * is specified, the the returned HostIdentifier will always be
+ * is specified, the returned HostIdentifier will always be
* equivalent to HostIdentifier("file://localhost").
*
* @param vmid the VmIdentifier use to construct the HostIdentifier.
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVm.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVm.java Wed Jul 05 20:11:52 2017 +0200
@@ -59,7 +59,7 @@
*
* @param name the name of the Instrumentation object to find.
* @return Monitor - the {@link Monitor} object that can be used to
- * monitor the the named instrumentation object, or
+ * monitor the named instrumentation object, or
* <tt>null</tt> if the named object doesn't exist.
* @throws MonitorException Thrown if an error occurs while communicating
* with the target Java Virtual Machine.
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVmUtil.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVmUtil.java Wed Jul 05 20:11:52 2017 +0200
@@ -58,7 +58,7 @@
*
* @param vm the target MonitoredVm
* @return String - contains the command line of the target Java
- * application or the the string "Unknown" if the
+ * application or the string "Unknown" if the
* command line cannot be determined.
*/
public static String commandLine(MonitoredVm vm) throws MonitorException {
@@ -73,7 +73,7 @@
*
* @param vm the target MonitoredVm
* @return String - contains the arguments to the main class for the
- * target Java application or the the string "Unknown"
+ * target Java application or the string "Unknown"
* if the command line cannot be determined.
*/
public static String mainArgs(MonitoredVm vm) throws MonitorException {
@@ -97,7 +97,7 @@
* @param vm the target MonitoredVm
* @param fullPath include the full path to Jar file, where applicable
* @return String - contains the main class of the target Java
- * application or the the string "Unknown" if the
+ * application or the string "Unknown" if the
* command line cannot be determined.
*/
public static String mainClass(MonitoredVm vm, boolean fullPath)
@@ -138,7 +138,7 @@
*
* @param vm the target MonitoredVm
* @return String - contains the arguments passed to the JVM for the
- * target Java application or the the string "Unknown"
+ * target Java application or the string "Unknown"
* if the command line cannot be determined.
*/
public static String jvmArgs(MonitoredVm vm) throws MonitorException {
@@ -151,7 +151,7 @@
*
* @param vm the target MonitoredVm
* @return String - contains the flags passed to the JVM for the
- * target Java application or the the string "Unknown"
+ * target Java application or the string "Unknown"
* if the command line cannot be determined.
*/
public static String jvmFlags(MonitoredVm vm) throws MonitorException {
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/remote/RemoteVm.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/remote/RemoteVm.java Wed Jul 05 20:11:52 2017 +0200
@@ -49,7 +49,7 @@
byte[] getBytes() throws RemoteException;
/**
- * Interface to get the the size of the instrumentation buffer
+ * Interface to get the size of the instrumentation buffer
* for the target Java Virtual Machine.
*
* @return int - the size of the instrumentation buffer for the
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java Wed Jul 05 20:11:52 2017 +0200
@@ -91,7 +91,7 @@
*
* @param name the name of the Instrumentation object to find.
* @return Monitor - the {@link Monitor} object that can be used to
- * monitor the the named instrumentation object, or
+ * monitor the named instrumentation object, or
* <tt>null</tt> if the named object doesn't exist.
* @throws MonitorException Thrown if an error occurs while communicating
* with the target Java Virtual Machine.
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfDataBufferImpl.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfDataBufferImpl.java Wed Jul 05 20:11:52 2017 +0200
@@ -229,7 +229,7 @@
*
* @param name the name of the Instrumentation object to find.
* @return Monitor - the {@link Monitor} object that can be used to
- * monitor the the named instrumentation object, or
+ * monitor the named instrumentation object, or
* <tt>null</tt> if the named object doesn't exist.
* @throws MonitorException Thrown if an error occurs while communicating
* with the target Java Virtual Machine.
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfIntegerMonitor.java Wed Jul 05 20:11:52 2017 +0200
@@ -63,7 +63,7 @@
* The object returned contains an Integer object containing the
* current value of the IntegerInstrument.
*
- * @return Object - the current value of the the IntegerInstrument. The
+ * @return Object - the current value of the IntegerInstrument. The
* return type is guaranteed to be of type Integer.
*/
public Object getValue() {
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java Wed Jul 05 20:11:52 2017 +0200
@@ -62,7 +62,7 @@
* The object returned contains a Long object containing the
* current value of the LongInstrument.
*
- * @return Object - the current value of the the LongInstrument. The
+ * @return Object - the current value of the LongInstrument. The
* return type is guaranteed to be of type Long.
*/
public Object getValue() {
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java Wed Jul 05 20:11:52 2017 +0200
@@ -429,7 +429,7 @@
/*
* replace the real counters with pseudo counters that are
- * initialized to to the correct values. The maximum size of
+ * initialized to the correct values. The maximum size of
* the eden and survivor spaces are supposed to be:
* max_eden_size = new_size - (2*alignment).
* max_survivor_size = new_size - (2*alignment).
--- a/jdk/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/ResourceRecord.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/ResourceRecord.java Wed Jul 05 20:11:52 2017 +0200
@@ -103,7 +103,7 @@
int rrlen; // number of octets in encoded RR
DnsName name; // name field of RR, including root label
int rrtype; // type field of RR
- String rrtypeName; // name of of rrtype
+ String rrtypeName; // name of rrtype
int rrclass; // class field of RR
String rrclassName; // name of rrclass
int ttl = 0; // ttl field of RR
--- a/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java Wed Jul 05 20:11:52 2017 +0200
@@ -353,7 +353,6 @@
/**
* Wrap a RemoteException inside a NamingException.
*/
- @SuppressWarnings("deprecation")
public static NamingException wrapRemoteException(RemoteException re) {
NamingException ne;
@@ -365,8 +364,7 @@
ne = new NoPermissionException();
} else if (re instanceof StubNotFoundException ||
- re instanceof UnknownHostException ||
- re instanceof SocketSecurityException) {
+ re instanceof UnknownHostException) {
ne = new ConfigurationException();
} else if (re instanceof ExportException ||
@@ -414,11 +412,10 @@
* Attempts to install a security manager if none is currently in
* place.
*/
- @SuppressWarnings("deprecation")
private static void installSecurityMgr() {
try {
- System.setSecurityManager(new RMISecurityManager());
+ System.setSecurityManager(new SecurityManager());
} catch (Exception e) {
}
}
--- a/jdk/src/jdk.rmic/share/classes/sun/tools/java/ClassDefinition.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.rmic/share/classes/sun/tools/java/ClassDefinition.java Wed Jul 05 20:11:52 2017 +0200
@@ -295,7 +295,7 @@
}
/**
- * Tell if the class is local or or anonymous class, or inside
+ * Tell if the class is local or anonymous class, or inside
* such a class, which means it cannot be mentioned outside of
* its file.
*/
@@ -770,7 +770,7 @@
}
/**
- * We know the the field is marked protected (and not public) and that
+ * We know the field is marked protected (and not public) and that
* the field is visible (as per canAccess). Can we access the field as
* <accessor>.<field>, where <accessor> has the type <accessorType>?
*
--- a/jdk/src/jdk.sctp/share/classes/com/sun/nio/sctp/SctpMultiChannel.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.sctp/share/classes/com/sun/nio/sctp/SctpMultiChannel.java Wed Jul 05 20:11:52 2017 +0200
@@ -219,7 +219,7 @@
* bind the socket to an automatically assigned socket address
*
* @param backlog
- * The maximum number number of pending connections
+ * The maximum number of pending connections
*
* @return This channel
*
@@ -706,7 +706,7 @@
*
* @throws SecurityException
* If a security manager has been installed and it does not permit
- * new associations to be setup with the the messages's address
+ * new associations to be setup with the messages's address
*
* @throws IOException
* If some other I/O error occurs
--- a/jdk/src/jdk.sctp/share/classes/com/sun/nio/sctp/SctpServerChannel.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.sctp/share/classes/com/sun/nio/sctp/SctpServerChannel.java Wed Jul 05 20:11:52 2017 +0200
@@ -214,7 +214,7 @@
* bind the socket to an automatically assigned socket address
*
* @param backlog
- * The maximum number number of pending associations
+ * The maximum number of pending associations
*
* @return This channel
*
--- a/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c Wed Jul 05 20:11:52 2017 +0200
@@ -507,7 +507,7 @@
if (handleNotification(env, fd, resultContainerObj, snp, rv,
(msg->msg_flags & MSG_EOR),
(struct sockaddr*)&sa ) == JNI_TRUE) {
- /* We have received a notification that is of interest to
+ /* We have received a notification that is of interest
to the Java API. The appropriate notification will be
set in the result container. */
if (allocated == JNI_TRUE) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -117,7 +117,7 @@
* @param o Object to be compared for equality with this
* <code>NTDomainPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>NTDomainPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java Wed Jul 05 20:11:52 2017 +0200
@@ -88,7 +88,7 @@
* @param o Object to be compared for equality with this
* <code>NTNumericCredential</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>NTNumericCredential</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -91,7 +91,7 @@
* @param o Object to be compared for equality with this
* <code>NTSidDomainPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>NTSidDomainPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -86,7 +86,7 @@
* @param o Object to be compared for equality with this
* <code>NTSidGroupPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>NTSidGroupPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -89,7 +89,7 @@
* @param o Object to be compared for equality with this
* <code>NTSidPrimaryGroupPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>NTSidPrimaryGroupPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -85,7 +85,7 @@
* @param o Object to be compared for equality with this
* <code>NTSidUserPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>NTSidUserPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -111,7 +111,7 @@
* @param o Object to be compared for equality with this
* <code>NTPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>NTPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -184,7 +184,7 @@
* @param o Object to be compared for equality with this
* <code>SolarisNumericGroupPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>SolarisNumericGroupPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -151,7 +151,7 @@
* @param o Object to be compared for equality with this
* <code>SolarisNumericUserPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>SolarisNumericUserPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -115,7 +115,7 @@
* @param o Object to be compared for equality with this
* <code>SolarisPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>SolarisPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -187,7 +187,7 @@
* @param o Object to be compared for equality with this
* <code>UnixNumericGroupPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>UnixNumericGroupPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -147,7 +147,7 @@
* @param o Object to be compared for equality with this
* <code>UnixNumericUserPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>UnixNumericUserPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java Wed Jul 05 20:11:52 2017 +0200
@@ -112,7 +112,7 @@
* @param o Object to be compared for equality with this
* <code>UnixPrincipal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>UnixPrincipal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java Wed Jul 05 20:11:52 2017 +0200
@@ -130,7 +130,7 @@
* @param o Object to be compared for equality with this
* <code>X500Principal</code>.
*
- * @return true if the specified Object is equal equal to this
+ * @return true if the specified Object is equal to this
* <code>X500Principal</code>.
*/
public boolean equals(Object o) {
--- a/jdk/src/sample/share/nio/server/ChannelIOSecure.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/sample/share/nio/server/ChannelIOSecure.java Wed Jul 05 20:11:52 2017 +0200
@@ -576,7 +576,7 @@
/*
* We ignore the return value here, we return the
- * number of bytes actually consumed from the the file.
+ * number of bytes actually consumed from the file.
* We'll flush the output buffer before we start shutting down.
*/
doWrite(fileChannelBB);
--- a/jdk/src/sample/solaris/dtrace/hotspot/gc_time_stat.d Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/src/sample/solaris/dtrace/hotspot/gc_time_stat.d Wed Jul 05 20:11:52 2017 +0200
@@ -111,8 +111,8 @@
* arg4: uintptr_t, the initial size of the memory pool (in bytes)
* arg5: uintptr_t, the amount of memory in use in the memory pool
* (in bytes)
- * arg6: uintptr_t, the the number of committed pages in the memory pool
- * arg7: uintptr_t, the the maximum size of the memory pool
+ * arg6: uintptr_t, the number of committed pages in the memory pool
+ * arg7: uintptr_t, the maximum size of the memory pool
*/
hotspot$target:::mem-pool-gc-begin
{
--- a/jdk/test/ProblemList.txt Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/ProblemList.txt Wed Jul 05 20:11:52 2017 +0200
@@ -135,10 +135,6 @@
# jdk_management
-# 8044591
-com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java generic-all
-com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java generic-all
-
# 8058492
java/lang/management/ThreadMXBean/FindDeadlocks.java generic-all
@@ -303,25 +299,6 @@
# jdk_util
-# 8051641
-sun/util/calendar/zi/TestZoneInfo310.java generic-all
-
-# 8062588
-java/util/Locale/LocaleProviders.sh generic-all
-java/util/PluggableLocale/BreakIteratorProviderTest.sh generic-all
-java/util/PluggableLocale/CalendarDataProviderTest.sh generic-all
-java/util/PluggableLocale/CalendarNameProviderTest.sh generic-all
-java/util/PluggableLocale/CollatorProviderTest.sh generic-all
-java/util/PluggableLocale/CurrencyNameProviderTest.sh generic-all
-java/util/PluggableLocale/DateFormatProviderTest.sh generic-all
-java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh generic-all
-java/util/PluggableLocale/DecimalFormatSymbolsProviderTest.sh generic-all
-java/util/PluggableLocale/GenericTest.sh generic-all
-java/util/PluggableLocale/LocaleNameProviderTest.sh generic-all
-java/util/PluggableLocale/NumberFormatProviderTest.sh generic-all
-java/util/PluggableLocale/TimeZoneNameProviderTest.sh generic-all
-java/util/ResourceBundle/Bug6299235Test.sh generic-all
-
# 8062512
java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java generic-all
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/SameDHKeyStressTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1999, 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 8048819
+ * @summary This test stressful verifies the assertion of "The secret keys generated
+ * by all involved parties should be the same." for javax.crypto.KeyAgreement
+ * @run main SameDHKeyStressTest
+ */
+import java.security.AlgorithmParameterGenerator;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Arrays;
+import javax.crypto.KeyAgreement;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.DHGenParameterSpec;
+import javax.crypto.spec.DHParameterSpec;
+
+public class SameDHKeyStressTest {
+
+ static final String[] ALGORITHMS = {"DH", "DiffieHellman", "dh", "diffieHELLMAN"};
+ static final String[] SECRET_ALOGRITHMS = {"DES", "DESede", "blowfish"};
+ static final int[] NUMBER_OF_PARTIES = {2, 3, 4};
+ static final String[] PA_NAMES = {"Alice", "Bob", "Carol", "David"};
+
+ public static void main(String args[]) {
+ int failedCnt = 0;
+ StringBuilder failedList = new StringBuilder("Failed List:");
+
+ for (String algorithm : ALGORITHMS) {
+ for (int numOfParties : NUMBER_OF_PARTIES) {
+ for (String secretAlgorithm : SECRET_ALOGRITHMS) {
+ if (!runTest(algorithm, numOfParties, secretAlgorithm)) {
+ failedCnt++;
+ failedList.append("\n Altorightm = ").append(algorithm).
+ append(" Number of Parties = ").append(numOfParties).
+ append(" Secret Algorithm = ").append(secretAlgorithm);
+ }
+ }
+ }
+ } //end of for loop
+
+ if (failedCnt > 0) {
+ System.out.println(failedList);
+ throw new RuntimeException("SameDHKeyStressTest Failed");
+ }
+ }
+
+ public static boolean runTest(String algo, int numParties, String secretAlgo) {
+ KAParticipant[] parties = new KAParticipant[numParties];
+ Key[] keyArchives = new Key[numParties];
+ try {
+ // generate AlogirhtmParameterSpec
+ AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE");
+ AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64);
+ apg.init(aps);
+ DHParameterSpec spec = apg.generateParameters().
+ getParameterSpec(DHParameterSpec.class);
+
+ //initilize all KeyAgreement participants
+ for (int i = 0; i < numParties; i++) {
+ parties[i] = new KAParticipant(PA_NAMES[i], algo);
+ parties[i].initialize(spec);
+ keyArchives[i] = parties[i].getPublicKey();
+ }
+
+ // Do all phases in the KeyAgreement for all participants
+ Key[] keyBuffer = new Key[numParties];
+ boolean lastPhase = false;
+ for (int j = 0; j < numParties - 1; j++) {
+ if (j == numParties - 2) {
+ lastPhase = true;
+ }
+ for (int k = 0; k < numParties; k++) {
+ if (k == numParties - 1) {
+ keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase);
+ } else {
+ keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase);
+ }
+ }
+ System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties);
+ }
+
+ //Comparison: The secret keys generated by all involved parties should be the same
+ SecretKey[] sKeys = new SecretKey[numParties];
+ for (int n = 0; n < numParties; n++) {
+ sKeys[n] = parties[n].generateSecret(secretAlgo);
+ }
+ for (int q = 0; q < numParties - 1; q++) {
+ if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) {
+ return false;
+ }
+ }
+ return true;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ }
+
+}
+
+class KAParticipant {
+
+ private String name = null;
+ private String algorithm = null;
+ private KeyPairGenerator keyGen = null;
+ private KeyPair keys = null;
+ private KeyAgreement ka = null;
+
+ public KAParticipant(String pName, String algo) throws NoSuchAlgorithmException, NoSuchProviderException {
+ name = pName;
+ algorithm = algo;
+ keyGen = KeyPairGenerator.getInstance(algo,"SunJCE");
+ ka = KeyAgreement.getInstance(algo,"SunJCE");
+ }
+
+ public void initialize(AlgorithmParameterSpec spec) throws InvalidAlgorithmParameterException, InvalidKeyException {
+ keyGen.initialize(spec);
+ keys = keyGen.generateKeyPair();
+ ka.init(keys.getPrivate());
+ }
+
+ public Key doPhase(Key key, boolean lastPhase) throws InvalidKeyException {
+ return ka.doPhase(key, lastPhase);
+ }
+
+ public Key getPublicKey() {
+ return keys.getPublic();
+ }
+
+ public byte[] generateSecret() {
+ return ka.generateSecret();
+ }
+
+ public SecretKey generateSecret(String algo) throws java.lang.IllegalStateException,
+ java.security.NoSuchAlgorithmException,
+ java.security.InvalidKeyException {
+ return ka.generateSecret(algo);
+ }
+}
--- a/jdk/test/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,6 +26,7 @@
* @bug 7036199
* @summary Check that GarbageCollectionNotification contents are reasonable
* @author Frederic Parain
+ * @requires vm.opt.ExplicitGCInvokesConcurrent == null | vm.opt.ExplicitGCInvokesConcurrent == false
* @run main/othervm GarbageCollectionNotificationContentTest
*/
--- a/jdk/test/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,6 +26,7 @@
* @bug 7036199
* @summary Check that GarbageCollection notification are thrown by every GarbageCollectorMXBean
* @author Frederic Parain
+ * @requires vm.opt.ExplicitGCInvokesConcurrent == null | vm.opt.ExplicitGCInvokesConcurrent == false
* @run main/othervm GarbageCollectionNotificationTest
*/
--- a/jdk/test/com/sun/tools/attach/StartManagementAgent.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/com/sun/tools/attach/StartManagementAgent.java Wed Jul 05 20:11:52 2017 +0200
@@ -41,7 +41,7 @@
* @summary Test for VirtualMachine.startManagementAgent and VirtualMachine.startLocalManagementAgent
* @library /lib/testlibrary
* @run build Application SimpleProvider jdk.testlibrary.*
- * @run main StartManagementAgent
+ * @run main/timeout=300 StartManagementAgent
*/
/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/DragMouseOutAndRelease/DragMouseOutAndRelease.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,421 @@
+/*
+ * 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
+ * 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 6322625
+ @summary REG:Choice does not trigger MouseReleased when dragging and releasing the mouse outside choice, XAWT
+ @author andrei.dmitriev area=awt.choice
+ @run main DragMouseOutAndRelease
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class DragMouseOutAndRelease
+{
+ static Frame frame = new Frame("Test Frame");
+ static Choice choice1 = new Choice();
+ static Robot robot;
+ static Point pt;
+ static volatile boolean mousePressed = false;
+ static volatile boolean mouseReleased = false;
+
+ private static void init()
+ {
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ frame.setLayout (new FlowLayout ());
+ for (int i = 1; i<10;i++){
+ choice1.add("item "+i);
+ }
+ frame.add(choice1);
+
+ choice1.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent me) {
+ mousePressed = true;
+ System.out.println(me);
+ }
+ public void mouseReleased(MouseEvent me) {
+ mouseReleased = true;
+ System.out.println(me);
+ }
+ });
+
+ frame.pack();
+ frame.setVisible(true);
+ frame.validate();
+
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
+ testMouseDrag();
+ } catch (Throwable e) {
+ new RuntimeException("Test failed. Exception thrown: "+e);
+ }
+ DragMouseOutAndRelease.pass();
+ }//End init()
+
+ public static void testMouseDrag(){
+ mousePressed = false;
+ mouseReleased = false;
+
+ pt = choice1.getLocationOnScreen();
+ robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + choice1.getHeight()/2);
+ robot.waitForIdle();
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+
+ //move mouse outside Choice
+ robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y - choice1.getHeight());
+ robot.waitForIdle();
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ if (!mousePressed || !mouseReleased)
+ {
+ System.out.println("ERROR: "+ mousePressed+","+mouseReleased);
+ // close the choice
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ robot.waitForIdle();
+ DragMouseOutAndRelease.fail("Test failed. Choice should generate PRESSED, RELEASED events outside if pressed on Choice ");
+ } else{
+ // close the choice
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ robot.waitForIdle();
+ System.out.println("Choice did generated PRESSED and RELEASED after Drag outside the Choice ");
+ }
+ }
+
+
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main( String args[] ) throws InterruptedException
+ {
+ mainThread = Thread.currentThread();
+ try
+ {
+ init();
+ }
+ catch( TestPassedException e )
+ {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try
+ {
+ Thread.sleep( sleepTime );
+ //Timed out, so fail the test
+ throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ }
+ catch (InterruptedException e)
+ {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if( ! testGeneratedInterrupt ) throw e;
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if ( theTestPassed == false )
+ {
+ throw new RuntimeException( failureMessage );
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo( int seconds )
+ {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass()
+ {
+ Sysout.println( "The test passed." );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //first check if this is executing in main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail()
+ {
+ //test writer didn't specify why test failed, so give generic
+ fail( "it just plain failed! :-)" );
+ }
+
+ public static synchronized void fail( String whyFailed )
+ {
+ Sysout.println( "The test failed: " + whyFailed );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //check if this called from main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException( whyFailed );
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }//fail()
+
+}// class DragMouseOutAndRelease
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// if want to make listeners, here is the recommended place for them, then instantiate
+// them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+ static int newVar = 0;
+
+ public void eventDispatched(AWTEvent e)
+ {
+ //Counting events to see if we get enough
+ eventCount++;
+
+ if( eventCount == 20 )
+ {
+ //got enough events, so pass
+
+ DragMouseOutAndRelease.pass();
+ }
+ else if( tries == 20 )
+ {
+ //tried too many times without getting enough events so fail
+
+ DragMouseOutAndRelease.fail();
+ }
+
+ }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ System.out.println(messageIn);
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/GetSizeTest/GetSizeTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 1999, 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 4255631
+ @summary Solaris: Size returned by Choice.getSize() does not match actual size
+ @author Andrei Dmitriev : area=Choice
+ run main GetSizeTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class GetSizeTest {
+
+ static String []s = {"Choice 1",
+ "Choice 2",
+ "unselected choices",
+ "what choices do I have?",
+ "Will I pick the same thing in the future?",
+ };
+ static boolean passed = false;
+ static Robot robot = null;
+
+ public static void main(String args[])
+ {
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(50);
+
+ Frame f = new Frame("choice test");
+
+ Panel p = new Panel();
+ p.setLayout(null);
+
+ Choice c = new Choice();
+ for (int i = 0; i < s.length; i++)
+ c.addItem(s[i]);
+
+ c.addMouseListener(new MouseAdapter() {
+ public void mouseReleased(MouseEvent e) {
+ System.err.println("Test passed");
+ passed = true;
+ }
+ });
+
+ p.add(c);
+
+ f.add(p);
+
+ f.setSize(300, 300);
+
+ f.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent we) {
+ System.err.println("Test passed");
+ passed = true;
+ }
+ });
+
+ f.setVisible(true);
+
+ c.setSize(200, 200);
+ f.validate();
+
+ robot.waitForIdle();
+
+ Point pt = c.getLocationOnScreen();
+ robot.mouseMove(pt.x + c.getWidth() - 10, pt.y + c.getHeight() / 2);
+ robot.waitForIdle();
+ robot.mousePress(InputEvent.BUTTON2_MASK);
+ robot.mouseRelease(InputEvent.BUTTON2_MASK);
+ robot.waitForIdle();
+ } catch (Throwable e) {
+ if (robot == null){
+ throw new RuntimeException( "Test failed.Unable to initialize Robot "+e);
+ }
+ throw new RuntimeException( "Test failed due to thrown exception "+e);
+ }
+ if (!passed) {
+ throw new RuntimeException( "Timeout. Choice component size is not actual size." );
+ }
+ System.err.println("Test passed.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/GrabLockTest/GrabLockTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2003, 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 4800638
+ @summary Tests that Choice does not lock the Desktop
+ @run main GrabLockTest
+*/
+import java.awt.*;
+import java.awt.event.*;
+
+public class GrabLockTest
+{
+ public static void main (String args[])
+ {
+ Frame frame = new TestFrame();
+ }
+}
+
+class TestFrame extends Frame implements MouseListener {
+ public TestFrame() {
+ Choice choice = new Choice();
+ choice.addItem("Fist Item");
+ choice.addItem("Second Item");
+ add(choice,BorderLayout.NORTH);
+ Panel panel = new Panel();
+ panel.addMouseListener(this);
+ panel.setBackground(Color.RED);
+ add(panel);
+ setSize(200, 200);
+ setVisible(true);
+ toFront();
+
+ try {
+ Robot robot = new Robot();
+ robot.setAutoWaitForIdle(true);
+ robot.setAutoDelay(50);
+
+ robot.waitForIdle();
+
+ Point pt = choice.getLocationOnScreen();
+ robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight()/2,
+ pt.y + choice.getHeight()/2);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ robot.mouseMove(pt.x + choice.getWidth()/2,
+ pt.y + choice.getHeight()*2);
+ robot.waitForIdle();
+ robot.mousePress(InputEvent.BUTTON2_MASK);
+ robot.waitForIdle();
+ Point pt1 = panel.getLocationOnScreen();
+ robot.mouseMove(pt1.x + panel.getWidth()/2,
+ pt1.y + panel.getHeight()/2);
+ robot.waitForIdle();
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON2_MASK);
+
+ robot.waitForIdle();
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(30);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ if (nPressed == 0) {
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ throw new RuntimeException("GrabLockTest failed." + nPressed);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("The test was not completed.\n\n" + e);
+ }
+
+ }
+
+ public int nPressed = 0;
+
+ public void mouseClicked(MouseEvent e) {
+ }
+
+ public void mousePressed(MouseEvent e) {
+ nPressed++;
+ System.out.println("Pressed!");
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ public void mouseEntered(MouseEvent e) {}
+ public void mouseExited(MouseEvent e) {}
+}// class TestFrame
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/PopupPosTest/PopupPosTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 5044150
+ @summary Tests that pupup doesn't popdown if no space to display under
+ @author ssi@sparc.spb.su
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run applet PopupPosTest.html
+ -->
+<head>
+<title> PopupPosTest </title>
+</head>
+<body>
+
+<h1>PopupPosTest<br>Bug ID: 5044150</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="PopupPosTest.class" WIDTH=350 HEIGHT=400></APPLET>
+</body>
+</html>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/PopupPosTest/PopupPosTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,150 @@
+/*
+ * 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
+ * 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 5044150
+ @summary Tests that pupup doesn't popdown if no space to display under
+ @author andrei.dmitriev area=awt.choice
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run applet PopupPosTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+import jdk.testlibrary.OSInfo;
+
+public class PopupPosTest extends Applet
+{
+ public void start ()
+ {
+ if(OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+ // On OS X, popup isn't under the mouse
+ return;
+ }
+ Frame frame = new TestFrame();
+ }
+}
+
+class TestFrame extends Frame implements ItemListener {
+ Robot robot;
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ Choice choice = new Choice();
+ boolean indexChanged = false;
+ final static int INITIAL_ITEM = 99;
+ volatile boolean stateChanged;
+
+ public TestFrame() {
+ for (int i = 0; i < 100; i++) {
+ choice.addItem("Item Item Item " + i);
+ }
+ choice.addItemListener(this);
+
+ choice.select(INITIAL_ITEM);
+ choice.setFont(new Font("Courier", Font.BOLD + Font.ITALIC, 100));
+
+ add(choice, BorderLayout.CENTER);
+ Dimension screen = tk.getScreenSize();
+ setSize(screen.width - 10, screen.height - 70);
+ setVisible(true);
+ toFront();
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
+ // fix for 6175418. When we take "choice.getHeight()/2"
+ // divider 2 is not sufficiently big to hit into the
+ // small box Choice. We should use bigger divider to get
+ // smaller value choice.getHeight()/i. 4 is sufficient.
+ Point pt = choice.getLocationOnScreen();
+ // click on 1/4 of Choice's height
+ mouseMoveAndPressOnChoice(pt.x + choice.getWidth()/2,
+ pt.y + choice.getHeight()/4);
+
+ // click on center of Choice's height
+ mouseMoveAndPressOnChoice(pt.x + choice.getWidth()/2,
+ pt.y + choice.getHeight()/2);
+
+ // click on 3/4 of Choice's height
+ mouseMoveAndPressOnChoice(pt.x + choice.getWidth()/2,
+ pt.y + choice.getHeight()*3/4);
+ // testing that ItemEvent doesn't generated on a simple
+ // mouse click when the dropdown appears under mouse : 6425067
+ stateChanged = false;
+ openChoice();
+ closeChoice();
+ } catch (Throwable e) {
+ throw new RuntimeException("The test was not completed.\n\n" + e);
+ }
+
+ if (!indexChanged){
+ throw new RuntimeException("Test failed. Another item wasn't selected.");
+ }
+
+ if(stateChanged){
+ throw new RuntimeException("Test failed. ItemEvent was generated on a simple mouse click when the dropdown appears under mouse");
+ }
+ }// start()
+
+ public void itemStateChanged(ItemEvent ie) {
+ System.out.println("choice.stateChanged = "+ ie);
+ stateChanged = true;
+ }
+
+ public void mouseMoveAndPressOnChoice(int x, int y){
+ openChoice();
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(30);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ //should close choice after each test stage
+ closeChoice();
+ checkSelectedIndex();
+ }
+
+ public void openChoice(){
+ Point pt = choice.getLocationOnScreen();
+ robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight()/4,
+ pt.y + choice.getHeight()/2);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(30);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ }
+ public void closeChoice(){
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ robot.waitForIdle();
+ }
+
+ public void checkSelectedIndex(){
+ if (choice.getSelectedIndex() != INITIAL_ITEM) {
+ System.out.println("choice.getSelectedIndex = "+ choice.getSelectedIndex());
+ indexChanged = true;
+ }
+ }
+}// class TestFrame
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/ResizeAutoClosesChoice/ResizeAutoClosesChoice.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,113 @@
+/*
+ * 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
+ * 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 6399679
+ @summary Choice is not invalidated when the frame gets resized programmatically when the drop-down is visible
+ @author andrei.dmitriev area=awt.choice
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run main ResizeAutoClosesChoice
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+import jdk.testlibrary.OSInfo;
+
+public class ResizeAutoClosesChoice
+{
+ static Frame frame = new Frame("Test Frame");
+ static Choice choice1 = new Choice();
+ static Robot robot;
+ static Point pt;
+ static String passed = null;
+ static Button button = new Button("This button causes Frame to be resized on pack()");
+ public static void main(String args[]) throws Exception
+ {
+ if(OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+ System.out.println("Not for OS OX");
+ return;
+ }
+
+ choice1.setForeground(Color.red);
+ choice1.setBackground(Color.red);
+
+ frame.setLayout (new BorderLayout ());
+ for (int i = 1; i<10;i++){
+ choice1.add("item "+i);
+ }
+ frame.setSize(300, 300);
+ choice1.setLocation(50, 50);
+ choice1.setSize(70, 20);
+
+ button.setLocation(150, 100);
+ button.setSize(150, 20);
+ frame.add(choice1, BorderLayout.SOUTH);
+ frame.pack();
+
+ frame.validate();
+ frame.setVisible(true);
+
+ robot = new Robot();
+ robot.waitForIdle();
+ pt = choice1.getLocationOnScreen();
+ robot.mouseMove(pt.x + choice1.getWidth()/10*9, pt.y + choice1.getHeight()/2);
+ robot.waitForIdle();
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(1000);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ Color color = robot.getPixelColor(pt.x + choice1.getWidth()/2,
+ pt.y + 3 * choice1.getHeight());
+ //should take a color on the point on the choice's menu
+ System.out.println("Choice opened. Color got : "+color);
+ if ( !color.equals(Color.red) ){
+ passed = "Choice wasn't opened with the mouse";
+ }
+
+ Rectangle oldBounds = choice1.getBounds();
+ System.out.println("Choice's old bounds : "+oldBounds);
+
+ frame.add(button, BorderLayout.NORTH);
+ // frame.setSize(500, 500);
+ frame.pack();
+ robot.waitForIdle();
+ System.out.println("Choice's new bounds : "+choice1.getBounds());
+
+ if (!choice1.getBounds().equals(oldBounds)){
+ pt = choice1.getLocationOnScreen();
+ color = robot.getPixelColor(pt.x + choice1.getWidth()/2,
+ pt.y + 3 * choice1.getHeight());
+ System.out.println("Choice opened. Color got : "+color);
+ if (color.equals(Color.red) ){
+ passed = "Choice wasn't closed when toplevel repacked.";
+ }
+ } else {
+ System.out.println("frame.pack didn't changed Choice's size - dropdown menu should remain the same. Test passed.");
+ }
+ if (passed != null){
+ throw new RuntimeException(passed);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,44 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test 1.2 01/02/10
+ @bug 4902933
+ @summary Test that selecting the current item sends an ItemEvent
+ @author bchristi : area= Choice
+ @run applet SelectCurrentItemTest.html
+ -->
+<head>
+<title> </title>
+</head>
+<body>
+
+<h1>SelectCurrentItemTest<br>Bug ID: 9999999 XXX_CHANGE_THIS </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="SelectCurrentItemTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,323 @@
+/*
+ * 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
+ * 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 1.3 02/06/25
+ @bug 4902933
+ @summary Test that selecting the current item sends an ItemEvent
+ @author bchristi : area= Choice
+ @run applet SelectCurrentItemTest.html
+*/
+
+// Note there is no @ in front of test above. This is so that the
+// harness will not mistake this file as a test file. It should
+// only see the html file as a test file. (the harness runs all
+// valid test files, so it would run this test twice if this file
+// were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag. Here, you
+// should put which functional area the test falls in. See the
+// AWT-core home page -> test areas and/or -> AWT team for a list of
+// areas.
+// Note also the 'SelectCurrentItemTest.html' in the run tag. This should
+// be changed to the name of the test.
+
+
+/**
+ * SelectCurrentItemTest.java
+ *
+ * summary:
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+//Automated tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors. (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems). Also, you don't have to worry about
+// synchronisation stuff in Applet tests they way you do in main
+// tests...
+
+
+public class SelectCurrentItemTest extends Applet implements ItemListener,
+ WindowListener, Runnable
+{
+ //Declare things used in the test, like buttons and labels here
+ Frame frame;
+ Choice theChoice;
+ Robot robot;
+
+ Object lock = new Object();
+ boolean passed = false;
+
+ public void init()
+ {
+ //Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+
+ this.setLayout (new BorderLayout ());
+
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test",
+ "simply wait until it is done"
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ frame = new Frame("SelectCurrentItemTest");
+ theChoice = new Choice();
+ for (int i = 0; i < 10; i++) {
+ theChoice.add(new String("Choice Item " + i));
+ }
+ theChoice.addItemListener(this);
+ frame.add(theChoice);
+ frame.addWindowListener(this);
+
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(500);
+ }
+ catch (AWTException e) {
+ throw new RuntimeException("Unable to create Robot. Test fails.");
+ }
+
+ }//End init()
+
+ public void start ()
+ {
+ //Get things going. Request focus, set size, et cetera
+ setSize (200,200);
+ setVisible(true);
+ validate();
+
+ //What would normally go into main() will probably go here.
+ //Use System.out.println for diagnostic messages that you want
+ //to read after the test is done.
+ //Use Sysout.println for messages you want the tester to read.
+
+ frame.setLocation(1,20);
+ robot.mouseMove(10, 30);
+ frame.pack();
+ frame.setVisible(true);
+ synchronized(lock) {
+ try {
+ lock.wait(120000);
+ }
+ catch(InterruptedException e) {}
+ }
+ robot.waitForIdle();
+ if (!passed) {
+ throw new RuntimeException("TEST FAILED!");
+ }
+
+ // wait to make sure ItemEvent has been processed
+
+// try {Thread.sleep(10000);} catch (InterruptedException e){}
+ }// start()
+
+ public void run() {
+ try {Thread.sleep(1000);} catch (InterruptedException e){}
+ // get loc of Choice on screen
+ Point loc = theChoice.getLocationOnScreen();
+ // get bounds of Choice
+ Dimension size = theChoice.getSize();
+ robot.mouseMove(loc.x + size.width - 10, loc.y + size.height / 2);
+
+ robot.setAutoDelay(250);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ robot.setAutoDelay(1000);
+ robot.mouseMove(loc.x + size.width / 2, loc.y + size.height + size.height / 2);
+ robot.setAutoDelay(250);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ synchronized(lock) {
+ lock.notify();
+ }
+ }
+
+ public void itemStateChanged(ItemEvent e) {
+ Sysout.println("ItemEvent received. Test passes");
+ passed = true;
+ }
+
+ public void windowOpened(WindowEvent e) {
+ Sysout.println("windowActivated()");
+ Thread testThread = new Thread(this);
+ testThread.start();
+ }
+ public void windowActivated(WindowEvent e) {
+ }
+ public void windowDeactivated(WindowEvent e) {}
+ public void windowClosed(WindowEvent e) {}
+ public void windowClosing(WindowEvent e) {}
+ public void windowIconified(WindowEvent e) {}
+ public void windowDeiconified(WindowEvent e) {}
+
+}// class SelectCurrentItemTest
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setLocation(0, 400);
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ show();
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Choice/UnfocusableCB_ERR/UnfocusableCB_ERR.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,421 @@
+/*
+ * 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
+ * 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 6390103
+ @summary Non-Focusable choice throws exception when selecting an item, Win32
+ @author andrei.dmitriev area=awt.choice
+ @run main UnfocusableCB_ERR
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class UnfocusableCB_ERR
+{
+ static final int delay = 100;
+ static Frame frame = new Frame("Test Frame");
+ static Choice choice1 = new Choice();
+ static Button button = new Button("Test");
+
+ static Robot robot;
+ static Point pt;
+ static String failed = "";
+
+ private static void init()
+ {
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ Thread.currentThread().setUncaughtExceptionHandler(
+ new Thread.UncaughtExceptionHandler(){
+ public void uncaughtException(Thread t, Throwable exc){
+ failed = exc.toString();
+ }
+ });
+ }
+ });
+
+ frame.setLayout (new FlowLayout ());
+ for (int i = 1; i<10;i++){
+ choice1.add("item "+i);
+ }
+ frame.add(button);
+ frame.add(choice1);
+
+ choice1.setFocusable(false);
+
+ frame.pack();
+ frame.setVisible(true);
+ frame.validate();
+
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
+ testSpacePress();
+ } catch (Throwable e) {
+ UnfocusableCB_ERR.fail("Test failed. Exception thrown: "+e);
+ }
+ if (failed.equals("")){
+ UnfocusableCB_ERR.pass();
+ } else {
+ UnfocusableCB_ERR.fail("Test failed:");
+ }
+ }//End init()
+
+ public static void testSpacePress(){
+
+ pt = choice1.getLocationOnScreen();
+ robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + choice1.getHeight()/2);
+ robot.waitForIdle();
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+
+ robot.waitForIdle();
+
+ //position mouse cursor over dropdown menu
+ robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + 2 * choice1.getHeight());
+ robot.waitForIdle();
+
+ //move mouse outside Choice
+ robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y - choice1.getHeight());
+ robot.waitForIdle();
+
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ robot.waitForIdle();
+ }
+
+
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main( String args[] ) throws InterruptedException
+ {
+ mainThread = Thread.currentThread();
+ try
+ {
+ init();
+ }
+ catch( TestPassedException e )
+ {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try
+ {
+ Thread.sleep( sleepTime );
+ //Timed out, so fail the test
+ throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ }
+ catch (InterruptedException e)
+ {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if( ! testGeneratedInterrupt ) throw e;
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if ( theTestPassed == false )
+ {
+ throw new RuntimeException( failureMessage );
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo( int seconds )
+ {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass()
+ {
+ Sysout.println( "The test passed." );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //first check if this is executing in main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail()
+ {
+ //test writer didn't specify why test failed, so give generic
+ fail( "it just plain failed! :-)" );
+ }
+
+ public static synchronized void fail( String whyFailed )
+ {
+ Sysout.println( "The test failed: " + whyFailed );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //check if this called from main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException( whyFailed );
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }//fail()
+
+}// class UnfocusableCB_ERR
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// if want to make listeners, here is the recommended place for them, then instantiate
+// them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+ static int newVar = 0;
+
+ public void eventDispatched(AWTEvent e)
+ {
+ //Counting events to see if we get enough
+ eventCount++;
+
+ if( eventCount == 20 )
+ {
+ //got enough events, so pass
+
+ UnfocusableCB_ERR.pass();
+ }
+ else if( tries == 20 )
+ {
+ //tried too many times without getting enough events so fail
+
+ UnfocusableCB_ERR.fail();
+ }
+
+ }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ System.out.println(messageIn);
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- a/jdk/test/java/awt/Component/7097771/bug7097771.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Component/7097771/bug7097771.java Wed Jul 05 20:11:52 2017 +0200
@@ -21,14 +21,12 @@
* questions.
*/
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
import java.awt.AWTException;
import java.awt.Button;
import java.awt.Frame;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -53,13 +51,14 @@
button.addActionListener(frame);
frame.add(button);
frame.setVisible(true);
- sleep();
+ Robot robot = new Robot();
+ sleep(robot);
frame.setEnabled(false);
button.setEnabled(false);
button.setEnabled(true);
- sleep();
- Util.clickOnComp(button, new Robot());
- sleep();
+ sleep(robot);
+ Util.clickOnComp(button, robot);
+ sleep(robot);
frame.dispose();
if (action) {
throw new RuntimeException("Button is not disabled.");
@@ -71,8 +70,8 @@
action = true;
}
- private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ private static void sleep(Robot robot) {
+ robot.waitForIdle();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
--- a/jdk/test/java/awt/Component/F10TopToplevel/F10TopToplevel.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Component/F10TopToplevel/F10TopToplevel.java Wed Jul 05 20:11:52 2017 +0200
@@ -90,29 +90,26 @@
Robot robot;
try {
robot = new Robot();
+ robot.setAutoDelay(5);
} catch(AWTException e){
throw new RuntimeException("cannot create robot.", e);
}
- ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
robot.mouseMove(dialog.getLocationOnScreen().x + dialog.getWidth()/2,
dialog.getLocationOnScreen().y + dialog.getHeight()/2 );
- robot.delay(5);
+ robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
- robot.delay(5);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- robot.delay(5);
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_F10);
- robot.delay(5);
robot.keyRelease(KeyEvent.VK_F10);
- robot.delay(5);
robot.delay(10);
robot.keyPress(KeyEvent.VK_ENTER);
- robot.delay(5);
+ robot.waitForIdle();
robot.keyRelease(KeyEvent.VK_ENTER);
- robot.delay(5);
- ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
if(menuToggled) {
throw new RuntimeException("Oops! Menu should not open.");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Component/NativeInLightShow/NativeInLightShow.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,92 @@
+/*
+ * 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
+ * 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 1.0 04/05/20
+ @bug 4140484
+ @summary Heavyweight components inside invisible lightweight containers still show
+ @author Your Name: art@sparc.spb.su
+ @run main NativeInLightShow
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+
+// The test verifies that the mixing code correctly handles COMPONENT_SHOWN events
+// while the top-level container is invisible.
+
+public class NativeInLightShow
+{
+ //Declare things used in the test, like buttons and labels here
+ static boolean buttonPressed = false;
+ public static void main(String args[]) throws Exception {
+ Frame f = new Frame("Test");
+
+ Robot robot = null;
+ robot = new Robot();
+ robot.setAutoDelay(50);
+
+ Container c = new Container();
+ c.setLayout(new BorderLayout());
+ Button b = new Button("I'm should be visible!");
+ b.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("Test PASSED");
+ buttonPressed = true;
+ }
+ });
+ c.add(b);
+
+ f.add(c);
+
+ f.pack();
+
+ c.setVisible(false);
+ c.setVisible(true);
+
+ // Wait for a while for COMPONENT_SHOW event to be dispatched
+ robot.waitForIdle();
+
+ f.setVisible(true);
+
+ robot.waitForIdle();
+
+ Point buttonLocation = b.getLocationOnScreen();
+
+ robot.mouseMove(buttonLocation.x + 5, buttonLocation.y + 5);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ // Wait for a while for ACTION event to be dispatched
+ robot.waitForIdle();
+ robot.delay(100);
+
+ if (!buttonPressed) {
+ System.out.println("Test FAILED");
+ throw new RuntimeException("Button was not pressed");
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/FileDialog/ISCthrownByFileListTest/ISCthrownByFileListTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ *
+ * 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 6304979
+ @summary REG: File Dialog throws ArrayIndexOutOfBounds Exception on XToolkit with b45
+ @author Dmitry Cherepanov: area=awt.filedialog
+ @run main/othervm -Dsun.awt.disableGtkFileDialogs=true ISCthrownByFileListTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.reflect.*;
+
+/*
+ Since the "sun.awt.exception.handler" property will be removed in a future release
+ this test will be rewritten using new future API. (<<< Done).
+ It's important that the bug 6304979 is reproducible if the bug 6299853 is reproducible.
+*/
+
+public class ISCthrownByFileListTest
+{
+ private static Frame frame = null;
+ private static FileDialog fd = null;
+
+ // The handler load the class and instantiate this class
+ // so the 'passed' variable is static
+ static boolean passed = true;
+
+ public static final void main(String args[]) {
+ // It's not true that the native file dialog will be focused on Motif & Windows
+ boolean isXToolkit = Toolkit.getDefaultToolkit().getClass().getName().equals("sun.awt.X11.XToolkit");
+ if (!isXToolkit){
+ return;
+ }
+
+ frame = new Frame("frame");
+ frame.setLayout (new FlowLayout ());
+ frame.setBounds(100, 100, 100, 100);
+ frame.setVisible(true);
+
+ fd = new FileDialog(frame, "file dialog", FileDialog.LOAD);
+
+ // In order to handle all uncaught exceptions in the EDT
+ final Thread.UncaughtExceptionHandler eh = new Thread.UncaughtExceptionHandler()
+ {
+ @Override
+ public void uncaughtException(Thread t, Throwable e)
+ {
+ e.printStackTrace();
+ ISCthrownByFileListTest.passed = false;
+ }
+ };
+
+ test();
+ }// start()
+
+ private static void test (){
+ Robot r;
+
+ try {
+ r = new Robot();
+ } catch(AWTException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+ r.delay(500);
+ new Thread(new Runnable() {
+ public void run() {
+ // The bug 6299853 is reproducible only if the file list is not empty
+ // since else the focus will be set to the directory list.
+ // But the focus index of the directory list equals 0.
+ // So goto the source directory (the file list is non empty)
+ fd.setDirectory(System.getProperty("test.src", "."));
+ fd.setVisible(true);
+ }
+ }).start();
+ r.delay(2000);
+ r.waitForIdle();
+
+ Component focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
+ if (focusedWindow != fd) {
+ throw new RuntimeException("Test failed - the file dialog isn't focused window, owner: " + focusedWindow);
+ }
+ r.waitForIdle();
+
+ r.keyPress(KeyEvent.VK_SPACE);
+ r.delay(50);
+ r.keyRelease(KeyEvent.VK_SPACE);
+ r.delay(1000);
+ fd.setVisible(false);
+ r.delay(1000);
+ r.waitForIdle();
+
+ if (!ISCthrownByFileListTest.passed){
+ throw new RuntimeException("Test failed.");
+ }
+
+ }// test()
+}// class ISCthrownByFileListTest
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6378278/InputVerifierTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,413 @@
+/*
+ * 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
+ * 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 6378278
+ @summary Apparent missing key events causing Bugster to break
+ @author oleg.sukhodolsky: area=awt.focus
+ @run main InputVerifierTest
+*/
+
+/**
+ * InputVerifierTest.java
+ *
+ * summary: Apparent missing key events causing Bugster to break
+ */
+
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.TextArea;
+
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.InputVerifier;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JTextField;
+
+public class InputVerifierTest
+{
+
+ //*** test-writer defined static variables go here ***
+ static volatile boolean ivWasCalled = false;
+
+ private static void init()
+ {
+ //*** Create instructions for the user here ***
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ JFrame frame = new JFrame();
+ JTextField t1 = new JTextField();
+ t1.setInputVerifier(new InputVerifier() {
+ public boolean verify(JComponent input) {
+ Sysout.println("verify(" + input + ")");
+ ivWasCalled = true;
+ return true;
+ }
+ });
+ JTextField t2 = new JTextField();
+
+ frame.getContentPane().add(t1, BorderLayout.NORTH);
+ frame.getContentPane().add(t2, BorderLayout.SOUTH);
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+
+ Robot r = null;
+ try {
+ r = new Robot();
+ } catch (AWTException e) {
+ e.printStackTrace();
+ InputVerifierTest.fail(e.toString());
+ }
+
+ try {
+ r.waitForIdle();
+
+ mouseClickOnComp(r, t1);
+ r.waitForIdle();
+
+ if (!t1.isFocusOwner()) {
+ throw new RuntimeException("t1 is not a focus owner");
+ }
+ ivWasCalled = false;
+ r.keyPress(KeyEvent.VK_TAB);
+ r.delay(10);
+ r.keyRelease(KeyEvent.VK_TAB);
+ r.waitForIdle();
+
+ if (!t2.isFocusOwner()) {
+ throw new RuntimeException("t2 is not a focus owner");
+ }
+ if (!ivWasCalled) {
+ throw new RuntimeException("InputVerifier was not called after tabbing");
+ }
+
+ mouseClickOnComp(r, t1);
+ r.waitForIdle();
+
+ if (!t1.isFocusOwner()) {
+ throw new RuntimeException("t1 is not a focus owner");
+ }
+
+ ivWasCalled = false;
+ mouseClickOnComp(r, t2);
+ r.waitForIdle();
+ if (!t2.isFocusOwner()) {
+ throw new RuntimeException("t2 is not a focus owner");
+ }
+ if (!ivWasCalled) {
+ throw new RuntimeException("InputVErifier was not called after mouse press");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ InputVerifierTest.fail(e.toString());
+ }
+
+ InputVerifierTest.pass();
+
+ }//End init()
+
+ static void mouseClickOnComp(Robot r, Component comp) {
+ Point loc = comp.getLocationOnScreen();
+ loc.x += comp.getWidth() / 2;
+ loc.y += comp.getHeight() / 2;
+ r.mouseMove(loc.x, loc.y);
+ r.delay(10);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ r.delay(10);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main( String args[] ) throws InterruptedException
+ {
+ mainThread = Thread.currentThread();
+ try
+ {
+ init();
+ }
+ catch( TestPassedException e )
+ {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try
+ {
+ Thread.sleep( sleepTime );
+ //Timed out, so fail the test
+ throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ }
+ catch (InterruptedException e)
+ {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if( ! testGeneratedInterrupt ) throw e;
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if ( theTestPassed == false )
+ {
+ throw new RuntimeException( failureMessage );
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo( int seconds )
+ {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass()
+ {
+ Sysout.println( "The test passed." );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //first check if this is executing in main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail()
+ {
+ //test writer didn't specify why test failed, so give generic
+ fail( "it just plain failed! :-)" );
+ }
+
+ public static synchronized void fail( String whyFailed )
+ {
+ Sysout.println( "The test failed: " + whyFailed );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //check if this called from main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException( whyFailed );
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }//fail()
+
+}// class InputVerifierTest
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ System.out.println(messageIn);
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6382144/EndlessLoopTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,409 @@
+/*
+ * 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
+ * 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 6382144
+ @summary REGRESSION: InputVerifier and JOptionPane
+ @author oleg.sukhodolsky: area=awt.focus
+ @run main EndlessLoopTest
+*/
+
+/**
+ * EndlessLoopTest.java
+ *
+ * summary: REGRESSION: InputVerifier and JOptionPane
+ */
+
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.TextArea;
+import java.awt.Toolkit;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.InputVerifier;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JTextField;
+
+public class EndlessLoopTest
+{
+
+ //*** test-writer defined static variables go here ***
+ static volatile int n_iv_calls;
+
+
+ private static void init()
+ {
+ //*** Create instructions for the user here ***
+
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ JFrame frame = new JFrame();
+ final JDialog dialog = new JDialog(frame, true);
+ JButton button = new JButton("press me");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ dialog.dispose();
+ }
+ });
+ dialog.getContentPane().add(button);
+ dialog.pack();
+
+ JTextField t1 = new JTextField();
+ t1.setInputVerifier(new InputVerifier() {
+ public boolean verify(JComponent input) {
+ n_iv_calls++;
+ if (n_iv_calls == 1) {
+ dialog.setVisible(true);
+ }
+ return true;
+ }
+ });
+ JTextField t2 = new JTextField();
+
+
+ frame.getContentPane().add(t1, BorderLayout.NORTH);
+ frame.getContentPane().add(t2, BorderLayout.SOUTH);
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+
+ Robot r = null;
+ try {
+ r = new Robot();
+ } catch (AWTException e) {
+ EndlessLoopTest.fail(e);
+ }
+
+ try {
+ r.waitForIdle();
+
+ mouseClickOnComp(r, t1);
+ r.waitForIdle();
+
+ if (!t1.isFocusOwner()) {
+ throw new RuntimeException("t1 is not a focus owner");
+ }
+ n_iv_calls = 0;
+ r.keyPress(KeyEvent.VK_TAB);
+ r.delay(10);
+ r.keyRelease(KeyEvent.VK_TAB);
+ r.waitForIdle();
+
+ mouseClickOnComp(r, button);
+ r.waitForIdle();
+ } catch (Exception e) {
+ EndlessLoopTest.fail(e);
+ }
+
+ if (n_iv_calls != 1) {
+ EndlessLoopTest.fail(new RuntimeException("InputVerifier was called " + n_iv_calls + " times"));
+ }
+
+ EndlessLoopTest.pass();
+
+ }//End init()
+
+
+ static void mouseClickOnComp(Robot r, Component comp) {
+ Point loc = comp.getLocationOnScreen();
+ loc.x += comp.getWidth() / 2;
+ loc.y += comp.getHeight() / 2;
+ r.mouseMove(loc.x, loc.y);
+ r.delay(10);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ r.delay(10);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main( String args[] ) throws InterruptedException
+ {
+ mainThread = Thread.currentThread();
+ try
+ {
+ init();
+ }
+ catch( TestPassedException e )
+ {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try
+ {
+ Thread.sleep( sleepTime );
+ //Timed out, so fail the test
+ throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ }
+ catch (InterruptedException e)
+ {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if( ! testGeneratedInterrupt ) throw e;
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if ( theTestPassed == false )
+ {
+ throw new RuntimeException( failureMessage );
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo( int seconds )
+ {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass()
+ {
+ Sysout.println( "The test passed." );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //first check if this is executing in main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail( Exception whyFailed )
+ {
+ Sysout.println( "The test failed: " + whyFailed );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //check if this called from main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException( whyFailed );
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed.toString();
+ mainThread.interrupt();
+ }//fail()
+
+}// class EndlessLoopTest
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ System.out.println(messageIn);
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/6401036/InputVerifierTest2.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,384 @@
+/*
+ * 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
+ * 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 6401036
+ @summary InputVerifier shouldn't be called when requestFocus() is called on comp from another toplevel
+ @author oleg.sukhodolsky: area=awt.focus
+ @run main InputVerifierTest2
+*/
+
+/**
+ * InputVerifierTest2.java
+ *
+ * summary: REGRESSION: InputVerifier and JOptionPane
+ */
+
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.TextArea;
+
+import java.awt.event.InputEvent;
+
+import javax.swing.InputVerifier;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JTextField;
+import javax.swing.JWindow;
+
+public class InputVerifierTest2
+{
+
+ private static void init()
+ {
+ //*** Create instructions for the user here ***
+
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ JTextField tf = new JTextField(10);
+ frame.getContentPane().add(tf);
+
+ final JWindow w = new JWindow(frame);
+ JButton btn1 = new JButton("window");
+ btn1.setName("bnt1");
+ w.getContentPane().add(btn1);
+ w.pack();
+ w.setVisible(true);
+
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+
+
+ Robot r = null;
+ try {
+ r = new Robot();
+ } catch (AWTException e) {
+ InputVerifierTest2.fail(e);
+ }
+
+
+ try {
+ r.waitForIdle();
+ mouseClickOnComp(r, tf);
+ r.waitForIdle();
+
+ if (!tf.isFocusOwner()) {
+ throw new RuntimeException("t1 is not a focus owner");
+ }
+
+ tf.setInputVerifier(new InputVerifier() {
+ public boolean verify(JComponent input) {
+ System.err.println("verify on " + input);
+ throw new RuntimeException("InputVerifier should not be called");
+ }
+ });
+ btn1.requestFocus();
+ } catch (Exception e) {
+ InputVerifierTest2.fail(e);
+ }
+
+ InputVerifierTest2.pass();
+
+ }//End init()
+
+
+ static void mouseClickOnComp(Robot r, Component comp) {
+ Point loc = comp.getLocationOnScreen();
+ loc.x += comp.getWidth() / 2;
+ loc.y += comp.getHeight() / 2;
+ r.mouseMove(loc.x, loc.y);
+ r.delay(10);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ r.delay(10);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main( String args[] ) throws InterruptedException
+ {
+ mainThread = Thread.currentThread();
+ try
+ {
+ init();
+ }
+ catch( TestPassedException e )
+ {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try
+ {
+ Thread.sleep( sleepTime );
+ //Timed out, so fail the test
+ throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ }
+ catch (InterruptedException e)
+ {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if( ! testGeneratedInterrupt ) throw e;
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if ( theTestPassed == false )
+ {
+ throw new RuntimeException( failureMessage );
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo( int seconds )
+ {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass()
+ {
+ Sysout.println( "The test passed." );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //first check if this is executing in main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail( Exception whyFailed )
+ {
+ Sysout.println( "The test failed: " + whyFailed );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //check if this called from main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException( whyFailed );
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed.toString();
+ mainThread.interrupt();
+ }//fail()
+
+}// class InputVerifierTest2
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ System.out.println(messageIn);
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ChildWindowFocusTest/ChildWindowFocusTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,43 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 5090325
+ @summary Tests that Window's child can be focused on XAWT.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet ChildWindowFocusTest.html
+ -->
+<head>
+<title>ChildWindowFocusTest</title>
+</head>
+<body>
+
+<h1>ChildWindowFocusTest<br>Bug ID: 5090325</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="ChildWindowFocusTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ChildWindowFocusTest/ChildWindowFocusTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,281 @@
+/*
+ * 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
+ * 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 5090325
+ @summary Tests that Window's child can be focused on XAWT.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet ChildWindowFocusTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.lang.reflect.*;
+
+public class ChildWindowFocusTest extends Applet {
+ Robot robot;
+ Frame frame = new Frame("Owner");
+ Button button0 = new Button("button-0");
+ TextField text0 = new TextField("text-0");
+ TextField text1 = new TextField("text-1");
+ Window win1 = new TestWindow(frame, text0, 110);
+ Window win2 = new TestWindow(win1, text1, 220);
+ Frame outerFrame = new Frame("Outer");
+ Button button1 = new Button("button-1");
+ int shift;
+
+ public void init() {
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"This is an AUTOMATIC test", "simply wait until it is done"});
+
+ Rectangle bounds = Sysout.dialog.getBounds();
+ shift = (int)(bounds.x + bounds.width + 10);
+ }
+
+ public void start() {
+
+ frame.setBounds(0, 50, 400, 100);
+ frame.setLayout(new FlowLayout());
+ frame.add(button0);
+
+ outerFrame.setBounds(0, 390, 400, 100);
+ outerFrame.setLayout(new FlowLayout());
+ outerFrame.add(button1);
+
+ adjustAndShow(new Component[] {frame, win1, win2, outerFrame});
+ robot.waitForIdle();
+
+ test();
+ }
+
+ void adjustAndShow(Component[] comps) {
+ for (Component comp: comps) {
+ comp.setLocation(shift, (int)comp.getLocation().getY());
+ comp.setVisible(true);
+ robot.waitForIdle();
+ }
+ }
+
+ void test() {
+ clickOnCheckFocusOwner(button0);
+ clickOnCheckFocusOwner(text1);
+ clickOnCheckFocusOwner(button1);
+ clickOn(frame);
+ checkFocusOwner(text1);
+ clickOnCheckFocusOwner(text0);
+ clickOnCheckFocusOwner(button1);
+ clickOn(frame);
+ checkFocusOwner(text0);
+
+ Sysout.println("Test passed.");
+ }
+
+ void clickOnCheckFocusOwner(Component c) {
+ clickOn(c);
+ if (!checkFocusOwner(c)) {
+ throw new RuntimeException("Test failed: couldn't focus <" + c + "> by mouse click!");
+ }
+ }
+
+ boolean checkFocusOwner(Component comp) {
+ return (comp == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+ }
+
+ void clickOn(Component c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+
+ Sysout.println("Clicking " + c);
+
+ if (c instanceof Frame) {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
+ } else {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+ }
+ robot.delay(50);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(50);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ }
+
+}
+
+class TestWindow extends Window {
+ TestWindow(Window owner, Component comp, int x) {
+ super(owner);
+ setBackground(Color.blue);
+ setLayout(new FlowLayout());
+ add(comp);
+ comp.setBackground(Color.yellow);
+ setBounds(0, x, 100, 100);
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,43 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6386592
+ @summary Tests that disposing a dialog doesn't activate its invisible owner.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet DisposeDialogNotActivateOwnerTest.html
+ -->
+<head>
+<title>DisposeDialogNotActivateOwnerTest</title>
+</head>
+<body>
+
+<h1>DisposeDialogNotActivateOwnerTest<br>Bug ID: 6386592</h1>
+
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE=DisposeDialogNotActivateOwnerTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,258 @@
+/*
+ * 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
+ * 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 6386592
+ @summary Tests that disposing a dialog doesn't activate its invisible owner.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet DisposeDialogNotActivateOwnerTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+
+public class DisposeDialogNotActivateOwnerTest extends Applet {
+ Robot robot;
+
+ Frame frame = new Frame("Owner Frame");
+ Dialog dialog = new Dialog(new Frame(), "Owned Dialog");
+ Button frameButton = new Button("button");
+
+ static boolean passed = false;
+
+ public static void main(String[] args) {
+ DisposeDialogNotActivateOwnerTest app = new DisposeDialogNotActivateOwnerTest();
+ app.init();
+ app.start();
+ }
+
+ public void init() {
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"This is automatic test. Simply wait until it is done."
+ });
+
+ frame.setBounds(800, 50, 200, 100);
+ frame.add(frameButton);
+ dialog.setBounds(800, 300, 200, 100);
+ }
+
+ public void start() {
+
+ frameButton.addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent e) {
+ passed = true;
+ }
+ });
+
+ frame.setVisible(true);
+ robot.waitForIdle();
+
+ // make sure the frame is focused
+ clickOn(frame);
+ if (!frame.isFocused()) {
+ throw new RuntimeException("Error: a frame didn't get initial focus.");
+ }
+
+ dialog.setVisible(true);
+ robot.waitForIdle();
+
+ // make sure the dialog is focused
+ if (!dialog.isFocused()) {
+ throw new RuntimeException("Error: a dialog didn't get initial focus.");
+ }
+
+ dialog.dispose();
+ robot.waitForIdle();
+
+ if (passed) {
+ Sysout.println("Test passed.");
+ } else {
+ throw new RuntimeException("Test failed: a dialog activates invisible owner when disposed!");
+ }
+ }
+
+ void clickOn(Component c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+
+ if (c instanceof Frame) {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
+ } else {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+ }
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(20);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ robot.waitForIdle();
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- a/jdk/test/java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,7 +27,7 @@
@summary Tests that EmbeddedFrame can be focused.
@author anton.tarasov: area=awt-focus
@library ../../regtesthelpers
- @build Util
+ @build Util UtilInternal
@run main FocusEmbeddedFrameTest
*/
@@ -37,6 +37,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.lang.reflect.InvocationTargetException;
import test.java.awt.regtesthelpers.Util;
+import test.java.awt.regtesthelpers.UtilInternal;
public class FocusEmbeddedFrameTest extends Applet {
static Frame embedder = new Frame("Embedder");
@@ -71,7 +72,7 @@
embedder.addNotify();
try {
- ef = Util.createEmbeddedFrame(embedder);
+ ef = UtilInternal.createEmbeddedFrame(embedder);
} catch (Throwable t) {
t.printStackTrace();
throw new Error("Test error: couldn't create an EmbeddedFrame!");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,43 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 5082319
+ @summary Tests that focus request for already focused component doesn't block key events.
+ @author anton.tarasov@sun.com
+ @run applet FocusSubRequestTest.html
+ -->
+<head>
+<title>FocusSubRequestTest</title>
+</head>
+<body>
+
+<h1>FocusSubRequestTest<br>Bug ID: 5082319</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="FocusSubRequestTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,98 @@
+/*
+ * 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
+ * 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 5082319
+ @summary Tests that focus request for already focused component doesn't block key events.
+ @author anton.tarasov@sun.com
+ @run applet FocusSubRequestTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+public class FocusSubRequestTest extends Applet {
+ Frame frame = new Frame("Test Frame");
+ Button button = new Button("button");
+ boolean passed = false;
+ Robot robot;
+
+ public void init() {
+ frame.add(button);
+ button.addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent e) {
+ System.out.println("FocusSubRequestTest: focusGained for: " + e.getSource());
+ ((Component)e.getSource()).requestFocus();
+ }
+ });
+
+ button.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ System.out.println("FocusSubRequestTest: keyPressed for: " + e.getSource());
+ passed = true;
+ }
+ });
+
+ try {
+ robot = new Robot();
+ } catch(Exception e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ }
+
+ public void start() {
+ frame.pack();
+ frame.setLocation(getLocation().x + getSize().width + 20, 0);
+ frame.setVisible(true);
+
+ waitTillShown(button);
+ frame.toFront();
+
+ robot.delay(100);
+ robot.keyPress(KeyEvent.VK_K);
+ robot.delay(100);
+ robot.keyRelease(KeyEvent.VK_K);
+
+ robot.waitForIdle();
+
+ if(passed) {
+ System.out.println("Test passed.");
+ } else {
+ throw new RuntimeException("Test failed.");
+ }
+ }
+
+ private void waitTillShown(Component component) {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ component.getLocationOnScreen();
+ break;
+ } catch(InterruptedException ie) {
+ throw new RuntimeException(ie);
+ } catch(IllegalComponentStateException icse) {}
+ }
+ }
+}
--- a/jdk/test/java/awt/Focus/KeyEventForBadFocusOwnerTest/KeyEventForBadFocusOwnerTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Focus/KeyEventForBadFocusOwnerTest/KeyEventForBadFocusOwnerTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -38,13 +38,11 @@
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
-import sun.awt.SunToolkit;
public class KeyEventForBadFocusOwnerTest {
final static String ITEM_ONE_TEXT = "one";
@@ -55,7 +53,6 @@
volatile static boolean unexpectedItemSelected = false;
static Robot robot;
- static SunToolkit toolkit;
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@@ -122,16 +119,15 @@
}
});
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
robot = new Robot();
robot.setAutoDelay(100);
+ robot.waitForIdle();
Util.hitMnemonics(robot, KeyEvent.VK_O);
Util.hitMnemonics(robot, KeyEvent.VK_T);
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(1000); // workaround for MacOS
if (unexpectedItemSelected) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ModalDialogInitialFocusTest/ModalDialogInitialFocusTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,43 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6382750
+ @summary
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet ModalDialogInitialFocusTest.html
+ -->
+<head>
+<title>ModalDialogInitialFocusTest</title>
+</head>
+<body>
+
+<h1>ModalDialogInitialFocusTest<br>Bug ID: 6382750</h1>
+
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE=ModalDialogInitialFocusTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ModalDialogInitialFocusTest/ModalDialogInitialFocusTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,253 @@
+/*
+ * 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
+ * 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 6382750
+ @summary Tests that modal dialog doesn't request extra initial focus on show.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet ModalDialogInitialFocusTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.lang.reflect.InvocationTargetException;
+
+public class ModalDialogInitialFocusTest extends Applet {
+ Robot robot;
+
+ Dialog dialog = new Dialog((Window)null, "Test Dialog", Dialog.ModalityType.TOOLKIT_MODAL);
+ Button button = new Button("button");
+
+ volatile static boolean passed = true;
+
+ public static void main(String[] args) {
+ ModalDialogInitialFocusTest app = new ModalDialogInitialFocusTest();
+ app.init();
+ app.start();
+ }
+
+ public void init() {
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"This is automatic test. Simply wait until it is done."
+ });
+ }
+
+ public void start() {
+
+ dialog.setLayout(new FlowLayout());
+ dialog.add(button);
+ dialog.setBounds(800, 0, 100, 100);
+
+ dialog.addFocusListener(new FocusAdapter() {
+ // The only expected FOCUS_GAINED is on the button.
+ public void focusGained(FocusEvent e) {
+ passed = false;
+ }
+ });
+
+ test();
+ }
+
+ void test() {
+ new Thread(new Runnable() {
+ public void run() {
+ dialog.setVisible(true);
+ }
+ }).start();
+
+ waitTillShown(dialog);
+
+ robot.waitForIdle();
+
+ dialog.dispose();
+
+ if (passed) {
+ Sysout.println("Test passed.");
+ } else {
+ throw new RuntimeException("Test failed: dialog requests extra focus on show!");
+ }
+ }
+
+ void waitTillShown(Component c) {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ c.getLocationOnScreen();
+ break;
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ break;
+ } catch (IllegalComponentStateException e) {
+ }
+ }
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,43 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 5028014
+ @summary Focus request & mouse click being performed nearly synchronously shouldn't break the focus subsystem
+ @author anton.tarasov@sun.com: area=awt-focus
+ @run applet MouseClickRequestFocusRaceTest.html
+ -->
+<head>
+<title>MouseClickRequestFocusRaceTest</title>
+</head>
+<body>
+
+<h1>MouseClickRequestFocusRaceTest<br>Bug ID: 5028014</h1>
+
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE=MouseClickRequestFocusRaceTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,307 @@
+/*
+ * 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
+ * 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 5028014
+ @summary Focus request & mouse click performed nearly synchronously shouldn't lead to a focus race.
+ @author anton.tarasov@sun.com: area=awt-focus
+ @run applet MouseClickRequestFocusRaceTest.html
+*/
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+import java.applet.Applet;
+
+public class MouseClickRequestFocusRaceTest extends Applet {
+ Robot robot;
+ JFrame frame1 = new JFrame("Frame-1") {
+ public String toString() { return "Frame-1";}
+ };
+ JFrame frame2 = new JFrame("Frame-2") {
+ public String toString() { return "Frame-2";}
+ };
+ JButton button1 = new JButton("button-1") {
+ public String toString() { return "button-1";}
+ };
+ JButton button2 = new JButton("button-2") {
+ public String toString() { return "button-2";}
+ };
+ JPopupMenu popup = new JPopupMenu();
+
+ public static void main(String[] args) {
+ MouseClickRequestFocusRaceTest app = new MouseClickRequestFocusRaceTest();
+ app.init();
+ app.start();
+ }
+
+ public void init() {
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"Automatic test. Simply wait until it is done."
+ });
+ }
+
+ public void start() {
+ frame1.add(button1);
+ frame2.add(button2);
+ frame1.setBounds(0, 0, 200, 300);
+ frame2.setBounds(300, 0, 200, 300);
+ frame1.setLayout(new FlowLayout());
+ frame2.setLayout(new FlowLayout());
+
+ popup.add(new JMenuItem("black"));
+ popup.add(new JMenuItem("yellow"));
+ popup.add(new JMenuItem("white"));
+
+ frame1.add(popup);
+
+ frame1.addMouseListener(new MouseAdapter() {
+ void popup(MouseEvent e) {
+ if (e.isPopupTrigger()) {
+ Point loc = button1.getLocation();
+ popup.show(button1, e.getX() - loc.x, e.getY() - loc.y);
+ }
+ }
+ public void mousePressed(MouseEvent e) {
+ popup(e);
+ }
+ public void mouseReleased(MouseEvent e) {
+ popup(e);
+ }
+ });
+
+ frame2.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ button1.requestFocusInWindow();
+ }
+ });
+
+ frame2.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
+ frame1.setVisible(true);
+ frame2.setVisible(true);
+// ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.delay(1000);
+
+ test();
+ }
+
+ public void test() {
+ // Right click Frame-1
+ robot.mouseMove(frame1.getLocation().x + 100, frame1.getLocation().y + 200);
+ robot.mousePress(InputEvent.BUTTON3_MASK);
+ robot.delay(100);
+ robot.mouseRelease(InputEvent.BUTTON3_MASK);
+
+// ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.delay(1000);
+
+ // Left click Frame-2
+ robot.mouseMove(frame2.getLocation().x + 100, frame1.getLocation().y + 200);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(100);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+// ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.delay(1000);
+
+ JComponent focusOwner = (JComponent)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+ JFrame focusedWindow = (JFrame)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
+
+ Sysout.println("focus owner: " + focusOwner);
+ Sysout.println("focused window: " + focusedWindow);
+
+ // Verify that the focused window is the ancestor of the focus owner
+ if (!focusedWindow.isAncestorOf(focusOwner)) {
+ throw new TestFailedException("The focus owner is not in the focused window!");
+ }
+
+ // Try to close native focused window
+ robot.keyPress(KeyEvent.VK_ALT);
+ robot.keyPress(KeyEvent.VK_F4);
+ robot.keyRelease(KeyEvent.VK_F4);
+ robot.keyRelease(KeyEvent.VK_ALT);
+
+// ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.delay(1000);
+
+ // Verify that the Java focused window really mapped the native focused window.
+ if (focusedWindow.isVisible()) {
+ throw new TestFailedException("The focused window is different on Java and on the native level.");
+ }
+ }
+
+ class TestFailedException extends RuntimeException {
+ public TestFailedException(String cause) {
+ super("Test failed.");
+ Sysout.println(cause);
+ }
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+// dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+// dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+// setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- a/jdk/test/java/awt/Focus/SimpleWindowActivationTest/SimpleWindowActivationTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Focus/SimpleWindowActivationTest/SimpleWindowActivationTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,7 +34,6 @@
import java.awt.event.*;
import java.util.concurrent.Callable;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
public class SimpleWindowActivationTest {
@@ -45,7 +44,6 @@
private static Button wbutton;
private static Label label;
private static Robot robot;
- private static SunToolkit toolkit;
public static void main(String[] args) throws Exception {
@@ -54,7 +52,6 @@
return;
}
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(50);
@@ -66,10 +63,10 @@
}, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
createAndShowWindow();
- toolkit.realSync();
+ robot.waitForIdle();
createAndShowFrame();
- toolkit.realSync();
+ robot.waitForIdle();
// click on Frame
clickOn(getClickPoint(frame));
@@ -96,7 +93,7 @@
// won't activate it.
window.setFocusableWindowState(false);
- toolkit.realSync();
+ robot.waitForIdle();
clickOn(getClickPoint(label));
@@ -136,11 +133,12 @@
static void clickOn(Point point) {
robot.mouseMove(point.x, point.y);
+ robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
}
static Point getClickPoint(Component c) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/GetBoundsResizeTest/GetBoundsResizeTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 1998, 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 4103095
+ @summary Test for getBounds() after a Frame resize.
+ @author andrei.dmitriev : area=awt.toplevel
+ @run main/manual GetBoundsResizeTest
+*/
+
+import java.applet.Applet;
+import java.lang.*;
+import java.awt.*;
+import java.awt.event.*;
+
+class Globals {
+ static boolean testPassed=false;
+ static Thread mainThread=null;
+}
+
+public class GetBoundsResizeTest extends Applet {
+
+ public static void main(String args[]) throws Exception {
+ GetBoundsResizeTest app = new GetBoundsResizeTest();
+ app.start();
+ Globals.mainThread = Thread.currentThread();
+ try {
+ Thread.sleep(300000);
+ } catch (InterruptedException e) {
+ if (!Globals.testPassed)
+ throw new Exception("GetBoundsResizeTest failed.");
+ }
+ }
+
+ public void start()
+ {
+ String[] message = {
+ "Resize the window using the upper left corner.",
+ "Press the button to print the result of getBounds() to the terminal.",
+ "If getBounds() prints the correct values for the window",
+ "then click Pass, else click Fail."
+ };
+ new TestDialog(new Frame(), "GetBoundsResizeTest", message).start();
+ new GetBoundsResizeTester("GetBoundsResizeTester").start();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////
+// Test Dialog
+////////////////////////////////////////////////////////////////////////
+
+class TestDialog extends Dialog
+ implements ActionListener {
+
+ static TextArea output;
+ Button passButton;
+ Button failButton;
+ String name;
+
+ public TestDialog(Frame frame, String name, String[] message)
+ {
+ super(frame, name + " Pass/Fail Dialog");
+ this.name = name;
+ int maxStringLength = 0;
+ for (int i=0; i<message.length; i++) {
+ maxStringLength = Math.max(maxStringLength, message[i].length());
+ }
+ output = new TextArea(10, maxStringLength);
+ add("North", output);
+ for (int i=0; i<message.length; i++){
+ output.append(message[i] + "\n");
+ }
+ Panel buttonPanel = new Panel();
+ passButton = new Button("Pass");
+ failButton = new Button("Fail");
+ passButton.addActionListener(this);
+ failButton.addActionListener(this);
+ buttonPanel.add(passButton);
+ buttonPanel.add(failButton);
+ add("South", buttonPanel);
+ pack();
+ }
+
+ public void start()
+ {
+ show();
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ if ( event.getSource() == passButton ) {
+ Globals.testPassed = true;
+ System.err.println(name + " Passed.");
+ }
+ else if ( event.getSource() == failButton ) {
+ Globals.testPassed = false;
+ System.err.println(name + " Failed.");
+ }
+ this.dispose();
+ if (Globals.mainThread != null)
+ Globals.mainThread.interrupt();
+ }
+}
+
+
+ ////////////////////////////////////////////////////////////////////////
+ // Test Class
+ ////////////////////////////////////////////////////////////////////////
+
+class GetBoundsResizeTester extends Frame {
+ Button b = new Button("Press");
+
+ GetBoundsResizeTester(String name)
+ {
+ super(name);
+ final Frame f = this;
+ Panel p = new Panel();
+ f.add(p);
+ p.setLayout(new BorderLayout());
+ b.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent be){
+ Point cp = b.getLocationOnScreen();
+ TestDialog.output.append("Current Frame.getBounds() = " + f.getBounds()+"\n");
+ }
+ });
+ p.add("Center", b);
+ f.pack();
+ }
+
+ public void start ()
+ {
+ setVisible(true);
+ Robot robot;
+ try {
+ robot = new Robot();
+ robot.waitForIdle();
+ }catch(Exception ignorex) {
+ }
+ Point cp = b.getLocationOnScreen();
+ TestDialog.output.append("Original Frame.getBounds() = " + this.getBounds()+"\n");
+ }
+
+ public static void main(String[] args)
+ {
+ new GetBoundsResizeTester("GetBoundsResizeTester").start();
+ }
+
+}
--- a/jdk/test/java/awt/FullScreen/8013581/bug8013581.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/FullScreen/8013581/bug8013581.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,7 +29,6 @@
* @run main bug8013581
*/
-import sun.awt.*;
import java.awt.*;
import java.awt.event.*;
@@ -42,12 +41,11 @@
.getLocalGraphicsEnvironment();
final GraphicsDevice[] devices = ge.getScreenDevices();
- final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
final Robot robot = new Robot();
robot.setAutoDelay(50);
createAndShowGUI();
- toolkit.realSync();
+ robot.waitForIdle();
Exception error = null;
for (final GraphicsDevice device : devices) {
@@ -56,14 +54,14 @@
}
device.setFullScreenWindow(frame);
- sleep();
+ sleep(robot);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
- toolkit.realSync();
+ robot.waitForIdle();
device.setFullScreenWindow(null);
- sleep();
+ sleep(robot);
if (listenerCallCounter != 2) {
error = new Exception("Test failed: KeyListener called " + listenerCallCounter + " times instead of 2!");
@@ -98,8 +96,8 @@
frame.setVisible(true);
}
- private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ private static void sleep(Robot robot) {
+ robot.waitForIdle();
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
--- a/jdk/test/java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java Wed Jul 05 20:11:52 2017 +0200
@@ -30,12 +30,9 @@
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.Window;
import java.awt.image.BufferedImage;
-import sun.awt.SunToolkit;
-
/**
* @test
* @bug 8003173 7019055
@@ -45,6 +42,7 @@
public final class FullScreenInsets {
private static boolean passed = true;
+ private static Robot robot = null;
public static void main(final String[] args) {
final GraphicsEnvironment ge = GraphicsEnvironment
@@ -147,7 +145,15 @@
}
private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ if(robot == null) {
+ try {
+ robot = new Robot();
+ }catch(AWTException ae) {
+ ae.printStackTrace();
+ throw new RuntimeException("Cannot create Robot.");
+ }
+ }
+ robot.waitForIdle();
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,43 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6391688
+ @summary Tests that next mnemonic KeyTyped is consumed for a modal dialog.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet ConsumeForModalDialogTest.html
+ -->
+<head>
+<title>ConsumeForModalDialogTest</title>
+</head>
+<body>
+
+<h1>ConsumeForModalDialogTest<br>Bug ID: 6391688</h1>
+
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE=ConsumeForModalDialogTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,281 @@
+/*
+ * 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
+ * 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 6391688
+ @summary Tests that next mnemonic KeyTyped is consumed for a modal dialog.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet ConsumeForModalDialogTest.html
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.lang.reflect.InvocationTargetException;
+
+public class ConsumeForModalDialogTest extends Applet {
+ Robot robot;
+ JFrame frame = new JFrame("Test Frame");
+ JDialog dialog = new JDialog((Window)null, "Test Dialog", Dialog.ModalityType.DOCUMENT_MODAL);
+ JTextField text = new JTextField();
+ static boolean passed = true;
+
+ public static void main(String[] args) {
+ ConsumeForModalDialogTest app = new ConsumeForModalDialogTest();
+ app.init();
+ app.start();
+ }
+
+ public void init() {
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(50);
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"This is automatic test. Simply wait until it is done."
+ });
+ }
+
+ public void start() {
+
+ text.addKeyListener(new KeyAdapter() {
+ public void keyTyped(KeyEvent e) {
+ Sysout.println(e.toString());
+ passed = false;
+ }
+ });
+
+ JMenuItem testItem = new JMenuItem();
+ testItem.setMnemonic('s');
+ testItem.setText("Test");
+
+ testItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ dialog.setVisible(true);
+ }
+ });
+
+ JMenu menu = new JMenu();
+ menu.setMnemonic('f');
+ menu.setText("File");
+ menu.add(testItem);
+
+ JMenuBar menuBar = new JMenuBar();
+ menuBar.add(menu);
+
+ dialog.setSize(100, 100);
+ dialog.add(text);
+
+ frame.setJMenuBar(menuBar);
+ frame.setSize(100, 100);
+ frame.setVisible(true);
+
+ robot.waitForIdle();
+
+ if (!frame.isFocusOwner()) {
+ Point loc = frame.getLocationOnScreen();
+ Dimension size = frame.getSize();
+ robot.mouseMove(loc.x + size.width/2, loc.y + size.height/2);
+ robot.delay(10);
+ robot.mousePress(MouseEvent.BUTTON1_MASK);
+ robot.delay(10);
+ robot.mouseRelease(MouseEvent.BUTTON1_MASK);
+
+ robot.waitForIdle();
+
+ int iter = 10;
+ while (!frame.isFocusOwner() && iter-- > 0) {
+ robot.delay(200);
+ }
+ if (iter <= 0) {
+ Sysout.println("Test: the frame couldn't be focused!");
+ return;
+ }
+ }
+
+ robot.keyPress(KeyEvent.VK_ALT);
+ robot.keyPress(KeyEvent.VK_F);
+ robot.delay(10);
+ robot.keyRelease(KeyEvent.VK_F);
+ robot.keyRelease(KeyEvent.VK_ALT);
+
+ robot.waitForIdle();
+
+ robot.keyPress(KeyEvent.VK_S);
+ robot.delay(10);
+ robot.keyRelease(KeyEvent.VK_S);
+
+ robot.delay(1000);
+
+ if (passed) {
+ Sysout.println("Test passed.");
+ } else {
+ throw new RuntimeException("Test failed! Enexpected KeyTyped came into the JTextField.");
+ }
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6346690
+ @summary Tests that key_typed is consumed after mnemonic key_pressed is handled for a menu item.
+ @author anton.tarasov@sun.com: area=awt-focus
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run applet ConsumeNextMnemonicKeyTypedTest.html
+ -->
+<head>
+<title>ConsumeNextMnemonicKeyTypedTest</title>
+</head>
+<body>
+
+<h1>ConsumeNextMnemonicKeyTypedTest<br>Bug ID: 6346690</h1>
+
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE=ConsumeNextMnemonicKeyTypedTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,300 @@
+/*
+ * 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
+ * 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 6346690
+ @summary Tests that key_typed is consumed after mnemonic key_pressed is handled for a menu item.
+ @author anton.tarasov@sun.com: area=awt-focus
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run applet ConsumeNextMnemonicKeyTypedTest.html
+*/
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+import java.applet.Applet;
+
+
+public class ConsumeNextMnemonicKeyTypedTest extends Applet {
+ Robot robot;
+ JFrame frame = new JFrame("Test Frame");
+ JTextField text = new JTextField();
+ JMenuBar bar = new JMenuBar();
+ JMenu menu = new JMenu("Menu");
+ JMenuItem item = new JMenuItem("item");
+
+ public static void main(String[] args) {
+ ConsumeNextMnemonicKeyTypedTest app = new ConsumeNextMnemonicKeyTypedTest();
+ app.init();
+ app.start();
+ }
+
+ public void init() {
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(50);
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"Automatic test. Simply wait until it's done."});
+ }
+
+ public void start() {
+ menu.setMnemonic('f');
+ item.setMnemonic('i');
+ menu.add(item);
+ bar.add(menu);
+
+ frame.add(text);
+ frame.setJMenuBar(bar);
+ frame.pack();
+
+ frame.setLocation(800, 0);
+ frame.setVisible(true);
+
+ test();
+ }
+
+ void test() {
+
+ robot.waitForIdle();
+
+ if (!text.isFocusOwner()) {
+ robot.mouseMove(text.getLocationOnScreen().x + 5, text.getLocationOnScreen().y + 5);
+ robot.delay(100);
+ robot.mousePress(MouseEvent.BUTTON1_MASK);
+ robot.delay(100);
+ robot.mouseRelease(MouseEvent.BUTTON1_MASK);
+
+ int iter = 10;
+ while (!text.isFocusOwner() && iter-- > 0) {
+ robot.delay(200);
+ }
+ if (iter <= 0) {
+ Sysout.println("Test: text field couldn't be focused!");
+ return;
+ }
+ }
+
+ robot.keyPress(KeyEvent.VK_A);
+ robot.delay(100);
+ robot.keyRelease(KeyEvent.VK_A);
+
+ robot.waitForIdle();
+
+ String charA = text.getText();
+ System.err.println("Test: character typed with VK_A: " + charA);
+
+ robot.keyPress(KeyEvent.VK_BACK_SPACE);
+ robot.delay(100);
+ robot.keyRelease(KeyEvent.VK_BACK_SPACE);
+
+ robot.waitForIdle();
+
+ if (jdk.testlibrary.OSInfo.getOSType() == jdk.testlibrary.OSInfo.OSType.MACOSX) {
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ }
+ robot.keyPress(KeyEvent.VK_ALT);
+ robot.keyPress(KeyEvent.VK_F);
+ robot.delay(100);
+ robot.keyRelease(KeyEvent.VK_F);
+ robot.keyRelease(KeyEvent.VK_ALT);
+ if (jdk.testlibrary.OSInfo.getOSType() == jdk.testlibrary.OSInfo.OSType.MACOSX) {
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ }
+
+ robot.waitForIdle();
+
+ String string = text.getText();
+
+ robot.keyPress(KeyEvent.VK_I);
+ robot.delay(100);
+ robot.keyRelease(KeyEvent.VK_I);
+
+ robot.waitForIdle();
+
+ Sysout.println("Test: character typed after mnemonic key press: " + text.getText());
+
+ if (!text.getText().equals(string)) {
+ throw new RuntimeException("Test failed!");
+ }
+
+ robot.keyPress(KeyEvent.VK_A);
+ robot.delay(100);
+ robot.keyRelease(KeyEvent.VK_A);
+
+ robot.waitForIdle();
+
+ System.err.println("Test: chracter typed with VK_A: " + text.getText());
+
+ if (!charA.equals(text.getText())) {
+ throw new RuntimeException("Test failed!");
+ }
+
+ Sysout.println("Test passed.");
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogButtonTest/EnqueueWithDialogButtonTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,374 @@
+/*
+ * Copyright (c) 2003, 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 4799136
+@summary Tests that type-ahead for dialog works and doesn't block program
+@author Dmitry.Cherepanov@SUN.COM area=awt.focus
+@run main EnqueueWithDialogButtonTest
+*/
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.awt.event.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/*
+ * Tests that type-ahead works correctly. That means
+ * that the key events are not delivered until a focus
+ * transfer is completed.
+ * There is another pretty similar test EnqueueWithDialogTest
+ * written in time before 6347235 resolution. We'll keep it
+ * to track quite unrelated suspicious waitForIdle behavior.
+ */
+
+public class EnqueueWithDialogButtonTest
+{
+ static Frame f;
+ static Button b;
+ static Dialog d;
+ static Button ok;
+ static CountDownLatch pressLatch = new CountDownLatch(1);
+ static CountDownLatch robotLatch = new CountDownLatch(1);
+ static volatile boolean gotFocus = false;
+ static Robot robot;
+ public static void main(String args[]) throws Exception {
+ EnqueueWithDialogButtonTest test = new EnqueueWithDialogButtonTest();
+ test.init();
+ test.start();
+ }
+ public void init()
+ {
+ Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+ public void eventDispatched(AWTEvent e) {
+ if (e instanceof InputEvent){
+ System.err.println(e.toString()+","+((InputEvent)e).getWhen());
+ }else{
+ System.err.println(e.toString());
+ }
+ }
+ }, AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
+
+
+ f = new Frame("frame");
+ f.setPreferredSize(new Dimension(100,100));
+ f.setLocation(100,50);
+ b = new Button("press");
+ d = new Dialog(f, "dialog", true);
+ d.setPreferredSize(new Dimension(70,70));
+ ok = new Button("ok");
+ d.add(ok);
+ d.pack();
+ ok.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ System.err.println("OK pressed: should arrive after got focus");
+ d.dispose();
+ f.dispose();
+ // Typed-ahead key events should only be accepted if
+ // they arrive after FOCUS_GAINED
+ if (gotFocus) {
+ pressLatch.countDown();
+ }
+ }
+ });
+ ok.addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent e) {
+ gotFocus = true;
+ System.err.println("OK got focus");
+ }
+ });
+ f.add(b);
+ f.pack();
+ b.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ System.err.println(e.toString()+","+e.getWhen());
+ System.err.println("B pressed");
+ robotLatch.countDown();
+
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ waitTillShown(d);
+ EnqueueWithDialogButtonTest.this.d.toFront();
+ EnqueueWithDialogButtonTest.this.moveMouseOver(d);
+ }
+ });
+
+ // This will cause enqueue the following key events
+ d.setVisible(true);
+ }
+ });
+
+ }//End init()
+
+ public void start () throws Exception
+ {
+
+ robot = new Robot();
+ robot.setAutoDelay(50);
+
+ f.setVisible(true);
+ waitTillShown(b);
+ System.err.println("b is shown");
+ f.toFront();
+ moveMouseOver(f);
+ robot.waitForIdle();
+ robot.delay(100);
+ makeFocused(b);
+ robot.waitForIdle();
+ robot.delay(100);
+ System.err.println("b is focused");
+
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ boolean ok = robotLatch.await(1, TimeUnit.SECONDS);
+ if(!ok) {
+ throw new RuntimeException("Was B button pressed?");
+ }
+
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ robot.delay(500);
+ ok = pressLatch.await(3, TimeUnit.SECONDS);
+ if(!ok) {
+ throw new RuntimeException("Type-ahead doesn't work");
+ }
+
+ }// start()
+
+ private void moveMouseOver(Container c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+ }
+
+ private void waitTillShown(Component c) {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ c.getLocationOnScreen();
+ break;
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ break;
+ } catch (Exception e) {
+ }
+ }
+ }
+ private void makeFocused(Component comp) {
+ if (comp.isFocusOwner()) {
+ return;
+ }
+ final Semaphore sema = new Semaphore();
+ final FocusAdapter fa = new FocusAdapter() {
+ public void focusGained(FocusEvent fe) {
+ sema.raise();
+ }
+ };
+ comp.addFocusListener(fa);
+ comp.requestFocusInWindow();
+ if (comp.isFocusOwner()) {
+ return;
+ }
+ try {
+ sema.doWait(3000);
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ comp.removeFocusListener(fa);
+ if (!comp.isFocusOwner()) {
+ throw new RuntimeException("Can't make " + comp + " focused, current owner is " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+ }
+ }
+
+static class Semaphore {
+ boolean state = false;
+ int waiting = 0;
+ public Semaphore() {
+ }
+ public synchronized void doWait() throws InterruptedException {
+ if (state) {
+ return;
+ }
+ waiting++;
+ wait();
+ waiting--;
+ }
+ public synchronized void doWait(int timeout) throws InterruptedException {
+ if (state) {
+ return;
+ }
+ waiting++;
+ wait(timeout);
+ waiting--;
+ }
+ public synchronized void raise() {
+ state = true;
+ if (waiting > 0) {
+ notifyAll();
+ }
+ }
+ public synchronized boolean getState() {
+ return state;
+ }
+}
+}// class TestDialogTypeAhead
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ show();
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogTest/EnqueueWithDialogTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2003, 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 4799136
+@summary Tests that type-ahead for dialog works and doesn't block program
+@author Dmitry.Cherepanov@SUN.COM area=awt.focus
+@run main EnqueueWithDialogTest
+*/
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.awt.event.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/*
+ * The purpose of this test is check that the type-head
+ * works correctly on Windows. That means that the key
+ * events are not delivered until a focus transfer is
+ * completed. Another regression test EnqueueWithDialogButton
+ * doesn't work on Windows because of the bug 6347235.
+ * This test workaround the bug by means of the removing
+ * button from the dialog.
+ */
+
+public class EnqueueWithDialogTest
+{
+ static Frame f;
+ static Button b;
+ static Dialog d;
+ static CountDownLatch pressLatch = new CountDownLatch(1);
+ static CountDownLatch robotLatch = new CountDownLatch(1);
+ static volatile boolean gotFocus = false;
+ static Robot robot;
+ public static void main(String args[]) throws Exception {
+ EnqueueWithDialogTest test = new EnqueueWithDialogTest();
+ test.init();
+ test.start();
+ }
+ public void init()
+ {
+ Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+ public void eventDispatched(AWTEvent e) {
+ if (e instanceof InputEvent){
+ System.err.println(e.toString()+","+((InputEvent)e).getWhen());
+ }else{
+ System.err.println(e.toString());
+ }
+ }
+ }, AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
+
+
+ f = new Frame("frame");
+ f.setPreferredSize(new Dimension(100,100));
+ f.setLocation(100,50);
+ b = new Button("press");
+ d = new Dialog(f, "dialog", true);
+ d.setPreferredSize(new Dimension(70,70));
+ d.pack();
+ d.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ System.err.println("DIALOG pressed: should arrive after got focus");
+ d.dispose();
+ f.dispose();
+ // Typed-ahead key events should only be accepted if
+ // they arrive after FOCUS_GAINED
+ if (gotFocus) {
+ pressLatch.countDown();
+ }
+ }
+ });
+ d.addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent e) {
+ gotFocus = true;
+ System.err.println("DIALOG got focus");
+ }
+ });
+ f.add(b);
+ f.pack();
+ b.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ System.err.println(e.toString()+","+e.getWhen());
+ System.err.println("B pressed");
+ robotLatch.countDown();
+
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ waitTillShown(d);
+ EnqueueWithDialogTest.this.d.toFront();
+ EnqueueWithDialogTest.this.moveMouseOver(d);
+ }
+ });
+
+ // This will cause enqueue the following key events
+ d.setVisible(true);
+ }
+ });
+
+ }//End init()
+
+ public void start () throws Exception
+ {
+ try {
+ robot = new Robot();
+ //robot.setAutoDelay(50);
+ } catch (Exception e) {
+ throw new RuntimeException("Can't create robot:" + e);
+ }
+
+ f.setVisible(true);
+ waitTillShown(b);
+ System.err.println("b is shown");
+ f.toFront();
+ moveMouseOver(f);
+ robot.waitForIdle();
+ robot.delay(100);
+ makeFocused(b);
+ robot.waitForIdle();
+ robot.delay(100);
+ System.err.println("b is focused");
+
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ System.err.println("space typed once");
+ boolean ok = robotLatch.await(1, TimeUnit.SECONDS);
+ if(!ok) {
+ throw new RuntimeException("Was B button pressed?");
+ }
+
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ System.err.println("space typed twice");
+ robot.delay(500);
+ ok = pressLatch.await(3, TimeUnit.SECONDS);
+ if(!ok) {
+ throw new RuntimeException("Type-ahead doesn't work");
+ }
+
+ }// start()
+
+ private void moveMouseOver(Container c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+ }
+
+ private void waitTillShown(Component c) {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ c.getLocationOnScreen();
+ break;
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ break;
+ } catch (Exception e) {
+ }
+ }
+ }
+ private void makeFocused(Component comp) {
+ if (comp.isFocusOwner()) {
+ return;
+ }
+ final Semaphore sema = new Semaphore();
+ final FocusAdapter fa = new FocusAdapter() {
+ public void focusGained(FocusEvent fe) {
+ sema.raise();
+ }
+ };
+ comp.addFocusListener(fa);
+ comp.requestFocusInWindow();
+ if (comp.isFocusOwner()) {
+ return;
+ }
+ try {
+ sema.doWait(3000);
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ comp.removeFocusListener(fa);
+ if (!comp.isFocusOwner()) {
+ throw new RuntimeException("Can't make " + comp + " focused, current owner is " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+ }
+ }
+
+static class Semaphore {
+ boolean state = false;
+ int waiting = 0;
+ public Semaphore() {
+ }
+ public synchronized void doWait() throws InterruptedException {
+ if (state) {
+ return;
+ }
+ waiting++;
+ wait();
+ waiting--;
+ }
+ public synchronized void doWait(int timeout) throws InterruptedException {
+ if (state) {
+ return;
+ }
+ waiting++;
+ wait(timeout);
+ waiting--;
+ }
+ public synchronized void raise() {
+ state = true;
+ if (waiting > 0) {
+ notifyAll();
+ }
+ }
+ public synchronized boolean getState() {
+ return state;
+ }
+}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/FreezeTest/FreezeTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2003, 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 4799136
+@summary Tests that type-ahead for dialog works and doesn't block program
+@author Dmitry.Cherepanov@SUN.COM area=awt.focus
+@run main FreezeTest
+*/
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.awt.event.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/*
+ * Tests that type-ahead doesn't block program.
+ */
+
+public class FreezeTest
+{
+ static Frame f;
+ static Button b;
+ static Dialog d;
+ static TextField tf;
+ static CountDownLatch robotLatch = new CountDownLatch(1);
+ static Robot robot;
+ static int click_count = 100;
+ static int deliver_count = 0;
+
+ public static void main(String args[]) throws Exception {
+ FreezeTest test = new FreezeTest();
+ test.init();
+ test.start();
+ }
+ public void init()
+ {
+ Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+ public void eventDispatched(AWTEvent e) {
+ if (e instanceof KeyEvent){
+ deliver_count++;
+ System.err.println("key_event# "+deliver_count);
+ }
+
+ if (e instanceof InputEvent){
+ System.err.println(e.toString()+","+((InputEvent)e).getWhen());
+ }else{
+ System.err.println(e.toString());
+ }
+ }
+ }, AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
+
+
+ f = new Frame("frame");
+ b = new Button("press");
+ d = new Dialog(f, "dialog", true);
+ tf = new TextField("");
+ d.add(tf);
+ d.pack();
+
+ f.add(b);
+ f.pack();
+ b.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ System.err.println(e.toString()+","+e.getWhen());
+ System.err.println("B pressed");
+ robotLatch.countDown();
+
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ waitTillShown(d);
+ FreezeTest.this.d.toFront();
+ FreezeTest.this.moveMouseOver(d);
+ }
+ });
+ d.setVisible(true);
+ }
+ });
+
+ }//End init()
+
+ public void start () throws Exception
+ {
+ robot = new Robot();
+
+ f.setVisible(true);
+ waitTillShown(b);
+ System.err.println("b is shown");
+ f.toFront();
+ moveMouseOver(f);
+ robot.waitForIdle();
+ makeFocused(b);
+ robot.waitForIdle();
+ System.err.println("b is focused");
+
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ boolean ok = robotLatch.await(1, TimeUnit.SECONDS);
+ if(!ok) {
+ throw new RuntimeException("Was B button pressed?");
+ }
+
+ for (int i = 0; i < click_count; i++){
+ System.err.println("click# "+(i+1));
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.delay(10);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ robot.delay(50);
+ }
+
+ robot.waitForIdle();
+
+ int deliver_count = this.deliver_count;
+ int expected_count = (click_count + 1) * 3;
+
+ if (deliver_count != expected_count){
+ System.err.println("deliver_count = "+deliver_count+" (!="+expected_count+")");
+ throw new RuntimeException("incorrect behaviour");
+ }
+ }// start()
+
+ private void moveMouseOver(Container c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+ }
+
+ private void waitTillShown(Component c) {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ c.getLocationOnScreen();
+ break;
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ break;
+ } catch (Exception e) {
+ }
+ }
+ }
+ private void makeFocused(Component comp) {
+ if (comp.isFocusOwner()) {
+ return;
+ }
+ final Semaphore sema = new Semaphore();
+ final FocusAdapter fa = new FocusAdapter() {
+ public void focusGained(FocusEvent fe) {
+ sema.raise();
+ }
+ };
+ comp.addFocusListener(fa);
+ comp.requestFocusInWindow();
+ if (comp.isFocusOwner()) {
+ return;
+ }
+ try {
+ sema.doWait(3000);
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ comp.removeFocusListener(fa);
+ if (!comp.isFocusOwner()) {
+ throw new RuntimeException("Can't make " + comp + " focused, current owner is " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+ }
+ }
+
+static class Semaphore {
+ boolean state = false;
+ int waiting = 0;
+ public Semaphore() {
+ }
+ public synchronized void doWait() throws InterruptedException {
+ if (state) {
+ return;
+ }
+ waiting++;
+ wait();
+ waiting--;
+ }
+ public synchronized void doWait(int timeout) throws InterruptedException {
+ if (state) {
+ return;
+ }
+ waiting++;
+ wait(timeout);
+ waiting--;
+ }
+ public synchronized void raise() {
+ state = true;
+ if (waiting > 0) {
+ notifyAll();
+ }
+ }
+ public synchronized boolean getState() {
+ return state;
+ }
+}
+}
--- a/jdk/test/java/awt/List/ActionAfterRemove/ActionAfterRemove.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/List/ActionAfterRemove/ActionAfterRemove.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,27 +33,29 @@
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
public class ActionAfterRemove
{
private static volatile boolean passed = true;
- // handle the uncaught exception
- public void handle(Throwable e) {
- e.printStackTrace();
- passed = false;
- }
-
public static final void main(String args[])
{
+ // In order to handle all uncaught exceptions in the EDT
+ final Thread.UncaughtExceptionHandler eh = new Thread.UncaughtExceptionHandler()
+ {
+ @Override
+ public void uncaughtException(Thread t, Throwable e)
+ {
+ e.printStackTrace();
+ passed = false;
+ }
+ };
+
final Frame frame = new Frame();
final List list = new List();
Robot robot = null;
- // In order to handle all uncaught exceptions in the EDT
- System.setProperty("sun.awt.exception.handler", "ActionAfterRemove");
list.add("will be removed");
frame.add(list);
@@ -72,9 +74,9 @@
}
Util.clickOnComp(list, robot);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
Util.clickOnComp(list, robot);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
if (!passed){
throw new RuntimeException("Test failed: exception was thrown on EDT.");
--- a/jdk/test/java/awt/List/EmptyListEventTest/EmptyListEventTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/List/EmptyListEventTest/EmptyListEventTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,7 +33,6 @@
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
public class EmptyListEventTest {
@@ -41,7 +40,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -53,7 +51,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
// press mouse -> ItemEvent
Point point = getClickPoint();
@@ -61,7 +59,7 @@
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -71,7 +69,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != list) {
throw new RuntimeException("Test failed - list isn't focus owner.");
@@ -80,12 +78,12 @@
// press key ENTER -> ActionEvent
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
// press key SPACE -> ItemEvent
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
- toolkit.realSync();
+ robot.waitForIdle();
// mouse double click -> ActionEvent
robot.setAutoDelay(10);
@@ -93,7 +91,7 @@
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
}
private static Point getClickPoint() throws Exception {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/List/KeyEventsTest/KeyEventsTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+<!--
+ 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.
+
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6190768 6190778
+ @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
+ @author Dmitry.Cherepanov@SUN.COM area=awt.list
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run applet KeyEventsTest.html
+ -->
+<head>
+<title> </title>
+</head>
+<body>
+
+<h1>KeyEventsTest<br>Bug ID: 6190768 6190778 </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="KeyEventsTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/List/KeyEventsTest/KeyEventsTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,370 @@
+/*
+ * 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.
+ *
+ * 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 6190768 6190778
+ @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
+ @author Dmitry.Cherepanov@SUN.COM area=awt.list
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run applet KeyEventsTest.html
+*/
+
+/**
+ * KeyEventsTest.html
+ *
+ * summary:
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.Set;
+import java.lang.reflect.*;
+
+import jdk.testlibrary.OSInfo;
+
+public class KeyEventsTest extends Applet implements ItemListener, FocusListener, KeyListener
+{
+ TestState currentState;
+ final Object LOCK = new Object();
+ final int ACTION_TIMEOUT = 500;
+
+ List single = new List(3, false);
+ List multiple = new List(3, true);
+
+ Panel p1 = new Panel ();
+ Panel p2 = new Panel ();
+
+ public void init()
+ {
+ setLayout (new BorderLayout ());
+
+ single.add("0");
+ single.add("1");
+ single.add("2");
+ single.add("3");
+ single.add("4");
+ single.add("5");
+ single.add("6");
+ single.add("7");
+ single.add("8");
+
+ multiple.add("0");
+ multiple.add("1");
+ multiple.add("2");
+ multiple.add("3");
+ multiple.add("4");
+ multiple.add("5");
+ multiple.add("6");
+ multiple.add("7");
+ multiple.add("8");
+
+ single.addKeyListener(this);
+ single.addItemListener(this);
+ single.addFocusListener(this);
+ p1.add(single);
+ add("North", p1);
+
+ multiple.addKeyListener(this);
+ multiple.addItemListener(this);
+ multiple.addFocusListener(this);
+ p2.add(multiple);
+ add("South", p2);
+
+ }//End init()
+
+ public void start ()
+ {
+
+ try{
+ setSize (200,200);
+ setVisible(true);
+ validate();
+
+ main(null);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("The test failed.");
+ }
+
+ }// start()
+
+ private void main(String[] args)
+ throws InterruptedException, InvocationTargetException {
+
+ doTest();
+
+ System.out.println("Test passed.");
+ }
+
+ public void itemStateChanged (ItemEvent ie) {
+ System.out.println("itemStateChanged-"+ie);
+ this.currentState.setAction(true);
+ }
+
+ public void focusGained(FocusEvent e){
+
+ synchronized (LOCK) {
+ LOCK.notifyAll();
+ }
+
+ }
+
+ public void focusLost(FocusEvent e){
+ }
+
+ public void keyPressed(KeyEvent e){
+ System.out.println("keyPressed-"+e);
+ }
+
+ public void keyReleased(KeyEvent e){
+ System.out.println("keyReleased-"+e);
+ }
+
+ public void keyTyped(KeyEvent e){
+ System.out.println("keyTyped-"+e);
+ }
+
+ private void test(TestState currentState)
+ throws InterruptedException, InvocationTargetException {
+
+ synchronized (LOCK) {
+
+ this.currentState = currentState;
+ System.out.println(this.currentState);
+
+ List list;
+ if (currentState.getMultiple()){
+ list = multiple;
+ }else{
+ list = single;
+ }
+
+ Robot r;
+ try {
+ r = new Robot();
+ } catch(AWTException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+ r.delay(10);
+ Point loc = this.getLocationOnScreen();
+
+ r.mouseMove(loc.x+10, loc.y+10);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ r.delay(10);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ r.delay(10);
+
+ list.requestFocusInWindow();
+ LOCK.wait(ACTION_TIMEOUT);
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != list){
+ throw new RuntimeException("Test failed - list isn't focus owner.");
+ }
+
+ list.deselect(0);
+ list.deselect(1);
+ list.deselect(2);
+ list.deselect(3);
+ list.deselect(4);
+ list.deselect(5);
+ list.deselect(6);
+ list.deselect(7);
+ list.deselect(8);
+
+ int selectIndex = 0;
+ int visibleIndex = 0;
+
+ if (currentState.getScrollMoved()){
+
+ if (currentState.getKeyID() == KeyEvent.VK_PAGE_UP ||
+ currentState.getKeyID() == KeyEvent.VK_HOME){
+ selectIndex = 8;
+ visibleIndex = 8;
+ }else if (currentState.getKeyID() == KeyEvent.VK_PAGE_DOWN ||
+ currentState.getKeyID() == KeyEvent.VK_END){
+ selectIndex = 0;
+ visibleIndex = 0;
+ }
+
+ }else{
+
+ if (currentState.getKeyID() == KeyEvent.VK_PAGE_UP ||
+ currentState.getKeyID() == KeyEvent.VK_HOME){
+
+ if (currentState.getSelectedMoved()){
+ selectIndex = 1;
+ visibleIndex = 0;
+ }else{
+ selectIndex = 0;
+ visibleIndex = 0;
+ }
+
+ }else if (currentState.getKeyID() == KeyEvent.VK_PAGE_DOWN ||
+ currentState.getKeyID() == KeyEvent.VK_END){
+
+ if (currentState.getSelectedMoved()){
+ selectIndex = 7;
+ visibleIndex = 8;
+ }else{
+ selectIndex = 8;
+ visibleIndex = 8;
+ }
+
+ }
+
+ }
+
+ list.select(selectIndex);
+ list.makeVisible(visibleIndex);
+
+ r.delay(10);
+
+ if (currentState.getKeyID() == KeyEvent.VK_HOME ||
+ currentState.getKeyID() == KeyEvent.VK_END){
+ r.keyPress(KeyEvent.VK_CONTROL);
+ }
+
+ r.delay(10);
+ r.keyPress(currentState.getKeyID());
+ r.delay(10);
+ r.keyRelease(currentState.getKeyID());
+ r.delay(10);
+
+ if (currentState.getKeyID() == KeyEvent.VK_HOME ||
+ currentState.getKeyID() == KeyEvent.VK_END){
+ r.keyRelease(KeyEvent.VK_CONTROL);
+ }
+
+ r.waitForIdle();
+ r.delay(200);
+
+ if (currentState.getTemplate() != currentState.getAction())
+ throw new RuntimeException("Test failed.");
+
+ }
+
+ }
+
+ private void doTest()
+ throws InterruptedException, InvocationTargetException {
+
+ boolean isWin = false;
+ if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+ isWin = true;
+ }else if(OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+ System.out.println("Not for OS X");
+ return;
+ }
+
+ System.out.println("multiple? selectedMoved? ?scrollMoved keyID? template? action?");
+ test(new TestState(false, false, false, KeyEvent.VK_PAGE_UP, isWin?false:false));
+ // SelectedMoved (false) != ScrollMoved (true) for single list not emulated
+ test(new TestState(false, true, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
+ test(new TestState(false, true, true, KeyEvent.VK_PAGE_UP, isWin?true:true));
+ test(new TestState(true, false, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
+ test(new TestState(true, false, true, KeyEvent.VK_PAGE_UP, isWin?true:false));
+ test(new TestState(true, true, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
+ test(new TestState(true, true, true, KeyEvent.VK_PAGE_UP, isWin?true:false));
+
+ test(new TestState(false, false, false, KeyEvent.VK_PAGE_DOWN, isWin?false:false));
+ test(new TestState(false, true, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+ test(new TestState(false, true, true, KeyEvent.VK_PAGE_DOWN, isWin?true:true));
+ test(new TestState(true, false, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+ test(new TestState(true, false, true, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+ test(new TestState(true, true, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+ test(new TestState(true, true, true, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
+
+ test(new TestState(false, false, false, KeyEvent.VK_HOME, isWin?false:true));
+ test(new TestState(false, true, false, KeyEvent.VK_HOME, isWin?true:true));
+ test(new TestState(false, true, true, KeyEvent.VK_HOME, isWin?true:true));
+ test(new TestState(true, false, false, KeyEvent.VK_HOME, isWin?true:false));
+ test(new TestState(true, false, true, KeyEvent.VK_HOME, isWin?true:false));
+ test(new TestState(true, true, false, KeyEvent.VK_HOME, isWin?true:false));
+ test(new TestState(true, true, true, KeyEvent.VK_HOME, isWin?true:false));
+
+ test(new TestState(false, false, false, KeyEvent.VK_END, isWin?false:true));
+ test(new TestState(false, true, false, KeyEvent.VK_END, isWin?true:true));
+ test(new TestState(false, true, true, KeyEvent.VK_END, isWin?true:true));
+ test(new TestState(true, false, false, KeyEvent.VK_END, isWin?true:false));
+ test(new TestState(true, false, true, KeyEvent.VK_END, isWin?true:false));
+ test(new TestState(true, true, false, KeyEvent.VK_END, isWin?true:false));
+ test(new TestState(true, true, true, KeyEvent.VK_END, isWin?true:false));
+
+ }
+}// class KeyEventsTest
+
+class TestState{
+
+ private boolean multiple;
+ // after key pressing selected item moved
+ private final boolean selectedMoved;
+ // after key pressing scroll moved
+ private final boolean scrollMoved;
+ private final int keyID;
+ private final boolean template;
+ private boolean action;
+
+ public TestState(boolean multiple, boolean selectedMoved, boolean scrollMoved, int keyID, boolean template){
+ this.multiple = multiple;
+ this.selectedMoved = selectedMoved;
+ this.scrollMoved = scrollMoved;
+ this.keyID = keyID;
+ this.template = template;
+ this.action = false;
+ }
+
+ public boolean getMultiple(){
+ return multiple;
+ }
+ public boolean getSelectedMoved(){
+ return selectedMoved;
+ }
+
+ public boolean getScrollMoved(){
+ return scrollMoved;
+ }
+
+ public int getKeyID(){
+ return keyID;
+ }
+
+ public boolean getTemplate(){
+ return template;
+ }
+
+ public boolean getAction(){
+ return action;
+ }
+
+ public void setAction(boolean action){
+ this.action = action;
+ }
+
+ public String toString(){
+ return multiple + "," + selectedMoved + "," + scrollMoved + "," + keyID + "," + template + "," + action;
+ }
+}// TestState
--- a/jdk/test/java/awt/List/NofocusListDblClickTest/NofocusListDblClickTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/List/NofocusListDblClickTest/NofocusListDblClickTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,14 +32,12 @@
import java.awt.event.*;
import java.util.concurrent.atomic.AtomicInteger;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
public class NofocusListDblClickTest {
static final int EXPECTED_ACTION_COUNT = 2;
static Robot robot;
static final AtomicInteger actionPerformed = new AtomicInteger(0);
static List lst;
- private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@@ -47,16 +45,16 @@
createAndShowGUI();
}
});
- toolkit.realSync();
+ robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
Thread.sleep(1000);
- robot = new Robot();
- robot.setAutoDelay(50);
// ACTION_PERFORMED event happens only on even clicks
clickTwiceOn(lst);
Thread.sleep(500);
clickTwiceOn(lst);
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(1000);
synchronized (actionPerformed) {
--- a/jdk/test/java/awt/List/ScrollOutside/ScrollOut.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/List/ScrollOutside/ScrollOut.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,7 +33,6 @@
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
public class ScrollOut
@@ -54,13 +53,13 @@
frame.setLocationRelativeTo(null);
frame.setVisible(true);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
try{
robot = new Robot();
}catch(AWTException e){
throw new RuntimeException(e);
}
+ robot.waitForIdle();
//Drag from center to the outside on left
Point from = new Point(list.getLocationOnScreen().x + list.getWidth()/2,
@@ -68,16 +67,16 @@
Point to = new Point(list.getLocationOnScreen().x - 30,
from.y);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
//Drag from center to the outside on up
to = new Point(from.x,
list.getLocationOnScreen().y - 50);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
}//End init()
--- a/jdk/test/java/awt/List/SetBackgroundTest/SetBackgroundTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/List/SetBackgroundTest/SetBackgroundTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,6 +26,8 @@
@bug 6246467
@summary List does not honor user specified background, foreground colors on XToolkit
@author Dmitry Cherepanov area=awt.list
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
@run main SetBackgroundTest
*/
@@ -37,29 +39,12 @@
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
public class SetBackgroundTest
{
- private static void init()
- {
- String[] instructions =
- {
- "This is an AUTOMATIC test, simply wait until it is done.",
- "The result (passed or failed) will be shown in the",
- "message window below."
- };
- Sysout.createDialog( );
- Sysout.printInstructions( instructions );
-
- test();
-
- SetBackgroundTest.pass();
- }//End init()
-
private static boolean isXAWT = (Toolkit.getDefaultToolkit().getClass().getName().equals("sun.awt.X11.XToolkit"));
- private static Robot robot = null;
+ private static ExtendedRobot robot = null;
private static Frame frame = null;
private static final Color color = Color.red;
@@ -71,24 +56,24 @@
canvas.setBackground(color);
frame.add(canvas, BorderLayout.CENTER);
frame.validate();
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle(500);
Point loc = canvas.getLocationOnScreen();
Color robotColor = robot.getPixelColor(loc.x + canvas.getWidth()/2, loc.y + canvas.getHeight()/2);
roughColor = robotColor;
- Sysout.println(" --- init rough color ... ");
- Sysout.println(" color = "+color);
- Sysout.println(" roughColor = "+roughColor);
+ System.out.println(" --- init rough color ... ");
+ System.out.println(" color = "+color);
+ System.out.println(" roughColor = "+roughColor);
frame.remove(canvas);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle(500);
}
private static void test() {
if (!isXAWT){
- Sysout.println(" this is XAWT-only test. ");
+ System.out.println(" this is XAWT-only test. ");
return;
}
@@ -97,14 +82,15 @@
frame.setLayout(new BorderLayout());
frame.setVisible(true);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
try{
- robot = new Robot();
+ robot = new ExtendedRobot();
}catch(AWTException e){
throw new RuntimeException(e.getMessage());
}
+ robot.waitForIdle(500);
+
initRoughColor();
Component[] components = new Component[] {
new Button(), new Checkbox(), new Label(), new List(3, false),
@@ -115,6 +101,7 @@
testComponent(new Panel(), component, color);
}
+ robot.waitForIdle(1500);
frame.dispose();
}
@@ -127,327 +114,31 @@
frame.add(container, BorderLayout.CENTER);
frame.add("Center", container);
frame.validate();
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle(500);
Point loc = component.getLocationOnScreen();
Color robotColor = robot.getPixelColor(loc.x + component.getWidth()/2, loc.y + component.getHeight()/2);
- Sysout.println(" --- test ... ");
- Sysout.println(" container = "+container);
- Sysout.println(" component = "+component);
- Sysout.println(" color = "+color);
- Sysout.println(" roughColor = "+roughColor);
- Sysout.println(" robotColor = "+robotColor);
+ System.out.println(" --- test ... ");
+ System.out.println(" container = "+container);
+ System.out.println(" component = "+component);
+ System.out.println(" color = "+color);
+ System.out.println(" roughColor = "+roughColor);
+ System.out.println(" robotColor = "+robotColor);
if(robotColor.getRGB() != roughColor.getRGB()){
throw new RuntimeException(" the case failed. ");
} else {
- Sysout.println(" the case passed. ");
+ System.out.println(" the case passed. ");
}
container.remove(component);
frame.remove(container);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle(500);
}
-
-
- /*****************************************************
- * Standard Test Machinery Section
- * DO NOT modify anything in this section -- it's a
- * standard chunk of code which has all of the
- * synchronisation necessary for the test harness.
- * By keeping it the same in all tests, it is easier
- * to read and understand someone else's test, as
- * well as insuring that all tests behave correctly
- * with the test harness.
- * There is a section following this for test-
- * classes
- ******************************************************/
- private static boolean theTestPassed = false;
- private static boolean testGeneratedInterrupt = false;
- private static String failureMessage = "";
-
- private static Thread mainThread = null;
-
- private static int sleepTime = 300000;
-
- // Not sure about what happens if multiple of this test are
- // instantiated in the same VM. Being static (and using
- // static vars), it aint gonna work. Not worrying about
- // it for now.
- public static void main( String args[] ) throws InterruptedException
+ public static void main( String args[] ) throws Exception
{
- mainThread = Thread.currentThread();
- try
- {
- init();
- }
- catch( TestPassedException e )
- {
- //The test passed, so just return from main and harness will
- // interepret this return as a pass
- return;
- }
- //At this point, neither test pass nor test fail has been
- // called -- either would have thrown an exception and ended the
- // test, so we know we have multiple threads.
-
- //Test involves other threads, so sleep and wait for them to
- // called pass() or fail()
- try
- {
- Thread.sleep( sleepTime );
- //Timed out, so fail the test
- throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
- }
- catch (InterruptedException e)
- {
- //The test harness may have interrupted the test. If so, rethrow the exception
- // so that the harness gets it and deals with it.
- if( ! testGeneratedInterrupt ) throw e;
-
- //reset flag in case hit this code more than once for some reason (just safety)
- testGeneratedInterrupt = false;
-
- if ( theTestPassed == false )
- {
- throw new RuntimeException( failureMessage );
- }
- }
-
- }//main
-
- public static synchronized void setTimeoutTo( int seconds )
- {
- sleepTime = seconds * 1000;
+ test();
}
-
- public static synchronized void pass()
- {
- Sysout.println( "The test passed." );
- Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
- //first check if this is executing in main thread
- if ( mainThread == Thread.currentThread() )
- {
- //Still in the main thread, so set the flag just for kicks,
- // and throw a test passed exception which will be caught
- // and end the test.
- theTestPassed = true;
- throw new TestPassedException();
- }
- theTestPassed = true;
- testGeneratedInterrupt = true;
- mainThread.interrupt();
- }//pass()
-
- public static synchronized void fail()
- {
- //test writer didn't specify why test failed, so give generic
- fail( "it just plain failed! :-)" );
- }
-
- public static synchronized void fail( String whyFailed )
- {
- Sysout.println( "The test failed: " + whyFailed );
- Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
- //check if this called from main thread
- if ( mainThread == Thread.currentThread() )
- {
- //If main thread, fail now 'cause not sleeping
- throw new RuntimeException( whyFailed );
- }
- theTestPassed = false;
- testGeneratedInterrupt = true;
- failureMessage = whyFailed;
- mainThread.interrupt();
- }//fail()
-
-}// class AutomaticMainTest
-
-//This exception is used to exit from any level of call nesting
-// when it's determined that the test has passed, and immediately
-// end the test.
-class TestPassedException extends RuntimeException
-{
}
-//*********** End Standard Test Machinery Section **********
-
-
-//************ Begin classes defined for the test ****************
-
-// if want to make listeners, here is the recommended place for them, then instantiate
-// them in init()
-
-/* Example of a class which may be written as part of a test
-class NewClass implements anInterface
- {
- static int newVar = 0;
-
- public void eventDispatched(AWTEvent e)
- {
- //Counting events to see if we get enough
- eventCount++;
-
- if( eventCount == 20 )
- {
- //got enough events, so pass
-
- AutomaticMainTest.pass();
- }
- else if( tries == 20 )
- {
- //tried too many times without getting enough events so fail
-
- AutomaticMainTest.fail();
- }
-
- }// eventDispatched()
-
- }// NewClass class
-
-*/
-
-
-//************** End classes defined for the test *******************
-
-
-
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
- chunk of code whose purpose is to make user
- interaction uniform, and thereby make it simpler
- to read and understand someone else's test.
- ****************************************************/
-
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
- for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
- WithInstructions method. Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
- with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
- as standalone.
- */
-
-class Sysout
-{
- private static TestDialog dialog;
-
- public static void createDialogWithInstructions( String[] instructions )
- {
- dialog = new TestDialog( new Frame(), "Instructions" );
- dialog.printInstructions( instructions );
- dialog.setVisible(true);
- println( "Any messages for the tester will display here." );
- }
-
- public static void createDialog( )
- {
- dialog = new TestDialog( new Frame(), "Instructions" );
- String[] defInstr = { "Instructions will appear here. ", "" } ;
- dialog.printInstructions( defInstr );
- dialog.setVisible(true);
- println( "Any messages for the tester will display here." );
- }
-
-
- public static void printInstructions( String[] instructions )
- {
- dialog.printInstructions( instructions );
- }
-
-
- public static void println( String messageIn )
- {
- dialog.displayMessage( messageIn );
- System.out.println(messageIn);
- }
-
-}// Sysout class
-
-/**
- This is part of the standard test machinery. It provides a place for the
- test instructions to be displayed, and a place for interactive messages
- to the user to be displayed.
- To have the test instructions displayed, see Sysout.
- To have a message to the user be displayed, see Sysout.
- Do not call anything in this dialog directly.
- */
-class TestDialog extends Dialog
-{
-
- TextArea instructionsText;
- TextArea messageText;
- int maxStringLength = 80;
-
- //DO NOT call this directly, go through Sysout
- public TestDialog( Frame frame, String name )
- {
- super( frame, name );
- int scrollBoth = TextArea.SCROLLBARS_BOTH;
- instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
- add( "North", instructionsText );
-
- messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
- add("Center", messageText);
-
- pack();
-
- setVisible(true);
- }// TestDialog()
-
- //DO NOT call this directly, go through Sysout
- public void printInstructions( String[] instructions )
- {
- //Clear out any current instructions
- instructionsText.setText( "" );
-
- //Go down array of instruction strings
-
- String printStr, remainingStr;
- for( int i=0; i < instructions.length; i++ )
- {
- //chop up each into pieces maxSringLength long
- remainingStr = instructions[ i ];
- while( remainingStr.length() > 0 )
- {
- //if longer than max then chop off first max chars to print
- if( remainingStr.length() >= maxStringLength )
- {
- //Try to chop on a word boundary
- int posOfSpace = remainingStr.
- lastIndexOf( ' ', maxStringLength - 1 );
-
- if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
- printStr = remainingStr.substring( 0, posOfSpace + 1 );
- remainingStr = remainingStr.substring( posOfSpace + 1 );
- }
- //else just print
- else
- {
- printStr = remainingStr;
- remainingStr = "";
- }
-
- instructionsText.append( printStr + "\n" );
-
- }// while
-
- }// for
-
- }//printInstructions()
-
- //DO NOT call this directly, go through Sysout
- public void displayMessage( String messageIn )
- {
- messageText.append( messageIn + "\n" );
- System.out.println(messageIn);
- }
-
-}// TestDialog class
--- a/jdk/test/java/awt/MenuBar/8007006/bug8007006.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/MenuBar/8007006/bug8007006.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,35 +26,38 @@
* @bug 8007006
* @summary [macosx] Closing subwindow loses main window menus.
* @author Leonid Romanov
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot jdk.testlibrary.OSInfo
* @run main bug8007006
*/
-import sun.awt.SunToolkit;
import java.awt.*;
import java.awt.event.*;
+import jdk.testlibrary.OSInfo;
+
public class bug8007006 {
private static Frame frame1;
private static Frame frame2;
public static void main(String[] args) throws Exception {
- if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
+ if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
return;
}
System.setProperty("apple.laf.useScreenMenuBar", "true");
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(50);
+
createAndShowGUI();
- sleep(1500);
+ robot.waitForIdle(1500);
frame2.dispose();
- sleep(1500);
- SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
+ robot.waitForIdle(1500);
- Robot robot = new Robot();
- robot.setAutoDelay(50);
// open "Apple" menu (the leftmost one)
robot.keyPress(KeyEvent.VK_META);
@@ -74,7 +77,7 @@
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
- sleep(0);
+ robot.waitForIdle();
MenuBar mbar = frame1.getMenuBar();
Menu menu = mbar.getMenu(0);
@@ -112,13 +115,4 @@
return mbar;
}
- private static void sleep(int ms) {
- SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
- tk.realSync();
-
- try {
- Thread.sleep(ms);
- } catch (Exception ignore) {
- }
- }
}
--- a/jdk/test/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java Wed Jul 05 20:11:52 2017 +0200
@@ -21,8 +21,6 @@
* questions.
*/
-import sun.awt.SunToolkit;
-
import java.awt.Button;
import java.awt.CardLayout;
import java.awt.Font;
@@ -31,16 +29,19 @@
import java.awt.MenuBar;
import java.awt.Point;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
+import jdk.testlibrary.OSInfo;
+
/**
* @test
* @bug 6263470
* @summary Tries to change font of MenuBar. Test passes if the font has changed
* fails otherwise.
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
* @author Vyacheslav.Baranov: area=menu
* @run main MenuBarSetFont
*/
@@ -66,7 +67,7 @@
public static void main(final String[] args) throws Exception {
- if (sun.awt.OSInfo.getOSType() == sun.awt.OSInfo.OSType.MACOSX) {
+ if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
System.err.println("This test is not for OS X. Menu.setFont() is not supported on OS X.");
return;
}
@@ -75,13 +76,16 @@
frame.setMenuBar(mb);
mb.setFont(new Font("Helvetica", Font.ITALIC, 5));
+ final Robot r = new Robot();
+ r.setAutoDelay(200);
+
final Button button = new Button("Click Me");
button.addActionListener(new Listener());
frame.setLayout(new CardLayout());
frame.add(button, "First");
frame.setSize(400, 400);
frame.setVisible(true);
- sleep();
+ sleep(r);
final int fInsets = frame.getInsets().top; //Frame insets without menu.
addMenu();
@@ -96,24 +100,23 @@
mb.remove(0);
frame.validate();
- sleep();
+ sleep(r);
// Test execution.
// On XToolkit, menubar font should be changed to 60.
// On WToolkit, menubar font should be changed to default and menubar
// should be splitted in 2 rows.
mb.setFont(new Font("Helvetica", Font.ITALIC, 60));
- sleep();
- final Robot r = new Robot();
- r.setAutoDelay(200);
+ sleep(r);
+
final Point pt = frame.getLocation();
r.mouseMove(pt.x + frame.getWidth() / 2,
pt.y + fMenuInsets + menuBarHeight / 2);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
- sleep();
+ sleep(r);
frame.dispose();
if (clicked) {
@@ -121,8 +124,8 @@
}
}
- private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ private static void sleep(Robot robot) {
+ robot.waitForIdle();
try {
Thread.sleep(500L);
} catch (InterruptedException ignored) {
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/OverlappingTestBase.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,7 +29,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import javax.swing.*;
-import sun.awt.*;
+import sun.awt.EmbeddedFrame;
import java.io.*;
import test.java.awt.regtesthelpers.Util;
@@ -141,7 +141,6 @@
public void getVerifyColor() {
try {
final int size = 200;
- final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
final Point[] p = new Point[1];
SwingUtilities.invokeAndWait(new Runnable() {
public void run(){
@@ -155,7 +154,7 @@
}
});
Robot robot = new Robot();
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(ROBOT_DELAY);
AWT_VERIFY_COLOR = robot.getPixelColor(p[0].x+size/2, p[0].y+size/2);
System.out.println("Color will be compared with " + AWT_VERIFY_COLOR + " instead of " + AWT_BACKGROUND_COLOR);
@@ -434,6 +433,11 @@
protected Component currentAwtControl;
private void testComponent(Component component) throws InterruptedException, InvocationTargetException {
+ Robot robot = null;
+ try {
+ robot = new Robot();
+ }catch(Exception ignorex) {
+ }
currentAwtControl = component;
System.out.println("Testing " + currentAwtControl.getClass().getSimpleName());
SwingUtilities.invokeAndWait(new Runnable() {
@@ -444,7 +448,7 @@
if (component != null) {
Util.waitTillShown(component);
}
- Util.waitForIdle(null);
+ Util.waitForIdle(robot);
try {
Thread.sleep(500); // wait for graphic effects on systems like Win7
} catch (InterruptedException ex) {
@@ -461,6 +465,11 @@
}
private void testEmbeddedFrame() throws InvocationTargetException, InterruptedException {
+ Robot robot = null;
+ try {
+ robot = new Robot();
+ }catch(Exception ignorex) {
+ }
System.out.println("Testing EmbeddedFrame");
currentAwtControl = null;
SwingUtilities.invokeAndWait(new Runnable() {
@@ -468,7 +477,7 @@
prepareControls();
}
});
- Util.waitForIdle(null);
+ Util.waitForIdle(robot);
try {
Thread.sleep(500); // wait for graphic effects on systems like Win7
} catch (InterruptedException ex) {
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java Wed Jul 05 20:11:52 2017 +0200
@@ -135,7 +135,7 @@
// get coord
Point lLoc = !debug ? testedComponent.getLocationOnScreen() : new Point(70, 30);
- Util.waitForIdle(null);
+ Util.waitForIdle(robot);
/* this is a workaround for certain jtreg(?) focus issue:
tests fail starting after failing mixing tests but always pass alone.
*/
@@ -152,7 +152,7 @@
}
clickAndBlink(robot, lLoc);
- Util.waitForIdle(null);
+ Util.waitForIdle(robot);
return wasLWClicked;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogAppModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks an application modal Dialog
+ * created with a null Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogAppModal1Test
+ */
+
+public class FileDialogAppModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.APPLICATION_MODAL,
+ FileDialogFWDTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogAppModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks an application modal Dialog
+ * created with a null Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogAppModal2Test
+ */
+
+public class FileDialogAppModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.APPLICATION_MODAL,
+ FileDialogFWDTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogAppModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks an application modal Dialog
+ * created with a hidden Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogAppModal3Test
+ */
+
+public class FileDialogAppModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.APPLICATION_MODAL,
+ FileDialogFWDTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogAppModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks an application modal Dialog
+ * created with a hidden Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogAppModal4Test
+ */
+
+public class FileDialogAppModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.APPLICATION_MODAL,
+ FileDialogFWDTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogAppModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks an application modal Dialog
+ * created with a visible Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogAppModal5Test
+ */
+
+public class FileDialogAppModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.APPLICATION_MODAL,
+ FileDialogFWDTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogAppModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks an application modal Dialog
+ * created with a visible Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogAppModal6Test
+ */
+
+public class FileDialogAppModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogDWDTest(Dialog.ModalityType.APPLICATION_MODAL)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogDWDTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,233 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+
+
+// DWD: Dialog, Window, Dialog
+
+public class FileDialogDWDTest {
+
+ private volatile FileDialog fileDialog;
+ private volatile ParentDialog parent;
+ private volatile CustomDialog dialog;
+ private volatile TestWindow window;
+
+ private static final int delay = 500;
+ private final ExtendedRobot robot;
+
+ boolean setModal;
+
+ Dialog.ModalityType modalityType;
+
+ private FileDialogDWDTest(Dialog.ModalityType modType,
+ boolean modal) throws Exception {
+ modalityType = modType;
+ setModal = modal;
+
+ robot = new ExtendedRobot();
+ EventQueue.invokeLater(this::createGUI);
+ }
+
+ public FileDialogDWDTest(Dialog.ModalityType modalityType) throws Exception {
+ this(modalityType, false);
+ }
+
+ public FileDialogDWDTest() throws Exception {
+ this(null, true);
+ }
+
+ private void createGUI() {
+
+ parent = new ParentDialog();
+ dialog = new CustomDialog(parent);
+
+ if (setModal) {
+ dialog.setModal(true);
+ modalityType = dialog.getModalityType();
+ } else if (modalityType != null) {
+ dialog.setModalityType(modalityType);
+ }
+
+ window = new CustomWindow(parent);
+
+ int x = Toolkit.getDefaultToolkit().getScreenSize().width -
+ parent.getWidth() - 50;
+ int y = 50;
+ parent.setLocation(x, y);
+ y += (parent.getHeight() + 50);
+ window.setLocation(x, y);
+ y += (window.getHeight() + 50);
+ dialog.setLocation(x, y);
+
+ parent.setVisible(true);
+ }
+
+ private void openAll() throws Exception {
+ robot.waitForIdle(delay);
+ parent.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ window.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ dialog.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ }
+
+ private void checkBlockedWindows() throws Exception {
+
+ String msg = "FileDialog should block this ";
+ parent.checkBlockedDialog(robot, msg + "Dialog.");
+ robot.waitForIdle(delay);
+ window.checkBlockedWindow(robot, msg + "Window.");
+ robot.waitForIdle(delay);
+ dialog.checkBlockedDialog(robot, msg + "Dialog.");
+ robot.waitForIdle(delay);
+ }
+
+ private void checkUnblockedWindows() throws Exception {
+
+ String msg = "Blocking dialogs were closed.";
+ parent.checkUnblockedDialog(robot, msg + "Frame.");
+ robot.waitForIdle(delay);
+ window.checkUnblockedWindow(robot, msg + "Window.");
+ robot.waitForIdle(delay);
+ }
+
+
+ private void modalTest(String type) throws Exception {
+
+ checkBlockedWindows();
+
+ EventQueue.invokeAndWait(() -> { fileDialog.dispose(); });
+ robot.waitForIdle(delay);
+
+ String msg = "FileDialog was closed, " +
+ "but the " + type + " modal dialog should block this ";
+
+ parent.checkBlockedDialog(robot, msg + "Dialog.");
+ robot.waitForIdle(delay);
+
+ window.checkBlockedWindow(robot, msg + "Window.");
+ robot.waitForIdle(delay);
+
+ dialog.checkUnblockedDialog(robot, "FileDialog was closed.");
+ robot.waitForIdle(delay);
+
+ dialog.clickCloseButton(robot);
+ robot.waitForIdle(delay);
+
+ checkUnblockedWindows();
+ }
+
+ private void nonModalTest() throws Exception {
+
+ checkBlockedWindows();
+
+ EventQueue.invokeAndWait(() -> { fileDialog.dispose(); });
+ robot.waitForIdle(delay);
+
+ dialog.checkUnblockedDialog(robot, "FileDialog was closed.");
+ robot.waitForIdle(delay);
+
+ checkUnblockedWindows();
+ }
+
+ public void doTest() throws Exception {
+
+ try {
+
+ openAll();
+
+ if (modalityType == null) {
+ nonModalTest();
+ return;
+ }
+
+ switch (modalityType) {
+ case APPLICATION_MODAL:
+ modalTest("application");
+ break;
+ case DOCUMENT_MODAL:
+ modalTest("document");
+ break;
+ case TOOLKIT_MODAL:
+ modalTest("toolkit");
+ break;
+ case MODELESS:
+ nonModalTest();
+ break;
+ }
+
+ } finally {
+ EventQueue.invokeAndWait(this::closeAll);
+ }
+ }
+
+ private void closeAll() {
+ if (parent != null) { parent.dispose(); }
+ if (dialog != null) { dialog.dispose(); }
+ if (window != null) { window.dispose(); }
+ if (fileDialog != null) { fileDialog.dispose(); }
+
+ }
+
+ class ParentDialog extends TestDialog {
+
+ public ParentDialog() { super((Frame) null); }
+
+ @Override
+ public void doOpenAction() {
+ if (window != null) { window.setVisible(true); }
+ }
+
+ }
+
+
+ class CustomDialog extends TestDialog {
+
+ public CustomDialog(Dialog d) { super(d); }
+
+ @Override
+ public void doOpenAction() {
+ fileDialog = new FileDialog((Frame) null);
+ fileDialog.setLocation(50, 50);
+ fileDialog.setVisible(true);
+ }
+
+ @Override
+ public void doCloseAction() {
+ this.dispose();
+ }
+ }
+
+ class CustomWindow extends TestWindow {
+
+ public CustomWindow(Dialog d) { super(d); }
+
+ @Override
+ public void doOpenAction() {
+ if (dialog != null) { dialog.setVisible(true); }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogDocModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a document modal Dialog
+ * created with a null Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogDocModal1Test
+ */
+
+public class FileDialogDocModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ FileDialogFWDTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogDocModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a document modal Dialog
+ * created with a null Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogDocModal2Test
+ */
+
+public class FileDialogDocModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ FileDialogFWDTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogDocModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a document modal Dialog
+ * created with a hidden Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogDocModal3Test
+ */
+
+public class FileDialogDocModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ FileDialogFWDTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogDocModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a document modal Dialog
+ * created with a hidden Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogDocModal4Test
+ */
+
+public class FileDialogDocModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ FileDialogFWDTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogDocModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a document modal Dialog
+ * created with a visible Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogDocModal5Test
+ */
+
+public class FileDialogDocModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ FileDialogFWDTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogDocModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a document modal Dialog
+ * created with a visible Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogDocModal6Test
+ */
+
+public class FileDialogDocModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogDWDTest(Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogDocModal7Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ * @summary Check whether a FileDialog set to document modality behaves as expected.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogDocModal7Test
+ */
+
+public class FileDialogDocModal7Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogModalityTest(Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogFWDTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,291 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+
+
+// FWD: Frame, Window, Dialog
+
+public class FileDialogFWDTest {
+
+ private volatile FileDialog fileDialog;
+ private volatile CustomDialog dialog;
+ private volatile TestFrame frame;
+ private volatile TestWindow window;
+
+ private static final int delay = 500;
+ private final ExtendedRobot robot;
+
+ private volatile Dialog hiddenDialog;
+ private volatile Frame hiddenFrame;
+
+ public enum DialogOwner {
+ HIDDEN_DIALOG, NULL_DIALOG, HIDDEN_FRAME, NULL_FRAME, FRAME};
+
+ private DialogOwner owner;
+ boolean setModal;
+
+ Dialog.ModalityType modalityType;
+
+ private FileDialogFWDTest(Dialog.ModalityType modType,
+ boolean modal,
+ DialogOwner o) throws Exception {
+ modalityType = modType;
+ setModal = modal;
+ owner = o;
+
+ robot = new ExtendedRobot();
+ EventQueue.invokeLater(this::createGUI);
+ }
+
+ public FileDialogFWDTest(Dialog.ModalityType modalityType,
+ DialogOwner o) throws Exception {
+ this(modalityType, false, o);
+ }
+
+ public FileDialogFWDTest(DialogOwner o) throws Exception {
+ this(null, true, o);
+ }
+
+ private void createGUI() {
+
+ frame = new CustomFrame();
+
+ switch (owner) {
+ case HIDDEN_DIALOG:
+ hiddenDialog = new Dialog((Frame) null);
+ dialog = new CustomDialog(hiddenDialog);
+ break;
+ case NULL_DIALOG:
+ dialog = new CustomDialog((Dialog) null);
+ break;
+ case HIDDEN_FRAME:
+ hiddenFrame = new Frame();
+ dialog = new CustomDialog(hiddenFrame);
+ break;
+ case NULL_FRAME:
+ dialog = new CustomDialog((Frame) null);
+ break;
+ case FRAME:
+ dialog = new CustomDialog(frame);
+ break;
+ }
+
+ if (setModal) {
+ dialog.setModal(true);
+ modalityType = dialog.getModalityType();
+ } else if (modalityType != null) {
+ dialog.setModalityType(modalityType);
+ }
+
+ window = new CustomWindow(frame);
+
+ int x = Toolkit.getDefaultToolkit().getScreenSize().width -
+ frame.getWidth() - 50;
+ int y = 50;
+ frame.setLocation(x, y);
+ y += (frame.getHeight() + 50);
+ window.setLocation(x, y);
+ y += (window.getHeight() + 50);
+ dialog.setLocation(x, y);
+
+ frame.setVisible(true);
+ }
+
+ private void openAll() throws Exception {
+ robot.waitForIdle(delay);
+ frame.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ window.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ dialog.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ }
+
+ private void checkBlockedWindows() throws Exception {
+
+ String msg = "FileDialog should block this ";
+ frame.checkBlockedFrame(robot, msg + "Frame.");
+ robot.waitForIdle(delay);
+ window.checkBlockedWindow(robot, msg + "Window.");
+ robot.waitForIdle(delay);
+ dialog.checkBlockedDialog(robot, msg + "Dialog.");
+ robot.waitForIdle(delay);
+ }
+
+ private void checkUnblockedWindows() throws Exception {
+
+ String msg = "Blocking dialogs were closed.";
+ frame.checkUnblockedFrame(robot, msg + "Frame.");
+ robot.waitForIdle(delay);
+ window.checkUnblockedWindow(robot, msg + "Window.");
+ robot.waitForIdle(delay);
+ }
+
+ private void modalTest(String type) throws Exception {
+
+ checkBlockedWindows();
+
+ EventQueue.invokeAndWait(() -> { fileDialog.dispose(); });
+ robot.waitForIdle(delay);
+
+ String msg = "FileDialog was closed, " +
+ "but the " + type + " modal dialog should block this ";
+
+ frame.checkBlockedFrame(robot, msg + "Frame.");
+ robot.waitForIdle(delay);
+
+ window.checkBlockedWindow(robot, msg + "Window.");
+ robot.waitForIdle(delay);
+
+ dialog.checkUnblockedDialog(robot, "FileDialog was closed.");
+ robot.waitForIdle(delay);
+
+ dialog.clickCloseButton(robot);
+ robot.waitForIdle(delay);
+
+ checkUnblockedWindows();
+ }
+
+ private void docModalTest() throws Exception {
+
+ if (owner == DialogOwner.FRAME) {
+
+ checkBlockedWindows();
+
+ EventQueue.invokeAndWait(() -> { fileDialog.dispose(); });
+ robot.waitForIdle(delay);
+
+ String msg = "FileDialog was closed.";
+
+ dialog.checkUnblockedDialog(robot, msg);
+ robot.waitForIdle(delay);
+
+ msg += " But the blocking document modal dialog is still open.";
+
+ frame.checkBlockedFrame(robot, msg);
+ robot.waitForIdle(delay);
+
+ window.checkBlockedWindow(robot, msg);
+ robot.waitForIdle(delay);
+
+ dialog.clickCloseButton(robot);
+ robot.waitForIdle(delay);
+
+ checkUnblockedWindows();
+
+ } else {
+ nonModalTest();
+ }
+ }
+
+ private void nonModalTest() throws Exception {
+
+ checkBlockedWindows();
+
+ EventQueue.invokeAndWait(() -> { fileDialog.dispose(); });
+ robot.waitForIdle(delay);
+
+ dialog.checkUnblockedDialog(robot, "FileDialog was closed.");
+ robot.waitForIdle(delay);
+
+ checkUnblockedWindows();
+ }
+
+ public void doTest() throws Exception {
+
+ try {
+ openAll();
+
+ if (modalityType == null) {
+ nonModalTest();
+ return;
+ }
+
+ switch (modalityType) {
+ case APPLICATION_MODAL:
+ modalTest("application");
+ break;
+ case DOCUMENT_MODAL:
+ docModalTest();
+ break;
+ case TOOLKIT_MODAL:
+ modalTest("toolkit");
+ break;
+ case MODELESS:
+ nonModalTest();
+ break;
+ }
+
+ } finally {
+ EventQueue.invokeAndWait(this::closeAll);
+ }
+ }
+
+ private void closeAll() {
+ if (dialog != null) { dialog.dispose(); }
+ if (frame != null) { frame.dispose(); }
+ if (window != null) { window.dispose(); }
+ if (fileDialog != null) { fileDialog.dispose(); }
+ if (hiddenDialog != null) { hiddenDialog.dispose(); }
+ if (hiddenFrame != null) { hiddenFrame.dispose(); }
+ }
+
+
+ class CustomDialog extends TestDialog {
+
+ public CustomDialog(Dialog d) { super(d); }
+ public CustomDialog(Frame f) { super(f); }
+
+ @Override
+ public void doOpenAction() {
+ fileDialog = new FileDialog((Frame) null);
+ fileDialog.setLocation(50, 50);
+ fileDialog.setVisible(true);
+ }
+
+ @Override
+ public void doCloseAction() {
+ this.dispose();
+ }
+ }
+
+ class CustomFrame extends TestFrame {
+
+ @Override
+ public void doOpenAction() {
+ if (window != null) { window.setVisible(true); }
+ }
+ }
+
+ class CustomWindow extends TestWindow {
+
+ public CustomWindow(Frame f) { super(f); }
+
+ @Override
+ public void doOpenAction() {
+ if (dialog != null) { dialog.setVisible(true); }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a modal Dialog
+ * created with a null Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogModal1Test
+ */
+
+public class FileDialogModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(
+ FileDialogFWDTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a modal Dialog
+ * created with a null Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogModal2Test
+ */
+
+public class FileDialogModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(
+ FileDialogFWDTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a modal Dialog
+ * created with a hidden Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogModal3Test
+ */
+
+public class FileDialogModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(
+ FileDialogFWDTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a modal Dialog
+ * created with a hidden Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogModal4Test
+ */
+
+public class FileDialogModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(
+ FileDialogFWDTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a modal Dialog
+ * created with a visible Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogModal5Test
+ */
+
+public class FileDialogModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(
+ FileDialogFWDTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * 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 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a modal Dialog
+ * created with a visible Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogModal6Test
+ */
+
+public class FileDialogModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogDWDTest()).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogModalityTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,180 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+public class FileDialogModalityTest {
+
+ private volatile TestDialog dialog;
+ private volatile ParentFrame parent;
+ private volatile TestWindow window;
+ private volatile FileDialog fileDialog;
+
+ private static final int delay = 500;
+ private final ExtendedRobot robot;
+
+ private final Dialog.ModalityType modalityType;
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogModalityTest(Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+ (new FileDialogModalityTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+ (new FileDialogModalityTest(Dialog.ModalityType.MODELESS)).doTest();
+ }
+
+ public FileDialogModalityTest(Dialog.ModalityType t) throws Exception {
+ modalityType = t;
+ robot = new ExtendedRobot();
+ }
+
+ private void createGUI() {
+
+ parent = new ParentFrame();
+ dialog = new CustomDialog((Frame) null);
+ window = new CustomWindow(parent);
+
+ int x = Toolkit.getDefaultToolkit().getScreenSize().width -
+ parent.getWidth() - 50;
+ int y = 50;
+
+ parent.setLocation(x, y);
+ y += (parent.getHeight() + 50);
+ window.setLocation(x, y);
+ y += (window.getHeight() + 50);
+ dialog.setLocation(x, y);
+
+ parent.setVisible(true);
+ }
+
+ private void startTest() throws Exception {
+
+ EventQueue.invokeLater(this::createGUI);
+
+ robot.waitForIdle(delay);
+ parent.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ window.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ dialog.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+ }
+
+ private void checkUnblockedWindows() throws Exception {
+
+ String msg = " should not be blocked.";
+ parent.checkUnblockedFrame (robot, "This frame" + msg);
+ robot.waitForIdle(delay);
+ window.checkUnblockedWindow(robot, "This window" + msg);
+ robot.waitForIdle(delay);
+ dialog.checkUnblockedDialog(robot, "This dialog" + msg);
+ robot.waitForIdle(delay);
+ }
+
+ private void checkBlockedWindows() throws Exception {
+
+ String msg = " should be blocked by the FileDialog.";
+ parent.checkBlockedFrame (robot, "This Frame" + msg);
+ robot.waitForIdle(delay);
+ window.checkBlockedWindow(robot, "This Window" + msg);
+ robot.waitForIdle(delay);
+ dialog.checkBlockedDialog(robot, "This Dialog" + msg);
+ robot.waitForIdle(delay);
+ }
+
+ private void docModalTest() throws Exception {
+
+ String msg = "Document modal FileDialog should ";
+ parent.checkUnblockedFrame (robot, msg + "not block this Frame.");
+ robot.waitForIdle(delay);
+ window.checkUnblockedWindow(robot, msg + "not block this Window.");
+ robot.waitForIdle(delay);
+ dialog.checkBlockedDialog(robot, msg + "block its parent Dialog.");
+ robot.waitForIdle(delay);
+ }
+
+ public void doTest() throws Exception {
+
+ try {
+ startTest();
+
+ switch (modalityType) {
+ case APPLICATION_MODAL:
+ case TOOLKIT_MODAL:
+ checkBlockedWindows();
+ break;
+ case DOCUMENT_MODAL:
+ docModalTest();
+ break;
+ case MODELESS:
+ checkUnblockedWindows();
+ break;
+ }
+
+ EventQueue.invokeAndWait(() -> { fileDialog.dispose(); });
+ robot.waitForIdle(delay);
+
+ if (modalityType != Dialog.ModalityType.MODELESS) {
+ checkUnblockedWindows();
+ }
+ } finally {
+ EventQueue.invokeLater(this::closeAll);
+ }
+ }
+
+ private void closeAll() {
+ if (parent != null) { parent.dispose(); }
+ if (dialog != null) { dialog.dispose(); }
+ if (window != null) { window.dispose(); }
+ if (fileDialog != null) { fileDialog.dispose(); }
+ }
+
+ class ParentFrame extends TestFrame {
+
+ @Override
+ public void doOpenAction() {
+ if (window != null) { window.setVisible(true); }
+ }
+ }
+
+ class CustomDialog extends TestDialog {
+
+ public CustomDialog(Frame f) { super(f); }
+
+ @Override
+ public void doOpenAction() {
+ fileDialog = new FileDialog(this);
+ fileDialog.setModalityType(modalityType);
+ fileDialog.setLocation(50, 50);
+ fileDialog.setVisible(true);
+ }
+ }
+
+ class CustomWindow extends TestWindow {
+
+ public CustomWindow(TestFrame f) { super(f); }
+
+ @Override
+ public void doOpenAction() {
+ if (dialog != null) { dialog.setVisible(true); }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogNonModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359 7186009
+ *
+ * @summary Check whether FileDialog blocks a non-modal Dialog
+ * created with a null Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogNonModal1Test
+ */
+
+public class FileDialogNonModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(null,
+ FileDialogFWDTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogNonModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359
+ *
+ * @summary Check whether FileDialog blocks a non-modal Dialog
+ * created with a null Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogNonModal2Test
+ */
+
+public class FileDialogNonModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(null,
+ FileDialogFWDTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogNonModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359
+ *
+ * @summary Check whether FileDialog blocks a non-modal Dialog
+ * created with a hidden Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogNonModal3Test
+ */
+
+public class FileDialogNonModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(null,
+ FileDialogFWDTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogNonModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359
+ *
+ * @summary Check whether FileDialog blocks a non-modal Dialog
+ * created with a hidden Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogNonModal4Test
+ */
+
+public class FileDialogNonModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(null,
+ FileDialogFWDTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogNonModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 8054359
+ *
+ * @summary Check whether FileDialog blocks a non-modal Dialog
+ * created with a visible Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogNonModal5Test
+ */
+
+public class FileDialogNonModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(null,
+ FileDialogFWDTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogNonModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * 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 8054359
+ *
+ * @summary Check whether FileDialog blocks a non-modal Dialog
+ * created with a visible Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogNonModal6Test
+ */
+
+public class FileDialogNonModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogDWDTest(null)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogNonModal7Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359
+ * @summary Check whether a modeless FileDialog behaves as expected.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogNonModal7Test
+ */
+
+public class FileDialogNonModal7Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogModalityTest(Dialog.ModalityType.MODELESS)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogTKModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 8055752
+ *
+ * @summary Check whether FileDialog blocks a toolkit modal Dialog
+ * created with a null Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogTKModal1Test
+ */
+
+public class FileDialogTKModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ FileDialogFWDTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogTKModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 8055752
+ *
+ * @summary Check whether FileDialog blocks a toolkit modal Dialog
+ * created with a null Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogTKModal2Test
+ */
+
+public class FileDialogTKModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ FileDialogFWDTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogTKModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 8055752
+ *
+ * @summary Check whether FileDialog blocks a toolkit modal Dialog
+ * created with a hidden Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogTKModal3Test
+ */
+
+public class FileDialogTKModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ FileDialogFWDTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogTKModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 8055752
+ *
+ * @summary Check whether FileDialog blocks a toolkit modal Dialog
+ * created with a hidden Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogTKModal4Test
+ */
+
+public class FileDialogTKModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ FileDialogFWDTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogTKModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 8055752
+ *
+ * @summary Check whether FileDialog blocks a toolkit modal Dialog
+ * created with a visible Frame constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogTKModal5Test
+ */
+
+public class FileDialogTKModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogFWDTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ FileDialogFWDTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogTKModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 8055752
+ *
+ * @summary Check whether FileDialog blocks a toolkit modal Dialog
+ * created with a visible Dialog constructor. Also check if other
+ * windows are blocked by the FileDialog too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogTKModal6Test
+ */
+
+public class FileDialogTKModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogDWDTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/FileDialog/FileDialogTKModal7Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054359 7186009
+ * @summary Check whether a FileDialog set to toolkit modality behaves as expected.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main FileDialogTKModal7Test
+ */
+
+public class FileDialogTKModal7Test {
+
+ public static void main(String[] args) throws Exception {
+ (new FileDialogModalityTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+ }
+}
--- a/jdk/test/java/awt/Modal/ModalDialogOrderingTest/ModalDialogOrderingTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Modal/ModalDialogOrderingTest/ModalDialogOrderingTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,13 +29,13 @@
import java.awt.Toolkit;
import java.awt.event.InputEvent;
-import sun.awt.SunToolkit;
-
/**
* @test
* @bug 8008728
* @summary [macosx] Swing. JDialog. Modal dialog goes to background
* @author Alexandr Scherbatiy
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
* @run main ModalDialogOrderingTest
*/
public class ModalDialogOrderingTest {
@@ -69,12 +69,12 @@
private static void runTest(Dialog dialog, Frame frame) {
try {
- Robot robot = new Robot();
+ ExtendedRobot robot = new ExtendedRobot();
robot.setAutoDelay(50);
robot.mouseMove(300, 300);
while (!dialog.isVisible()) {
- sleep();
+ robot.waitForIdle(1000);
}
Rectangle dialogBounds = dialog.getBounds();
@@ -89,30 +89,23 @@
robot.mouseMove(clickX, clickY);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- sleep();
+ robot.waitForIdle(1000);
int colorX = dialogBounds.x + dialogBounds.width / 2;
int colorY = dialogBounds.y + dialogBounds.height / 2;
Color color = robot.getPixelColor(colorX, colorY);
- dialog.dispose();
- frame.dispose();
if (!DIALOG_COLOR.equals(color)) {
throw new RuntimeException("The frame is on top"
+ " of the modal dialog!");
+ }else{
+ frame.dispose();
+ dialog.dispose();
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
-
- private static void sleep() {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignored) {
- }
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
- }
}
--- a/jdk/test/java/awt/Modal/ModalInternalFrameTest/ModalInternalFrameTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Modal/ModalInternalFrameTest/ModalInternalFrameTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,11 +34,10 @@
import javax.swing.*;
-import sun.awt.*;
-
public class ModalInternalFrameTest
{
private boolean passed = true;
+ private static Robot r;
private JDesktopPane pane1;
private JDesktopPane pane2;
@@ -139,13 +138,12 @@
r.mouseMove(p.x, p.y);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ r.waitForIdle();
}
private void start()
throws Exception
{
- Robot r = new Robot();
r.setAutoDelay(200);
unblocked1 = false;
@@ -193,6 +191,7 @@
public static void main(String[] args)
throws Exception
{
+ r = new Robot();
test = new ModalInternalFrameTest();
SwingUtilities.invokeAndWait(new Runnable()
{
@@ -201,7 +200,7 @@
test.init();
}
});
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ r.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable()
{
public void run()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,44 @@
+<!--
+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
+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.
+-->
+
+<html>
+<head>
+<title> PrintDialogsTest </title>
+</head>
+<body>
+<applet code="PrintDialogsTest.class" width=250 height=350></applet>
+
+Please select dialog modality type and parent; also select
+the print auxiliary dialog to be displayed (Page Setup or Print dialog).
+Then click "Start test" button.
+
+When the windows will appear check if modal blocking for Dialog works as expected.
+Then push "Open" button on the Dialog to show the auxiliary dialog and check
+if it blocks the rest of the application. Then close it and check correctness
+of modal blocking behavior for the Dialog again. To close all the test
+windows please push "Finish" button.
+
+To finish the overall test push "Pass" or "Fail" button depending on result.
+
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,160 @@
+/*
+ * 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
+ * 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 8055836 8057694 8055752
+ * @summary Check if Print and Page Setup dialogs lock other windows;
+ * check also correctness of modal behavior for other dialogs.
+ *
+ * @run applet/manual=yesno PrintDialogsTest.html
+ */
+
+
+import java.applet.Applet;
+import java.awt.*;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+
+public class PrintDialogsTest extends Applet implements ActionListener {
+
+ private Button btnTest;
+ private Checkbox cbPage, cbPrint,
+ cbNullDlg, cbNullFrm, cbHiddDlg, cbHiddFrm, cbDlg, cbFrm,
+ cbModal, cbAppModal, cbTKModal, cbDocModal, cbModeless, cbNonModal;
+
+ private CheckboxGroup groupDialog, groupParent, groupModType;
+
+
+ public void actionPerformed(ActionEvent e) {
+
+ if (!btnTest.equals(e.getSource())) { return; }
+
+ boolean isPrintDlg = groupDialog.getSelectedCheckbox().equals(cbPrint);
+
+ Test.DialogParent p = null;
+ Checkbox cbParent = groupParent.getSelectedCheckbox();
+ if (cbParent.equals(cbNullDlg)) {
+ p = Test.DialogParent.NULL_DIALOG;
+ } else if (cbParent.equals(cbNullFrm)) {
+ p = Test.DialogParent.NULL_FRAME;
+ } else if (cbParent.equals(cbHiddDlg)) {
+ p = Test.DialogParent.HIDDEN_DIALOG;
+ } else if (cbParent.equals(cbHiddFrm)) {
+ p = Test.DialogParent.HIDDEN_FRAME;
+ } else if (cbParent.equals(cbDlg)) {
+ p = Test.DialogParent.DIALOG;
+ } else if (cbParent.equals(cbFrm)) {
+ p = Test.DialogParent.FRAME;
+ }
+
+ boolean modal = false;
+ Dialog.ModalityType type = null;
+ Checkbox cbModType = groupModType.getSelectedCheckbox();
+ if (cbModType.equals(cbModal)) {
+ modal = true;
+ } else if (cbModType.equals(cbNonModal)) {
+ modal = false;
+ } else if (cbModType.equals(cbAppModal)) {
+ type = Dialog.ModalityType.APPLICATION_MODAL;
+ } else if (cbModType.equals(cbDocModal)) {
+ type = Dialog.ModalityType.DOCUMENT_MODAL;
+ } else if (cbModType.equals(cbTKModal)) {
+ type = Dialog.ModalityType.TOOLKIT_MODAL;
+ } else if (cbModType.equals(cbModeless)) {
+ type = Dialog.ModalityType.MODELESS;
+ }
+
+ if (type == null) {
+ (new Test(isPrintDlg, modal, p)).start();
+ } else {
+ (new Test(isPrintDlg, type, p)).start();
+ }
+ }
+
+ private void createGUI() {
+
+ setLayout(new BorderLayout());
+
+ setSize(350, 200);
+ Panel panel = new Panel();
+ panel.setLayout(new GridLayout(18, 1));
+
+ btnTest = new Button("Start test");
+ btnTest.addActionListener(this);
+ panel.add(btnTest);
+
+
+ panel.add(new Label("Dialog parent:"));
+ groupParent = new CheckboxGroup();
+ cbNullDlg = new Checkbox("NULL Dialog" , groupParent, true );
+ cbNullFrm = new Checkbox("NULL Frame" , groupParent, false);
+ cbHiddDlg = new Checkbox("Hidden Dialog", groupParent, false);
+ cbHiddFrm = new Checkbox("Hidden Frame" , groupParent, false);
+ cbDlg = new Checkbox("Dialog" , groupParent, false);
+ cbFrm = new Checkbox("Frame" , groupParent, false);
+
+ panel.add(cbNullDlg);
+ panel.add(cbNullFrm);
+ panel.add(cbHiddDlg);
+ panel.add(cbHiddFrm);
+ panel.add(cbDlg);
+ panel.add(cbFrm);
+
+ panel.add(new Label("Dialog modality type:"));
+ groupModType = new CheckboxGroup();
+ cbModal = new Checkbox("Modal" , groupModType, true );
+ cbNonModal = new Checkbox("Non-modal" , groupModType, false);
+ cbAppModal = new Checkbox("Application modal", groupModType, false);
+ cbDocModal = new Checkbox("Document modal" , groupModType, false);
+ cbTKModal = new Checkbox("Toolkit modal" , groupModType, false);
+ cbModeless = new Checkbox("Modeless" , groupModType, false);
+
+ panel.add(cbModal);
+ panel.add(cbNonModal);
+ panel.add(cbAppModal);
+ panel.add(cbDocModal);
+ panel.add(cbTKModal);
+ panel.add(cbModeless);
+ add(panel);
+
+ panel.add(new Label("Print dialog type:"));
+ groupDialog = new CheckboxGroup();
+ cbPage = new Checkbox("Page Setup", groupDialog, true);
+ cbPrint = new Checkbox("Print", groupDialog, false);
+ panel.add(cbPage);
+ panel.add(cbPrint);
+
+ validate();
+ setVisible(true);
+ }
+
+ public void start() {
+ try {
+ EventQueue.invokeAndWait(this::createGUI);
+ } catch (Exception e) {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/PrintDialogsTest/Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,217 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.print.*;
+
+
+public class Test {
+
+ class CustomFrame extends Frame {
+ public CustomFrame() {
+ super();
+ setTitle("Frame");
+ setSize(150, 100);
+ Button dummy = new Button("Dummy");
+ add(dummy);
+ }
+ }
+
+ class CustomWindow extends Window {
+
+ private void GUI() {
+ setSize(150, 100);
+ Button dummy = new Button("Dummy");
+ add(dummy);
+ }
+
+ public CustomWindow(Dialog d) {
+ super(d);
+ GUI();
+ }
+
+ public CustomWindow(Frame f) {
+ super(f);
+ GUI();
+ }
+ }
+
+ private class CustomDialog extends Dialog implements ActionListener {
+
+ private Button open, close;
+
+ private void GUI() {
+ setTitle("Dialog");
+ setSize(150, 100);
+
+ Panel p = new Panel();
+ p.setLayout(new GridLayout(1, 2));
+ open = new Button("Open");
+ open.addActionListener(this);
+ p.add(open);
+ close = new Button("Finish");
+ close.addActionListener(this);
+ p.add(close);
+ add(p);
+ }
+
+ public CustomDialog(Dialog d) {
+ super(d);
+ GUI();
+ }
+
+ public CustomDialog(Frame f) {
+ super(f);
+ GUI();
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (open.equals(e.getSource())) {
+ if (isPrintDialog) {
+ PrinterJob.getPrinterJob().printDialog();
+ } else {
+ PrinterJob.getPrinterJob().pageDialog(new PageFormat());
+ }
+ } else if (close.equals(e.getSource())) {
+ if (parentDialog != null) { parentDialog.dispose(); }
+ if ( parentFrame != null) { parentFrame.dispose(); }
+ if (parent != null) { parent.dispose(); }
+ if (dialog != null) { dialog.dispose(); }
+ if ( frame != null) { frame.dispose(); }
+ if (window != null) { window.dispose(); }
+ }
+ }
+ }
+
+ class ParentDialog extends Dialog {
+ public ParentDialog() {
+ super((Frame) null);
+ setTitle("Dialog");
+ setSize(150, 100);
+ Button dummy = new Button("Dummy");
+ add(dummy);
+ }
+ }
+
+ private CustomFrame frame;
+ private CustomWindow window;
+ private CustomDialog dialog;
+ private ParentDialog parent;
+
+ private boolean isPrintDialog;
+
+ private final Dialog.ModalityType modalityType;
+ private final boolean setModal;
+
+ public enum DialogParent
+ {NULL_FRAME, HIDDEN_FRAME, NULL_DIALOG, HIDDEN_DIALOG, FRAME, DIALOG};
+ private final DialogParent dialogParent;
+
+ private Dialog parentDialog;
+ private Frame parentFrame;
+
+ public Test(boolean isPrintDlg,
+ Dialog.ModalityType type,
+ DialogParent p){
+ isPrintDialog = isPrintDlg;
+ modalityType = type;
+ setModal = false;
+ dialogParent = p;
+ EventQueue.invokeLater( this::createGUI );
+ }
+
+ public Test(boolean isPrintDlg,
+ boolean modal,
+ DialogParent p) {
+ isPrintDialog = isPrintDlg;
+ modalityType = null;
+ setModal = modal;
+ dialogParent = p;
+ EventQueue.invokeLater( this::createGUI );
+ }
+
+ private void createGUI() {
+
+ Window p;
+
+ if (dialogParent == DialogParent.DIALOG) {
+ parent = new ParentDialog();
+ window = new CustomWindow(parent);
+ p = parent;
+ } else {
+ frame = new CustomFrame();
+ window = new CustomWindow(frame);
+ p = frame;
+ }
+
+ int x = 50, y = 50;
+ p.setLocation(x, y);
+
+ y += (50 + p.getHeight());
+ window.setLocation(x, y);
+
+ switch (dialogParent) {
+ case NULL_DIALOG:
+ dialog = new CustomDialog((Dialog) null);
+ break;
+ case NULL_FRAME:
+ dialog = new CustomDialog((Frame) null);
+ break;
+ case HIDDEN_DIALOG:
+ parentDialog = new Dialog((Frame) null);
+ dialog = new CustomDialog(parentDialog);
+ break;
+ case HIDDEN_FRAME:
+ parentFrame = new Frame();
+ dialog = new CustomDialog(parentFrame);
+ break;
+ case DIALOG:
+ dialog = new CustomDialog(parent);
+ case FRAME:
+ dialog = new CustomDialog(frame);
+ break;
+ }
+
+ y += (50 + dialog.getHeight());
+ dialog.setLocation(x, y);
+
+ if (modalityType == null) {
+ dialog.setModal(setModal);
+ } else {
+ dialog.setModalityType(modalityType);
+ }
+ }
+
+ public void start() {
+ EventQueue.invokeLater(() -> {
+ if (parent != null) { parent.setVisible(true); }
+ else if (frame != null) { frame.setVisible(true); }
+ });
+ EventQueue.invokeLater(() -> { window.setVisible(true); });
+ EventQueue.invokeLater(() -> { dialog.setVisible(true); });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether an application modal dialog having a null Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal1Test
+ */
+
+public class ToBackAppModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+ ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether an application modal dialog having a null Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal2Test
+ */
+
+public class ToBackAppModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+ ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether an application modal dialog having a hidden Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal3Test
+ */
+
+public class ToBackAppModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+ ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether an application modal dialog having a hidden Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal4Test
+ */
+
+public class ToBackAppModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+ ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether an application modal dialog having a visible Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal5Test
+ */
+
+public class ToBackAppModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+ ToBackFDFTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether an application modal dialog having a visible Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal6Test
+ */
+
+public class ToBackAppModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackDDFTest(Dialog.ModalityType.APPLICATION_MODAL)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDDFTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,183 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+// DDF: Dialog->Dialog->Frame
+
+public class ToBackDDFTest {
+
+ private volatile TestDialog leftDialog;
+ private volatile TestFrame rightFrame;
+ private volatile CustomDialog dialog;
+
+ private static final int delay = 500;
+ private final ExtendedRobot robot;
+
+ private Frame hiddenFrame;
+
+ private volatile boolean setModal;
+
+ private Dialog.ModalityType modalityType;
+
+ private ToBackDDFTest(Dialog.ModalityType modType,
+ boolean modal) throws Exception {
+ modalityType = modType;
+ setModal = modal;
+
+ robot = new ExtendedRobot();
+ EventQueue.invokeLater(this::createGUI);
+ }
+
+ public ToBackDDFTest(Dialog.ModalityType modalityType) throws Exception {
+ this(modalityType, false);
+ }
+
+ public ToBackDDFTest(boolean modal) throws Exception { this(null, modal); }
+
+ private void createGUI() {
+
+ hiddenFrame = new Frame();
+ leftDialog = new TestDialog(hiddenFrame);
+ leftDialog.setLocation(50, 50);
+ leftDialog.setBackground(Color.BLUE);
+ leftDialog.setVisible(true);
+
+ dialog = new CustomDialog(leftDialog);
+
+ if (modalityType == null) {
+ dialog.setModal(setModal);
+ modalityType = dialog.getModalityType();
+ } else if (modalityType != null) {
+ dialog.setModalityType(modalityType);
+ }
+
+ dialog.setBackground(Color.WHITE);
+ dialog.setLocation(150, 50);
+
+ rightFrame = new TestFrame();
+ rightFrame.setLocation(250, 50);
+ rightFrame.setBackground(Color.RED);
+
+ if (modalityType == Dialog.ModalityType.APPLICATION_MODAL) {
+ rightFrame.setModalExclusionType(
+ Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
+ } else if (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) {
+ rightFrame.setModalExclusionType(
+ Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
+ }
+
+ dialog.setVisible(true);
+ }
+
+ private void checkLeftDialogIsOverlapped(String msg) {
+
+ Point p = leftDialog.getLocationOnScreen();
+ int x = p.x + (int)(leftDialog.getWidth() * 0.9);
+ int y = p.y + (int)(leftDialog.getHeight() * 0.9);
+ boolean f = robot.getPixelColor(x, y).equals(leftDialog.getBackground());
+ assertFalse(f, msg);
+ }
+
+ private void checkRightFrameIsOverlaped(String msg) {
+
+ Point p = rightFrame.getLocationOnScreen();
+ int x = p.x + (int)(rightFrame.getWidth() * 0.1);
+ int y = p.y + (int)(rightFrame.getHeight() * 0.9);
+ boolean f = robot.getPixelColor(x, y).equals(rightFrame.getBackground());
+ assertFalse(f, msg);
+ }
+
+ public void doTest() throws Exception {
+
+ try {
+ robot.waitForIdle(delay);
+
+ dialog.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+
+ dialog.clickCloseButton(robot);
+ robot.waitForIdle(delay);
+
+ EventQueue.invokeAndWait(() -> { dialog.toBack(); });
+ robot.waitForIdle(delay);
+
+ String type = modalityType.toString().toLowerCase().replace('_', ' ');
+
+ boolean isModeless = (modalityType == Dialog.ModalityType.MODELESS);
+
+ final String msg1;
+ if (isModeless) {
+ msg1 = "The modeless dialog was overlapped by the " +
+ "parent dialog after calling toBack method.";
+ } else {
+ msg1 = "The " + type + " dialog was overlapped by the blocked dialog.";
+ }
+ EventQueue.invokeAndWait(() -> { checkLeftDialogIsOverlapped(msg1); });
+
+ if (isModeless) {
+ EventQueue.invokeAndWait(() -> { dialog.toFront(); });
+ } else {
+ EventQueue.invokeAndWait(() -> { leftDialog.toFront(); });
+ }
+ robot.waitForIdle(delay);
+
+ final String msg2 = "The dialog is still behind the right frame after " +
+ "calling toFront method for " + (isModeless ? "it." : "its parent.");
+
+ EventQueue.invokeAndWait(() -> { checkRightFrameIsOverlaped(msg2); });
+
+ final String msg3;
+ if (isModeless) {
+ msg3 = "The modeless dialog is still behind the parent dialog.";
+ } else {
+ msg3 = "The " + type + " dialog was overlapped by the blocked " +
+ "dialog after calling toFront method for the blocked dialog.";
+ }
+ EventQueue.invokeAndWait(() -> { checkLeftDialogIsOverlapped(msg3); });
+
+ } finally {
+ EventQueue.invokeAndWait(this::closeAll);
+ }
+ }
+
+ private void closeAll() {
+ if (dialog != null) { dialog.dispose(); }
+ if (leftDialog != null) { leftDialog.dispose(); }
+ if (rightFrame != null) { rightFrame.dispose(); }
+ if (hiddenFrame != null) { hiddenFrame.dispose(); }
+ }
+
+
+ class CustomDialog extends TestDialog {
+
+ public CustomDialog(Dialog d) { super(d); }
+
+ @Override
+ public void doOpenAction() {
+ if (rightFrame != null) { rightFrame.setVisible(true); }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for
+ * a document modal dialog with null Frame parent.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal1Test
+ */
+
+public class ToBackDocModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for
+ * a document modal dialog with null Dialog parent.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal2Test
+ */
+
+public class ToBackDocModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for
+ * a document modal dialog with hidden Frame parent.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal3Test
+ */
+
+public class ToBackDocModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for
+ * a document modal dialog with hidden Dialog parent.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal4Test
+ */
+
+public class ToBackDocModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a document modal dialog having a visible Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal5Test
+ */
+
+public class ToBackDocModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+ ToBackFDFTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a document modal dialog having a visible Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal6Test
+ */
+
+public class ToBackDocModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackDDFTest(Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackFDFTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,291 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+// FDF: Frame->Dialog->Frame
+
+public class ToBackFDFTest {
+
+ private volatile CustomDialog dialog;
+ private volatile TestFrame leftFrame, rightFrame;
+
+ private static final int delay = 500;
+ private final ExtendedRobot robot;
+
+ private Dialog hiddenDialog;
+ private Frame hiddenFrame;
+
+ public enum DialogOwner {HIDDEN_DIALOG, NULL_DIALOG, HIDDEN_FRAME, NULL_FRAME, FRAME};
+
+ private DialogOwner owner;
+ private volatile boolean setModal;
+
+ private Dialog.ModalityType modalityType;
+
+ private ToBackFDFTest(Dialog.ModalityType modType,
+ boolean modal,
+ DialogOwner o) throws Exception {
+ modalityType = modType;
+ setModal = modal;
+ owner = o;
+
+ robot = new ExtendedRobot();
+ EventQueue.invokeLater(this::createGUI);
+ }
+
+ public ToBackFDFTest(Dialog.ModalityType modalityType,
+ DialogOwner o) throws Exception {
+ this(modalityType, false, o);
+ }
+
+ public ToBackFDFTest(boolean modal, DialogOwner o) throws Exception {
+ this(null, modal, o);
+ }
+
+ private void createGUI() {
+
+ leftFrame = new TestFrame();
+ leftFrame.setLocation(50, 50);
+ leftFrame.setBackground(Color.BLUE);
+ leftFrame.setVisible(true);
+
+ switch (owner) {
+ case HIDDEN_DIALOG:
+ hiddenDialog = new Dialog((Frame) null);
+ dialog = new CustomDialog(hiddenDialog);
+ break;
+ case NULL_DIALOG:
+ dialog = new CustomDialog((Dialog) null);
+ break;
+ case HIDDEN_FRAME:
+ hiddenFrame = new Frame();
+ dialog = new CustomDialog(hiddenFrame);
+ break;
+ case NULL_FRAME:
+ dialog = new CustomDialog((Frame) null);
+ break;
+ case FRAME:
+ dialog = new CustomDialog(leftFrame);
+ break;
+ }
+
+ if (modalityType == null) {
+ dialog.setModal(setModal);
+ modalityType = dialog.getModalityType();
+ } else if (modalityType != null) {
+ dialog.setModalityType(modalityType);
+ }
+
+ dialog.setBackground(Color.WHITE);
+ dialog.setLocation(150, 50);
+
+ rightFrame = new TestFrame();
+ rightFrame.setLocation(250, 50);
+ rightFrame.setBackground(Color.RED);
+
+ if (modalityType == Dialog.ModalityType.APPLICATION_MODAL) {
+ rightFrame.setModalExclusionType(
+ Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
+ } else if (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) {
+ rightFrame.setModalExclusionType(
+ Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
+ }
+
+ dialog.setVisible(true);
+ }
+
+ private void checkIfLeftOnTop(boolean refState, String msg) {
+
+ Point p = leftFrame.getLocationOnScreen();
+ int x = p.x + (int)(leftFrame.getWidth() * 0.9);
+ int y = p.y + (int)(leftFrame.getHeight() * 0.9);
+ boolean f = robot.getPixelColor(x, y).equals(leftFrame.getBackground());
+ assertEQ(refState, f, msg);
+ }
+
+ private void checkIfRightOnTop(boolean refState, String msg) {
+
+ Point p = rightFrame.getLocationOnScreen();
+ int x = p.x + (int)(rightFrame.getWidth() * 0.1);
+ int y = p.y + (int)(rightFrame.getHeight() * 0.9);
+ boolean f = robot.getPixelColor(x, y).equals(rightFrame.getBackground());
+ assertEQ(refState, f, msg);
+ }
+
+ private void Test() throws Exception {
+
+ String type =
+ dialog.getModalityType().toString().toLowerCase().replace('_', ' ');
+
+ final String msg1 = "The " + type + "dialog was " +
+ "overlapped by the blocked frame.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg1); });
+
+ EventQueue.invokeAndWait(() -> { leftFrame.toFront(); });
+ robot.waitForIdle(delay);
+
+ final String msg2 = "The dialog is still overlapped by the right frame" +
+ " after calling toFront method for the blocked (left) frame.";
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg2); });
+
+ final String msg3 = "The " + type + " dialog was overlapped by the " +
+ "blocked frame after calling toFront method for the blocked frame.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg3); });
+
+
+ if (owner == DialogOwner.FRAME) { return; }
+
+ EventQueue.invokeAndWait(() -> { leftFrame.toBack(); });
+ robot.waitForIdle(delay);
+
+ final String msg4 = "Calling toBack " +
+ "for the blocked frame pushed the blocking dialog to back.";
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg4); });
+
+ final String msg5 = "The " + type + " dialog was overlapped " +
+ "by the blocked frame after toBack was called for the left frame.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg5); });
+ }
+
+ private void docTest() throws Exception {
+
+ if (owner == DialogOwner.FRAME) { Test(); }
+ else {
+
+ final String msg1 = "toBack was called for the dialog.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(true, msg1); });
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(true, msg1); });
+
+ EventQueue.invokeAndWait(() -> { dialog.toFront(); });
+ robot.waitForIdle(delay);
+
+ final String msg2 = "Dialog still behind " +
+ "the right frame even after calling toFront method.";
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg2); });
+ final String msg3 = "The document modal dialog " +
+ "gone behind the blocked left frame.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg3); });
+
+ EventQueue.invokeAndWait(() -> { leftFrame.toBack(); });
+ robot.waitForIdle(delay);
+
+ final String msg4 = "Calling toBack for the left " +
+ "frame pushed the document modal dialog to back.";
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg4); });
+ final String msg5 = "The document modal dialog " +
+ "was pushed behind the left frame when toBack called for the frame.";
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg5); });
+ }
+ }
+
+ private void modelessTest() throws Exception {
+
+ if (owner == DialogOwner.FRAME) {
+ final String msg = "The modeless dialog was " +
+ "pushed behind the parent left frame after toBack call.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg); });
+ } else {
+ final String msg =
+ "Dialog should not overlap the frame after calling toBack.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(true, msg); });
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(true, msg); });
+ }
+
+ EventQueue.invokeAndWait(() -> { dialog.toFront(); });
+ robot.waitForIdle(delay);
+
+ final String msg1 = "The frames should not overlap the dialog " +
+ "after calling toFront for it.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg1); });
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg1); });
+
+ if (owner == DialogOwner.FRAME) { return; }
+
+ EventQueue.invokeAndWait(() -> { leftFrame.toBack(); });
+ robot.waitForIdle(delay);
+
+ final String msg2 = "Calling toBack method for the " +
+ "left frame pushed the modeless dialog to back.";
+ EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg2); });
+ final String msg3 = "The modeless dialog was pushed " +
+ "behind the left frame after toBack was called for the frame.";
+ EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg3); });
+ }
+
+ public void doTest() throws Exception {
+
+ try {
+ robot.waitForIdle(delay);
+
+ dialog.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+
+ dialog.clickCloseButton(robot);
+ robot.waitForIdle(delay);
+
+ EventQueue.invokeAndWait(() -> { dialog.toBack(); });
+ robot.waitForIdle(delay);
+
+ switch (modalityType) {
+ case APPLICATION_MODAL:
+ case TOOLKIT_MODAL:
+ Test();
+ break;
+ case DOCUMENT_MODAL:
+ docTest();
+ break;
+ case MODELESS:
+ modelessTest();
+ break;
+ }
+ } finally {
+ EventQueue.invokeAndWait(this::closeAll);
+ }
+ }
+
+ private void closeAll() {
+ if (dialog != null) { dialog.dispose(); }
+ if (leftFrame != null) { leftFrame.dispose(); }
+ if (rightFrame != null) { rightFrame.dispose(); }
+ if (hiddenDialog != null) { hiddenDialog.dispose(); }
+ if (hiddenFrame != null) { hiddenFrame.dispose(); }
+ }
+
+
+ class CustomDialog extends TestDialog {
+
+ public CustomDialog(Dialog d) { super(d); }
+ public CustomDialog(Frame f) { super(f); }
+
+ @Override
+ public void doOpenAction() {
+ if (rightFrame != null) {
+ rightFrame.setVisible(true);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a modal dialog having a null Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal1Test
+ */
+
+public class ToBackModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ true, ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a modal dialog having a null Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal2Test
+ */
+
+public class ToBackModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ true, ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a modal dialog having a hidden Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal3Test
+ */
+
+public class ToBackModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ true, ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a modal dialog having a hidden Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal4Test
+ */
+
+public class ToBackModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ true, ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a modal dialog having a visible Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal5Test
+ */
+
+public class ToBackModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ true, ToBackFDFTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a modal dialog having a visible Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal6Test
+ */
+
+public class ToBackModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackDDFTest(true)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modeless dialog having a null Frame constructor
+ * goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless1Test
+ */
+
+public class ToBackModeless1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+ ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modeless dialog having a null Dialog constructor
+ * goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless2Test
+ */
+
+public class ToBackModeless2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+ ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modeless dialog having a hidden Frame constructor
+ * goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless3Test
+ */
+
+public class ToBackModeless3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+ ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modeless dialog having a hidden Dialog constructor
+ * goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless4Test
+ */
+
+public class ToBackModeless4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+ ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for a modeless dialog
+ * having a visible Frame constructor.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless5Test
+ */
+
+public class ToBackModeless5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+ ToBackFDFTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for a modeless dialog
+ * having a visible Dialog constructor.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless6Test
+ */
+
+public class ToBackModeless6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackDDFTest(Dialog.ModalityType.MODELESS)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a non-modal dialog having a null Frame constructor
+ * goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal1Test
+ */
+
+public class ToBackNonModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ false, ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a non-modal dialog having a null Dialog constructor
+ * goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal2Test
+ */
+
+public class ToBackNonModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ false, ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a non-modal dialog having a hidden Frame constructor
+ * goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal3Test
+ */
+
+public class ToBackNonModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ false, ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check whether a non-modal dialog having a hidden Dialog constructor
+ * goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal4Test
+ */
+
+public class ToBackNonModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ false, ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check if toBack method works correctly for a non-modal dialog
+ * having a visible Frame constructor.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal5Test
+ */
+
+public class ToBackNonModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(
+ false, ToBackFDFTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * 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 8054143
+ * @summary Check if toBack method works correctly for a non-modal dialog
+ * having a visible Dialog constructor.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal6Test
+ */
+
+public class ToBackNonModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackDDFTest(false)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal1Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a toolkit modal dialog having a null Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal1Test
+ */
+
+public class ToBackTKModal1Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal2Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a toolkit modal dialog having a null Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal2Test
+ */
+
+public class ToBackTKModal2Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal3Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a toolkit modal dialog having a hidden Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal3Test
+ */
+
+public class ToBackTKModal3Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal4Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a toolkit modal dialog having a hidden Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal4Test
+ */
+
+public class ToBackTKModal4Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal5Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a toolkit modal dialog having a visible Frame
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal5Test
+ */
+
+public class ToBackTKModal5Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+ ToBackFDFTest.DialogOwner.FRAME)).doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal6Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a toolkit modal dialog having a visible Dialog
+ * constructor still stays on top of the blocked windows even
+ * after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal6Test
+ */
+
+public class ToBackTKModal6Test {
+
+ public static void main(String[] args) throws Exception {
+ (new ToBackDDFTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+ }
+}
--- a/jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -37,7 +37,6 @@
import javax.swing.*;
import java.util.concurrent.*;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
@@ -57,7 +56,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -69,7 +67,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {
@@ -82,7 +80,7 @@
robot.mouseMove(pointToClick.x, pointToClick.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (dragWindowMouseEnteredCount != 1 && dragWindowMouseExitedCount != 0) {
throw new RuntimeException(
@@ -100,7 +98,7 @@
});
robot.mouseMove(450, pointToClick.y);
- toolkit.realSync();
+ robot.waitForIdle();
if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
throw new RuntimeException(
@@ -108,7 +106,7 @@
}
robot.mouseMove(450, pointToDrag.y);
- toolkit.realSync();
+ robot.waitForIdle();
if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
throw new RuntimeException(
@@ -121,7 +119,7 @@
}
robot.mouseMove(pointToDrag.y, pointToDrag.y);
- toolkit.realSync();
+ robot.waitForIdle();
if (buttonMouseEnteredCount != 1 && buttonMouseExitedCount != 0) {
throw new RuntimeException(
@@ -129,7 +127,7 @@
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (labelMouseReleasedCount != 1) {
throw new RuntimeException("No MouseReleased event on label!");
--- a/jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Mouse/EnterExitEvents/DragWindowTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -38,7 +38,6 @@
import javax.swing.*;
import java.util.concurrent.*;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
@@ -54,7 +53,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -66,7 +64,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {
@@ -79,7 +77,7 @@
robot.mouseMove(pointToClick.x, pointToClick.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (dragWindowMouseEnteredCount != 1) {
throw new RuntimeException("No MouseEntered event on Drag Window!");
@@ -95,14 +93,14 @@
});
robot.mouseMove(pointToDrag.x, pointToDrag.y);
- toolkit.realSync();
+ robot.waitForIdle();
if (buttonMouseEnteredCount != 0) {
throw new RuntimeException("Extra MouseEntered event on button!");
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (labelMouseReleasedCount != 1) {
throw new RuntimeException("No MouseReleased event on label!");
--- a/jdk/test/java/awt/Mouse/EnterExitEvents/ResizingFrameTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Mouse/EnterExitEvents/ResizingFrameTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,15 +28,10 @@
* @author alexandr.scherbatiy area=awt.event
* @run main ResizingFrameTest
*/
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import sun.awt.SunToolkit;
public class ResizingFrameTest {
@@ -46,10 +41,10 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.mouseMove(100, 100);
+ robot.delay(200);
// create a frame under the mouse cursor
SwingUtilities.invokeAndWait(new Runnable() {
@@ -61,7 +56,8 @@
});
- toolkit.realSync();
+ robot.waitForIdle();
+ robot.delay(1000);
if (mouseEnteredCount != 1 || mouseExitedCount != 0) {
throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -76,11 +72,11 @@
}
});
- toolkit.realSync();
- robot.delay(200);
+ robot.waitForIdle();
+ robot.delay(1000);
if (mouseEnteredCount != 1 || mouseExitedCount != 1) {
- throw new RuntimeException("No Mouse Entered/Exited events!");
+ throw new RuntimeException("No Mouse Entered/Exited events! "+mouseEnteredCount+", "+mouseExitedCount);
}
// deiconify frame
@@ -92,8 +88,8 @@
}
});
- toolkit.realSync();
- robot.delay(200);
+ robot.waitForIdle();
+ robot.delay(1000);
if (mouseEnteredCount != 2 || mouseExitedCount != 1) {
throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -101,8 +97,8 @@
// move the mouse out of the frame
robot.mouseMove(500, 500);
- toolkit.realSync();
- robot.delay(200);
+ robot.waitForIdle();
+ robot.delay(1000);
if (mouseEnteredCount != 2 || mouseExitedCount != 2) {
throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -117,8 +113,8 @@
}
});
- toolkit.realSync();
- robot.delay(200);
+ robot.waitForIdle();
+ robot.delay(1000);
if (mouseEnteredCount != 3 || mouseExitedCount != 2) {
throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -134,8 +130,8 @@
}
});
- toolkit.realSync();
- robot.delay(200);
+ robot.waitForIdle();
+ robot.delay(1000);
if (mouseEnteredCount != 3 || mouseExitedCount != 3) {
throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -151,8 +147,8 @@
}
});
- toolkit.realSync();
- robot.delay(200);
+ robot.waitForIdle();
+ robot.delay(1000);
if (mouseEnteredCount != 4 || mouseExitedCount != 3) {
throw new RuntimeException("No Mouse Entered/Exited events!");
@@ -167,7 +163,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
robot.delay(400);
if (mouseEnteredCount != 4 || mouseExitedCount != 4) {
@@ -183,7 +179,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
robot.delay(200);
if (mouseEnteredCount != 5 || mouseExitedCount != 4) {
@@ -199,7 +195,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
robot.delay(400);
@@ -229,4 +225,4 @@
frame.setVisible(true);
}
-}
\ No newline at end of file
+}
--- a/jdk/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,8 +27,6 @@
* @summary Tests JComboBox selection via the mouse
* @author Dmitry Markov
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
@@ -41,14 +39,12 @@
public class MouseComboBoxTest {
private static final String[] items = {"One", "Two", "Three", "Four", "Five"};
- private static SunToolkit toolkit = null;
private static Robot robot = null;
private static JFrame frame = null;
private static JComboBox comboBox = null;
private static MyComboBoxUI comboBoxUI = null;
public static void main(String[] args) throws Exception {
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(50);
@@ -59,19 +55,19 @@
createAndShowGUI();
}
});
- toolkit.realSync();
+ robot.waitForIdle();
for (int i = 0; i < items.length; i++) {
// Open popup
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
- toolkit.realSync();
+ robot.waitForIdle();
Point point = getItemPointToClick(i);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (i != getSelectedIndex()) {
throw new RuntimeException("Test Failed! Incorrect value of selected index = " + getSelectedIndex() +
--- a/jdk/test/java/awt/Multiscreen/MouseEventTest/MouseEventTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Multiscreen/MouseEventTest/MouseEventTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@run main MouseEventTest
*/
-import sun.awt.SunToolkit;
-
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -37,8 +35,8 @@
public class MouseEventTest {
static volatile boolean crossed = false;
- static void sleep() throws InterruptedException {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ static void sleep(Robot robot) throws InterruptedException {
+ robot.waitForIdle();
Thread.sleep(500);
}
@@ -64,7 +62,7 @@
frame.setLocation(screen.x + 200, screen.y + 200);
frame.setBackground(Color.YELLOW);
frame.setVisible(true);
- sleep();
+ sleep(robot);
Point loc = frame.getLocationOnScreen();
Dimension size = frame.getSize();
@@ -86,7 +84,7 @@
robot.mouseMove(point.x - 1, point.y - 1);
robot.mouseMove(point.x, point.y);
- sleep();
+ sleep(robot);
frame.dispose();
if (!crossed) {
--- a/jdk/test/java/awt/Paint/PaintNativeOnUpdate.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Paint/PaintNativeOnUpdate.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,21 +28,22 @@
import java.awt.Graphics;
import java.awt.Label;
import java.awt.Point;
-import java.awt.Robot;
-import java.awt.Toolkit;
-
-import sun.awt.SunToolkit;
/**
* @test
* @bug 7157680
+ * @library ../../../lib/testlibrary
+ * @build ExtendedRobot
* @author Sergey Bylokhov
+ @ @run main PaintNativeOnUpdate
*/
public final class PaintNativeOnUpdate extends Label {
private boolean fullUpdate = true;
public static void main(final String[] args) throws AWTException {
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(50);
final Frame frame = new Frame();
final Component label = new PaintNativeOnUpdate();
frame.setBackground(Color.RED);
@@ -51,14 +52,12 @@
frame.setUndecorated(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
- sleep();
+ robot.waitForIdle(1000);
label.repaint();// first paint
- sleep();
+ robot.waitForIdle(1000);
label.repaint();// incremental paint
- sleep();
+ robot.waitForIdle(1000);
- Robot robot = new Robot();
- robot.setAutoDelay(50);
Point point = label.getLocationOnScreen();
Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
point.y + label.getHeight() / 2);
@@ -87,12 +86,4 @@
public void paint(final Graphics g) {
// Do nothing
}
-
- private static void sleep() {
- try {
- ((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
- Thread.sleep(1000);
- } catch (InterruptedException ignored) {
- }
- }
}
--- a/jdk/test/java/awt/Robot/CtorTest/CtorTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Robot/CtorTest/CtorTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -38,8 +38,6 @@
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
-
public class CtorTest
{
public static void main(String []s) throws Exception
@@ -57,7 +55,7 @@
frame.setBounds(100, 100, 100, 100);
frame.setVisible(true);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
// click in the middle of the frame
robot.mouseMove(150, 150);
@@ -66,6 +64,6 @@
robot.delay(50);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TextArea/ScrollbarIntersectionTest/ScrollbarIntersectionTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,207 @@
+/*
+ * 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
+ * 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 6429174
+ @summary Tests that mouse click at the are of intersection of two
+ scrollbars for text area doesn't trigger any scrolling
+ @author artem.ananiev@sun.com: area=awt.text
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run main ScrollbarIntersectionTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import jdk.testlibrary.OSInfo;
+
+
+public class ScrollbarIntersectionTest
+{
+ private static void init()
+ {
+
+ Frame f = new Frame("F");
+ f.setBounds(100, 100, 480, 360);
+ f.setLayout(new BorderLayout());
+
+ TextArea ta = new TextArea(null, 8, 24, TextArea.SCROLLBARS_BOTH);
+ // append several lines to show vertical scrollbar
+ for (int i = 0; i < 128; i++)
+ {
+ ta.append("" + i + "\n");
+ }
+ // and some characters into the last line for horizontal scrollbar
+ for (int i = 0; i < 128; i++)
+ {
+ ta.append("" + i);
+ }
+ ta.append("\n");
+ f.add(ta);
+
+ f.setVisible(true);
+
+ Robot r = null;
+ try
+ {
+ r = new Robot();
+ r.setAutoDelay(20);
+ }
+ catch (Exception z)
+ {
+ z.printStackTrace(System.err);
+ fail(z.getMessage());
+ return;
+ }
+ r.waitForIdle();
+
+ ta.setCaretPosition(0);
+ r.waitForIdle();
+
+ Point p = ta.getLocationOnScreen();
+ Dimension d = ta.getSize();
+
+ int fh = 8;
+ Graphics g = ta.getGraphics();
+ try
+ {
+ FontMetrics fm = g.getFontMetrics();
+ fh = fm.getHeight();
+ }
+ finally
+ {
+ if (g != null)
+ {
+ g.dispose();
+ }
+ };
+
+ r.mouseMove(p.x + d.width - 2, p.y + d.height - 2);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ r.waitForIdle();
+
+ // select 1st line in the text area
+ r.mouseMove(p.x + 2, p.y + 2 + fh / 2);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ for (int i = 0; i < d.width - 4; i += 4)
+ {
+ r.mouseMove(p.x + 2 + i, p.y + 2 + fh / 2);
+ }
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ r.waitForIdle();
+
+ String sel = ta.getSelectedText();
+ System.err.println("Selected text: " + sel);
+ if ((sel == null) || !sel.startsWith("0"))
+ {
+ fail("Test FAILED: TextArea is scrolled");
+ return;
+ }
+
+ pass();
+ }
+
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ public static void main( String args[] ) throws InterruptedException
+ {
+ if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+ // On OS X, this area is commandeered by the system,
+ // and frame would be wildly resized
+ System.out.println("Not for OS X");
+ return;
+ }
+ mainThread = Thread.currentThread();
+ try
+ {
+ init();
+ }
+ catch( TestPassedException e )
+ {
+ return;
+ }
+
+ try
+ {
+ Thread.sleep( sleepTime );
+ throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ }
+ catch (InterruptedException e)
+ {
+ if( ! testGeneratedInterrupt ) throw e;
+
+ testGeneratedInterrupt = false;
+
+ if ( theTestPassed == false )
+ {
+ throw new RuntimeException( failureMessage );
+ }
+ }
+ }
+
+ public static synchronized void setTimeoutTo( int seconds )
+ {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass()
+ {
+ if ( mainThread == Thread.currentThread() )
+ {
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
+ public static synchronized void fail()
+ {
+ fail( "it just plain failed! :-)" );
+ }
+
+ public static synchronized void fail( String whyFailed )
+ {
+ if ( mainThread == Thread.currentThread() )
+ {
+ throw new RuntimeException( whyFailed );
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }
+}
+
+class TestPassedException extends RuntimeException
+{
+}
--- a/jdk/test/java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/TextField/SelectionInvisibleTest/SelectionInvisibleTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,9 +27,7 @@
import java.awt.Point;
import java.awt.Robot;
import java.awt.TextField;
-import java.awt.Toolkit;
import java.awt.event.InputEvent;
-import sun.awt.SunToolkit;
/**
* @test
@@ -54,19 +52,18 @@
frame.add(panel);
frame.setVisible(true);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
-
Robot robot = new Robot();
robot.setAutoDelay(50);
+ robot.waitForIdle();
+
Point point = textField.getLocationOnScreen();
int x = point.x + textField.getWidth() / 2;
int y = point.y + textField.getHeight() / 2;
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
int N = 10;
@@ -76,7 +73,7 @@
robot.mouseMove(x, y);
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (!textField.getSelectedText().endsWith(LAST_WORD)) {
throw new RuntimeException("Last word is not selected!");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Toolkit/RealSync/Test.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,405 @@
+/*
+ * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * 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 6252005
+ @summary Tests that realSync feature works
+ @author denis.mikhalkin: area=awt.toolkit
+ @run main/timeout=6000 Test
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.LinkedList;
+import java.util.Collections;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import javax.swing.*;
+import java.awt.image.*;
+import javax.imageio.*;
+import java.io.*;
+
+/**
+ * Tests various problematic areas and how they are fixed using real-sync API:
+ * - requesting focus
+ * - showing and robot mouse pressing
+ * - showing and getting location on screen
+ * - showing and typing
+ */
+
+public class Test {
+ private static boolean doRealSync = true;
+ private static boolean someFailed = false;
+ private static Robot robot;
+ public static void main(String[] args) {
+ installListeners();
+
+ try {
+ robot = new Robot();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return;
+ }
+
+
+ int count = 100;
+ String method = null;
+ if (args.length != 0) {
+ try {
+ count = Integer.parseInt(args[0]);
+ } catch (NumberFormatException nfe) {
+ method = args[0];
+ count = 1;
+ }
+ }
+ while (count > 0 && !someFailed) {
+ run(method);
+ gc();
+ count--;
+ }
+
+ System.err.println("Total results: " + (someFailed? ("some tests failed (" + count + ")"): "ALL TESTS PASSED!!!"));
+ }
+
+ private static void gc() {
+ System.gc();
+ sleep(50);
+ System.gc();
+ Thread.yield();
+ System.gc();
+ }
+
+ private static void sleep(int time) {
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException ie) {
+ }
+ }
+
+ private static java.util.List<Object> events = Collections.synchronizedList(new LinkedList<Object>());
+
+ private static class TestFailureException extends RuntimeException {
+ }
+
+ public static void run(String method) {
+ Class cl = Test.class;
+ for (Method m : cl.getMethods()) {
+ if (Modifier.isStatic(m.getModifiers()) && m.getName().startsWith("test") && method == null ||
+ (method != null && method.equals(m.getName()))) {
+ realSync(null);
+ events.clear();
+ try {
+ m.invoke(null);
+ } catch (TestFailureException e) {
+ // Do nothing
+ } catch (Exception e) {
+ fail(e);
+ }
+ reportErrors(m);
+ }
+ }
+ }
+
+ private static java.util.List<Object> errors = Collections.synchronizedList(new LinkedList<Object>());
+ public static void reportErrors(Method m) {
+ realSync(null);
+ if (errors.size() == 0) {
+// System.err.println("Test passed: " + m.getName());
+// System.err.println("------------------------------------------------------\nEvents for " + m.getName());
+// for (Object e : events) {
+// System.err.println(e);
+// }
+ return;
+ }
+
+ someFailed = true;
+ System.err.println("Test failed: " + m.getName());
+ for (Object error : errors) {
+ if (error instanceof Throwable) {
+ ((Throwable)error).printStackTrace();
+ } else {
+ System.err.println("Cause: " + error);
+ }
+ }
+ System.err.println("Events:");
+ synchronized(events) {
+ for (Object e : events) {
+ System.err.println(e);
+ }
+ }
+ errors.clear();
+ System.exit(1);
+ }
+
+ public static void asser(boolean value) {
+ if (!value) {
+ fail("Test failed");
+ }
+ }
+ public static void asser(boolean value, String msg) {
+ if (!value) {
+ fail(msg);
+ }
+ }
+ static int screenNum = 0;
+ public static void fail(Object cause) {
+ synchronized (events) {
+ events.add("FAILURE MOMENT");
+ }
+ errors.add(cause);
+ errors.add("- Focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+ errors.add("- Focused window: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow());
+// try {
+// Robot r = new Robot();
+// BufferedImage image = r.createScreenCapture(new Rectangle(0, 0, 1024, 768));
+// ImageIO.write(image, "GIF", new File("/tmp/screen" + screenNum + ".gif"));
+// screenNum++;
+// image.flush();
+// } catch (Exception e) {
+// }
+ }
+
+ public static void _test1() {
+ Frame f = new Frame();
+ f.setLocation(100, 100);
+
+ f.setVisible(true);
+
+ Point loc = new Point(100, 100);
+ robot.mouseMove(loc.x+30, loc.y+40);
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ie) {
+ }
+ }
+
+ public static void testType() {
+ Frame f = new Frame("testType");
+ f.setLayout(new BorderLayout());
+ TextField b = new TextField();
+ f.add(b, BorderLayout.CENTER);
+ f.setBounds(100, 100, 200, 200);
+
+ f.setVisible(true);
+ realSync(f);
+
+ f.toFront();
+ realSync(f);
+ b.requestFocus();
+ realSync(f);
+ asser(b.isFocusOwner(), "Couldn't focus text field");
+
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_A);
+ realSync(f);
+ asser("a".equals(b.getText()), "Wrong text: " + b.getText());
+ f.dispose();
+ }
+
+ public static void testTypeSwing() {
+ JFrame f = new JFrame("testTypeSwing");
+ f.setLayout(new BorderLayout());
+ JTextField b = new JTextField();
+ f.add(b, BorderLayout.CENTER);
+ f.setBounds(100, 100, 200, 200);
+
+ f.setVisible(true);
+ realSync(f);
+
+ f.toFront();
+ realSync(f);
+ b.requestFocus();
+ realSync(f);
+ asser(b.isFocusOwner(), "Couldn't focus text field");
+
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_A);
+ realSync(f);
+ asser("a".equals(b.getText()), "Wrong text: " + b.getText());
+ f.dispose();
+ }
+
+ private static boolean pressed;
+ public static void testPress() {
+ Frame f = new Frame("testPress");
+ f.setLayout(new FlowLayout());
+ Button b = new Button("b");
+ b.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ pressed = true;
+ }
+ });
+ f.add(b);
+ f.setBounds(100, 100, 200, 200);
+
+ f.setVisible(true);
+ realSync(f);
+
+ Point loc = b.getLocationOnScreen();
+ events.add("Pressing at " + loc);
+ robot.mouseMove(loc.x+3, loc.y+3);
+ pressed = false;
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ realSync(f);
+ asser(pressed, "Not pressed");
+ f.dispose();
+ }
+
+ public static void testPressSwing() {
+ JFrame f = new JFrame("testPressSwing");
+ f.setLayout(new FlowLayout());
+ JButton b = new JButton("b");
+ b.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ pressed = true;
+ }
+ });
+ f.add(b);
+ f.setBounds(100, 100, 200, 200);
+
+ f.setVisible(true);
+ realSync(f);
+
+ Point loc = b.getLocationOnScreen();
+ events.add("Pressing at " + loc);
+ robot.mouseMove(loc.x+3, loc.y+3);
+ pressed = false;
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ realSync(f);
+ asser(pressed, "Not pressed");
+ f.dispose();
+ }
+
+ public static void testFocus0() {
+ Frame f = new Frame("testFocus0");
+ f.setLayout(new FlowLayout());
+ Button b1 = new Button("b1");
+ Button b2 = new Button("b2");
+ f.add(b1);
+ f.add(b2);
+ f.setBounds(100, 100, 200, 200);
+ f.setVisible(true);
+ realSync(f);
+ f.toFront();
+ realSync(f);
+ asser(b1.isFocusOwner(), "B1 didn't get focus");
+ b2.requestFocus();
+ realSync(f);
+ asser(b2.isFocusOwner(), "Couldn't focus b2");
+ f.dispose();
+ }
+
+ public static void testFocus1() {
+ Frame f = new Frame("testFocus1");
+ f.setLayout(new FlowLayout());
+ Button b1 = new Button("b1");
+ f.add(b1);
+ f.setBounds(100, 100, 200, 200);
+ f.setVisible(true);
+ realSync(f);
+ f.toFront();
+ realSync(f);
+ asser(b1.isFocusOwner(), "B1 didn't get focus");
+ f.dispose();
+ }
+
+ public static void testFocus2() {
+ Frame f = new Frame("testFocus2");
+ f.setLayout(new FlowLayout());
+ Button b1 = new Button("b1");
+ Button b2 = new Button("b2");
+ f.add(b1);
+ f.add(b2);
+ f.setBounds(100, 100, 200, 200);
+ f.setVisible(true);
+ realSync(f);
+ f.toFront();
+ realSync(f);
+ b2.requestFocus();
+ realSync(f);
+ if (!b2.isFocusOwner()) {
+ fail("1: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+ } else {
+ // Half passed
+ b1.requestFocus();
+ realSync(f);
+ asser(b1.isFocusOwner(), "B1 couldn't get focus");
+ }
+ f.dispose();
+ }
+
+ public static void testFocus2Swing() {
+ JFrame f = new JFrame("testFocus2Swing");
+ f.setLayout(new FlowLayout());
+ JButton b1 = new JButton("b1");
+ JButton b2 = new JButton("b2");
+ f.add(b1);
+ f.add(b2);
+ f.setBounds(100, 100, 200, 200);
+ f.setVisible(true);
+ realSync(f);
+ f.toFront();
+ realSync(f);
+ b2.requestFocus();
+ realSync(f);
+ if (!b2.isFocusOwner()) {
+ fail("1: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
+ } else {
+ // Half passed
+ b1.requestFocus();
+ realSync(f);
+ asser(b1.isFocusOwner(), "B1 couldn't get focus");
+ }
+ f.dispose();
+ }
+
+ public static void realSync(Window w) {
+ if (doRealSync) {
+ ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ }
+ }
+
+ public static void installListeners() {
+ Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+ public void eventDispatched(AWTEvent e) {
+ synchronized(events) {
+ events.add(e);
+ }
+ }
+ }, 0xffff & ~AWTEvent.HIERARCHY_EVENT_MASK);
+// ((XToolkit)Toolkit.getDefaultToolkit()).addXEventListener(new XToolkit.XEventListener() {
+// public void eventProcessed(IXAnyEvent e) {
+// synchronized(events) {
+// events.add(e);
+// }
+// }
+// });
+ }
+}
--- a/jdk/test/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Window/AlwaysOnTop/TestAlwaysOnTopBeforeShow.java Wed Jul 05 20:11:52 2017 +0200
@@ -40,7 +40,6 @@
import java.awt.*;
import java.awt.event.*;
import java.util.concurrent.atomic.AtomicBoolean;
-import sun.awt.SunToolkit;
//*** global search and replace TestAlwaysOnTopBeforeShow with name of the test ***
@@ -53,6 +52,7 @@
private static AtomicBoolean focused = new AtomicBoolean();
private static AtomicBoolean pressed = new AtomicBoolean();
private static volatile Object pressedTarget;
+ private static Robot robot = null;
private static void init()
{
//*** Create instructions for the user here ***
@@ -123,10 +123,13 @@
}//End init()
private static void waitForIdle(int mls) {
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
try {
+ if(robot == null) {
+ robot = new Robot();
+ }
+ robot.waitForIdle();
Thread.sleep(mls);
- } catch (InterruptedException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
--- a/jdk/test/java/awt/Window/BackgroundIsNotUpdated/BackgroundIsNotUpdated.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Window/BackgroundIsNotUpdated/BackgroundIsNotUpdated.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,16 +27,16 @@
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.Window;
-import sun.awt.SunToolkit;
-
/**
* @test
* @bug 8001472
* @summary Background of the window should not depend from the paint()/update()
* @author Sergey Bylokhov
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
+ * @run main BackgroundIsNotUpdated
*/
public final class BackgroundIsNotUpdated extends Window {
@@ -59,11 +59,12 @@
window.setSize(300, 300);
window.setLocationRelativeTo(null);
window.setVisible(true);
- sleep();
+ window.requestFocus();
+ final ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(200);
+ robot.waitForIdle(1000);
window.setBackground(Color.GREEN);
- sleep();
- final Robot robot = new Robot();
- robot.setAutoDelay(200);
+ robot.waitForIdle(1000);
Point point = window.getLocationOnScreen();
Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
point.y + window.getHeight() / 2);
@@ -73,12 +74,4 @@
"Expected: " + Color.GREEN + " , Actual: " + color);
}
}
-
- private static void sleep() {
- try {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
- Thread.sleep(1000);
- } catch (InterruptedException ignored) {
- }
- }
}
--- a/jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -65,7 +65,6 @@
public static void main(String[] args)
throws Exception
{
- sun.awt.SunToolkit tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit();
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (GraphicsDevice gd : ge.getScreenDevices()) {
@@ -96,7 +95,7 @@
initAndShowGUI();
}
});
- tk.realSync();
+ r.waitForIdle();
if (!paintComponentCalled) {
throw new RuntimeException("Test FAILED: panel's paintComponent() method is not called");
--- a/jdk/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,16 +25,16 @@
@test
@bug 4397404 4720930
@summary tests that images of all supported native image formats are transfered properly
+ @library ../../../../lib/testlibrary
@library ../../regtesthelpers/process/
- @build ProcessResults ProcessCommunicator
+ @build jdk.testlibrary.OSInfo ProcessResults ProcessCommunicator
@author gas@sparc.spb.su area=Clipboard
@run main ImageTransferTest
*/
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.process.ProcessCommunicator;
import test.java.awt.regtesthelpers.process.ProcessResults;
+import jdk.testlibrary.OSInfo;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
@@ -105,11 +105,15 @@
class Util {
+ private static Robot srobot = null;
public static void sync() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
try {
+ if(srobot == null) {
+ srobot = new Robot();
+ }
+ srobot.waitForIdle();
Thread.sleep(500);
- } catch (InterruptedException e) {
+ } catch (Exception e) {
throw new RuntimeException(e);
}
}
--- a/jdk/test/java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,7 +34,6 @@
import java.awt.Color;
import java.awt.Point;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetAdapter;
@@ -49,7 +48,6 @@
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
public class MissingDragExitEventTest {
@@ -108,7 +106,7 @@
} finally {
r.mouseRelease(InputEvent.BUTTON1_MASK);
}
- sleep();
+ sleep(r);
if (FAILED || !MOUSE_ENTERED || !MOUSE_ENTERED_DT || !MOUSE_EXIT
|| !MOUSE_EXIT_TD) {
@@ -121,12 +119,12 @@
}
}
- private static void sleep() {
+ private static void sleep(Robot robot) {
try {
Thread.sleep(10000);
} catch (InterruptedException ignored) {
}
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
}
static class TestdropTargetListener extends DropTargetAdapter {
--- a/jdk/test/java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -21,8 +21,6 @@
* questions.
*/
-import sun.awt.SunToolkit;
-
import java.awt.*;
import java.awt.event.AWTEventListener;
import java.awt.event.InputEvent;
@@ -71,7 +69,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Frame frame = new Frame();
try {
@@ -79,9 +76,9 @@
frame.setBounds(300, 300, 300, 300);
frame.add(b);
frame.setVisible(true);
- toolkit.realSync();
Robot robot = new Robot();
+ robot.waitForIdle();
robot.mouseMove((int)frame.getLocationOnScreen().getX() + 150,
(int)frame.getLocationOnScreen().getY() + 150);
@@ -104,7 +101,7 @@
System.out.println("Clicking mouse done: " + eventsCount + " events.");
b.requestFocusInWindow();
- toolkit.realSync();
+ robot.waitForIdle();
eventsCount = 0;
System.out.println("Typing a key...");
--- a/jdk/test/java/awt/event/KeyEvent/8020209/bug8020209.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/event/KeyEvent/8020209/bug8020209.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,13 +26,16 @@
* @bug 8020209
* @summary [macosx] Mac OS X key event confusion for "COMMAND PLUS"
* @author leonid.romanov@oracle.com
+ * @library ../../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
* @run main bug8020209
*/
-import sun.awt.*;
import java.awt.*;
import java.awt.event.*;
+import jdk.testlibrary.OSInfo;
+
public class bug8020209 {
static volatile int listenerCallCounter = 0;
@@ -43,19 +46,18 @@
};
public static void main(String[] args) throws Exception {
- if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
+ if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
return;
}
System.setProperty("apple.laf.useScreenMenuBar", "true");
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
createAndShowGUI();
- toolkit.realSync();
+ robot.waitForIdle();
for (int i = 0; i < keyStrokes.length; ++i) {
AWTKeyStroke ks = keyStrokes[i];
@@ -68,7 +70,7 @@
robot.keyRelease(modKeyCode);
- toolkit.realSync();
+ robot.waitForIdle();
if (listenerCallCounter != 4) {
throw new Exception("Test failed: KeyListener for '" + ks.toString() +
--- a/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,18 +26,19 @@
* @bug 7199180
* @summary [macosx] Dead keys handling for input methods
* @author alexandr.scherbatiy area=awt.event
+ * @library ../../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
* @run main DeadKeyMacOSXInputText
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.event.KeyEvent;
import javax.swing.JTextField;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+
+import jdk.testlibrary.OSInfo;
public class DeadKeyMacOSXInputText {
- private static SunToolkit toolkit;
private static volatile int state = 0;
public static void main(String[] args) throws Exception {
@@ -46,11 +47,10 @@
return;
}
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
- createAndShowGUI();
+ createAndShowGUI(robot);
// Pressed keys: Alt + E + A
// Results: ALT + VK_DEAD_ACUTE + a with accute accent
@@ -61,14 +61,14 @@
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
- toolkit.realSync();
+ robot.waitForIdle();
if (state != 3) {
throw new RuntimeException("Wrong number of key events.");
}
}
- static void createAndShowGUI() {
+ static void createAndShowGUI(Robot robot) {
Frame frame = new Frame();
frame.setSize(300, 300);
Panel panel = new Panel(new BorderLayout());
@@ -77,10 +77,10 @@
panel.add(textField, BorderLayout.CENTER);
frame.add(panel);
frame.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
textField.requestFocusInWindow();
- toolkit.realSync();
+ robot.waitForIdle();
}
--- a/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/DeadKeySystemAssertionDialog.java Wed Jul 05 20:11:52 2017 +0200
@@ -24,9 +24,7 @@
import java.awt.Frame;
import java.awt.Robot;
import java.awt.TextField;
-import java.awt.Toolkit;
import java.awt.event.KeyEvent;
-import sun.awt.SunToolkit;
/*
* @test
* @bug 8013849
@@ -39,25 +37,25 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Frame frame = new Frame();
frame.setSize(300, 200);
TextField textField = new TextField();
frame.add(textField);
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+
frame.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
textField.requestFocus();
- toolkit.realSync();
+ robot.waitForIdle();
// Check that the system assertion dialog does not block Java
- Robot robot = new Robot();
- robot.setAutoDelay(50);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
- toolkit.realSync();
+ robot.waitForIdle();
frame.setVisible(false);
frame.dispose();
--- a/jdk/test/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,18 +26,19 @@
* @bug 7196547
* @summary Dead Key implementation for KeyEvent on Mac OS X
* @author alexandr.scherbatiy area=awt.event
+ * @library ../../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
* @run main deadKeyMacOSX
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.event.KeyEvent;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+
+import jdk.testlibrary.OSInfo;
public class deadKeyMacOSX {
- private static SunToolkit toolkit;
private static volatile int state = 0;
public static void main(String[] args) throws Exception {
@@ -46,11 +47,10 @@
return;
}
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
- createAndShowGUI();
+ createAndShowGUI(robot);
// Pressed keys: Alt + E + A
// Results: ALT + VK_DEAD_ACUTE + a with accute accent
@@ -67,17 +67,17 @@
}
}
- static void createAndShowGUI() {
+ static void createAndShowGUI(Robot robot) {
Frame frame = new Frame();
frame.setSize(300, 300);
Panel panel = new Panel();
panel.addKeyListener(new DeadKeyListener());
frame.add(panel);
frame.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
panel.requestFocusInWindow();
- toolkit.realSync();
+ robot.waitForIdle();
}
static class DeadKeyListener extends KeyAdapter {
--- a/jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -23,17 +23,16 @@
import java.awt.Frame;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.KeyAdapter;
-import sun.awt.ExtendedKeyCodes;
-import sun.awt.SunToolkit;
/*
* @test
* @bug 8007156 8025126
* @summary Extended key code is not set for a key event
* @author Alexandr Scherbatiy
+ * @library ../../../../../lib/testlibrary
+ * @build ExtendedRobot
* @run main ExtendedKeyCodeTest
*/
public class ExtendedKeyCodeTest {
@@ -42,8 +41,7 @@
private static volatile int eventsCount = 0;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- Robot robot = new Robot();
+ ExtendedRobot robot = new ExtendedRobot();
robot.setAutoDelay(50);
Frame frame = new Frame();
@@ -55,23 +53,23 @@
public void keyPressed(KeyEvent e) {
eventsCount++;
setExtendedKeyCode = setExtendedKeyCode && (e.getExtendedKeyCode()
- == ExtendedKeyCodes.getExtendedKeyCodeForChar(e.getKeyChar()));
+ == KeyEvent.getExtendedKeyCodeForChar(e.getKeyChar()));
}
@Override
public void keyReleased(KeyEvent e) {
eventsCount++;
setExtendedKeyCode = setExtendedKeyCode && (e.getExtendedKeyCode()
- == ExtendedKeyCodes.getExtendedKeyCodeForChar(e.getKeyChar()));
+ == KeyEvent.getExtendedKeyCodeForChar(e.getKeyChar()));
}
});
frame.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_D);
robot.keyRelease(KeyEvent.VK_D);
- toolkit.realSync();
+ robot.waitForIdle();
frame.dispose();
@@ -92,11 +90,11 @@
});
frame.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_LEFT);
robot.keyRelease(KeyEvent.VK_LEFT);
- toolkit.realSync();
+ robot.waitForIdle();
frame.dispose();
if (!setExtendedKeyCode) {
--- a/jdk/test/java/awt/event/KeyEvent/KeyChar/KeyCharTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/event/KeyEvent/KeyChar/KeyCharTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,7 +28,6 @@
import java.awt.event.AWTEventListener;
import java.awt.event.KeyEvent;
import java.util.Locale;
-import sun.awt.SunToolkit;
/*
* @test
@@ -59,18 +58,18 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Frame frame = new Frame();
frame.setSize(300, 300);
frame.setVisible(true);
- toolkit.realSync();
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
- Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_DELETE);
robot.keyRelease(KeyEvent.VK_DELETE);
- toolkit.realSync();
+ robot.waitForIdle();
frame.dispose();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 1998, 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 1.2 98/08/05
+ @bug 4515763
+ @summary Tests that clicking mouse and pressing keys generates correct amount of click-counts
+ @author andrei.dmitriev: area=awt.mouse
+ @run main ClickDuringKeypress
+*/
+
+/**
+ * ClickDuringKeypress.java
+ *
+ * summary:
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+public class ClickDuringKeypress implements MouseListener
+ {
+ //Declare things used in the test, like buttons and labels here
+ final static int CLICKCOUNT = 10;
+ final static int DOUBLE_CLICK_AUTO_DELAY = 10;
+ volatile int lastClickCount = 0;
+ volatile boolean clicked = false;
+ volatile boolean ready = false;
+
+ Frame frame;
+ Robot robot;
+
+ public void init()
+ {
+ //Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+
+ frame = new Frame("ClickDuringKeypress");
+ frame.addMouseListener(this);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowActivated(WindowEvent e) {
+ synchronized(ClickDuringKeypress.this) {
+ ready = true;
+ ClickDuringKeypress.this.notifyAll();
+ }
+ }
+ });
+ frame.setBounds(0, 0, 400, 400);
+
+ start();
+
+ }//End init()
+
+ public void start ()
+ {
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ System.out.println("Could not create Robot.");
+ throw new RuntimeException("Couldn't create Robot. Test fails");
+ }
+
+ robot.mouseMove(200, 200);
+ frame.show();
+
+ synchronized(this) {
+ try {
+ if (!ready) {
+ wait(10000);
+ }
+ } catch (InterruptedException ex) {
+ }
+ if (!ready) {
+ System.out.println("Not Activated. Test fails");
+ throw new RuntimeException("Not Activated. Test fails");
+ }
+ }
+
+ doTest();
+
+ //What would normally go into main() will probably go here.
+ //Use System.out.println for diagnostic messages that you want
+ //to read after the test is done.
+ //Use Sysout.println for messages you want the tester to read.
+
+ }// start()
+
+ // Mouse should be over the Frame by this point
+ private void doTest() {
+ robot.setAutoDelay(2000);
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_B);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(10);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ // Should trigger mouseClicked
+ robot.keyRelease(KeyEvent.VK_B);
+ robot.delay(1000);
+
+ robot.setAutoDelay(DOUBLE_CLICK_AUTO_DELAY);
+ for (int i = 0; i < CLICKCOUNT / 2; i++) {
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(10);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.keyPress(KeyEvent.VK_B);
+ robot.delay(10);
+ robot.keyRelease(KeyEvent.VK_B);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(10);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+ robot.waitForIdle();
+ // check results
+ robot.delay(200);
+ if (!clicked) {
+ System.out.println("No MOUSE_CLICKED events received. Test fails.");
+ throw new RuntimeException("No MOUSE_CLICKED events received. Test fails.");
+ }
+ if (lastClickCount != CLICKCOUNT) {
+ System.out.println("Actual click count: " + lastClickCount + " does not match expected click count: " + CLICKCOUNT + ". Test fails");
+ throw new RuntimeException("Actual click count: " + lastClickCount + " does not match expected click count: " + CLICKCOUNT + ". Test fails");
+
+ }
+ // else test passes.
+ }
+
+ public void mouseEntered(MouseEvent e) {}
+ public void mouseExited(MouseEvent e) {}
+ public void mousePressed(MouseEvent e) {}
+ public void mouseReleased(MouseEvent e) {}
+ public void mouseClicked(MouseEvent e) {
+ System.out.println(e.toString());
+ clicked = true;
+ lastClickCount = e.getClickCount();
+ }
+
+ public static void main(String[] args) {
+ new ClickDuringKeypress().init();
+ }
+
+ }// class ClickDuringKeypress
--- a/jdk/test/java/awt/event/MouseWheelEvent/DisabledComponent/DisabledComponent.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/event/MouseWheelEvent/DisabledComponent/DisabledComponent.java Wed Jul 05 20:11:52 2017 +0200
@@ -24,9 +24,9 @@
/*
@test
@bug 6847958
- @library ../../../regtesthelpers
@summary MouseWheel event is getting triggered for the disabled Textarea in jdk7 b60 pit build.
@author Dmitry Cherepanov: area=awt.event
+ @library ../../../regtesthelpers
@build Util
@run main DisabledComponent
*/
@@ -40,8 +40,6 @@
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
-
import test.java.awt.regtesthelpers.Util;
public class DisabledComponent
@@ -72,21 +70,21 @@
}
};
+ Robot robot = new Robot();
+
list.addMouseWheelListener(listener);
textArea.addMouseWheelListener(listener);
frame.setVisible(true);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
-
- Robot robot = new Robot();
+ robot.waitForIdle();
// point and wheel on the list
Util.pointOnComp(list, robot);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
robot.mouseWheel(2);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
// disable the text area
System.err.println(" disable text area ");
@@ -95,10 +93,10 @@
// point and wheel on the text area
Util.pointOnComp(textArea, robot);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
robot.mouseWheel(2);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
if (!passed) {
throw new RuntimeException(" wrong wheel events ");
--- a/jdk/test/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,7 +27,7 @@
@summary REGRESSION: Popup menus dont respond to selections when extend outside Applet
@author oleg.sukhodolsky area=awt.grab
@library ../../regtesthelpers
- @build Util
+ @build Util UtilInternal
@run main EmbeddedFrameTest1
*/
@@ -44,6 +44,7 @@
import java.awt.Robot;
import java.awt.TextArea;
import java.awt.Toolkit;
+import java.awt.AWTException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -51,40 +52,21 @@
import javax.swing.JButton;
import javax.swing.JPopupMenu;
-import sun.awt.SunToolkit;
-
import test.java.awt.regtesthelpers.Util;
+import test.java.awt.regtesthelpers.UtilInternal;
public class EmbeddedFrameTest1
{
- private static void init()
+ public static void main( String args[] ) throws AWTException
{
- //*** Create instructions for the user here ***
-
- String[] instructions = {
- "This is an AUTOMATIC test, simply wait until it is done.",
- "The result (passed or failed) will be shown in the",
- "message window below."
- };
-
- Sysout.createDialog( );
- Sysout.printInstructions( instructions );
-
- SunToolkit tk = (SunToolkit) Toolkit.getDefaultToolkit();
- if ("sun.awt.motif.MToolkit".equals(tk.getClass().getName())) {
- System.out.println("We shouldn't test MToolkit.");
- EmbeddedFrameTest1.pass();
- return;
- }
-
try {
final Frame frame = new Frame("AWT Frame");
frame.pack();
frame.setSize(200,200);
- final Frame embedded_frame = Util.createEmbeddedFrame(frame);
+ final Frame embedded_frame = UtilInternal.createEmbeddedFrame(frame);
embedded_frame.setSize(200, 200);
- Sysout.println("embedded_frame = " + embedded_frame);
+ System.out.println("embedded_frame = " + embedded_frame);
final JPopupMenu menu = new JPopupMenu();
JButton item = new JButton("A button in popup");
@@ -110,12 +92,12 @@
p.validate();
frame.setVisible(true);
Robot robot = new Robot();
- tk.realSync();
+ robot.waitForIdle();
Util.clickOnComp(btn, robot);
- tk.realSync();
+ robot.waitForIdle();
Util.clickOnComp(item, robot);
- tk.realSync();
+ robot.waitForIdle();
if (item.getMousePosition() == null) {
throw new RuntimeException("Popup was not closed (mouse above it)");
}
@@ -124,268 +106,7 @@
frame.dispose();
} catch (Throwable thr) {
thr.printStackTrace();
- EmbeddedFrameTest1.fail("TEST FAILED: " + thr);
- }
- EmbeddedFrameTest1.pass();
- }//End init()
-
- /*****************************************************
- * Standard Test Machinery Section
- * DO NOT modify anything in this section -- it's a
- * standard chunk of code which has all of the
- * synchronisation necessary for the test harness.
- * By keeping it the same in all tests, it is easier
- * to read and understand someone else's test, as
- * well as insuring that all tests behave correctly
- * with the test harness.
- * There is a section following this for test-
- * classes
- ******************************************************/
- private static boolean theTestPassed = false;
- private static boolean testGeneratedInterrupt = false;
- private static String failureMessage = "";
-
- private static Thread mainThread = null;
-
- private static int sleepTime = 300000;
-
- // Not sure about what happens if multiple of this test are
- // instantiated in the same VM. Being static (and using
- // static vars), it aint gonna work. Not worrying about
- // it for now.
- public static void main( String args[] ) throws InterruptedException
- {
- mainThread = Thread.currentThread();
- try
- {
- init();
- }
- catch( TestPassedException e )
- {
- //The test passed, so just return from main and harness will
- // interepret this return as a pass
- return;
- }
- //At this point, neither test pass nor test fail has been
- // called -- either would have thrown an exception and ended the
- // test, so we know we have multiple threads.
-
- //Test involves other threads, so sleep and wait for them to
- // called pass() or fail()
- try
- {
- Thread.sleep( sleepTime );
- //Timed out, so fail the test
- throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ throw new RuntimeException("TEST FAILED: " + thr);
}
- catch (InterruptedException e)
- {
- //The test harness may have interrupted the test. If so, rethrow the exception
- // so that the harness gets it and deals with it.
- if( ! testGeneratedInterrupt ) throw e;
-
- //reset flag in case hit this code more than once for some reason (just safety)
- testGeneratedInterrupt = false;
-
- if ( theTestPassed == false )
- {
- throw new RuntimeException( failureMessage );
- }
- }
-
- }//main
-
- public static synchronized void setTimeoutTo( int seconds )
- {
- sleepTime = seconds * 1000;
}
-
- public static synchronized void pass()
- {
- Sysout.println( "The test passed." );
- Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
- //first check if this is executing in main thread
- if ( mainThread == Thread.currentThread() )
- {
- //Still in the main thread, so set the flag just for kicks,
- // and throw a test passed exception which will be caught
- // and end the test.
- theTestPassed = true;
- throw new TestPassedException();
- }
- theTestPassed = true;
- testGeneratedInterrupt = true;
- mainThread.interrupt();
- }//pass()
-
- public static synchronized void fail()
- {
- //test writer didn't specify why test failed, so give generic
- fail( "it just plain failed! :-)" );
- }
-
- public static synchronized void fail( String whyFailed )
- {
- Sysout.println( "The test failed: " + whyFailed );
- Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
- //check if this called from main thread
- if ( mainThread == Thread.currentThread() )
- {
- //If main thread, fail now 'cause not sleeping
- throw new RuntimeException( whyFailed );
- }
- theTestPassed = false;
- testGeneratedInterrupt = true;
- failureMessage = whyFailed;
- mainThread.interrupt();
- }//fail()
-
-}// class EmbeddedFrameTest1
-
-//This exception is used to exit from any level of call nesting
-// when it's determined that the test has passed, and immediately
-// end the test.
-class TestPassedException extends RuntimeException
-{
}
-
-//*********** End Standard Test Machinery Section **********
-
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
- chunk of code whose purpose is to make user
- interaction uniform, and thereby make it simpler
- to read and understand someone else's test.
- ****************************************************/
-
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
- for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
- WithInstructions method. Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
- with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
- as standalone.
- */
-
-class Sysout
-{
- private static TestDialog dialog;
-
- public static void createDialogWithInstructions( String[] instructions )
- {
- dialog = new TestDialog( new Frame(), "Instructions" );
- dialog.printInstructions( instructions );
- dialog.setVisible(true);
- println( "Any messages for the tester will display here." );
- }
-
- public static void createDialog( )
- {
- dialog = new TestDialog( new Frame(), "Instructions" );
- String[] defInstr = { "Instructions will appear here. ", "" } ;
- dialog.printInstructions( defInstr );
- dialog.setVisible(true);
- println( "Any messages for the tester will display here." );
- }
-
-
- public static void printInstructions( String[] instructions )
- {
- dialog.printInstructions( instructions );
- }
-
-
- public static void println( String messageIn )
- {
- dialog.displayMessage( messageIn );
- System.out.println(messageIn);
- }
-
-}// Sysout class
-
-/**
- This is part of the standard test machinery. It provides a place for the
- test instructions to be displayed, and a place for interactive messages
- to the user to be displayed.
- To have the test instructions displayed, see Sysout.
- To have a message to the user be displayed, see Sysout.
- Do not call anything in this dialog directly.
- */
-class TestDialog extends Dialog
-{
-
- TextArea instructionsText;
- TextArea messageText;
- int maxStringLength = 80;
-
- //DO NOT call this directly, go through Sysout
- public TestDialog( Frame frame, String name )
- {
- super( frame, name );
- int scrollBoth = TextArea.SCROLLBARS_BOTH;
- instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
- add( "North", instructionsText );
-
- messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
- add("Center", messageText);
-
- pack();
-
- setVisible(true);
- }// TestDialog()
-
- //DO NOT call this directly, go through Sysout
- public void printInstructions( String[] instructions )
- {
- //Clear out any current instructions
- instructionsText.setText( "" );
-
- //Go down array of instruction strings
-
- String printStr, remainingStr;
- for( int i=0; i < instructions.length; i++ )
- {
- //chop up each into pieces maxSringLength long
- remainingStr = instructions[ i ];
- while( remainingStr.length() > 0 )
- {
- //if longer than max then chop off first max chars to print
- if( remainingStr.length() >= maxStringLength )
- {
- //Try to chop on a word boundary
- int posOfSpace = remainingStr.
- lastIndexOf( ' ', maxStringLength - 1 );
-
- if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
- printStr = remainingStr.substring( 0, posOfSpace + 1 );
- remainingStr = remainingStr.substring( posOfSpace + 1 );
- }
- //else just print
- else
- {
- printStr = remainingStr;
- remainingStr = "";
- }
-
- instructionsText.append( printStr + "\n" );
-
- }// while
-
- }// for
-
- }//printInstructions()
-
- //DO NOT call this directly, go through Sysout
- public void displayMessage( String messageIn )
- {
- messageText.append( messageIn + "\n" );
- System.out.println(messageIn);
- }
-
-}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/grab/MenuDragEvents/MenuDragEvents.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,44 @@
+<!--
+ 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
+ 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.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6390326
+ @summary REGRESSION: Broken mouse behaviour of menus partially outside the main window.
+ @author oleg.sukhodolsky: area=awt-drab
+ @run applet MenuDragEvents.html
+ -->
+<head>
+<title> </title>
+</head>
+<body>
+
+<h1>MenuDragEvents<br>Bug ID: 6390326 </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="MenuDragEvents.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/grab/MenuDragEvents/MenuDragEvents.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,195 @@
+/*
+ * 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
+ * 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 6390326
+ @summary REGRESSION: Broken mouse behaviour of menus partially outside the main window.
+ @author oleg.sukhodolsky: area=awt-drab
+ @run applet AutomaticAppletTest.html
+*/
+
+/**
+ * MenuDragEvents.java
+ *
+ * summary: REGRESSION: Broken mouse behaviour of menus partially outside the main window.
+ */
+
+import java.applet.Applet;
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.BorderLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Toolkit;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.AWTEventListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.WindowConstants;
+
+import javax.swing.event.MenuDragMouseEvent;
+import javax.swing.event.MenuDragMouseListener;
+
+public class MenuDragEvents extends Applet
+{
+ //Declare things used in the test, like buttons and labels here
+ boolean mouseDragged = false;
+ boolean mouseEntered = false;
+ boolean mouseReleased = false;
+ boolean actionReceived = false;
+
+ public void init()
+ {
+ // Set up the environment -- set the layout manager, add
+ // buttons, etc.
+
+ setLayout (new BorderLayout ());
+
+ }//End init()
+
+ public void start ()
+ {
+ //Get things going. Request focus, set size, et cetera
+ setSize (200,200);
+ setVisible(true);
+ validate();
+
+ Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+ public void eventDispatched(AWTEvent event) {
+ int id = event.getID();
+ if (id == MouseEvent.MOUSE_ENTERED || id == MouseEvent.MOUSE_EXITED) {
+ System.err.println(event);
+ }
+ }
+ }, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
+ JMenuBar mb = new JMenuBar();
+
+ JMenu m = new JMenu("A Menu");
+ mb.add(m);
+
+ JMenuItem i = new JMenuItem("A menu item",KeyEvent.VK_A);
+ m.add(i);
+
+ m = new JMenu("Another Menu");
+ mb.add(m);
+ i = new JMenuItem("Yet another menu item",KeyEvent.VK_Y);
+ m.add(i);
+ i.addMenuDragMouseListener(new MenuDragMouseListener() {
+ public void menuDragMouseDragged(MenuDragMouseEvent e) {
+ System.err.println(e);
+ mouseDragged = true;
+ }
+ public void menuDragMouseEntered(MenuDragMouseEvent e) {
+ System.err.println(e);
+ mouseEntered = true;
+ }
+ public void menuDragMouseReleased(MenuDragMouseEvent e) {
+ System.err.println(e);
+ mouseReleased = true;
+ }
+ // perhaps we need to test mouse exited too
+ // but this doesn't work even with tiger
+ public void menuDragMouseExited(MenuDragMouseEvent e) {
+ System.err.println(e);
+ }
+ });
+
+ i.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ System.err.println(ae);
+ actionReceived = true;
+ }
+ });
+
+ JFrame frame = new JFrame("Menu");
+ frame.setJMenuBar(mb);
+ frame.setSize(200, 200);
+ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ frame.setVisible(true);
+
+ Robot r = null;
+ try {
+ r = new Robot();
+ r.setAutoDelay(50);
+ }
+ catch (AWTException ae) {
+ throw new RuntimeException(ae);
+ }
+
+ r.waitForIdle();
+
+ Point loc = m.getLocationOnScreen();
+ loc.x += m.getWidth() / 2;
+ loc.y += m.getHeight() / 2;
+ r.mouseMove(loc.x, loc.y);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+
+ r.waitForIdle();
+ r.delay(1000);
+
+ Point loc2 = i.getLocationOnScreen();
+ loc2.x += i.getWidth() / 2;
+ loc2.y += i.getHeight() / 2;
+
+ // move from menu on menubar to menu item
+ dragMouse(r, loc, loc2);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+ r.waitForIdle();
+ r.delay(1000);
+
+ if (!mouseEntered || !mouseDragged || !mouseReleased || !actionReceived) {
+ throw new RuntimeException("we expected to receive both mouseEntered and MouseDragged ("
+ + mouseEntered + ", " + mouseDragged + ", " + mouseReleased
+ + ", " + actionReceived + ")");
+ }
+
+ System.out.println("Test passed");
+ }// start()
+
+ void dragMouse(Robot r, Point from, Point to) {
+ final int n_step = 10;
+ int step_x = (to.x - from.x) / n_step;
+ int step_y = (to.y - from.y) / n_step;
+ int x = from.x;
+ int y = from.y;
+ for (int idx = 0; idx < n_step; idx++) {
+ x += step_x;
+ y += step_y;
+ r.mouseMove(x, y);
+ r.delay(10);
+ }
+ if (x != to.x || y != to.y) {
+ r.mouseMove(to.x, to.y);
+ r.delay(10);
+ }
+ }
+
+}// class MenuDragEvents
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/DrawImage/IncorrectUnmanagedImageRotatedClip.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * 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.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferShort;
+import java.awt.image.VolatileImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import static java.awt.Transparency.TRANSLUCENT;
+import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
+
+/**
+ * @test
+ * @bug 8059942
+ * @summary Tests rotated clip when unmanaged image is drawn to VI.
+ * Results of the blit to compatibleImage are used for comparison.
+ * @author Sergey Bylokhov
+ */
+public final class IncorrectUnmanagedImageRotatedClip {
+
+ public static void main(final String[] args) throws IOException {
+ BufferedImage bi = makeUnmanagedBI();
+ fill(bi);
+ test(bi);
+ }
+
+ private static void test(final BufferedImage bi) throws IOException {
+ GraphicsEnvironment ge = GraphicsEnvironment
+ .getLocalGraphicsEnvironment();
+ GraphicsConfiguration gc = ge.getDefaultScreenDevice()
+ .getDefaultConfiguration();
+ VolatileImage vi = gc.createCompatibleVolatileImage(500, 200,
+ TRANSLUCENT);
+ BufferedImage gold = gc.createCompatibleImage(500, 200, TRANSLUCENT);
+ // draw to compatible Image
+ draw(bi, gold);
+ // draw to volatile image
+ int attempt = 0;
+ BufferedImage snapshot;
+ while (true) {
+ if (++attempt > 10) {
+ throw new RuntimeException("Too many attempts: " + attempt);
+ }
+ vi.validate(gc);
+ if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
+ continue;
+ }
+ draw(bi, vi);
+ snapshot = vi.getSnapshot();
+ if (vi.contentsLost()) {
+ continue;
+ }
+ break;
+ }
+ // validate images
+ for (int x = 0; x < gold.getWidth(); ++x) {
+ for (int y = 0; y < gold.getHeight(); ++y) {
+ if (gold.getRGB(x, y) != snapshot.getRGB(x, y)) {
+ ImageIO.write(gold, "png", new File("gold.png"));
+ ImageIO.write(snapshot, "png", new File("bi.png"));
+ throw new RuntimeException("Test failed.");
+ }
+ }
+ }
+ }
+
+ private static void draw(final BufferedImage from,final Image to) {
+ final Graphics2D g2d = (Graphics2D) to.getGraphics();
+ g2d.setComposite(AlphaComposite.Src);
+ g2d.setColor(Color.ORANGE);
+ g2d.fillRect(0, 0, to.getWidth(null), to.getHeight(null));
+ g2d.rotate(Math.toRadians(45));
+ g2d.clip(new Rectangle(41, 42, 43, 44));
+ g2d.drawImage(from, 50, 50, Color.blue, null);
+ g2d.dispose();
+ }
+
+ private static BufferedImage makeUnmanagedBI() {
+ final BufferedImage bi = new BufferedImage(500, 200, TYPE_INT_ARGB);
+ final DataBuffer db = bi.getRaster().getDataBuffer();
+ if (db instanceof DataBufferInt) {
+ ((DataBufferInt) db).getData();
+ } else if (db instanceof DataBufferShort) {
+ ((DataBufferShort) db).getData();
+ } else if (db instanceof DataBufferByte) {
+ ((DataBufferByte) db).getData();
+ } else {
+ try {
+ bi.setAccelerationPriority(0.0f);
+ } catch (final Throwable ignored) {
+ }
+ }
+ return bi;
+ }
+
+ private static void fill(final Image image) {
+ final Graphics2D graphics = (Graphics2D) image.getGraphics();
+ graphics.setComposite(AlphaComposite.Src);
+ for (int i = 0; i < image.getHeight(null); ++i) {
+ graphics.setColor(new Color(i, 0, 0));
+ graphics.fillRect(0, i, image.getWidth(null), 1);
+ }
+ graphics.dispose();
+ }
+}
--- a/jdk/test/java/awt/regtesthelpers/Util.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/awt/regtesthelpers/Util.java Wed Jul 05 20:11:52 2017 +0200
@@ -63,8 +63,6 @@
import java.awt.event.FocusListener;
import java.awt.event.ActionListener;
-import java.awt.peer.FramePeer;
-
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@@ -89,40 +87,6 @@
}
}
- public static Frame createEmbeddedFrame(final Frame embedder)
- throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException,
- InstantiationException, InvocationTargetException
- {
- Toolkit tk = Toolkit.getDefaultToolkit();
- FramePeer frame_peer = (FramePeer) embedder.getPeer();
- System.out.println("frame's peer = " + frame_peer);
- if ("sun.awt.windows.WToolkit".equals(tk.getClass().getName())) {
- Class comp_peer_class =
- Class.forName("sun.awt.windows.WComponentPeer");
- System.out.println("comp peer class = " + comp_peer_class);
- Field hwnd_field = comp_peer_class.getDeclaredField("hwnd");
- hwnd_field.setAccessible(true);
- System.out.println("hwnd_field =" + hwnd_field);
- long hwnd = hwnd_field.getLong(frame_peer);
- System.out.println("hwnd = " + hwnd);
-
- Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
- Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE});
- return (Frame) constructor.newInstance (new Object[] {hwnd});
- } else if ("sun.awt.X11.XToolkit".equals(tk.getClass().getName())) {
- Class x_base_window_class = Class.forName("sun.awt.X11.XBaseWindow");
- System.out.println("x_base_window_class = " + x_base_window_class);
- Method get_window = x_base_window_class.getMethod("getWindow", new Class[0]);
- System.out.println("get_window = " + get_window);
- long window = (Long) get_window.invoke(frame_peer, new Object[0]);
- System.out.println("window = " + window);
- Class clazz = Class.forName("sun.awt.X11.XEmbeddedFrame");
- Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE, Boolean.TYPE});
- return (Frame) constructor.newInstance (new Object[] {window, true});
- }
-
- throw new RuntimeException("Unexpected toolkit - " + tk);
- }
/**
* Makes the window visible and waits until it's shown.
@@ -237,8 +201,7 @@
}
public static void waitForIdle(final Robot robot) {
- // we do not use robot for now, use SunToolkit.realSync() instead
- ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
}
public static Field getField(final Class klass, final String fieldName) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/regtesthelpers/UtilInternal.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * 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
+ * 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.java.awt.regtesthelpers;
+
+import java.awt.peer.FramePeer;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.awt.Toolkit;
+import java.awt.Frame;
+
+
+
+/**
+ Class with static methods using internal/proprietary API by necessity.
+*/
+public final class UtilInternal {
+
+ private UtilInternal () {} // this is a helper class with static methods :)
+
+ public static Frame createEmbeddedFrame(final Frame embedder)
+ throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException,
+ InstantiationException, InvocationTargetException
+ {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ FramePeer frame_peer = (FramePeer) embedder.getPeer();
+ System.out.println("frame's peer = " + frame_peer);
+ if ("sun.awt.windows.WToolkit".equals(tk.getClass().getName())) {
+ Class comp_peer_class =
+ Class.forName("sun.awt.windows.WComponentPeer");
+ System.out.println("comp peer class = " + comp_peer_class);
+ Field hwnd_field = comp_peer_class.getDeclaredField("hwnd");
+ hwnd_field.setAccessible(true);
+ System.out.println("hwnd_field =" + hwnd_field);
+ long hwnd = hwnd_field.getLong(frame_peer);
+ System.out.println("hwnd = " + hwnd);
+
+ Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame");
+ Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE});
+ return (Frame) constructor.newInstance (new Object[] {hwnd});
+ } else if ("sun.awt.X11.XToolkit".equals(tk.getClass().getName())) {
+ Class x_base_window_class = Class.forName("sun.awt.X11.XBaseWindow");
+ System.out.println("x_base_window_class = " + x_base_window_class);
+ Method get_window = x_base_window_class.getMethod("getWindow", new Class[0]);
+ System.out.println("get_window = " + get_window);
+ long window = (Long) get_window.invoke(frame_peer, new Object[0]);
+ System.out.println("window = " + window);
+ Class clazz = Class.forName("sun.awt.X11.XEmbeddedFrame");
+ Constructor constructor = clazz.getConstructor (new Class [] {Long.TYPE, Boolean.TYPE});
+ return (Frame) constructor.newInstance (new Object[] {window, true});
+ }
+
+ throw new RuntimeException("Unexpected toolkit - " + tk);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/InputStream/TransferTo.java Wed Jul 05 20:11:52 2017 +0200
@@ -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.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Random;
+
+import static java.lang.String.format;
+
+/*
+ * @test
+ * @bug 8066867
+ * @summary tests whether java.io.InputStream.transferTo conforms to its
+ * contract defined in the javadoc
+ */
+public class TransferTo {
+
+ public static void main(String[] args) throws IOException {
+ ifOutIsNullThenNpeIsThrown();
+ ifExceptionInInputNeitherStreamIsClosed();
+ ifExceptionInOutputNeitherStreamIsClosed();
+ onReturnNeitherStreamIsClosed();
+ onReturnInputIsAtEnd();
+ contents();
+ }
+
+ private static void ifOutIsNullThenNpeIsThrown() throws IOException {
+ try (InputStream in = input()) {
+ assertThrowsNPE(() -> in.transferTo(null), "out");
+ }
+
+ try (InputStream in = input((byte) 1)) {
+ assertThrowsNPE(() -> in.transferTo(null), "out");
+ }
+
+ try (InputStream in = input((byte) 1, (byte) 2)) {
+ assertThrowsNPE(() -> in.transferTo(null), "out");
+ }
+
+ InputStream in = null;
+ try {
+ InputStream fin = in = new ThrowingInputStream();
+ // null check should precede everything else:
+ // InputStream shouldn't be touched if OutputStream is null
+ assertThrowsNPE(() -> fin.transferTo(null), "out");
+ } finally {
+ if (in != null)
+ try {
+ in.close();
+ } catch (IOException ignored) { }
+ }
+ }
+
+ private static void ifExceptionInInputNeitherStreamIsClosed()
+ throws IOException {
+ transferToThenCheckIfAnyClosed(input(0, new byte[]{1, 2, 3}), output());
+ transferToThenCheckIfAnyClosed(input(1, new byte[]{1, 2, 3}), output());
+ transferToThenCheckIfAnyClosed(input(2, new byte[]{1, 2, 3}), output());
+ }
+
+ private static void ifExceptionInOutputNeitherStreamIsClosed()
+ throws IOException {
+ transferToThenCheckIfAnyClosed(input(new byte[]{1, 2, 3}), output(0));
+ transferToThenCheckIfAnyClosed(input(new byte[]{1, 2, 3}), output(1));
+ transferToThenCheckIfAnyClosed(input(new byte[]{1, 2, 3}), output(2));
+ }
+
+ private static void transferToThenCheckIfAnyClosed(InputStream input,
+ OutputStream output)
+ throws IOException {
+ try (CloseLoggingInputStream in = new CloseLoggingInputStream(input);
+ CloseLoggingOutputStream out =
+ new CloseLoggingOutputStream(output)) {
+ boolean thrown = false;
+ try {
+ in.transferTo(out);
+ } catch (IOException ignored) {
+ thrown = true;
+ }
+ if (!thrown)
+ throw new AssertionError();
+
+ if (in.wasClosed() || out.wasClosed()) {
+ throw new AssertionError();
+ }
+ }
+ }
+
+ private static void onReturnNeitherStreamIsClosed()
+ throws IOException {
+ try (CloseLoggingInputStream in =
+ new CloseLoggingInputStream(input(new byte[]{1, 2, 3}));
+ CloseLoggingOutputStream out =
+ new CloseLoggingOutputStream(output())) {
+
+ in.transferTo(out);
+
+ if (in.wasClosed() || out.wasClosed()) {
+ throw new AssertionError();
+ }
+ }
+ }
+
+ private static void onReturnInputIsAtEnd() throws IOException {
+ try (InputStream in = input(new byte[]{1, 2, 3});
+ OutputStream out = output()) {
+
+ in.transferTo(out);
+
+ if (in.read() != -1) {
+ throw new AssertionError();
+ }
+ }
+ }
+
+ private static void contents() throws IOException {
+ checkTransferredContents(new byte[0]);
+ checkTransferredContents(createRandomBytes(1024, 4096));
+ // to span through several batches
+ checkTransferredContents(createRandomBytes(16384, 16384));
+ }
+
+ private static void checkTransferredContents(byte[] bytes)
+ throws IOException {
+ try (InputStream in = input(bytes);
+ ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+ in.transferTo(out);
+
+ byte[] outBytes = out.toByteArray();
+ if (!Arrays.equals(bytes, outBytes)) {
+ throw new AssertionError(
+ format("bytes.length=%s, outBytes.length=%s",
+ bytes.length, outBytes.length));
+ }
+ }
+ }
+
+ private static byte[] createRandomBytes(int min, int maxRandomAdditive) {
+ Random rnd = new Random();
+ byte[] bytes = new byte[min + rnd.nextInt(maxRandomAdditive)];
+ rnd.nextBytes(bytes);
+ return bytes;
+ }
+
+ private static OutputStream output() {
+ return output(-1);
+ }
+
+ private static OutputStream output(int exceptionPosition) {
+ return new OutputStream() {
+
+ int pos;
+
+ @Override
+ public void write(int b) throws IOException {
+ if (pos++ == exceptionPosition)
+ throw new IOException();
+ }
+ };
+ }
+
+ private static InputStream input(byte... bytes) {
+ return input(-1, bytes);
+ }
+
+ private static InputStream input(int exceptionPosition, byte... bytes) {
+ return new InputStream() {
+
+ int pos;
+
+ @Override
+ public int read() throws IOException {
+ if (pos == exceptionPosition) {
+ // because of the pesky IOException swallowing in
+ // java.io.InputStream.read(byte[], int, int)
+ // pos++;
+ throw new IOException();
+ }
+
+ if (pos >= bytes.length)
+ return -1;
+ return bytes[pos++] & 0xff;
+ }
+ };
+ }
+
+ private static class ThrowingInputStream extends InputStream {
+
+ boolean closed;
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ throw new IOException();
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ throw new IOException();
+ }
+
+ @Override
+ public long skip(long n) throws IOException {
+ throw new IOException();
+ }
+
+ @Override
+ public int available() throws IOException {
+ throw new IOException();
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (!closed) {
+ closed = true;
+ throw new IOException();
+ }
+ }
+
+ @Override
+ public void reset() throws IOException {
+ throw new IOException();
+ }
+
+ @Override
+ public int read() throws IOException {
+ throw new IOException();
+ }
+ }
+
+ private static class CloseLoggingInputStream extends FilterInputStream {
+
+ boolean closed;
+
+ CloseLoggingInputStream(InputStream in) {
+ super(in);
+ }
+
+ @Override
+ public void close() throws IOException {
+ closed = true;
+ super.close();
+ }
+
+ boolean wasClosed() {
+ return closed;
+ }
+ }
+
+ private static class CloseLoggingOutputStream extends FilterOutputStream {
+
+ boolean closed;
+
+ CloseLoggingOutputStream(OutputStream out) {
+ super(out);
+ }
+
+ @Override
+ public void close() throws IOException {
+ closed = true;
+ super.close();
+ }
+
+ boolean wasClosed() {
+ return closed;
+ }
+ }
+
+ public interface Thrower {
+ public void run() throws Throwable;
+ }
+
+ public static void assertThrowsNPE(Thrower thrower, String message) {
+ assertThrows(thrower, NullPointerException.class, message);
+ }
+
+ public static <T extends Throwable> void assertThrows(Thrower thrower,
+ Class<T> throwable,
+ String message) {
+ Throwable thrown;
+ try {
+ thrower.run();
+ thrown = null;
+ } catch (Throwable caught) {
+ thrown = caught;
+ }
+
+ if (!throwable.isInstance(thrown)) {
+ String caught = thrown == null ?
+ "nothing" : thrown.getClass().getCanonicalName();
+ throw new AssertionError(
+ format("Expected to catch %s, but caught %s",
+ throwable, caught), thrown);
+ }
+
+ if (thrown != null && !message.equals(thrown.getMessage())) {
+ throw new AssertionError(
+ format("Expected exception message to be '%s', but it's '%s'",
+ message, thrown.getMessage()));
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/ObjectInputStream/PeekInputStreamTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,91 @@
+/*
+ * 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.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/*
+ * @test
+ * @bug 8067870
+ * @summary verifies java.io.ObjectInputStream.PeekInputStream.skip works
+ * as intended
+ */
+public class PeekInputStreamTest {
+
+ public static void main(String[] args) throws ReflectiveOperationException,
+ IOException {
+
+ InputStream pin = createPeekInputStream(
+ new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
+ peek(pin);
+ if (pin.skip(1) != 1 || pin.read() != 2)
+ throw new AssertionError();
+
+ InputStream pin1 = createPeekInputStream(
+ new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
+ if (pin1.skip(1) != 1 || pin1.read() != 2)
+ throw new AssertionError();
+
+ InputStream pin2 = createPeekInputStream(
+ new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
+ if (pin2.skip(0) != 0 || pin2.read() != 1)
+ throw new AssertionError();
+
+ InputStream pin3 = createPeekInputStream(
+ new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
+ if (pin3.skip(2) != 2 || pin3.read() != 3)
+ throw new AssertionError();
+
+ InputStream pin4 = createPeekInputStream(
+ new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
+ if (pin4.skip(3) != 3 || pin4.read() != 4)
+ throw new AssertionError();
+
+ InputStream pin5 = createPeekInputStream(
+ new ByteArrayInputStream(new byte[]{1, 2, 3, 4}));
+ if (pin5.skip(16) != 4 || pin5.read() != -1)
+ throw new AssertionError();
+ }
+
+ private static InputStream createPeekInputStream(InputStream underlying)
+ throws ReflectiveOperationException {
+ Class<? extends InputStream> clazz =
+ Class.forName("java.io.ObjectInputStream$PeekInputStream")
+ .asSubclass(InputStream.class);
+
+ Constructor<? extends InputStream> ctr =
+ clazz.getDeclaredConstructor(InputStream.class);
+ ctr.setAccessible(true);
+ return ctr.newInstance(underlying);
+ }
+
+ private static void peek(InputStream pin)
+ throws ReflectiveOperationException {
+ Method p = pin.getClass().getDeclaredMethod("peek");
+ p.setAccessible(true);
+ p.invoke(pin);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,384 @@
+/*
+ * 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.io.FilePermission;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.ReflectPermission;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+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.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.PropertyPermission;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Stream;
+
+/**
+ * @test
+ * @bug 8065552
+ * @summary test that all fields returned by getDeclaredFields() can be
+ * set accessible if the right permission is granted; this test
+ * loads all the classes in the BCL, get their declared fields,
+ * and call setAccessible(false) followed by setAccessible(true);
+ * @run main/othervm FieldSetAccessibleTest UNSECURE
+ * @run main/othervm FieldSetAccessibleTest SECURE
+ *
+ * @author danielfuchs
+ */
+public class FieldSetAccessibleTest {
+
+ static final List<String> skipped = new ArrayList<>();
+ static final List<String> cantread = new ArrayList<>();
+ static final List<String> failed = new ArrayList<>();
+ static final AtomicLong classCount = new AtomicLong();
+ static final AtomicLong fieldCount = new AtomicLong();
+ static long startIndex = 0;
+ static long maxSize = Long.MAX_VALUE;
+ static long maxIndex = Long.MAX_VALUE;
+ static final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
+
+
+ // Test that all fields for any given class can be made accessibles
+ static void testSetFieldsAccessible(Class<?> c) {
+ for (Field f : c.getDeclaredFields()) {
+ fieldCount.incrementAndGet();
+ f.setAccessible(false);
+ f.setAccessible(true);
+ }
+ }
+
+ // Performs a series of test on the given class.
+ // At this time, we only call testSetFieldsAccessible(c)
+ public static boolean test(Class<?> c) {
+ //System.out.println(c.getName());
+ classCount.incrementAndGet();
+
+ // Call getDeclaredFields() and try to set their accessible flag.
+ testSetFieldsAccessible(c);
+
+ // add more tests here...
+
+ return c == Class.class;
+ }
+
+ // Prints a summary at the end of the test.
+ static void printSummary(long secs, long millis, long nanos) {
+ System.out.println("Tested " + fieldCount.get() + " fields of "
+ + classCount.get() + " classes in "
+ + secs + "s " + millis + "ms " + nanos + "ns");
+ }
+
+
+ /**
+ * @param args the command line arguments:
+ *
+ * SECURE|UNSECURE [startIndex (default=0)] [maxSize (default=Long.MAX_VALUE)]
+ *
+ * @throws java.lang.Exception if the test fails
+ */
+ public static void main(String[] args) throws Exception {
+ if (args == null || args.length == 0) {
+ args = new String[] {"SECURE", "0"};
+ } else if (args.length > 3) {
+ throw new RuntimeException("Expected at most one argument. Found "
+ + Arrays.asList(args));
+ }
+ try {
+ if (args.length > 1) {
+ startIndex = Long.parseLong(args[1]);
+ if (startIndex < 0) {
+ throw new IllegalArgumentException("startIndex args[1]: "
+ + startIndex);
+ }
+ }
+ if (args.length > 2) {
+ maxSize = Long.parseLong(args[2]);
+ if (maxSize <= 0) {
+ maxSize = Long.MAX_VALUE;
+ }
+ maxIndex = (Long.MAX_VALUE - startIndex) < maxSize
+ ? Long.MAX_VALUE : startIndex + maxSize;
+ }
+ TestCase.valueOf(args[0]).run();
+ } catch (OutOfMemoryError oome) {
+ System.err.println(classCount.get());
+ throw oome;
+ }
+ }
+
+ public static void run(TestCase test) {
+ System.out.println("Testing " + test);
+ test(listAllClassNames());
+ System.out.println("Passed " + test);
+ }
+
+ static Iterable<String> listAllClassNames() {
+ return new ClassNameJrtStreamBuilder();
+ }
+
+ static void test(Iterable<String> iterable) {
+ final long start = System.nanoTime();
+ boolean classFound = false;
+ int index = 0;
+ for (String s: iterable) {
+ if (index == maxIndex) break;
+ try {
+ if (index < startIndex) continue;
+ if (test(s)) {
+ classFound = true;
+ }
+ } finally {
+ index++;
+ }
+ }
+ long elapsed = System.nanoTime() - start;
+ long secs = elapsed / 1000_000_000;
+ long millis = (elapsed % 1000_000_000) / 1000_000;
+ long nanos = elapsed % 1000_000;
+ System.out.println("Unreadable path elements: " + cantread);
+ System.out.println("Skipped path elements: " + skipped);
+ System.out.println("Failed path elements: " + failed);
+ printSummary(secs, millis, nanos);
+
+ if (!failed.isEmpty()) {
+ throw new RuntimeException("Test failed for the following classes: " + failed);
+ }
+ if (!classFound && startIndex == 0 && index < maxIndex) {
+ // this is just to verify that we have indeed parsed rt.jar
+ // (or the java.base module)
+ throw new RuntimeException("Test failed: Class.class not found...");
+ }
+ if (classCount.get() == 0 && startIndex == 0) {
+ throw new RuntimeException("Test failed: no class found?");
+ }
+ }
+
+ static boolean test(String s) {
+ try {
+ if (s.startsWith("WrapperGenerator")) {
+ System.out.println("Skipping "+ s);
+ return false;
+ }
+ final Class<?> c = Class.forName(
+ s.replace('/', '.').substring(0, s.length() - 6),
+ false,
+ systemClassLoader);
+ return test(c);
+ } catch (Exception t) {
+ t.printStackTrace(System.err);
+ failed.add(s);
+ } catch (NoClassDefFoundError e) {
+ e.printStackTrace(System.err);
+ failed.add(s);
+ }
+ return false;
+ }
+
+ static class ClassNameJrtStreamBuilder implements Iterable<String>{
+
+ final FileSystem jrt;
+ final List<Path> roots = new ArrayList<>();
+ ClassNameJrtStreamBuilder() {
+ jrt = FileSystems.getFileSystem(URI.create("jrt:/"));
+ for (Path root : jrt.getRootDirectories()) {
+ roots.add(root);
+ }
+ }
+
+ Stream<String> build() {
+ return roots.stream().flatMap(this::toStream)
+ .filter(x -> x.getNameCount() > 1)
+ .map( x-> x.subpath(1, x.getNameCount()))
+ .map( x -> x.toString())
+ .filter(s -> s.endsWith(".class"));
+ }
+
+ @Override
+ public Iterator<String> iterator() {
+ return build().iterator();
+ }
+
+ private Stream<Path> toStream(Path root) {
+ try {
+ return Files.walk(root);
+ } catch(IOException x) {
+ x.printStackTrace(System.err);
+ skipped.add(root.toString());
+ }
+ return Collections.<Path>emptyList().stream();
+ }
+
+ }
+
+ // Test with or without a security manager
+ public static enum TestCase {
+ UNSECURE, SECURE;
+ public void run() throws Exception {
+ System.out.println("Running test case: " + name());
+ Configure.setUp(this);
+ FieldSetAccessibleTest.run(this);
+ }
+ }
+
+ // A helper class to configure the security manager for the test,
+ // and bypass it when needed.
+ static class Configure {
+ static Policy policy = null;
+ static final ThreadLocal<AtomicBoolean> allowAll = new ThreadLocal<AtomicBoolean>() {
+ @Override
+ protected AtomicBoolean initialValue() {
+ return new AtomicBoolean(false);
+ }
+ };
+ static void setUp(TestCase test) {
+ switch (test) {
+ case SECURE:
+ if (policy == null && System.getSecurityManager() != null) {
+ throw new IllegalStateException("SecurityManager already set");
+ } else if (policy == null) {
+ policy = new SimplePolicy(TestCase.SECURE, allowAll);
+ Policy.setPolicy(policy);
+ System.setSecurityManager(new SecurityManager());
+ }
+ if (System.getSecurityManager() == null) {
+ throw new IllegalStateException("No SecurityManager.");
+ }
+ if (policy == null) {
+ throw new IllegalStateException("policy not configured");
+ }
+ break;
+ case UNSECURE:
+ if (System.getSecurityManager() != null) {
+ throw new IllegalStateException("SecurityManager already set");
+ }
+ break;
+ default:
+ throw new InternalError("No such testcase: " + test);
+ }
+ }
+ static void doPrivileged(Runnable run) {
+ allowAll.get().set(true);
+ try {
+ run.run();
+ } finally {
+ allowAll.get().set(false);
+ }
+ }
+ }
+
+ // A Helper class to build a set of permissions.
+ final static class PermissionsBuilder {
+ final Permissions perms;
+ public PermissionsBuilder() {
+ this(new Permissions());
+ }
+ public PermissionsBuilder(Permissions perms) {
+ this.perms = perms;
+ }
+ public PermissionsBuilder add(Permission p) {
+ perms.add(p);
+ return this;
+ }
+ public PermissionsBuilder addAll(PermissionCollection col) {
+ if (col != null) {
+ for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) {
+ perms.add(e.nextElement());
+ }
+ }
+ return this;
+ }
+ public Permissions toPermissions() {
+ final PermissionsBuilder builder = new PermissionsBuilder();
+ builder.addAll(perms);
+ return builder.perms;
+ }
+ }
+
+ // Policy for the test...
+ public static class SimplePolicy extends Policy {
+
+ final Permissions permissions;
+ final Permissions allPermissions;
+ final ThreadLocal<AtomicBoolean> allowAll;
+ public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) {
+ this.allowAll = allowAll;
+
+ // Permission needed by the tested code exercised in the test
+ permissions = new Permissions();
+ permissions.add(new RuntimePermission("fileSystemProvider"));
+ permissions.add(new RuntimePermission("createClassLoader"));
+ permissions.add(new RuntimePermission("closeClassLoader"));
+ permissions.add(new RuntimePermission("getClassLoader"));
+ permissions.add(new RuntimePermission("accessDeclaredMembers"));
+ permissions.add(new ReflectPermission("suppressAccessChecks"));
+ permissions.add(new PropertyPermission("*", "read"));
+ permissions.add(new FilePermission("<<ALL FILES>>", "read"));
+
+ // these are used for configuring the test itself...
+ allPermissions = new Permissions();
+ allPermissions.add(new java.security.AllPermission());
+ }
+
+ @Override
+ public boolean implies(ProtectionDomain domain, Permission permission) {
+ if (allowAll.get().get()) return allPermissions.implies(permission);
+ if (permissions.implies(permission)) return true;
+ if (permission instanceof java.lang.RuntimePermission) {
+ if (permission.getName().startsWith("accessClassInPackage.")) {
+ // add these along to the set of permission we have, when we
+ // discover that we need them.
+ permissions.add(permission);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public PermissionCollection getPermissions(CodeSource codesource) {
+ return new PermissionsBuilder().addAll(allowAll.get().get()
+ ? allPermissions : permissions).toPermissions();
+ }
+
+ @Override
+ public PermissionCollection getPermissions(ProtectionDomain domain) {
+ return new PermissionsBuilder().addAll(allowAll.get().get()
+ ? allPermissions : permissions).toPermissions();
+ }
+ }
+
+}
--- a/jdk/test/java/lang/Runtime/exec/SleepyCat.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/lang/Runtime/exec/SleepyCat.java Wed Jul 05 20:11:52 2017 +0200
@@ -22,7 +22,7 @@
*/
/* @test
- @bug 4843136 4763384
+ @bug 4843136 4763384 8044841
@summary Various race conditions caused exec'ed processes to have
extra unused file descriptors, which caused hard-to-reproduce hangs.
@author Martin Buchholz
@@ -50,6 +50,8 @@
}
public void run() {
+ dumpState(deathRow); // before killing the processes dump all the state
+
timedOut = true;
destroy(deathRow);
}
@@ -59,6 +61,37 @@
}
}
+ /**
+ * Temporary debugging code for intermittent failures.
+ * @param pids the processes to dump status for
+ */
+ static void dumpState(Process... pids) {
+ if (!System.getProperty("os.name").contains("SunOS")) {
+ return;
+ }
+ try {
+ String[] psArgs = {"ps", "-elf"};
+ Process ps = new ProcessBuilder(psArgs).inheritIO().start();
+ ps.waitFor();
+ String[] sfiles = {"pfiles", "self"};
+ Process fds = new ProcessBuilder(sfiles).inheritIO().start();
+ fds.waitFor();
+
+ for (Process p : pids) {
+ if (p == null)
+ continue;
+ String[] pfiles = {"pfiles", Long.toString(p.getPid())};
+ fds = new ProcessBuilder(pfiles).inheritIO().start();
+ fds.waitFor();
+ String[] pstack = {"pstack", Long.toString(p.getPid())};
+ fds = new ProcessBuilder(pstack).inheritIO().start();
+ fds.waitFor();
+ }
+ } catch (IOException | InterruptedException i) {
+ i.printStackTrace();
+ }
+ }
+
private static boolean hang1() throws IOException, InterruptedException {
// Time out was reproducible on Solaris 50% of the time;
// on Linux 80% of the time.
--- a/jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java Wed Jul 05 20:11:52 2017 +0200
@@ -79,24 +79,15 @@
throws IllegalClassFormatException
{
String tName = Thread.currentThread().getName();
- // In 160_03 and older, transform() is called
- // with the "system_loader_lock" held and that
- // prevents the bootstrap class loaded from
- // running in parallel. If we add a slight sleep
- // delay here when the transform() call is not
- // main or TestThread, then the deadlock in
- // 160_03 and older is much more reproducible.
- if (!tName.equals("main") && !tName.equals("TestThread")) {
- System.out.println("Thread '" + tName +
- "' has called transform()");
- try {
- Thread.sleep(500);
- } catch (InterruptedException ie) {
- }
- }
- // load additional classes when called from other threads
- if (!tName.equals("main"))
+ // Load additional classes when called from thread 'TestThread'
+ // When a class is loaded during a callback handling the boot loader, we can
+ // run into ClassCircularityError if the ClassFileLoadHook is set early enough
+ // to catch classes needed during class loading, e.g.
+ // sun.misc.URLClassPath$JarLoader$2.
+ // The goal of the test is to stress class loading on the test class loaders.
+
+ if (tName.equals("TestThread") && loader != null)
{
loadClasses(3);
}
--- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,17 +29,21 @@
* @author Mandy Chung
* @author Jaroslav Bachorik
*
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
* @run main/othervm Locks
*/
import java.lang.management.*;
import java.util.concurrent.Phaser;
+import jdk.testlibrary.LockFreeLogManager;
public class Locks {
private static final Object objA = new Object();
private static final Object objB = new Object();
private static final Object objC = new Object();
private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean();
+ private static final LockFreeLogManager logger = new LockFreeLogManager();
private static boolean testFailed = false;
@@ -126,14 +130,14 @@
public void run() {
synchronized(objA) {
// stop here for LockBThread to hold objB
- System.out.println("LockAThread about to block on objB");
+ log("LockAThread about to block on objB");
p.arriveAndAwaitAdvance(); // Phase 1 (blocking)
synchronized(objB) {
dummyCounter++;
};
}
p.arriveAndAwaitAdvance(); // Phase 2 (blocking)
- System.out.println("LockAThread about to exit");
+ log("LockAThread about to exit");
// Make sure the current thread is not holding any lock
assertNoLock(this);
}
@@ -147,7 +151,7 @@
}
public void run() {
synchronized(objB) {
- System.out.println("LockBThread about to block on objC");
+ log("LockBThread about to block on objC");
p.arriveAndAwaitAdvance(); // Phase 1 (blocking)
// Signal main thread about to block on objC
synchronized(objC) {
@@ -155,14 +159,14 @@
};
}
p.arriveAndAwaitAdvance(); // Phase 2 (blocking)
- System.out.println("LockBThread about to exit");
+ log("LockBThread about to exit");
// Make sure the current thread is not holding any lock
assertNoLock(this);
}
}
private static WaitingThread waiter;
- private static Object ready = new Object();
+ private static final Object ready = new Object();
private static CheckerThread checker;
static class WaitingThread extends Thread {
private final Phaser p;
@@ -173,9 +177,10 @@
super("WaitingThread");
this.p = p;
}
+ @Override
public void run() {
synchronized(objC) {
- System.out.println("WaitingThread about to wait on objC");
+ log("WaitingThread about to wait on objC");
try {
// Signal checker thread, about to wait on objC.
waiting = false;
@@ -188,13 +193,13 @@
}
// block until CheckerThread finishes checking
- System.out.println("WaitingThread about to block on ready");
+ log("WaitingThread about to block on ready");
// signal checker thread that it is about acquire
// object ready.
p.arriveAndAwaitAdvance(); // Phase 2 (waiting)
synchronized(ready) {
dummyCounter++;
- };
+ }
}
synchronized(objC) {
try {
@@ -208,7 +213,7 @@
testFailed = true;
}
}
- System.out.println("WaitingThread about to exit waiting on objC 2");
+ log("WaitingThread about to exit waiting on objC 2");
}
public void waitForWaiting() {
@@ -321,10 +326,10 @@
private static ThreadInfo findOwnerInfo(ThreadInfo[] infos, String lock)
throws Exception {
ThreadInfo ownerInfo = null;
- for (int i = 0; i < infos.length; i++) {
- String blockedLock = infos[i].getLockName();
+ for (ThreadInfo info : infos) {
+ String blockedLock = info.getLockName();
if (lock.equals(blockedLock)) {
- long threadId = infos[i].getLockOwnerId();
+ long threadId = info.getLockOwnerId();
if (threadId == -1) {
throw new RuntimeException("TEST FAILED: " +
lock + " expected to have owner");
@@ -355,14 +360,17 @@
throws Exception {
ThreadInfo ownerInfo = null;
// Find the thread who is blocking on lock
- for (int i = 0; i < infos.length; i++) {
- String blockedLock = infos[i].getLockName();
+ for (ThreadInfo info : infos) {
+ String blockedLock = info.getLockName();
if (lock.equals(blockedLock)) {
- System.out.print(infos[i].getThreadName() +
- " blocked on " + blockedLock);
- ownerInfo = infos[i];
+ log("%s blocked on %s", info.getThreadName(), blockedLock);
+ ownerInfo = info;
}
}
+ if (ownerInfo == null) {
+ throw new RuntimeException("TEST FAILED: " +
+ "Can't retrieve ThreadInfo for the blocked thread");
+ }
long[] threads = new long[10];
int count = 0;
@@ -370,14 +378,18 @@
while (ownerInfo != null && ownerInfo.getThreadState() == Thread.State.BLOCKED) {
ownerInfo = findOwnerInfo(infos, lock);
threads[count++] = ownerInfo.getThreadId();
- System.out.println(" Owner = " + ownerInfo.getThreadName() +
- " id = " + ownerInfo.getThreadId());
+ log(" Owner = %s id = %d",
+ ownerInfo.getThreadName(),
+ ownerInfo.getThreadId()
+ );
lock = ownerInfo.getLockName();
- System.out.print(ownerInfo.getThreadName() + " Id = " +
- ownerInfo.getThreadId() +
- " blocked on " + lock);
+ log("%s Id = %d blocked on %s",
+ ownerInfo.getThreadName(),
+ ownerInfo.getThreadId(),
+ lock
+ );
}
- System.out.println();
+ log("");
if (count != expectedThreads.length) {
throw new RuntimeException("TEST FAILED: " +
@@ -385,10 +397,15 @@
}
for (int i = 0; i < count; i++) {
if (threads[i] != expectedThreads[i]) {
- System.out.println("TEST FAILED: " +
- "Unexpected thread in the chain " + threads[i] +
- " expected to be " + expectedThreads[i]);
+ log("TEST FAILED: Unexpected thread in the chain %s expected to be %s",
+ threads[i],
+ expectedThreads[i]
+ );
}
}
}
+
+ private static void log(String format, Object ... args) {
+ logger.log(format + "%n", args);
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/FileChannel/GetClosedChannel.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,112 @@
+/*
+ * 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 8025619
+ * @summary Verify that a channel obtained from a closed stream is truly closed.
+ */
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.FileChannel;
+
+public class GetClosedChannel {
+ private static final int NUM_CHANNELS = 3;
+ private static final int NUM_EXCEPTIONS = 2*NUM_CHANNELS;
+
+ public static void main(String[] args) throws IOException {
+ int exceptions = 0;
+ int openChannels = 0;
+
+ for (int i = 0; i < NUM_CHANNELS; i++) {
+ File f = File.createTempFile("fcbug", ".tmp");
+ f.deleteOnExit();
+
+ FileChannel fc = null;
+ boolean shared = false;
+ switch (i) {
+ case 0:
+ System.out.print("FileInputStream...");
+ FileInputStream fis = new FileInputStream(f);
+ fis.close();
+ fc = fis.getChannel();
+ if (fc.isOpen()) {
+ System.err.println("FileInputStream channel should not be open");
+ openChannels++;
+ }
+ shared = true;
+ break;
+ case 1:
+ System.out.print("FileOutputStream...");
+ FileOutputStream fos = new FileOutputStream(f);
+ fos.close();
+ fc = fos.getChannel();
+ if (fc.isOpen()) {
+ System.err.println("FileOutputStream channel should not be open");
+ openChannels++;
+ }
+ break;
+ case 2:
+ System.out.print("RandomAccessFile...");
+ RandomAccessFile raf = new RandomAccessFile(f, "rw");
+ raf.close();
+ fc = raf.getChannel();
+ if (fc.isOpen()) {
+ System.err.println("RandomAccessFile channel should not be open");
+ openChannels++;
+ }
+ break;
+ default:
+ assert false : "Should not get here";
+ }
+
+ try {
+ long position = fc.position();
+ System.err.println("Channel "+i+" position is "+position);
+ } catch (ClosedChannelException cce) {
+ exceptions++;
+ }
+
+ try {
+ fc.tryLock(0, Long.MAX_VALUE, shared);
+ } catch (ClosedChannelException e) {
+ System.out.println("OK");
+ exceptions++;
+ } catch (Error err) {
+ System.err.println(err);
+ }
+ }
+
+ if (exceptions != NUM_EXCEPTIONS || openChannels != 0) {
+ throw new RuntimeException("FAILED:" +
+ " ClosedChannelExceptions: expected: " + NUM_EXCEPTIONS +
+ " actual: " + exceptions + ";" + System.lineSeparator() +
+ " number of open channels: expected: 0 " +
+ " actual: " + openChannels + ".");
+ }
+ }
+}
--- a/jdk/test/java/rmi/server/RemoteObject/notExtending/NotExtending.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/rmi/server/RemoteObject/notExtending/NotExtending.java Wed Jul 05 20:11:52 2017 +0200
@@ -30,7 +30,7 @@
* @author Peter Jones
*
* @build NotExtending_Stub NotExtending_Skel
- * @run main/othervm/timeout=240 NotExtending
+ * @run main/othervm NotExtending
*/
@@ -46,9 +46,16 @@
/** true if the hashValue field has been initialized */
private boolean hashValueInitialized = false;
- public NotExtending() throws RemoteException {
+ // no declared constructor - rely on implicit no-arg contructor
+
+ public Remote export() throws RemoteException {
stub = UnicastRemoteObject.exportObject(this);
setHashValue(stub.hashCode());
+ return stub;
+ }
+
+ public void unexport() throws RemoteException {
+ UnicastRemoteObject.unexportObject(this, true);
}
private void setHashValue(int value) {
@@ -58,12 +65,11 @@
public int hashCode() {
/*
- * Test fails with a RuntimeException if the hashCode() method is
- * called (during the export procedure) before the correct hash
- * value has been initialized.
+ * Test fails if the hashCode() method is called (during export)
+ * before the correct hash value has been initialized.
*/
if (!hashValueInitialized) {
- throw new RuntimeException(
+ throw new AssertionError(
"hashCode() invoked before hashValue initialized");
}
return hashValue;
@@ -74,69 +80,40 @@
}
public static void main(String[] args) throws Exception {
- /*
- * The following line is required with the JDK 1.2 VM so that the
- * VM can exit gracefully when this test completes. Otherwise, the
- * conservative garbage collector will find a handle to the server
- * object on the native stack and not clear the weak reference to
- * it in the RMI runtime's object table.
- */
- Object dummy = new Object();
+ NotExtending server = null;
- NotExtending server;
try {
/*
* Verify that hashCode() is not invoked before it is
* initialized. Tests bugid 4102938.
*/
server = new NotExtending();
+ Remote stub = server.export();
System.err.println("Server exported without invoking hashCode().");
/*
* Verify that passing stub to server's equals() method
* returns true.
*/
- if (server.equals(server.stub)) {
- System.err.println(
- "Passing stub to server's equals() method succeeded.");
+ if (server.equals(stub)) {
+ System.err.println("server.equals(stub) returns true");
} else {
- throw new RuntimeException(
- "passing stub to server's equals() method failed");
+ throw new AssertionError("server.equals(stub) returns false");
}
/*
* Verify that passing server to stub's equals() method
* returns true. Tests bugid 4099660.
*/
- if (server.stub.equals(server)) {
- System.err.println(
- "Passing server to stub's equals() method succeeded.");
+ if (stub.equals(server)) {
+ System.err.println("stub.equals(server) returns true");
} else {
- throw new RuntimeException(
- "passing server to stub's equals() method failed");
+ throw new AssertionError("stub.equals(server) returns false");
}
-
} finally {
- server = null;
- flushCachedRefs();
- }
- }
-
- /**
- * Force desperate garbage collection so that soft references
- * will be cleared.
- *
- * This method is required with the JDK 1.1.x RMI runtime so that the
- * VM can exit gracefully when this test completes. See bugid 4006356.
- */
- public static void flushCachedRefs() {
- java.util.Vector chain = new java.util.Vector();
- try {
- while (true) {
- int[] hungry = new int[65536];
- chain.addElement(hungry);
+ if (server != null) {
+ server.unexport();
}
- } catch (OutOfMemoryError e) {
}
}
}
--- a/jdk/test/java/util/Collections/EmptyIterator.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/Collections/EmptyIterator.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2012, 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
@@ -33,40 +33,35 @@
public class EmptyIterator {
void test(String[] args) throws Throwable {
- testEmptyCollection(Collections.<Object>emptyList());
- testEmptyCollection(Collections.<Object>emptySet());
+ testEmptyCollection(emptyList());
+ testEmptyCollection(emptySet());
- testEmptyMap(Collections.<Object, Object>emptyMap());
+ testEmptyMap(emptyMap());
- Hashtable<Object, Object> emptyTable = new Hashtable<Object, Object>();
+ Hashtable<?,?> emptyTable = new Hashtable<>();
testEmptyEnumeration(emptyTable.keys());
testEmptyEnumeration(emptyTable.elements());
testEmptyIterator(emptyTable.keySet().iterator());
testEmptyIterator(emptyTable.values().iterator());
testEmptyIterator(emptyTable.entrySet().iterator());
- final Enumeration<EmptyIterator> finalEmptyTyped =
- Collections.emptyEnumeration();
+ final Enumeration<EmptyIterator> finalEmptyTyped = emptyEnumeration();
testEmptyEnumeration(finalEmptyTyped);
- final Enumeration finalEmptyAbstract =
- Collections.emptyEnumeration();
+ final Enumeration<?> finalEmptyAbstract = emptyEnumeration();
testEmptyEnumeration(finalEmptyAbstract);
- @SuppressWarnings("unchecked") Iterator<?> x =
- new sun.tools.java.MethodSet()
- .lookupName(sun.tools.java.Identifier.lookup(""));
- testEmptyIterator(x);
+ testEmptyIterator(emptyIterator());
}
- <T> void testEmptyEnumeration(final Enumeration<T> e) {
+ void testEmptyEnumeration(final Enumeration<?> e) {
check(e == emptyEnumeration());
- check(! e.hasMoreElements());
+ check(!e.hasMoreElements());
THROWS(NoSuchElementException.class,
new F(){void f(){ e.nextElement(); }});
}
- <T> void testEmptyIterator(final Iterator<T> it) {
+ void testEmptyIterator(final Iterator<?> it) {
check(it == emptyIterator());
check(! it.hasNext());
THROWS(NoSuchElementException.class,
@@ -75,10 +70,10 @@
new F(){void f(){ it.remove(); }});
}
- void testEmptyMap(Map<Object, Object> m) {
+ void testEmptyMap(Map<?,?> m) {
check(m == emptyMap());
check(m.entrySet().iterator() ==
- Collections.<Map.Entry<Object,Object>>emptyIterator());
+ Collections.<Map.Entry<?,?>>emptyIterator());
check(m.values().iterator() == emptyIterator());
check(m.keySet().iterator() == emptyIterator());
equal(m, unmodifiableMap(m));
@@ -88,7 +83,7 @@
testEmptyCollection(m.values());
}
- <E> void testToArray(final Collection<E> c) {
+ void testToArray(final Collection<?> c) {
Object[] a = c.toArray();
equal(a.length, 0);
equal(a.getClass().getComponentType(), Object.class);
@@ -109,7 +104,7 @@
}
}
- <E> void testEmptyCollection(final Collection<E> c) {
+ void testEmptyCollection(final Collection<?> c) {
testEmptyIterator(c.iterator());
check(c.iterator() == emptyIterator());
--- a/jdk/test/java/util/Locale/LocaleProviders.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/Locale/LocaleProviders.sh Wed Jul 05 20:11:52 2017 +0200
@@ -137,7 +137,7 @@
runTest()
{
- RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
+ RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES}${PS}${SPICLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
echo ${RUNCMD}
${RUNCMD}
result=$?
@@ -189,6 +189,7 @@
PARAM2=zh
PARAM3=CN
fi
+SPICLASSES=
runTest
# testing SPI is NOT selected, as there is none.
@@ -197,6 +198,7 @@
PARAM1=JRE
PARAM2=en
PARAM3=US
+SPICLASSES=
runTest
# testing the order, variaton #1. This assumes en_GB DateFormat data are available both in JRE & CLDR
@@ -205,6 +207,7 @@
PARAM1=CLDR
PARAM2=en
PARAM3=GB
+SPICLASSES=
runTest
# testing the order, variaton #2. This assumes en_GB DateFormat data are available both in JRE & CLDR
@@ -213,6 +216,7 @@
PARAM1=JRE
PARAM2=en
PARAM3=GB
+SPICLASSES=
runTest
# testing the order, variaton #3 for non-existent locale in JRE assuming "haw" is not in JRE.
@@ -221,6 +225,7 @@
PARAM1=CLDR
PARAM2=haw
PARAM3=GB
+SPICLASSES=
runTest
# testing the order, variaton #4 for the bug 7196799. CLDR's "zh" data should be used in "zh_CN"
@@ -229,6 +234,7 @@
PARAM1=CLDR
PARAM2=zh
PARAM3=CN
+SPICLASSES=
runTest
# testing FALLBACK provider. SPI and invalid one cases.
@@ -237,16 +243,19 @@
PARAM1=FALLBACK
PARAM2=en
PARAM3=US
+SPICLASSES=
runTest
PREFLIST=FOO
PARAM1=JRE
PARAM2=en
PARAM3=US
+SPICLASSES=
runTest
PREFLIST=BAR,SPI
PARAM1=FALLBACK
PARAM2=en
PARAM3=US
+SPICLASSES=
runTest
# testing 7198834 fix. Only works on Windows Vista or upper.
@@ -255,22 +264,25 @@
PARAM1=
PARAM2=
PARAM3=
+SPICLASSES=
runTest
# testing 8000245 fix.
METHODNAME=tzNameTest
-PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
+PREFLIST=JRE
PARAM1=Europe/Moscow
PARAM2=
PARAM3=
+SPICLASSES=${SPIDIR}
runTest
# testing 8000615 fix.
METHODNAME=tzNameTest
-PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
+PREFLIST=JRE
PARAM1=America/Los_Angeles
PARAM2=
PARAM3=
+SPICLASSES=${SPIDIR}
runTest
# testing 8001440 fix.
@@ -279,6 +291,7 @@
PARAM1=
PARAM2=
PARAM3=
+SPICLASSES=
runTest
# testing 8010666 fix.
@@ -289,15 +302,17 @@
PARAM1=
PARAM2=
PARAM3=
+ SPICLASSES=
runTest
fi
# testing 8013086 fix.
METHODNAME=bug8013086Test
-PREFLIST="JRE,SPI -Djava.ext.dirs=${SPIDIR}"
+PREFLIST=JRE,SPI
PARAM1=ja
PARAM2=JP
PARAM3=
+SPICLASSES=${SPIDIR}
runTest
# testing 8013903 fix. (Windows only)
@@ -306,12 +321,14 @@
PARAM1=
PARAM2=
PARAM3=
+SPICLASSES=
runTest
METHODNAME=bug8013903Test
PREFLIST=HOST
PARAM1=
PARAM2=
PARAM3=
+SPICLASSES=
runTest
# testing 8027289 fix, if the platform format default is zh_CN
@@ -323,12 +340,14 @@
PARAM1=FFE5
PARAM2=
PARAM3=
+ SPICLASSES=
runTest
METHODNAME=bug8027289Test
PREFLIST=HOST
PARAM1=00A5
PARAM2=
PARAM3=
+ SPICLASSES=
runTest
fi
--- a/jdk/test/java/util/PluggableLocale/BreakIteratorProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/BreakIteratorProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440
+# @bug 4052440 8062588
# @summary BreakIteratorProvider tests
-# @run shell ExecTest.sh foo BreakIteratorProviderTest true
+# @run shell ExecTest.sh foo BreakIteratorProviderTest
--- a/jdk/test/java/util/PluggableLocale/CalendarDataProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/CalendarDataProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 7058207 8000986
+# @bug 7058207 8000986 8062588
# @summary CalendarDataProvider tests
-# @run shell ExecTest.sh bar CalendarDataProviderTest true
+# @run shell ExecTest.sh bar CalendarDataProviderTest
--- a/jdk/test/java/util/PluggableLocale/CalendarNameProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/CalendarNameProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -22,6 +22,6 @@
#
# @test
-# @bug 8000986
+# @bug 8000986 8062588
# @summary CalendarNameProvider tests
-# @run shell ExecTest.sh bar CalendarNameProviderTest true
+# @run shell ExecTest.sh bar CalendarNameProviderTest
--- a/jdk/test/java/util/PluggableLocale/ClasspathTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/ClasspathTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -36,13 +36,13 @@
ClasspathTest() {
/*
- * Since providers can only be loaded from the extension directory,
- * this test will fail if they are loaded from classpath.
+ * Since providers can be loaded from the application's classpath,
+ * this test will fail if they are NOT loaded from classpath.
*/
Locale OSAKA = new Locale("ja", "JP", "osaka");
List<Locale> availableLocales = Arrays.asList(Locale.getAvailableLocales());
- if (availableLocales.contains(OSAKA)) {
- throw new RuntimeException("LSS providers were loaded from the class path.");
+ if (!availableLocales.contains(OSAKA)) {
+ throw new RuntimeException("LSS providers were NOT loaded from the class path.");
}
}
}
--- a/jdk/test/java/util/PluggableLocale/ClasspathTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/ClasspathTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,7 +23,6 @@
#
#
# @test
-# @bug 6388652
-# @summary Checks whether providers can only be loaded from extension directories,
-# not from classpath.
-# @run shell ExecTest.sh bar ClasspathTest false
+# @bug 6388652 8062588
+# @summary Checks whether providers can be loaded from classpath.
+# @run shell ExecTest.sh bar ClasspathTest
--- a/jdk/test/java/util/PluggableLocale/CollatorProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/CollatorProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440
+# @bug 4052440 8062588
# @summary CollatorProvider tests
-# @run shell ExecTest.sh foo CollatorProviderTest true
+# @run shell ExecTest.sh foo CollatorProviderTest
--- a/jdk/test/java/util/PluggableLocale/CurrencyNameProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/CurrencyNameProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440 7199750 8000997
+# @bug 4052440 7199750 8000997 8062588
# @summary CurrencyNameProvider tests
-# @run shell ExecTest.sh bar CurrencyNameProviderTest true
+# @run shell ExecTest.sh bar CurrencyNameProviderTest
--- a/jdk/test/java/util/PluggableLocale/DateFormatProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/DateFormatProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440 7003643
+# @bug 4052440 7003643 8062588
# @summary DateFormatProvider tests
-# @run shell ExecTest.sh foo DateFormatProviderTest true
+# @run shell ExecTest.sh foo DateFormatProviderTest
--- a/jdk/test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440 7200341
+# @bug 4052440 7200341 8062588
# @summary DateFormatSymbolsProvider tests
-# @run shell ExecTest.sh foo DateFormatSymbolsProviderTest true
+# @run shell ExecTest.sh foo DateFormatSymbolsProviderTest
--- a/jdk/test/java/util/PluggableLocale/DecimalFormatSymbolsProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/DecimalFormatSymbolsProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440
+# @bug 4052440 8062588
# @summary DecimalFormatSymbolsProvider tests
-# @run shell ExecTest.sh foo DecimalFormatSymbolsProviderTest true
+# @run shell ExecTest.sh foo DecimalFormatSymbolsProviderTest
--- a/jdk/test/java/util/PluggableLocale/ExecTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/ExecTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -76,14 +76,6 @@
;;
esac
-# set classpath and extension directory variables
-if [ -d ${TESTJAVA}${FS}lib${FS}ext ]
-then
- EXTDIRS="${TESTJAVA}${FS}lib${FS}ext${PS}${TESTCLASSES}"
-else
- EXTDIRS="${TESTJAVA}${FS}jre${FS}lib${FS}ext${PS}${TESTCLASSES}"
-fi
-
case "$1" in
"foo" )
cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
@@ -122,12 +114,7 @@
fi
# run
-if [ "$3" = "true" ]
-then
- RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Djava.ext.dirs=${EXTDIRS} $2 "
-else
- RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${CLASSPATHARG} $2 "
-fi
+RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${CLASSPATHARG} $2 "
echo ${RUNCMD}
${RUNCMD}
--- a/jdk/test/java/util/PluggableLocale/GenericTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/GenericTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440
+# @bug 4052440 8062588
# @summary Generic tests for the pluggable locales feature
-# @run shell ExecTest.sh foobar GenericTest true
+# @run shell ExecTest.sh foobar GenericTest
--- a/jdk/test/java/util/PluggableLocale/LocaleNameProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/LocaleNameProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440 8000273
+# @bug 4052440 8000273 8062588
# @summary LocaleNameProvider tests
-# @run shell ExecTest.sh bar LocaleNameProviderTest true
+# @run shell ExecTest.sh bar LocaleNameProviderTest
--- a/jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440 7003643
+# @bug 4052440 7003643 8062588
# @summary NumberFormatProvider tests
-# @run shell ExecTest.sh foo NumberFormatProviderTest true
+# @run shell ExecTest.sh foo NumberFormatProviderTest
--- a/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.sh Wed Jul 05 20:11:52 2017 +0200
@@ -23,6 +23,6 @@
#
#
# @test
-# @bug 4052440 8003267
+# @bug 4052440 8003267 8062588
# @summary TimeZoneNameProvider tests
-# @run shell ExecTest.sh bar TimeZoneNameProviderTest true
+# @run shell ExecTest.sh bar TimeZoneNameProviderTest
--- a/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh Wed Jul 05 20:11:52 2017 +0200
@@ -55,27 +55,14 @@
exit 1
fi
-# See if TESTJAVA points to JRE or JDK
-if [ -d "${TESTJAVA}${FILESEP}jre" ]; then
- JRE_EXT_DIR=${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext
-else
- JRE_EXT_DIR=${TESTJAVA}${FILESEP}lib${FILESEP}ext
-fi
-
-if [ -d "${JRE_EXT_DIR}" ]; then
- NEW_EXT_DIR="${JRE_EXT_DIR}${PATHSEP}${TESTSRC}"
-else
- NEW_EXT_DIR=${TESTSRC}
-fi
-
echo "TESTJAVA=${TESTJAVA}"
echo "TESTSRC=${TESTSRC}"
echo "TESTCLASSES=${TESTCLASSES}"
echo "NEW_EXT_DIR=${NEW_EXT_DIR}"
cd ${TESTSRC}
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES} -Djava.ext.dirs=${NEW_EXT_DIR} Bug6299235Test
+echo
+${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES}${PATHSEP}${TESTSRC}${FILESEP}awtres.jar Bug6299235Test
if [ $? -ne 0 ]
then
--- a/jdk/test/javax/management/monitor/CounterMonitorTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/management/monitor/CounterMonitorTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -68,7 +68,7 @@
observedValue = count;
CounterMonitorTest.class.notifyAll();
}
- return count;
+ return observedValue;
}
public void setNbObjects(Object n) {
echo(">>> StdObservedObject.setNbObjects: " + n);
--- a/jdk/test/javax/management/standardmbean/DeadlockTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/management/standardmbean/DeadlockTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -24,7 +24,7 @@
/*
* @test
* @bug 6331746
- * @summary Deadlock on synchronization problem
+ * @summary Test a deadlock and will be blocked forever if the deadlock is present.
* @author Shanliang JIANG
* @run main DeadlockTest
*/
@@ -55,43 +55,25 @@
BadBoy bb = new BadBoy(dt);
bb.start();
- final long timeout = 2000;
- long stopTime = System.currentTimeMillis() + timeout;
- long timeToWait = timeout;
synchronized(bb) {
- while(!bb.gotLock || timeToWait > 0) {
- bb.wait(timeToWait);
-
- timeToWait = stopTime - System.currentTimeMillis();
+ while(!bb.gotLock) {
+ bb.wait(); // if blocked here, means failing to get lock, impossible.
}
}
- if (!bb.gotLock) {
- throw new RuntimeException("Failed to get lock, impossible!");
- }
-
System.out.println("main: The BadBay is holding the lock forever.");
System.out.println("main: Create a WorkingBoy to see blocking ...");
WorkingBoy wb = new WorkingBoy(dt);
- stopTime = System.currentTimeMillis() + timeout;
- timeToWait = timeout;
-
synchronized(wb) {
wb.start();
- while(!wb.done || timeToWait > 0) {
- wb.wait(timeToWait);
-
- timeToWait = stopTime - System.currentTimeMillis();
+ while(!wb.done) {
+ wb.wait(); // if blocked here, the deadlock happends
}
}
- if (!wb.done) {
- throw new RuntimeException("It is blocked!");
- }
-
System.out.println("main: OK, bye bye.");
}
--- a/jdk/test/javax/swing/AbstractButton/6711682/bug6711682.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/AbstractButton/6711682/bug6711682.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@run main bug6711682
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.table.TableCellEditor;
@@ -47,13 +45,12 @@
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point l = table.getLocationOnScreen();
int h = table.getRowHeight();
for (int i = 0; i < 3; i++) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JButton/4368790/bug4368790.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 4368790
+ @summary JButton stays pressed when focus stolen
+ @author Alexander Potochkin
+ @run main bug4368790
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug4368790 {
+ private static JButton b1;
+
+ private static void createGui() {
+ final JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setLayout(new FlowLayout());
+
+ b1 = new JButton("Button1");
+ frame.add(b1);
+ frame.add(new JButton("Button2"));
+
+ frame.setSize(200, 200);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ b1.requestFocus();
+ }
+
+ public static void main(String[] args) throws Exception {
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ bug4368790.createGui();
+ }
+ });
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyPress(KeyEvent.VK_TAB);
+ robot.keyRelease(KeyEvent.VK_TAB);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ robot.waitForIdle();
+ if (b1.getModel().isPressed()) {
+ throw new RuntimeException("The button is unexpectedly pressed");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JColorChooser/8065098/JColorChooserDnDTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * 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 javax.swing.BorderFactory;
+import javax.swing.JColorChooser;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+/*
+ * @bug 8065098
+ * @summary JColorChooser no longer supports drag and drop
+ * between two JVM instances
+ */
+public class JColorChooserDnDTest {
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ JPanel panel = new JPanel();
+ JColorChooser colorChooser = new JColorChooser();
+ colorChooser.setDragEnabled(true);
+ panel.setBorder(BorderFactory.createTitledBorder("JColorChoosers"));
+ panel.add(colorChooser);
+ frame.setContentPane(panel);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JColorChooser/8065098/bug8065098.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,40 @@
+<!--
+ 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.
+-->
+
+<html>
+ <body>
+ 1. Compile the java test JColorChooserDnDTest.java:
+ > <path-to-the-tested-jdk>/bin/javac JColorChooserDnDTest.java
+ 2. Run the first instance of the java test:
+ > <path-to-the-tested-jdk>/bin/java JColorChooserDnDTest
+ 3. Select a color in the color chooser
+ 4. Run the second instance of the java test:
+ > <path-to-the-tested-jdk>/bin/java JColorChooserDnDTest
+ 5. Drag and drop the selected color from the first color chooser
+ preview panel to the second color chooser preview panel
+ 6. If the color is dragged to the second color chooser then the test passes.
+
+ <applet width="500" height="1" code="bug8065098.class">
+ </applet>
+</body>
+</html>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JColorChooser/8065098/bug8065098.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,34 @@
+/*
+ * 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 javax.swing.JApplet;
+
+/*
+ * @test
+ * @bug 8065098
+ * @summary JColorChooser no longer supports drag and drop
+ * between two JVM instances
+ * @run applet/manual=yesno bug8065098.html
+ */
+public class bug8065098 extends JApplet {
+
+}
--- a/jdk/test/javax/swing/JColorChooser/Test6541987.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JColorChooser/Test6541987.java Wed Jul 05 20:11:52 2017 +0200
@@ -39,10 +39,7 @@
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
-
public class Test6541987 implements Runnable {
- private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
private static Robot robot;
public static void main(String[] args) throws AWTException {
@@ -50,14 +47,14 @@
// test escape after selection
start();
click(KeyEvent.VK_ESCAPE);
- toolkit.realSync();
+ robot.waitForIdle();
// test double escape after editing
start();
click(KeyEvent.VK_1);
click(KeyEvent.VK_0);
click(KeyEvent.VK_ESCAPE);
click(KeyEvent.VK_ESCAPE);
- toolkit.realSync();
+ robot.waitForIdle();
// all windows should be closed
for (Window window : Window.getWindows()) {
if (window.isVisible()) {
@@ -76,7 +73,7 @@
}
private static void click(int...keys) {
- toolkit.realSync();
+ robot.waitForIdle();
for (int key : keys) {
robot.keyPress(key);
}
--- a/jdk/test/javax/swing/JColorChooser/Test6827032.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JColorChooser/Test6827032.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,8 +29,6 @@
* @library ../regtesthelpers
*/
-import sun.awt.SunToolkit;
-
import java.awt.*;
import java.awt.event.*;
@@ -49,7 +47,6 @@
Robot robot = new Robot();
robot.setAutoDelay(50);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -57,7 +54,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
--- a/jdk/test/javax/swing/JColorChooser/Test7194184.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JColorChooser/Test7194184.java Wed Jul 05 20:11:52 2017 +0200
@@ -39,7 +39,6 @@
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.JColorChooser;
@@ -47,7 +46,6 @@
import javax.swing.SwingUtilities;
import java.util.concurrent.Callable;
-import sun.awt.SunToolkit;
public class Test7194184 implements Runnable {
private static JFrame frame;
@@ -60,10 +58,9 @@
private static void testKeyBoardAccess() throws Exception {
Robot robot = new Robot();
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeLater(new Test7194184());
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeLater(new Runnable() {
@Override
@@ -78,7 +75,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
// Tab to move the focus to MainSwatch
Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
@@ -87,7 +84,7 @@
Util.hitKeys(robot, KeyEvent.VK_RIGHT);
Util.hitKeys(robot, KeyEvent.VK_RIGHT);
Util.hitKeys(robot, KeyEvent.VK_SPACE);
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
--- a/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,12 +25,13 @@
@bug 4199622
@summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation
@author Vladislav Karnaukhov
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
@run main bug4199622
*/
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
@@ -74,7 +75,6 @@
}
static Robot robot = null;
- static SunToolkit toolkit = null;
static void doTest() {
if (robot == null) {
@@ -86,11 +86,7 @@
}
}
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- if (toolkit == null) {
- throw new RuntimeException("Can't get the toolkit. Test failed");
- }
- toolkit.realSync();
+ robot.waitForIdle();
doActualTest();
@@ -109,7 +105,7 @@
throw new RuntimeException("Test failed", e);
}
- toolkit.realSync();
+ robot.waitForIdle();
doActualTest();
}
@@ -144,12 +140,14 @@
} catch (InvocationTargetException e) {
throw new RuntimeException("Test failed", e);
}
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_END);
- toolkit.realSync();
+ robot.keyRelease(KeyEvent.VK_END);
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_HOME);
- toolkit.realSync();
+ robot.keyRelease(KeyEvent.VK_HOME);
+ robot.waitForIdle();
}
static void doTestUpDown() {
@@ -166,16 +164,18 @@
} catch (InvocationTargetException e) {
throw new RuntimeException("Test failed", e);
}
- toolkit.realSync();
+ robot.waitForIdle();
for (int i = 0; i < nElems; i++) {
robot.keyPress(KeyEvent.VK_DOWN);
- toolkit.realSync();
+ robot.keyRelease(KeyEvent.VK_DOWN);
+ robot.waitForIdle();
}
for (int i = 0; i < nElems; i++) {
robot.keyPress(KeyEvent.VK_UP);
- toolkit.realSync();
+ robot.keyRelease(KeyEvent.VK_UP);
+ robot.waitForIdle();
}
}
@@ -193,17 +193,19 @@
} catch (InvocationTargetException e) {
throw new RuntimeException("Test failed", e);
}
- toolkit.realSync();
+ robot.waitForIdle();
int listHeight = cb.getMaximumRowCount();
for (int i = 0; i < nElems; i += listHeight) {
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
- toolkit.realSync();
+ robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
+ robot.waitForIdle();
}
for (int i = 0; i < nElems; i += listHeight) {
robot.keyPress(KeyEvent.VK_PAGE_UP);
- toolkit.realSync();
+ robot.keyRelease(KeyEvent.VK_PAGE_UP);
+ robot.waitForIdle();
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComboBox/4515752/DefaultButtonTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,214 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+/**
+ * @test
+ * @bug 4515752 4337071
+ * @author Mark Davidson
+ * @summary Tests the invocation of the default button within the JComboBox.
+ */
+public class DefaultButtonTest extends JFrame implements ActionListener {
+
+ private static boolean defaultButtonPressed = false;
+ private static boolean editChanged = false;
+
+ private static String[] strData = {
+ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
+ };
+
+ private static String[] strData2 = {
+ "One", "Two", "Three", "Four", "Five", "Six", "Seven"
+ };
+
+ public static void main(String[] args) throws Throwable {
+ SwingUtilities.invokeAndWait(new Runnable(){
+ public void run() {
+ new DefaultButtonTest();
+ }
+ });
+ test();
+ System.out.println("Test Passed");
+ }
+
+ public DefaultButtonTest() {
+ getContentPane().add(new DefaultPanel(this));
+ pack();
+ setVisible(true);
+ }
+
+ public static void test() {
+ // Use Robot to automate the test
+ Robot robot = null;
+ try {
+ robot = new Robot();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ robot.setAutoDelay(125);
+
+ for (int i = 0; i < 3; i++) {
+ // Test ENTER press on the non editable combo.
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_ENTER);
+ robot.waitForIdle();
+ testDefaultButton(true);
+
+ // Test the ENTER press on the editable combo box
+ robot.keyPress(KeyEvent.VK_TAB);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_TAB);
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_ENTER);
+ robot.waitForIdle();
+ testDefaultButton(true);
+
+ // Change the value, should generate a change but not a Default Button press.
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_D);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_D);
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_ENTER);
+ robot.waitForIdle();
+ testEditChange(true);
+ robot.waitForIdle();
+ testDefaultButton(true);
+
+ // Change value, changing focus should fire an ActionEvent.
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_BACK_SPACE);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_BACK_SPACE);
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_SHIFT);
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_TAB);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_SHIFT);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_TAB);
+ robot.waitForIdle();
+ testEditChange(true);
+ robot.waitForIdle();
+ testDefaultButton(false);
+ }
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ String cmd = evt.getActionCommand();
+ System.out.println("ActionEvent: " + cmd);
+
+ if (cmd.equals("OK")) {
+ defaultButtonPressed = true;
+ }
+
+ if (cmd.equals("comboBoxChanged")) {
+ editChanged = true;
+ }
+ }
+
+ public static void testDefaultButton(boolean flag) {
+ if (defaultButtonPressed != flag) {
+ new RuntimeException("defaultButtonPressed unexpectedly = " + defaultButtonPressed);
+ }
+ // reset
+ defaultButtonPressed = false;
+ }
+
+ public static void testEditChange(boolean flag) {
+ if (editChanged != flag) {
+ new RuntimeException("editChanged unexpectedly = " + editChanged);
+ }
+ // reset
+ editChanged = false;
+ }
+
+ class DefaultPanel extends JPanel {
+
+ public JComboBox combo;
+ public JComboBox combo2;
+
+ private JButton okButton = new JButton("OK");
+ private JButton cancelButton = new JButton("Cancel");
+
+ public DefaultPanel(JFrame root) {
+ setLayout(new BorderLayout());
+ add(createPanel(), BorderLayout.NORTH);
+ add(createInfoPanel(), BorderLayout.CENTER);
+ add(createButtonPanel(root), BorderLayout.SOUTH);
+ }
+
+ private JPanel createPanel() {
+ combo = new JComboBox(strData);
+ combo.addActionListener(DefaultButtonTest.this);
+ combo2 = new JComboBox(strData2);
+ combo2.setEditable(true);
+ combo2.addActionListener(DefaultButtonTest.this);
+
+ JPanel panel = new JPanel();
+
+ panel.add(combo);
+ panel.add(combo2);
+
+ return panel;
+ }
+
+ private JScrollPane createInfoPanel() {
+ StringBuffer txt = new StringBuffer("Test for 4337071:\n");
+ txt.append("ENTER pressed in NON-EDITABLE combo box should be passed to the OK button.\n");
+ txt.append("For an EDITABLE combo box, the combo box should fire an action event.");
+ txt.append("\n\nTest for 4515752:\n");
+ txt.append("ENTER on an EDITABLE combo box in which the contents has not changed\n");
+ txt.append("should be passed to the default button");
+
+ JTextArea text = new JTextArea(txt.toString());
+ text.setEditable(false);
+
+ return new JScrollPane(text);
+ }
+
+
+ private JPanel createButtonPanel(JFrame frame) {
+ frame.getRootPane().setDefaultButton(okButton);
+
+ // This is just to check when the OK Button was pressed.
+ okButton.addActionListener(DefaultButtonTest.this);
+
+ JPanel panel = new JPanel();
+ panel.add(okButton);
+ panel.add(cancelButton);
+ return panel;
+ }
+ }
+
+}
--- a/jdk/test/javax/swing/JComboBox/4743225/bug4743225.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JComboBox/4743225/bug4743225.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,8 +27,6 @@
* @author Alexander Potochkin
*/
-import sun.awt.SunToolkit;
-
import javax.accessibility.AccessibleContext;
import javax.swing.JComboBox;
import javax.swing.JFrame;
@@ -39,7 +37,6 @@
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.InputEvent;
public class bug4743225 extends JFrame {
@@ -80,21 +77,20 @@
Robot robot = new Robot();
robot.setAutoDelay(20);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new bug4743225().setVisible(true);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
// calling this method from main thread is ok
Point point = cb.getLocationOnScreen();
robot.mouseMove(point.x + 10, point.y + 10);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
--- a/jdk/test/javax/swing/JComboBox/6236162/bug6236162.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JComboBox/6236162/bug6236162.java Wed Jul 05 20:11:52 2017 +0200
@@ -31,8 +31,6 @@
@run main bug6236162
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.MetalComboBoxUI;
@@ -40,7 +38,6 @@
import java.awt.event.KeyEvent;
public class bug6236162 {
- private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
private static JFrame frame;
private static JComboBox combo;
private static MyComboUI comboUI;
@@ -52,7 +49,6 @@
createAndShowGUI();
}
});
- toolkit.realSync();
test();
System.out.println("Test passed");
}
@@ -78,11 +74,11 @@
robot.setAutoDelay(50);
// Open popup menu
- realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_DOWN);
// Move mouse to the first popup menu item
- realSync();
+ robot.waitForIdle();
Point p = combo.getLocationOnScreen();
Dimension size = combo.getSize();
p.x += size.width / 2;
@@ -94,10 +90,10 @@
}
// Select the second popup menu item
- realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_DOWN);
- realSync();
+ robot.waitForIdle();
JList list = comboUI.getComboPopup().getList();
if (list.getSelectedIndex() != 1) {
throw new RuntimeException("There is an inconsistence in combo box " +
@@ -106,9 +102,6 @@
}
}
- private static void realSync() {
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
- }
// Gives access to BasicComboBoxUI.popup field
private static class MyComboUI extends MetalComboBoxUI {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComboBox/6559152/bug6559152.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,101 @@
+/*
+ * 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
+ * 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 6559152
+ @summary Checks that you can select an item in JComboBox with keyboard
+ when it is a JTable cell editor.
+ @author Mikhail Lapshin
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @run main bug6559152
+*/
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableModel;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug6559152 {
+ private JFrame frame;
+ private JComboBox cb;
+ private ExtendedRobot robot;
+
+ public static void main(String[] args) throws Exception {
+ final bug6559152 test = new bug6559152();
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ test.setupUI();
+ }
+ });
+ test.test();
+ } finally {
+ if (test.frame != null) {
+ test.frame.dispose();
+ }
+ }
+ }
+
+ private void setupUI() {
+ frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ DefaultTableModel model = new DefaultTableModel(1, 1);
+ JTable table = new JTable(model);
+
+ cb = new JComboBox(new String[]{"one", "two", "three"});
+ cb.setEditable(true);
+ table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(cb));
+ frame.add(cb);
+
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+
+ private void test() throws Exception {
+ robot = new ExtendedRobot();
+ robot.waitForIdle();
+ testImpl();
+ robot.waitForIdle();
+ checkResult();
+ }
+
+ private void testImpl() throws Exception {
+ robot.type(KeyEvent.VK_DOWN);
+ robot.waitForIdle();
+ robot.type(KeyEvent.VK_DOWN);
+ robot.waitForIdle();
+ robot.type(KeyEvent.VK_ENTER);
+ }
+
+ private void checkResult() {
+ if (cb.getSelectedItem().equals("two")) {
+ System.out.println("Test passed");
+ } else {
+ System.out.println("Test failed");
+ throw new RuntimeException("Cannot select an item " +
+ "from popup with the ENTER key.");
+ }
+ }
+}
--- a/jdk/test/javax/swing/JComboBox/6607130/bug6607130.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JComboBox/6607130/bug6607130.java Wed Jul 05 20:11:52 2017 +0200
@@ -30,8 +30,6 @@
* @author Mikhail Lapshin
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
@@ -79,44 +77,44 @@
}
private void test() throws Exception {
- realSync();
+ robot.waitForIdle();
test1();
- realSync();
+ robot.waitForIdle();
checkResult("First test");
test2();
- realSync();
+ robot.waitForIdle();
checkResult("Second test");
}
private void test1() throws Exception {
// Select 'one'
hitKey(KeyEvent.VK_TAB);
- realSync();
+ robot.waitForIdle();
hitKey(KeyEvent.VK_F2);
- realSync();
+ robot.waitForIdle();
hitKey(KeyEvent.VK_DOWN);
- realSync();
+ robot.waitForIdle();
hitKey(KeyEvent.VK_DOWN);
- realSync();
+ robot.waitForIdle();
hitKey(KeyEvent.VK_ENTER);
- realSync();
+ robot.waitForIdle();
// Select 'one' again
hitKey(KeyEvent.VK_F2);
- realSync();
+ robot.waitForIdle();
hitKey(KeyEvent.VK_DOWN);
- realSync();
+ robot.waitForIdle();
hitKey(KeyEvent.VK_ENTER);
- realSync();
+ robot.waitForIdle();
}
private void test2() throws Exception {
// Press F2 and then press ENTER
// Editor should be shown and then closed
hitKey(KeyEvent.VK_F2);
- realSync();
+ robot.waitForIdle();
hitKey(KeyEvent.VK_ENTER);
- realSync();
+ robot.waitForIdle();
}
private void checkResult(String testName) {
@@ -129,10 +127,6 @@
}
}
- private static void realSync() {
- ((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
- }
-
public void hitKey(int keycode) {
robot.keyPress(keycode);
robot.keyRelease(keycode);
--- a/jdk/test/javax/swing/JComboBox/8032878/bug8032878.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JComboBox/8032878/bug8032878.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,6 +29,7 @@
* @library ../../regtesthelpers
* @build Util
* @author Alexey Ivanov
+ * @run main bug8032878
*/
import java.awt.*;
@@ -36,8 +37,6 @@
import javax.swing.*;
import javax.swing.text.JTextComponent;
-import sun.awt.SunToolkit;
-
public class bug8032878 implements Runnable {
private static final String ONE = "one";
private static final String TWO = "two";
@@ -99,15 +98,15 @@
}
private void runTest() throws Exception {
- realSync();
+ robot.waitForIdle();
// Select 'one'
Util.hitKeys(robot, KeyEvent.VK_TAB);
- realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_1);
Util.hitKeys(robot, KeyEvent.VK_2);
Util.hitKeys(robot, KeyEvent.VK_3);
Util.hitKeys(robot, KeyEvent.VK_ENTER);
- realSync();
+ robot.waitForIdle();
}
private void checkResult() throws Exception {
@@ -125,9 +124,6 @@
}
}
- private static void realSync() {
- ((SunToolkit) (Toolkit.getDefaultToolkit())).realSync();
- }
@Override
public void run() {
--- a/jdk/test/javax/swing/JComboBox/8057893/bug8057893.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JComboBox/8057893/bug8057893.java Wed Jul 05 20:11:52 2017 +0200
@@ -30,7 +30,6 @@
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
-import sun.awt.SunToolkit;
/**
* @test
@@ -47,7 +46,6 @@
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
EventQueue.invokeAndWait(() -> {
JFrame frame = new JFrame();
@@ -69,13 +67,13 @@
comboBox.requestFocusInWindow();
});
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
if(!isComboBoxEdited){
throw new RuntimeException("ComboBoxEdited event is not fired!");
--- a/jdk/test/javax/swing/JComboBox/ConsumedEscTest/ConsumedEscTest.java Thu Dec 18 19:57:48 2014 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +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.
- */
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-
-/*
- @test
- @bug 8031485
- @summary Combo box consuming escape and enter key events
- @author Petr Pchelko
- @library ../../../../lib/testlibrary/
- @build ExtendedRobot
- @run main ConsumedEscTest
-*/
-public class ConsumedEscTest {
- private static volatile JFrame frame;
- private static volatile boolean passed = false;
-
- public static void main(String... args) throws Exception {
- try {
- SwingUtilities.invokeAndWait(() -> {
- frame = new JFrame();
- JComboBox<String> combo = new JComboBox<>(new String[]{"one", "two", "three"});
- JPanel panel = new JPanel();
- panel.add(combo);
- combo.requestFocusInWindow();
- frame.setBounds(100, 150, 300, 100);
- addAction(panel);
- frame.add(panel);
- frame.setVisible(true);
- });
-
- ExtendedRobot robot = new ExtendedRobot();
- robot.waitForIdle();
- robot.type(KeyEvent.VK_ESCAPE);
- robot.waitForIdle();
- if (!passed) {
- throw new RuntimeException("FAILED: ESC was consumed by combo box");
- }
- } finally {
- if (frame != null) {
- frame.dispose();
- }
- }
- }
-
- private static void addAction(JComponent comp) {
- KeyStroke k = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
- Object actionKey = "cancel";
- comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(k, actionKey);
- Action cancelAction = new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent ev) {
- passed = true;
- }
- };
- comp.getActionMap().put(actionKey, cancelAction);
- }
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComboBox/ConsumedKeyTest/ConsumedKeyTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,89 @@
+/*
+ * 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 javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+/*
+ @test
+ @bug 8031485 8058193
+ @summary Combo box consuming escape and enter key events
+ @author Petr Pchelko
+ @library ../../../../lib/testlibrary/
+ @build ExtendedRobot
+ @run main ConsumedKeyTest
+*/
+public class ConsumedKeyTest {
+ private static volatile JFrame frame;
+ private static volatile boolean passed;
+
+ public static void main(String... args) throws Exception {
+ test(KeyEvent.VK_ESCAPE);
+ test(KeyEvent.VK_ENTER);
+ }
+
+ private static void test(final int key) throws Exception {
+ passed = false;
+ try {
+ SwingUtilities.invokeAndWait(() -> {
+ frame = new JFrame();
+ JComboBox<String> combo = new JComboBox<>(new String[]{"one", "two", "three"});
+ JPanel panel = new JPanel();
+ panel.add(combo);
+ combo.requestFocusInWindow();
+ frame.setBounds(100, 150, 300, 100);
+ addAction(panel, key);
+ frame.add(panel);
+ frame.setVisible(true);
+ });
+
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.waitForIdle();
+ robot.type(key);
+ robot.waitForIdle();
+ if (!passed) {
+ throw new RuntimeException("FAILED: " + KeyEvent.getKeyText(key) + " was consumed by combo box");
+ }
+ } finally {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+
+ }
+
+ private static void addAction(JComponent comp, final int key) {
+ KeyStroke k = KeyStroke.getKeyStroke(key, 0);
+ Object actionKey = "cancel";
+ comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(k, actionKey);
+ Action cancelAction = new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent ev) {
+ passed = true;
+ }
+ };
+ comp.getActionMap().put(actionKey, cancelAction);
+ }
+
+}
--- a/jdk/test/javax/swing/JComponent/6683775/bug6683775.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JComponent/6683775/bug6683775.java Wed Jul 05 20:11:52 2017 +0200
@@ -38,8 +38,8 @@
public class bug6683775 {
public static void main(String[] args) throws Exception {
GraphicsConfiguration gc = getGC();
- if (!AWTUtilities.isTranslucencySupported(
- AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
+ if (!AWTUtilities.isTranslucencySupported(
+ AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
|| gc == null) {
return;
}
--- a/jdk/test/javax/swing/JComponent/7154030/bug7154030.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JComponent/7154030/bug7154030.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,7 +29,6 @@
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
import java.awt.AWTException;
import java.awt.AlphaComposite;
@@ -46,7 +45,9 @@
* @summary Swing components fail to hide after calling hide()
* @author Jonathan Lu
* @library ../../regtesthelpers/
+ * @library ../../../../lib/testlibrary/
* @build Util
+ * @build ExtendedRobot
* @run main bug7154030
*/
@@ -61,9 +62,7 @@
BufferedImage imageHide = null;
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-
- Robot robot = new Robot();
+ ExtendedRobot robot = new ExtendedRobot();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -89,7 +88,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle(500);
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
SwingUtilities.invokeAndWait(new Runnable() {
@@ -100,13 +99,13 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle(500);
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
if (Util.compareBufferedImages(imageInit, imageShow)) {
throw new Exception("Failed to show opaque button");
}
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -116,7 +115,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle(500);
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
if (!Util.compareBufferedImages(imageInit, imageHide)) {
@@ -133,7 +132,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle(500);
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
SwingUtilities.invokeAndWait(new Runnable() {
@@ -144,7 +143,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle(500);
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
SwingUtilities.invokeAndWait(new Runnable() {
@@ -159,7 +158,7 @@
throw new Exception("Failed to show non-opaque button");
}
- toolkit.realSync();
+ robot.waitForIdle(500);
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
if (!Util.compareBufferedImages(imageInit, imageHide)) {
--- a/jdk/test/javax/swing/JEditorPane/6917744/bug6917744.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JEditorPane/6917744/bug6917744.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,8 +33,6 @@
import java.io.IOException;
import javax.swing.*;
-import sun.awt.SunToolkit;
-
public class bug6917744 {
private static JFrame frame;
@@ -45,7 +43,6 @@
private static Robot robot;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(100);
@@ -70,13 +67,14 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
for (int i = 0; i < 50; i++) {
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
+ robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
}
- toolkit.realSync();
+ robot.waitForIdle();
// Check that we at the end of document
SwingUtilities.invokeAndWait(new Runnable() {
@@ -89,13 +87,14 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
for (int i = 0; i < 50; i++) {
robot.keyPress(KeyEvent.VK_PAGE_UP);
+ robot.keyRelease(KeyEvent.VK_PAGE_UP);
}
- toolkit.realSync();
+ robot.waitForIdle();
// Check that we at the begin of document
SwingUtilities.invokeAndWait(new Runnable() {
--- a/jdk/test/javax/swing/JFileChooser/4524490/bug4524490.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JFileChooser/4524490/bug4524490.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,24 +25,23 @@
* @test
* @bug 4524490
* @summary Tests if in JFileChooser, ALT+L does not bring focus to 'Files' selection list in Motif LAF
+ * @author Konstantin Eremin
* @library ../../regtesthelpers
- * @build Util
- * @author Konstantin Eremin
+ * @library ../../../../lib/testlibrary
+ * @build Util jdk.testlibrary.OSInfo
* @run main bug4524490
*/
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.*;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
public class bug4524490 {
private static JFileChooser fileChooser;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -56,7 +55,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
--- a/jdk/test/javax/swing/JFileChooser/7199708/bug7199708.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JFileChooser/7199708/bug7199708.java Wed Jul 05 20:11:52 2017 +0200
@@ -37,7 +37,6 @@
import javax.swing.AbstractButton;
import javax.swing.JTable;
import javax.swing.UIManager;
-import sun.awt.SunToolkit;
/**
* @test
@@ -56,7 +55,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -70,7 +68,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -108,14 +106,14 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
int d = 25;
for (int i = 0; i < width / d; i++) {
robot.mouseMove(locationX + i * d, locationY + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
}
robot.keyPress(KeyEvent.VK_ESCAPE);
--- a/jdk/test/javax/swing/JFileChooser/8002077/bug8002077.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JFileChooser/8002077/bug8002077.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,7 +28,6 @@
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
-import sun.awt.SunToolkit;
/**
* @test
@@ -54,7 +53,6 @@
}
private static void runTest() throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -63,17 +61,17 @@
fileChooserState = new JFileChooser().showSaveDialog(null);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitMnemonics(robot, KeyEvent.VK_N);
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitMnemonics(robot, KeyEvent.VK_S);
- toolkit.realSync();
+ robot.waitForIdle();
if (fileChooserState != JFileChooser.APPROVE_OPTION) {
throw new RuntimeException("Save button is not pressed!");
--- a/jdk/test/javax/swing/JFileChooser/8021253/bug8021253.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JFileChooser/8021253/bug8021253.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,7 +32,6 @@
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
/**
* @test
@@ -50,7 +49,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -60,7 +58,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -68,11 +66,11 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
if (!defaultKeyPressed) {
throw new RuntimeException("Default button is not pressed");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,40 @@
+<html>
+<!--
+ 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 8029536
+ @author Sergey Bylokhov
+ @run applet/manual=yesno FileFilterDescription.html
+-->
+
+<body>
+<applet code="FileFilterDescription.class" width=200 height=200></applet>
+Follow the instructions below.
+1) Check that current filter in the opened JFileChooser is a "CustomFileFilter".
+2) Close the JFileChooser.
+3) Test will repeat steps 1 - 2 for all supported look and feels.
+4) If it's true for all look and feels then the test passed, otherwise it failed.
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JFileChooser/FileFilterDescription/FileFilterDescription.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,85 @@
+/*
+ * 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.applet.Applet;
+import java.io.File;
+
+import javax.swing.JFileChooser;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.filechooser.FileFilter;
+
+public final class FileFilterDescription extends Applet {
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public void start() {
+ try {
+ test();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public static void test() throws Exception {
+ final UIManager.LookAndFeelInfo[] infos = UIManager
+ .getInstalledLookAndFeels();
+ for (final UIManager.LookAndFeelInfo info : infos) {
+ SwingUtilities.invokeAndWait(() -> {
+ final JFileChooser chooser = new JFileChooser();
+ setLookAndFeel(info);
+ chooser.setAcceptAllFileFilterUsed(false);
+ chooser.setFileFilter(new CustomFileFilter());
+ SwingUtilities.updateComponentTreeUI(chooser);
+ chooser.showDialog(null, "Open");
+ });
+ }
+ }
+
+ private static void setLookAndFeel(final UIManager.LookAndFeelInfo info) {
+ try {
+ UIManager.setLookAndFeel(info.getClassName());
+ } catch (ClassNotFoundException | InstantiationException |
+ UnsupportedLookAndFeelException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static class CustomFileFilter extends FileFilter {
+
+ @Override
+ public boolean accept(final File f) {
+ return false;
+ }
+
+ @Override
+ public String getDescription() {
+ return "CustomFileFilter";
+ }
+ }
+}
\ No newline at end of file
--- a/jdk/test/javax/swing/JFrame/4962534/bug4962534.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JFrame/4962534/bug4962534.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,7 +33,6 @@
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
-import sun.awt.SunToolkit;
public class bug4962534 extends Applet {
@@ -45,7 +44,6 @@
Component titleComponent;
JLayeredPane lPane;
volatile boolean titleFound = false;
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
public static Object LOCK = new Object();
@Override
@@ -91,13 +89,13 @@
robot = new Robot();
robot.setAutoDelay(70);
- toolkit.realSync();
+ robot.waitForIdle();
robot.mouseMove(framePosition.x + getJFrameWidthEDT() / 2,
framePosition.y + titleComponent.getHeight() / 2);
robot.mousePress(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
gcBounds =
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getConfigurations()[0].getBounds();
@@ -105,7 +103,7 @@
robot.mouseMove(framePosition.x + getJFrameWidthEDT() / 2,
framePosition.y + titleComponent.getHeight() / 2);
- toolkit.realSync();
+ robot.waitForIdle();
int multier = gcBounds.height / 2 - 10; //we will not go out the borders
for (int i = 0; i < 10; i++) {
@@ -113,7 +111,7 @@
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
} catch (AWTException e) {
throw new RuntimeException("Test Failed. AWTException thrown." + e.getMessage());
--- a/jdk/test/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java Wed Jul 05 20:11:52 2017 +0200
@@ -22,21 +22,21 @@
*/
import java.awt.Rectangle;
-import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
-
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
/**
* @test
* @bug 7124513
* @summary We should support NSTexturedBackgroundWindowMask style on OSX.
* @author Sergey Bylokhov
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot jdk.testlibrary.OSInfo
+ * @run main NSTexturedJFrame
*/
public final class NSTexturedJFrame {
@@ -46,12 +46,15 @@
private static Rectangle bounds;
private static volatile int step;
private static JFrame frame;
+ private static ExtendedRobot robot;
public static void main(final String[] args) throws Exception {
if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
System.out.println("This test is for OSX, considered passed.");
return;
}
+ robot = new ExtendedRobot();
+ robot.setAutoDelay(50);
// Default window appearance
showFrame();
step++;
@@ -84,12 +87,10 @@
}
private static void showFrame() throws Exception {
- final Robot robot = new Robot();
- robot.setAutoDelay(50);
createUI();
images[step] = robot.createScreenCapture(bounds);
SwingUtilities.invokeAndWait(frame::dispose);
- sleep();
+ robot.waitForIdle(1000);
}
private static void createUI() throws Exception {
@@ -107,15 +108,11 @@
}
frame.setVisible(true);
});
- sleep();
+ robot.waitForIdle(1000);
SwingUtilities.invokeAndWait(() -> {
bounds = frame.getBounds();
});
- sleep();
+ robot.waitForIdle(1000);
}
- private static void sleep() throws InterruptedException {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
- Thread.sleep(1000);
- }
}
--- a/jdk/test/javax/swing/JInternalFrame/5066752/bug5066752.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JInternalFrame/5066752/bug5066752.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,21 +32,19 @@
import java.awt.*;
import javax.swing.*;
-import sun.awt.*;
public class bug5066752
{
private static JFrame frame;
public static void main(String[] args) throws Exception {
- SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
Robot r = new Robot();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
- tk.realSync();
+ r.waitForIdle();
r.delay(600);
--- a/jdk/test/javax/swing/JInternalFrame/8020708/bug8020708.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JInternalFrame/8020708/bug8020708.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,7 +32,6 @@
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
-import sun.awt.SunToolkit;
/**
* @test
@@ -79,7 +78,6 @@
}
static void testInternalFrameMnemonic() throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -103,25 +101,26 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point clickPoint = Util.getCenterPoint(internalFrame);
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_SPACE);
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_C);
- toolkit.realSync();
+ robot.waitForIdle();
+ robot.delay(500);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (internalFrame.isVisible()) {
- throw new RuntimeException("Close mnemonic does not work");
+ throw new RuntimeException("Close mnemonic does not work in "+UIManager.getLookAndFeel());
}
frame.dispose();
}
--- a/jdk/test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,8 +27,6 @@
@author mcherkas
@run main InternalFrameIsNotCollectedTest
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.beans.PropertyVetoException;
@@ -41,12 +39,6 @@
private static Robot robot;
private static CustomInternalFrame iFrame;
- public static void sync() {
-
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
- }
-
public static void main(String[] args) throws Exception {
initRobot();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -60,7 +52,7 @@
}
}
});
- sync();
+ robot.waitForIdle();
invokeGC();
System.runFinalization();
Thread.sleep(1000); // it's better to wait 1 sec now then 10 sec later
@@ -134,4 +126,4 @@
waiter.notifyAll();
}
}
-}
\ No newline at end of file
+}
--- a/jdk/test/javax/swing/JLabel/6596966/bug6596966.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JLabel/6596966/bug6596966.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,16 +25,19 @@
@bug 6596966
@summary Some JFileChooser mnemonics do not work with sticky keys
@library ../../regtesthelpers
- @build Util
+ @library ../../../../lib/testlibrary
+ @build Util jdk.testlibrary.OSInfo
@run main bug6596966
@author Pavel Porvatov
*/
import java.awt.*;
import java.awt.event.KeyEvent;
+import java.awt.event.InputEvent;
import java.util.ArrayList;
import javax.swing.*;
-import sun.awt.SunToolkit;
+
+import jdk.testlibrary.OSInfo;
public class bug6596966 {
private static JFrame frame;
@@ -45,7 +48,6 @@
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
- SunToolkit toolkit = (SunToolkit) SunToolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -70,20 +72,25 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
+
- ArrayList<Integer> keys = Util.getSystemMnemonicKeyCodes();
+ int keyMask = InputEvent.ALT_MASK;
+ if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+ keyMask = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
+ }
+ ArrayList<Integer> keys = Util.getKeyCodesFromKeyMask(keyMask);
for (int i = 0; i < keys.size(); ++i) {
robot.keyPress(keys.get(i));
}
robot.keyPress(KeyEvent.VK_L);
- toolkit.realSync();
- toolkit.getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED,
+ robot.waitForIdle();
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED,
EventQueue.getMostRecentEventTime(), 0, KeyEvent.VK_L, 'L'));
- toolkit.realSync();
+ robot.waitForIdle();
try {
SwingUtilities.invokeAndWait(new Runnable() {
@@ -98,7 +105,7 @@
for (int i = 0; i < keys.size(); ++i) {
robot.keyRelease(keys.get(i));
}
- toolkit.realSync();
+ robot.waitForIdle();
}
}
}
--- a/jdk/test/javax/swing/JList/6462008/bug6462008.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JList/6462008/bug6462008.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,7 +32,6 @@
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
-import sun.awt.SunToolkit;
public class bug6462008 {
@@ -41,11 +40,9 @@
private static boolean isAquaLAF;
private static int controlKey;
private static JList list;
- private static SunToolkit toolkit;
private static Robot robot;
public static void main(String[] args) throws Exception {
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(100);
@@ -60,15 +57,15 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
setAnchorLead(-1);
- toolkit.realSync();
+ robot.waitForIdle();
testListSelection();
setAnchorLead(100);
- toolkit.realSync();
+ robot.waitForIdle();
testListSelection();
}
@@ -79,10 +76,10 @@
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelection();
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Control + Space
robot.keyPress(KeyEvent.VK_CONTROL);
@@ -90,10 +87,10 @@
robot.keyRelease(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_CONTROL);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelection();
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Shift + Space
robot.keyPress(KeyEvent.VK_SHIFT);
@@ -101,10 +98,10 @@
robot.keyRelease(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SHIFT);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelection();
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Control + Shift + Space
robot.keyPress(KeyEvent.VK_CONTROL);
@@ -114,10 +111,10 @@
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.keyRelease(KeyEvent.VK_CONTROL);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelection();
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Control + A Multiple Selection
@@ -127,11 +124,11 @@
robot.keyRelease(KeyEvent.VK_A);
robot.keyRelease(controlKey);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectionAL(-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
resetList();
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- toolkit.realSync();
+ robot.waitForIdle();
// Control + A Single Selection
robot.keyPress(controlKey);
@@ -139,12 +136,12 @@
robot.keyRelease(KeyEvent.VK_A);
robot.keyRelease(controlKey);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectionAL(0, 0, 0);
resetList();
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setSelectionInterval(5, 5);
- toolkit.realSync();
+ robot.waitForIdle();
// Control + A Selection interval (5, 5)
@@ -153,10 +150,10 @@
robot.keyRelease(KeyEvent.VK_A);
robot.keyRelease(controlKey);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelection(5);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Page Down
// Not applicable for the Aqua L&F
@@ -164,10 +161,10 @@
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelection(9, 9, 9);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
}
// Shift + Page Down
@@ -184,28 +181,28 @@
scrollDownExtendSelection();
- toolkit.realSync();
+ robot.waitForIdle();
checkSelection(0, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Down
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectionAL(0, 0, 0);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// L
robot.keyPress(KeyEvent.VK_L);
robot.keyRelease(KeyEvent.VK_L);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectionAL(0, 0, 0);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Click item 4
Point p = clickItem4();
@@ -214,10 +211,10 @@
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectionAL(4, 4, 4);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Control + Click item 4
@@ -229,10 +226,10 @@
robot.keyRelease(controlKey);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectionAL(4, 4, 4);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Shift + Click item 4
robot.keyPress(KeyEvent.VK_SHIFT);
@@ -243,10 +240,10 @@
robot.keyRelease(KeyEvent.VK_SHIFT);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectionAL(0, 4, 0, 1, 2, 3, 4);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
// Control + Shift + Click item 4
@@ -259,10 +256,10 @@
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.keyRelease(controlKey);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectionAL(0, 4);
resetList();
- toolkit.realSync();
+ robot.waitForIdle();
}
private static DefaultListModel getModel() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JList/6510999/bug6510999.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,74 @@
+/*
+ * 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
+ * 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 6510999
+ @summary Selection in a JList with both scrollbars visible jumps on arrowkey-down
+ @author Alexander Potochkin
+ @run main bug6510999
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug6510999 {
+ private static JScrollPane s;
+
+ private static void createGui() {
+ final JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ DefaultListModel dlm = new DefaultListModel();
+ for (int i = 0; i < 100; i++)
+ dlm
+ .addElement(i + " listItemlistItemlistItemlistItemItem");
+ JList l = new JList();
+ l.setModel(dlm);
+ s = new JScrollPane(l);
+ l.setSelectedIndex(50);
+ l.ensureIndexIsVisible(50);
+
+ frame.add(s);
+ frame.setSize(200, 200);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+
+ public static void main(String[] args) throws Exception {
+ Robot robot = new Robot();
+ robot.setAutoDelay(10);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ bug6510999.createGui();
+ }
+ });
+ robot.waitForIdle();
+ Point viewPosition = s.getViewport().getViewPosition();
+ robot.keyPress(KeyEvent.VK_DOWN);
+ robot.keyRelease(KeyEvent.VK_DOWN);
+ robot.waitForIdle();
+ if (!s.getViewport().getViewPosition().equals(viewPosition)) {
+ throw new RuntimeException("JScrollPane was unexpectedly scrolled");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JMenu/4417601/bug4417601.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * 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
+ * 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 4417601
+ @summary JMenus with no items paint a tiny menu.
+ @author Alexander Potochkin
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @run main bug4417601
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class bug4417601 {
+ static JMenu menu;
+ static volatile boolean flag;
+
+ public static void main(String[] args) throws Exception {
+
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(10);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ menu = new JMenu("Menu");
+ JMenuBar bar = new JMenuBar();
+ bar.add(menu);
+ frame.setJMenuBar(bar);
+
+ frame.getLayeredPane().addContainerListener(new ContainerAdapter() {
+ public void componentAdded(ContainerEvent e) {
+ flag = true;
+ }
+ });
+
+ frame.pack();
+ frame.setSize(200, 200);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+ });
+ robot.waitForIdle();
+ Point p = menu.getLocationOnScreen();
+ Dimension size = menu.getSize();
+ p.x += size.width / 2;
+ p.y += size.height / 2;
+ robot.mouseMove(p.x, p.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ if (flag) {
+ throw new RuntimeException("Empty popup was shown");
+ }
+ }
+}
--- a/jdk/test/javax/swing/JMenu/4515762/bug4515762.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JMenu/4515762/bug4515762.java Wed Jul 05 20:11:52 2017 +0200
@@ -24,7 +24,6 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import sun.awt.SunToolkit;
/**
* @test
@@ -107,7 +106,6 @@
}
public static void main(String[] args) throws Throwable {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(250);
@@ -123,17 +121,17 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitMnemonics(robot, KeyEvent.VK_D);
- toolkit.realSync();
+ robot.waitForIdle();
// Press the S key many times (should not cause an action peformed)
int TIMES = 5;
for (int i = 0; i < TIMES; i++) {
Util.hitKeys(robot, KeyEvent.VK_S);
}
- toolkit.realSync();
+ robot.waitForIdle();
// Unique menu items.
actionExpected = true;
@@ -141,31 +139,31 @@
robot.keyPress(KeyEvent.VK_S);
robot.keyRelease(KeyEvent.VK_S);
- toolkit.realSync();
+ robot.waitForIdle();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_M);
robot.keyRelease(KeyEvent.VK_M);
- toolkit.realSync();
+ robot.waitForIdle();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_T);
- toolkit.realSync();
+ robot.waitForIdle();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_W);
- toolkit.realSync();
+ robot.waitForIdle();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_U);
- toolkit.realSync();
+ robot.waitForIdle();
checkAction();
}
--- a/jdk/test/javax/swing/JMenu/4692443/bug4692443.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JMenu/4692443/bug4692443.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,7 +35,6 @@
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
-import sun.awt.SunToolkit;
public class bug4692443 {
@@ -56,29 +55,23 @@
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
+ robo.waitForIdle();
- try {
- robo = new Robot();
- } catch (AWTException e) {
- throw new RuntimeException("Robot could not be created");
- }
- int altKey = java.awt.event.KeyEvent.VK_ALT;
- robo.setAutoDelay(100);
- Util.hitMnemonics(robo, KeyEvent.VK_F); // Enter File menu
- robo.keyPress(KeyEvent.VK_S); // Enter submenu
- robo.keyRelease(KeyEvent.VK_S);
- robo.keyPress(KeyEvent.VK_O); // Launch "One" action
- robo.keyRelease(KeyEvent.VK_O);
- robo.keyPress(KeyEvent.VK_M); // Launch "One" action
- robo.keyRelease(KeyEvent.VK_M);
+ int altKey = java.awt.event.KeyEvent.VK_ALT;
+ robo.setAutoDelay(100);
+ Util.hitMnemonics(robo, KeyEvent.VK_F); // Enter File menu
+ robo.keyPress(KeyEvent.VK_S); // Enter submenu
+ robo.keyRelease(KeyEvent.VK_S);
+ robo.keyPress(KeyEvent.VK_O); // Launch "One" action
+ robo.keyRelease(KeyEvent.VK_O);
+ robo.keyPress(KeyEvent.VK_M); // Launch "One" action
+ robo.keyRelease(KeyEvent.VK_M);
- toolkit.realSync();
+ robo.waitForIdle();
- if (!passed) {
- throw new RuntimeException("Test failed.");
- }
+ if (!passed) {
+ throw new RuntimeException("Test failed.");
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JMenu/6359669/bug6359669.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,84 @@
+/*
+ * 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
+ * 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 6359669
+ @summary REGRESSION: Submenu does not work if populated in PopupMenuListener.popupMenuWillBecomeVisible
+ @author Alexander Potochkin
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @run main bug6359669
+*/
+
+import javax.swing.*;
+import javax.swing.event.PopupMenuListener;
+import javax.swing.event.PopupMenuEvent;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class bug6359669 {
+ static JMenu menu;
+
+ public static void main(String[] args) throws Exception {
+
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(10);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ JFrame f = new JFrame();
+ JMenuBar menuBar = new JMenuBar();
+ menu = new JMenu("Test");
+ menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {
+ public void popupMenuCanceled(PopupMenuEvent e) {
+ }
+
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
+ }
+
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+ menu.add(new JMenuItem("An item"));
+ }
+ });
+
+ menuBar.add(menu);
+ f.setJMenuBar(menuBar);
+
+ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ f.setSize(200, 200);
+ f.setVisible(true);
+ }
+ });
+ robot.waitForIdle();
+ Point p = menu.getLocationOnScreen();
+ Dimension size = menu.getSize();
+ p.x += size.width / 2;
+ p.y += size.height / 2;
+ robot.mouseMove(p.x, p.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ if (menu.getPopupMenu().getComponentCount() == 0) {
+ throw new RuntimeException("Where is a menuItem ?");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JMenu/6470128/bug6470128.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,84 @@
+/*
+ * 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
+ * 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 6470128
+ @summary Escape Key causes JMenu Selection to Disappear
+ @author Alexander Potochkin
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
+ @run main bug6470128
+*/
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import jdk.testlibrary.OSInfo;
+
+public class bug6470128 {
+ static JFrame frame;
+ static JMenu subMenu;
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ JMenuBar bar = new JMenuBar();
+ JMenu menu = new JMenu("Menu");
+ menu.setMnemonic('m');
+ subMenu = new JMenu("SubMenu");
+ JMenuItem item = new JMenuItem("Item");
+
+ frame.setJMenuBar(bar);
+ bar.add(menu);
+ menu.add(subMenu);
+ subMenu.add(item);
+
+ frame.setSize(200, 200);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+ });
+ Robot robot = new Robot();
+ robot.setAutoDelay(10);
+ robot.waitForIdle();
+ if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ }
+ robot.keyPress(KeyEvent.VK_ALT);
+ robot.keyPress(KeyEvent.VK_M);
+ robot.keyRelease(KeyEvent.VK_M);
+ robot.keyRelease(KeyEvent.VK_ALT);
+ if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ }
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ robot.waitForIdle();
+ if (!subMenu.isSelected()) {
+ throw new RuntimeException("Submenu is unexpectedly unselected");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JMenu/6538132/bug6538132.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,131 @@
+/*
+ * 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
+ * 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 6538132
+ @summary Regression: Pressing Escape key don't close the menu items from jdk7.0 b07 onwards
+ @author Alexander Potochkin
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @run main bug6538132
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class bug6538132 {
+ private static JMenu menu1;
+ private static JMenu menu2;
+ private static volatile boolean isWinLaf;
+
+ private static void createGui() {
+ try {
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ isWinLaf = true;
+ } catch (Exception e) {
+ // If we can't set WinLaf it means we are not under Windows
+ // make the test pass
+ isWinLaf = false;
+ return;
+ }
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ JMenuBar menuBar = new JMenuBar();
+ menu1 = createMenu();
+ menuBar.add(menu1);
+ menu2 = createMenu();
+ menuBar.add(menu2);
+ frame.setJMenuBar(menuBar);
+
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+ }
+
+ static JMenu createMenu() {
+ JMenu menu = new JMenu("Menu");
+ menu.add(new JMenuItem("MenuItem"));
+ menu.add(new JMenuItem("MenuItem"));
+ menu.add(new JMenuItem("MenuItem"));
+ return menu;
+ }
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ bug6538132.createGui();
+ }
+ });
+ if(isWinLaf) {
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(10);
+ robot.waitForIdle();
+ Point p1 = menu1.getLocationOnScreen();
+ final int x1 = p1.x + menu1.getWidth() / 2;
+ final int y1 = p1.y + menu1.getHeight() / 2;
+ robot.glide(0, 0, x1, y1);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ assertPopupOpen();
+ Point p2 = menu2.getLocationOnScreen();
+ final int x2 = p2.x + menu2.getWidth() / 2;
+ final int y2 = p2.y + menu2.getHeight() / 2;
+ robot.glide(x1, y1, x2, y2);
+ assertPopupOpen();
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+ assertPopupNotOpen();
+ robot.glide(x2, y2, x1, y1);
+ assertPopupNotOpen();
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ assertPopupOpen();
+ }
+ }
+
+ static void assertPopupOpen() {
+ if (getLastPopup() == null) {
+ throw new RuntimeException("PopupMenu is not open");
+ }
+ }
+
+ static void assertPopupNotOpen() {
+ if (getLastPopup() != null) {
+ throw new RuntimeException("PopupMenu is unexpectedly open");
+ }
+ }
+
+ // copied from BasicPopupMenuUI
+ static JPopupMenu getLastPopup() {
+ MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+ MenuElement[] p = msm.getSelectedPath();
+ JPopupMenu popup = null;
+
+ for (int i = p.length - 1; popup == null && i >= 0; i--) {
+ if (p[i] instanceof JPopupMenu)
+ popup = (JPopupMenu) p[i];
+ }
+ return popup;
+ }
+}
--- a/jdk/test/javax/swing/JMenuBar/4750590/bug4750590.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JMenuBar/4750590/bug4750590.java Wed Jul 05 20:11:52 2017 +0200
@@ -48,16 +48,15 @@
}
});
- sun.awt.SunToolkit toolkit = (sun.awt.SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
-
Robot robo = new Robot();
robo.setAutoDelay(500);
+ robo.waitForIdle();
+
Util.hitMnemonics(robo, KeyEvent.VK_F);
robo.keyPress(KeyEvent.VK_M);
robo.keyRelease(KeyEvent.VK_M);
- toolkit.realSync();
+ robo.waitForIdle();
if (passed) {
System.out.println("Test passed!");
--- a/jdk/test/javax/swing/JMenuItem/4171437/bug4171437.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JMenuItem/4171437/bug4171437.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,7 +32,6 @@
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.event.*;
-import sun.awt.SunToolkit;
public class bug4171437 {
static volatile boolean closeActivated = false;
@@ -45,16 +44,14 @@
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
-
Robot robot = new Robot();
robot.setAutoDelay(50);
+ robot.waitForIdle();
Util.hitMnemonics(robot, KeyEvent.VK_F);
Util.hitKeys(robot, KeyEvent.VK_C);
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(1000);
if (!closeActivated || customActivated) {
--- a/jdk/test/javax/swing/JMenuItem/4654927/bug4654927.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JMenuItem/4654927/bug4654927.java Wed Jul 05 20:11:52 2017 +0200
@@ -36,7 +36,6 @@
import java.awt.*;
import java.awt.event.InputEvent;
import java.util.concurrent.Callable;
-import sun.awt.SunToolkit;
public class bug4654927 {
@@ -51,7 +50,6 @@
}
UIManager.setLookAndFeel(systemLAF);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(10);
@@ -61,20 +59,20 @@
createAndShowUI();
}
});
- toolkit.realSync();
+ robot.waitForIdle();
// test mouse press
Point point = Util.getCenterPoint(menu);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
point = Util.getCenterPoint(menuItem);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (!isMenuItemShowing()) {
throw new RuntimeException("Popup is unexpectedly closed");
@@ -107,12 +105,12 @@
// close menu
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
Util.glide(robot, x0, y0, x1, y1);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (!isMenuItemShowing()) {
throw new RuntimeException("Popup is unexpectedly closed");
--- a/jdk/test/javax/swing/JMenuItem/6209975/bug6209975.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JMenuItem/6209975/bug6209975.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,15 +25,12 @@
* @test
* @bug 6209975
* @summary regression: JMenuItem icons overimposed on JMenuItem labels under Metal LAF
- * @library ../../regtesthelpers
- * @build Util
* @author Alexander Zuev
* @run main bug6209975
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
-import sun.awt.SunToolkit;
public class bug6209975 {
@@ -45,7 +42,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(500);
@@ -58,19 +54,19 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point clickPoint = getButtonClickPoint();
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
clickPoint = getMenuClickPoint();
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (RO1.itsValue <= RO2.itsValue) {
throw new RuntimeException("Offset if the second icon is invalid.");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JMenuItem/6249972/bug6249972.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,105 @@
+/*
+ * 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
+ * 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 6249972
+ @summary Tests that JMenuItem(String,int) handles lower-case mnemonics properly.
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @author Mikhail Lapshin
+ @run main bug6249972
+ */
+
+import javax.swing.*;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+public class bug6249972 implements ActionListener {
+
+
+ private JFrame frame;
+ private JMenu menu;
+ private volatile boolean testPassed = false;
+
+ public static void main(String[] args) throws Exception {
+ bug6249972 bugTest = new bug6249972();
+ bugTest.test();
+ }
+
+ public bug6249972() throws Exception {
+ SwingUtilities.invokeAndWait(
+ new Runnable() {
+ public void run() {
+ frame = new JFrame("bug6249972");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ JMenuBar bar = new JMenuBar();
+ frame.setJMenuBar(bar);
+
+ menu = new JMenu("Problem");
+ bar.add(menu);
+
+ JMenuItem item = new JMenuItem("JMenuItem(String,'z')", 'z');
+ item.addActionListener(bug6249972.this);
+ menu.add(item);
+
+ frame.setLocationRelativeTo(null);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ }
+ );
+ }
+
+
+ private void test() throws Exception {
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.waitForIdle();
+ java.awt.Point p = menu.getLocationOnScreen();
+ java.awt.Dimension size = menu.getSize();
+ p.x += size.width / 2;
+ p.y += size.height / 2;
+ robot.mouseMove(p.x, p.y);
+ robot.click();
+ robot.delay(100);
+
+ robot.waitForIdle();
+ robot.type(KeyEvent.VK_Z);
+
+ robot.waitForIdle();
+ frame.dispose(); // Try to stop the event dispatch thread
+
+ if (!testPassed) {
+ throw new RuntimeException("JMenuItem(String,int) does not handle " +
+ "lower-case mnemonics properly.");
+ }
+
+ System.out.println("Test passed");
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ // We are in the actionPerformed() method -
+ // JMenuItem(String,int) handles lower-case mnemonics properly
+ testPassed = true;
+ }
+}
--- a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,10 +26,12 @@
* @bug 7160951
* @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
* @author vera.akulova@oracle.com
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
* @run main ActionListenerCalledTwiceTest
*/
-import sun.awt.*;
+import jdk.testlibrary.OSInfo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
@@ -47,7 +49,7 @@
static volatile int listenerCallCounter = 0;
public static void main(String[] args) throws Exception {
- if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
+ if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
return;
}
@@ -59,7 +61,6 @@
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(100);
@@ -78,7 +79,7 @@
robot.keyRelease(modKeyCode);
}
- toolkit.realSync();
+ robot.waitForIdle();
if (listenerCallCounter != 1) {
throw new Exception("Test failed: ActionListener for " + menuItems[i] +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JOptionPane/6428694/bug6428694.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,114 @@
+/*
+ * 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
+ * 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 6428694
+@summary Checks that double click closes JOptionPane's input dialog.
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@author Mikhail Lapshin
+@run main bug6428694
+*/
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.JOptionPane;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class bug6428694 {
+ private static JFrame frame;
+ private static boolean mainIsWaitingForDialogClosing;
+ private static ExtendedRobot robot;
+ private static volatile boolean testPassed;
+
+ public static void main(String[] args) throws Exception {
+ robot = new ExtendedRobot();
+ try {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ bug6428694.setupUI();
+ }
+ });
+ robot.waitForIdle();
+ test();
+ } finally {
+ stopEDT();
+ }
+
+ if (testPassed) {
+ System.out.println("Test passed");
+ } else {
+ throw new RuntimeException("JOptionPane doesn't close input dialog " +
+ "by double click!");
+ }
+ }
+
+ private static void setupUI() {
+ frame = new JFrame("bug6428694 test");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+
+ Object[] selectedItems = new Object[40];
+ for (int i = 0; i < 39; i++) {
+ selectedItems[i] = ("item: " + i);
+ }
+ JOptionPane.showInputDialog(frame,
+ "Double click on selected item then click cancel",
+ "Test Option Dialog", JOptionPane.WARNING_MESSAGE, null,
+ selectedItems, selectedItems[0]);
+
+ // We are here if double click has closed the dialog
+ // or when the EDT is stopping
+ testPassed = mainIsWaitingForDialogClosing;
+ }
+
+ private static void test() {
+
+ mainIsWaitingForDialogClosing = true;
+
+ // Perform double click on an item
+ int frameLeftX = frame.getLocationOnScreen().x;
+ int frameUpperY = frame.getLocationOnScreen().y;
+ robot.mouseMove(frameLeftX + 150, frameUpperY + 120);
+ robot.waitForIdle();
+ robot.delay(100);
+ robot.setAutoDelay(50);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ // Wait for the input dialog closing
+ robot.waitForIdle();
+ robot.delay(2000);
+
+ mainIsWaitingForDialogClosing = false;
+ }
+
+ private static void stopEDT() {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+}
--- a/jdk/test/javax/swing/JOptionPane/7138665/bug7138665.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JOptionPane/7138665/bug7138665.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,8 +27,6 @@
@author Pavel Porvatov
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
@@ -55,16 +53,14 @@
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
- toolkit.realSync();
-
- Robot robot = new Robot();
+ robot.waitForIdle();
robot.setAutoDelay(100);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
}
}
--- a/jdk/test/javax/swing/JPopupMenu/4458079/bug4458079.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JPopupMenu/4458079/bug4458079.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,7 +35,6 @@
import javax.swing.event.*;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
-import sun.awt.SunToolkit;
public class bug4458079 extends JFrame implements PopupMenuListener {
public JMenu menu;
@@ -47,21 +46,20 @@
new bug4458079().createAndShowGUI();
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
+ Robot robot = new Robot();
+ robot.waitForIdle();
- Robot robot = new Robot();
robot.setAutoDelay(50);
Util.hitMnemonics(robot, KeyEvent.VK_M);
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(1000);
Util.hitKeys(robot, KeyEvent.VK_DOWN);
Util.hitKeys(robot, KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(1000);
if (!itemASelected) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/4634626/bug4634626.html Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,8 @@
+<Html>
+<Body>
+<APPLET code="bug4634626.class" WIDTH = 50 HEIGHT = 50>
+</APPLET>
+
+</Body>
+</Html>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/4634626/bug4634626.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2003, 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 4634626
+ @summary Implement context popup menus for components
+ @author Alexander Zuev
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @run applet bug4634626.html
+*/
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class bug4634626 extends JApplet {
+
+ public boolean passed = true;
+ public boolean done = false;
+
+ public JFrame mainFrame = new JFrame("Bug4634626");
+ public JRootPane rootPane = mainFrame.getRootPane();
+ public JPanel contentPane = new JPanel();
+ public JButton nopButton = new JButton("No popup button");
+ public JTextArea someText = new JTextArea("Some text here", 20, 10);
+ public JButton popButton = new JButton("Button with the popup");
+
+ public JPopupMenu btnPopup = new JPopupMenu();
+ public JPopupMenu commonPopup = new JPopupMenu();
+ static public Error toBeThrown = null;
+ static int popTrig = MouseEvent.BUTTON3_MASK;
+ static boolean popt = false;
+
+ public static class MouseWatcher extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ if(e.isPopupTrigger()) popt = true;
+ if(e.getComponent() != null &&
+ e.getComponent() instanceof JComponent &&
+ e.isPopupTrigger() &&
+ ((JComponent)e.getComponent()).getComponentPopupMenu() != null) {
+ toBeThrown =
+ new Error("The event got thru the component with popup: "
+ + e);
+ }
+ }
+ public void mouseReleased(MouseEvent e) {
+ if(e.isPopupTrigger()) popt = true;
+ if(e.getComponent() != null &&
+ e.getComponent() instanceof JComponent &&
+ e.isPopupTrigger() &&
+ ((JComponent)e.getComponent()).getComponentPopupMenu() != null) {
+ toBeThrown =
+ new Error("The event got thru the component with popup: "
+ + e);
+ }
+ if(toBeThrown != null) {
+ throw(toBeThrown);
+ }
+ }
+ }
+
+ public static MouseWatcher mouser = new MouseWatcher();
+
+ public void init() {
+
+ try {
+ popButton.setComponentPopupMenu(null);
+ popButton.setComponentPopupMenu(null);
+ popButton.setComponentPopupMenu(btnPopup);
+ popButton.setComponentPopupMenu(null);
+ } catch(Exception ex) {
+ System.err.println("Unexpected exception was thrown by " +
+ "setComponentPopupMenu() method: " + ex);
+ }
+ btnPopup.add("Button 1");
+ btnPopup.add("Button 2");
+ btnPopup.add("Button 3");
+ popButton.setComponentPopupMenu(btnPopup);
+ popButton.addMouseListener(mouser);
+ commonPopup.add("One");
+ commonPopup.add("Two");
+ commonPopup.add("Three");
+
+ contentPane.setLayout(new BorderLayout());
+ contentPane.setComponentPopupMenu(commonPopup);
+ contentPane.addMouseListener(mouser);
+ contentPane.add(nopButton, BorderLayout.NORTH);
+ nopButton.addMouseListener(mouser);
+ contentPane.add(popButton, BorderLayout.SOUTH);
+ someText.addMouseListener(mouser);
+ contentPane.add(someText, BorderLayout.CENTER);
+ mainFrame.setContentPane(contentPane);
+
+ mainFrame.pack();
+ mainFrame.setLocation(50, 50);
+
+ mainFrame.addWindowListener(new TestStateListener());
+ mainFrame.setVisible(true);
+
+ while(!done) Thread.yield();
+
+ if(!passed) {
+ throw new RuntimeException("Test failed");
+ }
+
+ }
+
+ public class TestStateListener extends WindowAdapter {
+ public void windowOpened(WindowEvent ev) {
+ try {
+ ev.getWindow().toFront();
+ ev.getWindow().requestFocus();
+ new Thread(new RobotThread()).start();
+ } catch (Exception ex) {
+ throw new RuntimeException("Thread Exception");
+ }
+ }
+ }
+
+ class RobotThread implements Runnable {
+ public void run() {
+ ExtendedRobot robo;
+ try {
+ robo = new ExtendedRobot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Cannot create Robot");
+ }
+ robo.setAutoDelay(100);
+ robo.waitForIdle();
+
+ // Determine working popup trigger event
+ clickMouseOn(robo, nopButton, popTrig);
+ robo.waitForIdle();
+ robo.delay(500);
+ if(!popt) popTrig = MouseEvent.BUTTON2_MASK;
+
+ // Inheritance is OFF by default. Popup should not appear.
+ clickMouseOn(robo, someText, popTrig);
+
+ // Set inheritance ON watch for popup.
+ someText.setInheritsPopupMenu(true);
+ clickMouseOn(robo, someText, popTrig);
+ robo.waitForIdle();
+ robo.delay(500);
+ if(!commonPopup.isVisible()) {
+ toBeThrown = new Error("Popup should be visible");
+ passed = false;
+ }
+ // Dispose popup.
+ robo.type(KeyEvent.VK_ESCAPE);
+ robo.waitForIdle();
+ someText.setInheritsPopupMenu(false);
+
+ // Button with popup assigned. Wathch for popup.
+ clickMouseOn(robo, popButton, popTrig);
+ robo.waitForIdle();
+ robo.delay(500);
+ if(!btnPopup.isVisible()) {
+ toBeThrown = new Error("Popup should be visible");
+ passed = false;
+ }
+ // Dispose popup.
+ robo.type(KeyEvent.VK_ESCAPE);
+ // Test finished.
+ done = true;
+ }
+ }
+
+
+
+ public void destroy() {
+ if(!passed) {
+ throw(toBeThrown);
+ }
+ }
+ private void clickMouseOn(ExtendedRobot robot, Component c, int button) {
+ java.awt.Point p = c.getLocationOnScreen();
+ java.awt.Dimension size = c.getSize();
+ p.x += size.width / 2;
+ p.y += size.height / 2;
+ robot.mouseMove(p.x, p.y);
+ robot.delay(100);
+ robot.click(button);
+ }
+}
--- a/jdk/test/javax/swing/JPopupMenu/4966112/bug4966112.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JPopupMenu/4966112/bug4966112.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,7 +35,6 @@
import javax.swing.event.PopupMenuEvent;
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
public class bug4966112 {
@@ -50,19 +49,18 @@
private static Robot robot;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(100);
createAndShowButton();
- toolkit.realSync();
+ robot.waitForIdle();
setClickPoint(testButton);
clickMouse(InputEvent.BUTTON1_MASK);
clickMouse(InputEvent.BUTTON2_MASK);
clickMouse(InputEvent.BUTTON3_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
closeFrame();
if (popupButton == NO_MOUSE_BUTTON) {
@@ -74,10 +72,10 @@
// Test Split Pane
createAndShowSplitPane();
- toolkit.realSync();
+ robot.waitForIdle();
clickMouse(jsp);
- toolkit.realSync();
+ robot.waitForIdle();
closeFrame();
if (!shown) {
@@ -86,10 +84,10 @@
// Test Spinner
createAndShowSpinner();
- toolkit.realSync();
+ robot.waitForIdle();
clickMouse(spin);
- toolkit.realSync();
+ robot.waitForIdle();
closeFrame();
if (!shown) {
@@ -98,16 +96,16 @@
// Test File Chooser
createAndShowFileChooser();
- toolkit.realSync();
+ robot.waitForIdle();
clickMouse(filec);
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
- toolkit.realSync();
+ robot.waitForIdle();
closeFrame();
if (!shown) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6217905/bug6217905.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,114 @@
+/*
+ * 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
+ * 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 6217905
+@summary JPopupMenu keyboard navigation stops working
+@author Alexander Potochkin
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@run main bug6217905
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class bug6217905 {
+ private static JPanel popupPanel;
+ private static JMenuItem firstItem;
+ private static JMenuItem lastItem;
+
+ private static void createGui() {
+ final JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ JPopupMenu popup = new JPopupMenu("Menu");
+ firstItem = new JMenuItem("MenuItem");
+ popup.add(firstItem);
+ popup.add(new JMenuItem("MenuItem"));
+ lastItem = new JMenuItem("MenuItem");
+ popup.add(lastItem);
+
+ popupPanel = new JPanel();
+ popupPanel.setComponentPopupMenu(popup);
+ frame.add(popupPanel);
+ frame.setSize(100, 100);
+ frame.setVisible(true);
+ }
+
+ public static void main(String[] args) throws Exception {
+ try {
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ } catch (Exception e) {
+ // This test is for WinLaf only
+ System.out.println("This test is for Windows LaF only.");
+ return;
+ }
+
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(10);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ bug6217905.createGui();
+ }
+ });
+ robot.waitForIdle();
+ Point loc = popupPanel.getLocationOnScreen();
+ int x = loc.x + popupPanel.getWidth()/2;
+ int y = loc.y + popupPanel.getHeight()/2;
+ robot.glide(0, 0, x, y);
+ robot.mousePress(InputEvent.BUTTON3_MASK);
+ robot.mouseRelease(InputEvent.BUTTON3_MASK);
+ robot.waitForIdle();
+ if (getSelectedPathLength() != 1) {
+ throw new RuntimeException("Only popup must be selected");
+ }
+ robot.glide(x, y, 0, 0);
+ robot.type(KeyEvent.VK_DOWN);
+ robot.waitForIdle();
+ if (getSelectedPathLength() != 2 || !firstItem.isArmed()) {
+ throw new RuntimeException("First item must be selected");
+ }
+ robot.type(KeyEvent.VK_ESCAPE);
+ robot.waitForIdle();
+ if (getSelectedPathLength() != 0) {
+ throw new RuntimeException("There must be no selected items");
+ }
+ robot.glide(0, 0, x, y);
+ robot.mousePress(InputEvent.BUTTON3_MASK);
+ robot.mouseRelease(InputEvent.BUTTON3_MASK);
+ robot.waitForIdle();
+ robot.glide(x, y, 0, 0);
+ robot.type(KeyEvent.VK_UP);
+ robot.waitForIdle();
+ if (getSelectedPathLength() != 2 || !lastItem.isArmed()) {
+ throw new RuntimeException("Last item must be selected");
+ }
+ }
+
+ private static int getSelectedPathLength() {
+ return MenuSelectionManager.defaultManager().getSelectedPath().length;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6415145/bug6415145.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,121 @@
+/*
+ * 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
+ * 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 6415145
+@summary REGRESSION: Selected item is not being updated while dragging above popup menu
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@author Mikhail Lapshin
+@run main bug6415145
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.AWTException;
+import java.awt.Component;
+
+public class bug6415145 {
+ private JFrame frame;
+ private JButton button;
+ private JPopupMenu popupMenu;
+ private JMenuItem item1;
+ private JMenuItem item2;
+ private static ExtendedRobot robot;
+
+ public static void main(String[] args) throws Exception {
+ robot = new ExtendedRobot();
+ final bug6415145 bugTest = new bug6415145();
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ bugTest.init();
+ }
+ });
+
+ robot.waitForIdle();
+ bugTest.test();
+ } finally {
+ bugTest.stopEDT();
+ }
+ }
+
+ private void stopEDT() {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+
+ private void init() {
+ popupMenu = new JPopupMenu("test menu");
+ item1 = new JMenuItem("item 1");
+ item2 = new JMenuItem("item 2");
+ popupMenu.add(item1);
+ popupMenu.add(item2);
+
+ button = new JButton("test button");
+ button.addMouseListener(new MouseListener());
+
+ frame = new JFrame("test frame");
+ frame.add(popupMenu);
+ frame.add(button);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(200, 200);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+
+ private class MouseListener extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ popupMenu.show(button, e.getX(), e.getY());
+ }
+ }
+
+ private void test() throws AWTException {
+ try {
+ moveMouseTo(robot, button);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ moveMouseTo(robot, item1);
+ robot.waitForIdle();
+
+ moveMouseTo(robot, item2);
+ robot.waitForIdle();
+ if ( (item1.isArmed()) || (!item2.isArmed()) ) {
+ throw new RuntimeException("Selected item is not being updated" +
+ " while dragging above popup menu.");
+ }
+ } finally {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+ }
+ private void moveMouseTo(ExtendedRobot robot, Component c) {
+ java.awt.Point p = c.getLocationOnScreen();
+ java.awt.Dimension size = c.getSize();
+ p.x += size.width / 2;
+ p.y += size.height / 2;
+ robot.mouseMove(p.x, p.y);
+ robot.delay(100);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6515446/bug6515446.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,91 @@
+/*
+ * 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
+ * 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 6515446
+@summary JMenuItems in JPopupMenus not receiving ActionEvents - incompat with 1.5
+@author Alexander Potochkin
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@run main bug6515446
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class bug6515446 {
+ private static JPanel panel;
+ private static volatile boolean flag;
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ final JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ final JPopupMenu popup = new JPopupMenu("Menu");
+ JMenuItem item = new JMenuItem("MenuItem");
+ item.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ flag = true;
+ }
+ });
+ popup.add(item);
+
+ panel = new JPanel();
+ panel.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ popup.show(panel, e.getX(), e.getY());
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ popup.setVisible(false);
+ }
+ });
+ frame.add(panel);
+ frame.setSize(200, 200);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+ });
+
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(10);
+ robot.waitForIdle();
+
+ Point l = panel.getLocationOnScreen();
+
+ int x = l.x + panel.getWidth() / 2;
+ int y = l.y + panel.getHeight() / 2;
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.glide(x, y, x + 10, y + 10);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ if (!flag) {
+ throw new RuntimeException("ActionEvent wasn't fired");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6544309/bug6544309.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,105 @@
+/*
+ * 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
+ * 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 6544309
+ @summary Checks that 'Select Input Method' popup menu allows to select
+ items with keyboard.
+ @author Mikhail Lapshin
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @run main bug6544309
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class bug6544309 {
+ private JDialog dialog;
+ private boolean passed;
+ private static ExtendedRobot robot;
+
+ public static void main(String[] args) throws Exception {
+ robot = new ExtendedRobot();
+ final bug6544309 test = new bug6544309();
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ test.setupUI();
+ }
+ });
+ test.test();
+ System.out.println("Test passed");
+ } finally {
+ if (test.dialog != null) {
+ test.dialog.dispose();
+ }
+ }
+ }
+
+ private void setupUI() {
+ dialog = new JDialog();
+ dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ dialog.setSize(200, 100);
+ dialog.setLocationRelativeTo(null);
+ dialog.setVisible(true);
+
+ JPopupMenu popup = new JPopupMenu();
+ popup.add(new JMenuItem("one"));
+ JMenuItem two = new JMenuItem("two");
+ two.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ passed = true;
+ }
+ });
+ popup.add(two);
+ popup.add(new JMenuItem("three"));
+ popup.show(dialog, 50, 50);
+ }
+
+ private void test() throws Exception {
+ testImpl();
+ checkResult();
+ }
+
+
+ private void testImpl() throws Exception {
+ robot.waitForIdle();
+ System.out.println("Pressing DOWN ARROW");
+ robot.type(KeyEvent.VK_DOWN);
+ robot.waitForIdle();
+ System.out.println("Pressing DOWN ARROW");
+ robot.type(KeyEvent.VK_DOWN);
+ robot.waitForIdle();
+ System.out.println("Pressing SPACE");
+ robot.type(KeyEvent.VK_SPACE);
+ }
+
+ private void checkResult() {
+ robot.waitForIdle();
+ if (!passed) {
+ throw new RuntimeException("If a JDialog is invoker for JPopupMenu, " +
+ "the menu cannot be handled by keyboard.");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6580930/bug6580930.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,148 @@
+/*
+ * 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
+ * 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 6580930 7184956
+@summary Swing Popups should overlap taskbar
+@author Alexander Potochkin
+@library ../../../../lib/testlibrary
+@build ExtendedRobot
+@run main bug6580930
+*/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+public class bug6580930 {
+ private static ExtendedRobot robot;
+ private static JFrame frame;
+ private static JPopupMenu popup;
+ private static Toolkit toolkit;
+ private static volatile boolean skipTest = false;
+
+ private static void createGui() {
+ frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setUndecorated(true);
+
+ popup = new JPopupMenu("Menu");
+ for (int i = 0; i < 7; i++) {
+ popup.add(new JMenuItem("MenuItem"));
+ }
+ JPanel panel = new JPanel();
+ panel.setComponentPopupMenu(popup);
+ frame.add(panel);
+
+ frame.setSize(200, 200);
+ }
+
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ JPopupMenu.setDefaultLightWeightPopupEnabled(true);
+ bug6580930.createGui();
+ }
+ });
+
+ toolkit = Toolkit.getDefaultToolkit();
+ robot = new ExtendedRobot();
+ robot.setAutoDelay(10);
+ robot.waitForIdle();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ Insets insets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
+ if (insets.bottom == 0) {
+ System.out.println("This test is only for configurations with taskbar on the bottom");
+
+ skipTest = true;
+ }
+
+ Dimension screenSize = toolkit.getScreenSize();
+ frame.setLocation(screenSize.width/2, screenSize.height - frame.getHeight() - insets.bottom + 10);
+ frame.setVisible(true);
+ }
+ });
+
+ robot.waitForIdle();
+
+ if(skipTest) {
+ return;
+ }
+ Point loc = frame.getLocationOnScreen();
+
+ robot.mouseMove(loc.x, loc.y);
+ showPopup();
+ robot.waitForIdle();
+ if (isHeavyWeightMenuVisible()) {
+ throw new RuntimeException("HeavyWeightPopup is unexpectedly visible");
+ }
+
+ robot.keyPress(KeyEvent.VK_ESCAPE);
+ robot.keyRelease(KeyEvent.VK_ESCAPE);
+
+ int x = loc.x;
+ int y = loc.y + (frame.getHeight() - popup.getPreferredSize().height) + 1;
+ robot.mouseMove(x, y);
+
+ showPopup();
+
+ if (!popup.getLocationOnScreen().equals(new Point(x, y))) {
+ throw new RuntimeException("Popup is unexpectedly shifted");
+ }
+
+ if (!isHeavyWeightMenuVisible()) {
+ throw new RuntimeException("HeavyWeightPopup is unexpectedly hidden");
+ }
+ }
+
+ private static void showPopup() {
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ if (!popup.isShowing()) {
+ robot.mousePress(InputEvent.BUTTON2_MASK);
+ robot.mouseRelease(InputEvent.BUTTON2_MASK);
+ robot.waitForIdle();
+ if (!popup.isShowing()) {
+ robot.mousePress(InputEvent.BUTTON3_MASK);
+ robot.mouseRelease(InputEvent.BUTTON3_MASK);
+ robot.waitForIdle();
+ }
+ }
+ }
+
+ private static boolean isHeavyWeightMenuVisible() {
+ Window[] windows = Window.getWindows();
+ for (Window window : windows) {
+ if (window.getClass().getSimpleName().equals("HeavyWeightWindow")
+ && window.isVisible()) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
--- a/jdk/test/javax/swing/JPopupMenu/6800513/bug6800513.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JPopupMenu/6800513/bug6800513.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,8 +32,6 @@
* @run main bug6800513
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
@@ -47,10 +45,10 @@
private static JPopupMenu popupMenu;
private static JMenu menu;
private static JFrame frame;
+ private static Robot robot;
public static void testFrame(final boolean defaultLightWeightPopupEnabled,
String expectedPopupClass) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -59,11 +57,11 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
clickOnMenu();
- toolkit.realSync();
+ robot.waitForIdle();
Field getPopup = JPopupMenu.class.getDeclaredField("popup");
getPopup.setAccessible(true);
@@ -87,7 +85,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
}
@@ -99,7 +97,6 @@
}
});
- Robot robot = new Robot();
robot.setAutoDelay(100);
robot.mouseMove(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
@@ -140,6 +137,7 @@
}
public static void main(String[] args) throws Exception {
+ robot = new Robot();
testFrame(false, "javax.swing.PopupFactory$HeavyWeightPopup");
testFrame(true, "javax.swing.PopupFactory$LightWeightPopup");
--- a/jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,7 +33,6 @@
import java.awt.*;
import java.awt.event.KeyEvent;
import javax.swing.*;
-import sun.awt.SunToolkit;
public class bug6827786 {
@@ -41,7 +40,6 @@
private static Component focusable;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -52,7 +50,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -61,7 +59,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
checkfocus();
// select menu
@@ -72,17 +70,17 @@
}
// select submenu
Util.hitKeys(robot, KeyEvent.VK_S);
- toolkit.realSync();
+ robot.waitForIdle();
// verify submenu is selected
verify(1);
Util.hitKeys(robot, KeyEvent.VK_S);
- toolkit.realSync();
+ robot.waitForIdle();
// verify last item is selected
verify(2);
Util.hitKeys(robot, KeyEvent.VK_S);
- toolkit.realSync();
+ robot.waitForIdle();
// selection should wrap to first item
verify(0);
--- a/jdk/test/javax/swing/JPopupMenu/6987844/bug6987844.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JPopupMenu/6987844/bug6987844.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,8 +29,6 @@
* @run main bug6987844
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
@@ -40,7 +38,6 @@
static JMenu menu2;
public static void main(String... args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(200);
@@ -64,7 +61,7 @@
frame.setVisible(true);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point1 = menu1.getLocationOnScreen();
Point point2 = menu2.getLocationOnScreen();
@@ -79,7 +76,7 @@
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseMove(point1.x + 1, point1.y + 1);
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
--- a/jdk/test/javax/swing/JPopupMenu/7154841/bug7154841.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JPopupMenu/7154841/bug7154841.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,16 +26,17 @@
@bug 7154841
@summary JPopupMenu is overlapped by a Dock on Mac OS X
@author Petr Pchelko
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot jdk.testlibrary.OSInfo
+ @run main bug7154841
*/
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
-
import java.awt.*;
import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.util.concurrent.atomic.AtomicReference;
+import jdk.testlibrary.OSInfo;
public class bug7154841 {
@@ -71,20 +72,20 @@
}
try {
- Robot r = new Robot();
+ ExtendedRobot r = new ExtendedRobot();
r.setAutoDelay(100);
r.setAutoWaitForIdle(true);
r.mouseMove(0, 0);
SwingUtilities.invokeAndWait(bug7154841::initAndShowUI);
- sleep();
+ r.waitForIdle(200);
SwingUtilities.invokeAndWait(() -> {
popupMenu.show(frame, frame.getX() + frame.getWidth() / 2, frame.getY() + frame.getHeight() / 2);
});
- sleep();
+ r.waitForIdle(200);
int y = (int)screenBounds.get().getY() + (int)screenBounds.get().getHeight() - 10;
int center = (int)(screenBounds.get().getX() + screenBounds.get().getWidth() / 2);
@@ -112,10 +113,4 @@
.getBounds();
}
- private static void sleep() {
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
- try {
- Thread.sleep(200);
- } catch (InterruptedException ignored) { }
- }
}
--- a/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,11 +35,9 @@
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
-import sun.awt.SunToolkit;
public class bug8033699 {
private static Robot robot;
- private static SunToolkit toolkit;
private static JButton btnStart;
private static ButtonGroup btnGrp;
@@ -61,7 +59,6 @@
Thread.sleep(100);
robot.setAutoDelay(100);
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
// tab key test grouped radio button
runTest1();
@@ -242,7 +239,7 @@
private static void hitKey(Robot robot, int keycode) {
robot.keyPress(keycode);
robot.keyRelease(keycode);
- toolkit.realSync();
+ robot.waitForIdle();
}
private static void hitKey(Robot robot, int mode, int keycode) {
@@ -250,6 +247,6 @@
robot.keyPress(keycode);
robot.keyRelease(mode);
robot.keyRelease(keycode);
- toolkit.realSync();
+ robot.waitForIdle();
}
}
--- a/jdk/test/javax/swing/JRadioButton/8041561/bug8041561.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JRadioButton/8041561/bug8041561.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,7 +25,6 @@
import java.awt.Color;
import java.awt.Point;
import java.awt.Robot;
-import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
@@ -34,7 +33,6 @@
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
-import sun.awt.SunToolkit;
/**
* @test
@@ -62,7 +60,7 @@
}
});
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ new Robot().waitForIdle();
Thread.sleep(500);
SwingUtilities.invokeAndWait(new Runnable() {
--- a/jdk/test/javax/swing/JRootPane/4670486/bug4670486.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JRootPane/4670486/bug4670486.java Wed Jul 05 20:11:52 2017 +0200
@@ -24,7 +24,6 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import sun.awt.SunToolkit;
/**
* @test
@@ -101,7 +100,6 @@
}
public static void main(String[] args) throws Throwable {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(250);
@@ -120,7 +118,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
// Change the default button to
// force a call to BasicRootPaneUI.updateDefaultButtonBindings()
@@ -131,14 +129,14 @@
// effect.
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_DOWN);
Util.hitKeys(robot, KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
checkAction();
}
--- a/jdk/test/javax/swing/JScrollBar/4708809/bug4708809.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JScrollBar/4708809/bug4708809.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,7 +32,6 @@
import java.awt.*;
import java.awt.Point;
import java.awt.event.*;
-import sun.awt.SunToolkit;
public class bug4708809 {
@@ -42,7 +41,6 @@
private static JScrollBar sbar;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(350);
@@ -53,7 +51,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -63,13 +61,13 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = getClickPoint(0.5, 0.5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -88,12 +86,12 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
point = getClickPoint(0.5, 0.2);
robot.mouseMove(point.x, point.y);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (!do_test || !passed) {
throw new Exception("The scrollbar moved with incorrect direction");
@@ -131,4 +129,4 @@
fr.setSize(200, 200);
fr.setVisible(true);
}
-}
\ No newline at end of file
+}
--- a/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@run main bug6542335
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.plaf.basic.BasicScrollBarUI;
import java.awt.*;
@@ -43,8 +41,6 @@
final Robot robot = new Robot();
robot.setAutoDelay(10);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-
final Rectangle[] thumbBounds = new Rectangle[1];
SwingUtilities.invokeAndWait(new Runnable() {
@@ -72,7 +68,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -86,7 +82,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
--- a/jdk/test/javax/swing/JScrollBar/7163696/Test7163696.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JScrollBar/7163696/Test7163696.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,12 +28,9 @@
* @author Sergey Malenkov
*/
-import sun.awt.SunToolkit;
-
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.InputEvent;
import javax.swing.JFrame;
@@ -54,12 +51,11 @@
private void test() throws Exception {
Robot robot = new Robot();
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
UIManager.setLookAndFeel(info.getClassName());
SwingUtilities.invokeAndWait(this);
- toolkit.realSync(); // after creation
+ robot.waitForIdle(); // after creation
Thread.sleep(1000);
Point point = this.bar.getLocation();
@@ -70,7 +66,7 @@
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync(); // before validation
+ robot.waitForIdle(); // before validation
Thread.sleep(1000);
SwingUtilities.invokeAndWait(this);
--- a/jdk/test/javax/swing/JScrollBar/bug4202954/bug4202954.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JScrollBar/bug4202954/bug4202954.java Wed Jul 05 20:11:52 2017 +0200
@@ -22,8 +22,9 @@
*/
/* @test
@bug 4202954
+ @library ../../../../lib/testlibrary
@library ../../regtesthelpers
- @build Util
+ @build Util jdk.testlibrary.OSInfo
@author Michael C. Albers
@run main bug4202954
*/
@@ -31,11 +32,10 @@
import java.awt.*;
import java.awt.event.InputEvent;
import javax.swing.*;
-import sun.awt.*;
+import jdk.testlibrary.OSInfo;
public class bug4202954 {
static JScrollPane buttonScrollPane;
- private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
static Robot robot;
public static void main(String[] args) throws Exception {
if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
@@ -138,13 +138,17 @@
}
};
Integer oldHValue = Util.invokeOnEDT(horizontalValue);
+ robot.waitForIdle();
Integer oldVValue = Util.invokeOnEDT(verticalValue);
+ robot.waitForIdle();
clickMouseOnComponent(scrollButton, buttons);
- toolkit.realSync();
+ robot.waitForIdle();
int newHValue = Util.invokeOnEDT(horizontalValue);
+ robot.waitForIdle();
int newVValue = Util.invokeOnEDT(verticalValue);
+ robot.waitForIdle();
return (oldHValue != newHValue || oldVValue != newVValue) == expectScroll;
}
--- a/jdk/test/javax/swing/JSlider/6348946/bug6348946.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JSlider/6348946/bug6348946.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,8 +29,6 @@
* @author Mikhail Lapshin
*/
-import sun.awt.SunToolkit;
-
import java.awt.*;
import java.awt.event.InputEvent;
import javax.swing.*;
@@ -42,13 +40,16 @@
private static JFrame frame;
private static JPanel panel;
+ private static Robot robot;
private static volatile boolean passed = false;
public static void main(String[] args) throws Exception {
+ robot = new Robot();
+ robot.setAutoDelay(10);
+
String lf = "javax.swing.plaf.metal.MetalLookAndFeel";
UIManager.setLookAndFeel(lf);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
try {
SwingUtilities.invokeAndWait(new Runnable() {
@@ -56,9 +57,9 @@
setupUI();
}
});
- toolkit.realSync();
+ robot.waitForIdle();
clickOnSlider();
- toolkit.realSync();
+ robot.waitForIdle();
checkResult();
} finally {
stopEDT();
@@ -79,9 +80,6 @@
}
private static void clickOnSlider() throws Exception {
- Robot robot = new Robot();
- robot.setAutoDelay(10);
-
Rectangle rect = getPanelRectangle();
double clickX = rect.getX() + rect.getWidth() / 4;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JSlider/6401380/bug6401380.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,82 @@
+/*
+ * 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
+ * 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 6401380
+ @summary JSlider - mouse click ont the left side of the knob is ignored.
+ @library ../../../../lib/testlibrary
+ @build ExtendedRobot
+ @author Alexander Potochkin
+ @run main bug6401380
+*/
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicSliderUI;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class bug6401380 extends JFrame {
+ private static JSlider slider;
+
+ public bug6401380() {
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ slider = new JSlider();
+ slider.setMajorTickSpacing(0);
+ slider.setMaximum(50);
+ slider.setMinorTickSpacing(10);
+ slider.setPaintLabels(true);
+ slider.setPaintTicks(true);
+ slider.setSnapToTicks(true);
+
+ // MetalSliderUI overrides scrollDueToClickInTrack() method
+ // so this test doens't work for Metal
+ slider.setUI(new BasicSliderUI(slider));
+
+ add(slider);
+ setSize(200, 200);
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.setAutoDelay(10);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ new bug6401380().setVisible(true);
+ }
+ });
+ robot.waitForIdle();
+
+ Point l = slider.getLocationOnScreen();
+ robot.glide(0, 0, l.x + slider.getWidth() / 2, l.y + slider.getHeight() / 2);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ robot.waitForIdle();
+
+ if (slider.getValue() == slider.getMaximum()) {
+ throw new RuntimeException("Slider value unchanged");
+ }
+ }
+}
--- a/jdk/test/javax/swing/JSlider/6848475/bug6848475.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JSlider/6848475/bug6848475.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
* @run main bug6848475
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.plaf.SliderUI;
import javax.swing.plaf.basic.BasicSliderUI;
@@ -47,7 +45,6 @@
private static int thumbRectX;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(100);
@@ -70,7 +67,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -80,7 +77,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -95,7 +92,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
--- a/jdk/test/javax/swing/JSpinner/4973721/bug4973721.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JSpinner/4973721/bug4973721.java Wed Jul 05 20:11:52 2017 +0200
@@ -30,21 +30,18 @@
*/
import java.awt.Robot;
-import java.awt.Toolkit;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import java.awt.event.KeyEvent;
import java.awt.event.FocusListener;
import java.awt.event.FocusEvent;
import javax.swing.*;
-import sun.awt.SunToolkit;
public class bug4973721 implements ChangeListener, FocusListener {
static volatile boolean bStateChanged = false;
static volatile boolean bFocusGained = false;
static JSpinner spinner;
static final Object listener = new bug4973721();
- private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
public void focusLost(FocusEvent e) {}
@@ -100,7 +97,7 @@
robot.setAutoDelay(50);
Util.hitKeys(robot, KeyEvent.VK_UP);
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(1000);
if (!bStateChanged) {
@@ -110,7 +107,7 @@
bStateChanged = false;
Util.hitKeys(robot, KeyEvent.VK_DOWN);
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(1000);
if (!bStateChanged) {
--- a/jdk/test/javax/swing/JSpinner/5012888/bug5012888.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JSpinner/5012888/bug5012888.java Wed Jul 05 20:11:52 2017 +0200
@@ -43,10 +43,10 @@
pane.add(spinner2, BorderLayout.SOUTH);
}
public void doTest() throws Exception {
- ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ Robot robot = new Robot();
+ robot.waitForIdle();
Point p = spinner2.getLocationOnScreen();
Rectangle rect = spinner2.getBounds();
- Robot robot = new Robot();
robot.mouseMove(p.x+rect.width-5, p.y+5);
robot.mousePress(InputEvent.BUTTON1_MASK);
Thread.sleep(1000);
--- a/jdk/test/javax/swing/JSplitPane/4885629/bug4885629.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JSplitPane/4885629/bug4885629.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
* @author Andrey Pikalev
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
@@ -91,9 +89,8 @@
}
});
- ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
-
final Robot robot = new Robot();
+ robot.waitForIdle();
robot.delay(1000);
SwingUtilities.invokeAndWait(new Runnable() {
--- a/jdk/test/javax/swing/JTabbedPane/4361477/bug4361477.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTabbedPane/4361477/bug4361477.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,7 +25,6 @@
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
-import sun.awt.SunToolkit;
/*
* @test
@@ -42,7 +41,6 @@
public static void main(String args[]) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -54,7 +52,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
--- a/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,8 +26,9 @@
* @bug 4624207
* @summary JTabbedPane mnemonics don't work from outside the tabbed pane
* @author Oleg Mokhovikov
+ * @library ../../../../lib/testlibrary
* @library ../../regtesthelpers
- * @build Util
+ * @build Util jdk.testlibrary.OSInfo
* @run main bug4624207
*/
import javax.swing.*;
@@ -38,8 +39,7 @@
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
public class bug4624207 implements ChangeListener, FocusListener {
@@ -65,7 +65,6 @@
}
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -76,7 +75,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -85,7 +84,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
if (!focusGained) {
throw new RuntimeException("Couldn't gain focus for text field");
@@ -99,7 +98,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
@@ -107,7 +106,7 @@
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
}
- toolkit.realSync();
+ robot.waitForIdle();
if (!stateChanged || tab.getSelectedIndex() != 1) {
throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
--- a/jdk/test/javax/swing/JTabbedPane/6495408/bug6495408.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTabbedPane/6495408/bug6495408.java Wed Jul 05 20:11:52 2017 +0200
@@ -23,7 +23,6 @@
import javax.swing.*;
import java.awt.*;
-import sun.awt.SunToolkit;
/*
* @test
* @bug 6495408
@@ -37,7 +36,6 @@
static JTabbedPane tabbedPane;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
final Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -56,7 +54,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
final Rectangle d = new Rectangle();
final Point p = new Point();
--- a/jdk/test/javax/swing/JTabbedPane/7161568/bug7161568.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTabbedPane/7161568/bug7161568.java Wed Jul 05 20:11:52 2017 +0200
@@ -23,7 +23,6 @@
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
/**
* @test
@@ -40,7 +39,6 @@
public static void main(String[] args) throws Exception {
UIManager.put("TabbedPane.selectionFollowsFocus", Boolean.FALSE);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -52,7 +50,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -62,12 +60,12 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
for (int i = 0; i < N; i++) {
robot.keyPress(KeyEvent.VK_LEFT);
robot.keyRelease(KeyEvent.VK_LEFT);
- toolkit.realSync();
+ robot.waitForIdle();
}
}
--- a/jdk/test/javax/swing/JTable/4220171/bug4220171.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTable/4220171/bug4220171.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,12 +34,10 @@
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.*;
import javax.swing.border.LineBorder;
-import sun.awt.SunToolkit;
public class bug4220171 {
@@ -47,7 +45,6 @@
public static void main(String args[]) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -58,26 +55,26 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
clickMouse(robot, 0, 0);
Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
checkCell(0, 0);
clickMouse(robot, 0, 1);
Util.hitKeys(robot, KeyEvent.VK_D, KeyEvent.VK_E, KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
checkCell(0, 1);
clickMouse(robot, 1, 0);
Util.hitKeys(robot, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
checkCell(1, 0);
clickMouse(robot, 1, 1);
Util.hitKeys(robot, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_ENTER);
- toolkit.realSync();
+ robot.waitForIdle();
checkCell(1, 1);
}
--- a/jdk/test/javax/swing/JTable/6263446/bug6263446.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTable/6263446/bug6263446.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,7 +32,6 @@
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
-import sun.awt.SunToolkit;
public class bug6263446 {
@@ -43,7 +42,6 @@
private static Robot robot;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(50);
@@ -55,63 +53,63 @@
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = getClickPoint();
robot.mouseMove(point.x, point.y);
- toolkit.realSync();
+ robot.waitForIdle();
click(1);
- toolkit.realSync();
+ robot.waitForIdle();
assertEditing(false);
click(2);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(null);
click(3);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(FIRST);
click(4);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(ALL);
setClickCountToStart(1);
click(1);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(null);
click(2);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(FIRST);
click(3);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(ALL);
setClickCountToStart(3);
click(1);
- toolkit.realSync();
+ robot.waitForIdle();
assertEditing(false);
click(2);
- toolkit.realSync();
+ robot.waitForIdle();
assertEditing(false);
click(3);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(null);
click(4);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(FIRST);
click(5);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(ALL);
@@ -123,11 +121,11 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
assertEditing(true);
click(2);
- toolkit.realSync();
+ robot.waitForIdle();
checkSelectedText(FIRST);
}
--- a/jdk/test/javax/swing/JTable/6777378/bug6777378.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTable/6777378/bug6777378.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@run main bug6777378
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader;
@@ -43,7 +41,6 @@
private static JTableHeader header;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(20);
SwingUtilities.invokeAndWait(new Runnable() {
@@ -78,7 +75,7 @@
frame.setVisible(true);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = header.getLocationOnScreen();
robot.mouseMove(point.x + 20, point.y + 50);
robot.mouseMove(point.x + 30, point.y + 50);
--- a/jdk/test/javax/swing/JTable/7055065/bug7055065.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTable/7055065/bug7055065.java Wed Jul 05 20:11:52 2017 +0200
@@ -38,7 +38,6 @@
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
@@ -49,7 +48,6 @@
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
-import sun.awt.SunToolkit;
import java.util.concurrent.Callable;
public class bug7055065 {
@@ -57,7 +55,6 @@
private static JTable table;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -67,15 +64,15 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
clickCell(robot, 1, 1);
Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
KeyEvent.VK_BACK_SPACE);
- toolkit.realSync();
+ robot.waitForIdle();
clickColumnHeader(robot, 1);
- toolkit.realSync();
+ robot.waitForIdle();
clickColumnHeader(robot, 1);
}
--- a/jdk/test/javax/swing/JTable/7068740/bug7068740.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTable/7068740/bug7068740.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@run main bug7068740
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.plaf.LayerUI;
import javax.swing.plaf.metal.MetalLookAndFeel;
@@ -43,7 +41,6 @@
private static Robot robot = null;
private static JTable table = null;
- private static SunToolkit toolkit = null;
bug7068740() {
super();
@@ -83,10 +80,6 @@
robot.setAutoDelay(50);
}
- if (toolkit == null) {
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- }
-
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
@@ -118,11 +111,11 @@
}
private static void doTest() throws Exception {
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
- toolkit.realSync();
+ robot.waitForIdle();
if (getSelectedRow() != 19) {
throw new RuntimeException("Test failed");
@@ -130,7 +123,7 @@
robot.keyPress(KeyEvent.VK_PAGE_UP);
robot.keyRelease(KeyEvent.VK_PAGE_UP);
- toolkit.realSync();
+ robot.waitForIdle();
if (getSelectedRow() != 0) {
throw new RuntimeException("Test failed");
}
--- a/jdk/test/javax/swing/JTableHeader/6884066/bug6884066.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTableHeader/6884066/bug6884066.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@run main bug6884066
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumnModel;
@@ -46,7 +44,6 @@
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(20);
SwingUtilities.invokeAndWait(new Runnable() {
@@ -62,7 +59,7 @@
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = header.getLocationOnScreen();
robot.mouseMove(point.x + 3, point.y + 3);
robot.mousePress(InputEvent.BUTTON1_MASK);
--- a/jdk/test/javax/swing/JTableHeader/6889007/bug6889007.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTableHeader/6889007/bug6889007.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,8 +27,6 @@
@author Alexander Potochkin
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.plaf.basic.BasicTableHeaderUI;
import javax.swing.table.JTableHeader;
@@ -37,7 +35,6 @@
public class bug6889007 {
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(20);
@@ -59,7 +56,7 @@
frame.setVisible(true);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = frame.getLocationOnScreen();
int shift = 10;
int x = point.x;
@@ -67,7 +64,7 @@
for(int i = -shift; i < frame.getWidth() + 2*shift; i++) {
robot.mouseMove(x++, y);
}
- toolkit.realSync();
+ robot.waitForIdle();
// 9 is a magic test number
if (MyTableHeaderUI.getTestValue() != 9) {
throw new RuntimeException("Unexpected test number "
--- a/jdk/test/javax/swing/JTextArea/4697612/bug4697612.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTextArea/4697612/bug4697612.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,7 +35,6 @@
import javax.swing.*;
import javax.swing.text.BadLocationException;
-import sun.awt.SunToolkit;
public class bug4697612 {
@@ -49,7 +48,6 @@
private static JScrollPane scroller;
public static void main(String[] args) throws Throwable {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(100);
@@ -61,7 +59,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -71,7 +69,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
// 4697612: pressing PgDn + PgUp should not alter caret position
Util.hitKeys(robot, KeyEvent.VK_HOME);
@@ -102,11 +100,11 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
Util.hitKeys(robot, KeyEvent.VK_PAGE_UP);
- toolkit.realSync();
+ robot.waitForIdle();
int pos = getTextCaretPosition();
if (pos0 != pos) {
@@ -126,11 +124,11 @@
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_END);
}
- toolkit.realSync();
+ robot.waitForIdle();
pos0 = getScrollerViewPosition();
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
- toolkit.realSync();
+ robot.waitForIdle();
int pos = getScrollerViewPosition();
@@ -187,6 +185,7 @@
private static void createAndShowGUI() {
frame = new JFrame();
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
+ frame.setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
text = new JTextArea();
--- a/jdk/test/javax/swing/JTextField/8036819/bug8036819.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTextField/8036819/bug8036819.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,7 +35,6 @@
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
-import sun.awt.SunToolkit;
import javax.accessibility.*;
public class bug8036819 {
@@ -49,15 +48,14 @@
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
Robot robo = new Robot();
robo.setAutoDelay(300);
+ robo.waitForIdle();
// Using mnemonic key to focus on the textfield
Util.hitMnemonics(robo, KeyEvent.VK_P);
- toolkit.realSync();
+ robo.waitForIdle();
if (!passed){
throw new RuntimeException("Test failed.");
--- a/jdk/test/javax/swing/JToolBar/4247996/bug4247996.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JToolBar/4247996/bug4247996.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,7 +29,6 @@
*/
import java.awt.*;
import javax.swing.*;
-import sun.awt.SunToolkit;
public class bug4247996 {
@@ -38,7 +37,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -51,11 +49,11 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = getButtonCenter();
robot.mouseMove(point.x, point.y);
- toolkit.realSync();
+ robot.waitForIdle();
checkButtonsSize();
--- a/jdk/test/javax/swing/JToolTip/4846413/bug4846413.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JToolTip/4846413/bug4846413.java Wed Jul 05 20:11:52 2017 +0200
@@ -37,7 +37,6 @@
import javax.swing.*;
import java.awt.event.*;
import javax.swing.plaf.metal.MetalToolTipUI;
-import sun.awt.SunToolkit;
public class bug4846413 {
@@ -46,7 +45,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -59,11 +57,11 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point movePoint = getButtonPoint();
robot.mouseMove(movePoint.x, movePoint.y);
- toolkit.realSync();
+ robot.waitForIdle();
long timeout = System.currentTimeMillis() + 9000;
while (!isTooltipAdded && (System.currentTimeMillis() < timeout)) {
--- a/jdk/test/javax/swing/JTree/4330357/bug4330357.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTree/4330357/bug4330357.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,7 +34,6 @@
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
-import sun.awt.SunToolkit;
public class bug4330357 {
@@ -43,7 +42,6 @@
private static Robot robot;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(50);
@@ -56,12 +54,12 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
clickMouse(getTreeRowClickPoint(1));
Util.hitKeys(robot, KeyEvent.VK_F2);
Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_C);
- toolkit.realSync();
+ robot.waitForIdle();
if (!hasComponent(JTextField.class)) {
throw new RuntimeException("Cell editor is missed for path: color");
@@ -69,11 +67,11 @@
clickMouse(getButtonClickPoint());
- toolkit.realSync();
+ robot.waitForIdle();
clickMouse(getTreeRowClickPoint(2));
Util.hitKeys(robot, KeyEvent.VK_F2);
- toolkit.realSync();
+ robot.waitForIdle();
if (!hasComponent(JComboBox.class)) {
throw new RuntimeException("Cell editor is missed for path: sports");
--- a/jdk/test/javax/swing/JTree/4908142/bug4908142.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTree/4908142/bug4908142.java Wed Jul 05 20:11:52 2017 +0200
@@ -36,7 +36,6 @@
import java.awt.*;
import java.awt.event.*;
import java.util.concurrent.Callable;
-import sun.awt.SunToolkit;
public class bug4908142 {
@@ -44,7 +43,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -55,7 +53,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -65,7 +63,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_A);
@@ -74,7 +72,7 @@
robot.keyRelease(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_D);
robot.keyRelease(KeyEvent.VK_D);
- toolkit.realSync();
+ robot.waitForIdle();
String sel = Util.invokeOnEDT(new Callable<String>() {
--- a/jdk/test/javax/swing/JTree/4927934/bug4927934.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTree/4927934/bug4927934.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,7 +33,6 @@
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.InvocationTargetException;
-import sun.awt.*;
public class bug4927934 implements TreeSelectionListener, TreeExpansionListener, FocusListener {
@@ -73,8 +72,7 @@
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(1000);
SwingUtilities.invokeLater(new Runnable() {
@@ -97,35 +95,35 @@
// GO TO RIGHT
selectionChanged = false;
hitKey(KeyEvent.VK_RIGHT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!checkSelectionChanged(tree, 0)) {
throw new RuntimeException("Root should be selected");
}
selectionChanged = false;
hitKey(KeyEvent.VK_RIGHT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!checkSelectionChanged(tree, 1)) {
throw new RuntimeException("Node should be selected");
}
treeExpanded = false;
hitKey(KeyEvent.VK_RIGHT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!isTreeExpanded()) {
throw new RuntimeException("Node should be expanded");
}
selectionChanged = false;
hitKey(KeyEvent.VK_RIGHT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!checkSelectionChanged(tree, 2)) {
throw new RuntimeException("Leaf1 should be selected");
}
selectionChanged = false;
hitKey(KeyEvent.VK_RIGHT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!checkSelectionChanged(tree, 2)) {
throw new RuntimeException("Leaf1 should be selected");
}
@@ -133,7 +131,7 @@
// GO TO LEFT
selectionChanged = false;
hitKey(KeyEvent.VK_LEFT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!checkSelectionChanged(tree, 1)) {
throw new RuntimeException("Node should be selected");
}
@@ -146,14 +144,14 @@
selectionChanged = false;
hitKey(KeyEvent.VK_LEFT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!checkSelectionChanged(tree, 0)) {
throw new RuntimeException("Root should be selected");
}
treeCollapsed = false;
hitKey(KeyEvent.VK_LEFT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!isTreeCollapsed()) {
throw new RuntimeException("Root should be collapsed");
}
--- a/jdk/test/javax/swing/JTree/6263446/bug6263446.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTree/6263446/bug6263446.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,7 +33,6 @@
import java.lang.reflect.Field;
import javax.swing.*;
import javax.swing.tree.*;
-import sun.awt.SunToolkit;
public class bug6263446 {
@@ -42,10 +41,8 @@
private static final String ALL = FIRST + " " + SECOND;
private static JTree tree;
private static Robot robot;
- private static SunToolkit toolkit;
public static void main(String[] args) throws Exception {
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(50);
@@ -56,7 +53,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = getClickPoint();
robot.mouseMove(point.x, point.y);
@@ -182,7 +179,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
}
@@ -252,7 +249,7 @@
}
private static void assertEditingNoTreeLock(final boolean editing) throws Exception {
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
--- a/jdk/test/javax/swing/JTree/6505523/bug6505523.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTree/6505523/bug6505523.java Wed Jul 05 20:11:52 2017 +0200
@@ -31,7 +31,6 @@
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.InputEvent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
@@ -42,14 +41,12 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
-import sun.awt.SunToolkit;
public class bug6505523 {
private static JTree tree;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -61,14 +58,14 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = getRowPointToClick(2);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
}
@@ -129,4 +126,4 @@
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
-}
\ No newline at end of file
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/6578666/bug6578666.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,80 @@
+/*
+ * 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
+ * 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 6578666
+ * @summary REGRESSION: Exception occurs when updateUI for JTree is triggered by KeyEvent
+ * @run main bug6578666
+ * @author Alexander Potochkin
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+
+public class bug6578666 {
+
+ private static JTree tree;
+
+ private static void createGui() {
+ final JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ tree = new JTree();
+ frame.add(tree);
+
+ tree.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ tree.updateUI();
+ }
+ });
+
+ frame.setSize(200, 200);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+
+ public static void main(String[] args) throws Exception {
+ Robot robot = new Robot();
+ robot.setAutoDelay(10);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ bug6578666.createGui();
+ }
+ });
+
+ robot.waitForIdle();
+
+ tree.requestFocus();
+ robot.waitForIdle();
+
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_SPACE);
+ robot.keyRelease(KeyEvent.VK_SPACE);
+
+ }
+}
--- a/jdk/test/javax/swing/JTree/8003400/Test8003400.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTree/8003400/Test8003400.java Wed Jul 05 20:11:52 2017 +0200
@@ -26,17 +26,16 @@
* @bug 8003400
* @summary Tests that JTree shows the last row
* @author Sergey Malenkov
+ * @library ../../../../lib/testlibrary
+ * @build ExtendedRobot
* @run main/othervm Test8003400
* @run main/othervm Test8003400 reverse
* @run main/othervm Test8003400 system
* @run main/othervm Test8003400 system reverse
*/
-import sun.awt.SunToolkit;
-
import java.awt.Rectangle;
import java.awt.Robot;
-import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.util.Arrays;
import java.util.Collections;
@@ -85,10 +84,12 @@
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync(500);
- new Robot().keyPress(KeyEvent.VK_END);
- toolkit.realSync(500);
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.waitForIdle(500);
+ robot.keyPress(KeyEvent.VK_END);
+ robot.waitForIdle(500);
+ robot.keyRelease(KeyEvent.VK_END);
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
--- a/jdk/test/javax/swing/JTree/8004298/bug8004298.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/JTree/8004298/bug8004298.java Wed Jul 05 20:11:52 2017 +0200
@@ -36,7 +36,6 @@
import javax.swing.*;
import javax.swing.tree.*;
import java.util.concurrent.Callable;
-import sun.awt.SunToolkit;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import com.sun.java.swing.plaf.windows.WindowsTreeUI;
@@ -47,7 +46,6 @@
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
try {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
} catch (javax.swing.UnsupportedLookAndFeelException ulafe) {
@@ -63,7 +61,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = Util.invokeOnEDT(new Callable<Point>() {
@@ -81,7 +79,7 @@
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
}
--- a/jdk/test/javax/swing/Popup/TaskbarPositionTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/Popup/TaskbarPositionTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -259,7 +259,6 @@
public static void main(String[] args) throws Throwable {
- sun.awt.SunToolkit toolkit = (sun.awt.SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -275,7 +274,7 @@
// 1 - menu
Util.hitMnemonics(robot, KeyEvent.VK_1);
- toolkit.realSync();
+ robot.waitForIdle();
isPopupOnScreen(menu1.getPopupMenu(), screenBounds);
// 2 menu with sub menu
@@ -283,14 +282,14 @@
robot.keyRelease(KeyEvent.VK_RIGHT);
Util.hitMnemonics(robot, KeyEvent.VK_S);
- toolkit.realSync();
+ robot.waitForIdle();
isPopupOnScreen(menu2.getPopupMenu(), screenBounds);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
// Focus should go to non editable combo box
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(500);
robot.keyPress(KeyEvent.VK_DOWN);
@@ -320,7 +319,7 @@
robot.mousePress(InputEvent.BUTTON3_MASK);
robot.mouseRelease(InputEvent.BUTTON3_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
test.setLocation(-30, 100);
@@ -334,7 +333,7 @@
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
- toolkit.realSync();
+ robot.waitForIdle();
Thread.sleep(500);
}
}
--- a/jdk/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -31,7 +31,6 @@
import java.awt.event.*;
import javax.swing.*;
-import sun.awt.SunToolkit;
public class NonOpaquePopupMenuTest extends JFrame {
@@ -53,7 +52,6 @@
}
public static void main(String[] args) throws Throwable {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(250);
@@ -65,14 +63,14 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point p = getMenuClickPoint();
robot.mouseMove(p.x, p.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
if (isParentOpaque()) {
throw new RuntimeException("Popup menu parent is opaque");
--- a/jdk/test/javax/swing/SwingUtilities/4917669/bug4917669.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/SwingUtilities/4917669/bug4917669.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,7 +34,6 @@
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
-import sun.awt.SunToolkit;
public class bug4917669 {
@@ -42,7 +41,6 @@
private static JFrame mainFrame;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(500);
@@ -54,7 +52,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -64,10 +62,10 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_O);
- toolkit.realSync();
+ robot.waitForIdle();
if (!passed) {
throw new RuntimeException("Action did not received by menu item.");
--- a/jdk/test/javax/swing/SwingUtilities/7146377/bug7146377.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/SwingUtilities/7146377/bug7146377.java Wed Jul 05 20:11:52 2017 +0200
@@ -27,8 +27,6 @@
@author Pavel Porvatov
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
@@ -82,9 +80,9 @@
}
});
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
- toolkit.realSync();
+ robot.waitForIdle();
// On Linux platforms realSync doesn't guaranties setSize completion
Thread.sleep(1000);
@@ -95,7 +93,6 @@
}
});
- Robot robot = new Robot();
robot.setAutoDelay(200);
@@ -117,7 +114,7 @@
robot.mouseRelease(button);
}
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
--- a/jdk/test/javax/swing/ToolTipManager/Test6256140.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/ToolTipManager/Test6256140.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,8 +29,6 @@
* @run main Test6256140
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
@@ -46,14 +44,13 @@
Robot robot = new Robot();
robot.setAutoDelay(10);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = ft.getLocationOnScreen();
robot.mouseMove(point.x, point.y);
@@ -61,7 +58,7 @@
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
- toolkit.realSync();
+ robot.waitForIdle();
if (!isTooltipShowning()) {
throw new RuntimeException("Tooltip is not shown");
@@ -69,7 +66,7 @@
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
- toolkit.realSync();
+ robot.waitForIdle();
if (isTooltipShowning()) {
throw new RuntimeException("Tooltip must be hidden now");
@@ -81,7 +78,7 @@
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
- toolkit.realSync();
+ robot.waitForIdle();
if (!isTextEqual()) {
throw new RuntimeException("FormattedTextField must cancel the updated value");
--- a/jdk/test/javax/swing/dnd/7171812/bug7171812.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/dnd/7171812/bug7171812.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@run main bug7171812
*/
-import sun.awt.SunToolkit;
-
import java.awt.*;
import java.awt.dnd.*;
import java.awt.event.InputEvent;
@@ -45,7 +43,6 @@
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception{
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -53,10 +50,10 @@
setupGUI();
}
});
- toolkit.realSync();
Robot robot = new Robot();
robot.setAutoDelay(10);
+ robot.waitForIdle();
robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
for(int offset = 5; offset < scrollPane.getHeight()-20; offset++) {
--- a/jdk/test/javax/swing/plaf/basic/BasicHTML/4251579/bug4251579.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/plaf/basic/BasicHTML/4251579/bug4251579.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,14 +32,11 @@
import java.awt.*;
import javax.swing.*;
-import sun.awt.SunToolkit;
-
public class bug4251579 {
private static JLabel htmlComponent;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
final Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -51,7 +48,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
--- a/jdk/test/javax/swing/plaf/basic/BasicMenuUI/4983388/bug4983388.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/plaf/basic/BasicMenuUI/4983388/bug4983388.java Wed Jul 05 20:11:52 2017 +0200
@@ -30,7 +30,6 @@
@run main bug4983388
*/
-import sun.awt.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.MenuListener;
@@ -64,7 +63,6 @@
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
} catch (UnsupportedLookAndFeelException | ClassNotFoundException ex) {
@@ -78,9 +76,10 @@
});
Robot robot = new Robot();
+ robot.waitForIdle();
Util.hitMnemonics(robot, KeyEvent.VK_F);
-
- toolkit.realSync();
+ robot.waitForIdle();
+ robot.delay(1000);
if (!bMenuSelected) {
throw new RuntimeException("shortcuts on menus do not work");
--- a/jdk/test/javax/swing/plaf/basic/BasicTreeUI/8023474/bug8023474.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/plaf/basic/BasicTreeUI/8023474/bug8023474.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,8 +29,6 @@
* @run main bug8023474
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -45,7 +43,6 @@
private static JTree tree;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -55,14 +52,14 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Point point = getRowPointToClick(1);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
Boolean result = (Boolean)tree.getCellEditor().getCellEditorValue();
if (!result) {
--- a/jdk/test/javax/swing/plaf/synth/7158712/bug7158712.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/plaf/synth/7158712/bug7158712.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@author Pavel Porvatov
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.synth.SynthLookAndFeel;
@@ -82,7 +80,7 @@
}
});
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
Point comboBoxLocation = Util.invokeOnEDT(new Callable<Point>() {
@Override
--- a/jdk/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,13 +35,11 @@
import javax.swing.*;
import javax.swing.plaf.synth.*;
-import sun.awt.SunToolkit;
public class bug6276188 extends JFrame {
private static JButton button;
private static Point p;
- private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
public static void main(String[] args) throws Throwable {
SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
@@ -67,7 +65,7 @@
robot.mouseMove(p.x , p.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
robot.delay(1000);
Color color = robot.getPixelColor(p.x, p.y);
--- a/jdk/test/javax/swing/plaf/windows/WindowsRootPaneUI/WrongAltProcessing/WrongAltProcessing.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/plaf/windows/WindowsRootPaneUI/WrongAltProcessing/WrongAltProcessing.java Wed Jul 05 20:11:52 2017 +0200
@@ -28,8 +28,6 @@
@run main WrongAltProcessing
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
@@ -56,7 +54,7 @@
createWindows();
}
});
- sync();
+ robot.waitForIdle();
initRobot();
runScript();
SwingUtilities.invokeLater(new Runnable() {
@@ -75,11 +73,6 @@
}
}
- public static void sync() {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
- }
-
public static void initRobot() throws AWTException {
robot = new Robot();
robot.setAutoDelay(100);
@@ -101,7 +94,7 @@
robot.keyPress(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_ALT);
clickWindowsTitle(firstFrame);
- sync();
+ robot.waitForIdle();
}
private static void pressTab() {
--- a/jdk/test/javax/swing/regtesthelpers/Util.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java Wed Jul 05 20:11:52 2017 +0200
@@ -29,7 +29,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
-import sun.swing.*;
+//import sun.swing.*;
/**
* <p>This class contains utilities useful for regression testing.
@@ -231,13 +231,6 @@
return result.get(0);
}
- /**
- * Gets key codes from system mnemonic key mask
- * @return key codes list
- */
- public static ArrayList<Integer> getSystemMnemonicKeyCodes() {
- return Util.getKeyCodesFromKeyMask(SwingUtilities2.getSystemMnemonicKeyMask());
- }
/**
* Gets the key codes list from modifiers
--- a/jdk/test/javax/swing/text/AbstractDocument/6968363/Test6968363.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/text/AbstractDocument/6968363/Test6968363.java Wed Jul 05 20:11:52 2017 +0200
@@ -20,8 +20,6 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-import sun.awt.SunToolkit;
-
import java.awt.Robot;
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -47,17 +45,22 @@
* @bug 6968363
* @summary Ensures that a custom document may not extend AbstractDocument
* @author Sergey Malenkov
+ * @library ../../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main Test6968363
*/
public class Test6968363 implements Runnable, Thread.UncaughtExceptionHandler {
private JFrame frame;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) getDefaultToolkit();
Runnable task = new Test6968363();
invokeAndWait(task);
- toolkit.realSync(100);
- new Robot().keyPress(VK_LEFT);
- toolkit.realSync(100);
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.waitForIdle(100);
+ robot.keyPress(VK_LEFT);
+ robot.waitForIdle(100);
+ robot.keyRelease(VK_LEFT);
+ robot.waitForIdle(100);
invokeAndWait(task);
}
--- a/jdk/test/javax/swing/text/CSSBorder/6796710/bug6796710.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/text/CSSBorder/6796710/bug6796710.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,7 +34,6 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
-import sun.awt.SunToolkit;
public class bug6796710 {
// The page is inlined because we want to be sure that the JEditorPane filled synchronously
@@ -95,7 +94,7 @@
}
});
- ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
// This delay should be added for MacOSX, realSync is not enough
Thread.sleep(1000);
@@ -109,7 +108,7 @@
}
});
- ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
// On Linux platforms realSync doesn't guaranties setSize completion
Thread.sleep(1000);
--- a/jdk/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,19 +33,16 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import sun.awt.SunToolkit;
public class bug4278839 extends JFrame {
private static boolean passed = true;
private static JTextArea area;
private static Robot robo;
- private static SunToolkit toolkit;
public static void main(String[] args) {
try {
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robo = new Robot();
robo.setAutoDelay(100);
@@ -56,10 +53,10 @@
}
});
- toolkit.realSync();
+ robo.waitForIdle();
clickMouse();
- toolkit.realSync();
+ robo.waitForIdle();
if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
@@ -67,7 +64,7 @@
} else {
Util.hitKeys(robo, KeyEvent.VK_CONTROL, KeyEvent.VK_HOME);
}
- toolkit.realSync();
+ robo.waitForIdle();
passed &= moveCaret(true) == 1;
passed &= moveCaret(true) == 5;
@@ -97,7 +94,7 @@
private static int moveCaret(boolean right) throws Exception {
Util.hitKeys(robo, getCtrlKey(),
right ? KeyEvent.VK_RIGHT : KeyEvent.VK_LEFT);
- toolkit.realSync();
+ robo.waitForIdle();
final int[] result = new int[1];
@@ -127,6 +124,7 @@
robo.mouseMove(rect.x + rect.width / 2, rect.y + rect.width / 2);
robo.mousePress(InputEvent.BUTTON1_MASK);
+ robo.mouseRelease(InputEvent.BUTTON1_MASK);
}
/**
--- a/jdk/test/javax/swing/text/JTextComponent/5074573/bug5074573.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/text/JTextComponent/5074573/bug5074573.java Wed Jul 05 20:11:52 2017 +0200
@@ -35,7 +35,6 @@
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
-import sun.awt.SunToolkit;
public class bug5074573 {
@@ -60,11 +59,11 @@
}
static boolean test(final Class<? extends JTextComponent> textComponentClass) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoWaitForIdle(true);
robot.setAutoDelay(50);
+
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -73,7 +72,7 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
// Remove selection from JTextField components for the Aqua Look & Feel
if (textComponent instanceof JTextField && "Aqua".equals(UIManager.getLookAndFeel().getID())) {
@@ -87,14 +86,14 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
}
robot.keyPress(getCtrlKey());
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(getCtrlKey());
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -104,13 +103,13 @@
caret.setDot(0);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
robot.keyPress(getCtrlKey());
robot.keyPress(KeyEvent.VK_DELETE);
robot.keyRelease(KeyEvent.VK_DELETE);
robot.keyRelease(getCtrlKey());
- toolkit.realSync();
+ robot.waitForIdle();
return resultString.equals(getText());
}
--- a/jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/text/StyledEditorKit/4506788/bug4506788.java Wed Jul 05 20:11:52 2017 +0200
@@ -33,13 +33,11 @@
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
-import sun.awt.SunToolkit;
public class bug4506788 extends JApplet {
private volatile boolean passed = false;
private JEditorPane jep;
- private SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
@Override
public void init() {
@@ -65,7 +63,7 @@
throw new RuntimeException("Robot could not be created");
}
- toolkit.realSync();
+ robot.waitForIdle();
Point p;
try {
@@ -78,6 +76,8 @@
robot.mouseMove(p.x, p.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.keyPress(KeyEvent.VK_HOME);
+ robot.keyRelease(KeyEvent.VK_HOME);
robot.keyPress(KeyEvent.VK_RIGHT);
robot.keyRelease(KeyEvent.VK_RIGHT);
robot.keyPress(KeyEvent.VK_X);
@@ -85,7 +85,7 @@
robot.keyPress(KeyEvent.VK_RIGHT);
robot.keyRelease(KeyEvent.VK_RIGHT);
- toolkit.realSync();
+ robot.waitForIdle();
if (!passed) {
throw new RuntimeException("Test failed.");
--- a/jdk/test/javax/swing/text/View/8014863/bug8014863.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/text/View/8014863/bug8014863.java Wed Jul 05 20:11:52 2017 +0200
@@ -32,8 +32,6 @@
* @run main bug8014863
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.text.GlyphView;
import javax.swing.text.View;
@@ -49,7 +47,6 @@
private static JEditorPane editorPane;
private static JFrame frame;
private static Robot robot;
- private static SunToolkit toolkit;
private static String text1 = "<p>one two qqqq <em>this is a test sentence</em> qqqq <em>pp</em> qqqq <em>pp</em> " +
"qqqq <em>pp</em> qqqq <em>pp</em> qqqq <em>pp</em> qqqq <em>pp</em> qqqq <em>pp</em> qqqq <em>pp</em> qqqq</p>";
@@ -59,14 +56,13 @@
private static ArrayList<GlyphView> glyphViews;
public static void main(String[] args) throws Exception {
- toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
robot.setAutoDelay(50);
glyphViews = new ArrayList<GlyphView>();
createAndShowGUI(text1);
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -80,10 +76,10 @@
createAndShowGUI(text2);
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_HOME);
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_O);
Util.hitKeys(robot, KeyEvent.VK_N);
@@ -94,7 +90,7 @@
Util.hitKeys(robot, KeyEvent.VK_O);
Util.hitKeys(robot, KeyEvent.VK_SPACE);
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
--- a/jdk/test/javax/swing/text/html/CSS/4530474/bug4530474.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/text/html/CSS/4530474/bug4530474.java Wed Jul 05 20:11:52 2017 +0200
@@ -34,8 +34,6 @@
import java.io.*;
-import sun.awt.SunToolkit;
-
public class bug4530474 {
private static final Color TEST_COLOR = Color.BLUE;
@@ -43,7 +41,6 @@
public static void main(String args[]) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
final Robot robot = new Robot();
robot.setAutoDelay(50);
@@ -55,7 +52,8 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
+ robot.delay(500);
SwingUtilities.invokeAndWait(new Runnable() {
--- a/jdk/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java Wed Jul 05 20:11:52 2017 +0200
@@ -37,7 +37,6 @@
import javax.swing.text.Document;
import javax.swing.text.BadLocationException;
import java.awt.event.KeyEvent;
-import sun.awt.SunToolkit;
public class bug5043626 {
@@ -45,7 +44,6 @@
private static Robot robot;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
robot = new Robot();
SwingUtilities.invokeAndWait(new Runnable() {
@@ -54,12 +52,12 @@
}
});
- toolkit.realSync();
+ robot.waitForIdle();
Util.hitKeys(robot, KeyEvent.VK_HOME);
Util.hitKeys(robot, KeyEvent.VK_1);
- toolkit.realSync();
+ robot.waitForIdle();
String test = getText();
@@ -70,7 +68,7 @@
Util.hitKeys(robot, KeyEvent.VK_HOME);
Util.hitKeys(robot, KeyEvent.VK_2);
- toolkit.realSync();
+ robot.waitForIdle();
test = getText();
--- a/jdk/test/lib/testlibrary/OutputAnalyzerTest.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/lib/testlibrary/OutputAnalyzerTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -112,8 +112,10 @@
}
String stdoutPattern = "[a]";
+ String stdoutByLinePattern = "a*";
String stderrPattern = "[b]";
String nonExistingPattern = "[c]";
+ String byLinePattern = "[ab]*";
// Should match
try {
@@ -148,6 +150,19 @@
// expected
}
+ if (output.shouldMatchByLine(byLinePattern) != 1) {
+ throw new Exception("shouldMatchByLine() should find one line");
+ }
+ try {
+ output.shouldMatchByLine(nonExistingPattern);
+ throw new Exception("shouldMatchByLine() failed to throw exception");
+ } catch (RuntimeException e) {
+ // expected
+ }
+ if (output.stdoutShouldMatchByLine(stdoutByLinePattern) != 1) {
+ throw new Exception("stdoutShouldMatchByLine() should find one line");
+ }
+
// Should not match
try {
output.shouldNotMatch(nonExistingPattern);
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,13 +25,9 @@
import static jdk.testlibrary.Asserts.*;
-import java.io.ByteArrayOutputStream;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -414,8 +410,12 @@
* @return Contents of the output buffer as list of strings
*/
public List<String> asLines() {
+ return asLines(getOutput());
+ }
+
+ private List<String> asLines(String buffer) {
List<String> l = new ArrayList<>();
- String[] a = getOutput().split(Utils.NEW_LINE);
+ String[] a = buffer.split(Utils.NEW_LINE);
for (String string : a) {
l.add(string);
}
@@ -445,6 +445,13 @@
}
/**
+ * @see #stdoutShouldMatchByLine(String, String, String)
+ */
+ public int stdoutShouldMatchByLine(String pattern) {
+ return stdoutShouldMatchByLine(null, null, pattern);
+ }
+
+ /**
* @see #shouldMatchByLine(String, String, String)
*/
public int shouldMatchByLineFrom(String from, String pattern) {
@@ -474,7 +481,30 @@
* @return Count of lines which match the {@code pattern}
*/
public int shouldMatchByLine(String from, String to, String pattern) {
- List<String> lines = asLines();
+ return shouldMatchByLine(getOutput(), from, to, pattern);
+ }
+
+ /**
+ * Verify that the stdout contents of output buffer matches the
+ * {@code pattern} line by line. The whole stdout could be matched or
+ * just a subset of it.
+ *
+ * @param from
+ * The line from where stdout will be matched.
+ * Set {@code from} to null for matching from the first line.
+ * @param to
+ * The line until where stdout will be matched.
+ * Set {@code to} to null for matching until the last line.
+ * @param pattern
+ * Matching pattern
+ * @return Count of lines which match the {@code pattern}
+ */
+ public int stdoutShouldMatchByLine(String from, String to, String pattern) {
+ return shouldMatchByLine(getStdout(), from, to, pattern);
+ }
+
+ private int shouldMatchByLine(String buffer, String from, String to, String pattern) {
+ List<String> lines = asLines(buffer);
int fromIndex = 0;
if (from != null) {
@@ -500,4 +530,5 @@
return matchedCount;
}
+
}
--- a/jdk/test/sun/awt/dnd/8024061/bug8024061.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/sun/awt/dnd/8024061/bug8024061.java Wed Jul 05 20:11:52 2017 +0200
@@ -25,11 +25,10 @@
* @bug 8024061
* @summary Checks that no exception is thrown if dragGestureRecognized
* takes a while to complete.
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
+ * @run main bug8024061
*/
-import sun.awt.OSInfo;
-import sun.awt.OSInfo.OSType;
-import sun.awt.SunToolkit;
-
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
@@ -55,6 +54,8 @@
import java.util.concurrent.TimeUnit;
import javax.swing.*;
+import jdk.testlibrary.OSInfo;
+
/**
* If dragGestureRecognized() takes a while to complete and if user performs a drag quickly,
@@ -106,8 +107,8 @@
}
public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
- OSType type = OSInfo.getOSType();
- if (type != OSType.LINUX && type != OSType.SOLARIS) {
+ OSInfo.OSType type = OSInfo.getOSType();
+ if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
System.out.println("This test is for Linux and Solaris only... " +
"skipping!");
return;
@@ -122,8 +123,7 @@
});
final Robot robot = new Robot();
robot.setAutoDelay(10);
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
+ robot.waitForIdle();
JFrame frame = dnd[0].frame;
Point point = frame.getLocationOnScreen();
@@ -138,7 +138,7 @@
System.out.println("x = " + here.x);
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- toolkit.realSync();
+ robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
System.out.println("finished");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/java2d/SunGraphics2D/EmptyClipRenderingTest.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,299 @@
+/*
+ * 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.awt.AWTException;
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import javax.imageio.ImageIO;
+import sun.awt.ConstrainableGraphics;
+
+/**
+ * @test
+ * @bug 6335200 6419610
+ * @summary Tests that we don't render anything if specific empty clip is set
+ * @author Dmitri.Trembovetski@Sun.COM: area=Graphics
+ * @run main EmptyClipRenderingTest
+ * @run main/othervm -Dsun.java2d.noddraw=true EmptyClipRenderingTest
+ * @run main/othervm -Dsun.java2d.pmoffscreen=true EmptyClipRenderingTest
+ * @run main/othervm -Dsun.java2d.opengl=true EmptyClipRenderingTest
+ */
+public class EmptyClipRenderingTest {
+ static final int IMG_W = 400;
+ static final int IMG_H = 400;
+
+ // generated rectangles
+ static HashSet<Rectangle> rects;
+
+ volatile boolean isActivated = false;
+ volatile boolean isPainted;
+ private static boolean showErrors = false;
+
+ public EmptyClipRenderingTest() {
+ // initialize clip/render region rectangles
+ initClips();
+
+ HashSet<RuntimeException> errors = new HashSet<RuntimeException>();
+
+ BufferedImage screenResult = testOnscreen();
+ try {
+ testResult(screenResult, "Screen");
+ } catch (RuntimeException e) {
+ errors.add(e);
+ }
+
+ BufferedImage destBI =
+ new BufferedImage(IMG_W, IMG_H, BufferedImage.TYPE_INT_RGB);
+ runTest((Graphics2D)destBI.getGraphics());
+ try {
+ testResult(destBI, "BufferedImage");
+ } catch (RuntimeException e) {
+ errors.add(e);
+ }
+
+ GraphicsConfiguration gc =
+ GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice().getDefaultConfiguration();
+ VolatileImage destVI = gc.createCompatibleVolatileImage(IMG_W, IMG_H);
+ destVI.validate(gc);
+ runTest((Graphics2D)destVI.getGraphics());
+ try {
+ testResult(destVI.getSnapshot(), "VolatileImage");
+ } catch (RuntimeException e) {
+ errors.add(e);
+ }
+
+ if (errors.isEmpty()) {
+ System.err.println("Test PASSED.");
+ } else {
+ for (RuntimeException re : errors) {
+ re.printStackTrace();
+ }
+ if (showErrors) {
+ System.err.println("Test FAILED: "+ errors.size() +
+ " subtest failures.");
+ } else {
+ throw new RuntimeException("Test FAILED: "+ errors.size() +
+ " subtest failures.");
+ }
+ }
+ }
+
+ /**
+ * Recursively adds 4 new rectangles: two vertical and two horizontal
+ * based on the passed rectangle area. The area is then shrunk and the
+ * process repeated for smaller area.
+ */
+ private static void add4Rects(HashSet<Rectangle> rects, Rectangle area) {
+ if (area.width < 10 || area.height < 10) {
+ rects.add(area);
+ return;
+ }
+ // two vertical rects
+ rects.add(new Rectangle(area.x, area.y, 5, area.height));
+ rects.add(new Rectangle(area.x + area.width - 5, area.y, 5, area.height));
+ // two horizontal rects
+ int width = area.width - 2*(5 + 1);
+ rects.add(new Rectangle(area.x+6, area.y, width, 5));
+ rects.add(new Rectangle(area.x+6, area.y + area.height - 5, width, 5));
+ // reduce the area and repeat
+ area.grow(-6, -6);
+ add4Rects(rects, area);
+ }
+
+ /**
+ * Generate a bunch of non-intersecting rectangles
+ */
+ private static void initClips() {
+ rects = new HashSet<Rectangle>();
+ add4Rects(rects, new Rectangle(0, 0, IMG_W, IMG_H));
+ System.err.println("Total number of test rects: " + rects.size());
+ }
+
+ /**
+ * Render the pattern to the screen, capture the output with robot and
+ * return it.
+ */
+ private BufferedImage testOnscreen() throws HeadlessException {
+ final Canvas destComponent;
+ final Object lock = new Object();
+ Frame f = new Frame("Test Frame");
+ f.setUndecorated(true);
+ f.add(destComponent = new Canvas() {
+ public void paint(Graphics g) {
+ isPainted = true;
+ }
+ public Dimension getPreferredSize() {
+ return new Dimension(IMG_W, IMG_H);
+ }
+ });
+ f.addWindowListener(new WindowAdapter() {
+ public void windowActivated(WindowEvent e) {
+ if (!isActivated) {
+ synchronized (lock) {
+ isActivated = true;
+ lock.notify();
+ }
+ }
+ }
+ });
+ f.pack();
+ f.setLocationRelativeTo(null);
+ f.setVisible(true);
+ synchronized(lock) {
+ while (!isActivated) {
+ try {
+ lock.wait(100);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ Robot r;
+ try {
+ r = new Robot();
+ } catch (AWTException ex) {
+ throw new RuntimeException("Can't create Robot");
+ }
+ BufferedImage bi;
+ int attempt = 0;
+ do {
+ if (++attempt > 10) {
+ throw new RuntimeException("Too many attempts: " + attempt);
+ }
+ isPainted = false;
+ runTest((Graphics2D) destComponent.getGraphics());
+ r.waitForIdle();
+ Toolkit.getDefaultToolkit().sync();
+ bi = r.createScreenCapture(
+ new Rectangle(destComponent.getLocationOnScreen().x,
+ destComponent.getLocationOnScreen().y,
+ destComponent.getWidth(),
+ destComponent.getHeight()));
+ } while (isPainted);
+ f.setVisible(false);
+ f.dispose();
+ return bi;
+ }
+
+ /**
+ * Run the test: cycle through all the rectangles, use one as clip and
+ * another as the area to render to.
+ * Set the clip in the same way Swing does it when repainting:
+ * first constrain the graphics to the damaged area, and repaint everything
+ */
+ void runTest(Graphics2D destGraphics) {
+ destGraphics.setColor(Color.black);
+ destGraphics.fillRect(0, 0, IMG_W, IMG_H);
+
+ destGraphics.setColor(Color.red);
+ for (Rectangle clip : rects) {
+ Graphics2D g2d = (Graphics2D)destGraphics.create();
+ g2d.setColor(Color.red);
+ // mimic what swing does in BufferStrategyPaintManager
+ if (g2d instanceof ConstrainableGraphics) {
+ ((ConstrainableGraphics)g2d).constrain(clip.x, clip.y,
+ clip.width, clip.height);
+ }
+ g2d.setClip(clip);
+
+ for (Rectangle renderRegion : rects) {
+ if (renderRegion != clip) {
+ // from CellRendererPane's paintComponent
+ Graphics2D rG = (Graphics2D)
+ g2d.create(renderRegion.x, renderRegion.y,
+ renderRegion.width, renderRegion.height);
+ rG.fillRect(0,0, renderRegion.width, renderRegion.height);
+ }
+ }
+ }
+ }
+
+ void testResult(final BufferedImage bi, final String desc) {
+ for (int y = 0; y < bi.getHeight(); y++) {
+ for (int x = 0; x < bi.getWidth(); x++) {
+ if (bi.getRGB(x, y) != Color.black.getRGB()) {
+ if (showErrors) {
+ Frame f = new Frame("Error: " + desc);
+ f.add(new Component() {
+ public void paint(Graphics g) {
+ g.drawImage(bi, 0, 0, null);
+ }
+ public Dimension getPreferredSize() {
+ return new Dimension(bi.getWidth(),
+ bi.getHeight());
+ }
+ });
+ f.pack();
+ f.setVisible(true);
+ }
+ try {
+ String fileName =
+ "EmptyClipRenderingTest_"+desc+"_res.png";
+ System.out.println("Writing resulting image: "+fileName);
+ ImageIO.write(bi, "png", new File(fileName));
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ throw new RuntimeException("Dest: "+desc+
+ " was rendered to at x="+
+ x + " y=" + y +
+ " pixel="+Integer.toHexString(bi.getRGB(x,y)));
+ }
+ }
+ }
+ }
+
+ public static void main(String argv[]) {
+ for (String arg : argv) {
+ if (arg.equals("-show")) {
+ showErrors = true;
+ } else {
+ usage("Incorrect argument:" + arg);
+ }
+ }
+ new EmptyClipRenderingTest();
+ }
+
+ private static void usage(String string) {
+ System.out.println(string);
+ System.out.println("Usage: EmptyClipRenderingTest [-show]");
+ }
+}
--- a/jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java Wed Jul 05 20:11:52 2017 +0200
@@ -22,8 +22,8 @@
*/
/**
* @test
- * @bug 6581254 6986789 7196009
- * @summary Allow '~', '+' and quoted paths in config file
+ * @bug 6581254 6986789 7196009 8062170
+ * @summary Allow '~', '+', and quoted paths in config file
* @author Valerie Peng
*/
@@ -34,7 +34,7 @@
public class ConfigShortPath {
private static final String[] configNames = {
- "csp.cfg", "cspPlus.cfg", "cspQuotedPath.cfg"
+ "csp.cfg", "cspPlus.cfg", "cspSpace.cfg", "cspQuotedPath.cfg"
};
public static void main(String[] args) throws Exception {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Provider/cspSpace.cfg Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,5 @@
+showInfo = false
+name = test
+library = C:\pki DLL\x64\acpkcs211.dll
+
+
--- a/jdk/test/sun/tools/jps/JpsHelper.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/sun/tools/jps/JpsHelper.java Wed Jul 05 20:11:52 2017 +0200
@@ -168,10 +168,8 @@
}
/**
- * Verify jps output contains pids and programs' name information.
- * The function will discard any lines that come before the first line with pid.
- * This can happen if the JVM outputs a warning message for some reason
- * before running jps.
+ * Verify jps stdout contains only pids and programs' name information.
+ * jps stderr may contain VM warning messages which will be ignored.
*
* The output can look like:
* 35536 Jps
@@ -180,8 +178,10 @@
*/
public static void verifyJpsOutput(OutputAnalyzer output, String regex) throws Exception {
output.shouldHaveExitValue(0);
- int matchedCount = output.shouldMatchByLineFrom(regex, regex);
+ int matchedCount = output.stdoutShouldMatchByLine(regex);
assertGreaterThan(matchedCount , 0, "Found no lines matching pattern: " + regex);
+ output.stderrShouldNotMatch("[E|e]xception");
+ output.stderrShouldNotMatch("[E|e]rror");
}
/**
--- a/jdk/test/sun/tools/jstat/jstatHelp.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/sun/tools/jstat/jstatHelp.sh Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 2011, 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
@@ -22,9 +22,9 @@
#
# @test
-# @bug 4990825
+# @bug 4990825 6364329
# @run shell jstatHelp.sh
-# @summary Test that output of 'jstat -?' matches the usage.out file
+# @summary Test that output of 'jstat -?', 'jstat -help' and 'jstat' matches the usage.out file
. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
@@ -38,7 +38,7 @@
diff -w jstat.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
- echo "Output of jstat -? differ from expected output. Failed."
+ echo "Output of jstat -? differs from expected output. Failed."
exit 1
fi
@@ -48,7 +48,17 @@
diff -w jstat.out ${TESTSRC}/usage.out
if [ $? != 0 ]
then
- echo "Output of jstat -help differ from expected output. Failed."
+ echo "Output of jstat -help differs from expected output. Failed."
+ exit 1
+fi
+
+rm -f jstat.out 2>/dev/null
+${JSTAT} -J-XX:+UsePerfData > jstat.out 2>&1
+
+diff -w jstat.out ${TESTSRC}/usage.out
+if [ $? != 0 ]
+then
+ echo "Output of jstat differs from expected output. Failed."
exit 1
fi
--- a/jdk/test/sun/util/calendar/zi/Rule.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/sun/util/calendar/zi/Rule.java Wed Jul 05 20:11:52 2017 +0200
@@ -126,6 +126,14 @@
});
rules.clear();
for (int i = 0; i < n; i++) {
+ if (i != 0 && recs[i -1].getSave() == recs[i].getSave()) {
+ // we have two recs back to back with same saving for the same year.
+ if (recs[i].isLastRule()) {
+ continue;
+ } else if (recs[i - 1].isLastRule()) {
+ rules.remove(rules.size() - 1);
+ }
+ }
rules.add(recs[i]);
}
return rules;
--- a/jdk/test/tools/jar/JarEntryTime.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/tools/jar/JarEntryTime.java Wed Jul 05 20:11:52 2017 +0200
@@ -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,9 +51,6 @@
static void extractJar(File jarFile, boolean useExtractionTime) throws Throwable {
String javahome = System.getProperty("java.home");
- if (javahome.endsWith("jre")) {
- javahome = javahome.substring(0, javahome.length() - 4);
- }
String jarcmd = javahome + File.separator + "bin" + File.separator + "jar";
String[] args;
if (useExtractionTime) {
--- a/jdk/test/tools/launcher/ExecutionEnvironment.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/tools/launcher/ExecutionEnvironment.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2013, 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
@@ -45,7 +45,7 @@
* a. if LD_LIBRARY_PATH64 is set it will override LD_LIBRARY_PATH
* b. LD_LIBRARY_PATH32 is ignored if set
* 5. no extra symlink exists on Solaris ie.
- * jre/lib/$arch/libjvm.so -> client/libjvm.so
+ * lib/$arch/libjvm.so -> client/libjvm.so
* TODO:
* a. perhaps we need to add a test to audit all environment variables are
* in pristine condition after the launch, there may be a few that the
@@ -267,7 +267,7 @@
}
File symLink = null;
- String libPathPrefix = isSDK ? "jre/lib" : "/lib";
+ String libPathPrefix = "/lib";
symLink = new File(JAVAHOME, libPathPrefix +
getJreArch() + "/" + LIBJVM);
if (symLink.exists()) {
--- a/jdk/test/tools/launcher/MultipleJRE.sh Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/tools/launcher/MultipleJRE.sh Wed Jul 05 20:11:52 2017 +0200
@@ -1,15 +1,14 @@
#!/bin/sh
# @test MultipleJRE.sh
-# @bug 4811102 4953711 4955505 4956301 4991229 4998210 5018605 6387069 6733959
+# @bug 4811102 4953711 4955505 4956301 4991229 4998210 5018605 6387069 6733959 8058407 8067421
# @build PrintVersion
# @build UglyPrintVersion
# @build ZipMeUp
# @run shell MultipleJRE.sh
# @summary Verify Multiple JRE version support has been removed
# @author Joseph E. Kowalski
-
#
-# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -91,6 +90,36 @@
}
#
+# Shell routine to ensure help page does not include mjre options
+#
+TestHelp() {
+ mess="`$JAVA -help 2>&1`"
+ # make sure it worked
+ if [ $? -ne 0 ]; then
+ echo "java -help failed ????"
+ exit 1
+ fi
+
+ echo $mess | grep '\-version:<value>' > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ echo "help message contains obsolete option version:<value>"
+ exit 1
+ fi
+
+ echo $mess | grep '\-jre-restrict-search' > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ echo "help message contains obsolete option jre-restrict-search"
+ exit 1
+ fi
+
+ echo $mess | grep '\-no-jre-restrict-search' > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ echo "help message contains obsolete option no-jre-restrict-search"
+ exit 1
+ fi
+}
+
+#
# Just as the name says. We sprinkle these in the appropriate location
# in the test file system and they just say who they are pretending to be.
#
@@ -457,7 +486,8 @@
LaunchVM "" "${RELEASE}"
# Going to silently ignore JRE-Version setting in jar file manifest
#LaunchVM "" "warning: The jarfile JRE-Version"
-
+
+ # Verify help does not contain obsolete options
+ TestHelp
exit 0
-
--- a/jdk/test/tools/launcher/PrintVersion.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/tools/launcher/PrintVersion.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -27,12 +27,9 @@
* This stub simply prints out the java version string. It is used
* by MultipleJRE.sh.
*/
-import sun.misc.Version;
public class PrintVersion {
-
- public static void main(String argv[]) {
- Version.print();
- }
-
+ public static void main(String argv[]) {
+ System.out.println(System.getProperty("java.version"));
+ }
}
--- a/jdk/test/tools/launcher/TestHelper.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/tools/launcher/TestHelper.java Wed Jul 05 20:11:52 2017 +0200
@@ -67,10 +67,7 @@
static final String JAVAHOME = System.getProperty("java.home");
static final String JAVA_BIN;
- static final String JAVA_JRE_BIN;
static final String JAVA_LIB;
- static final String JAVA_JRE_LIB;
- static final boolean isSDK = JAVAHOME.endsWith("jre");
static final String javaCmd;
static final String javawCmd;
static final String javacCmd;
@@ -135,17 +132,10 @@
}
compiler = ToolProvider.getSystemJavaCompiler();
- File binDir = (isSDK)
- ? new File((new File(JAVAHOME)).getParentFile(), "bin")
- : new File(JAVAHOME, "bin");
+ File binDir = new File(JAVAHOME, "bin");
JAVA_BIN = binDir.getAbsolutePath();
- JAVA_JRE_BIN = new File(JAVAHOME, "bin").getAbsolutePath();
-
- File libDir = (isSDK)
- ? new File((new File(JAVAHOME)).getParentFile(), "lib")
- : new File(JAVAHOME, "lib");
+ File libDir = new File(JAVAHOME, "lib");
JAVA_LIB = libDir.getAbsolutePath();
- JAVA_JRE_LIB = new File(JAVAHOME, "lib").getAbsolutePath();
File javaCmdFile = (isWindows)
? new File(binDir, "java.exe")
@@ -191,11 +181,11 @@
}
private static boolean haveVmVariant(String type) {
if (isWindows) {
- File vmDir = new File(JAVA_JRE_BIN, type);
+ File vmDir = new File(JAVA_BIN, type);
File jvmFile = new File(vmDir, LIBJVM);
return jvmFile.exists();
} else {
- File vmDir = new File(JAVA_JRE_LIB, type);
+ File vmDir = new File(JAVA_LIB, type);
File vmArchDir = new File(vmDir, getJreArch());
File jvmFile = new File(vmArchDir, LIBJVM);
return jvmFile.exists();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/TooSmallStackSize.java Wed Jul 05 20:11:52 2017 +0200
@@ -0,0 +1,158 @@
+/*
+ * 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 6762191
+ * @summary Setting stack size to 16K causes segmentation fault
+ * @compile TooSmallStackSize.java
+ * @run main TooSmallStackSize
+ */
+
+/*
+ * The primary purpose of this test is to make sure we can run with a 16k stack
+ * size without crashing. Also this test will determine the minimum allowed
+ * stack size for the platform (as provided by the JVM error message when a very
+ * small stack is used), and then verify that the JVM can be launched with that stack
+ * size without a crash or any error messages.
+ */
+
+public class TooSmallStackSize extends TestHelper {
+ /* for debugging. Normally false. */
+ static final boolean verbose = false;
+
+ static void printTestOutput(TestResult tr) {
+ System.out.println("*** exitValue = " + tr.exitValue);
+ for (String x : tr.testOutput) {
+ System.out.println(x);
+ }
+ }
+
+ /*
+ * Returns the minimum stack size this platform will allowed based on the
+ * contents of the error message the JVM outputs when too small of a
+ * -Xss size was used.
+ *
+ * The TestResult argument must contain the result of having already run
+ * the JVM with too small of a stack size.
+ */
+ static String getMinStackAllowed(TestResult tr) {
+ /*
+ * The JVM output will contain in one of the lines:
+ * "The stack size specified is too small, Specify at least 100k"
+ * Although the actual size will vary. We need to extract this size
+ * string from the output and return it.
+ */
+ String matchStr = "Specify at least ";
+ for (String x : tr.testOutput) {
+ int match_idx = x.indexOf(matchStr);
+ if (match_idx >= 0) {
+ int size_start_idx = match_idx + matchStr.length();
+ int k_start_idx = x.indexOf("k", size_start_idx);
+ return x.substring(size_start_idx, k_start_idx + 1); // include the "k"
+ }
+ }
+
+ System.out.println("FAILED: Could not get the stack size from the output");
+ throw new RuntimeException("test fails");
+ }
+
+ /*
+ * Run the JVM with the specified stack size.
+ *
+ * Returns the minimum allowed stack size gleaned from the error message,
+ * if there is an error message. Otherwise returns the stack size passed in.
+ */
+ static String checkStack(String stackSize) {
+ String min_stack_allowed;
+ TestResult tr;
+
+ if (verbose)
+ System.out.println("*** Testing " + stackSize);
+ tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
+ if (verbose)
+ printTestOutput(tr);
+
+ if (tr.isOK()) {
+ System.out.println("PASSED: got no error message with stack size of " + stackSize);
+ min_stack_allowed = stackSize;
+ } else {
+ if (tr.contains("The stack size specified is too small")) {
+ System.out.println("PASSED: got expected error message with stack size of " + stackSize);
+ min_stack_allowed = getMinStackAllowed(tr);
+ } else {
+ // Likely a crash
+ System.out.println("FAILED: Did not get expected error message with stack size of " + stackSize);
+ throw new RuntimeException("test fails");
+ }
+ }
+
+ return min_stack_allowed;
+ }
+
+ /*
+ * Run the JVM with the minimum allowed stack size. This should always succeed.
+ */
+ static void checkMinStackAllowed(String stackSize) {
+ TestResult tr = null;
+
+ if (verbose)
+ System.out.println("*** Testing " + stackSize);
+ tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
+ if (verbose)
+ printTestOutput(tr);
+
+ if (tr.isOK()) {
+ System.out.println("PASSED: VM launched with minimum allowed stack size of " + stackSize);
+ } else {
+ // Likely a crash
+ System.out.println("FAILED: VM failed to launch with minimum allowed stack size of " + stackSize);
+ throw new RuntimeException("test fails");
+ }
+ }
+
+ public static void main(String... args) {
+ /*
+ * The result of a 16k stack size should be a quick exit with a complaint
+ * that the stack size is too small. However, for some win32 builds, the
+ * stack is always at least 64k, and this also sometimes is the minimum
+ * allowed size, so we won't see an error in this case.
+ *
+ * This test case will also produce a crash on some platforms if the fix
+ * for 6762191 is not yet in place.
+ */
+ checkStack("16k");
+
+ /*
+ * Try with a 32k stack size, which is the size that the launcher will
+ * set to if you try setting to anything smaller. This should produce the same
+ * result as setting to 16k if the fix for 6762191 is in place.
+ */
+ String min_stack_allowed = checkStack("32k");
+
+ /*
+ * Try again with a the minimum stack size that was given in the error message
+ */
+ checkMinStackAllowed(min_stack_allowed);
+ }
+}
--- a/jdk/test/tools/launcher/UglyPrintVersion.java Thu Dec 18 19:57:48 2014 -0800
+++ b/jdk/test/tools/launcher/UglyPrintVersion.java Wed Jul 05 20:11:52 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -30,12 +30,8 @@
*/
package reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongpackagename;
-import sun.misc.Version;
-
public class UglyPrintVersion {
-
- public static void main(String argv[]) {
- Version.print();
- }
-
+ public static void main(String argv[]) {
+ System.out.println(System.getProperty("java.version"));
+ }
}
--- a/make/Javadoc.gmk Thu Dec 18 19:57:48 2014 -0800
+++ b/make/Javadoc.gmk Wed Jul 05 20:11:52 2017 +0200
@@ -53,8 +53,7 @@
JAVADOC_CMD = $(JAVA) \
-Djava.awt.headless=true \
- $(NEW_JAVADOC) \
- -bootclasspath $(JDK_OUTPUTDIR)/classes
+ $(NEW_JAVADOC)
# Copyright year for beginning of Java and some of the apis
# (Needed when creating the javadocs)
@@ -231,17 +230,17 @@
# Common echo of option
define OptionOnly # opt
- if [ "$1" != "" ] ; then \
- $(PRINTF) "%s\n" "$1"; \
+ if [ "$(strip $1)" != "" ] ; then \
+ $(PRINTF) "%s\n" "$(strip $1)"; \
fi
endef
define OptionPair # opt arg
- $(PRINTF) "%s '%s'\n" "$1" '$2'
+ $(PRINTF) "%s '%s'\n" "$(strip $1)" '$(strip $2)'
endef
define OptionTrip # opt arg arg
- $(PRINTF) "%s '%s' '%s'\n" "$1" '$2' '$3'
+ $(PRINTF) "%s '%s' '%s'\n" "$(strip $1)" '$(strip $2)' '$(strip $3)'
endef
# Core api bottom argument (with special sauce)
--- a/make/Main.gmk Thu Dec 18 19:57:48 2014 -0800
+++ b/make/Main.gmk Wed Jul 05 20:11:52 2017 +0200
@@ -257,7 +257,7 @@
test:
($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \
- JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_OUTPUTDIR) \
+ JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) \
ALT_OUTPUTDIR=$(OUTPUT_ROOT) CONCURRENCY=$(JOBS) $(TEST)) || true
test-make:
@@ -394,7 +394,7 @@
docs-jvmtidoc: hotspot
- test: exploded-image
+ test: jimages
verify-modules: exploded-image
--- a/make/StripBinaries.gmk Thu Dec 18 19:57:48 2014 -0800
+++ b/make/StripBinaries.gmk Wed Jul 05 20:11:52 2017 +0200
@@ -66,11 +66,6 @@
$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs \
-name '*$(SHARED_LIBRARY_SUFFIX)' -type f)
-# On Windows, don't include debug info for libs either.
-ifeq ($(OPENJDK_TARGET_OS), windows)
- COPY_LIBS_SRC := $(filter-out %.diz %.map %.pdb, $(COPY_LIBS_SRC))
-endif
-
$(eval $(call SetupCopyFiles,STRIP_MODULES_CMDS, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
DEST := $(MODULES_CMDS_STRIPPED), \
--- a/make/jprt.properties Thu Dec 18 19:57:48 2014 -0800
+++ b/make/jprt.properties Wed Jul 05 20:11:52 2017 +0200
@@ -188,6 +188,13 @@
${my.test.target.set:TESTNAME=svc_tools}, \
${my.make.rule.test.targets.svc.extra}
+# JAXP vm test targets (testset=jaxp)
+my.test.targets.jaxp=
+
+# JAXP test targets (testset=jaxp)
+my.make.rule.test.targets.jaxp= \
+ ${my.test.target.set:TESTNAME=jaxp_all}
+
# All vm test targets (testset=all)
my.test.targets.all= \
${my.test.targets.default}, \
@@ -211,7 +218,8 @@
my.make.rule.test.targets.pit= \
${my.test.target.set:TESTNAME=langtools_jtreg}, \
${my.make.rule.test.targets.core}, \
- ${my.make.rule.test.targets.svc}
+ ${my.make.rule.test.targets.svc} \
+ ${my.make.rule.test.targets.jaxp}
# JCK test targets in test/Makefile (no windows)
my.test.target.set.jck= \
--- a/test/Makefile Thu Dec 18 19:57:48 2014 -0800
+++ b/test/Makefile Wed Jul 05 20:11:52 2017 +0200
@@ -33,6 +33,7 @@
# This makefile depends on the availability of sibling directories.
LANGTOOLS_DIR=$(TOPDIR)/langtools
JDK_DIR=$(TOPDIR)/jdk
+JAXP_DIR=$(TOPDIR)/jaxp
HOTSPOT_DIR=$(TOPDIR)/hotspot
# Macro to run a test target in a subdir
@@ -51,10 +52,10 @@
endef
# Default test target (core)
-default: jdk_core langtools_jtreg
+default: jdk_core langtools_jtreg jaxp_all
# All testing
-all: jdk_all langtools_all
+all: jdk_all langtools_all jaxp_all
# Test targets
langtools_% :
@@ -63,6 +64,9 @@
jdk_% core_%s svc_%:
@$(NO_STOPPING)$(call SUBDIR_TEST, $(JDK_DIR), TEST="$@" $@)
+jaxp_%:
+ @$(NO_STOPPING)$(call SUBDIR_TEST, $(JAXP_DIR), TEST="$@" $@)
+
hotspot_%:
@$(NO_STOPPING)$(call SUBDIR_TEST, $(HOTSPOT_DIR), TEST="$@" $@)