From f2b6ac989e1115101809f98ba5b3681b6897b64d Mon Sep 17 00:00:00 2001 From: "Y. Srinivas Ramakrishna" Date: Sun, 16 Mar 2008 21:57:25 -0700 Subject: [PATCH 001/119] 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction The option CMSInitiatingPermOccupancyFraction now controls perm triggering threshold. Even though the actual value of the threshold has not yet been changed, so there is no change in policy, we now have the infrastructure in place for dynamically deciding when to collect the perm gen, an issue that will be addressed in the near future. Reviewed-by: jmasa --- .../concurrentMarkSweepGeneration.cpp | 239 +++++++++++------- .../concurrentMarkSweepGeneration.hpp | 45 ++-- .../concurrentMarkSweepGeneration.inline.hpp | 2 +- hotspot/src/share/vm/runtime/globals.hpp | 21 +- 4 files changed, 198 insertions(+), 109 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index eff7a042e95..42593073c32 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -225,6 +225,34 @@ ConcurrentMarkSweepGeneration::ConcurrentMarkSweepGeneration( assert(_dilatation_factor >= 1.0, "from previous assert"); } + +// The field "_initiating_occupancy" represents the occupancy percentage +// at which we trigger a new collection cycle. Unless explicitly specified +// via CMSInitiating[Perm]OccupancyFraction (argument "io" below), it +// is calculated by: +// +// Let "f" be MinHeapFreeRatio in +// +// _intiating_occupancy = 100-f + +// f * (CMSTrigger[Perm]Ratio/100) +// where CMSTrigger[Perm]Ratio is the argument "tr" below. +// +// That is, if we assume the heap is at its desired maximum occupancy at the +// end of a collection, we let CMSTrigger[Perm]Ratio of the (purported) free +// space be allocated before initiating a new collection cycle. +// +void ConcurrentMarkSweepGeneration::init_initiating_occupancy(intx io, intx tr) { + assert(io <= 100 && tr >= 0 && tr <= 100, "Check the arguments"); + if (io >= 0) { + _initiating_occupancy = (double)io / 100.0; + } else { + _initiating_occupancy = ((100 - MinHeapFreeRatio) + + (double)(tr * MinHeapFreeRatio) / 100.0) + / 100.0; + } +} + + void ConcurrentMarkSweepGeneration::ref_processor_init() { assert(collector() != NULL, "no collector"); collector()->ref_processor_init(); @@ -520,8 +548,8 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen, _verification_mark_bm(0, Mutex::leaf + 1, "CMS_verification_mark_bm_lock"), _completed_initialization(false), _collector_policy(cp), - _unload_classes(false), - _unloaded_classes_last_cycle(false), + _should_unload_classes(false), + _concurrent_cycles_since_last_unload(0), _sweep_estimate(CMS_SweepWeight, CMS_SweepPadding) { if (ExplicitGCInvokesConcurrentAndUnloadsClasses) { @@ -642,26 +670,11 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen, } } - // "initiatingOccupancy" is the occupancy ratio at which we trigger - // a new collection cycle. Unless explicitly specified via - // CMSTriggerRatio, it is calculated by: - // Let "f" be MinHeapFreeRatio in - // - // intiatingOccupancy = 100-f + - // f * (CMSTriggerRatio/100) - // That is, if we assume the heap is at its desired maximum occupancy at the - // end of a collection, we let CMSTriggerRatio of the (purported) free - // space be allocated before initiating a new collection cycle. - if (CMSInitiatingOccupancyFraction > 0) { - _initiatingOccupancy = (double)CMSInitiatingOccupancyFraction / 100.0; - } else { - _initiatingOccupancy = ((100 - MinHeapFreeRatio) + - (double)(CMSTriggerRatio * - MinHeapFreeRatio) / 100.0) - / 100.0; - } + _cmsGen ->init_initiating_occupancy(CMSInitiatingOccupancyFraction, CMSTriggerRatio); + _permGen->init_initiating_occupancy(CMSInitiatingPermOccupancyFraction, CMSTriggerPermRatio); + // Clip CMSBootstrapOccupancy between 0 and 100. - _bootstrap_occupancy = ((double)MIN2((intx)100, MAX2((intx)0, CMSBootstrapOccupancy))) + _bootstrap_occupancy = ((double)MIN2((uintx)100, MAX2((uintx)0, CMSBootstrapOccupancy))) /(double)100; _full_gcs_since_conc_gc = 0; @@ -1413,7 +1426,8 @@ bool CMSCollector::shouldConcurrentCollect() { gclog_or_tty->print_cr("promotion_rate=%g", stats().promotion_rate()); gclog_or_tty->print_cr("cms_allocation_rate=%g", stats().cms_allocation_rate()); gclog_or_tty->print_cr("occupancy=%3.7f", _cmsGen->occupancy()); - gclog_or_tty->print_cr("initiatingOccupancy=%3.7f", initiatingOccupancy()); + gclog_or_tty->print_cr("initiatingOccupancy=%3.7f", _cmsGen->initiating_occupancy()); + gclog_or_tty->print_cr("initiatingPermOccupancy=%3.7f", _permGen->initiating_occupancy()); } // ------------------------------------------------------------------ @@ -1446,22 +1460,36 @@ bool CMSCollector::shouldConcurrentCollect() { // old gen want a collection cycle started. Each may use // an appropriate criterion for making this decision. // XXX We need to make sure that the gen expansion - // criterion dovetails well with this. - if (_cmsGen->shouldConcurrentCollect(initiatingOccupancy())) { + // criterion dovetails well with this. XXX NEED TO FIX THIS + if (_cmsGen->should_concurrent_collect()) { if (Verbose && PrintGCDetails) { gclog_or_tty->print_cr("CMS old gen initiated"); } return true; } - if (cms_should_unload_classes() && - _permGen->shouldConcurrentCollect(initiatingOccupancy())) { - if (Verbose && PrintGCDetails) { - gclog_or_tty->print_cr("CMS perm gen initiated"); + // We start a collection if we believe an incremental collection may fail; + // this is not likely to be productive in practice because it's probably too + // late anyway. + GenCollectedHeap* gch = GenCollectedHeap::heap(); + assert(gch->collector_policy()->is_two_generation_policy(), + "You may want to check the correctness of the following"); + if (gch->incremental_collection_will_fail()) { + if (PrintGCDetails && Verbose) { + gclog_or_tty->print("CMSCollector: collect because incremental collection will fail "); } return true; } + if (CMSClassUnloadingEnabled && _permGen->should_concurrent_collect()) { + bool res = update_should_unload_classes(); + if (res) { + if (Verbose && PrintGCDetails) { + gclog_or_tty->print_cr("CMS perm gen initiated"); + } + return true; + } + } return false; } @@ -1471,32 +1499,36 @@ void CMSCollector::clear_expansion_cause() { _permGen->clear_expansion_cause(); } -bool ConcurrentMarkSweepGeneration::shouldConcurrentCollect( - double initiatingOccupancy) { - // We should be conservative in starting a collection cycle. To - // start too eagerly runs the risk of collecting too often in the - // extreme. To collect too rarely falls back on full collections, - // which works, even if not optimum in terms of concurrent work. - // As a work around for too eagerly collecting, use the flag - // UseCMSInitiatingOccupancyOnly. This also has the advantage of - // giving the user an easily understandable way of controlling the - // collections. - // We want to start a new collection cycle if any of the following - // conditions hold: - // . our current occupancy exceeds the initiating occupancy, or - // . we recently needed to expand and have not since that expansion, - // collected, or - // . we are not using adaptive free lists and linear allocation is - // going to fail, or - // . (for old gen) incremental collection has already failed or - // may soon fail in the near future as we may not be able to absorb - // promotions. - assert_lock_strong(freelistLock()); +// We should be conservative in starting a collection cycle. To +// start too eagerly runs the risk of collecting too often in the +// extreme. To collect too rarely falls back on full collections, +// which works, even if not optimum in terms of concurrent work. +// As a work around for too eagerly collecting, use the flag +// UseCMSInitiatingOccupancyOnly. This also has the advantage of +// giving the user an easily understandable way of controlling the +// collections. +// We want to start a new collection cycle if any of the following +// conditions hold: +// . our current occupancy exceeds the configured initiating occupancy +// for this generation, or +// . we recently needed to expand this space and have not, since that +// expansion, done a collection of this generation, or +// . the underlying space believes that it may be a good idea to initiate +// a concurrent collection (this may be based on criteria such as the +// following: the space uses linear allocation and linear allocation is +// going to fail, or there is believed to be excessive fragmentation in +// the generation, etc... or ... +// [.(currently done by CMSCollector::shouldConcurrentCollect() only for +// the case of the old generation, not the perm generation; see CR 6543076): +// we may be approaching a point at which allocation requests may fail because +// we will be out of sufficient free space given allocation rate estimates.] +bool ConcurrentMarkSweepGeneration::should_concurrent_collect() const { - if (occupancy() > initiatingOccupancy) { + assert_lock_strong(freelistLock()); + if (occupancy() > initiating_occupancy()) { if (PrintGCDetails && Verbose) { gclog_or_tty->print(" %s: collect because of occupancy %f / %f ", - short_name(), occupancy(), initiatingOccupancy); + short_name(), occupancy(), initiating_occupancy()); } return true; } @@ -1510,20 +1542,9 @@ bool ConcurrentMarkSweepGeneration::shouldConcurrentCollect( } return true; } - GenCollectedHeap* gch = GenCollectedHeap::heap(); - assert(gch->collector_policy()->is_two_generation_policy(), - "You may want to check the correctness of the following"); - if (gch->incremental_collection_will_fail()) { + if (_cmsSpace->should_concurrent_collect()) { if (PrintGCDetails && Verbose) { - gclog_or_tty->print(" %s: collect because incremental collection will fail ", - short_name()); - } - return true; - } - if (!_cmsSpace->adaptive_freelists() && - _cmsSpace->linearAllocationWouldFail()) { - if (PrintGCDetails && Verbose) { - gclog_or_tty->print(" %s: collect because of linAB ", + gclog_or_tty->print(" %s: collect because cmsSpace says so ", short_name()); } return true; @@ -1970,8 +1991,9 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) { "Should have been NULL'd before baton was passed"); reset(false /* == !asynch */); _cmsGen->reset_after_compaction(); + _concurrent_cycles_since_last_unload = 0; - if (verifying() && !cms_should_unload_classes()) { + if (verifying() && !should_unload_classes()) { perm_gen_verify_bit_map()->clear_all(); } @@ -2098,6 +2120,7 @@ void CMSCollector::collect_in_background(bool clear_all_soft_refs) { { bool safepoint_check = Mutex::_no_safepoint_check_flag; MutexLockerEx hl(Heap_lock, safepoint_check); + FreelistLocker fll(this); MutexLockerEx x(CGC_lock, safepoint_check); if (_foregroundGCIsActive || !UseAsyncConcMarkSweepGC) { // The foreground collector is active or we're @@ -2112,13 +2135,9 @@ void CMSCollector::collect_in_background(bool clear_all_soft_refs) { // a new cycle. clear_expansion_cause(); } - _unloaded_classes_last_cycle = cms_should_unload_classes(); // ... from last cycle - // This controls class unloading in response to an explicit gc request. - // If ExplicitGCInvokesConcurrentAndUnloadsClasses is set, then - // we will unload classes even if CMSClassUnloadingEnabled is not set. - // See CR 6541037 and related CRs. - _unload_classes = _full_gc_requested // ... for this cycle - && ExplicitGCInvokesConcurrentAndUnloadsClasses; + // Decide if we want to enable class unloading as part of the + // ensuing concurrent GC cycle. + update_should_unload_classes(); _full_gc_requested = false; // acks all outstanding full gc requests // Signal that we are about to start a collection gch->increment_total_full_collections(); // ... starting a collection cycle @@ -3047,21 +3066,62 @@ void CMSCollector::verify_overflow_empty() const { } #endif // PRODUCT +// Decide if we want to enable class unloading as part of the +// ensuing concurrent GC cycle. We will collect the perm gen and +// unload classes if it's the case that: +// (1) an explicit gc request has been made and the flag +// ExplicitGCInvokesConcurrentAndUnloadsClasses is set, OR +// (2) (a) class unloading is enabled at the command line, and +// (b) (i) perm gen threshold has been crossed, or +// (ii) old gen is getting really full, or +// (iii) the previous N CMS collections did not collect the +// perm gen +// NOTE: Provided there is no change in the state of the heap between +// calls to this method, it should have idempotent results. Moreover, +// its results should be monotonically increasing (i.e. going from 0 to 1, +// but not 1 to 0) between successive calls between which the heap was +// not collected. For the implementation below, it must thus rely on +// the property that concurrent_cycles_since_last_unload() +// will not decrease unless a collection cycle happened and that +// _permGen->should_concurrent_collect() and _cmsGen->is_too_full() are +// themselves also monotonic in that sense. See check_monotonicity() +// below. +bool CMSCollector::update_should_unload_classes() { + _should_unload_classes = false; + // Condition 1 above + if (_full_gc_requested && ExplicitGCInvokesConcurrentAndUnloadsClasses) { + _should_unload_classes = true; + } else if (CMSClassUnloadingEnabled) { // Condition 2.a above + // Disjuncts 2.b.(i,ii,iii) above + _should_unload_classes = (concurrent_cycles_since_last_unload() >= + CMSClassUnloadingMaxInterval) + || _permGen->should_concurrent_collect() + || _cmsGen->is_too_full(); + } + return _should_unload_classes; +} + +bool ConcurrentMarkSweepGeneration::is_too_full() const { + bool res = should_concurrent_collect(); + res = res && (occupancy() > (double)CMSIsTooFullPercentage/100.0); + return res; +} + void CMSCollector::setup_cms_unloading_and_verification_state() { const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC || VerifyBeforeExit; const int rso = SharedHeap::SO_Symbols | SharedHeap::SO_Strings | SharedHeap::SO_CodeCache; - if (cms_should_unload_classes()) { // Should unload classes this cycle + if (should_unload_classes()) { // Should unload classes this cycle remove_root_scanning_option(rso); // Shrink the root set appropriately set_verifying(should_verify); // Set verification state for this cycle return; // Nothing else needs to be done at this time } // Not unloading classes this cycle - assert(!cms_should_unload_classes(), "Inconsitency!"); - if ((!verifying() || cms_unloaded_classes_last_cycle()) && should_verify) { + assert(!should_unload_classes(), "Inconsitency!"); + if ((!verifying() || unloaded_classes_last_cycle()) && should_verify) { // We were not verifying, or we _were_ unloading classes in the last cycle, // AND some verification options are enabled this cycle; in this case, // we must make sure that the deadness map is allocated if not already so, @@ -4693,7 +4753,7 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch, GenCollectedHeap* gch = GenCollectedHeap::heap(); - if (cms_should_unload_classes()) { + if (should_unload_classes()) { CodeCache::gc_prologue(); } assert(haveFreelistLocks(), "must have free list locks"); @@ -4753,7 +4813,7 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch, verify_work_stacks_empty(); verify_overflow_empty(); - if (cms_should_unload_classes()) { + if (should_unload_classes()) { CodeCache::gc_epilogue(); } @@ -5623,7 +5683,7 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) { verify_work_stacks_empty(); } - if (cms_should_unload_classes()) { + if (should_unload_classes()) { { TraceTime t("class unloading", PrintGCDetails, false, gclog_or_tty); @@ -5726,7 +5786,7 @@ void CMSCollector::sweep(bool asynch) { // this cycle, we preserve the perm gen object "deadness" information // in the perm_gen_verify_bit_map. In order to do that we traverse // all blocks in perm gen and mark all dead objects. - if (verifying() && !cms_should_unload_classes()) { + if (verifying() && !should_unload_classes()) { assert(perm_gen_verify_bit_map()->sizeInBits() != 0, "Should have already been allocated"); MarkDeadObjectsClosure mdo(this, _permGen->cmsSpace(), @@ -5753,7 +5813,7 @@ void CMSCollector::sweep(bool asynch) { } // Now repeat for perm gen - if (cms_should_unload_classes()) { + if (should_unload_classes()) { CMSTokenSyncWithLocks ts(true, _permGen->freelistLock(), bitMapLock()); sweepWork(_permGen, asynch); @@ -5775,7 +5835,7 @@ void CMSCollector::sweep(bool asynch) { // already have needed locks sweepWork(_cmsGen, asynch); - if (cms_should_unload_classes()) { + if (should_unload_classes()) { sweepWork(_permGen, asynch); } // Update heap occupancy information which is used as @@ -5937,6 +5997,11 @@ void CMSCollector::sweepWork(ConcurrentMarkSweepGeneration* gen, } gen->cmsSpace()->sweep_completed(); gen->cmsSpace()->endSweepFLCensus(sweepCount()); + if (should_unload_classes()) { // unloaded classes this cycle, + _concurrent_cycles_since_last_unload = 0; // ... reset count + } else { // did not unload classes, + _concurrent_cycles_since_last_unload++; // ... increment count + } } // Reset CMS data structures (for now just the marking bit map) @@ -7194,7 +7259,7 @@ PushOrMarkClosure::PushOrMarkClosure(CMSCollector* collector, _revisitStack(revisitStack), _finger(finger), _parent(parent), - _should_remember_klasses(collector->cms_should_unload_classes()) + _should_remember_klasses(collector->should_unload_classes()) { } Par_PushOrMarkClosure::Par_PushOrMarkClosure(CMSCollector* collector, @@ -7217,7 +7282,7 @@ Par_PushOrMarkClosure::Par_PushOrMarkClosure(CMSCollector* collector, _finger(finger), _global_finger_addr(global_finger_addr), _parent(parent), - _should_remember_klasses(collector->cms_should_unload_classes()) + _should_remember_klasses(collector->should_unload_classes()) { } @@ -7360,7 +7425,7 @@ PushAndMarkClosure::PushAndMarkClosure(CMSCollector* collector, _mark_stack(mark_stack), _revisit_stack(revisit_stack), _concurrent_precleaning(concurrent_precleaning), - _should_remember_klasses(collector->cms_should_unload_classes()) + _should_remember_klasses(collector->should_unload_classes()) { assert(_ref_processor != NULL, "_ref_processor shouldn't be NULL"); } @@ -7422,7 +7487,7 @@ Par_PushAndMarkClosure::Par_PushAndMarkClosure(CMSCollector* collector, _bit_map(bit_map), _work_queue(work_queue), _revisit_stack(revisit_stack), - _should_remember_klasses(collector->cms_should_unload_classes()) + _should_remember_klasses(collector->should_unload_classes()) { assert(_ref_processor != NULL, "_ref_processor shouldn't be NULL"); } @@ -7944,7 +8009,7 @@ size_t SweepClosure::doLiveChunk(FreeChunk* fc) { #ifdef DEBUG if (oop(addr)->klass() != NULL && - ( !_collector->cms_should_unload_classes() + ( !_collector->should_unload_classes() || oop(addr)->is_parsable())) { // Ignore mark word because we are running concurrent with mutators assert(oop(addr)->is_oop(true), "live block should be an oop"); @@ -7957,7 +8022,7 @@ size_t SweepClosure::doLiveChunk(FreeChunk* fc) { } else { // This should be an initialized object that's alive. assert(oop(addr)->klass() != NULL && - (!_collector->cms_should_unload_classes() + (!_collector->should_unload_classes() || oop(addr)->is_parsable()), "Should be an initialized object"); // Ignore mark word because we are running concurrent with mutators diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp index f4f790ebab1..9f05caf7214 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @@ -535,13 +535,16 @@ class CMSCollector: public CHeapObj { // In support of ExplicitGCInvokesConcurrent static bool _full_gc_requested; unsigned int _collection_count_start; + // Should we unload classes this concurrent cycle? - // Set in response to a concurrent full gc request. - bool _unload_classes; - bool _unloaded_classes_last_cycle; + bool _should_unload_classes; + unsigned int _concurrent_cycles_since_last_unload; + unsigned int concurrent_cycles_since_last_unload() const { + return _concurrent_cycles_since_last_unload; + } // Did we (allow) unload classes in the previous concurrent cycle? - bool cms_unloaded_classes_last_cycle() const { - return _unloaded_classes_last_cycle || CMSClassUnloadingEnabled; + bool unloaded_classes_last_cycle() const { + return concurrent_cycles_since_last_unload() == 0; } // Verification support @@ -651,8 +654,6 @@ class CMSCollector: public CHeapObj { // number of full gc's since the last concurrent gc. uint _full_gcs_since_conc_gc; - // if occupancy exceeds this, start a new gc cycle - double _initiatingOccupancy; // occupancy used for bootstrapping stats double _bootstrap_occupancy; @@ -825,7 +826,6 @@ class CMSCollector: public CHeapObj { Mutex* bitMapLock() const { return _markBitMap.lock(); } static CollectorState abstract_state() { return _collectorState; } - double initiatingOccupancy() const { return _initiatingOccupancy; } bool should_abort_preclean() const; // Whether preclean should be aborted. size_t get_eden_used() const; @@ -849,11 +849,10 @@ class CMSCollector: public CHeapObj { // In support of ExplicitGCInvokesConcurrent static void request_full_gc(unsigned int full_gc_count); // Should we unload classes in a particular concurrent cycle? - bool cms_should_unload_classes() const { - assert(!_unload_classes || ExplicitGCInvokesConcurrentAndUnloadsClasses, - "Inconsistency; see CR 6541037"); - return _unload_classes || CMSClassUnloadingEnabled; + bool should_unload_classes() const { + return _should_unload_classes; } + bool update_should_unload_classes(); void direct_allocated(HeapWord* start, size_t size); @@ -1022,6 +1021,10 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { _incremental_collection_failed = false; } + // accessors + void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;} + CMSExpansionCause::Cause expansion_cause() const { return _expansion_cause; } + private: // For parallel young-gen GC support. CMSParGCThreadState** _par_gc_thread_states; @@ -1029,10 +1032,6 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { // Reason generation was expanded CMSExpansionCause::Cause _expansion_cause; - // accessors - void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;} - CMSExpansionCause::Cause expansion_cause() { return _expansion_cause; } - // In support of MinChunkSize being larger than min object size const double _dilatation_factor; @@ -1045,6 +1044,10 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { CollectionTypes _debug_collection_type; + // Fraction of current occupancy at which to start a CMS collection which + // will collect this generation (at least). + double _initiating_occupancy; + protected: // Grow generation by specified size (returns false if unable to grow) bool grow_by(size_t bytes); @@ -1060,6 +1063,10 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { // space. size_t max_available() const; + // getter and initializer for _initiating_occupancy field. + double initiating_occupancy() const { return _initiating_occupancy; } + void init_initiating_occupancy(intx io, intx tr); + public: ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size, int level, CardTableRS* ct, @@ -1103,7 +1110,7 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { size_t capacity() const; size_t used() const; size_t free() const; - double occupancy() { return ((double)used())/((double)capacity()); } + double occupancy() const { return ((double)used())/((double)capacity()); } size_t contiguous_available() const; size_t unsafe_max_alloc_nogc() const; @@ -1158,8 +1165,8 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { bool younger_handles_promotion_failure) const; bool should_collect(bool full, size_t size, bool tlab); - // XXXPERM - bool shouldConcurrentCollect(double initiatingOccupancy); // XXXPERM + virtual bool should_concurrent_collect() const; + virtual bool is_too_full() const; void collect(bool full, bool clear_all_soft_refs, size_t size, diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp index c151fab332a..8dd2ca4abe4 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp @@ -267,7 +267,7 @@ inline bool CMSCollector::is_dead_obj(oop obj) const { (_permGen->cmsSpace()->is_in_reserved(addr) && _permGen->cmsSpace()->block_is_obj(addr)), "must be object"); - return cms_should_unload_classes() && + return should_unload_classes() && _collectorState == Sweeping && !_markBitMap.isMarked(addr); } diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 67cb3285da5..3b09dc5e75d 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1319,6 +1319,10 @@ class CommandLineFlags { product(bool, CMSClassUnloadingEnabled, false, \ "Whether class unloading enabled when using CMS GC") \ \ + product(uintx, CMSClassUnloadingMaxInterval, 0, \ + "When CMS class unloading is enabled, the maximum CMS cycle count"\ + " for which classes may not be unloaded") \ + \ product(bool, CMSCompactWhenClearAllSoftRefs, true, \ "Compact when asked to collect CMS gen with clear_all_soft_refs") \ \ @@ -1504,17 +1508,30 @@ class CommandLineFlags { "Percentage of MinHeapFreeRatio in CMS generation that is " \ " allocated before a CMS collection cycle commences") \ \ - product(intx, CMSBootstrapOccupancy, 50, \ + product(intx, CMSTriggerPermRatio, 80, \ + "Percentage of MinHeapFreeRatio in the CMS perm generation that" \ + " is allocated before a CMS collection cycle commences, that " \ + " also collects the perm generation") \ + \ + product(uintx, CMSBootstrapOccupancy, 50, \ "Percentage CMS generation occupancy at which to " \ " initiate CMS collection for bootstrapping collection stats") \ \ product(intx, CMSInitiatingOccupancyFraction, -1, \ "Percentage CMS generation occupancy to start a CMS collection " \ - " cycle (A negative value means that CMSTirggerRatio is used)") \ + " cycle (A negative value means that CMSTriggerRatio is used)") \ + \ + product(intx, CMSInitiatingPermOccupancyFraction, -1, \ + "Percentage CMS perm generation occupancy to start a CMScollection"\ + " cycle (A negative value means that CMSTriggerPermRatio is used)")\ \ product(bool, UseCMSInitiatingOccupancyOnly, false, \ "Only use occupancy as a crierion for starting a CMS collection") \ \ + product(intx, CMSIsTooFullPercentage, 98, \ + "An absolute ceiling above which CMS will always consider the" \ + " perm gen ripe for collection") \ + \ develop(bool, CMSTestInFreeList, false, \ "Check if the coalesced range is already in the " \ "free lists as claimed.") \ From 1f1d82e2aaf3960f1ddcd601d86cf85258c6d05a Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Mon, 24 Mar 2008 15:51:26 +0300 Subject: [PATCH 002/119] 6637607: 1st char. is discarded after a modal dialogue shows up and disappears Reset consuming next KEY_TYPED on every subsequent KEY_PRESS. Reviewed-by: son --- .../java/awt/DefaultKeyboardFocusManager.java | 3 + .../native/sun/windows/awt_Component.cpp | 4 + .../ConsumeNextKeyTypedOnModalShowTest.java | 110 ++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 jdk/test/java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java diff --git a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java index 1874d8bb3e3..9e2c6e5620d 100644 --- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java +++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java @@ -1078,6 +1078,9 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { focusNextComponent(focusedComponent); } return; + } else if (e.getID() == KeyEvent.KEY_PRESSED) { + // Fix for 6637607: consumeNextKeyTyped should be reset. + consumeNextKeyTyped = false; } toTest = focusedComponent.getFocusTraversalKeys( diff --git a/jdk/src/windows/native/sun/windows/awt_Component.cpp b/jdk/src/windows/native/sun/windows/awt_Component.cpp index f5823786110..f2f59b859cc 100644 --- a/jdk/src/windows/native/sun/windows/awt_Component.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp @@ -5740,6 +5740,10 @@ void AwtComponent::_NativeHandleEvent(void *param) env->DeleteGlobalRef(event); delete nhes; return; + + } else if (id == java_awt_event_KeyEvent_KEY_PRESSED) { + // Fix for 6637607: reset consuming + keyDownConsumed = FALSE; } /* Consume a KEY_TYPED event if a KEY_PRESSED had been, to support diff --git a/jdk/test/java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java b/jdk/test/java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java new file mode 100644 index 00000000000..801dc2e6e17 --- /dev/null +++ b/jdk/test/java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java @@ -0,0 +1,110 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test %W% %E% + @bug 6637607 + @summary Showing a modal dlg on TAB KEY_PRESS shouldn't consume inappropriate KEY_TYPED. + @author Anton Tarasov: area=awt-focus + @library ../../regtesthelpers + @build Util + @run main ConsumeNextKeyTypedOnModalShowTest +*/ + +import java.awt.*; +import java.awt.event.*; +import java.applet.Applet; +import java.util.concurrent.atomic.AtomicBoolean; +import java.lang.reflect.InvocationTargetException; +import test.java.awt.regtesthelpers.Util; + +public class ConsumeNextKeyTypedOnModalShowTest extends Applet { + Robot robot; + Frame frame = new Frame("Frame"); + Dialog dialog = new Dialog(frame, "Dialog", true); + TextField tf0 = new TextField(); + TextField tf1 = new TextField(); + Button button = new Button("Button"); + + public static void main(String[] args) { + ConsumeNextKeyTypedOnModalShowTest app = new ConsumeNextKeyTypedOnModalShowTest(); + app.init(); + app.start(); + } + + public void init() { + robot = Util.createRobot(); + + tf0.setPreferredSize(new Dimension(50, 30)); + tf1.setPreferredSize(new Dimension(50, 30)); + frame.setLayout(new FlowLayout()); + frame.add(tf0); + frame.add(tf1); + frame.pack(); + + dialog.add(button); + dialog.pack(); + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + if (e.getID() == KeyEvent.KEY_PRESSED && e.getSource() == tf0) { + dialog.setVisible(true); + } + } + }, KeyEvent.KEY_EVENT_MASK); + } + + public void start() { + frame.setVisible(true); + Util.waitTillShown(frame); + + // Show the dialog. + robot.keyPress(KeyEvent.VK_TAB); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_TAB); + + Util.waitForIdle(robot); + + // Dispose the dialog. + Runnable action = new Runnable() { + public void run() { + dialog.dispose(); + } + }; + if (!Util.trackFocusGained(tf1, action, 2000, false)) { + throw new RuntimeException("Test failed: TAB was processed incorrectly!"); + } + + // Check for type-ability. + robot.keyPress(KeyEvent.VK_A); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_A); + + Util.waitForIdle(robot); + + if (tf1.getText().equals("")) { + throw new RuntimeException("Test failed: couldn't type a char!"); + } + System.out.println("Test passed."); + } +} From 87e915d1afc52fc4204713c842e7af3ae84dc3c7 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Mon, 24 Mar 2008 18:24:15 +0300 Subject: [PATCH 003/119] 6638872: invalid links Removed invalid links Reviewed-by: dcherepanov --- jdk/src/share/classes/java/awt/event/TextEvent.java | 3 +-- jdk/src/share/classes/java/awt/event/TextListener.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/java/awt/event/TextEvent.java b/jdk/src/share/classes/java/awt/event/TextEvent.java index a8636dc0d78..0c7aadca177 100644 --- a/jdk/src/share/classes/java/awt/event/TextEvent.java +++ b/jdk/src/share/classes/java/awt/event/TextEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,6 @@ import java.awt.AWTEvent; * * @see java.awt.TextComponent * @see TextListener - * @see Tutorial: Writing a Text Listener * * @since 1.1 */ diff --git a/jdk/src/share/classes/java/awt/event/TextListener.java b/jdk/src/share/classes/java/awt/event/TextListener.java index cbb615a4606..99e52c2e4e1 100644 --- a/jdk/src/share/classes/java/awt/event/TextListener.java +++ b/jdk/src/share/classes/java/awt/event/TextListener.java @@ -1,5 +1,5 @@ /* - * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,6 @@ import java.util.EventListener; * @author Georges Saab * * @see TextEvent - * @see Tutorial: Writing a Text Listener * * @since 1.1 */ From 88699393d78a786ac5b64c104075a9cafb5eff24 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Tue, 25 Mar 2008 15:16:03 +0300 Subject: [PATCH 004/119] 6610244: modal dialog closes with fatal error if -Xcheck:jni is set Obtain WWindowPeer class every time it is required Reviewed-by: art --- .../windows/native/sun/windows/awt_Dialog.cpp | 10 ++- .../windows/native/sun/windows/awt_Window.cpp | 10 +-- .../windows/native/sun/windows/awt_Window.h | 7 +- .../Dialog/CrashXCheckJni/CrashXCheckJni.java | 64 +++++++++++++++++++ 4 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 jdk/test/java/awt/Dialog/CrashXCheckJni/CrashXCheckJni.java diff --git a/jdk/src/windows/native/sun/windows/awt_Dialog.cpp b/jdk/src/windows/native/sun/windows/awt_Dialog.cpp index 0c98fc0d9fe..948fc0883ed 100644 --- a/jdk/src/windows/native/sun/windows/awt_Dialog.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Dialog.cpp @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -428,8 +428,12 @@ void AwtDialog::ModalActivateNextWindow(HWND dialogHWnd, { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); - jlongArray windows = (jlongArray)(env->CallStaticObjectMethod(AwtWindow::wwindowPeerCls, - AwtWindow::getActiveWindowsMID)); + jclass wwindowPeerCls = env->FindClass("sun/awt/windows/WWindowPeer"); + jmethodID getActiveWindowsMID = env->GetStaticMethodID(wwindowPeerCls, + "getActiveWindowHandles", "()[J"); + DASSERT(getActiveWindowsMID != NULL); + jlongArray windows = (jlongArray)(env->CallStaticObjectMethod(wwindowPeerCls, + getActiveWindowsMID)); if (windows == NULL) { return; } diff --git a/jdk/src/windows/native/sun/windows/awt_Window.cpp b/jdk/src/windows/native/sun/windows/awt_Window.cpp index 7e2f31fb139..2d94c779309 100644 --- a/jdk/src/windows/native/sun/windows/awt_Window.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,9 +122,6 @@ jfieldID AwtWindow::warningStringID; jfieldID AwtWindow::locationByPlatformID; jfieldID AwtWindow::autoRequestFocusID; -jclass AwtWindow::wwindowPeerCls; -jmethodID AwtWindow::getActiveWindowsMID; - jfieldID AwtWindow::sysXID; jfieldID AwtWindow::sysYID; jfieldID AwtWindow::sysWID; @@ -2159,11 +2156,6 @@ Java_sun_awt_windows_WWindowPeer_initIDs(JNIEnv *env, jclass cls) { TRY; - AwtWindow::wwindowPeerCls = cls; - AwtWindow::getActiveWindowsMID = - env->GetStaticMethodID(cls, "getActiveWindowHandles", "()[J"); - DASSERT(AwtWindow::getActiveWindowsMID != NULL); - AwtWindow::sysXID = env->GetFieldID(cls, "sysX", "I"); AwtWindow::sysYID = env->GetFieldID(cls, "sysY", "I"); AwtWindow::sysWID = env->GetFieldID(cls, "sysW", "I"); diff --git a/jdk/src/windows/native/sun/windows/awt_Window.h b/jdk/src/windows/native/sun/windows/awt_Window.h index 8e654a2d813..bc706d97aeb 100644 --- a/jdk/src/windows/native/sun/windows/awt_Window.h +++ b/jdk/src/windows/native/sun/windows/awt_Window.h @@ -1,5 +1,5 @@ /* - * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,11 +57,6 @@ public: static jfieldID screenID; /* screen number passed over from WindowPeer */ static jfieldID autoRequestFocusID; - /* WWindowPeer class */ - static jclass wwindowPeerCls; - /* long[] getActiveWindowHandles() method in WWindowPeer */ - static jmethodID getActiveWindowsMID; - // The coordinates at the peer. static jfieldID sysXID; static jfieldID sysYID; diff --git a/jdk/test/java/awt/Dialog/CrashXCheckJni/CrashXCheckJni.java b/jdk/test/java/awt/Dialog/CrashXCheckJni/CrashXCheckJni.java new file mode 100644 index 00000000000..377fae51c78 --- /dev/null +++ b/jdk/test/java/awt/Dialog/CrashXCheckJni/CrashXCheckJni.java @@ -0,0 +1,64 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6610244 + @library ../../regtesthelpers + @build Util Sysout AbstractTest + @summary modal dialog closes with fatal error if -Xcheck:jni is set + @author Andrei Dmitriev : area=awt.dialog + @run main/othervm -Xcheck:jni CrashXCheckJni +*/ + +import java.awt.*; +import java.awt.event.*; +import java.util.Timer; +import java.util.TimerTask; +import test.java.awt.regtesthelpers.Util; +import test.java.awt.regtesthelpers.AbstractTest; +import test.java.awt.regtesthelpers.Sysout; + +public class CrashXCheckJni { + + public static void main(String []s) + { + final Dialog fd = new Dialog(new Frame(), true); + Timer t = new Timer(); + t.schedule(new TimerTask() { + + public void run() { + System.out.println("RUNNING TASK"); + fd.setVisible(false); + fd.dispose(); + System.out.println("FINISHING TASK"); + } + }, 3000L); + + fd.setVisible(true); + t.cancel(); + Util.waitForIdle(null); + + AbstractTest.pass(); + } +} From f555fe0a5754beba24f7e5b9a6f2724e5270b436 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Tue, 25 Mar 2008 16:23:09 +0300 Subject: [PATCH 005/119] 6255653: REGRESSION: Override isLightweight() causes access violation in awt.dll Verufy that the component to restack is a HW component by checking for instanceof WComponentPeer Reviewed-by: son, anthony --- .../classes/sun/awt/windows/WPanelPeer.java | 14 +- .../IsLightweightCrash.java | 59 ++++++ .../isLightweightCrash/StubPeerCrash.java | 188 ++++++++++++++++++ 3 files changed, 259 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/awt/Component/isLightweightCrash/IsLightweightCrash.java create mode 100644 jdk/test/java/awt/Component/isLightweightCrash/StubPeerCrash.java diff --git a/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java b/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java index 04b07ca082b..ea060b24c28 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java @@ -30,9 +30,11 @@ import java.awt.peer.*; import java.util.Vector; import sun.awt.SunGraphicsCallback; +import java.util.logging.*; class WPanelPeer extends WCanvasPeer implements PanelPeer { + private static final Logger log = Logger.getLogger("sun.awt.windows.WPanelPeer"); // ComponentPeer overrides public void paint(Graphics g) { @@ -131,8 +133,16 @@ class WPanelPeer extends WCanvasPeer implements PanelPeer { for (int i = 0; i < cont.getComponentCount(); i++) { Component comp = cont.getComponent(i); if (!comp.isLightweight()) { - if (comp.getPeer() != null) { - peers.add(comp.getPeer()); + ComponentPeer peer = comp.getPeer(); + if (peer != null && (peer instanceof WComponentPeer)) + { + peers.add(peer); + } else { + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, + "peer of a {0} is null or not a WComponentPeer: {1}.", + new Object[]{comp, peer}); + } } } if (comp.isLightweight() && comp instanceof Container) { diff --git a/jdk/test/java/awt/Component/isLightweightCrash/IsLightweightCrash.java b/jdk/test/java/awt/Component/isLightweightCrash/IsLightweightCrash.java new file mode 100644 index 00000000000..37674dbdcf8 --- /dev/null +++ b/jdk/test/java/awt/Component/isLightweightCrash/IsLightweightCrash.java @@ -0,0 +1,59 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6255653 + @summary REGRESSION: Override isLightweight() causes access violation in awt.dll + @author Andrei Dmitriev: area=awt-component + @run main IsLightweightCrash +*/ + +/* + * The test may not crash for several times so iteratively continue up to some limit. + */ + +import java.awt.*; + +public class IsLightweightCrash { + public static int ITERATIONS = 20; + + public static void main(String []s) + { + for (int i = 0; i < ITERATIONS; i++){ + showFrame(i); + } + } + + private static void showFrame(int i){ + System.out.println("iteration = "+i); + Frame f = new Frame(); + f.add(new AHeavyweightComponent()); + f.setVisible(true); + f.setVisible(false); + } +} + +class AHeavyweightComponent extends Component { + public boolean isLightweight() { return false; } +} diff --git a/jdk/test/java/awt/Component/isLightweightCrash/StubPeerCrash.java b/jdk/test/java/awt/Component/isLightweightCrash/StubPeerCrash.java new file mode 100644 index 00000000000..ccdac15f8a6 --- /dev/null +++ b/jdk/test/java/awt/Component/isLightweightCrash/StubPeerCrash.java @@ -0,0 +1,188 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6255653 + @summary REGRESSION: Override isLightweight() causes access violation in awt.dll + @author Andrei Dmitriev: area=awt-component + @run main StubPeerCrash +*/ + +/* + * The test may not crash for several times so iteratively continue up to some limit. + */ + +import java.awt.*; +import java.awt.peer.*; +import java.awt.event.PaintEvent; +import java.awt.image.ImageProducer; +import java.awt.image.ImageObserver; +import java.awt.image.ColorModel; +import java.awt.image.VolatileImage; +import java.awt.GraphicsConfiguration; +import sun.awt.CausedFocusEvent; +import sun.java2d.pipe.Region; + +public class StubPeerCrash { + public static int ITERATIONS = 20; + + public static void main(String []s) + { + for (int i = 0; i < ITERATIONS; i++){ + showFrame(i); + } + } + + private static void showFrame(int i){ + System.out.println("iteration = "+i); + Frame f = new Frame(); + f.add(new AHeavyweightComponent()); + f.setVisible(true); + f.setVisible(false); + } +} + +class AHeavyweightComponent extends Component { + private ComponentPeer peer = new StubComponentPeer(); + + public AHeavyweightComponent(){ + } + + public boolean isLightweight() { + return false; + } + + public ComponentPeer getPeer(){ + return peer; + } +} + +class StubComponentPeer implements ComponentPeer { + public boolean isObscured(){return true;}; + public boolean canDetermineObscurity(){return true;}; + public void setVisible(boolean b){}; + public void setEnabled(boolean b){}; + public void paint(Graphics g){}; + public void repaint(long tm, int x, int y, int width, int height){}; + public void print(Graphics g){}; + public void setBounds(int x, int y, int width, int height, int op){}; + public void handleEvent(AWTEvent e){}; + public void coalescePaintEvent(PaintEvent e){}; + public Point getLocationOnScreen(){return null;}; + public Dimension getPreferredSize(){return null;}; + public Dimension getMinimumSize(){return null;}; + public ColorModel getColorModel(){return null;}; + public Toolkit getToolkit(){return null;}; + public Graphics getGraphics(){return null;}; + public FontMetrics getFontMetrics(Font font){return null;}; + public void dispose(){}; + public void setForeground(Color c){}; + public void setBackground(Color c){}; + public void setFont(Font f){}; + public void updateCursorImmediately(){}; + public boolean requestFocus(Component lightweightChild, + boolean temporary, + boolean focusedWindowChangeAllowed, + long time, CausedFocusEvent.Cause cause){ + return true; + }; + public boolean isFocusable(){return true;}; + + public Image createImage(ImageProducer producer){return null;}; + public Image createImage(int width, int height){return null;}; + public VolatileImage createVolatileImage(int width, int height){return null;}; + public boolean prepareImage(Image img, int w, int h, ImageObserver o){return true;}; + public int checkImage(Image img, int w, int h, ImageObserver o){return 0;}; + public GraphicsConfiguration getGraphicsConfiguration(){return null;}; + public boolean handlesWheelScrolling(){return true;}; + public void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException{}; + public Image getBackBuffer(){return null;}; + public void flip(BufferCapabilities.FlipContents flipAction){}; + public void destroyBuffers(){}; + + /** + * Reparents this peer to the new parent referenced by newContainer peer + * Implementation depends on toolkit and container. + * @param newContainer peer of the new parent container + * @since 1.5 + */ + public void reparent(ContainerPeer newContainer){}; + /** + * Returns whether this peer supports reparenting to another parent withour destroying the peer + * @return true if appropriate reparent is supported, false otherwise + * @since 1.5 + */ + public boolean isReparentSupported(){return true;}; + + /** + * Used by lightweight implementations to tell a ComponentPeer to layout + * its sub-elements. For instance, a lightweight Checkbox needs to layout + * the box, as well as the text label. + */ + public void layout(){}; + + + public Rectangle getBounds(){return null;}; + + /** + * Applies the shape to the native component window. + * @since 1.7 + */ + public void applyShape(Region shape){}; + + /** + * DEPRECATED: Replaced by getPreferredSize(). + */ + public Dimension preferredSize(){return null;}; + + /** + * DEPRECATED: Replaced by getMinimumSize(). + */ + public Dimension minimumSize(){return null;}; + + /** + * DEPRECATED: Replaced by setVisible(boolean). + */ + public void show(){}; + + /** + * DEPRECATED: Replaced by setVisible(boolean). + */ + public void hide(){}; + + /** + * DEPRECATED: Replaced by setEnabled(boolean). + */ + public void enable(){}; + + /** + * DEPRECATED: Replaced by setEnabled(boolean). + */ + public void disable(){}; + + /** + * DEPRECATED: Replaced by setBounds(int, int, int, int). + */ + public void reshape(int x, int y, int width, int height){}; +} From 5b39f2291c5d1102b04e27e7ea9fd58b0db0e233 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Tue, 25 Mar 2008 18:08:57 +0300 Subject: [PATCH 006/119] 6613426: two WM_TAKE_FOCUS messages on one mouse click in GNOME Metacity 2.16.0 A workaround to the metacity issue 485016. Reviewed-by: son --- .../solaris/classes/sun/awt/X11/XDecoratedPeer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java index 8aa3085282f..a930dfb2be8 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java @@ -1013,6 +1013,16 @@ abstract class XDecoratedPeer extends XWindowPeer { private void handleWmTakeFocus(XClientMessageEvent cl) { focusLog.log(Level.FINE, "WM_TAKE_FOCUS on {0}", new Object[]{this}); + // A workaround to Metacity issue (see 6613426). + // The first check is to skip redundant WM_TAKE_FOCUS on click + // in a focused frame. The second check is to allow requesting focus + // on click in a frame when its owned window is currently focused. + if (this == getNativeFocusedWindowPeer() && + target == XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow()) + { + focusLog.fine("The window is already focused, skipping."); + return; + } requestWindowFocus(cl.get_data(1), true); } From 3a0d8165cea893f89e120b21cee631a164720292 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Wed, 26 Mar 2008 16:20:01 +0300 Subject: [PATCH 007/119] 6680135: A number of test/closed/java/awt/Focus/* tests should be opened The tests moved from the closed repository. Reviewed-by: son --- .../ActualFocusedWindowBlockingTest.java | 333 ++++++++++++ .../ActualFocusedWindowRetaining.java | 430 +++++++++++++++ .../AppletInitialFocusTest.html | 22 + .../AppletInitialFocusTest.java | 103 ++++ .../AppletInitialFocusTest1.html | 22 + .../AppletInitialFocusTest1.java | 94 ++++ .../FrameJumpingToMouse.java | 259 ++++++++++ .../NonfocusableOwnerTest.java | 352 +++++++++++++ .../Focus/NonFocusableWindowTest/Test.java | 417 +++++++++++++++ .../awt/Focus/TypeAhead/TestFocusFreeze.java | 488 ++++++++++++++++++ .../WrongKeyTypedConsumedTest.java | 293 +++++++++++ 11 files changed, 2813 insertions(+) create mode 100644 jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java create mode 100644 jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java create mode 100644 jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html create mode 100644 jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.java create mode 100644 jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html create mode 100644 jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java create mode 100644 jdk/test/java/awt/Focus/FrameJumpingToMouse/FrameJumpingToMouse.java create mode 100644 jdk/test/java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java create mode 100644 jdk/test/java/awt/Focus/NonFocusableWindowTest/Test.java create mode 100644 jdk/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java create mode 100644 jdk/test/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java diff --git a/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java b/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java new file mode 100644 index 00000000000..823c2d0310b --- /dev/null +++ b/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java @@ -0,0 +1,333 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6314575 + @summary Tests that previosly focused owned window doesn't steal focus when an owner's component requests focus. + @author Anton Tarasov: area=awt-focus + @run applet ActualFocusedWindowBlockingTest.html +*/ + +import java.awt.*; +import java.awt.event.*; +import java.applet.Applet; +import java.util.concurrent.atomic.AtomicBoolean; +import java.lang.reflect.InvocationTargetException; +import sun.awt.SunToolkit; + +public class ActualFocusedWindowBlockingTest extends Applet { + Robot robot; + Frame owner = new Frame("Owner Frame"); + Window win = new Window(owner); + Frame frame = new Frame("Auxiliary Frame"); + Button fButton = new Button("frame button") {public String toString() {return "Frame_Button";}}; + Button wButton = new Button("window button") {public String toString() {return "Window_Button";}}; + Button aButton = new Button("auxiliary button") {public String toString() {return "Auxiliary_Button";}}; + + public static void main(String[] args) { + ActualFocusedWindowBlockingTest app = new ActualFocusedWindowBlockingTest(); + app.init(); + app.start(); + } + + 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 ()); + Sysout.createDialogWithInstructions(new String[] + {"Automatic test. Simply wait until it's done."}); + + if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) { + return; + } + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + Sysout.println("--> " + e); + } + }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); + + try { + robot = new Robot(); + } catch (AWTException e) { + throw new RuntimeException("Error: unable to create robot", e); + } + owner.add(fButton); + win.add(wButton); + frame.add(aButton); + + owner.setName("OWNER_FRAME"); + win.setName("OWNED_WINDOW"); + frame.setName("AUX_FRAME"); + + tuneAndShowWindows(new Window[] {owner, win, frame}); + } + + public void start() { + if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) { + Sysout.println("No testing on Motif. Test passed."); + return; + } + + Sysout.println("\nTest started:\n"); + + // Test 1. + + clickOnCheckFocus(wButton); + + clickOnCheckFocus(aButton); + + clickOn(fButton); + if (!testFocused(fButton)) { + throw new TestFailedException("The owner's component [" + fButton + "] couldn't be focused by click"); + } + + // Test 2. + + clickOnCheckFocus(wButton); + + clickOnCheckFocus(aButton); + + fButton.requestFocus(); + realSync(); + if (!testFocused(fButton)) { + throw new TestFailedException("The owner's component [" + fButton + "] couldn't be focused by request"); + } + + // Test 3. + + clickOnCheckFocus(wButton); + + clickOnCheckFocus(aButton); + + clickOnCheckFocus(fButton); + + clickOnCheckFocus(aButton); + + clickOn(owner); + if (!testFocused(fButton)) { + throw new TestFailedException("The owner's component [" + fButton + "] couldn't be focused as the most recent focus owner"); + } + + Sysout.println("Test passed."); + } + + void tuneAndShowWindows(Window[] arr) { + int y = 0; + for (Window w: arr) { + w.setLayout(new FlowLayout()); + w.setBounds(100, y, 400, 150); + w.setBackground(Color.blue); + w.setVisible(true); + y += 200; + realSync(); + } + } + + void clickOn(Component c) { + Sysout.println("Test: clicking " + 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); + Sysout.println((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(100); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + realSync(); + } + + void clickOnCheckFocus(Component c) { + clickOn(c); + if (!testFocused(c)) { + throw new RuntimeException("Error: [" + c + "] couldn't get focus by click."); + } + } + + boolean testFocused(Component c) { + for (int i=0; i<10; i++) { + if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == c) { + return true; + } + realSync(); + } + return false; + } + + void realSync() { + ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + } + + class TestFailedException extends RuntimeException { + public TestFailedException(String cause) { + super("Test failed. " + cause); + 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.setLocation(500,0); + 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 diff --git a/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java b/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java new file mode 100644 index 00000000000..e539e39cd70 --- /dev/null +++ b/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java @@ -0,0 +1,430 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 4823903 + @summary Tests actual focused window retaining. + @author Anton Tarasov: area=awt.focus + @run applet ActualFocusedWindowRetaining.html +*/ + +import java.awt.*; +import java.awt.event.*; +import java.lang.reflect.*; +import java.applet.*; + +public class ActualFocusedWindowRetaining extends Applet { + public static Frame frame = new Frame("Other Frame"); + public static Frame owner = new Frame("Test Frame"); + public static Button otherButton1 = new Button("Other Button 1"); + public static Button otherButton2 = new Button("Other Button 2"); + public static Button otherButton3 = new Button("Other Button 3"); + public static Button testButton1 = new Button("Test Button 1"); + public static Button testButton2 = new Button("Test Button 2"); + public static Button testButton3 = new Button("Test Button 3"); + public static Window window1 = new TestWindow(owner, otherButton2, testButton2, 800, 200); + public static Window window2 = new TestWindow(owner, otherButton3, testButton3, 800, 300); + public static int step; + public static Robot robot; + + public static void main(String[] args) { + ActualFocusedWindowRetaining a = new ActualFocusedWindowRetaining(); + a.init(); + a.start(); + } + + 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.createDialogWithInstructions( instructions ); + } + + public void start () + { + if (Toolkit.getDefaultToolkit().getClass() + .getName().equals("sun.awt.motif.MToolkit")) { + Sysout.println("No testing on Motif."); + return; + } + + try { + robot = new Robot(); + } catch (AWTException e) { + throw new RuntimeException("Error: unable to create robot", e); + } + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + Object src = e.getSource(); + Class cls = src.getClass(); + + if (cls == TestWindow.class) { + Sysout.println(e.paramString() + " on <" + (src == window1 ? "Window 1" : "Window 2") + ">"); + } else if (cls == Frame.class) { + Sysout.println(e.paramString() + " on <" + ((Frame)src).getTitle() + ">"); + } else if (cls == Button.class) { + Sysout.println(e.paramString() + " on <" + ((Button)src).getLabel() + ">"); + } else { + Sysout.println(e.paramString() + " on "); + } + } + }, AWTEvent.WINDOW_EVENT_MASK | AWTEvent.WINDOW_FOCUS_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK); + + setSize (200,200); + setVisible(true); + validate(); + + frame.setSize(new Dimension(400, 100)); + frame.setLocation(800, 400); + frame.setVisible(true); + frame.toFront(); + + owner.setLayout(new FlowLayout()); + owner.add(testButton1); + owner.add(otherButton1); + owner.pack(); + owner.setLocation(800, 100); + owner.setSize(new Dimension(400, 100)); + owner.setVisible(true); + owner.toFront(); + waitTillShown(owner); + + window1.setVisible(true); + window2.setVisible(true); + window1.toFront(); + window2.toFront(); + // Wait longer... + waitTillShown(window1); + waitTillShown(window2); + + test(); + + frame.dispose(); + owner.dispose(); + } + + public void test() { + + Button[] butArr = new Button[] {testButton3, testButton2, testButton1}; + Window[] winArr = new Window[] {window2, window1, owner}; + + step = 1; + for (int i = 0; i < 3; i++) { + clickOnCheckFocusOwner(butArr[i]); + clickOnCheckFocusedWindow(frame); + clickOn(owner); + if (!checkFocusedWindow(winArr[i])) { + stopTest("Test failed: actual focused window didn't get a focus"); + } + if (!checkFocusOwner(butArr[i])) { + stopTest("Test failed: actual focus owner didn't get a focus"); + } + step++; + } + + step = 4; + clickOnCheckFocusOwner(testButton3); + clickOnCheckFocusOwner(testButton1); + clickOnCheckFocusedWindow(frame); + clickOn(owner); + if (!checkFocusedWindow(owner)) { + stopTest("Test failed: actual focused window didn't get a focus"); + } + if (!checkFocusOwner(testButton1)) { + stopTest("Test failed: actual focus owner didn't get a focus"); + } + + step = 5; + clickOnCheckFocusOwner(testButton3); + clickOnCheckFocusOwner(testButton2); + clickOnCheckFocusedWindow(frame); + clickOn(owner); + if (!checkFocusedWindow(window1)) { + stopTest("Test failed: actual focused window didn't get a focus"); + } + if (!checkFocusOwner(testButton2)) { + stopTest("Test failed: actual focus owner didn't get a focus"); + } + + step = 6; + clickOnCheckFocusOwner(testButton1); + clickOnCheckFocusOwner(testButton2); + clickOnCheckFocusedWindow(frame); + clickOn(owner); + if (!checkFocusedWindow(window1)) { + stopTest("Test failed: actual focused window didn't get a focus"); + } + if (!checkFocusOwner(testButton2)) { + stopTest("Test failed: actual focus owner didn't get a focus"); + } + + step = 7; + clickOnCheckFocusOwner(testButton1); + clickOnCheckFocusOwner(testButton2); + clickOnCheckFocusedWindow(frame); + window1.setVisible(false); + clickOn(owner); + if (!checkFocusedWindow(owner)) { + stopTest("Test failed: actual focused window didn't get a focus"); + } + if (!checkFocusOwner(testButton1)) { + stopTest("Test failed: actual focus owner didn't get a focus"); + } + + step = 8; + window1.setVisible(true); + waitTillShown(window1); + clickOnCheckFocusOwner(testButton2); + clickOnCheckFocusedWindow(frame); + clickOn(owner); + if (!checkFocusedWindow(window1)) { + stopTest("Test failed: actual focused window didn't get a focus"); + } + if (!checkFocusOwner(testButton2)) { + stopTest("Test failed: actual focus owner didn't get a focus"); + } + } + + boolean checkFocusOwner(Component comp) { + return (comp == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); + } + + boolean checkFocusedWindow(Window win) { + return (win == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow()); + } + + void waitTillShown(Component c) { + ((sun.awt.SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + } + + void clickOnCheckFocusOwner(Component c) { + clickOn(c); + if (!checkFocusOwner(c)) { + stopTest("Error: can't bring a focus on Component by clicking on it"); + } + } + + void clickOnCheckFocusedWindow(Frame f) { + clickOn(f); + if (!checkFocusedWindow(f)) { + stopTest("Error: can't bring a focus on Frame by clicking on it"); + } + } + + 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)); + } + + pause(100); + robot.mousePress(InputEvent.BUTTON1_MASK); + pause(100); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + waitForIdle(); + } + + void waitForIdle() { + ((sun.awt.SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + } + + void pause(int msec) { + try { + Thread.sleep(msec); + } catch (InterruptedException e) { + Sysout.println("pause: non-fatal exception caught:"); + e.printStackTrace(); + } + } + + void stopTest(String msg) { + throw new RuntimeException(new String("Step " + step + ": " + msg)); + } +} + +class TestWindow extends Window { + TestWindow(Frame owner, Button otherButton, Button testButton, int x, int y) { + super(owner); + + setLayout(new FlowLayout()); + setLocation(x, y); + add(testButton); + add(otherButton); + pack(); + setBackground(Color.green); + } +} + + +/**************************************************** + 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(); + + 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 diff --git a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html new file mode 100644 index 00000000000..3d3d0c81a62 --- /dev/null +++ b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html @@ -0,0 +1,22 @@ + + + + AppletInitialFocusTest + + + +

AppletInitialFocusTest
Bug ID: 4041703

+ +

See the dialog box (usually in upper left corner) for instructions

+ + + + + diff --git a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.java b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.java new file mode 100644 index 00000000000..e34e6e123a5 --- /dev/null +++ b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.java @@ -0,0 +1,103 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + test + @bug 4041703 4096228 4025223 4260929 + @summary Ensures that appletviewer sets a reasonable default focus + for an Applet on start + @author das area=appletviewer + @run shell AppletInitialFocusTest.sh +*/ + +import java.applet.Applet; +import java.awt.*; +import java.awt.event.*; + +class MyKeyboardFocusManager extends DefaultKeyboardFocusManager { + public Window getGlobalFocusedWindow() { + return super.getGlobalFocusedWindow(); + } +} + +public class AppletInitialFocusTest extends Applet { + + Window window; + Button button = new Button("Button"); + MyKeyboardFocusManager manager = new MyKeyboardFocusManager(); + + Object lock = new Object(); + + public void init() { + KeyboardFocusManager.setCurrentKeyboardFocusManager(manager); + + Component parent = this; + while (parent != null && !(parent instanceof Window)) { + parent = parent.getParent(); + } + /* + * This applet is designed to be run only with appletviewer, + * so there always should be a toplevel frame. + */ + if (parent == null) { + synchronized (lock) { + System.err.println("appletviewer not running"); + System.exit(3); + } + } + window = (Window)parent; + + button.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + synchronized (lock) { + System.err.println("passed"); + System.exit(0); + } + } + }); + add(button); + } + + public void start() { + Thread thread = new Thread(new Runnable() { + public void run() { + try { + Thread.sleep(1000); + synchronized (lock) { + Window focused = manager.getGlobalFocusedWindow(); + if (window == focused) { + System.err.println("failed"); + System.exit(2); + } else { + System.err.println("window never activated"); + System.err.println(focused); + System.exit(0); + } + } + } catch(InterruptedException e) { + } + } + }); + thread.start(); + } +} diff --git a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html new file mode 100644 index 00000000000..cdbcdb48021 --- /dev/null +++ b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html @@ -0,0 +1,22 @@ + + + + AppletInitialFocusTest1 + + + +

AppletInitialFocusTest1
Bug ID: 4517274

+ +

See the dialog box (usually in upper left corner) for instructions

+ + + + + diff --git a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java new file mode 100644 index 00000000000..b72c1c99758 --- /dev/null +++ b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java @@ -0,0 +1,94 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + test + @bug 4411534 4517274 + @summary ensures that user's requestFocus() during applet initialization + is not ignored. + @author prs area=appletviewer + @run shell AppletInitialFocusTest1.sh +*/ + +import java.applet.Applet; +import java.awt.*; +import java.awt.event.*; + +public class AppletInitialFocusTest1 extends Applet implements FocusListener { + + Button button1 = new Button("Button1"); + Button button2 = new Button("Button2"); + + Object lock = new Object(); + + public void init() { + + Component parent = this; + while (parent != null && !(parent instanceof Window)) { + parent = parent.getParent(); + } + /* + * This applet is designed to be run only with appletviewer, + * so there always should be a toplevel frame. + */ + if (parent == null) { + synchronized (lock) { + System.err.println("appletviewer not running"); + System.exit(3); + } + } + button1.addFocusListener(this); + button2.addFocusListener(this); + add(button1); + add(button2); + button2.requestFocus(); + } + + public void focusGained(FocusEvent e) { + if (e.getSource() == button1) { + synchronized (lock) { + System.err.println("failed: focus on the wrong button"); + System.exit(2); + } + } + } + + public void focusLost(FocusEvent e) { + } + + public void start() { + Thread thread = new Thread(new Runnable() { + public void run() { + try { + Thread.sleep(10000); + synchronized (lock) { + System.err.println("passed"); + System.exit(0); + } + } catch(InterruptedException e) { + } + } + }); + thread.start(); + } +} diff --git a/jdk/test/java/awt/Focus/FrameJumpingToMouse/FrameJumpingToMouse.java b/jdk/test/java/awt/Focus/FrameJumpingToMouse/FrameJumpingToMouse.java new file mode 100644 index 00000000000..54928d2988b --- /dev/null +++ b/jdk/test/java/awt/Focus/FrameJumpingToMouse/FrameJumpingToMouse.java @@ -0,0 +1,259 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* +test +@bug 4752312 +@summary Tests that after moving non-focusable window it ungrabs mouse pointer +@author dom@sparc.spb.su: area=awt.focus +@run applet FrameJumpingToMouse.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 'FrameJumpingToMouse.html' in the run tag. This should +// be changed to the name of the test. + + +/** + * FrameJumpingToMouse.java + * + * summary: + */ + +import java.applet.Applet; +import java.awt.*; +import java.awt.event.*; +import javax.swing.JFrame; + +//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 FrameJumpingToMouse extends Applet +{ + //Declare things used in the test, like buttons and labels here + JFrame frame = new JFrame("Test jumping frame"); + Robot robot = null; + 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 ()); + + frame.setFocusableWindowState(false); + frame.setBounds(100, 100, 100, 100); + }//End init() + + public void start () + { + //Get things going. Request focus, set size, et cetera + setSize (200,200); + setVisible(true); + validate(); + + try { + robot = new Robot(); + } catch (Exception e) { + throw new RuntimeException("Can't create robot"); + } + + frame.setVisible(true); + + robot.delay(1000); + + Point frameLoc = frame.getLocationOnScreen(); + robot.mouseMove(frameLoc.x+frame.getWidth()/4, frameLoc.y+frame.getInsets().top/2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseMove(frameLoc.x+100, frameLoc.y+50); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + Toolkit.getDefaultToolkit().sync(); + robot.waitForIdle(); + frameLoc = frame.getLocation(); + + robot.mouseMove(frameLoc.x+frame.getWidth()/2, frameLoc.y+frame.getHeight()/2); + + Toolkit.getDefaultToolkit().sync(); + robot.waitForIdle(); + + if (!(frame.getLocation().equals(frameLoc))) { + throw new RuntimeException("Frame is moving to mouse with grab"); + } + }// start() + +}// class FrameJumpingToMouse + + +/**************************************************** + 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 diff --git a/jdk/test/java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java b/jdk/test/java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java new file mode 100644 index 00000000000..087eba9dea5 --- /dev/null +++ b/jdk/test/java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java @@ -0,0 +1,352 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6182359 + @summary Tests that Window having non-focusable owner can't be a focus owner. + @author Anton Tarasov: area=awt.focus + @run applet NonfocusableOwnerTest.html +*/ + +import java.awt.*; +import java.awt.event.*; +import java.applet.Applet; +import java.lang.reflect.*; +import java.io.*; + +public class NonfocusableOwnerTest extends Applet { + Robot robot; + Frame frame; + Dialog dialog; + Window window1; + Window window2; + Button button = new Button("button"); +// PrintStream Sysout = System.out; + + public static void main(String[] args) { + NonfocusableOwnerTest test = new NonfocusableOwnerTest(); + test.init(); + test.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 ()); + } + + public void start() { + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + Sysout.println(e.toString()); + } + }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK | WindowEvent.WINDOW_EVENT_MASK); + + frame = new Frame("Frame"); + frame.setName("Frame-owner"); + dialog = new Dialog(frame, "Dialog"); + dialog.setName("Dialog-owner"); + + window1 = new Window(frame); + window1.setName("1st child"); + window2 = new Window(window1); + window2.setName("2nd child"); + + test1(frame, window1); + test2(frame, window1, window2); + test3(frame, window1, window2); + + window1 = new Window(dialog); + window1.setName("1st child"); + window2 = new Window(window1); + window2.setName("2nd child"); + + test1(dialog, window1); + test2(dialog, window1, window2); + test3(dialog, window1, window2); + + Sysout.println("Test passed."); + } + + void test1(Window owner, Window child) { + Sysout.println("* * * STAGE 1 * * *\nowner=" + owner); + + owner.setFocusableWindowState(false); + owner.setSize(100, 100); + owner.setVisible(true); + + child.add(button); + child.setBounds(0, 300, 100, 100); + child.setVisible(true); + + waitTillShown(child); + + clickOn(button); + if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) { + throw new RuntimeException("Test Failed."); + } + owner.dispose(); + child.dispose(); + } + + void test2(Window owner, Window child1, Window child2) { + Sysout.println("* * * STAGE 2 * * *\nowner=" + owner); + + owner.setFocusableWindowState(false); + owner.setSize(100, 100); + owner.setVisible(true); + + child1.setFocusableWindowState(true); + child1.setBounds(0, 300, 100, 100); + child1.setVisible(true); + + child2.add(button); + child2.setBounds(0, 500, 100, 100); + child2.setVisible(true); + + clickOn(button); + if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) { + throw new RuntimeException("Test failed."); + } + owner.dispose(); + child1.dispose(); + child2.dispose(); + } + + void test3(Window owner, Window child1, Window child2) { + Sysout.println("* * * STAGE 3 * * *\nowner=" + owner); + + owner.setFocusableWindowState(true); + owner.setSize(100, 100); + owner.setVisible(true); + + child1.setFocusableWindowState(false); + child1.setBounds(0, 300, 100, 100); + child1.setVisible(true); + + child2.setFocusableWindowState(true); + child2.add(button); + child2.setBounds(0, 500, 100, 100); + child2.setVisible(true); + + clickOn(button); + + System.err.println("focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); + if (button != KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) { + throw new RuntimeException("Test failed."); + } + owner.dispose(); + child1.dispose(); + child2.dispose(); + } + + 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.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + waitForIdle(); + } + + void waitTillShown(Component c) { + while (true) { + try { + Thread.sleep(100); + c.getLocationOnScreen(); + break; + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (IllegalComponentStateException e) {} + } + } + void waitForIdle() { + try { + Toolkit.getDefaultToolkit().sync(); + sun.awt.SunToolkit.flushPendingEvents(); + EventQueue.invokeAndWait( new Runnable() { + public void run() {} // Dummy implementation + }); + } catch(InterruptedException ie) { + Sysout.println("waitForIdle, non-fatal exception caught:"); + ie.printStackTrace(); + } catch(InvocationTargetException ite) { + Sysout.println("waitForIdle, non-fatal exception caught:"); + ite.printStackTrace(); + } + + // wait longer... + robot.delay(200); + } +} + +/**************************************************** + 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 ) + { + System.err.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 diff --git a/jdk/test/java/awt/Focus/NonFocusableWindowTest/Test.java b/jdk/test/java/awt/Focus/NonFocusableWindowTest/Test.java new file mode 100644 index 00000000000..e3e7d0645a8 --- /dev/null +++ b/jdk/test/java/awt/Focus/NonFocusableWindowTest/Test.java @@ -0,0 +1,417 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ +/* + @test + @bug 4452384 + @summary Tests that non-focusable windows doesn't generate any focus events when accessed. + @author dom: area=awt.focus + @run main Test +*/ + +import java.awt.*; +import java.awt.event.*; +import java.util.*; + +public class Test extends Frame { + public static final int DEF_WIDTH = 400, + DEF_HEIGHT = 300, + DEF_TOP = 1, + DEF_LEFT = 100, + DEF_ROW = 0, + DEF_COL = 0; + static boolean automatic = true; + static Window[] windows; + static Frame main_frame, jumpingFrame; + static Button focus_button; + static Robot robot; + static void pause(int timeout) { + Toolkit.getDefaultToolkit().sync(); + robot.waitForIdle(); + robot.delay(100); + } + static GlobalListener listener; + public static void main(String[] args) { + + listener = new GlobalListener(); + Toolkit.getDefaultToolkit().addAWTEventListener(listener, + AWTEvent.FOCUS_EVENT_MASK | + AWTEvent.WINDOW_EVENT_MASK); + try{ + robot = new Robot(); + } catch(Exception e) {} + // Create several pairs - focusable Frame with focusable component(button) and non-focusable: + // window, resizable frame, non-resizable frame, dialog, non-resiable dialog + main_frame = new Frame("focusable frame"); + focus_button = new Button("button to focus"); + main_frame.add(focus_button); + main_frame.pack(); + main_frame.setVisible(true); + main_frame.setLocation(10, 600); + main_frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + listener.report(); + System.exit(0); + } + }); + + jumpingFrame = new Frame("Jumping frame"); + jumpingFrame.setBounds(DEF_LEFT, DEF_TOP, DEF_WIDTH, DEF_HEIGHT); + + windows = new Window[7]; + windows[0] = new TestWindow(0, 0, false, main_frame); + //windows[1] = new TestWindow(2, 1, true, main_frame); + windows[2] = new Test(1, 0, false, true); + windows[3] = new Test(2, 0, false, false); + //windows[4] = new Test(3, 0, true, true); + windows[5] = new TestDialog(0, 1, false, true, main_frame); + windows[6] = new TestDialog(1, 1, false, false, main_frame); + if (!automatic) { + int windowInd; + for (windowInd = 0; windowInd < windows.length; windowInd++) { + if (windows[windowInd] != null) { + windows[windowInd].setVisible(true); + } + } + } + // Run the test + // 1. Click on all controls, check for no focus events for non-focusable, right focus events for focusable + // 2. Perform some action with control, check if it works + if (automatic) { + int windowInd; + for (windowInd = 0; windowInd < windows.length; windowInd++) { + if (windows[windowInd] != null) { + windows[windowInd].setVisible(true); + focus_button.requestFocus(); + pause(1000); + + // Verify that click on non-focusable window causes no focus lost on active window + performFocusClick(windows[windowInd]); + focus_button.requestFocus(); + pause(500); + performActionClick(windows[windowInd]); + + // Verify that toFront, toBack doesn't cause non-focusable window to become active + jumpingFrame.setVisible(true); + pause(1000); + jumpingFrame.toBack(); + pause(500); + jumpingFrame.toFront(); + pause(500); + windows[windowInd].toBack(); + pause(500); + windows[windowInd].toFront(); + pause(500); + + // Verify that iconifiyng/deiconfiying and + // zooming/unzooming doesn't cause non-focusable + // window to become active + if (windows[windowInd] instanceof Frame) { + Frame toTest = (Frame)windows[windowInd]; + // Deiconification currently doesn't work! +// toTest.setExtendedState(Frame.ICONIFIED); +// pause(500); +// toTest.setExtendedState(Frame.NORMAL); + pause(500); + toTest.setExtendedState(Frame.MAXIMIZED_BOTH); + pause(500); + toTest.setExtendedState(Frame.NORMAL); + } + + windows[windowInd].dispose(); + jumpingFrame.dispose(); + } + } + pause(1000); + System.err.println("Test finished."); + if (!listener.report()) { + throw new RuntimeException("Test Failed. See error stream output for details"); + } + } + } + static void performFocusClick(Window parent) { + if (parent == null) { + return; + } + for (int compInd = 0; compInd < parent.getComponentCount(); compInd++) { + Component child = parent.getComponent(compInd); + if (child instanceof TestPanel) { + TestPanel pan = (TestPanel)child; + pan.performFocusClicks(robot); + pause(100); + } + } + } + static void performActionClick(Window parent) { + if (parent == null) { + return; + } + for (int compInd = 0; compInd < parent.getComponentCount(); compInd++) { + Component child = parent.getComponent(compInd); + if (child instanceof TestPanel) { + TestPanel pan = (TestPanel)child; + pan.performActionClicks(robot); + pause(100); + } + } + } + public Test(int row, int col, boolean focusable, boolean resizable) { + super("Frame" + row + "" + col); + TestPanel panel = new TestPanel(row, col); + if (Test.automatic) { + row = Test.DEF_ROW; + col = Test.DEF_COL; + } + setName(getTitle()); + add("Center", panel); + Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") + + ", " + (resizable?"resizable":"non-resizable")); + l.setBackground(Color.green); + add("North", l); + setBounds(Test.DEF_LEFT + DEF_WIDTH*col, DEF_TOP + DEF_HEIGHT*row, DEF_WIDTH, DEF_HEIGHT); + if (!focusable) { + setFocusableWindowState(false); + } + if (!resizable) { + setResizable(false); + } +// setVisible(true); + } +} +class TestWindow extends Window { + public TestWindow(int row, int col, boolean focusable, Frame owner) { + super(owner); + setName("Window" + row + "" + col); + TestPanel panel = new TestPanel(row, col); + if (Test.automatic) { + row = Test.DEF_ROW; + col = Test.DEF_COL; + } + + add("Center", panel); + Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") + + ", " + (false?"resizable":"non-resizable")); + l.setBackground(Color.green); + add("North", l); + + setBounds(Test.DEF_LEFT + Test.DEF_WIDTH*col, Test.DEF_TOP + Test.DEF_HEIGHT*row, Test.DEF_WIDTH, Test.DEF_HEIGHT); + if (!focusable) { + setFocusableWindowState(false); + } +// setVisible(true); + } +} +class TestDialog extends Dialog { + public TestDialog(int row, int col, boolean focusable, boolean resizable, Frame owner) { + super(owner); + setName("Dialog" + row + "" + col); + TestPanel panel = new TestPanel(row, col); + if (Test.automatic) { + row = Test.DEF_ROW; + col = Test.DEF_COL; + } + + add("Center", panel); + Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") + + ", " + (resizable?"resizable":"non-resizable")); + l.setBackground(Color.green); + add("North", l); + + setBounds(Test.DEF_LEFT + Test.DEF_WIDTH*col, Test.DEF_TOP + Test.DEF_HEIGHT*row, Test.DEF_WIDTH, Test.DEF_HEIGHT); + if (!focusable) { + setFocusableWindowState(false); + } + if (!resizable) { + setResizable(false); + } +// setVisible(true); + } +} + +class TestPanel extends Panel { + + void clickComponent(Component comp, Robot robot) { + if (comp instanceof Choice) { + return; + } + Point compLoc = comp.getLocationOnScreen(); + Dimension size = comp.getSize(); + robot.mouseMove(compLoc.x + size.width/2, compLoc.y + size.height/2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + } + void performFocusClicks(Robot robot) { + for (int childInd = 0; childInd < getComponentCount(); childInd++) { + performFocusClick(getComponent(childInd), robot); + } + } + void performFocusClick(Component comp, Robot robot) { + clickComponent(comp, robot); + } + + void performActionClicks(Robot robot) { + for (int childInd = 0; childInd < getComponentCount(); childInd++) { + performActionClick(getComponent(childInd), robot); + } + } + void performActionClick(Component comp, Robot robot) { + } + + public TestPanel(int row, int col) { + setLayout(new FlowLayout()); + Button b; + add(b = new Button("press"+ row + "" + col)); + b.setName(b.getLabel()); +// b.addMouseListener(new MouseAdapter() { +// public void mousePressed(MouseEvent e) { +// System.err.println(e); +// } +// }); + TextField t; + add(t = new TextField("text" + row + "" + col)); + t.setName(t.getText()); + + java.awt.List list = new java.awt.List(); + add(list); + list.setName("list"); + list.add("one"); + list.add("two"); + list.add("three"); + list.setMultipleMode(true); + list.setName("list" + row + "" + col); + + Checkbox check = new Checkbox("checker"); + add(check); + check.setName("check" + row + "" + col); + + Choice choice = new Choice(); + choice.add("one"); + choice.add("two"); + choice.add("three"); + add(choice); + choice.setName("choice" + row + "" + col); + + Canvas can = new Canvas() { + public Dimension getPreferredSize() { + return new Dimension(10, 10); + } + }; + can.setBackground(Color.blue); + add(can); + can.setName("canvas" + row + "" + col); + + TextArea ta = new TextArea("text\ntttt\naaaa\nwwwww\nqqqqqq\neeeeee\nrrrrrr\nyyyyyy\nuuuuu", 3, 5); + add(ta); + ta.setName("textarea" + row + "" + col); + + Scrollbar bar = new Scrollbar(Scrollbar.HORIZONTAL); + add(bar); + bar.setName("scrollbar" + row + "" + col); + + CheckboxGroup group = new CheckboxGroup(); + Checkbox ch1 = new Checkbox("one", group, true); + Checkbox ch2 = new Checkbox("two", group, false); + add(ch1); + add(ch2); + ch1.setName("checkbox1 " + row + "" + col); + ch2.setName("checkbox2 " + row + "" + col); + + + ScrollPane pane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); + add(pane); + Button bigButton = new Button("abc") { + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } + }; + pane.add(bigButton); + bigButton.setName("bigbutton" + row + "" + col); + } +} + +class GlobalListener implements AWTEventListener { + java.util.List errors = new java.util.LinkedList(); + public boolean report() { + if (errors.size() != 0) { + System.err.println("Test FAILED"); + } else { + System.err.println("Test PASSED"); + return true; + } + ListIterator iter = errors.listIterator(); + while (iter.hasNext()) { + System.err.println(iter.next()); + } + return false; + } + public GlobalListener() { + } + Window getWindowParent(Component comp) { + while (comp != null && !(comp instanceof Window)) { + comp = comp.getParent(); + } + return (Window)comp; + } + void reportError(AWTEvent e, String message) { + String error = "ERROR: " + message + " : " + e; + errors.add(error); + System.err.println(error); + } + public void eventDispatched(AWTEvent e) { + Component comp = (Component)e.getSource(); + Window parent = getWindowParent(comp); + if (!(e instanceof WindowEvent || e instanceof FocusEvent)) { + System.err.println("Strange event " + e); + } + + // Skip WINDOW_OPENED + if (e.getID() == WindowEvent.WINDOW_CLOSING) { + System.err.println(e); + } + switch (e.getID()) { + case WindowEvent.WINDOW_OPENED: + case WindowEvent.WINDOW_CLOSING: + case WindowEvent.WINDOW_CLOSED: + case WindowEvent.WINDOW_ICONIFIED: + case WindowEvent.WINDOW_DEICONIFIED: + case WindowEvent.WINDOW_STATE_CHANGED: + return; + case WindowEvent.WINDOW_LOST_FOCUS: { + WindowEvent we = (WindowEvent)e; + if (we.getOppositeWindow() != null && !we.getOppositeWindow().getFocusableWindowState()) { + reportError(e, "frame lost focus because of non-focusable window"); + } + break; + } + } + // Check that Window owner is focusable + if (!parent.getFocusableWindowState()) { + reportError(e, "focus event for component in non-focusable window " + parent.getName()); + } + if (!comp.isFocusable()) { + reportError(e, "focus event for non-focusable component"); + } +// if (e instanceof WindowEvent || e instanceof FocusEvent) { +// // System.err.println(e); +// } + } +} diff --git a/jdk/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java b/jdk/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java new file mode 100644 index 00000000000..129cdc2811e --- /dev/null +++ b/jdk/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java @@ -0,0 +1,488 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* +@test +@bug 6183877 6216005 6225560 +@summary Tests that keyboard input doesn't freeze due to type-ahead problems +@author Denis Mikhalkin: area=awt.focus +@run main/timeout=300 TestFocusFreeze +*/ + +// 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. + + +/** + * TestFocusFreeze.java + * + * summary: XXX A brief summary of what this tests + */ + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.util.concurrent.atomic.*; +import sun.awt.SunToolkit; + +public class TestFocusFreeze +{ + + //*** test-writer defined static variables go here *** + + + private static void init() + { + //*** Create instructions for the user here *** + + FocusTest.test(); + + }//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" ); + } + 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 TestFocusFreeze + +//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 + + TestFocusFreeze.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + TestFocusFreeze.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 ) + { + 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 + + +class FocusTest extends JFrame implements ActionListener { + + private JDialog pageDialog = null; + + private AtomicBoolean passed = new AtomicBoolean(); + private static volatile boolean all_passed = true; + private static volatile long pressTime; + private static Object testLock = new Object(); + private static Object resultLock = new Object(); + + public FocusTest() { + final GraphicsConfiguration gc = + GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(); + + pageDialog = new JDialog(this, "JDialog", true, gc); + Container c = pageDialog.getContentPane(); + c.setLayout(new BorderLayout()); + JButton btnApprove =new JButton("Exit Button"); + btnApprove.addActionListener(this); + c.add("South", btnApprove); + pageDialog.pack(); + + JButton bb = new JButton("Action"); + bb.addActionListener(new ActionListener() { + final JDialog pageDialog = FocusTest.this.pageDialog; + public void actionPerformed(ActionEvent e) { + synchronized(testLock) { + testLock.notify(); + } + pageDialog.setVisible(true); + } + }); + + add(bb); + pack(); + setVisible(true); + + ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + + bb.requestFocus(); + + ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + + if (!bb.isFocusOwner()) { + System.err.println("Couldn't make bb focused"); + all_passed = false; + return; + } + + new Thread() { + public void run() { + try { + Robot r = new Robot(); + synchronized (testLock) { + testLock.wait(); + } + r.keyPress(KeyEvent.VK_SPACE); + r.delay(50); + r.keyRelease(KeyEvent.VK_SPACE); + synchronized(passed) { + passed.wait(1000); + } + pageDialog.dispose(); + FocusTest.this.dispose(); + if (!passed.get()) { + all_passed = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + synchronized (resultLock) { + resultLock.notifyAll(); + } + } + }.start(); + + try { + Robot r = new Robot(); + r.keyPress(KeyEvent.VK_SPACE); + r.delay(50); + r.keyRelease(KeyEvent.VK_SPACE); + } catch (Exception e) { + e.printStackTrace(); + all_passed = false; + return; + } + + try { + synchronized (resultLock) { + resultLock.wait(); + } + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + + public void actionPerformed(ActionEvent ae) { + System.err.println("Action performed"); + passed.set(true); + synchronized(passed) { + passed.notify(); + } + } + + public static void test() { + FocusTest test = null; + for (int i = 0; i < 10; i++) { + test = new FocusTest(); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + break; + } + } + if (!all_passed) { + TestFocusFreeze.fail("Not all passed"); + } else { + TestFocusFreeze.pass(); + } + } +} diff --git a/jdk/test/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java b/jdk/test/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java new file mode 100644 index 00000000000..fd6b56d8609 --- /dev/null +++ b/jdk/test/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java @@ -0,0 +1,293 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + test + @bug 4782886 + @summary FocusManager consumes wrong KEYTYPED-Events + @author son: area=awt.focus + @run applet WrongKeyTypedConsumedTest.html +*/ + +/** + * WrongKeyTypedConsumedTest.java + * + * summary: FocusManager consumes wrong KEYTYPED-Events + */ + +import java.applet.Applet; + +import java.awt.AWTException; +import java.awt.AWTKeyStroke; +import java.awt.BorderLayout; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.KeyboardFocusManager; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextArea; + +import java.awt.event.KeyEvent; + +import java.util.HashSet; +import java.util.Set; + +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JTextArea; + +public class WrongKeyTypedConsumedTest extends Applet +{ + //Declare things used in the test, like buttons and labels here + + public void init() + { + //Create instructions for the user here, as well as set up + // the environment -- set the layout manager, add buttons, + // etc. + + String[] instructions = + { + "This is an AUTOMATIC test", + "simply wait until it is done" + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + }//End init() + + public void start () + { + //Get things going. Request focus, set size, et cetera + setSize (200,200); + setVisible(true); + validate(); + + JFrame frame = new JFrame("The Frame"); + Set ftk = new HashSet(); + ftk.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DOWN, 0)); + frame.getContentPane(). + setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, + ftk); + + JCheckBox checkbox = new JCheckBox("test"); + frame.getContentPane().add(checkbox, BorderLayout.NORTH); + + JTextArea textarea = new JTextArea(40, 10); + frame.getContentPane().add(textarea); + + frame.pack(); + frame.setVisible(true); + + try { + Robot robot = new Robot(); + + // wait for activation + robot.delay(2000); + if (!frame.isActive()) { + Point loc = frame.getLocationOnScreen(); + Dimension size = frame.getSize(); + robot.mouseMove(loc.x + size.width/2, + loc.y + size.height/2); + frame.toFront(); + robot.delay(1000); + if (!frame.isActive()) { + throw new RuntimeException("Test Fialed: frame isn't active"); + } + } + + // verify if checkbox has focus + if (!checkbox.isFocusOwner()) { + checkbox.requestFocusInWindow(); + robot.delay(1000); + if (!checkbox.isFocusOwner()) { + throw new RuntimeException("Test Failed: checkbox doesn't have focus"); + } + } + // press VK_DOWN + robot.keyPress(KeyEvent.VK_DOWN); + robot.delay(250); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.delay(1000); + + // verify if text area has focus + if (!textarea.isFocusOwner()) { + throw new RuntimeException("Test Failed: focus wasn't transfered to text area"); + } + // press '1' + robot.keyPress(KeyEvent.VK_1); + robot.delay(250); + robot.keyRelease(KeyEvent.VK_1); + robot.delay(1000); + + // verify if KEY_TYPED arraived + if (!"1".equals(textarea.getText())) { + throw new RuntimeException("Test Failed: text area text is \"" + textarea.getText() + "\", not \"1\""); + } + } catch(AWTException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed because of some internal exception"); + } + Sysout.println("Test Passed"); + }// start() + +}// class WrongKeyTypedConsumedTest + +/**************************************************** + 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(); + + 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 From 75f6b17d66a720ec267404e76d181a0ff6079a1a Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Wed, 26 Mar 2008 16:56:40 +0300 Subject: [PATCH 008/119] 6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten Using test.java.awt.regtesthelpers.Util. Refactoring. Reviewed-by: volk --- .../AppletInitialFocusTest.html | 11 +-- .../AppletInitialFocusTest.java | 78 ++++--------------- .../AppletInitialFocusTest1.html | 8 +- .../AppletInitialFocusTest1.java | 27 +------ 4 files changed, 30 insertions(+), 94 deletions(-) diff --git a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html index 3d3d0c81a62..bb07d59a736 100644 --- a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html +++ b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.html @@ -1,11 +1,12 @@ - AppletInitialFocusTest diff --git a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.java b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.java index e34e6e123a5..c3de576386e 100644 --- a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.java +++ b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest.java @@ -23,81 +23,37 @@ /* test - @bug 4041703 4096228 4025223 4260929 - @summary Ensures that appletviewer sets a reasonable default focus - for an Applet on start + @bug 4041703 4096228 4025223 4260929 + @summary Ensures that appletviewer sets a reasonable default focus for an Applet on start @author das area=appletviewer - @run shell AppletInitialFocusTest.sh + @run applet AppletInitialFocusTest.html */ import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; - -class MyKeyboardFocusManager extends DefaultKeyboardFocusManager { - public Window getGlobalFocusedWindow() { - return super.getGlobalFocusedWindow(); - } -} +import java.awt.Button; +import java.awt.Component; +import java.awt.Robot; +import java.awt.Window; +import test.java.awt.regtesthelpers.Util; public class AppletInitialFocusTest extends Applet { - - Window window; + Robot robot = Util.createRobot(); Button button = new Button("Button"); - MyKeyboardFocusManager manager = new MyKeyboardFocusManager(); - - Object lock = new Object(); public void init() { - KeyboardFocusManager.setCurrentKeyboardFocusManager(manager); - - Component parent = this; - while (parent != null && !(parent instanceof Window)) { - parent = parent.getParent(); - } - /* - * This applet is designed to be run only with appletviewer, - * so there always should be a toplevel frame. - */ - if (parent == null) { - synchronized (lock) { - System.err.println("appletviewer not running"); - System.exit(3); - } - } - window = (Window)parent; - - button.addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - synchronized (lock) { - System.err.println("passed"); - System.exit(0); - } - } - }); add(button); } public void start() { - Thread thread = new Thread(new Runnable() { - public void run() { - try { - Thread.sleep(1000); - synchronized (lock) { - Window focused = manager.getGlobalFocusedWindow(); - if (window == focused) { - System.err.println("failed"); - System.exit(2); - } else { - System.err.println("window never activated"); - System.err.println(focused); - System.exit(0); - } + new Thread(new Runnable() { + public void run() { + Util.waitTillShown(button); + robot.delay(1000); // delay the thread to let EDT to start dispatching focus events + Util.waitForIdle(robot); + if (!button.hasFocus()) { + throw new RuntimeException("Appletviewer doesn't set default focus correctly."); } - } catch(InterruptedException e) { } - } - }); - thread.start(); + }).start(); } } diff --git a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html index cdbcdb48021..dc094e1a556 100644 --- a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html +++ b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html @@ -1,11 +1,13 @@ - AppletInitialFocusTest1 diff --git a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java index b72c1c99758..2f7e8f92304 100644 --- a/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java +++ b/jdk/test/java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java @@ -1,32 +1,9 @@ /* - * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -/* - test + test %W% %E% @bug 4411534 4517274 @summary ensures that user's requestFocus() during applet initialization is not ignored. - @author prs area=appletviewer + @author prs@sparc.spb.su area=appletviewer @run shell AppletInitialFocusTest1.sh */ From 911da0a7964f43ad30be8cf022affa132bf35bc6 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Wed, 26 Mar 2008 17:38:26 +0300 Subject: [PATCH 009/119] 6616792: five AWT focus regression tests should be fixed Fixed/refactored the tests. Reviewed-by: volk --- .../ActualFocusedWindowBlockingTest.java | 228 +------ .../ActualFocusedWindowRetaining.java | 333 ++--------- .../FrameJumpingToMouse.java | 253 ++------ .../{Test.java => NoEventsTest.java} | 39 +- .../NonfocusableOwnerTest.java | 249 +------- .../awt/Focus/TypeAhead/TestFocusFreeze.java | 559 ++++-------------- .../WrongKeyTypedConsumedTest.java | 260 ++------ 7 files changed, 329 insertions(+), 1592 deletions(-) rename jdk/test/java/awt/Focus/NonFocusableWindowTest/{Test.java => NoEventsTest.java} (92%) diff --git a/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java b/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java index 823c2d0310b..888fae37f51 100644 --- a/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java +++ b/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java @@ -25,8 +25,10 @@ @test @bug 6314575 @summary Tests that previosly focused owned window doesn't steal focus when an owner's component requests focus. - @author Anton Tarasov: area=awt-focus - @run applet ActualFocusedWindowBlockingTest.html + @author Anton.Tarasov: area=awt.focus + @library ../../regtesthelpers + @build Util + @run main ActualFocusedWindowBlockingTest */ import java.awt.*; @@ -35,9 +37,10 @@ import java.applet.Applet; import java.util.concurrent.atomic.AtomicBoolean; import java.lang.reflect.InvocationTargetException; import sun.awt.SunToolkit; +import test.java.awt.regtesthelpers.Util; public class ActualFocusedWindowBlockingTest extends Applet { - Robot robot; + Robot robot = Util.createRobot(); Frame owner = new Frame("Owner Frame"); Window win = new Window(owner); Frame frame = new Frame("Auxiliary Frame"); @@ -52,28 +55,12 @@ public class ActualFocusedWindowBlockingTest extends Applet { } 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 ()); - Sysout.createDialogWithInstructions(new String[] - {"Automatic test. Simply wait until it's done."}); - - if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) { - return; - } - Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent e) { - Sysout.println("--> " + e); + System.out.println("--> " + e); } }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); - try { - robot = new Robot(); - } catch (AWTException e) { - throw new RuntimeException("Error: unable to create robot", e); - } owner.add(fButton); win.add(wButton); frame.add(aButton); @@ -87,19 +74,18 @@ public class ActualFocusedWindowBlockingTest extends Applet { public void start() { if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) { - Sysout.println("No testing on Motif. Test passed."); + System.out.println("No testing on Motif. Test passed."); return; } - Sysout.println("\nTest started:\n"); + System.out.println("\nTest started:\n"); // Test 1. clickOnCheckFocus(wButton); - clickOnCheckFocus(aButton); - clickOn(fButton); + Util.clickOnComp(fButton, robot); if (!testFocused(fButton)) { throw new TestFailedException("The owner's component [" + fButton + "] couldn't be focused by click"); } @@ -107,11 +93,10 @@ public class ActualFocusedWindowBlockingTest extends Applet { // Test 2. clickOnCheckFocus(wButton); - clickOnCheckFocus(aButton); fButton.requestFocus(); - realSync(); + Util.waitForIdle(robot); if (!testFocused(fButton)) { throw new TestFailedException("The owner's component [" + fButton + "] couldn't be focused by request"); } @@ -119,19 +104,16 @@ public class ActualFocusedWindowBlockingTest extends Applet { // Test 3. clickOnCheckFocus(wButton); - clickOnCheckFocus(aButton); - clickOnCheckFocus(fButton); - clickOnCheckFocus(aButton); - clickOn(owner); + Util.clickOnTitle(owner, robot); if (!testFocused(fButton)) { throw new TestFailedException("The owner's component [" + fButton + "] couldn't be focused as the most recent focus owner"); } - Sysout.println("Test passed."); + System.out.println("Test passed."); } void tuneAndShowWindows(Window[] arr) { @@ -142,33 +124,18 @@ public class ActualFocusedWindowBlockingTest extends Applet { w.setBackground(Color.blue); w.setVisible(true); y += 200; - realSync(); + Util.waitForIdle(robot); } } - void clickOn(Component c) { - Sysout.println("Test: clicking " + 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); - Sysout.println((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(100); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - - realSync(); - } - void clickOnCheckFocus(Component c) { - clickOn(c); + if (c instanceof Frame) { + Util.clickOnTitle((Frame)c, robot); + } else { + Util.clickOnComp(c, robot); + } if (!testFocused(c)) { - throw new RuntimeException("Error: [" + c + "] couldn't get focus by click."); + throw new TestErrorException(c + "couldn't get focus by click."); } } @@ -177,157 +144,22 @@ public class ActualFocusedWindowBlockingTest extends Applet { if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == c) { return true; } - realSync(); + Util.waitForIdle(robot); } return false; } - void realSync() { - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + // Thrown when the behavior being verified is found wrong. + class TestFailedException extends RuntimeException { + TestFailedException(String msg) { + super("Test failed: " + msg); + } } - class TestFailedException extends RuntimeException { - public TestFailedException(String cause) { - super("Test failed. " + cause); - Sysout.println(cause); + // Thrown when an error not related to the behavior being verified is encountered. + class TestErrorException extends RuntimeException { + TestErrorException(String msg) { + super("Unexpected error: " + msg); } } } - -/**************************************************** - 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.setLocation(500,0); - 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 diff --git a/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java b/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java index e539e39cd70..f657d431eac 100644 --- a/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java +++ b/jdk/test/java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java @@ -23,16 +23,19 @@ /* @test - @bug 4823903 - @summary Tests actual focused window retaining. - @author Anton Tarasov: area=awt.focus - @run applet ActualFocusedWindowRetaining.html + @bug 4823903 + @summary Tests actual focused window retaining. + @author Anton.Tarasov: area=awt.focus + @library ../../regtesthelpers + @build Util + @run main ActualFocusedWindowRetaining */ import java.awt.*; import java.awt.event.*; import java.lang.reflect.*; import java.applet.*; +import test.java.awt.regtesthelpers.Util; public class ActualFocusedWindowRetaining extends Applet { public static Frame frame = new Frame("Other Frame"); @@ -46,7 +49,7 @@ public class ActualFocusedWindowRetaining extends Applet { public static Window window1 = new TestWindow(owner, otherButton2, testButton2, 800, 200); public static Window window2 = new TestWindow(owner, otherButton3, testButton3, 800, 300); public static int step; - public static Robot robot; + public static Robot robot = Util.createRobot(); public static void main(String[] args) { ActualFocusedWindowRetaining a = new ActualFocusedWindowRetaining(); @@ -54,53 +57,25 @@ public class ActualFocusedWindowRetaining extends Applet { a.start(); } - 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.createDialogWithInstructions( instructions ); - } - - public void start () - { - if (Toolkit.getDefaultToolkit().getClass() - .getName().equals("sun.awt.motif.MToolkit")) { - Sysout.println("No testing on Motif."); - return; - } - - try { - robot = new Robot(); - } catch (AWTException e) { - throw new RuntimeException("Error: unable to create robot", e); - } - + public void start () { Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent e) { Object src = e.getSource(); Class cls = src.getClass(); if (cls == TestWindow.class) { - Sysout.println(e.paramString() + " on <" + (src == window1 ? "Window 1" : "Window 2") + ">"); + System.out.println(e.paramString() + " on <" + (src == window1 ? "Window 1" : "Window 2") + ">"); } else if (cls == Frame.class) { - Sysout.println(e.paramString() + " on <" + ((Frame)src).getTitle() + ">"); + System.out.println(e.paramString() + " on <" + ((Frame)src).getTitle() + ">"); } else if (cls == Button.class) { - Sysout.println(e.paramString() + " on <" + ((Button)src).getLabel() + ">"); + System.out.println(e.paramString() + " on <" + ((Button)src).getLabel() + ">"); } else { - Sysout.println(e.paramString() + " on "); + System.out.println(e.paramString() + " on "); } } }, AWTEvent.WINDOW_EVENT_MASK | AWTEvent.WINDOW_FOCUS_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK); - setSize (200,200); + setSize (500, 200); setVisible(true); validate(); @@ -117,15 +92,15 @@ public class ActualFocusedWindowRetaining extends Applet { owner.setSize(new Dimension(400, 100)); owner.setVisible(true); owner.toFront(); - waitTillShown(owner); + Util.waitTillShown(owner); window1.setVisible(true); window2.setVisible(true); window1.toFront(); window2.toFront(); // Wait longer... - waitTillShown(window1); - waitTillShown(window2); + Util.waitTillShown(window1); + Util.waitTillShown(window2); test(); @@ -134,85 +109,39 @@ public class ActualFocusedWindowRetaining extends Applet { } public void test() { - Button[] butArr = new Button[] {testButton3, testButton2, testButton1}; Window[] winArr = new Window[] {window2, window1, owner}; step = 1; for (int i = 0; i < 3; i++) { - clickOnCheckFocusOwner(butArr[i]); - clickOnCheckFocusedWindow(frame); - clickOn(owner); - if (!checkFocusedWindow(winArr[i])) { - stopTest("Test failed: actual focused window didn't get a focus"); - } - if (!checkFocusOwner(butArr[i])) { - stopTest("Test failed: actual focus owner didn't get a focus"); - } + clickInSeriesCheckFocus(null, butArr[i], frame); + clickOwnerCheckFocus(winArr[i], butArr[i]); step++; } step = 4; - clickOnCheckFocusOwner(testButton3); - clickOnCheckFocusOwner(testButton1); - clickOnCheckFocusedWindow(frame); - clickOn(owner); - if (!checkFocusedWindow(owner)) { - stopTest("Test failed: actual focused window didn't get a focus"); - } - if (!checkFocusOwner(testButton1)) { - stopTest("Test failed: actual focus owner didn't get a focus"); - } + clickInSeriesCheckFocus(testButton3, testButton1, frame); + clickOwnerCheckFocus(owner, testButton1); step = 5; - clickOnCheckFocusOwner(testButton3); - clickOnCheckFocusOwner(testButton2); - clickOnCheckFocusedWindow(frame); - clickOn(owner); - if (!checkFocusedWindow(window1)) { - stopTest("Test failed: actual focused window didn't get a focus"); - } - if (!checkFocusOwner(testButton2)) { - stopTest("Test failed: actual focus owner didn't get a focus"); - } + clickInSeriesCheckFocus(testButton3, testButton2, frame); + clickOwnerCheckFocus(window1, testButton2); step = 6; - clickOnCheckFocusOwner(testButton1); - clickOnCheckFocusOwner(testButton2); - clickOnCheckFocusedWindow(frame); - clickOn(owner); - if (!checkFocusedWindow(window1)) { - stopTest("Test failed: actual focused window didn't get a focus"); - } - if (!checkFocusOwner(testButton2)) { - stopTest("Test failed: actual focus owner didn't get a focus"); - } + clickInSeriesCheckFocus(testButton1, testButton2, frame); + clickOwnerCheckFocus(window1, testButton2); step = 7; - clickOnCheckFocusOwner(testButton1); - clickOnCheckFocusOwner(testButton2); - clickOnCheckFocusedWindow(frame); + clickInSeriesCheckFocus(testButton1, testButton2, frame); window1.setVisible(false); - clickOn(owner); - if (!checkFocusedWindow(owner)) { - stopTest("Test failed: actual focused window didn't get a focus"); - } - if (!checkFocusOwner(testButton1)) { - stopTest("Test failed: actual focus owner didn't get a focus"); - } + Util.waitForIdle(robot); + clickOwnerCheckFocus(owner, testButton1); step = 8; window1.setVisible(true); - waitTillShown(window1); - clickOnCheckFocusOwner(testButton2); - clickOnCheckFocusedWindow(frame); - clickOn(owner); - if (!checkFocusedWindow(window1)) { - stopTest("Test failed: actual focused window didn't get a focus"); - } - if (!checkFocusOwner(testButton2)) { - stopTest("Test failed: actual focus owner didn't get a focus"); - } + Util.waitTillShown(window1); + clickInSeriesCheckFocus(null, testButton2, frame); + clickOwnerCheckFocus(window1, testButton2); } boolean checkFocusOwner(Component comp) { @@ -223,56 +152,46 @@ public class ActualFocusedWindowRetaining extends Applet { return (win == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow()); } - void waitTillShown(Component c) { - ((sun.awt.SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + void clickOwnerCheckFocus(Window focusedWindow, Component focusedComp) { + Util.clickOnTitle(owner, robot); + robot.delay(500); + + if (!checkFocusedWindow(focusedWindow)) { + stopTest("Test failed: actual focused window didn't get a focus"); + } + if (!checkFocusOwner(focusedComp)) { + stopTest("Test failed: actual focus owner didn't get a focus"); + } + } + + void clickInSeriesCheckFocus(Component comp1, Component comp2, Frame frame) { + if (comp1 != null) { + clickOnCheckFocusOwner(comp1); + } + if (comp2 != null) { + clickOnCheckFocusOwner(comp2); + } + clickOnCheckFocusedWindow(frame); } void clickOnCheckFocusOwner(Component c) { - clickOn(c); + Util.clickOnComp(c, robot); + robot.delay(500); + if (!checkFocusOwner(c)) { stopTest("Error: can't bring a focus on Component by clicking on it"); } } void clickOnCheckFocusedWindow(Frame f) { - clickOn(f); + Util.clickOnTitle(f, robot); + robot.delay(500); + if (!checkFocusedWindow(f)) { stopTest("Error: can't bring a focus on Frame by clicking on it"); } } - 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)); - } - - pause(100); - robot.mousePress(InputEvent.BUTTON1_MASK); - pause(100); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - - waitForIdle(); - } - - void waitForIdle() { - ((sun.awt.SunToolkit) Toolkit.getDefaultToolkit()).realSync(); - } - - void pause(int msec) { - try { - Thread.sleep(msec); - } catch (InterruptedException e) { - Sysout.println("pause: non-fatal exception caught:"); - e.printStackTrace(); - } - } - void stopTest(String msg) { throw new RuntimeException(new String("Step " + step + ": " + msg)); } @@ -290,141 +209,3 @@ class TestWindow extends Window { setBackground(Color.green); } } - - -/**************************************************** - 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(); - - 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 diff --git a/jdk/test/java/awt/Focus/FrameJumpingToMouse/FrameJumpingToMouse.java b/jdk/test/java/awt/Focus/FrameJumpingToMouse/FrameJumpingToMouse.java index 54928d2988b..510a65cfa7e 100644 --- a/jdk/test/java/awt/Focus/FrameJumpingToMouse/FrameJumpingToMouse.java +++ b/jdk/test/java/awt/Focus/FrameJumpingToMouse/FrameJumpingToMouse.java @@ -22,238 +22,65 @@ */ /* -test -@bug 4752312 -@summary Tests that after moving non-focusable window it ungrabs mouse pointer -@author dom@sparc.spb.su: area=awt.focus -@run applet FrameJumpingToMouse.html + @test + @bug 4752312 + @summary Tests that after moving non-focusable window it ungrabs mouse pointer + @author Denis Mikhalkin: area=awt.focus + @library ../../regtesthelpers + @build Util + @run main FrameJumpingToMouse */ -// 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 'FrameJumpingToMouse.html' in the run tag. This should -// be changed to the name of the test. - - -/** - * FrameJumpingToMouse.java - * - * summary: - */ - import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +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.InputEvent; import javax.swing.JFrame; - -//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... - +import test.java.awt.regtesthelpers.Util; public class FrameJumpingToMouse extends Applet { - //Declare things used in the test, like buttons and labels here JFrame frame = new JFrame("Test jumping frame"); - Robot robot = null; - public void init() - { - //Create instructions for the user here, as well as set up - // the environment -- set the layout manager, add buttons, - // etc. + Robot robot = Util.createRobot(); - this.setLayout (new BorderLayout ()); + public static void main(String[] args) { + FrameJumpingToMouse test = new FrameJumpingToMouse(); + test.init(); + test.start(); + } + public void init() { frame.setFocusableWindowState(false); frame.setBounds(100, 100, 100, 100); - }//End init() - - public void start () - { - //Get things going. Request focus, set size, et cetera - setSize (200,200); - setVisible(true); - validate(); - - try { - robot = new Robot(); - } catch (Exception e) { - throw new RuntimeException("Can't create robot"); - } + } + public void start() { frame.setVisible(true); + Util.waitTillShown(frame); - robot.delay(1000); - - Point frameLoc = frame.getLocationOnScreen(); - robot.mouseMove(frameLoc.x+frame.getWidth()/4, frameLoc.y+frame.getInsets().top/2); + Point loc = frame.getLocationOnScreen(); + robot.mouseMove(loc.x + frame.getWidth() / 4, loc.y + frame.getInsets().top / 2); + robot.delay(50); robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseMove(frameLoc.x+100, frameLoc.y+50); + robot.delay(50); + robot.mouseMove(loc.x + 100, loc.y + 50); + robot.delay(50); robot.mouseRelease(InputEvent.BUTTON1_MASK); - Toolkit.getDefaultToolkit().sync(); - robot.waitForIdle(); - frameLoc = frame.getLocation(); + Util.waitForIdle(robot); - robot.mouseMove(frameLoc.x+frame.getWidth()/2, frameLoc.y+frame.getHeight()/2); + loc = frame.getLocation(); + robot.mouseMove(loc.x + frame.getWidth() / 2, loc.y + frame.getHeight() / 2); + Util.waitForIdle(robot); - Toolkit.getDefaultToolkit().sync(); - robot.waitForIdle(); - - if (!(frame.getLocation().equals(frameLoc))) { - throw new RuntimeException("Frame is moving to mouse with grab"); + if (!(frame.getLocation().equals(loc))) { + throw new RuntimeException("Test failed: frame is moving to mouse with grab!"); } - }// start() - -}// class FrameJumpingToMouse - - -/**************************************************** - 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." ); + System.out.println("Test passed."); } - - 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 +} diff --git a/jdk/test/java/awt/Focus/NonFocusableWindowTest/Test.java b/jdk/test/java/awt/Focus/NonFocusableWindowTest/NoEventsTest.java similarity index 92% rename from jdk/test/java/awt/Focus/NonFocusableWindowTest/Test.java rename to jdk/test/java/awt/Focus/NonFocusableWindowTest/NoEventsTest.java index e3e7d0645a8..4375385e5b6 100644 --- a/jdk/test/java/awt/Focus/NonFocusableWindowTest/Test.java +++ b/jdk/test/java/awt/Focus/NonFocusableWindowTest/NoEventsTest.java @@ -20,19 +20,20 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ + /* @test @bug 4452384 @summary Tests that non-focusable windows doesn't generate any focus events when accessed. - @author dom: area=awt.focus - @run main Test + @author Denis.Mikhalkin: area=awt.focus + @run main NoEventsTest */ import java.awt.*; import java.awt.event.*; import java.util.*; -public class Test extends Frame { +public class NoEventsTest extends Frame { public static final int DEF_WIDTH = 400, DEF_HEIGHT = 300, DEF_TOP = 1, @@ -80,8 +81,8 @@ public class Test extends Frame { windows = new Window[7]; windows[0] = new TestWindow(0, 0, false, main_frame); //windows[1] = new TestWindow(2, 1, true, main_frame); - windows[2] = new Test(1, 0, false, true); - windows[3] = new Test(2, 0, false, false); + windows[2] = new NoEventsTest(1, 0, false, true); + windows[3] = new NoEventsTest(2, 0, false, false); //windows[4] = new Test(3, 0, true, true); windows[5] = new TestDialog(0, 1, false, true, main_frame); windows[6] = new TestDialog(1, 1, false, false, main_frame); @@ -174,12 +175,12 @@ public class Test extends Frame { } } } - public Test(int row, int col, boolean focusable, boolean resizable) { + public NoEventsTest(int row, int col, boolean focusable, boolean resizable) { super("Frame" + row + "" + col); TestPanel panel = new TestPanel(row, col); - if (Test.automatic) { - row = Test.DEF_ROW; - col = Test.DEF_COL; + if (NoEventsTest.automatic) { + row = NoEventsTest.DEF_ROW; + col = NoEventsTest.DEF_COL; } setName(getTitle()); add("Center", panel); @@ -187,7 +188,7 @@ public class Test extends Frame { ", " + (resizable?"resizable":"non-resizable")); l.setBackground(Color.green); add("North", l); - setBounds(Test.DEF_LEFT + DEF_WIDTH*col, DEF_TOP + DEF_HEIGHT*row, DEF_WIDTH, DEF_HEIGHT); + setBounds(NoEventsTest.DEF_LEFT + DEF_WIDTH*col, DEF_TOP + DEF_HEIGHT*row, DEF_WIDTH, DEF_HEIGHT); if (!focusable) { setFocusableWindowState(false); } @@ -202,9 +203,9 @@ class TestWindow extends Window { super(owner); setName("Window" + row + "" + col); TestPanel panel = new TestPanel(row, col); - if (Test.automatic) { - row = Test.DEF_ROW; - col = Test.DEF_COL; + if (NoEventsTest.automatic) { + row = NoEventsTest.DEF_ROW; + col = NoEventsTest.DEF_COL; } add("Center", panel); @@ -213,7 +214,7 @@ class TestWindow extends Window { l.setBackground(Color.green); add("North", l); - setBounds(Test.DEF_LEFT + Test.DEF_WIDTH*col, Test.DEF_TOP + Test.DEF_HEIGHT*row, Test.DEF_WIDTH, Test.DEF_HEIGHT); + setBounds(NoEventsTest.DEF_LEFT + NoEventsTest.DEF_WIDTH*col, NoEventsTest.DEF_TOP + NoEventsTest.DEF_HEIGHT*row, NoEventsTest.DEF_WIDTH, NoEventsTest.DEF_HEIGHT); if (!focusable) { setFocusableWindowState(false); } @@ -225,9 +226,9 @@ class TestDialog extends Dialog { super(owner); setName("Dialog" + row + "" + col); TestPanel panel = new TestPanel(row, col); - if (Test.automatic) { - row = Test.DEF_ROW; - col = Test.DEF_COL; + if (NoEventsTest.automatic) { + row = NoEventsTest.DEF_ROW; + col = NoEventsTest.DEF_COL; } add("Center", panel); @@ -236,7 +237,7 @@ class TestDialog extends Dialog { l.setBackground(Color.green); add("North", l); - setBounds(Test.DEF_LEFT + Test.DEF_WIDTH*col, Test.DEF_TOP + Test.DEF_HEIGHT*row, Test.DEF_WIDTH, Test.DEF_HEIGHT); + setBounds(NoEventsTest.DEF_LEFT + NoEventsTest.DEF_WIDTH*col, NoEventsTest.DEF_TOP + NoEventsTest.DEF_HEIGHT*row, NoEventsTest.DEF_WIDTH, NoEventsTest.DEF_HEIGHT); if (!focusable) { setFocusableWindowState(false); } @@ -415,3 +416,5 @@ class GlobalListener implements AWTEventListener { // } } } + + diff --git a/jdk/test/java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java b/jdk/test/java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java index 087eba9dea5..74c124b294b 100644 --- a/jdk/test/java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java +++ b/jdk/test/java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java @@ -25,8 +25,10 @@ @test @bug 6182359 @summary Tests that Window having non-focusable owner can't be a focus owner. - @author Anton Tarasov: area=awt.focus - @run applet NonfocusableOwnerTest.html + @author Anton.Tarasov: area=awt.focus + @library ../../regtesthelpers + @build Util + @run main NonfocusableOwnerTest */ import java.awt.*; @@ -34,319 +36,124 @@ import java.awt.event.*; import java.applet.Applet; import java.lang.reflect.*; import java.io.*; +import test.java.awt.regtesthelpers.Util; public class NonfocusableOwnerTest extends Applet { - Robot robot; + Robot robot = Util.createRobot(); Frame frame; Dialog dialog; Window window1; Window window2; Button button = new Button("button"); -// PrintStream Sysout = System.out; public static void main(String[] args) { NonfocusableOwnerTest test = new NonfocusableOwnerTest(); - test.init(); test.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 ()); - } - public void start() { Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent e) { - Sysout.println(e.toString()); + System.out.println(e.toString()); } }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK | WindowEvent.WINDOW_EVENT_MASK); frame = new Frame("Frame"); frame.setName("Frame-owner"); + frame.setBounds(100, 0, 100, 100); dialog = new Dialog(frame, "Dialog"); dialog.setName("Dialog-owner"); + dialog.setBounds(100, 0, 100, 100); window1 = new Window(frame); window1.setName("1st child"); + window1.setBounds(100, 300, 100, 100); window2 = new Window(window1); window2.setName("2nd child"); + window2.setBounds(100, 500, 100, 100); test1(frame, window1); test2(frame, window1, window2); test3(frame, window1, window2); window1 = new Window(dialog); + window1.setBounds(100, 300, 100, 100); window1.setName("1st child"); window2 = new Window(window1); window2.setName("2nd child"); + window2.setBounds(100, 500, 100, 100); test1(dialog, window1); test2(dialog, window1, window2); test3(dialog, window1, window2); - Sysout.println("Test passed."); + System.out.println("Test passed."); } void test1(Window owner, Window child) { - Sysout.println("* * * STAGE 1 * * *\nowner=" + owner); + System.out.println("* * * STAGE 1 * * *\nWindow owner: " + owner); owner.setFocusableWindowState(false); - owner.setSize(100, 100); owner.setVisible(true); child.add(button); - child.setBounds(0, 300, 100, 100); child.setVisible(true); - waitTillShown(child); + Util.waitTillShown(child); - clickOn(button); + Util.clickOnComp(button, robot); if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) { throw new RuntimeException("Test Failed."); } - owner.dispose(); child.dispose(); + owner.dispose(); } void test2(Window owner, Window child1, Window child2) { - Sysout.println("* * * STAGE 2 * * *\nowner=" + owner); + System.out.println("* * * STAGE 2 * * *\nWindow nowner: " + owner); owner.setFocusableWindowState(false); - owner.setSize(100, 100); owner.setVisible(true); child1.setFocusableWindowState(true); - child1.setBounds(0, 300, 100, 100); child1.setVisible(true); child2.add(button); - child2.setBounds(0, 500, 100, 100); child2.setVisible(true); - clickOn(button); + Util.waitTillShown(child2); + + Util.clickOnComp(button, robot); if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) { throw new RuntimeException("Test failed."); } - owner.dispose(); - child1.dispose(); child2.dispose(); + child1.dispose(); + owner.dispose(); } void test3(Window owner, Window child1, Window child2) { - Sysout.println("* * * STAGE 3 * * *\nowner=" + owner); + System.out.println("* * * STAGE 3 * * *\nWidow owner: " + owner); owner.setFocusableWindowState(true); - owner.setSize(100, 100); owner.setVisible(true); child1.setFocusableWindowState(false); - child1.setBounds(0, 300, 100, 100); child1.setVisible(true); child2.setFocusableWindowState(true); child2.add(button); - child2.setBounds(0, 500, 100, 100); child2.setVisible(true); - clickOn(button); + Util.waitTillShown(child2); + Util.clickOnComp(button, robot); System.err.println("focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); if (button != KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) { throw new RuntimeException("Test failed."); } - owner.dispose(); child1.dispose(); child2.dispose(); - } - - 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.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - waitForIdle(); - } - - void waitTillShown(Component c) { - while (true) { - try { - Thread.sleep(100); - c.getLocationOnScreen(); - break; - } catch (InterruptedException e) { - throw new RuntimeException(e); - } catch (IllegalComponentStateException e) {} - } - } - void waitForIdle() { - try { - Toolkit.getDefaultToolkit().sync(); - sun.awt.SunToolkit.flushPendingEvents(); - EventQueue.invokeAndWait( new Runnable() { - public void run() {} // Dummy implementation - }); - } catch(InterruptedException ie) { - Sysout.println("waitForIdle, non-fatal exception caught:"); - ie.printStackTrace(); - } catch(InvocationTargetException ite) { - Sysout.println("waitForIdle, non-fatal exception caught:"); - ite.printStackTrace(); - } - - // wait longer... - robot.delay(200); + owner.dispose(); } } - -/**************************************************** - 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 ) - { - System.err.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 diff --git a/jdk/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java b/jdk/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java index 129cdc2811e..69f78e3640d 100644 --- a/jdk/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java +++ b/jdk/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java @@ -22,467 +22,118 @@ */ /* -@test -@bug 6183877 6216005 6225560 -@summary Tests that keyboard input doesn't freeze due to type-ahead problems -@author Denis Mikhalkin: area=awt.focus -@run main/timeout=300 TestFocusFreeze + @test + @bug 6183877 6216005 6225560 + @library ../../regtesthelpers + @build Util + @summary Tests that keyboard input doesn't freeze due to type-ahead problems + @author Denis.Mikhalkin, Anton.Tarasov: area=awt.focus + @run main TestFocusFreeze */ -// 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. +import java.awt.Component; +import java.awt.DefaultKeyboardFocusManager; +import java.awt.KeyboardFocusManager; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import test.java.awt.regtesthelpers.Util; + +public class TestFocusFreeze { + private static JFrame frame; + private static JDialog dialog; + private static JButton dlgButton; + private static JButton frameButton; + private static AtomicBoolean lock = new AtomicBoolean(false); + private static Robot robot = Util.createRobot(); + + public static void main(String[] args) { + boolean all_passed = true; + KeyboardFocusManager testKFM = new TestKFM(robot); + KeyboardFocusManager defKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - -/** - * TestFocusFreeze.java - * - * summary: XXX A brief summary of what this tests - */ - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.util.concurrent.atomic.*; -import sun.awt.SunToolkit; - -public class TestFocusFreeze -{ - - //*** test-writer defined static variables go here *** - - - private static void init() - { - //*** Create instructions for the user here *** - - FocusTest.test(); - - }//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" ); - } - 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 TestFocusFreeze - -//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 - - TestFocusFreeze.pass(); - } - else if( tries == 20 ) - { - //tried too many times without getting enough events so fail - - TestFocusFreeze.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 ) - { - 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 - - -class FocusTest extends JFrame implements ActionListener { - - private JDialog pageDialog = null; - - private AtomicBoolean passed = new AtomicBoolean(); - private static volatile boolean all_passed = true; - private static volatile long pressTime; - private static Object testLock = new Object(); - private static Object resultLock = new Object(); - - public FocusTest() { - final GraphicsConfiguration gc = - GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(); - - pageDialog = new JDialog(this, "JDialog", true, gc); - Container c = pageDialog.getContentPane(); - c.setLayout(new BorderLayout()); - JButton btnApprove =new JButton("Exit Button"); - btnApprove.addActionListener(this); - c.add("South", btnApprove); - pageDialog.pack(); - - JButton bb = new JButton("Action"); - bb.addActionListener(new ActionListener() { - final JDialog pageDialog = FocusTest.this.pageDialog; - public void actionPerformed(ActionEvent e) { - synchronized(testLock) { - testLock.notify(); - } - pageDialog.setVisible(true); - } - }); - - add(bb); - pack(); - setVisible(true); - - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); - - bb.requestFocus(); - - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); - - if (!bb.isFocusOwner()) { - System.err.println("Couldn't make bb focused"); - all_passed = false; - return; - } - - new Thread() { - public void run() { - try { - Robot r = new Robot(); - synchronized (testLock) { - testLock.wait(); - } - r.keyPress(KeyEvent.VK_SPACE); - r.delay(50); - r.keyRelease(KeyEvent.VK_SPACE); - synchronized(passed) { - passed.wait(1000); - } - pageDialog.dispose(); - FocusTest.this.dispose(); - if (!passed.get()) { - all_passed = false; - } - } catch (Exception e) { - e.printStackTrace(); - } - synchronized (resultLock) { - resultLock.notifyAll(); - } - } - }.start(); - - try { - Robot r = new Robot(); - r.keyPress(KeyEvent.VK_SPACE); - r.delay(50); - r.keyRelease(KeyEvent.VK_SPACE); - } catch (Exception e) { - e.printStackTrace(); - all_passed = false; - return; - } - - try { - synchronized (resultLock) { - resultLock.wait(); - } - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - - public void actionPerformed(ActionEvent ae) { - System.err.println("Action performed"); - passed.set(true); - synchronized(passed) { - passed.notify(); - } - } - - public static void test() { - FocusTest test = null; for (int i = 0; i < 10; i++) { - test = new FocusTest(); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - break; + test(testKFM, defKFM); + Util.waitForIdle(robot); + System.out.println("Iter " + i + ": " + (lock.get() ? "passed." : "failed!")); + if (!lock.get()) { + all_passed = false; } } if (!all_passed) { - TestFocusFreeze.fail("Not all passed"); - } else { - TestFocusFreeze.pass(); + throw new RuntimeException("Test failed: not all iterations passed!"); } + System.out.println("Test passed."); + } + + public static void test(final KeyboardFocusManager testKFM, final KeyboardFocusManager defKFM) { + frame = new JFrame("Frame"); + dialog = new JDialog(frame, "Dialog", true); + dlgButton = new JButton("Dialog_Button"); + frameButton = new JButton("Frame_Button"); + + lock.set(false); + + dialog.add(dlgButton); + dialog.setLocation(200, 0); + dialog.pack(); + frame.add(frameButton); + frame.pack(); + + dlgButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + frame.dispose(); + synchronized (lock) { + lock.set(true); + lock.notifyAll(); + } + } + }); + + frameButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // Right before the dialog will be shown, there will be called + // enqueuKeyEvents() method. We are to catch it. + KeyboardFocusManager.setCurrentKeyboardFocusManager(testKFM); + dialog.setVisible(true); + KeyboardFocusManager.setCurrentKeyboardFocusManager(defKFM); + } + }); + + Runnable showAction = new Runnable() { + public void run() { + frame.setVisible(true); + } + }; + if (!Util.trackFocusGained(frameButton, showAction, 2000, false)) { + System.out.println("Test error: wrong initial focus!"); + return; + } + + robot.keyPress(KeyEvent.VK_SPACE); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_SPACE); + + Util.waitForCondition(lock, 2000); + Util.waitForIdle(robot); + } +} + +class TestKFM extends DefaultKeyboardFocusManager { + Robot robot; + public TestKFM(Robot robot) { + this.robot = robot; + } + protected synchronized void enqueueKeyEvents(long after, Component untilFocused) { + super.enqueueKeyEvents(after, untilFocused); + robot.keyPress(KeyEvent.VK_SPACE); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_SPACE); } } diff --git a/jdk/test/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java b/jdk/test/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java index fd6b56d8609..14fd0807b82 100644 --- a/jdk/test/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java +++ b/jdk/test/java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java @@ -22,21 +22,16 @@ */ /* - test - @bug 4782886 - @summary FocusManager consumes wrong KEYTYPED-Events - @author son: area=awt.focus - @run applet WrongKeyTypedConsumedTest.html + @test + @bug 4782886 + @summary FocusManager consumes wrong KEY_TYPED events + @author Oleg.Sukhodolsky: area=awt.focus + @library ../../regtesthelpers + @build Util + @run main WrongKeyTypedConsumedTest */ -/** - * WrongKeyTypedConsumedTest.java - * - * summary: FocusManager consumes wrong KEYTYPED-Events - */ - import java.applet.Applet; - import java.awt.AWTException; import java.awt.AWTKeyStroke; import java.awt.BorderLayout; @@ -58,29 +53,19 @@ import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JTextArea; +import test.java.awt.regtesthelpers.Util; + public class WrongKeyTypedConsumedTest extends Applet { - //Declare things used in the test, like buttons and labels here + Robot robot = Util.createRobot(); - public void init() - { - //Create instructions for the user here, as well as set up - // the environment -- set the layout manager, add buttons, - // etc. - - String[] instructions = - { - "This is an AUTOMATIC test", - "simply wait until it is done" - }; - Sysout.createDialog( ); - Sysout.printInstructions( instructions ); - - }//End init() + public static void main(String[] args) { + WrongKeyTypedConsumedTest test = new WrongKeyTypedConsumedTest(); + test.start(); + } public void start () { - //Get things going. Request focus, set size, et cetera setSize (200,200); setVisible(true); validate(); @@ -100,194 +85,45 @@ public class WrongKeyTypedConsumedTest extends Applet frame.pack(); frame.setVisible(true); + Util.waitForIdle(robot); - try { - Robot robot = new Robot(); - - // wait for activation - robot.delay(2000); - if (!frame.isActive()) { - Point loc = frame.getLocationOnScreen(); - Dimension size = frame.getSize(); - robot.mouseMove(loc.x + size.width/2, - loc.y + size.height/2); - frame.toFront(); - robot.delay(1000); - if (!frame.isActive()) { - throw new RuntimeException("Test Fialed: frame isn't active"); - } - } - - // verify if checkbox has focus - if (!checkbox.isFocusOwner()) { - checkbox.requestFocusInWindow(); - robot.delay(1000); - if (!checkbox.isFocusOwner()) { - throw new RuntimeException("Test Failed: checkbox doesn't have focus"); - } - } - // press VK_DOWN - robot.keyPress(KeyEvent.VK_DOWN); - robot.delay(250); - robot.keyRelease(KeyEvent.VK_DOWN); - robot.delay(1000); - - // verify if text area has focus - if (!textarea.isFocusOwner()) { - throw new RuntimeException("Test Failed: focus wasn't transfered to text area"); - } - // press '1' - robot.keyPress(KeyEvent.VK_1); - robot.delay(250); - robot.keyRelease(KeyEvent.VK_1); - robot.delay(1000); - - // verify if KEY_TYPED arraived - if (!"1".equals(textarea.getText())) { - throw new RuntimeException("Test Failed: text area text is \"" + textarea.getText() + "\", not \"1\""); - } - } catch(AWTException e) { - e.printStackTrace(); - throw new RuntimeException("Test failed because of some internal exception"); + if (!frame.isActive()) { + throw new RuntimeException("Test Fialed: frame isn't active"); } - Sysout.println("Test Passed"); - }// start() -}// class WrongKeyTypedConsumedTest + // verify if checkbox has focus + if (!checkbox.isFocusOwner()) { + checkbox.requestFocusInWindow(); + Util.waitForIdle(robot); + if (!checkbox.isFocusOwner()) { + throw new RuntimeException("Test Failed: checkbox doesn't have focus"); + } + } -/**************************************************** - 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. - ****************************************************/ + // press VK_DOWN + robot.keyPress(KeyEvent.VK_DOWN); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.delay(50); -/** - 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. - */ + Util.waitForIdle(robot); -class Sysout -{ - private static TestDialog dialog; + // verify if text area has focus + if (!textarea.isFocusOwner()) { + throw new RuntimeException("Test Failed: focus wasn't transfered to text area"); + } + // press '1' + robot.keyPress(KeyEvent.VK_1); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_1); + robot.delay(50); - 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." ); + Util.waitForIdle(robot); + + // verify if KEY_TYPED arrived + if (!"1".equals(textarea.getText())) { + throw new RuntimeException("Test Failed: text area text is \"" + textarea.getText() + "\", not \"1\""); + } + System.out.println("Test Passed"); } - - 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 +} From 50bc5573a81a44b6f369dba9802abec292c0c27e Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Wed, 26 Mar 2008 12:25:06 -0700 Subject: [PATCH 010/119] 6679708: No_Safepoint_Verifier and BacktraceBuilder have uninitialized fields Fix or remove uninitialized fields Reviewed-by: kvn, rasbold --- hotspot/src/share/vm/classfile/javaClasses.cpp | 5 +---- hotspot/src/share/vm/memory/gcLocker.hpp | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index f2f3cb5869d..19ed2e419c0 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -1015,7 +1015,6 @@ class BacktraceBuilder: public StackObj { typeArrayOop _bcis; int _index; bool _dirty; - bool _done; No_Safepoint_Verifier _nsv; public: @@ -1029,12 +1028,10 @@ class BacktraceBuilder: public StackObj { }; // constructor for new backtrace - BacktraceBuilder(TRAPS): _methods(NULL), _bcis(NULL), _head(NULL) { + BacktraceBuilder(TRAPS): _methods(NULL), _bcis(NULL), _head(NULL), _dirty(false) { expand(CHECK); _backtrace = _head; _index = 0; - _dirty = false; - _done = false; } void flush() { diff --git a/hotspot/src/share/vm/memory/gcLocker.hpp b/hotspot/src/share/vm/memory/gcLocker.hpp index 00ba7ad89fd..b14b75797f1 100644 --- a/hotspot/src/share/vm/memory/gcLocker.hpp +++ b/hotspot/src/share/vm/memory/gcLocker.hpp @@ -184,7 +184,9 @@ class No_Safepoint_Verifier : public No_GC_Verifier { Thread *_thread; public: #ifdef ASSERT - No_Safepoint_Verifier(bool activated = true, bool verifygc = true ) : No_GC_Verifier(verifygc) { + No_Safepoint_Verifier(bool activated = true, bool verifygc = true ) : + No_GC_Verifier(verifygc), + _activated(activated) { _thread = Thread::current(); if (_activated) { _thread->_allow_allocation_count++; From fa0a3d049573c2c93174bac0e56d302a5285e8a6 Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Thu, 27 Mar 2008 11:08:37 +0300 Subject: [PATCH 011/119] 6603312: Segmentation fault running java -jar SwingSet2.jar in 256 color mode Force hiding the splashscreen if the code cannot allocate a reasonable number of color cells on PseudoColor displays Reviewed-by: son, art --- .../sun/awt/splashscreen/splashscreen_sys.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c b/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c index 859e3b4384d..bcbc98393af 100644 --- a/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c +++ b/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c @@ -436,6 +436,7 @@ SplashInitPlatform(Splash * splash) { break; } case PseudoColor: { + int availableColors; int numColors; int numComponents[3]; unsigned long colorIndex[SPLASH_COLOR_MAP_SIZE]; @@ -444,9 +445,20 @@ SplashInitPlatform(Splash * splash) { int depth = XDefaultDepthOfScreen(splash->screen); int scale = 65535 / MAX_COLOR_VALUE; - numColors = GetNumAvailableColors(splash->display, splash->screen, + availableColors = GetNumAvailableColors(splash->display, splash->screen, splash->visual->map_entries); - numColors = quantizeColors(numColors, numComponents); + numColors = quantizeColors(availableColors, numComponents); + if (numColors > availableColors) { + // Could not allocate the color cells. Most probably + // the pool got exhausted. Disable the splash screen. + XCloseDisplay(splash->display); + splash->isVisible = -1; + splash->display = NULL; + splash->screen = NULL; + splash->visual = NULL; + fprintf(stderr, "Warning: unable to initialize the splashscreen. Not enough available color cells.\n"); + return; + } splash->cmap = AllocColors(splash->display, splash->screen, numColors, colorIndex); for (i = 0; i < numColors; i++) { From 0530e0d85426166c7a491530b15a5cd6a46f65cf Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Fri, 28 Mar 2008 09:00:39 -0700 Subject: [PATCH 012/119] 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities Reviewed-by: kvn, jrose --- hotspot/src/share/vm/opto/addnode.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/opto/addnode.cpp b/hotspot/src/share/vm/opto/addnode.cpp index 2369792a1bf..35e3846ce16 100644 --- a/hotspot/src/share/vm/opto/addnode.cpp +++ b/hotspot/src/share/vm/opto/addnode.cpp @@ -70,9 +70,14 @@ static bool commute( Node *add, int con_left, int con_right ) { // Convert "Load+x" into "x+Load". // Now check for loads - if( in2->is_Load() ) return false; - // Left is a Load and Right is not; move it right. - if( in1->is_Load() ) { + if (in2->is_Load()) { + if (!in1->is_Load()) { + // already x+Load to return + return false; + } + // both are loads, so fall through to sort inputs by idx + } else if( in1->is_Load() ) { + // Left is a Load and Right is not; move it right. add->swap_edges(1, 2); return true; } From b2b125f8a93bd33671928018eea4b8d3d2bbd147 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Mon, 31 Mar 2008 15:41:56 +0400 Subject: [PATCH 013/119] 6508505: JComboBox collapses immediately if it is placed to embedded frame XWindowPeer should translate absolute coordinates to local Reviewed-by: son --- jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java index be679208974..c5fc7e1a7d4 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java @@ -1974,8 +1974,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, // So, I do not want to implement complicated logic for better retargeting. target = pressTarget.isVisible() ? pressTarget : this; xme.set_window(target.getWindow()); - xme.set_x(xme.get_x_root() - target.getX()); - xme.set_y(xme.get_y_root() - target.getY()); + Point localCoord = target.toLocal(xme.get_x_root(), xme.get_y_root()); + xme.set_x(localCoord.x); + xme.set_y(localCoord.y); } grabLog.log(Level.FINER, " - Grab event target {0}", new Object[] {target}); if (target != null) { @@ -2026,8 +2027,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, // see 6390326 for more information. target = pressTarget.isVisible() ? pressTarget : this; xbe.set_window(target.getWindow()); - xbe.set_x(xbe.get_x_root() - target.getX()); - xbe.set_y(xbe.get_y_root() - target.getY()); + Point localCoord = target.toLocal(xbe.get_x_root(), xbe.get_y_root()); + xbe.set_x(localCoord.x); + xbe.set_y(localCoord.y); pressTarget = this; } if (target != null && target != getContentXWindow() && target != this) { From cfaf19f278767e57ea355daf9d04c9379f95f40f Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Mon, 31 Mar 2008 15:56:12 +0400 Subject: [PATCH 014/119] 6637204: TrayIcon.displayMessage fails to show icon twice The icon canvas should be validated to finalize its layout Reviewed-by: ant --- jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java index 5c8ccd02913..e3bfacb4353 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java @@ -833,6 +833,7 @@ public class XTrayIconPeer implements TrayIconPeer { Dimension tpSize = textPanel.getSize(); iconCanvas.setSize(BALLOON_ICON_WIDTH, (BALLOON_ICON_HEIGHT > tpSize.height ? BALLOON_ICON_HEIGHT : tpSize.height)); + iconCanvas.validate(); } SunToolkit.executeOnEventHandlerThread(xtiPeer.target, new Runnable() { From 252a10cf1a84bb2710655b7d337ee27fdb3c4538 Mon Sep 17 00:00:00 2001 From: Andrey Petrusenko Date: Tue, 1 Apr 2008 15:13:47 +0400 Subject: [PATCH 015/119] 6539517: CR 6186200 should be extended to perm gen allocation to prevent spurious OOM's from perm gen Reviewed-by: ysr, jmasa --- .../concurrentMarkSweep/cmsPermGen.cpp | 44 +-------- .../concurrentMarkSweep/cmsPermGen.hpp | 1 - .../parallelScavenge/parallelScavengeHeap.cpp | 31 ++++++ .../parallelScavenge/psParallelCompact.cpp | 4 +- .../parallelScavenge/vmPSOperations.cpp | 3 + .../shared/vmGCOperations.cpp | 15 +++ .../shared/vmGCOperations.hpp | 21 ++++ hotspot/src/share/vm/includeDB_core | 13 ++- hotspot/src/share/vm/memory/gcLocker.cpp | 6 ++ .../src/share/vm/memory/genCollectedHeap.hpp | 1 + hotspot/src/share/vm/memory/permGen.cpp | 99 ++++++++++++------- hotspot/src/share/vm/memory/permGen.hpp | 2 + hotspot/src/share/vm/runtime/globals.hpp | 4 + .../src/share/vm/runtime/vm_operations.hpp | 1 + 14 files changed, 165 insertions(+), 80 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsPermGen.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsPermGen.cpp index ead077be1e3..9fd85d6b4f1 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsPermGen.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsPermGen.cpp @@ -44,52 +44,12 @@ HeapWord* CMSPermGen::mem_allocate(size_t size) { bool lock_owned = lock->owned_by_self(); if (lock_owned) { MutexUnlocker mul(lock); - return mem_allocate_work(size); + return mem_allocate_in_gen(size, _gen); } else { - return mem_allocate_work(size); + return mem_allocate_in_gen(size, _gen); } } -HeapWord* CMSPermGen::mem_allocate_work(size_t size) { - assert(!_gen->freelistLock()->owned_by_self(), "Potetntial deadlock"); - - MutexLocker ml(Heap_lock); - HeapWord* obj = NULL; - - obj = _gen->allocate(size, false); - // Since we want to minimize pause times, we will prefer - // expanding the perm gen rather than doing a stop-world - // collection to satisfy the allocation request. - if (obj == NULL) { - // Try to expand the perm gen and allocate space. - obj = _gen->expand_and_allocate(size, false, false); - if (obj == NULL) { - // Let's see if a normal stop-world full collection will - // free up enough space. - SharedHeap::heap()->collect_locked(GCCause::_permanent_generation_full); - obj = _gen->allocate(size, false); - if (obj == NULL) { - // The collection above may have shrunk the space, so try - // to expand again and allocate space. - obj = _gen->expand_and_allocate(size, false, false); - } - if (obj == NULL) { - // We have not been able to allocate space despite a - // full stop-world collection. We now make a last-ditch collection - // attempt (in which soft refs are all aggressively freed) - // that will try to reclaim as much space as possible. - SharedHeap::heap()->collect_locked(GCCause::_last_ditch_collection); - obj = _gen->allocate(size, false); - if (obj == NULL) { - // Expand generation in case it was shrunk following the collection. - obj = _gen->expand_and_allocate(size, false, false); - } - } - } - } - return obj; -} - void CMSPermGen::compute_new_size() { _gen->compute_new_size(); } diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsPermGen.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsPermGen.hpp index e7b7096f89c..8e1d07760ab 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsPermGen.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsPermGen.hpp @@ -29,7 +29,6 @@ class ConcurrentMarkSweepGeneration; class CMSPermGen: public PermGen { friend class VMStructs; - HeapWord* mem_allocate_work(size_t size); protected: // The "generation" view. ConcurrentMarkSweepGeneration* _gen; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index 8088f0c5d0d..6fd50b39fc5 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -590,6 +590,31 @@ HeapWord* ParallelScavengeHeap::permanent_mem_allocate(size_t size) { full_gc_count = Universe::heap()->total_full_collections(); result = perm_gen()->allocate_permanent(size); + + if (result != NULL) { + return result; + } + + if (GC_locker::is_active_and_needs_gc()) { + // If this thread is not in a jni critical section, we stall + // the requestor until the critical section has cleared and + // GC allowed. When the critical section clears, a GC is + // initiated by the last thread exiting the critical section; so + // we retry the allocation sequence from the beginning of the loop, + // rather than causing more, now probably unnecessary, GC attempts. + JavaThread* jthr = JavaThread::current(); + if (!jthr->in_critical()) { + MutexUnlocker mul(Heap_lock); + GC_locker::stall_until_clear(); + continue; + } else { + if (CheckJNICalls) { + fatal("Possible deadlock due to allocating while" + " in jni critical section"); + } + return NULL; + } + } } if (result == NULL) { @@ -622,6 +647,12 @@ HeapWord* ParallelScavengeHeap::permanent_mem_allocate(size_t size) { if (op.prologue_succeeded()) { assert(Universe::heap()->is_in_permanent_or_null(op.result()), "result not in heap"); + // If GC was locked out during VM operation then retry allocation + // and/or stall as necessary. + if (op.gc_locked()) { + assert(op.result() == NULL, "must be NULL if gc_locked() is true"); + continue; // retry and/or stall as necessary + } // If a NULL results is being returned, an out-of-memory // will be thrown now. Clear the gc_time_limit_exceeded // flag to avoid the following situation. diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index 81c2d47a647..b42b130894d 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -999,7 +999,7 @@ void PSParallelCompact::pre_compact(PreGCValues* pre_gc_values) DEBUG_ONLY(mark_bitmap_count = mark_bitmap_size = 0;) // Increment the invocation count - heap->increment_total_collections(); + heap->increment_total_collections(true); // We need to track unique mark sweep invocations as well. _total_invocations++; @@ -1964,7 +1964,7 @@ void PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); assert(ref_processor() != NULL, "Sanity"); - if (GC_locker::is_active()) { + if (GC_locker::check_active_before_gc()) { return; } diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp index 7f12cf55c55..0b21861397b 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp @@ -69,6 +69,9 @@ void VM_ParallelGCFailedPermanentAllocation::doit() { GCCauseSetter gccs(heap, _gc_cause); _result = heap->failed_permanent_mem_allocate(_size); + if (_result == NULL && GC_locker::is_active_and_needs_gc()) { + set_gc_locked(); + } notify_gc_end(); } diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp index 7108f318ec0..7cab57dd727 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp @@ -144,3 +144,18 @@ void VM_GenCollectFull::doit() { gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_level); notify_gc_end(); } + +void VM_GenCollectForPermanentAllocation::doit() { + JvmtiGCForAllocationMarker jgcm; + notify_gc_begin(true); + GenCollectedHeap* gch = GenCollectedHeap::heap(); + GCCauseSetter gccs(gch, _gc_cause); + gch->do_full_collection(gch->must_clear_all_soft_refs(), + gch->n_gens() - 1); + _res = gch->perm_gen()->allocate(_size, false); + assert(gch->is_in_reserved_or_null(_res), "result not in heap"); + if (_res == NULL && GC_locker::is_active_and_needs_gc()) { + set_gc_locked(); + } + notify_gc_end(); +} diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp index ee850f70e8f..7777dc71c84 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp @@ -43,6 +43,7 @@ // is specified; and also the attach "inspectheap" operation // // VM_GenCollectForAllocation +// VM_GenCollectForPermanentAllocation // VM_ParallelGCFailedAllocation // VM_ParallelGCFailedPermanentAllocation // - this operation is invoked when allocation is failed; @@ -166,3 +167,23 @@ class VM_GenCollectFull: public VM_GC_Operation { virtual VMOp_Type type() const { return VMOp_GenCollectFull; } virtual void doit(); }; + +class VM_GenCollectForPermanentAllocation: public VM_GC_Operation { + private: + HeapWord* _res; + size_t _size; // size of object to be allocated + public: + VM_GenCollectForPermanentAllocation(size_t size, + unsigned int gc_count_before, + unsigned int full_gc_count_before, + GCCause::Cause gc_cause) + : VM_GC_Operation(gc_count_before, full_gc_count_before, true), + _size(size) { + _res = NULL; + _gc_cause = gc_cause; + } + ~VM_GenCollectForPermanentAllocation() {} + virtual VMOp_Type type() const { return VMOp_GenCollectForPermanentAllocation; } + virtual void doit(); + HeapWord* result() const { return _res; } +}; diff --git a/hotspot/src/share/vm/includeDB_core b/hotspot/src/share/vm/includeDB_core index 17404cec658..4893e97b2b7 100644 --- a/hotspot/src/share/vm/includeDB_core +++ b/hotspot/src/share/vm/includeDB_core @@ -719,6 +719,11 @@ ciObjArray.cpp ciNullObject.hpp ciObjArray.cpp ciUtilities.hpp ciObjArray.cpp objArrayOop.hpp +ciObjArray.cpp ciObjArray.hpp +ciObjArray.cpp ciNullObject.hpp +ciObjArray.cpp ciUtilities.hpp +ciObjArray.cpp objArrayOop.hpp + ciObjArrayKlass.cpp ciInstanceKlass.hpp ciObjArrayKlass.cpp ciObjArrayKlass.hpp ciObjArrayKlass.cpp ciObjArrayKlassKlass.hpp @@ -1636,6 +1641,7 @@ frame_.inline.hpp generate_platform_dependent_include gcLocker.cpp gcLocker.inline.hpp gcLocker.cpp sharedHeap.hpp +gcLocker.cpp resourceArea.hpp gcLocker.hpp collectedHeap.hpp gcLocker.hpp genCollectedHeap.hpp @@ -3061,13 +3067,14 @@ oopMap.cpp scopeDesc.hpp oopMap.cpp signature.hpp oopMap.hpp allocation.hpp +oopMapCache.cpp jvmtiRedefineClassesTrace.hpp oopMap.hpp compressedStream.hpp oopMap.hpp growableArray.hpp oopMap.hpp vmreg.hpp oopMapCache.cpp allocation.inline.hpp -oopMapCache.cpp handles.inline.hpp oopMapCache.cpp jvmtiRedefineClassesTrace.hpp +oopMapCache.cpp handles.inline.hpp oopMapCache.cpp oop.inline.hpp oopMapCache.cpp oopMapCache.hpp oopMapCache.cpp resourceArea.hpp @@ -3315,6 +3322,10 @@ permGen.cpp java.hpp permGen.cpp oop.inline.hpp permGen.cpp permGen.hpp permGen.cpp universe.hpp +permGen.cpp gcLocker.hpp +permGen.cpp gcLocker.inline.hpp +permGen.cpp vmGCOperations.hpp +permGen.cpp vmThread.hpp permGen.hpp gcCause.hpp permGen.hpp generation.hpp diff --git a/hotspot/src/share/vm/memory/gcLocker.cpp b/hotspot/src/share/vm/memory/gcLocker.cpp index 428a5d27553..4e770e01b36 100644 --- a/hotspot/src/share/vm/memory/gcLocker.cpp +++ b/hotspot/src/share/vm/memory/gcLocker.cpp @@ -32,6 +32,12 @@ volatile bool GC_locker::_doing_gc = false; void GC_locker::stall_until_clear() { assert(!JavaThread::current()->in_critical(), "Would deadlock"); + if (PrintJNIGCStalls && PrintGCDetails) { + ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 + gclog_or_tty->print_cr( + "Allocation failed. Thread \"%s\" is stalled by JNI critical section.", + JavaThread::current()->name()); + } MutexLocker ml(JNICritical_lock); // Wait for _needs_gc to be cleared while (GC_locker::needs_gc()) { diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.hpp b/hotspot/src/share/vm/memory/genCollectedHeap.hpp index b3cf2de0f4b..36cf0a6959d 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp @@ -35,6 +35,7 @@ class GenCollectedHeap : public SharedHeap { friend class CMSCollector; friend class GenMarkSweep; friend class VM_GenCollectForAllocation; + friend class VM_GenCollectForPermanentAllocation; friend class VM_GenCollectFull; friend class VM_GenCollectFullConcurrent; friend class VM_GC_HeapInspection; diff --git a/hotspot/src/share/vm/memory/permGen.cpp b/hotspot/src/share/vm/memory/permGen.cpp index f611cc36e1a..1c8fa9681ec 100644 --- a/hotspot/src/share/vm/memory/permGen.cpp +++ b/hotspot/src/share/vm/memory/permGen.cpp @@ -25,6 +25,70 @@ #include "incls/_precompiled.incl" #include "incls/_permGen.cpp.incl" +HeapWord* PermGen::mem_allocate_in_gen(size_t size, Generation* gen) { + MutexLocker ml(Heap_lock); + GCCause::Cause next_cause = GCCause::_permanent_generation_full; + GCCause::Cause prev_cause = GCCause::_no_gc; + + for (;;) { + HeapWord* obj = gen->allocate(size, false); + if (obj != NULL) { + return obj; + } + if (gen->capacity() < _capacity_expansion_limit || + prev_cause != GCCause::_no_gc) { + obj = gen->expand_and_allocate(size, false); + } + if (obj == NULL && prev_cause != GCCause::_last_ditch_collection) { + if (GC_locker::is_active_and_needs_gc()) { + // If this thread is not in a jni critical section, we stall + // the requestor until the critical section has cleared and + // GC allowed. When the critical section clears, a GC is + // initiated by the last thread exiting the critical section; so + // we retry the allocation sequence from the beginning of the loop, + // rather than causing more, now probably unnecessary, GC attempts. + JavaThread* jthr = JavaThread::current(); + if (!jthr->in_critical()) { + MutexUnlocker mul(Heap_lock); + // Wait for JNI critical section to be exited + GC_locker::stall_until_clear(); + continue; + } else { + if (CheckJNICalls) { + fatal("Possible deadlock due to allocating while" + " in jni critical section"); + } + return NULL; + } + } + + // Read the GC count while holding the Heap_lock + unsigned int gc_count_before = SharedHeap::heap()->total_collections(); + unsigned int full_gc_count_before = SharedHeap::heap()->total_full_collections(); + { + MutexUnlocker mu(Heap_lock); // give up heap lock, execute gets it back + VM_GenCollectForPermanentAllocation op(size, gc_count_before, full_gc_count_before, + next_cause); + VMThread::execute(&op); + if (!op.prologue_succeeded() || op.gc_locked()) { + assert(op.result() == NULL, "must be NULL if gc_locked() is true"); + continue; // retry and/or stall as necessary + } + obj = op.result(); + assert(obj == NULL || SharedHeap::heap()->is_in_reserved(obj), + "result not in heap"); + if (obj != NULL) { + return obj; + } + } + prev_cause = next_cause; + next_cause = GCCause::_last_ditch_collection; + } else { + return obj; + } + } +} + CompactingPermGen::CompactingPermGen(ReservedSpace rs, ReservedSpace shared_rs, size_t initial_byte_size, @@ -44,40 +108,7 @@ CompactingPermGen::CompactingPermGen(ReservedSpace rs, } HeapWord* CompactingPermGen::mem_allocate(size_t size) { - MutexLocker ml(Heap_lock); - HeapWord* obj = _gen->allocate(size, false); - bool tried_collection = false; - bool tried_expansion = false; - while (obj == NULL) { - if (_gen->capacity() >= _capacity_expansion_limit || tried_expansion) { - // Expansion limit reached, try collection before expanding further - // For now we force a full collection, this could be changed - SharedHeap::heap()->collect_locked(GCCause::_permanent_generation_full); - obj = _gen->allocate(size, false); - tried_collection = true; - tried_expansion = false; // ... following the collection: - // the collection may have shrunk the space. - } - if (obj == NULL && !tried_expansion) { - obj = _gen->expand_and_allocate(size, false); - tried_expansion = true; - } - if (obj == NULL && tried_collection && tried_expansion) { - // We have not been able to allocate despite a collection and - // an attempted space expansion. We now make a last-ditch collection - // attempt that will try to reclaim as much space as possible (for - // example by aggressively clearing all soft refs). - SharedHeap::heap()->collect_locked(GCCause::_last_ditch_collection); - obj = _gen->allocate(size, false); - if (obj == NULL) { - // An expansion attempt is necessary since the previous - // collection may have shrunk the space. - obj = _gen->expand_and_allocate(size, false); - } - break; - } - } - return obj; + return mem_allocate_in_gen(size, _gen); } void CompactingPermGen::compute_new_size() { diff --git a/hotspot/src/share/vm/memory/permGen.hpp b/hotspot/src/share/vm/memory/permGen.hpp index 47f16b83b0f..263a589b272 100644 --- a/hotspot/src/share/vm/memory/permGen.hpp +++ b/hotspot/src/share/vm/memory/permGen.hpp @@ -38,6 +38,8 @@ class PermGen : public CHeapObj { size_t _capacity_expansion_limit; // maximum expansion allowed without a // full gc occuring + HeapWord* mem_allocate_in_gen(size_t size, Generation* gen); + public: enum Name { MarkSweepCompact, MarkSweep, ConcurrentMarkSweep diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 19f005aa887..66ff00b31d7 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1919,6 +1919,10 @@ class CommandLineFlags { develop(bool, IgnoreLibthreadGPFault, false, \ "Suppress workaround for libthread GP fault") \ \ + product(bool, PrintJNIGCStalls, false, \ + "Print diagnostic message when GC is stalled" \ + "by JNI critical section") \ + \ /* JVMTI heap profiling */ \ \ diagnostic(bool, TraceJVMTIObjectTagging, false, \ diff --git a/hotspot/src/share/vm/runtime/vm_operations.hpp b/hotspot/src/share/vm/runtime/vm_operations.hpp index 778a46dd718..54264ad0dde 100644 --- a/hotspot/src/share/vm/runtime/vm_operations.hpp +++ b/hotspot/src/share/vm/runtime/vm_operations.hpp @@ -49,6 +49,7 @@ template(GenCollectFull) \ template(GenCollectFullConcurrent) \ template(GenCollectForAllocation) \ + template(GenCollectForPermanentAllocation) \ template(ParallelGCFailedAllocation) \ template(ParallelGCFailedPermanentAllocation) \ template(ParallelGCSystemGC) \ From 4eb04f83d50bd58d385f5e14f76c56bbd2b088f9 Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Tue, 1 Apr 2008 17:38:46 +0400 Subject: [PATCH 016/119] 6681889: JSN security test headline/noWarningApp failed with NPE exception The java.awt.Component.changeSupportLock field should be initialized in the readObject() method. Reviewed-by: son, art --- jdk/src/share/classes/java/awt/Component.java | 6 +- ...opertyChangeListenerLockSerialization.java | 402 ++++++++++++++++++ 2 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/awt/Window/PropertyChangeListenerLockSerialization/PropertyChangeListenerLockSerialization.java diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java index b48b8c552fd..005a282442a 100644 --- a/jdk/src/share/classes/java/awt/Component.java +++ b/jdk/src/share/classes/java/awt/Component.java @@ -634,7 +634,9 @@ public abstract class Component implements ImageObserver, MenuContainer, */ private PropertyChangeSupport changeSupport; - private transient final Object changeSupportLock = new Object(); + // Note: this field is considered final, though readObject() prohibits + // initializing final fields. + private transient Object changeSupportLock = new Object(); private Object getChangeSupportLock() { return changeSupportLock; } @@ -8310,6 +8312,8 @@ public abstract class Component implements ImageObserver, MenuContainer, private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { + changeSupportLock = new Object(); + s.defaultReadObject(); appContext = AppContext.getAppContext(); diff --git a/jdk/test/java/awt/Window/PropertyChangeListenerLockSerialization/PropertyChangeListenerLockSerialization.java b/jdk/test/java/awt/Window/PropertyChangeListenerLockSerialization/PropertyChangeListenerLockSerialization.java new file mode 100644 index 00000000000..1a50818148a --- /dev/null +++ b/jdk/test/java/awt/Window/PropertyChangeListenerLockSerialization/PropertyChangeListenerLockSerialization.java @@ -0,0 +1,402 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6681889 + @summary Showing a deserialized frame should not throw NPE + @author anthony.petrov@...: area=awt.toplevel + @run main PropertyChangeListenerLockSerialization +*/ + + +/** + * PropertyChangeListenerLockSerialization.java + * + * summary: Showing a deserialized frame should not throw NPE + */ + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.net.*; + +public class PropertyChangeListenerLockSerialization +{ + + 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 ); + + File file = + new File(System.getProperty("test.classes", "."), "frame.ser"); + + Frame f = new Frame("Frame"); + f.setBounds(250, 50, 300, 300); + try { + OutputStream o = new FileOutputStream(file); + ObjectOutputStream oo = new ObjectOutputStream(o); + + oo.writeObject(f); + oo.close(); + } catch (IOException ex) { + ex.printStackTrace(); + fail("Unable to serialize the frame: " + ex); + } + + // Cleanup the frame + f.dispose(); + f = null; + + try { + ObjectInputStream i = new ObjectInputStream(new FileInputStream(file)); + + f = (Frame)i.readObject(); + f.show(); + } catch (NullPointerException ex) { + ex.printStackTrace(); + fail("The NullPointerException has been thrown: " + ex); + } catch (Exception ex) { + ex.printStackTrace(); + fail("Error while deserializing the frame: " + ex); + } + + // Cleanup the frame + f.dispose(); + f = null; + + 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" ); + } + 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 PropertyChangeListenerLockSerialization + +//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 + + PropertyChangeListenerLockSerialization.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + PropertyChangeListenerLockSerialization.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 From e95ef5ac2170dd730b7923f7ba2b785fddde00c7 Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Wed, 2 Apr 2008 17:45:50 +0400 Subject: [PATCH 017/119] 6677332: incorrect signatures for JNI methods in XWindow.c and XlibWrapper.c Int replaced with jint in XWindow.c and WlibWrapper.c, and BOOL replaced with Bool in MouseInfo.c. Reviewed-by: anthony --- jdk/src/solaris/native/sun/awt/MouseInfo.c | 4 ++-- jdk/src/solaris/native/sun/xawt/XWindow.c | 2 +- jdk/src/solaris/native/sun/xawt/XlibWrapper.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jdk/src/solaris/native/sun/awt/MouseInfo.c b/jdk/src/solaris/native/sun/awt/MouseInfo.c index 368ccab8cdd..f2716680174 100644 --- a/jdk/src/solaris/native/sun/awt/MouseInfo.c +++ b/jdk/src/solaris/native/sun/awt/MouseInfo.c @@ -54,7 +54,7 @@ Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls, int i; int32_t xr, yr, xw, yw; uint32_t keys; - BOOL pointerFound; + Bool pointerFound; AWT_LOCK(); if (pointClass == NULL) { @@ -102,7 +102,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse int32_t xr = 0, yr = 0, xw = 0, yw = 0; uint32_t keys = 0; uint32_t nchildren = 0; - BOOL pointerFound = 0; + Bool pointerFound = 0; struct FrameData *wdata = NULL; jobject winPeer = NULL; diff --git a/jdk/src/solaris/native/sun/xawt/XWindow.c b/jdk/src/solaris/native/sun/xawt/XWindow.c index a72187ef3fb..0690e58ad2c 100644 --- a/jdk/src/solaris/native/sun/xawt/XWindow.c +++ b/jdk/src/solaris/native/sun/xawt/XWindow.c @@ -1234,7 +1234,7 @@ Java_sun_awt_X11_XWindow_initIDs } } -JNIEXPORT int JNICALL +JNIEXPORT jint JNICALL Java_sun_awt_X11_XWindow_getKeySymForAWTKeyCode(JNIEnv* env, jclass clazz, jint keycode) { return awt_getX11KeySym(keycode); } diff --git a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c index 01d5def24c4..6884b366f09 100644 --- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c +++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c @@ -359,7 +359,7 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XDestroyWindow XDestroyWindow( (Display *)jlong_to_ptr(display),(Window) window); } -JNIEXPORT int JNICALL Java_sun_awt_X11_XlibWrapper_XGrabPointer +JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGrabPointer (JNIEnv *env, jclass clazz, jlong display, jlong window, jint owner_events, jint event_mask, jint pointer_mode, jint keyboard_mode, jlong confine_to, jlong cursor, jlong time) @@ -377,7 +377,7 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XUngrabPointer XUngrabPointer( (Display *)jlong_to_ptr(display), (Time) time); } -JNIEXPORT int JNICALL Java_sun_awt_X11_XlibWrapper_XGrabKeyboard +JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XGrabKeyboard (JNIEnv *env, jclass clazz, jlong display, jlong window, jint owner_events, jint pointer_mode, jint keyboard_mode, jlong time) @@ -621,7 +621,7 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_XSync } -JNIEXPORT int JNICALL Java_sun_awt_X11_XlibWrapper_XTranslateCoordinates +JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XTranslateCoordinates (JNIEnv *env, jclass clazz, jlong display, jlong src_w, jlong dest_w, jlong src_x, jlong src_y, jlong dest_x_return, jlong dest_y_return, jlong child_return) @@ -634,7 +634,7 @@ JNIEXPORT int JNICALL Java_sun_awt_X11_XlibWrapper_XTranslateCoordinates (Window *) jlong_to_ptr(child_return)); } -JNIEXPORT int JNICALL Java_sun_awt_X11_XlibWrapper_XEventsQueued +JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XEventsQueued (JNIEnv *env, jclass clazz, jlong display, jint mode) { AWT_CHECK_HAVE_LOCK(); From 0d27a8639f0af075d3952984d525c8e139dc7c74 Mon Sep 17 00:00:00 2001 From: John R Rose Date: Wed, 2 Apr 2008 12:09:59 -0700 Subject: [PATCH 018/119] 6667042: PrintAssembly option does not work without special plugin Remove old private plugin interface, simplify, rework old plugin to use unchanged Gnu sources Reviewed-by: kvn, rasbold --- hotspot/.hgignore | 1 + hotspot/build/linux/makefiles/vm.make | 2 + hotspot/build/linux/platform_amd64 | 2 - hotspot/build/linux/platform_i486 | 2 - hotspot/build/linux/platform_sparc | 2 - hotspot/build/solaris/makefiles/vm.make | 2 + hotspot/build/solaris/platform_amd64 | 2 - hotspot/build/solaris/platform_amd64.gcc | 2 - hotspot/build/solaris/platform_i486 | 2 - hotspot/build/solaris/platform_i486.gcc | 2 - hotspot/build/solaris/platform_sparc | 2 - hotspot/build/solaris/platform_sparc.gcc | 2 - hotspot/build/solaris/platform_sparcv9 | 4 +- hotspot/build/solaris/platform_sparcv9.gcc | 4 +- hotspot/build/windows/makefiles/vm.make | 1 + hotspot/build/windows/platform_amd64 | 4 +- hotspot/build/windows/platform_i486 | 5 +- .../src/cpu/sparc/vm/disassembler_sparc.cpp | 230 -------- .../src/cpu/sparc/vm/disassembler_sparc.hpp | 35 +- hotspot/src/cpu/x86/vm/disassembler_x86.cpp | 201 ------- hotspot/src/cpu/x86/vm/disassembler_x86.hpp | 28 +- hotspot/src/share/tools/hsdis/Makefile | 135 +++++ hotspot/src/share/tools/hsdis/README | 95 ++++ hotspot/src/share/tools/hsdis/hsdis-demo.c | 223 ++++++++ hotspot/src/share/tools/hsdis/hsdis.c | 499 ++++++++++++++++++ hotspot/src/share/tools/hsdis/hsdis.h | 67 +++ hotspot/src/share/vm/asm/codeBuffer.cpp | 1 + hotspot/src/share/vm/code/nmethod.cpp | 55 +- hotspot/src/share/vm/code/nmethod.hpp | 8 +- hotspot/src/share/vm/code/vmreg.cpp | 2 - hotspot/src/share/vm/code/vmreg.hpp | 10 +- .../src/share/vm/compiler/disassembler.cpp | 443 ++++++++++++++++ .../src/share/vm/compiler/disassembler.hpp | 59 +++ .../src/share/vm/compiler/disassemblerEnv.hpp | 35 -- hotspot/src/share/vm/compiler/oopMap.cpp | 15 +- hotspot/src/share/vm/compiler/oopMap.hpp | 6 +- hotspot/src/share/vm/includeDB_compiler1 | 2 +- hotspot/src/share/vm/includeDB_core | 42 +- hotspot/src/share/vm/opto/compile.cpp | 10 +- hotspot/src/share/vm/runtime/globals.hpp | 19 +- .../share/vm/runtime/stubCodeGenerator.cpp | 4 - hotspot/src/share/vm/utilities/ostream.cpp | 36 +- hotspot/src/share/vm/utilities/ostream.hpp | 3 +- 43 files changed, 1675 insertions(+), 629 deletions(-) delete mode 100644 hotspot/src/cpu/sparc/vm/disassembler_sparc.cpp delete mode 100644 hotspot/src/cpu/x86/vm/disassembler_x86.cpp create mode 100644 hotspot/src/share/tools/hsdis/Makefile create mode 100644 hotspot/src/share/tools/hsdis/README create mode 100644 hotspot/src/share/tools/hsdis/hsdis-demo.c create mode 100644 hotspot/src/share/tools/hsdis/hsdis.c create mode 100644 hotspot/src/share/tools/hsdis/hsdis.h create mode 100644 hotspot/src/share/vm/compiler/disassembler.cpp create mode 100644 hotspot/src/share/vm/compiler/disassembler.hpp delete mode 100644 hotspot/src/share/vm/compiler/disassemblerEnv.hpp diff --git a/hotspot/.hgignore b/hotspot/.hgignore index 8c4cff4cd1f..6798eb94087 100644 --- a/hotspot/.hgignore +++ b/hotspot/.hgignore @@ -168,3 +168,4 @@ ^build/linux/export-linux-x64/ ^dist/ ^nbproject/private/ +^src/share/tools/hsdis/bin/ diff --git a/hotspot/build/linux/makefiles/vm.make b/hotspot/build/linux/makefiles/vm.make index 567e6779145..72e6dbdd3dc 100644 --- a/hotspot/build/linux/makefiles/vm.make +++ b/hotspot/build/linux/makefiles/vm.make @@ -71,6 +71,7 @@ endif # The following variables are defined in the generated flags.make file. BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" JRE_VERSION = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" +HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\"" BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" @@ -81,6 +82,7 @@ CPPFLAGS = \ ${BUILD_VERSION} \ ${BUILD_TARGET} \ ${BUILD_USER} \ + ${HS_LIB_ARCH} \ ${JRE_VERSION} \ ${VM_DISTRO} diff --git a/hotspot/build/linux/platform_amd64 b/hotspot/build/linux/platform_amd64 index 2a76633d259..b612635958e 100644 --- a/hotspot/build/linux/platform_amd64 +++ b/hotspot/build/linux/platform_amd64 @@ -12,6 +12,4 @@ lib_arch = amd64 compiler = gcc -gnu_dis_arch = amd64 - sysdefs = -DLINUX -D_GNU_SOURCE -DAMD64 diff --git a/hotspot/build/linux/platform_i486 b/hotspot/build/linux/platform_i486 index 7f8b111675b..610ac91ce79 100644 --- a/hotspot/build/linux/platform_i486 +++ b/hotspot/build/linux/platform_i486 @@ -12,6 +12,4 @@ lib_arch = i386 compiler = gcc -gnu_dis_arch = i386 - sysdefs = -DLINUX -D_GNU_SOURCE -DIA32 diff --git a/hotspot/build/linux/platform_sparc b/hotspot/build/linux/platform_sparc index 2fda1971bd6..8d9e3ee7201 100644 --- a/hotspot/build/linux/platform_sparc +++ b/hotspot/build/linux/platform_sparc @@ -12,6 +12,4 @@ lib_arch = sparc compiler = gcc -gnu_dis_arch = sparc - sysdefs = -DLINUX -D_GNU_SOURCE -DSPARC diff --git a/hotspot/build/solaris/makefiles/vm.make b/hotspot/build/solaris/makefiles/vm.make index c1fa4643129..4d0df028840 100644 --- a/hotspot/build/solaris/makefiles/vm.make +++ b/hotspot/build/solaris/makefiles/vm.make @@ -63,6 +63,7 @@ endif # The following variables are defined in the generated flags.make file. BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" JRE_VERSION = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" +HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\"" BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" @@ -73,6 +74,7 @@ CPPFLAGS = \ ${BUILD_VERSION} \ ${BUILD_TARGET} \ ${BUILD_USER} \ + ${HS_LIB_ARCH} \ ${JRE_VERSION} \ ${VM_DISTRO} diff --git a/hotspot/build/solaris/platform_amd64 b/hotspot/build/solaris/platform_amd64 index 2cfe3d41681..f85242b1d30 100644 --- a/hotspot/build/solaris/platform_amd64 +++ b/hotspot/build/solaris/platform_amd64 @@ -12,6 +12,4 @@ lib_arch = amd64 compiler = sparcWorks -gnu_dis_arch = amd64 - sysdefs = -DSOLARIS -DSPARC_WORKS -DAMD64 diff --git a/hotspot/build/solaris/platform_amd64.gcc b/hotspot/build/solaris/platform_amd64.gcc index 57d25fa6f44..ebd495bca40 100644 --- a/hotspot/build/solaris/platform_amd64.gcc +++ b/hotspot/build/solaris/platform_amd64.gcc @@ -12,6 +12,4 @@ lib_arch = amd64 compiler = gcc -gnu_dis_arch = amd64 - sysdefs = -DSOLARIS -D_GNU_SOURCE -DAMD64 diff --git a/hotspot/build/solaris/platform_i486 b/hotspot/build/solaris/platform_i486 index c6902160b1f..91d4c5e7a64 100644 --- a/hotspot/build/solaris/platform_i486 +++ b/hotspot/build/solaris/platform_i486 @@ -12,6 +12,4 @@ lib_arch = i386 compiler = sparcWorks -gnu_dis_arch = i386 - sysdefs = -DSOLARIS -DSPARC_WORKS -DIA32 diff --git a/hotspot/build/solaris/platform_i486.gcc b/hotspot/build/solaris/platform_i486.gcc index 8d1d57ff596..61d55e1b59e 100644 --- a/hotspot/build/solaris/platform_i486.gcc +++ b/hotspot/build/solaris/platform_i486.gcc @@ -12,6 +12,4 @@ lib_arch = i386 compiler = gcc -gnu_dis_arch = i386 - sysdefs = -DSOLARIS -D_GNU_SOURCE -DIA32 diff --git a/hotspot/build/solaris/platform_sparc b/hotspot/build/solaris/platform_sparc index 4ff94c3ae68..424088ef53f 100644 --- a/hotspot/build/solaris/platform_sparc +++ b/hotspot/build/solaris/platform_sparc @@ -12,6 +12,4 @@ lib_arch = sparc compiler = sparcWorks -gnu_dis_arch = sparc - sysdefs = -DSOLARIS -DSPARC_WORKS -DSPARC diff --git a/hotspot/build/solaris/platform_sparc.gcc b/hotspot/build/solaris/platform_sparc.gcc index 87d42becfa3..9a900f49384 100644 --- a/hotspot/build/solaris/platform_sparc.gcc +++ b/hotspot/build/solaris/platform_sparc.gcc @@ -12,6 +12,4 @@ lib_arch = sparc compiler = gcc -gnu_dis_arch = sparc - sysdefs = -DSOLARIS -D_GNU_SOURCE -DSPARC diff --git a/hotspot/build/solaris/platform_sparcv9 b/hotspot/build/solaris/platform_sparcv9 index 4ff94c3ae68..a17dd08d29d 100644 --- a/hotspot/build/solaris/platform_sparcv9 +++ b/hotspot/build/solaris/platform_sparcv9 @@ -8,10 +8,8 @@ os_arch = solaris_sparc os_arch_model = solaris_sparc -lib_arch = sparc +lib_arch = sparcv9 compiler = sparcWorks -gnu_dis_arch = sparc - sysdefs = -DSOLARIS -DSPARC_WORKS -DSPARC diff --git a/hotspot/build/solaris/platform_sparcv9.gcc b/hotspot/build/solaris/platform_sparcv9.gcc index 87d42becfa3..2824381774b 100644 --- a/hotspot/build/solaris/platform_sparcv9.gcc +++ b/hotspot/build/solaris/platform_sparcv9.gcc @@ -8,10 +8,8 @@ os_arch = solaris_sparc os_arch_model = solaris_sparc -lib_arch = sparc +lib_arch = sparcv9 compiler = gcc -gnu_dis_arch = sparc - sysdefs = -DSOLARIS -D_GNU_SOURCE -DSPARC diff --git a/hotspot/build/windows/makefiles/vm.make b/hotspot/build/windows/makefiles/vm.make index ddfc8729678..c911ab261f0 100644 --- a/hotspot/build/windows/makefiles/vm.make +++ b/hotspot/build/windows/makefiles/vm.make @@ -58,6 +58,7 @@ CPP_FLAGS=$(CPP_FLAGS) /D "COMPILER1" /D "COMPILER2" # The following variables are defined in the generated local.make file. CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_RELEASE_VERSION=\"$(HS_BUILD_VER)\"" CPP_FLAGS=$(CPP_FLAGS) /D "JRE_RELEASE_VERSION=\"$(JRE_RELEASE_VER)\"" +CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_LIB_ARCH=\"$(BUILDARCH)\"" CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_TARGET=\"$(BUILD_FLAVOR)\"" CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\"" CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\"" diff --git a/hotspot/build/windows/platform_amd64 b/hotspot/build/windows/platform_amd64 index e19b4878163..49a326e5690 100644 --- a/hotspot/build/windows/platform_amd64 +++ b/hotspot/build/windows/platform_amd64 @@ -10,6 +10,6 @@ os_arch = windows_x86 os_arch_model = windows_x86_64 -compiler = visCPP +lib_arch = amd64 -gnu_dis_arch = amd64 +compiler = visCPP diff --git a/hotspot/build/windows/platform_i486 b/hotspot/build/windows/platform_i486 index a426305fb5d..bdb31681038 100644 --- a/hotspot/build/windows/platform_i486 +++ b/hotspot/build/windows/platform_i486 @@ -10,7 +10,6 @@ os_arch = windows_x86 os_arch_model = windows_x86_32 +lib_arch = i386 + compiler = visCPP - -gnu_dis_arch = i386 - diff --git a/hotspot/src/cpu/sparc/vm/disassembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/disassembler_sparc.cpp deleted file mode 100644 index fc7cc059798..00000000000 --- a/hotspot/src/cpu/sparc/vm/disassembler_sparc.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - */ - -# include "incls/_precompiled.incl" -# include "incls/_disassembler_sparc.cpp.incl" - -#ifndef PRODUCT - -#define SPARC_VERSION (VM_Version::v9_instructions_work()? \ - (VM_Version::v8_instructions_work()? "" : "9") : "8") - -// This routine is in the shared library: -typedef unsigned char* print_insn_sparc_t(unsigned char* start, DisassemblerEnv* env, - const char* sparc_version); - -void* Disassembler::_library = NULL; -dll_func Disassembler::_print_insn_sparc = NULL; - -bool Disassembler::load_library() { - if (_library == NULL) { - char buf[1024]; - char ebuf[1024]; - sprintf(buf, "disassembler%s", os::dll_file_extension()); - _library = hpi::dll_load(buf, ebuf, sizeof ebuf); - if (_library != NULL) { - tty->print_cr("Loaded disassembler"); - _print_insn_sparc = CAST_TO_FN_PTR(dll_func, hpi::dll_lookup(_library, "print_insn_sparc")); - } - } - return (_library != NULL) && (_print_insn_sparc != NULL); -} - - -class sparc_env : public DisassemblerEnv { - private: - nmethod* code; - outputStream* output; - const char* version; - - static void print_address(address value, outputStream* st); - - public: - sparc_env(nmethod* rcode, outputStream* routput) { - code = rcode; - output = routput; - version = SPARC_VERSION; - } - const char* sparc_version() { return version; } - void print_label(intptr_t value); - void print_raw(char* str) { output->print_raw(str); } - void print(char* format, ...); - char* string_for_offset(intptr_t value); - char* string_for_constant(unsigned char* pc, intptr_t value, int is_decimal); -}; - - -void sparc_env::print_address(address adr, outputStream* st) { - if (!Universe::is_fully_initialized()) { - st->print(INTPTR_FORMAT, (intptr_t)adr); - return; - } - if (StubRoutines::contains(adr)) { - StubCodeDesc *desc = StubCodeDesc::desc_for(adr); - if (desc == NULL) - desc = StubCodeDesc::desc_for(adr + frame::pc_return_offset); - if (desc == NULL) - st->print("Unknown stub at " INTPTR_FORMAT, adr); - else { - st->print("Stub::%s", desc->name()); - if (desc->begin() != adr) - st->print("%+d 0x%p",adr - desc->begin(), adr); - else if (WizardMode) st->print(" " INTPTR_FORMAT, adr); - } - } else { - BarrierSet* bs = Universe::heap()->barrier_set(); - if (bs->kind() == BarrierSet::CardTableModRef && - adr == (address)((CardTableModRefBS*)(bs))->byte_map_base) { - st->print("word_map_base"); - if (WizardMode) st->print(" " INTPTR_FORMAT, (intptr_t)adr); - } else { - st->print(INTPTR_FORMAT, (intptr_t)adr); - } - } -} - - -// called by the disassembler to print out jump addresses -void sparc_env::print_label(intptr_t value) { - print_address((address) value, output); -} - -void sparc_env::print(char* format, ...) { - va_list ap; - va_start(ap, format); - output->vprint(format, ap); - va_end(ap); -} - -char* sparc_env::string_for_offset(intptr_t value) { - stringStream st; - print_address((address) value, &st); - return st.as_string(); -} - -char* sparc_env::string_for_constant(unsigned char* pc, intptr_t value, int is_decimal) { - stringStream st; - oop obj; - if (code && (obj = code->embeddedOop_at(pc)) != NULL) { - obj->print_value_on(&st); - } else - { - print_address((address) value, &st); - } - return st.as_string(); -} - - -address Disassembler::decode_instruction(address start, DisassemblerEnv* env) { - const char* version = ((sparc_env*)env)->sparc_version(); - return ((print_insn_sparc_t*) _print_insn_sparc)(start, env, version); -} - - -const int show_bytes = false; // for disassembler debugging - - -void Disassembler::decode(CodeBlob* cb, outputStream* st) { - st = st ? st : tty; - st->print_cr("Decoding CodeBlob " INTPTR_FORMAT, cb); - decode(cb->instructions_begin(), cb->instructions_end(), st); -} - - -void Disassembler::decode(u_char* begin, u_char* end, outputStream* st) { - assert ((((intptr_t)begin | (intptr_t)end) % sizeof(int) == 0), "misaligned insn addr"); - st = st ? st : tty; - if (!load_library()) { - st->print_cr("Could not load disassembler"); - return; - } - sparc_env env(NULL, st); - unsigned char* p = (unsigned char*) begin; - CodeBlob* cb = CodeCache::find_blob_unsafe(begin); - while (p < (unsigned char*) end && p) { - if (cb != NULL) { - cb->print_block_comment(st, (intptr_t)(p - cb->instructions_begin())); - } - - unsigned char* p0 = p; - st->print(INTPTR_FORMAT ": ", p); - p = decode_instruction(p, &env); - if (show_bytes && p) { - st->print("\t\t\t"); - while (p0 < p) { st->print("%08lx ", *(int*)p0); p0 += sizeof(int); } - } - st->cr(); - } -} - - -void Disassembler::decode(nmethod* nm, outputStream* st) { - st = st ? st : tty; - - st->print_cr("Decoding compiled method " INTPTR_FORMAT ":", nm); - st->print("Code:"); - st->cr(); - - if (!load_library()) { - st->print_cr("Could not load disassembler"); - return; - } - sparc_env env(nm, st); - unsigned char* p = nm->instructions_begin(); - unsigned char* end = nm->instructions_end(); - assert ((((intptr_t)p | (intptr_t)end) % sizeof(int) == 0), "misaligned insn addr"); - - unsigned char *p1 = p; - int total_bucket_count = 0; - while (p1 < end && p1) { - unsigned char *p0 = p1; - ++p1; - address bucket_pc = FlatProfiler::bucket_start_for(p1); - if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1) - total_bucket_count += FlatProfiler::bucket_count_for(p0); - } - - while (p < end && p) { - if (p == nm->entry_point()) st->print_cr("[Entry Point]"); - if (p == nm->verified_entry_point()) st->print_cr("[Verified Entry Point]"); - if (p == nm->exception_begin()) st->print_cr("[Exception Handler]"); - if (p == nm->stub_begin()) st->print_cr("[Stub Code]"); - if (p == nm->consts_begin()) st->print_cr("[Constants]"); - nm->print_block_comment(st, (intptr_t)(p - nm->instructions_begin())); - unsigned char* p0 = p; - st->print(" " INTPTR_FORMAT ": ", p); - p = decode_instruction(p, &env); - nm->print_code_comment_on(st, 40, p0, p); - st->cr(); - // Output pc bucket ticks if we have any - address bucket_pc = FlatProfiler::bucket_start_for(p); - if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p) { - int bucket_count = FlatProfiler::bucket_count_for(p0); - tty->print_cr("%3.1f%% [%d]", bucket_count*100.0/total_bucket_count, bucket_count); - tty->cr(); - } - } -} - -#endif // PRODUCT diff --git a/hotspot/src/cpu/sparc/vm/disassembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/disassembler_sparc.hpp index 827488b8e20..343f96d968d 100644 --- a/hotspot/src/cpu/sparc/vm/disassembler_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/disassembler_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,30 +22,11 @@ * */ -// The disassembler prints out sparc code annotated -// with Java specific information. + static int pd_instruction_alignment() { + return sizeof(int); + } -class Disassembler { -#ifndef PRODUCT - private: - // points to the library. - static void* _library; - // points to the print_insn_sparc function. - static dll_func _print_insn_sparc; - // tries to load library and return whether it succedded. - static bool load_library(); - // decodes one instruction and return the start of the next instruction. - static address decode_instruction(address start, DisassemblerEnv* env); -#endif - public: - static void decode(CodeBlob *cb, outputStream* st = NULL) PRODUCT_RETURN; - static void decode(nmethod* nm, outputStream* st = NULL) PRODUCT_RETURN; - static void decode(u_char* begin, u_char* end, outputStream* st = NULL) PRODUCT_RETURN; -}; - -//Reconciliation History -// 1.9 98/04/29 10:45:51 disassembler_i486.hpp -// 1.10 98/05/11 16:47:20 disassembler_i486.hpp -// 1.12 99/06/22 16:37:37 disassembler_i486.hpp -// 1.13 99/08/06 10:09:04 disassembler_i486.hpp -//End + static const char* pd_cpu_opts() { + return (VM_Version::v9_instructions_work()? + (VM_Version::v8_instructions_work()? "" : "v9only") : "v8only"); + } diff --git a/hotspot/src/cpu/x86/vm/disassembler_x86.cpp b/hotspot/src/cpu/x86/vm/disassembler_x86.cpp deleted file mode 100644 index 9e75de3548a..00000000000 --- a/hotspot/src/cpu/x86/vm/disassembler_x86.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - */ - -# include "incls/_precompiled.incl" -# include "incls/_disassembler_x86.cpp.incl" - -#ifndef PRODUCT - -void* Disassembler::_library = NULL; -Disassembler::decode_func Disassembler::_decode_instruction = NULL; - -bool Disassembler::load_library() { - if (_library == NULL) { - char buf[1024]; - char ebuf[1024]; - sprintf(buf, "disassembler%s", os::dll_file_extension()); - _library = hpi::dll_load(buf, ebuf, sizeof ebuf); - if (_library != NULL) { - tty->print_cr("Loaded disassembler"); - _decode_instruction = CAST_TO_FN_PTR(Disassembler::decode_func, hpi::dll_lookup(_library, "decode_instruction")); - } - } - return (_library != NULL) && (_decode_instruction != NULL); -} - -class x86_env : public DisassemblerEnv { - private: - nmethod* code; - outputStream* output; - public: - x86_env(nmethod* rcode, outputStream* routput) { - code = rcode; - output = routput; - } - void print_label(intptr_t value); - void print_raw(char* str) { output->print_raw(str); } - void print(char* format, ...); - char* string_for_offset(intptr_t value); - char* string_for_constant(unsigned char* pc, intptr_t value, int is_decimal); -}; - - -void x86_env::print_label(intptr_t value) { - if (!Universe::is_fully_initialized()) { - output->print(INTPTR_FORMAT, value); - return; - } - address adr = (address) value; - if (StubRoutines::contains(adr)) { - StubCodeDesc* desc = StubCodeDesc::desc_for(adr); - const char * desc_name = "unknown stub"; - if (desc != NULL) { - desc_name = desc->name(); - } - output->print("Stub::%s", desc_name); - if (WizardMode) output->print(" " INTPTR_FORMAT, value); - } else { - output->print(INTPTR_FORMAT, value); - } -} - -void x86_env::print(char* format, ...) { - va_list ap; - va_start(ap, format); - output->vprint(format, ap); - va_end(ap); -} - -char* x86_env::string_for_offset(intptr_t value) { - stringStream st; - if (!Universe::is_fully_initialized()) { - st.print(INTX_FORMAT, value); - return st.as_string(); - } - BarrierSet* bs = Universe::heap()->barrier_set(); - BarrierSet::Name bsn = bs->kind(); - if (bs->kind() == BarrierSet::CardTableModRef && - (jbyte*) value == ((CardTableModRefBS*)(bs))->byte_map_base) { - st.print("word_map_base"); - } else { - st.print(INTX_FORMAT, value); - } - return st.as_string(); -} - -char* x86_env::string_for_constant(unsigned char* pc, intptr_t value, int is_decimal) { - stringStream st; - oop obj = NULL; - if (code && ((obj = code->embeddedOop_at(pc)) != NULL)) { - obj->print_value_on(&st); - } else { - if (is_decimal == 1) { - st.print(INTX_FORMAT, value); - } else { - st.print(INTPTR_FORMAT, value); - } - } - return st.as_string(); -} - - - -address Disassembler::decode_instruction(address start, DisassemblerEnv* env) { - return ((decode_func) _decode_instruction)(start, env); -} - - -void Disassembler::decode(CodeBlob* cb, outputStream* st) { - st = st ? st : tty; - st->print_cr("Decoding CodeBlob " INTPTR_FORMAT, cb); - decode(cb->instructions_begin(), cb->instructions_end(), st); -} - - -void Disassembler::decode(u_char* begin, u_char* end, outputStream* st) { - st = st ? st : tty; - - const int show_bytes = false; // for disassembler debugging - - if (!load_library()) { - st->print_cr("Could not load disassembler"); - return; - } - - x86_env env(NULL, st); - unsigned char* p = (unsigned char*) begin; - CodeBlob* cb = CodeCache::find_blob_unsafe(begin); - while (p < (unsigned char*) end) { - if (cb != NULL) { - cb->print_block_comment(st, (intptr_t)(p - cb->instructions_begin())); - } - - unsigned char* p0 = p; - st->print(" " INTPTR_FORMAT ": ", p); - p = decode_instruction(p, &env); - if (show_bytes) { - st->print("\t\t\t"); - while (p0 < p) st->print("%x ", *p0++); - } - st->cr(); - } -} - - -void Disassembler::decode(nmethod* nm, outputStream* st) { - st = st ? st : tty; - - st->print_cr("Decoding compiled method " INTPTR_FORMAT ":", nm); - st->print("Code:"); - st->cr(); - - if (!load_library()) { - st->print_cr("Could not load disassembler"); - return; - } - x86_env env(nm, st); - unsigned char* p = nm->instructions_begin(); - unsigned char* end = nm->instructions_end(); - while (p < end) { - if (p == nm->entry_point()) st->print_cr("[Entry Point]"); - if (p == nm->verified_entry_point()) st->print_cr("[Verified Entry Point]"); - if (p == nm->exception_begin()) st->print_cr("[Exception Handler]"); - if (p == nm->stub_begin()) st->print_cr("[Stub Code]"); - if (p == nm->consts_begin()) st->print_cr("[Constants]"); - nm->print_block_comment(st, (intptr_t)(p - nm->instructions_begin())); - unsigned char* p0 = p; - st->print(" " INTPTR_FORMAT ": ", p); - p = decode_instruction(p, &env); - nm->print_code_comment_on(st, 40, p0, p); - st->cr(); - // Output pc bucket ticks if we have any - address bucket_pc = FlatProfiler::bucket_start_for(p); - if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p) { - int bucket_count = FlatProfiler::bucket_count_for(bucket_pc); - tty->print_cr("[%d]", bucket_count); - } - } -} - -#endif // PRODUCT diff --git a/hotspot/src/cpu/x86/vm/disassembler_x86.hpp b/hotspot/src/cpu/x86/vm/disassembler_x86.hpp index 75da808aedb..bdf7d3500b0 100644 --- a/hotspot/src/cpu/x86/vm/disassembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/disassembler_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,24 +22,10 @@ * */ -// The disassembler prints out intel 386 code annotated -// with Java specific information. + static int pd_instruction_alignment() { + return 1; + } -class Disassembler { -#ifndef PRODUCT - private: - typedef address (*decode_func)(address start, DisassemblerEnv* env); - // points the library. - static void* _library; - // points to the decode function. - static decode_func _decode_instruction; - // tries to load library and return whether it succedded. - static bool load_library(); - // decodes one instruction and return the start of the next instruction. - static address decode_instruction(address start, DisassemblerEnv* env); -#endif - public: - static void decode(CodeBlob *cb, outputStream* st = NULL) PRODUCT_RETURN; - static void decode(nmethod* nm, outputStream* st = NULL) PRODUCT_RETURN; - static void decode(u_char* begin, u_char* end, outputStream* st = NULL) PRODUCT_RETURN; -}; + static const char* pd_cpu_opts() { + return ""; + } diff --git a/hotspot/src/share/tools/hsdis/Makefile b/hotspot/src/share/tools/hsdis/Makefile new file mode 100644 index 00000000000..6bdf4b8151c --- /dev/null +++ b/hotspot/src/share/tools/hsdis/Makefile @@ -0,0 +1,135 @@ +# +# Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# +# + +# Single gnu makefile for solaris, linux and windows (windows requires mks or +# cygwin). + +ifeq ($(BINUTILS),) +# Pop all the way out of the workspace to look for binutils. +# ...You probably want to override this setting. +BINUTILS = $(shell cd ../../../../..;pwd)/binutils-2.17-$(LIBARCH) +endif + +# Default arch; it is changed below as needed. +ARCH = i386 +OS = $(shell uname) + +CPPFLAGS += -I$(BINUTILS)/include -I$(BINUTILS)/bfd +CPPFLAGS += -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -DLIBARCH_$(LIBARCH) +CPPFLAGS += -DHOTSPOT_OS=\"$(OS)\" -DOS_$(OS) + +## OS = SunOS ## +ifeq ($(OS),SunOS) +ARCH = $(shell uname -p) +OS = solaris +CC = cc +CCFLAGS += -Kpic -g +CCFLAGS/amd64 += -xarch=amd64 +CCFLAGS/sparcv9 += -xarch=v9 +CCFLAGS += $(CCFLAGS/$(LIBARCH)) +DLDFLAGS += -G +OUTFLAGS += -o $@ +LIB_EXT = .so +else +## OS = Linux ## +ifeq ($(OS),Linux) +CPU = $(shell uname -m) +ifeq ($(CPU),ia64) +ARCH = ia64 +else +ifeq ($(CPU),x86_64) +CCFLAGS += -fPIC +endif # x86_64 +endif # ia64 +OS = linux +CC = gcc +CCFLAGS += -O +DLDFLAGS += -shared +OUTFLAGS += -o $@ +LIB_EXT = .so +CPPFLAGS += -Iinclude -Iinclude/$(OS)_$(ARCH)/ +## OS = Windows ## +else # !SunOS, !Linux => Windows +OS = win +CC = cl +#CPPFLAGS += /D"WIN32" /D"_WINDOWS" /D"DEBUG" /D"NDEBUG" +CCFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi- +CCFLAGS += -Iinclude -Iinclude/gnu -Iinclude/$(OS)_$(ARCH) +CCFLAGS += /D"HOTSPOT_LIB_ARCH=\"$(LIBARCH)\"" +DLDFLAGS += /dll /subsystem:windows /incremental:no \ + /export:decode_instruction +OUTFLAGS += /link /out:$@ +LIB_EXT = .dll +endif # Linux +endif # SunOS + +LIBARCH = $(ARCH) +ifdef LP64 +LIBARCH64/sparc = sparcv9 +LIBARCH64/i386 = amd64 +LIBARCH64 = $(LIBARCH64/$(ARCH)) +ifneq ($(LIBARCH64),) +LIBARCH = $(LIBARCH64) +endif # LIBARCH64/$(ARCH) +endif # LP64 + +TARGET_DIR = bin/$(OS) +TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT) + +SOURCE = hsdis.c + +LIBRARIES = $(BINUTILS)/bfd/libbfd.a \ + $(BINUTILS)/opcodes/libopcodes.a \ + $(BINUTILS)/libiberty/libiberty.a + +DEMO_TARGET = $(TARGET_DIR)/hsdis-demo-$(LIBARCH) +DEMO_SOURCE = hsdis-demo.c + +.PHONY: all clean demo both + +all: $(TARGET) demo + +both: all all64 + +%64: + $(MAKE) LP64=1 ${@:%64=%} + +demo: $(TARGET) $(DEMO_TARGET) + +$(LIBRARIES): + @echo "*** Please build binutils first; see ./README: ***" + @sed < ./README '1,/__________/d' | head -20 + @echo "..."; exit 1 + +$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR) + $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) + +$(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR) + $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(DEMO_SOURCE) $(LDFLAGS) + +$(TARGET_DIR): + [ -d $@ ] || mkdir -p $@ + +clean: + rm -rf $(TARGET_DIR) diff --git a/hotspot/src/share/tools/hsdis/README b/hotspot/src/share/tools/hsdis/README new file mode 100644 index 00000000000..76c92a44ed8 --- /dev/null +++ b/hotspot/src/share/tools/hsdis/README @@ -0,0 +1,95 @@ +Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + +This code is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 only, as +published by the Free Software Foundation. + +This code is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +version 2 for more details (a copy is included in the LICENSE file that +accompanied this code). + +You should have received a copy of the GNU General Public License version +2 along with this work; if not, write to the Free Software Foundation, +Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +CA 95054 USA or visit www.sun.com if you need additional information or +have any questions. + +________________________________________________________________________ + +'hsdis': A HotSpot plugin for disassembling dynamically generated code. + +The files in this directory (Makefile, hsdis.[ch], hsdis-demo.c) +are built independently of the HotSpot JVM. + +To use the plugin with a JVM, you need a new version that can load it. +If the product mode of your JVM does not accept -XX:+PrintAssembly, +you do not have a version that is new enough. + +* Building + +To build this project you need a build of Gnu binutils to link against. +It is known to work with binutils 2.17. + +The makefile looks for this build in $BINUTILS, or (if that is not set), +in .../binutils-2.17-$LIBARCH, where LIBARCH (as in HotSpot) is one of +the jre subdirectory keywords i386, amd64, sparc, sparcv9, etc. + +To build Gnu binutils, first download a copy of the software: + http://directory.fsf.org/project/binutils/ + +Unpack the binutils tarball into an empty directory: + chdir ../../../../.. + tar -xzf - < ../binutils-2.17.tar.gz + mv binutils-2.17 binutils-2.17-i386 #or binutils-2.17-sparc + cd binutils-2.17-i386 + +From inside that directory, run configure and make: + ( export CFLAGS='-fPIC' + ./configure i386-pc-elf ) + gnumake + +(Leave out or change the argument to configure if not on an i386 system.) + +Next, untar again into another empty directory for the LP64 version: + chdir .. + tar -xzf - < ../binutils-2.17.tar.gz + mv binutils-2.17 binutils-2.17-amd64 #or binutils-2.17-sparcv9 + cd binutils-2.17-amd64 + +From inside that directory, run configure for LP64 and make: + ( export ac_cv_c_bigendian=no CFLAGS='-m64 -fPIC' LDFLAGS=-m64 + ./configure amd64-pc-elf ) + gnumake + +The -fPIC option is needed because the generated code will be +linked into the hsdid-$LIBARCH.so binary. If you miss the +option, the JVM will fail to load the disassembler. + +You probably want two builds, one for 32 and one for 64 bits. +To build the 64-bit variation of a platforn, add LP64=1 to +the make command line for hsdis. + +So, go back to the hsdis project and build: + chdir .../hsdis + gnumake + gnumake LP64=1 + +* Installing + +Products are named like bin/$OS/hsdis-$LIBARCH.so. +You can install them on your LD_LIBRARY_PATH, +or inside of your JRE next to $LIBARCH/libjvm.so. + +Now test: + export LD_LIBRARY_PATH .../hsdis/bin/solaris:$LD_LIBRARY_PATH + dargs='-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly' + dargs=$dargs' -XX:PrintAssemblyOptions=hsdis-print-bytes' + java $dargs -Xbatch CompileCommand=print,*String.hashCode HelloWorld + +If the product mode of the JVM does not accept -XX:+PrintAssembly, +you do not have a version new enough to use the hsdis plugin. diff --git a/hotspot/src/share/tools/hsdis/hsdis-demo.c b/hotspot/src/share/tools/hsdis/hsdis-demo.c new file mode 100644 index 00000000000..adea76e63d7 --- /dev/null +++ b/hotspot/src/share/tools/hsdis/hsdis-demo.c @@ -0,0 +1,223 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +/* hsdis-demo.c -- dump a range of addresses as native instructions + This demonstrates the protocol required by the HotSpot PrintAssembly option. +*/ + +#include "hsdis.h" + +#include "stdio.h" +#include "stdlib.h" +#include "string.h" + +void greet(const char*); +void disassemble(void*, void*); +void end_of_file(); + +const char* options = NULL; +int raw = 0; +int xml = 0; + +int main(int ac, char** av) { + int greeted = 0; + int i; + for (i = 1; i < ac; i++) { + const char* arg = av[i]; + if (arg[0] == '-') { + if (!strcmp(arg, "-xml")) + xml ^= 1; + else if (!strcmp(arg, "-raw")) + raw ^= 1; + else if (!strncmp(arg, "-options=", 9)) + options = arg+9; + else + { printf("Usage: %s [-xml] [name...]\n"); exit(2); } + continue; + } + greet(arg); + greeted = 1; + } + if (!greeted) + greet("world"); + printf("...And now for something completely different:\n"); + disassemble((void*) &main, (void*) &end_of_file); + printf("Cheers!\n"); +} + +void greet(const char* whom) { + printf("Hello, %s!\n", whom); +} + +void end_of_file() { } + +/* don't disassemble after this point... */ + +#include "dlfcn.h" + +#ifdef HOTSPOT_LIB_ARCH +#define LIBARCH HOTSPOT_LIB_ARCH +#endif +#ifdef HOTSPOT_OS +#define OS HOTSPOT_OS +#endif + +#define DECODE_INSTRUCTIONS_NAME "decode_instructions" +#define HSDIS_NAME "hsdis" +static void* decode_instructions_pv = 0; +static const char* hsdis_path[] = { + HSDIS_NAME".so", +#ifdef OS + "bin/"OS"/"HSDIS_NAME".so", +#endif +#ifdef LIBARCH + HSDIS_NAME"-"LIBARCH".so", +#ifdef OS + "bin/"OS"/"HSDIS_NAME"-"LIBARCH".so", +#endif +#endif + NULL +}; + +static const char* load_decode_instructions() { + void* dllib = NULL; + const char* *next_in_path = hsdis_path; + while (1) { + decode_instructions_pv = dlsym(dllib, DECODE_INSTRUCTIONS_NAME); + if (decode_instructions_pv != NULL) + return NULL; + if (dllib != NULL) + return "plugin does not defined "DECODE_INSTRUCTIONS_NAME; + for (dllib = NULL; dllib == NULL; ) { + const char* next_lib = (*next_in_path++); + if (next_lib == NULL) + return "cannot find plugin "HSDIS_NAME".so"; + dllib = dlopen(next_lib, RTLD_LAZY); + } + } +} + + +static const char* lookup(void* addr) { +#define CHECK_NAME(fn) \ + if (addr == (void*) &fn) return #fn; + + CHECK_NAME(main); + CHECK_NAME(greet); + return NULL; +} + +/* does the event match the tag, followed by a null, space, or slash? */ +#define MATCH(event, tag) \ + (!strncmp(event, tag, sizeof(tag)-1) && \ + (!event[sizeof(tag)-1] || strchr(" /", event[sizeof(tag)-1]))) + + +static const char event_cookie[] = "event_cookie"; /* demo placeholder */ +static void* handle_event(void* cookie, const char* event, void* arg) { +#define NS_DEMO "demo:" + if (cookie != event_cookie) + printf("*** bad event cookie %p != %p\n", cookie, event_cookie); + + if (xml) { + /* We could almost do a printf(event, arg), + but for the sake of a better demo, + we dress the result up as valid XML. + */ + const char* fmt = strchr(event, ' '); + int evlen = (fmt ? fmt - event : strlen(event)); + if (!fmt) { + if (event[0] != '/') { + printf("<"NS_DEMO"%.*s>", evlen, event); + } else { + printf("", evlen-1, event+1); + } + } else { + if (event[0] != '/') { + printf("<"NS_DEMO"%.*s", evlen, event); + printf(fmt, arg); + printf(">"); + } else { + printf("<"NS_DEMO"%.*s_done", evlen-1, event+1); + printf(fmt, arg); + printf("/>", evlen-1, event+1); + } + } + } + + if (MATCH(event, "insn")) { + const char* name = lookup(arg); + if (name) printf("%s:\n", name); + + /* basic action for : */ + printf(" %p\t", arg); + + } else if (MATCH(event, "/insn")) { + /* basic action for : + (none, plugin puts the newline for us + */ + + } else if (MATCH(event, "mach")) { + printf("Decoding for CPU '%s'\n", (char*) arg); + + } else if (MATCH(event, "addr")) { + /* basic action for : */ + const char* name = lookup(arg); + if (name) { + printf("&%s (%p)", name, arg); + /* return non-null to notify hsdis not to print the addr */ + return arg; + } + } + + /* null return is always safe; can mean "I ignored it" */ + return NULL; +} + +#define fprintf_callback \ + (decode_instructions_printf_callback_ftype)&fprintf + +void disassemble(void* from, void* to) { + const char* err = load_decode_instructions(); + if (err != NULL) { + printf("%s: %s\n", err, dlerror()); + exit(1); + } + printf("Decoding from %p to %p...\n", from, to); + decode_instructions_ftype decode_instructions + = (decode_instructions_ftype) decode_instructions_pv; + void* res; + if (raw && xml) { + res = (*decode_instructions)(from, to, NULL, stdout, NULL, stdout, options); + } else if (raw) { + res = (*decode_instructions)(from, to, NULL, NULL, NULL, stdout, options); + } else { + res = (*decode_instructions)(from, to, + handle_event, (void*) event_cookie, + fprintf_callback, stdout, + options); + } + if (res != to) + printf("*** Result was %p!\n", res); +} diff --git a/hotspot/src/share/tools/hsdis/hsdis.c b/hotspot/src/share/tools/hsdis/hsdis.c new file mode 100644 index 00000000000..75b7efe2638 --- /dev/null +++ b/hotspot/src/share/tools/hsdis/hsdis.c @@ -0,0 +1,499 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +/* hsdis.c -- dump a range of addresses as native instructions + This implements the plugin protocol required by the + HotSpot PrintAssembly option. +*/ + +#include "hsdis.h" + +#include +#include +#include +#include + +#ifndef bool +#define bool int +#define true 1 +#define false 0 +#endif /*bool*/ + +/* short names for stuff in hsdis.h */ +typedef decode_instructions_event_callback_ftype event_callback_t; +typedef decode_instructions_printf_callback_ftype printf_callback_t; + +/* disassemble_info.application_data object */ +struct hsdis_app_data { + /* the arguments to decode_instructions */ + uintptr_t start; uintptr_t end; + event_callback_t event_callback; void* event_stream; + printf_callback_t printf_callback; void* printf_stream; + bool losing; + + /* the architecture being disassembled */ + const char* arch_name; + const bfd_arch_info_type* arch_info; + + /* the disassembler we are going to use: */ + disassembler_ftype dfn; + struct disassemble_info dinfo; /* the actual struct! */ + + char mach_option[64]; + char insn_options[256]; +}; + +#define DECL_APP_DATA(dinfo) \ + struct hsdis_app_data* app_data = (struct hsdis_app_data*) (dinfo)->application_data + +#define DECL_EVENT_CALLBACK(app_data) \ + event_callback_t event_callback = (app_data)->event_callback; \ + void* event_stream = (app_data)->event_stream + +#define DECL_PRINTF_CALLBACK(app_data) \ + printf_callback_t printf_callback = (app_data)->printf_callback; \ + void* printf_stream = (app_data)->printf_stream + + +static void print_help(struct hsdis_app_data* app_data, + const char* msg, const char* arg); +static void setup_app_data(struct hsdis_app_data* app_data, + const char* options); +static const char* format_insn_close(const char* close, + disassemble_info* dinfo, + char* buf, size_t bufsize); + +void* +#ifdef DLL_ENTRY + DLL_ENTRY +#endif +decode_instructions(void* start_pv, void* end_pv, + event_callback_t event_callback_arg, void* event_stream_arg, + printf_callback_t printf_callback_arg, void* printf_stream_arg, + const char* options) { + struct hsdis_app_data app_data; + memset(&app_data, 0, sizeof(app_data)); + app_data.start = (uintptr_t) start_pv; + app_data.end = (uintptr_t) end_pv; + app_data.event_callback = event_callback_arg; + app_data.event_stream = event_stream_arg; + app_data.printf_callback = printf_callback_arg; + app_data.printf_stream = printf_stream_arg; + + setup_app_data(&app_data, options); + char buf[128]; + + { + /* now reload everything from app_data: */ + DECL_EVENT_CALLBACK(&app_data); + DECL_PRINTF_CALLBACK(&app_data); + uintptr_t start = app_data.start; + uintptr_t end = app_data.end; + uintptr_t p = start; + + (*event_callback)(event_stream, "insns", (void*)start); + + (*event_callback)(event_stream, "mach name='%s'", + (void*) app_data.arch_info->printable_name); + if (app_data.dinfo.bytes_per_line != 0) { + (*event_callback)(event_stream, "format bytes-per-line='%p'/", + (void*)(intptr_t) app_data.dinfo.bytes_per_line); + } + + while (p < end && !app_data.losing) { + (*event_callback)(event_stream, "insn", (void*) p); + + /* reset certain state, so we can read it with confidence */ + app_data.dinfo.insn_info_valid = 0; + app_data.dinfo.branch_delay_insns = 0; + app_data.dinfo.data_size = 0; + app_data.dinfo.insn_type = 0; + + int size = (*app_data.dfn)((bfd_vma) p, &app_data.dinfo); + + if (size > 0) p += size; + else app_data.losing = true; + + const char* insn_close = format_insn_close("/insn", &app_data.dinfo, + buf, sizeof(buf)); + (*event_callback)(event_stream, insn_close, (void*) p); + + /* follow each complete insn by a nice newline */ + (*printf_callback)(printf_stream, "\n"); + } + + (*event_callback)(event_stream, "/insns", (void*) p); + return (void*) p; + } +} + +/* take the address of the function, for luck, and also test the typedef: */ +const decode_instructions_ftype decode_instructions_address = &decode_instructions; + +static const char* format_insn_close(const char* close, + disassemble_info* dinfo, + char* buf, size_t bufsize) { + if (!dinfo->insn_info_valid) + return close; + enum dis_insn_type itype = dinfo->insn_type; + int dsize = dinfo->data_size, delays = dinfo->branch_delay_insns; + if ((itype == dis_nonbranch && (dsize | delays) == 0) + || (strlen(close) + 3*20 > bufsize)) + return close; + + const char* type = "unknown"; + switch (itype) { + case dis_nonbranch: type = NULL; break; + case dis_branch: type = "branch"; break; + case dis_condbranch: type = "condbranch"; break; + case dis_jsr: type = "jsr"; break; + case dis_condjsr: type = "condjsr"; break; + case dis_dref: type = "dref"; break; + case dis_dref2: type = "dref2"; break; + } + + strcpy(buf, close); + char* p = buf; + if (type) sprintf(p += strlen(p), " type='%s'", type); + if (dsize) sprintf(p += strlen(p), " dsize='%d'", dsize); + if (delays) sprintf(p += strlen(p), " delay='%d'", delays); + return buf; +} + +/* handler functions */ + +static int +hsdis_read_memory_func(bfd_vma memaddr, + bfd_byte* myaddr, + unsigned int length, + struct disassemble_info* dinfo) { + uintptr_t memaddr_p = (uintptr_t) memaddr; + DECL_APP_DATA(dinfo); + if (memaddr_p + length > app_data->end) { + /* read is out of bounds */ + return EIO; + } else { + memcpy(myaddr, (bfd_byte*) memaddr_p, length); + return 0; + } +} + +static void +hsdis_print_address_func(bfd_vma vma, struct disassemble_info* dinfo) { + /* the actual value to print: */ + void* addr_value = (void*) (uintptr_t) vma; + DECL_APP_DATA(dinfo); + DECL_EVENT_CALLBACK(app_data); + + /* issue the event: */ + void* result = + (*event_callback)(event_stream, "addr/", addr_value); + if (result == NULL) { + /* event declined */ + generic_print_address(vma, dinfo); + } +} + + +/* configuration */ + +static void set_optional_callbacks(struct hsdis_app_data* app_data); +static void parse_caller_options(struct hsdis_app_data* app_data, + const char* caller_options); +static const char* native_arch_name(); +static enum bfd_endian native_endian(); +static const bfd_arch_info_type* find_arch_info(const char* arch_nane); +static bfd* get_native_bfd(const bfd_arch_info_type* arch_info, + /* to avoid malloc: */ + bfd* empty_bfd, bfd_target* empty_xvec); +static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, + void *stream, + fprintf_ftype fprintf_func, + bfd* bfd, + char* disassembler_options); +static void parse_fake_insn(disassembler_ftype dfn, + struct disassemble_info* dinfo); + +static void setup_app_data(struct hsdis_app_data* app_data, + const char* caller_options) { + /* Make reasonable defaults for null callbacks. + A non-null stream for a null callback is assumed to be a FILE* for output. + Events are rendered as XML. + */ + set_optional_callbacks(app_data); + + /* Look into caller_options for anything interesting. */ + if (caller_options != NULL) + parse_caller_options(app_data, caller_options); + + /* Discover which architecture we are going to disassemble. */ + app_data->arch_name = &app_data->mach_option[0]; + if (app_data->arch_name[0] == '\0') + app_data->arch_name = native_arch_name(); + app_data->arch_info = find_arch_info(app_data->arch_name); + + /* Make a fake bfd to hold the arch. and byteorder info. */ + struct { + bfd_target empty_xvec; + bfd empty_bfd; + } buf; + bfd* native_bfd = get_native_bfd(app_data->arch_info, + /* to avoid malloc: */ + &buf.empty_bfd, &buf.empty_xvec); + init_disassemble_info_from_bfd(&app_data->dinfo, + app_data->printf_stream, + app_data->printf_callback, + native_bfd, + app_data->insn_options); + + /* Finish linking together the various callback blocks. */ + app_data->dinfo.application_data = (void*) app_data; + app_data->dfn = disassembler(native_bfd); + app_data->dinfo.print_address_func = hsdis_print_address_func; + app_data->dinfo.read_memory_func = hsdis_read_memory_func; + + if (app_data->dfn == NULL) { + const char* bad = app_data->arch_name; + static bool complained; + if (bad == &app_data->mach_option[0]) + print_help(app_data, "bad mach=%s", bad); + else if (!complained) + print_help(app_data, "bad native mach=%s; please port hsdis to this platform", bad); + complained = true; + /* must bail out */ + app_data->losing = true; + return; + } + + parse_fake_insn(app_data->dfn, &app_data->dinfo); +} + + +/* ignore all events, return a null */ +static void* null_event_callback(void* ignore_stream, const char* ignore_event, void* arg) { + return NULL; +} + +/* print all events as XML markup */ +static void* xml_event_callback(void* stream, const char* event, void* arg) { + FILE* fp = (FILE*) stream; +#define NS_PFX "dis:" + if (event[0] != '/') { + /* issue the tag, with or without a formatted argument */ + fprintf(fp, "<"NS_PFX); + fprintf(fp, event, arg); + fprintf(fp, ">"); + } else { + ++event; /* skip slash */ + const char* argp = strchr(event, ' '); + if (argp == NULL) { + /* no arguments; just issue the closing tag */ + fprintf(fp, "", event); + } else { + /* split out the closing attributes as */ + int event_prefix = (argp - event); + fprintf(fp, "<"NS_PFX"%.*s_done", event_prefix, event); + fprintf(fp, argp, arg); + fprintf(fp, "/>", event_prefix, event); + } + } + return NULL; +} + +static void set_optional_callbacks(struct hsdis_app_data* app_data) { + if (app_data->printf_callback == NULL) { + int (*fprintf_callback)(FILE*, const char*, ...) = &fprintf; + FILE* fprintf_stream = stdout; + app_data->printf_callback = (printf_callback_t) fprintf_callback; + if (app_data->printf_stream == NULL) + app_data->printf_stream = (void*) fprintf_stream; + } + if (app_data->event_callback == NULL) { + if (app_data->event_stream == NULL) + app_data->event_callback = &null_event_callback; + else + app_data->event_callback = &xml_event_callback; + } + +} + +static void parse_caller_options(struct hsdis_app_data* app_data, const char* caller_options) { + char* iop_base = app_data->insn_options; + char* iop_limit = iop_base + sizeof(app_data->insn_options) - 1; + char* iop = iop_base; + const char* p; + for (p = caller_options; p != NULL; ) { + const char* q = strchr(p, ','); + size_t plen = (q == NULL) ? strlen(p) : ((q++) - p); + if (plen == 4 && strncmp(p, "help", plen) == 0) { + print_help(app_data, NULL, NULL); + } else if (plen >= 5 && strncmp(p, "mach=", 5) == 0) { + char* mach_option = app_data->mach_option; + size_t mach_size = sizeof(app_data->mach_option); + mach_size -= 1; /*leave room for the null*/ + if (plen > mach_size) plen = mach_size; + strncpy(mach_option, p, plen); + mach_option[plen] = '\0'; + } else if (plen > 6 && strncmp(p, "hsdis-", 6)) { + // do not pass these to the next level + } else { + /* just copy it; {i386,sparc}-dis.c might like to see it */ + if (iop > iop_base && iop < iop_limit) (*iop++) = ','; + if (iop + plen > iop_limit) + plen = iop_limit - iop; + strncpy(iop, p, plen); + iop += plen; + } + p = q; + } +} + +static void print_help(struct hsdis_app_data* app_data, + const char* msg, const char* arg) { + DECL_PRINTF_CALLBACK(app_data); + if (msg != NULL) { + (*printf_callback)(printf_stream, "hsdis: "); + (*printf_callback)(printf_stream, msg, arg); + (*printf_callback)(printf_stream, "\n"); + } + (*printf_callback)(printf_stream, "hsdis output options:\n"); + if (printf_callback == (printf_callback_t) &fprintf) + disassembler_usage((FILE*) printf_stream); + else + disassembler_usage(stderr); /* better than nothing */ + (*printf_callback)(printf_stream, " mach= select disassembly mode\n"); +#if defined(LIBARCH_i386) || defined(LIBARCH_amd64) + (*printf_callback)(printf_stream, " mach=i386 select 32-bit mode\n"); + (*printf_callback)(printf_stream, " mach=x86-64 select 64-bit mode\n"); + (*printf_callback)(printf_stream, " suffix always print instruction suffix\n"); +#endif + (*printf_callback)(printf_stream, " help print this message\n"); +} + + +/* low-level bfd and arch stuff that binutils doesn't do for us */ + +static const bfd_arch_info_type* find_arch_info(const char* arch_name) { + const bfd_arch_info_type* arch_info = bfd_scan_arch(arch_name); + if (arch_info == NULL) { + extern const bfd_arch_info_type bfd_default_arch_struct; + arch_info = &bfd_default_arch_struct; + } + return arch_info; +} + +static const char* native_arch_name() { + const char* res = HOTSPOT_LIB_ARCH; +#ifdef LIBARCH_amd64 + res = "i386:x86-64"; +#endif +#ifdef LIBARCH_sparc + res = "sparc:v8plusb"; +#endif +#ifdef LIBARCH_sparc + res = "sparc:v8plusb"; +#endif +#ifdef LIBARCH_sparcv9 + res = "sparc:v9b"; +#endif + if (res == NULL) + res = "HOTSPOT_LIB_ARCH is not set in Makefile!"; + return res; +} + +static enum bfd_endian native_endian() { + int32_t endian_test = 'x'; + if (*(const char*) &endian_test == 'x') + return BFD_ENDIAN_LITTLE; + else + return BFD_ENDIAN_BIG; +} + +static bfd* get_native_bfd(const bfd_arch_info_type* arch_info, + bfd* empty_bfd, bfd_target* empty_xvec) { + memset(empty_bfd, 0, sizeof(*empty_bfd)); + memset(empty_xvec, 0, sizeof(*empty_xvec)); + empty_xvec->flavour = bfd_target_unknown_flavour; + empty_xvec->byteorder = native_endian(); + empty_bfd->xvec = empty_xvec; + empty_bfd->arch_info = arch_info; + return empty_bfd; +} + +static int read_zero_data_only(bfd_vma ignore_p, + bfd_byte* myaddr, unsigned int length, + struct disassemble_info *ignore_info) { + memset(myaddr, 0, length); + return 0; +} +static int print_to_dev_null(void* ignore_stream, const char* ignore_format, ...) { + return 0; +} + +/* Prime the pump by running the selected disassembler on a null input. + This forces the machine-specific disassembler to divulge invariant + information like bytes_per_line. + */ +static void parse_fake_insn(disassembler_ftype dfn, + struct disassemble_info* dinfo) { + typedef int (*read_memory_ftype) + (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, + struct disassemble_info *info); + read_memory_ftype read_memory_func = dinfo->read_memory_func; + fprintf_ftype fprintf_func = dinfo->fprintf_func; + + dinfo->read_memory_func = &read_zero_data_only; + dinfo->fprintf_func = &print_to_dev_null; + (*dfn)(0, dinfo); + + // put it back: + dinfo->read_memory_func = read_memory_func; + dinfo->fprintf_func = fprintf_func; +} + +static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, + void *stream, + fprintf_ftype fprintf_func, + bfd* abfd, + char* disassembler_options) { + init_disassemble_info(dinfo, stream, fprintf_func); + + dinfo->flavour = bfd_get_flavour(abfd); + dinfo->arch = bfd_get_arch(abfd); + dinfo->mach = bfd_get_mach(abfd); + dinfo->disassembler_options = disassembler_options; + dinfo->octets_per_byte = bfd_octets_per_byte (abfd); + dinfo->skip_zeroes = sizeof(void*) * 2; + dinfo->skip_zeroes_at_end = sizeof(void*)-1; + dinfo->disassembler_needs_relocs = FALSE; + + if (bfd_big_endian(abfd)) + dinfo->display_endian = dinfo->endian = BFD_ENDIAN_BIG; + else if (bfd_little_endian(abfd)) + dinfo->display_endian = dinfo->endian = BFD_ENDIAN_LITTLE; + else + dinfo->endian = native_endian(); + + disassemble_init_for_target(dinfo); +} diff --git a/hotspot/src/share/tools/hsdis/hsdis.h b/hotspot/src/share/tools/hsdis/hsdis.h new file mode 100644 index 00000000000..df489ff0513 --- /dev/null +++ b/hotspot/src/share/tools/hsdis/hsdis.h @@ -0,0 +1,67 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +/* decode_instructions -- dump a range of addresses as native instructions + This implements the protocol required by the HotSpot PrintAssembly option. + + The starting and ending addresses are within the current process's address space. + + The option string, if not empty, is interpreted by the disassembler implementation. + + The printf callback is 'fprintf' or any other workalike. + It is called as (*printf_callback)(printf_stream, "some format...", some, format, args). + + The event callback receives an event tag (a string) and an argument (a void*). + It is called as (*event_callback)(event_stream, "tag", arg). + + Events: + begin an instruction, at a given location + end an instruction, at a given location + emit the symbolic value of an address + + A tag format is one of three basic forms: "tag", "/tag", "tag/", + where tag is a simple identifier, signifying (as in XML) a element start, + element end, and standalone element. (To render as XML, add angle brackets.) +*/ +extern +#ifdef DLL_EXPORT + DLL_EXPORT +#endif +void* decode_instructions(void* start, void* end, + void* (*event_callback)(void*, const char*, void*), + void* event_stream, + int (*printf_callback)(void*, const char*, ...), + void* printf_stream, + const char* options); + +/* convenience typedefs */ + +typedef void* (*decode_instructions_event_callback_ftype) (void*, const char*, void*); +typedef int (*decode_instructions_printf_callback_ftype) (void*, const char*, ...); +typedef void* (*decode_instructions_ftype) (void* start, void* end, + decode_instructions_event_callback_ftype event_callback, + void* event_stream, + decode_instructions_printf_callback_ftype printf_callback, + void* printf_stream, + const char* options); diff --git a/hotspot/src/share/vm/asm/codeBuffer.cpp b/hotspot/src/share/vm/asm/codeBuffer.cpp index a8b19abb3a7..0fc53ed45f7 100644 --- a/hotspot/src/share/vm/asm/codeBuffer.cpp +++ b/hotspot/src/share/vm/asm/codeBuffer.cpp @@ -947,6 +947,7 @@ void CodeComments::print_block_comment(outputStream* stream, intptr_t offset) { if (_comments != NULL) { CodeComment* c = _comments->find(offset); while (c && c->offset() == offset) { + stream->bol(); stream->print(" ;; "); stream->print_cr(c->comment()); c = c->next(); diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 518c0ce717d..f09e8a244c0 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -707,7 +707,9 @@ nmethod::nmethod( " entry points must be same for static methods and vice versa"); } - bool printnmethods = PrintNMethods || CompilerOracle::has_option_string(_method, "PrintNMethods"); + bool printnmethods = PrintNMethods + || CompilerOracle::should_print(_method) + || CompilerOracle::has_option_string(_method, "PrintNMethods"); if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) { print_nmethod(printnmethods); } @@ -798,7 +800,6 @@ void nmethod::print_on(outputStream* st, const char* title) const { } -#ifndef PRODUCT void nmethod::print_nmethod(bool printmethod) { ttyLocker ttyl; // keep the following output all in one block if (xtty != NULL) { @@ -831,7 +832,6 @@ void nmethod::print_nmethod(bool printmethod) { xtty->tail("print_nmethod"); } } -#endif void nmethod::set_version(int v) { @@ -1870,6 +1870,7 @@ void nmethod::check_store() { } } +#endif // PRODUCT // Printing operations @@ -1948,6 +1949,14 @@ void nmethod::print() const { oops_size()); } +void nmethod::print_code() { + HandleMark hm; + ResourceMark m; + Disassembler::decode(this); +} + + +#ifndef PRODUCT void nmethod::print_scopes() { // Find the first pc desc for all scopes in the code and print it. @@ -1979,13 +1988,6 @@ void nmethod::print_dependencies() { } -void nmethod::print_code() { - HandleMark hm; - ResourceMark m; - Disassembler().decode(this); -} - - void nmethod::print_relocations() { ResourceMark m; // in case methods get printed via the debugger tty->print_cr("relocations:"); @@ -2021,6 +2023,7 @@ void nmethod::print_pcs() { } } +#endif // PRODUCT const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { RelocIterator iter(this, begin, end); @@ -2055,7 +2058,6 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { return have_one ? "other" : NULL; } - // Return a the last scope in (begin..end] ScopeDesc* nmethod::scope_desc_in(address begin, address end) { PcDesc* p = pc_desc_near(begin+1); @@ -2078,29 +2080,26 @@ void nmethod::print_code_comment_on(outputStream* st, int column, u_char* begin, address pc = base + om->offset(); if (pc > begin) { if (pc <= end) { - st->fill_to(column); - if (st == tty) { - st->print("; OopMap "); - om->print(); - tty->cr(); - } else { - st->print_cr("; OopMap #%d offset:%d", i, om->offset()); - } + st->move_to(column); + st->print("; "); + om->print_on(st); } break; } } } + + // Print any debug info present at this pc. ScopeDesc* sd = scope_desc_in(begin, end); if (sd != NULL) { - st->fill_to(column); + st->move_to(column); if (sd->bci() == SynchronizationEntryBCI) { st->print(";*synchronization entry"); } else { if (sd->method().is_null()) { - tty->print("method is NULL"); + st->print("method is NULL"); } else if (sd->method()->is_native()) { - tty->print("method is native"); + st->print("method is native"); } else { address bcp = sd->method()->bcp_from(sd->bci()); Bytecodes::Code bc = Bytecodes::java_code_at(bcp); @@ -2137,13 +2136,13 @@ void nmethod::print_code_comment_on(outputStream* st, int column, u_char* begin, } } } - st->cr(); + // Print all scopes for (;sd != NULL; sd = sd->sender()) { - st->fill_to(column); + st->move_to(column); st->print("; -"); if (sd->method().is_null()) { - tty->print("method is NULL"); + st->print("method is NULL"); } else { sd->method()->print_short_name(st); } @@ -2161,17 +2160,19 @@ void nmethod::print_code_comment_on(outputStream* st, int column, u_char* begin, const char* str = reloc_string_for(begin, end); if (str != NULL) { if (sd != NULL) st->cr(); - st->fill_to(column); + st->move_to(column); st->print("; {%s}", str); } int cont_offset = ImplicitExceptionTable(this).at(begin - instructions_begin()); if (cont_offset != 0) { - st->fill_to(column); + st->move_to(column); st->print("; implicit exception: dispatches to " INTPTR_FORMAT, instructions_begin() + cont_offset); } } +#ifndef PRODUCT + void nmethod::print_value_on(outputStream* st) const { print_on(st, "nmethod"); } diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp index 0b1c61977e3..f03ec5434d8 100644 --- a/hotspot/src/share/vm/code/nmethod.hpp +++ b/hotspot/src/share/vm/code/nmethod.hpp @@ -485,8 +485,8 @@ class nmethod : public CodeBlob { void verify_interrupt_point(address interrupt_point); // printing support - void print() const PRODUCT_RETURN; - void print_code() PRODUCT_RETURN; + void print() const; + void print_code(); void print_relocations() PRODUCT_RETURN; void print_pcs() PRODUCT_RETURN; void print_scopes() PRODUCT_RETURN; @@ -495,7 +495,7 @@ class nmethod : public CodeBlob { void print_calls(outputStream* st) PRODUCT_RETURN; void print_handler_table() PRODUCT_RETURN; void print_nul_chk_table() PRODUCT_RETURN; - void print_nmethod(bool print_code) PRODUCT_RETURN; + void print_nmethod(bool print_code); void print_on(outputStream* st, const char* title) const; @@ -505,7 +505,7 @@ class nmethod : public CodeBlob { void log_state_change(int state) const; // Prints a comment for one native instruction (reloc info, pc desc) - void print_code_comment_on(outputStream* st, int column, address begin, address end) PRODUCT_RETURN; + void print_code_comment_on(outputStream* st, int column, address begin, address end); static void print_statistics() PRODUCT_RETURN; // Compiler task identification. Note that all OSR methods diff --git a/hotspot/src/share/vm/code/vmreg.cpp b/hotspot/src/share/vm/code/vmreg.cpp index 22be4b2f390..3d2aa69274d 100644 --- a/hotspot/src/share/vm/code/vmreg.cpp +++ b/hotspot/src/share/vm/code/vmreg.cpp @@ -36,7 +36,6 @@ const int VMRegImpl::register_count = ConcreteRegisterImpl::number_of_registers; // Register names const char *VMRegImpl::regName[ConcreteRegisterImpl::number_of_registers]; -#ifndef PRODUCT void VMRegImpl::print_on(outputStream* st) const { if( is_reg() ) { assert( VMRegImpl::regName[value()], "" ); @@ -48,4 +47,3 @@ void VMRegImpl::print_on(outputStream* st) const { st->print("BAD!"); } } -#endif // PRODUCT diff --git a/hotspot/src/share/vm/code/vmreg.hpp b/hotspot/src/share/vm/code/vmreg.hpp index ab77b265fe3..399cba3497b 100644 --- a/hotspot/src/share/vm/code/vmreg.hpp +++ b/hotspot/src/share/vm/code/vmreg.hpp @@ -96,7 +96,7 @@ public: intptr_t value() const {return (intptr_t) this; } - void print_on(outputStream* st) const PRODUCT_RETURN; + void print_on(outputStream* st) const; void print() const { print_on(tty); } // bias a stack slot. @@ -156,22 +156,22 @@ public: _first = ptr; } // Return true if single register, even if the pair is really just adjacent stack slots - bool is_single_reg() { + bool is_single_reg() const { return (_first->is_valid()) && (_first->value() + 1 == _second->value()); } // Return true if single stack based "register" where the slot alignment matches input alignment - bool is_adjacent_on_stack(int alignment) { + bool is_adjacent_on_stack(int alignment) const { return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0)); } // Return true if single stack based "register" where the slot alignment matches input alignment - bool is_adjacent_aligned_on_stack(int alignment) { + bool is_adjacent_aligned_on_stack(int alignment) const { return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0)); } // Return true if single register but adjacent stack slots do not count - bool is_single_phys_reg() { + bool is_single_phys_reg() const { return (_first->is_reg() && (_first->value() + 1 == _second->value())); } diff --git a/hotspot/src/share/vm/compiler/disassembler.cpp b/hotspot/src/share/vm/compiler/disassembler.cpp new file mode 100644 index 00000000000..3e800e9b9e7 --- /dev/null +++ b/hotspot/src/share/vm/compiler/disassembler.cpp @@ -0,0 +1,443 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +# include "incls/_precompiled.incl" +# include "incls/_disassembler.cpp.incl" + +void* Disassembler::_library = NULL; +bool Disassembler::_tried_to_load_library = false; + +// This routine is in the shared library: +Disassembler::decode_func Disassembler::_decode_instructions = NULL; + +static const char hsdis_library_name[] = "hsdis-"HOTSPOT_LIB_ARCH; +static const char decode_instructions_name[] = "decode_instructions"; + +#define COMMENT_COLUMN 40 LP64_ONLY(+8) /*could be an option*/ +#define BYTES_COMMENT ";..." /* funky byte display comment */ + +bool Disassembler::load_library() { + if (_decode_instructions != NULL) { + // Already succeeded. + return true; + } + if (_tried_to_load_library) { + // Do not try twice. + // To force retry in debugger: assign _tried_to_load_library=0 + return false; + } + // Try to load it. + char ebuf[1024]; + char buf[JVM_MAXPATHLEN]; + os::jvm_path(buf, sizeof(buf)); + int jvm_offset = -1; + { + // Match "jvm[^/]*" in jvm_path. + const char* base = buf; + const char* p = strrchr(buf, '/'); + p = strstr(p ? p : base, "jvm"); + if (p != NULL) jvm_offset = p - base; + } + if (jvm_offset >= 0) { + // Find the disassembler next to libjvm.so. + strcpy(&buf[jvm_offset], hsdis_library_name); + strcat(&buf[jvm_offset], os::dll_file_extension()); + _library = hpi::dll_load(buf, ebuf, sizeof ebuf); + } + if (_library == NULL) { + // Try a free-floating lookup. + strcpy(&buf[0], hsdis_library_name); + strcat(&buf[0], os::dll_file_extension()); + _library = hpi::dll_load(buf, ebuf, sizeof ebuf); + } + if (_library != NULL) { + _decode_instructions = CAST_TO_FN_PTR(Disassembler::decode_func, + hpi::dll_lookup(_library, decode_instructions_name)); + } + _tried_to_load_library = true; + if (_decode_instructions == NULL) { + tty->print_cr("Could not load %s; %s; %s", buf, + ((_library != NULL) + ? "entry point is missing" + : (WizardMode || PrintMiscellaneous) + ? (const char*)ebuf + : "library not loadable"), + "PrintAssembly is disabled"); + return false; + } + + // Success. + tty->print_cr("Loaded disassembler from %s", buf); + return true; +} + + +class decode_env { + private: + nmethod* _nm; + CodeBlob* _code; + outputStream* _output; + address _start, _end; + + char _option_buf[512]; + char _print_raw; + bool _print_pc; + bool _print_bytes; + address _cur_insn; + int _total_ticks; + int _bytes_per_line; // arch-specific formatting option + + static bool match(const char* event, const char* tag) { + size_t taglen = strlen(tag); + if (strncmp(event, tag, taglen) != 0) + return false; + char delim = event[taglen]; + return delim == '\0' || delim == ' ' || delim == '/' || delim == '='; + } + + void collect_options(const char* p) { + if (p == NULL || p[0] == '\0') return; + size_t opt_so_far = strlen(_option_buf); + if (opt_so_far + 1 + strlen(p) + 1 > sizeof(_option_buf)) return; + char* fillp = &_option_buf[opt_so_far]; + if (opt_so_far > 0) *fillp++ = ','; + strcat(fillp, p); + // replace white space by commas: + char* q = fillp; + while ((q = strpbrk(q, " \t\n")) != NULL) + *q++ = ','; + // Note that multiple PrintAssemblyOptions flags accumulate with \n, + // which we want to be changed to a comma... + } + + void print_insn_labels(); + void print_insn_bytes(address pc0, address pc); + void print_address(address value); + + public: + decode_env(CodeBlob* code, outputStream* output); + + address decode_instructions(address start, address end); + + void start_insn(address pc) { + _cur_insn = pc; + output()->bol(); + print_insn_labels(); + } + + void end_insn(address pc) { + address pc0 = cur_insn(); + outputStream* st = output(); + if (_print_bytes && pc > pc0) + print_insn_bytes(pc0, pc); + if (_nm != NULL) + _nm->print_code_comment_on(st, COMMENT_COLUMN, pc0, pc); + + // Output pc bucket ticks if we have any + if (total_ticks() != 0) { + address bucket_pc = FlatProfiler::bucket_start_for(pc); + if (bucket_pc != NULL && bucket_pc > pc0 && bucket_pc <= pc) { + int bucket_count = FlatProfiler::bucket_count_for(pc0); + if (bucket_count != 0) { + st->bol(); + st->print_cr("%3.1f%% [%d]", bucket_count*100.0/total_ticks(), bucket_count); + } + } + } + } + + address handle_event(const char* event, address arg); + + outputStream* output() { return _output; } + address cur_insn() { return _cur_insn; } + int total_ticks() { return _total_ticks; } + void set_total_ticks(int n) { _total_ticks = n; } + const char* options() { return _option_buf; } +}; + +decode_env::decode_env(CodeBlob* code, outputStream* output) { + memset(this, 0, sizeof(*this)); + _output = output ? output : tty; + _code = code; + if (code != NULL && code->is_nmethod()) + _nm = (nmethod*) code; + + // by default, output pc but not bytes: + _print_pc = true; + _print_bytes = false; + _bytes_per_line = Disassembler::pd_instruction_alignment(); + + // parse the global option string: + collect_options(Disassembler::pd_cpu_opts()); + collect_options(PrintAssemblyOptions); + + if (strstr(options(), "hsdis-")) { + if (strstr(options(), "hsdis-print-raw")) + _print_raw = (strstr(options(), "xml") ? 2 : 1); + if (strstr(options(), "hsdis-print-pc")) + _print_pc = !_print_pc; + if (strstr(options(), "hsdis-print-bytes")) + _print_bytes = !_print_bytes; + } + if (strstr(options(), "help")) { + tty->print_cr("PrintAssemblyOptions help:"); + tty->print_cr(" hsdis-print-raw test plugin by requesting raw output"); + tty->print_cr(" hsdis-print-raw-xml test plugin by requesting raw xml"); + tty->print_cr(" hsdis-print-pc turn off PC printing (on by default)"); + tty->print_cr(" hsdis-print-bytes turn on instruction byte output"); + tty->print_cr("combined options: %s", options()); + } +} + +address decode_env::handle_event(const char* event, address arg) { + if (match(event, "insn")) { + start_insn(arg); + } else if (match(event, "/insn")) { + end_insn(arg); + } else if (match(event, "addr")) { + if (arg != NULL) { + print_address(arg); + return arg; + } + } else if (match(event, "mach")) { + output()->print_cr("[Disassembling for mach='%s']", arg); + } else if (match(event, "format bytes-per-line")) { + _bytes_per_line = (int) (intptr_t) arg; + } else { + // ignore unrecognized markup + } + return NULL; +} + +// called by the disassembler to print out jump targets and data addresses +void decode_env::print_address(address adr) { + outputStream* st = _output; + + if (adr == NULL) { + st->print("NULL"); + return; + } + + int small_num = (int)(intptr_t)adr; + if ((intptr_t)adr == (intptr_t)small_num + && -1 <= small_num && small_num <= 9) { + st->print("%d", small_num); + return; + } + + if (Universe::is_fully_initialized()) { + if (StubRoutines::contains(adr)) { + StubCodeDesc* desc = StubCodeDesc::desc_for(adr); + if (desc == NULL) + desc = StubCodeDesc::desc_for(adr + frame::pc_return_offset); + if (desc != NULL) { + st->print("Stub::%s", desc->name()); + if (desc->begin() != adr) + st->print("%+d 0x%p",adr - desc->begin(), adr); + else if (WizardMode) st->print(" " INTPTR_FORMAT, adr); + return; + } + st->print("Stub:: " INTPTR_FORMAT, adr); + return; + } + + BarrierSet* bs = Universe::heap()->barrier_set(); + if (bs->kind() == BarrierSet::CardTableModRef && + adr == (address)((CardTableModRefBS*)(bs))->byte_map_base) { + st->print("word_map_base"); + if (WizardMode) st->print(" " INTPTR_FORMAT, (intptr_t)adr); + return; + } + + oop obj; + if (_nm != NULL + && (obj = _nm->embeddedOop_at(cur_insn())) != NULL + && (address) obj == adr) { + obj->print_value_on(st); + return; + } + } + + // Fall through to a simple numeral. + st->print(INTPTR_FORMAT, (intptr_t)adr); +} + +void decode_env::print_insn_labels() { + address p = cur_insn(); + outputStream* st = output(); + nmethod* nm = _nm; + if (nm != NULL) { + if (p == nm->entry_point()) st->print_cr("[Entry Point]"); + if (p == nm->verified_entry_point()) st->print_cr("[Verified Entry Point]"); + if (p == nm->exception_begin()) st->print_cr("[Exception Handler]"); + if (p == nm->stub_begin()) st->print_cr("[Stub Code]"); + if (p == nm->consts_begin()) st->print_cr("[Constants]"); + } + CodeBlob* cb = _code; + if (cb != NULL) { + cb->print_block_comment(st, (intptr_t)(p - cb->instructions_begin())); + } + if (_print_pc) { + st->print(" " INTPTR_FORMAT ": ", (intptr_t) p); + } +} + +void decode_env::print_insn_bytes(address pc, address pc_limit) { + outputStream* st = output(); + size_t incr = 1; + size_t perline = _bytes_per_line; + if ((size_t) Disassembler::pd_instruction_alignment() >= sizeof(int) + && !((uintptr_t)pc % sizeof(int)) + && !((uintptr_t)pc_limit % sizeof(int))) { + incr = sizeof(int); + if (perline % incr) perline += incr - (perline % incr); + } + while (pc < pc_limit) { + // tab to the desired column: + st->move_to(COMMENT_COLUMN); + address pc0 = pc; + address pc1 = pc + perline; + if (pc1 > pc_limit) pc1 = pc_limit; + for (; pc < pc1; pc += incr) { + if (pc == pc0) + st->print(BYTES_COMMENT); + else if ((uint)(pc - pc0) % sizeof(int) == 0) + st->print(" "); // put out a space on word boundaries + if (incr == sizeof(int)) + st->print("%08lx", *(int*)pc); + else st->print("%02x", (*pc)&0xFF); + } + st->cr(); + } +} + + +static void* event_to_env(void* env_pv, const char* event, void* arg) { + decode_env* env = (decode_env*) env_pv; + return env->handle_event(event, (address) arg); +} + +static int printf_to_env(void* env_pv, const char* format, ...) { + decode_env* env = (decode_env*) env_pv; + outputStream* st = env->output(); + size_t flen = strlen(format); + const char* raw = NULL; + if (flen == 0) return 0; + if (flen == 1 && format[0] == '\n') { st->bol(); return 1; } + if (flen < 2 || + strchr(format, '%') == NULL) { + raw = format; + } else if (format[0] == '%' && format[1] == '%' && + strchr(format+2, '%') == NULL) { + // happens a lot on machines with names like %foo + flen--; + raw = format+1; + } + if (raw != NULL) { + st->print_raw(raw, (int) flen); + return (int) flen; + } + va_list ap; + va_start(ap, format); + julong cnt0 = st->count(); + st->vprint(format, ap); + julong cnt1 = st->count(); + va_end(ap); + return (int)(cnt1 - cnt0); +} + +address decode_env::decode_instructions(address start, address end) { + _start = start; _end = end; + + assert((((intptr_t)start | (intptr_t)end) % Disassembler::pd_instruction_alignment() == 0), "misaligned insn addr"); + + const int show_bytes = false; // for disassembler debugging + + //_version = Disassembler::pd_cpu_version(); + + if (!Disassembler::can_decode()) { + return NULL; + } + + // decode a series of instructions and return the end of the last instruction + + if (_print_raw) { + // Print whatever the library wants to print, w/o fancy callbacks. + // This is mainly for debugging the library itself. + FILE* out = stdout; + FILE* xmlout = (_print_raw > 1 ? out : NULL); + return (address) + (*Disassembler::_decode_instructions)(start, end, + NULL, (void*) xmlout, + NULL, (void*) out, + options()); + } + + return (address) + (*Disassembler::_decode_instructions)(start, end, + &event_to_env, (void*) this, + &printf_to_env, (void*) this, + options()); +} + + +void Disassembler::decode(CodeBlob* cb, outputStream* st) { + if (!load_library()) return; + decode_env env(cb, st); + env.output()->print_cr("Decoding CodeBlob " INTPTR_FORMAT, cb); + env.decode_instructions(cb->instructions_begin(), cb->instructions_end()); +} + + +void Disassembler::decode(address start, address end, outputStream* st) { + if (!load_library()) return; + decode_env env(CodeCache::find_blob_unsafe(start), st); + env.decode_instructions(start, end); +} + +void Disassembler::decode(nmethod* nm, outputStream* st) { + if (!load_library()) return; + decode_env env(nm, st); + env.output()->print_cr("Decoding compiled method " INTPTR_FORMAT ":", nm); + env.output()->print_cr("Code:"); + + unsigned char* p = nm->instructions_begin(); + unsigned char* end = nm->instructions_end(); + + // If there has been profiling, print the buckets. + if (FlatProfiler::bucket_start_for(p) != NULL) { + unsigned char* p1 = p; + int total_bucket_count = 0; + while (p1 < end) { + unsigned char* p0 = p1; + p1 += pd_instruction_alignment(); + address bucket_pc = FlatProfiler::bucket_start_for(p1); + if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1) + total_bucket_count += FlatProfiler::bucket_count_for(p0); + } + env.set_total_ticks(total_bucket_count); + } + + env.decode_instructions(p, end); +} diff --git a/hotspot/src/share/vm/compiler/disassembler.hpp b/hotspot/src/share/vm/compiler/disassembler.hpp new file mode 100644 index 00000000000..670355f070d --- /dev/null +++ b/hotspot/src/share/vm/compiler/disassembler.hpp @@ -0,0 +1,59 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +class decode_env; + +// The disassembler prints out assembly code annotated +// with Java specific information. + +class Disassembler { + friend class decode_env; + private: + // this is the type of the dll entry point: + typedef void* (*decode_func)(void* start, void* end, + void* (*event_callback)(void*, const char*, void*), + void* event_stream, + int (*printf_callback)(void*, const char*, ...), + void* printf_stream, + const char* options); + // points to the library. + static void* _library; + // bailout + static bool _tried_to_load_library; + // points to the decode function. + static decode_func _decode_instructions; + // tries to load library and return whether it succedded. + static bool load_library(); + + // Machine dependent stuff + #include "incls/_disassembler_pd.hpp.incl" + + public: + static bool can_decode() { + return (_decode_instructions != NULL) || load_library(); + } + static void decode(CodeBlob *cb, outputStream* st = NULL); + static void decode(nmethod* nm, outputStream* st = NULL); + static void decode(address begin, address end, outputStream* st = NULL); +}; diff --git a/hotspot/src/share/vm/compiler/disassemblerEnv.hpp b/hotspot/src/share/vm/compiler/disassemblerEnv.hpp deleted file mode 100644 index 69bb38f77c1..00000000000 --- a/hotspot/src/share/vm/compiler/disassemblerEnv.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - */ - -// Call-back interface for external disassembler -class DisassemblerEnv { - public: - // printing - virtual void print_label(intptr_t value) = 0; - virtual void print_raw(char* str) = 0; - virtual void print(char* format, ...) = 0; - // helpers - virtual char* string_for_offset(intptr_t value) = 0; - virtual char* string_for_constant(unsigned char* pc, intptr_t value, int is_decimal) = 0; -}; diff --git a/hotspot/src/share/vm/compiler/oopMap.cpp b/hotspot/src/share/vm/compiler/oopMap.cpp index b4a85f787f8..9f5a1ada4d6 100644 --- a/hotspot/src/share/vm/compiler/oopMap.cpp +++ b/hotspot/src/share/vm/compiler/oopMap.cpp @@ -505,8 +505,13 @@ bool OopMap::has_derived_pointer() const { #endif // COMPILER2 } +#endif //PRODUCT -static void print_register_type(OopMapValue::oop_types x, VMReg optional, outputStream* st) { +// Printing code is present in product build for -XX:+PrintAssembly. + +static +void print_register_type(OopMapValue::oop_types x, VMReg optional, + outputStream* st) { switch( x ) { case OopMapValue::oop_value: st->print("Oop"); @@ -544,10 +549,12 @@ void OopMapValue::print_on(outputStream* st) const { void OopMap::print_on(outputStream* st) const { OopMapValue omv; + st->print("OopMap{"); for(OopMapStream oms((OopMap*)this); !oms.is_done(); oms.next()) { omv = oms.current(); omv.print_on(st); } + st->print("off=%d}", (int) offset()); } @@ -558,12 +565,12 @@ void OopMapSet::print_on(outputStream* st) const { for( i = 0; i < len; i++) { OopMap* m = at(i); - st->print_cr("OopMap #%d offset:%p",i,m->offset()); + st->print_cr("#%d ",i); m->print_on(st); - st->print_cr("\n"); + st->cr(); } } -#endif // !PRODUCT + //------------------------------DerivedPointerTable--------------------------- diff --git a/hotspot/src/share/vm/compiler/oopMap.hpp b/hotspot/src/share/vm/compiler/oopMap.hpp index 8b678368247..5c9c8c42ff9 100644 --- a/hotspot/src/share/vm/compiler/oopMap.hpp +++ b/hotspot/src/share/vm/compiler/oopMap.hpp @@ -129,7 +129,7 @@ public: return reg()->reg2stack(); } - void print_on(outputStream* st) const PRODUCT_RETURN; + void print_on(outputStream* st) const; void print() const { print_on(tty); } }; @@ -193,7 +193,7 @@ class OopMap: public ResourceObj { } // Printing - void print_on(outputStream* st) const PRODUCT_RETURN; + void print_on(outputStream* st) const; void print() const { print_on(tty); } }; @@ -248,7 +248,7 @@ class OopMapSet : public ResourceObj { OopClosure* value_fn, OopClosure* dead_fn); // Printing - void print_on(outputStream* st) const PRODUCT_RETURN; + void print_on(outputStream* st) const; void print() const { print_on(tty); } }; diff --git a/hotspot/src/share/vm/includeDB_compiler1 b/hotspot/src/share/vm/includeDB_compiler1 index 37bb58ccc32..ae500d2f6d7 100644 --- a/hotspot/src/share/vm/includeDB_compiler1 +++ b/hotspot/src/share/vm/includeDB_compiler1 @@ -323,7 +323,7 @@ c1_Runtime1.cpp collectedHeap.hpp c1_Runtime1.cpp compilationPolicy.hpp c1_Runtime1.cpp compiledIC.hpp c1_Runtime1.cpp copy.hpp -c1_Runtime1.cpp disassembler_.hpp +c1_Runtime1.cpp disassembler.hpp c1_Runtime1.cpp events.hpp c1_Runtime1.cpp interfaceSupport.hpp c1_Runtime1.cpp interpreter.hpp diff --git a/hotspot/src/share/vm/includeDB_core b/hotspot/src/share/vm/includeDB_core index 17404cec658..06eb247de6d 100644 --- a/hotspot/src/share/vm/includeDB_core +++ b/hotspot/src/share/vm/includeDB_core @@ -244,7 +244,7 @@ assembler.hpp vm_version_.hpp assembler.inline.hpp assembler.hpp assembler.inline.hpp codeBuffer.hpp -assembler.inline.hpp disassembler_.hpp +assembler.inline.hpp disassembler.hpp assembler.inline.hpp threadLocalStorage.hpp assembler_.cpp assembler_.inline.hpp @@ -946,7 +946,7 @@ codeBlob.cpp allocation.inline.hpp codeBlob.cpp bytecode.hpp codeBlob.cpp codeBlob.hpp codeBlob.cpp codeCache.hpp -codeBlob.cpp disassembler_.hpp +codeBlob.cpp disassembler.hpp codeBlob.cpp forte.hpp codeBlob.cpp handles.inline.hpp codeBlob.cpp heap.hpp @@ -968,7 +968,7 @@ codeBlob.hpp oopMap.hpp codeBuffer.cpp codeBuffer.hpp codeBuffer.cpp copy.hpp -codeBuffer.cpp disassembler_.hpp +codeBuffer.cpp disassembler.hpp codeBuffer.hpp assembler.hpp codeBuffer.hpp oopRecorder.hpp @@ -1323,7 +1323,7 @@ debug.cpp codeCache.hpp debug.cpp collectedHeap.hpp debug.cpp compileBroker.hpp debug.cpp defaultStream.hpp -debug.cpp disassembler_.hpp +debug.cpp disassembler.hpp debug.cpp events.hpp debug.cpp frame.hpp debug.cpp heapDumper.hpp @@ -1442,7 +1442,7 @@ deoptimization.hpp allocation.hpp deoptimization.hpp frame.inline.hpp depChecker_.cpp depChecker_.hpp -depChecker_.cpp disassembler_.hpp +depChecker_.cpp disassembler.hpp depChecker_.cpp hpi.hpp dependencies.cpp ciArrayKlass.hpp @@ -1472,21 +1472,21 @@ dictionary.hpp instanceKlass.hpp dictionary.hpp oop.hpp dictionary.hpp systemDictionary.hpp -disassemblerEnv.hpp globals.hpp +disassembler_.hpp generate_platform_dependent_include -disassembler_.cpp cardTableModRefBS.hpp -disassembler_.cpp codeCache.hpp -disassembler_.cpp collectedHeap.hpp -disassembler_.cpp depChecker_.hpp -disassembler_.cpp disassembler_.hpp -disassembler_.cpp fprofiler.hpp -disassembler_.cpp handles.inline.hpp -disassembler_.cpp hpi.hpp -disassembler_.cpp stubCodeGenerator.hpp -disassembler_.cpp stubRoutines.hpp +disassembler.cpp cardTableModRefBS.hpp +disassembler.cpp codeCache.hpp +disassembler.cpp collectedHeap.hpp +disassembler.cpp depChecker_.hpp +disassembler.cpp disassembler.hpp +disassembler.cpp fprofiler.hpp +disassembler.cpp handles.inline.hpp +disassembler.cpp hpi.hpp +disassembler.cpp stubCodeGenerator.hpp +disassembler.cpp stubRoutines.hpp -disassembler_.hpp disassemblerEnv.hpp -disassembler_.hpp os_.inline.hpp +disassembler.hpp globals.hpp +disassembler.hpp os_.inline.hpp dtraceAttacher.cpp codeCache.hpp dtraceAttacher.cpp deoptimization.hpp @@ -2909,7 +2909,7 @@ nmethod.cpp codeCache.hpp nmethod.cpp compileLog.hpp nmethod.cpp compiledIC.hpp nmethod.cpp compilerOracle.hpp -nmethod.cpp disassembler_.hpp +nmethod.cpp disassembler.hpp nmethod.cpp dtrace.hpp nmethod.cpp events.hpp nmethod.cpp jvmtiRedefineClassesTrace.hpp @@ -3763,7 +3763,7 @@ statSampler.hpp perfData.hpp statSampler.hpp task.hpp stubCodeGenerator.cpp assembler_.inline.hpp -stubCodeGenerator.cpp disassembler_.hpp +stubCodeGenerator.cpp disassembler.hpp stubCodeGenerator.cpp forte.hpp stubCodeGenerator.cpp oop.inline.hpp stubCodeGenerator.cpp stubCodeGenerator.hpp @@ -4530,7 +4530,7 @@ vmreg_.cpp vmreg.hpp vmreg_.hpp generate_platform_dependent_include vtableStubs.cpp allocation.inline.hpp -vtableStubs.cpp disassembler_.hpp +vtableStubs.cpp disassembler.hpp vtableStubs.cpp forte.hpp vtableStubs.cpp handles.inline.hpp vtableStubs.cpp instanceKlass.hpp diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 3fe43b53095..87423517536 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -456,7 +456,15 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr } TraceTime t1("Total compilation time", &_t_totalCompilation, TimeCompiler, TimeCompiler2); TraceTime t2(NULL, &_t_methodCompilation, TimeCompiler, false); - set_print_assembly(PrintOptoAssembly || _method->should_print_assembly()); + bool print_opto_assembly = PrintOptoAssembly || _method->has_option("PrintOptoAssembly"); + if (!print_opto_assembly) { + bool print_assembly = (PrintAssembly || _method->should_print_assembly()); + if (print_assembly && !Disassembler::can_decode()) { + tty->print_cr("PrintAssembly request changed to PrintOptoAssembly"); + print_opto_assembly = true; + } + } + set_print_assembly(print_opto_assembly); #endif if (ProfileTraps) { diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 1a46a00b7d9..9f79daac102 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -668,16 +668,19 @@ class CommandLineFlags { notproduct(bool, PrintCompilation2, false, \ "Print additional statistics per compilation") \ \ - notproduct(bool, PrintAdapterHandlers, false, \ + diagnostic(bool, PrintAdapterHandlers, false, \ "Print code generated for i2c/c2i adapters") \ \ - develop(bool, PrintAssembly, false, \ - "Print assembly code") \ + diagnostic(bool, PrintAssembly, false, \ + "Print assembly code (using external disassembler.so)") \ \ - develop(bool, PrintNMethods, false, \ + diagnostic(ccstr, PrintAssemblyOptions, false, \ + "Options string passed to disassembler.so") \ + \ + diagnostic(bool, PrintNMethods, false, \ "Print assembly code for nmethods when generated") \ \ - develop(bool, PrintNativeNMethods, false, \ + diagnostic(bool, PrintNativeNMethods, false, \ "Print assembly code for native nmethods when generated") \ \ develop(bool, PrintDebugInfo, false, \ @@ -702,7 +705,7 @@ class CommandLineFlags { develop(bool, PrintCodeCache2, false, \ "Print detailed info on the compiled_code cache when exiting") \ \ - develop(bool, PrintStubCode, false, \ + diagnostic(bool, PrintStubCode, false, \ "Print generated stub code") \ \ product(bool, StackTraceInThrowable, true, \ @@ -2250,7 +2253,7 @@ class CommandLineFlags { product_pd(bool, RewriteFrequentPairs, \ "Rewrite frequently used bytecode pairs into a single bytecode") \ \ - product(bool, PrintInterpreter, false, \ + diagnostic(bool, PrintInterpreter, false, \ "Prints the generated interpreter code") \ \ product(bool, UseInterpreter, true, \ @@ -2300,7 +2303,7 @@ class CommandLineFlags { develop(bool, PrintBytecodePairHistogram, false, \ "Print histogram of the executed bytecode pairs") \ \ - develop(bool, PrintSignatureHandlers, false, \ + diagnostic(bool, PrintSignatureHandlers, false, \ "Print code generated for native method signature handlers") \ \ develop(bool, VerifyOops, false, \ diff --git a/hotspot/src/share/vm/runtime/stubCodeGenerator.cpp b/hotspot/src/share/vm/runtime/stubCodeGenerator.cpp index bbdd6898b75..9b54e95eaa1 100644 --- a/hotspot/src/share/vm/runtime/stubCodeGenerator.cpp +++ b/hotspot/src/share/vm/runtime/stubCodeGenerator.cpp @@ -69,7 +69,6 @@ StubCodeGenerator::StubCodeGenerator(CodeBuffer* code) { _first_stub = _last_stub = NULL; } -#ifndef PRODUCT extern "C" { static int compare_cdesc(const void* void_a, const void* void_b) { int ai = (*((StubCodeDesc**) void_a))->index(); @@ -77,10 +76,8 @@ extern "C" { return ai - bi; } } -#endif StubCodeGenerator::~StubCodeGenerator() { -#ifndef PRODUCT if (PrintStubCode) { CodeBuffer* cbuf = _masm->code(); CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start()); @@ -105,7 +102,6 @@ StubCodeGenerator::~StubCodeGenerator() { tty->cr(); } } -#endif //PRODUCT } diff --git a/hotspot/src/share/vm/utilities/ostream.cpp b/hotspot/src/share/vm/utilities/ostream.cpp index d5ad211fc01..e5139f1dd30 100644 --- a/hotspot/src/share/vm/utilities/ostream.cpp +++ b/hotspot/src/share/vm/utilities/ostream.cpp @@ -52,8 +52,9 @@ void outputStream::update_position(const char* s, size_t len) { _precount += _position + 1; _position = 0; } else if (ch == '\t') { - _position += 8; - _precount -= 7; // invariant: _precount + _position == total count + int tw = 8 - (_position & 7); + _position += tw; + _precount -= tw-1; // invariant: _precount + _position == total count } else { _position += 1; } @@ -133,7 +134,17 @@ void outputStream::vprint_cr(const char* format, va_list argptr) { } void outputStream::fill_to(int col) { - while (position() < col) sp(); + int need_fill = col - position(); + sp(need_fill); +} + +void outputStream::move_to(int col, int slop, int min_space) { + if (position() >= col + slop) + cr(); + int need_fill = col - position(); + if (need_fill < min_space) + need_fill = min_space; + sp(need_fill); } void outputStream::put(char ch) { @@ -142,8 +153,23 @@ void outputStream::put(char ch) { write(buf, 1); } -void outputStream::sp() { - this->write(" ", 1); +#define SP_USE_TABS false + +void outputStream::sp(int count) { + if (count < 0) return; + if (SP_USE_TABS && count >= 8) { + int target = position() + count; + while (count >= 8) { + this->write("\t", 1); + count -= 8; + } + count = target - position(); + } + while (count > 0) { + int nw = (count > 8) ? 8 : count; + this->write(" ", nw); + count -= nw; + } } void outputStream::cr() { diff --git a/hotspot/src/share/vm/utilities/ostream.hpp b/hotspot/src/share/vm/utilities/ostream.hpp index 3d50c69888e..7232b485096 100644 --- a/hotspot/src/share/vm/utilities/ostream.hpp +++ b/hotspot/src/share/vm/utilities/ostream.hpp @@ -59,6 +59,7 @@ class outputStream : public ResourceObj { int indentation() const { return _indentation; } void set_indentation(int i) { _indentation = i; } void fill_to(int col); + void move_to(int col, int slop = 6, int min_space = 2); // sizing int width() const { return _width; } @@ -78,7 +79,7 @@ class outputStream : public ResourceObj { void print_raw_cr(const char* str) { write(str, strlen(str)); cr(); } void print_raw_cr(const char* str, int len){ write(str, len); cr(); } void put(char ch); - void sp(); + void sp(int count = 1); void cr(); void bol() { if (_position > 0) cr(); } From ccaa58c5db50f8a184b2f6ff3e3f184a8b8c24b2 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Wed, 2 Apr 2008 16:59:37 -0700 Subject: [PATCH 019/119] 6681577: PIT: some VM tests fails with -XX:+AggressiveOpts in 6u5p b01 C2 spends > 60% in escape analysis code during test nsk/regression/b4675027. Reviewed-by: never --- hotspot/src/share/vm/opto/escape.cpp | 70 ++++++++++++++++------------ hotspot/src/share/vm/opto/escape.hpp | 2 +- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp index e587cee177f..d3640ecb3a5 100644 --- a/hotspot/src/share/vm/opto/escape.cpp +++ b/hotspot/src/share/vm/opto/escape.cpp @@ -256,39 +256,49 @@ void ConnectionGraph::PointsTo(VectorSet &ptset, Node * n, PhaseTransform *phase } } -void ConnectionGraph::remove_deferred(uint ni) { - VectorSet visited(Thread::current()->resource_area()); +void ConnectionGraph::remove_deferred(uint ni, GrowableArray* deferred_edges, VectorSet* visited) { + // This method is most expensive during ConnectionGraph construction. + // Reuse vectorSet and an additional growable array for deferred edges. + deferred_edges->clear(); + visited->Clear(); uint i = 0; PointsToNode *ptn = ptnode_adr(ni); - while(i < ptn->edge_count()) { + // Mark current edges as visited and move deferred edges to separate array. + for (; i < ptn->edge_count(); i++) { uint t = ptn->edge_target(i); - PointsToNode *ptt = ptnode_adr(t); - if (ptn->edge_type(i) != PointsToNode::DeferredEdge) { - i++; - } else { +#ifdef ASSERT + assert(!visited->test_set(t), "expecting no duplications"); +#else + visited->set(t); +#endif + if (ptn->edge_type(i) == PointsToNode::DeferredEdge) { ptn->remove_edge(t, PointsToNode::DeferredEdge); - if(!visited.test_set(t)) { - for (uint j = 0; j < ptt->edge_count(); j++) { - uint n1 = ptt->edge_target(j); - PointsToNode *pt1 = ptnode_adr(n1); - switch(ptt->edge_type(j)) { - case PointsToNode::PointsToEdge: - add_pointsto_edge(ni, n1); - if(n1 == _phantom_object) { - // Special case - field set outside (globally escaping). - ptn->set_escape_state(PointsToNode::GlobalEscape); - } - break; - case PointsToNode::DeferredEdge: - add_deferred_edge(ni, n1); - break; - case PointsToNode::FieldEdge: - assert(false, "invalid connection graph"); - break; + deferred_edges->append(t); + } + } + for (int next = 0; next < deferred_edges->length(); ++next) { + uint t = deferred_edges->at(next); + PointsToNode *ptt = ptnode_adr(t); + for (uint j = 0; j < ptt->edge_count(); j++) { + uint n1 = ptt->edge_target(j); + if (visited->test_set(n1)) + continue; + switch(ptt->edge_type(j)) { + case PointsToNode::PointsToEdge: + add_pointsto_edge(ni, n1); + if(n1 == _phantom_object) { + // Special case - field set outside (globally escaping). + ptn->set_escape_state(PointsToNode::GlobalEscape); } - } + break; + case PointsToNode::DeferredEdge: + deferred_edges->append(n1); + break; + case PointsToNode::FieldEdge: + assert(false, "invalid connection graph"); + break; } } } @@ -1236,8 +1246,10 @@ void ConnectionGraph::compute_escape() { } VectorSet ptset(Thread::current()->resource_area()); - GrowableArray alloc_worklist; - GrowableArray worklist; + GrowableArray alloc_worklist; + GrowableArray worklist; + GrowableArray deferred_edges; + VectorSet visited(Thread::current()->resource_area()); // remove deferred edges from the graph and collect // information we will need for type splitting @@ -1247,7 +1259,7 @@ void ConnectionGraph::compute_escape() { PointsToNode::NodeType nt = ptn->node_type(); Node *n = ptn->_node; if (nt == PointsToNode::LocalVar || nt == PointsToNode::Field) { - remove_deferred(ni); + remove_deferred(ni, &deferred_edges, &visited); if (n->is_AddP()) { // If this AddP computes an address which may point to more that one // object, nothing the address points to can be scalar replaceable. diff --git a/hotspot/src/share/vm/opto/escape.hpp b/hotspot/src/share/vm/opto/escape.hpp index a7552b2c3ae..1d2c83511e7 100644 --- a/hotspot/src/share/vm/opto/escape.hpp +++ b/hotspot/src/share/vm/opto/escape.hpp @@ -269,7 +269,7 @@ private: // Remove outgoing deferred edges from the node referenced by "ni". // Any outgoing edges from the target of the deferred edge are copied // to "ni". - void remove_deferred(uint ni); + void remove_deferred(uint ni, GrowableArray* deferred_edges, VectorSet* visited); Node_Array _node_map; // used for bookeeping during type splitting // Used for the following purposes: From 194fc6af4304606d03685c05481445c43c72b8c2 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Thu, 3 Apr 2008 15:00:21 +0400 Subject: [PATCH 020/119] 6619458: testcase depends on a file with the name te{st.html Using test.html instead of te{st.html in reg test Reviewed-by: son --- .../IOExceptionIfEncodedURLTest.java | 64 +++++ .../IOExceptionIfEncodedURLTest.sh | 231 ++++++++++++++++++ .../IOExceptionIfEncodedURLTest/test.html | 21 ++ 3 files changed, 316 insertions(+) create mode 100644 jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.java create mode 100644 jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.sh create mode 100644 jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/test.html diff --git a/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.java b/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.java new file mode 100644 index 00000000000..5d7a73e9996 --- /dev/null +++ b/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.java @@ -0,0 +1,64 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + test + @bug 6193279 + @summary REGRESSION: AppletViewer throws IOException when path is encoded URL + @author Dmitry Cherepanov: area=appletviewer + @run compile IOExceptionIfEncodedURLTest.java + @run main IOExceptionIfEncodedURLTest + @run shell IOExceptionIfEncodedURLTest.sh +*/ + +import java.applet.Applet; +import sun.net.www.ParseUtil; +import java.io.File; +import java.net.MalformedURLException; + +public class IOExceptionIfEncodedURLTest extends Applet{ + public void init(){ + } + + public void start(){ + // We check that appletviewer writes this message to log file + System.err.println("the appletviewer started"); + } + + // We expect that sun.net.www.ParseUtil.fileToEncodedURL works like following + // if relative file URL, like this "file:index.html" is processed + static String url = "file:IOExceptionIfEncodedURLTest.java"; + public static final void main(String args[]) + throws MalformedURLException{ + System.err.println("prior checking..."); + String prefix = "file:"; + String path = ParseUtil.fileToEncodedURL(new File(System.getProperty("user.dir"))).getPath(); + String filename = url.substring(prefix.length()); + System.err.println("url="+url+" -> path="+path+",filename="+filename); + + if (!path.endsWith("/") && !filename.startsWith("/")) { + throw new RuntimeException("Incorrect '/' processing"); + } + } + +} diff --git a/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.sh b/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.sh new file mode 100644 index 00000000000..9df3e58741b --- /dev/null +++ b/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/IOExceptionIfEncodedURLTest.sh @@ -0,0 +1,231 @@ +# +# Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Sun designates this +# particular file as subject to the "Classpath" exception as provided +# by Sun in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, +# CA 95054 USA or visit www.sun.com if you need additional information or +# have any questions. +# + +#!/bin/ksh -p +# +# @test IOExceptionIfEncodedURLTest.sh +# @bug 6193279 6619458 +# @summary REGRESSION: AppletViewer throws IOException when path is encoded URL +# @author Dmitry Cherepanov: area=appletviewer +# @run compile IOExceptionIfEncodedURLTest.java +# @run main IOExceptionIfEncodedURLTest +# @run shell IOExceptionIfEncodedURLTest.sh + +# Beginning of subroutines: +status=1 + +#Call this from anywhere to fail the test with an error message +# usage: fail "reason why the test failed" +fail() + { echo "The test failed :-(" + echo "$*" 1>&2 + echo "exit status was $status" + exit $status + } #end of fail() + +#Call this from anywhere to pass the test with a message +# usage: pass "reason why the test passed if applicable" +pass() + { echo "The test passed!!!" + echo "$*" 1>&2 + exit 0 + } #end of pass() + +#Call this to run the test with a file name +test() + { + ${TESTJAVA}${FILESEP}bin${FILESEP}appletviewer -Xnosecurity ${URL} > err 2>&1 & + APPLET_ID=$! + sleep 15 + kill -9 $APPLET_ID + + # these exceptions will be thrown if the test fails + cat err | grep "I/O exception while reading" + exception=$? + if [ $exception = "0" ]; + then fail "test failed for "${URL}", see err file and CRs #6193279,6329251,6376334" + fi + + cat err | grep "java.lang.ClassNotFoundException" + exception=$? + if [ $exception = "0" ]; + then fail "test failed for "${URL}", see err file and CRs #6193279,6329251,6376334" + fi + + # the applet will log the same message + cat err | grep "the appletviewer started" + started=$? + + echo $started | grep "2" + if [ $? = 0 ] ; + then fail "test failed for "${URL}": syntax errors or inaccessible files" + fi + + if [ $started = "0" ]; + then echo "the test passed for "${URL} + else fail "test failed for "${URL}": the appletviewer behaviour is unexpected: "$started", see err file" + fi + } + +# end of subroutines + + +# The beginning of the script proper + +# Checking for proper OS +OS=`uname -s` +case "$OS" in + SunOS ) + VAR="One value for Sun" + DEFAULT_JDK=/usr/local/java/jdk1.2.1/solaris + FILESEP="/" + ;; + + Linux ) + VAR="A different value for Linux" + DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386 + FILESEP="/" + ;; + + Windows_95 | Windows_98 | Windows_NT | Windows_ME | CYGWIN_NT-5.1) + VAR="A different value for Win32" + DEFAULT_JDK=/usr/local/java/jdk1.2.1/win32 + FILESEP="\\" + ;; + + # catch all other OSs + * ) + echo "Unrecognized system! $OS" + fail "Unrecognized system! $OS" + ;; +esac + +# 6438730: Only a minimal set of env variables are set for shell tests. +# To guarantee that env variable holds correct value we need to set it ourselves. +if [ -z "${PWD}" ] ; then + PWD=`pwd` +fi + +# check that some executable or other file you need is available, abort if not +# note that the name of the executable is in the fail string as well. +# this is how to check for presence of the compiler, etc. +#RESOURCE=`whence SomeProgramOrFileNeeded` +#if [ "${RESOURCE}" = "" ] ; +# then fail "Need SomeProgramOrFileNeeded to perform the test" ; +#fi + +# Want this test to run standalone as well as in the harness, so do the +# following to copy the test's directory into the harness's scratch directory +# and set all appropriate variables: + +if [ -z "${TESTJAVA}" ] ; then + # TESTJAVA is not set, so the test is running stand-alone. + # TESTJAVA holds the path to the root directory of the build of the JDK + # to be tested. That is, any java files run explicitly in this shell + # should use TESTJAVA in the path to the java interpreter. + # So, we'll set this to the JDK spec'd on the command line. If none + # is given on the command line, tell the user that and use a cheesy + # default. + # THIS IS THE JDK BEING TESTED. + if [ -n "$1" ] ; + then TESTJAVA=$1 + else echo "no JDK specified on command line so using default!" + TESTJAVA=$DEFAULT_JDK + fi + TESTSRC=. + TESTCLASSES=. + STANDALONE=1; +fi +echo "JDK under test is: $TESTJAVA" + +#Deal with .class files: +if [ -n "${STANDALONE}" ] ; + then + #if standalone, remind user to cd to dir. containing test before running it + echo "Just a reminder: cd to the dir containing this test when running it" + # then compile all .java files (if there are any) into .class files + if [ -a *.java ] ; + then echo "Reminder, this test should be in its own directory with all" + echo "supporting files it needs in the directory with it." + ${TESTJAVA}/bin/javac ./*.java ; + fi + # else in harness so copy all the class files from where jtreg put them + # over to the scratch directory this test is running in. + else cp ${TESTCLASSES}/*.class . ; +fi + +#if in test harness, then copy the entire directory that the test is in over +# to the scratch directory. This catches any support files needed by the test. +#if [ -z "${STANDALONE}" ] ; +# then cp ${TESTSRC}/* . +#fi + +#Just before executing anything, make sure it has executable permission! +chmod 777 ./* + +############### YOUR TEST CODE HERE!!!!!!! ############# + +#All files required for the test should be in the same directory with +# this file. If converting a standalone test to run with the harness, +# as long as all files are in the same directory and it returns 0 for +# pass, you should be able to cut and paste it into here and it will +# run with the test harness. + +# This is an example of running something -- test +# The stuff below catches the exit status of test then passes or fails +# this shell test as appropriate ( 0 status is considered a pass here ) + +# The test verifies that appletviewer correctly works with the different +# names of the files, including relative and absolute paths + +# 6619458: exclude left brace from the name of the files managed by the VCS +NAME='test.html' + +ENCODED='te%7Bst.html' +UNENCODED='te{st.html' + +# Copy needed files into the harness's scratch directory +# or create a copy with the required name if the test is +# running as stand-alone +cp ${TESTSRC}${FILESEP}${NAME} ${UNENCODED} + +# the encoded name, the path is absolute +URL="file:"${PWD}${FILESEP}${ENCODED} +test + +# the encoded name, the path is relative +URL="file:"${ENCODED} +test + +# the unencoded name, the path is absolute +URL="file:"${PWD}${FILESEP}${UNENCODED} +test + +# the unencoded name, the path is relative +URL="file:"${UNENCODED} +test + +# pick up our toys from the scratch directory +rm ${UNENCODED} diff --git a/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/test.html b/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/test.html new file mode 100644 index 00000000000..104905bc4ea --- /dev/null +++ b/jdk/test/java/awt/appletviewer/IOExceptionIfEncodedURLTest/test.html @@ -0,0 +1,21 @@ + + + +Started by shell script + + + +

IOExceptionIfEncodedURLTest
Bug ID: 6193279

+ +

See the dialog box (usually in upper left corner) for instructions

+ + + + \ No newline at end of file From a602ec9fb2dbdd710f428de017a7759c99cceeff Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Thu, 3 Apr 2008 15:48:10 +0400 Subject: [PATCH 021/119] 6615015: Typo in javadoc for Component.getTreeLock() Fix for typo Reviewed-by: son --- jdk/src/share/classes/java/awt/Component.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java index 005a282442a..1bbd4dcf45b 100644 --- a/jdk/src/share/classes/java/awt/Component.java +++ b/jdk/src/share/classes/java/awt/Component.java @@ -1005,7 +1005,7 @@ public abstract class Component implements ImageObserver, MenuContainer, /** * Gets this component's locking object (the object that owns the thread - * sychronization monitor) for AWT component-tree and layout + * synchronization monitor) for AWT component-tree and layout * operations. * @return this component's locking object */ From a61087c7628bf61405b90ff48eff3ef171f170d4 Mon Sep 17 00:00:00 2001 From: Peter Zhelezniakov Date: Thu, 3 Apr 2008 16:41:43 +0400 Subject: [PATCH 022/119] 4714674: JEditorPane.setPage(url) blocks AWT thread when HTTP protocol is used Both POST and GET can now be processed asynchronously; PageLoader refactored Reviewed-by: gsm --- .../classes/javax/swing/JEditorPane.java | 125 +++++------------- .../javax/swing/JEditorPane/bug4714674.java | 124 +++++++++++++++++ 2 files changed, 155 insertions(+), 94 deletions(-) create mode 100644 jdk/test/javax/swing/JEditorPane/bug4714674.java diff --git a/jdk/src/share/classes/javax/swing/JEditorPane.java b/jdk/src/share/classes/javax/swing/JEditorPane.java index 8395075295f..4cf18c009c3 100644 --- a/jdk/src/share/classes/javax/swing/JEditorPane.java +++ b/jdk/src/share/classes/javax/swing/JEditorPane.java @@ -429,9 +429,8 @@ public class JEditorPane extends JTextComponent { // different url or POST method, load the new content int p = getAsynchronousLoadPriority(getDocument()); - if ((postData == null) || (p < 0)) { - // Either we do not have POST data, or should submit the data - // synchronously. + if (p < 0) { + // open stream synchronously InputStream in = getStream(page); if (kit != null) { Document doc = initializeModel(kit, page); @@ -440,22 +439,13 @@ public class JEditorPane extends JTextComponent { // view notifications slowing it down (i.e. best synchronous // behavior) or set the model and start to feed it on a separate // thread (best asynchronous behavior). - synchronized(this) { - if (loading != null) { - // we are loading asynchronously, so we need to cancel - // the old stream. - loading.cancel(); - loading = null; - } - } p = getAsynchronousLoadPriority(doc); if (p >= 0) { // load asynchronously setDocument(doc); synchronized(this) { - loading = new PageStream(in); - Thread pl = new PageLoader(doc, loading, p, loaded, page); - pl.start(); + pageLoader = new PageLoader(doc, in, loaded, page); + pageLoader.execute(); } return; } @@ -464,11 +454,15 @@ public class JEditorPane extends JTextComponent { reloaded = true; } } else { - // We have POST data and should send it asynchronously. - // Send (and subsequentally read) data in separate thread. + // we may need to cancel background loading + if (pageLoader != null) { + pageLoader.cancel(true); + } + + // Do everything in a background thread. // Model initialization is deferred to that thread, too. - Thread pl = new PageLoader(null, null, p, loaded, page); - pl.start(); + pageLoader = new PageLoader(null, null, loaded, page); + pageLoader.execute(); return; } } @@ -604,44 +598,38 @@ public class JEditorPane extends JTextComponent { /** - * Thread to load a stream into the text document model. + * Loads a stream into the text document model. */ - class PageLoader extends Thread { + class PageLoader extends SwingWorker { /** * Construct an asynchronous page loader. */ - PageLoader(Document doc, InputStream in, int priority, URL old, - URL page) { - setPriority(priority); + PageLoader(Document doc, InputStream in, URL old, URL page) { this.in = in; this.old = old; this.page = page; this.doc = doc; } - boolean pageLoaded = false; - /** * Try to load the document, then scroll the view * to the reference (if specified). When done, fire * a page property change event. */ - public void run() { + protected URL doInBackground() { + boolean pageLoaded = false; try { if (in == null) { in = getStream(page); if (kit == null) { // We received document of unknown content type. - UIManager.getLookAndFeel().provideErrorFeedback( - JEditorPane.this); - return; - } - // Access to loading should be synchronized. - synchronized(JEditorPane.this) { - in = loading = new PageStream(in); + UIManager.getLookAndFeel(). + provideErrorFeedback(JEditorPane.this); + return old; } } + if (doc == null) { try { SwingUtilities.invokeAndWait(new Runnable() { @@ -653,11 +641,11 @@ public class JEditorPane extends JTextComponent { } catch (InvocationTargetException ex) { UIManager.getLookAndFeel().provideErrorFeedback( JEditorPane.this); - return; + return old; } catch (InterruptedException ex) { UIManager.getLookAndFeel().provideErrorFeedback( JEditorPane.this); - return; + return old; } } @@ -682,16 +670,14 @@ public class JEditorPane extends JTextComponent { } catch (IOException ioe) { UIManager.getLookAndFeel().provideErrorFeedback(JEditorPane.this); } finally { - synchronized(JEditorPane.this) { - loading = null; - } - SwingUtilities.invokeLater(new Runnable() { - public void run() { - if (pageLoaded) { - firePropertyChange("page", old, page); + if (pageLoaded) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + JEditorPane.this.firePropertyChange("page", old, page); } - } - }); + }); + } + return (pageLoaded ? page : old); } } @@ -718,51 +704,6 @@ public class JEditorPane extends JTextComponent { Document doc; } - static class PageStream extends FilterInputStream { - - boolean canceled; - - public PageStream(InputStream i) { - super(i); - canceled = false; - } - - /** - * Cancel the loading of the stream by throwing - * an IOException on the next request. - */ - public synchronized void cancel() { - canceled = true; - } - - protected synchronized void checkCanceled() throws IOException { - if (canceled) { - throw new IOException("page canceled"); - } - } - - public int read() throws IOException { - checkCanceled(); - return super.read(); - } - - public long skip(long n) throws IOException { - checkCanceled(); - return super.skip(n); - } - - public int available() throws IOException { - checkCanceled(); - return super.available(); - } - - public void reset() throws IOException { - checkCanceled(); - super.reset(); - } - - } - /** * Fetches a stream for the given URL, which is about to * be loaded by the setPage method. By @@ -1573,11 +1514,7 @@ public class JEditorPane extends JTextComponent { // --- variables --------------------------------------- - /** - * Stream currently loading asynchronously (potentially cancelable). - * Access to this variable should be synchronized. - */ - PageStream loading; + private SwingWorker pageLoader; /** * Current content binding of the editor. diff --git a/jdk/test/javax/swing/JEditorPane/bug4714674.java b/jdk/test/javax/swing/JEditorPane/bug4714674.java new file mode 100644 index 00000000000..a3426144330 --- /dev/null +++ b/jdk/test/javax/swing/JEditorPane/bug4714674.java @@ -0,0 +1,124 @@ +/* @test + @bug 4714674 + @summary Tests that JEditorPane opens HTTP connection asynchronously + @author Peter Zhelezniakov + @run main bug4714674 +*/ + +import javax.swing.*; + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.concurrent.Executors; + + +public class bug4714674 { + + public static void main(String[] args) throws Exception { + new bug4714674().test(); + } + + private void test() throws Exception { + final DeafServer server = new DeafServer(); + final String baseURL = "http://localhost:" + server.getPort() + "/"; + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + try { + JEditorPane pane = new JEditorPane(); + ((javax.swing.text.AbstractDocument)pane.getDocument()). + setAsynchronousLoadPriority(1); + + // this will block EDT unless 4714674 is fixed + pane.setPage(baseURL); + } catch (IOException e) { + // should not happen + throw new Error(e); + } + } + }); + + // if 4714674 is fixed, this executes before connection times out + SwingUtilities.invokeLater(new Runnable() { + public void run() { + synchronized (server) { + server.wakeup = true; + server.notifyAll(); + } + pass(); + } + }); + + // wait, then check test status + try { + Thread.sleep(5000); + if (!passed()) { + throw new RuntimeException("Failed: EDT was blocked"); + } + } finally { + server.destroy(); + } + } + + private boolean passed = false; + + private synchronized boolean passed() { + return passed; + } + + private synchronized void pass() { + passed = true; + } +} + +/** + * A "deaf" HTTP server that does not respond to requests. + */ +class DeafServer { + HttpServer server; + boolean wakeup = false; + + /** + * Create and start the HTTP server. + */ + public DeafServer() throws IOException { + InetSocketAddress addr = new InetSocketAddress(0); + server = HttpServer.create(addr, 0); + HttpHandler handler = new DeafHandler(); + server.createContext("/", handler); + server.setExecutor(Executors.newCachedThreadPool()); + server.start(); + } + + /** + * Stop server without any delay. + */ + public void destroy() { + server.stop(0); + } + + /** + * Return actual server port number, useful for constructing request URIs. + */ + public int getPort() { + return server.getAddress().getPort(); + } + + + class DeafHandler implements HttpHandler { + public void handle(HttpExchange r) throws IOException { + synchronized (DeafServer.this) { + while (! wakeup) { + try { + DeafServer.this.wait(); + } catch (InterruptedException e) { + // just wait again + } + } + } + } + } +} From 89290f28174957b882ec0c02ae613856c376c06b Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Thu, 3 Apr 2008 10:20:44 -0700 Subject: [PATCH 023/119] 6619271: The -Xprintflags causes the VM to segv Add null checks Reviewed-by: jrose, kvn --- hotspot/src/share/vm/runtime/globals.cpp | 51 +++++++++++++----------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/hotspot/src/share/vm/runtime/globals.cpp b/hotspot/src/share/vm/runtime/globals.cpp index 139fe1c41f5..f70d0c08bd5 100644 --- a/hotspot/src/share/vm/runtime/globals.cpp +++ b/hotspot/src/share/vm/runtime/globals.cpp @@ -68,18 +68,20 @@ void Flag::print_on(outputStream* st) { if (is_uintx()) st->print("%-16lu", get_uintx()); if (is_ccstr()) { const char* cp = get_ccstr(); - const char* eol; - while ((eol = strchr(cp, '\n')) != NULL) { - char format_buffer[FORMAT_BUFFER_LEN]; - size_t llen = pointer_delta(eol, cp, sizeof(char)); - jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, - "%%." SIZE_FORMAT "s", llen); - st->print(format_buffer, cp); - st->cr(); - cp = eol+1; - st->print("%5s %-35s += ", "", name); + if (cp != NULL) { + const char* eol; + while ((eol = strchr(cp, '\n')) != NULL) { + char format_buffer[FORMAT_BUFFER_LEN]; + size_t llen = pointer_delta(eol, cp, sizeof(char)); + jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, + "%%." SIZE_FORMAT "s", llen); + st->print(format_buffer, cp); + st->cr(); + cp = eol+1; + st->print("%5s %-35s += ", "", name); + } + st->print("%-16s", cp); } - st->print("%-16s", cp); } st->print(" %s", kind); st->cr(); @@ -94,18 +96,21 @@ void Flag::print_as_flag(outputStream* st) { st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx()); } else if (is_ccstr()) { st->print("-XX:%s=", name); - // Need to turn embedded '\n's back into separate arguments - // Not so efficient to print one character at a time, - // but the choice is to do the transformation to a buffer - // and print that. And this need not be efficient. - for (const char* cp = get_ccstr(); *cp != '\0'; cp += 1) { - switch (*cp) { - default: - st->print("%c", *cp); - break; - case '\n': - st->print(" -XX:%s=", name); - break; + const char* cp = get_ccstr(); + if (cp != NULL) { + // Need to turn embedded '\n's back into separate arguments + // Not so efficient to print one character at a time, + // but the choice is to do the transformation to a buffer + // and print that. And this need not be efficient. + for (; *cp != '\0'; cp += 1) { + switch (*cp) { + default: + st->print("%c", *cp); + break; + case '\n': + st->print(" -XX:%s=", name); + break; + } } } } else { From 3bc5120d53fd92a6ff1c9d4fc9d719b08547a560 Mon Sep 17 00:00:00 2001 From: Xiaobin Lu Date: Thu, 3 Apr 2008 12:21:06 -0700 Subject: [PATCH 024/119] 6671882: memory access after free in solaris/vm/os_solaris.cpp Corrected the wrong memory access problem and made some minor clean ups Reviewed-by: dholmes, jcoomes --- hotspot/src/os/solaris/vm/os_solaris.cpp | 55 ++++++++++-------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 75ad158a9cd..f1051ed2acf 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -4391,61 +4391,52 @@ static address resolve_symbol(const char *name) { // threads. Calling thr_setprio is meaningless in this case. // bool isT2_libthread() { - int i, rslt; static prheader_t * lwpArray = NULL; static int lwpSize = 0; static int lwpFile = -1; lwpstatus_t * that; - int aslwpcount; char lwpName [128]; bool isT2 = false; #define ADR(x) ((uintptr_t)(x)) #define LWPINDEX(ary,ix) ((lwpstatus_t *)(((ary)->pr_entsize * (ix)) + (ADR((ary) + 1)))) - aslwpcount = 0; - lwpSize = 16*1024; - lwpArray = ( prheader_t *)NEW_C_HEAP_ARRAY (char, lwpSize); - lwpFile = open ("/proc/self/lstatus", O_RDONLY, 0); - if (lwpArray == NULL) { - if ( ThreadPriorityVerbose ) warning ("Couldn't allocate T2 Check array\n"); - return(isT2); - } + lwpFile = open("/proc/self/lstatus", O_RDONLY, 0); if (lwpFile < 0) { - if ( ThreadPriorityVerbose ) warning ("Couldn't open /proc/self/lstatus\n"); - return(isT2); + if (ThreadPriorityVerbose) warning ("Couldn't open /proc/self/lstatus\n"); + return false; } + lwpSize = 16*1024; for (;;) { lseek (lwpFile, 0, SEEK_SET); - rslt = read (lwpFile, lwpArray, lwpSize); - if ((lwpArray->pr_nent * lwpArray->pr_entsize) <= lwpSize) { + lwpArray = (prheader_t *)NEW_C_HEAP_ARRAY(char, lwpSize); + if (read(lwpFile, lwpArray, lwpSize) < 0) { + if (ThreadPriorityVerbose) warning("Error reading /proc/self/lstatus\n"); + break; + } + if ((lwpArray->pr_nent * lwpArray->pr_entsize) <= lwpSize) { + // We got a good snapshot - now iterate over the list. + int aslwpcount = 0; + for (int i = 0; i < lwpArray->pr_nent; i++ ) { + that = LWPINDEX(lwpArray,i); + if (that->pr_flags & PR_ASLWP) { + aslwpcount++; + } + } + if (aslwpcount == 0) isT2 = true; break; } - FREE_C_HEAP_ARRAY(char, lwpArray); lwpSize = lwpArray->pr_nent * lwpArray->pr_entsize; - lwpArray = ( prheader_t *)NEW_C_HEAP_ARRAY (char, lwpSize); - if (lwpArray == NULL) { - if ( ThreadPriorityVerbose ) warning ("Couldn't allocate T2 Check array\n"); - return(isT2); - } + FREE_C_HEAP_ARRAY(char, lwpArray); // retry. } - // We got a good snapshot - now iterate over the list. - for (i = 0; i < lwpArray->pr_nent; i++ ) { - that = LWPINDEX(lwpArray,i); - if (that->pr_flags & PR_ASLWP) { - aslwpcount++; - } - } - if ( aslwpcount == 0 ) isT2 = true; - FREE_C_HEAP_ARRAY(char, lwpArray); close (lwpFile); - if ( ThreadPriorityVerbose ) { - if ( isT2 ) tty->print_cr("We are running with a T2 libthread\n"); + if (ThreadPriorityVerbose) { + if (isT2) tty->print_cr("We are running with a T2 libthread\n"); else tty->print_cr("We are not running with a T2 libthread\n"); } - return (isT2); + return isT2; } From 21dbe47a30f57d24bf2dcbd4b6ffa1214b08ba42 Mon Sep 17 00:00:00 2001 From: Chuck Rasbold Date: Thu, 3 Apr 2008 13:33:13 -0700 Subject: [PATCH 025/119] 6624474: Server compiler generates unexpected LinkageError Fix load_signature_classes to tolerate LinkageErrors Reviewed-by: kvn, never --- hotspot/src/share/vm/oops/methodOop.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/oops/methodOop.cpp b/hotspot/src/share/vm/oops/methodOop.cpp index dfe9dee8560..db4dc773590 100644 --- a/hotspot/src/share/vm/oops/methodOop.cpp +++ b/hotspot/src/share/vm/oops/methodOop.cpp @@ -888,10 +888,11 @@ bool methodOopDesc::load_signature_classes(methodHandle m, TRAPS) { symbolHandle name (THREAD, sym); klassOop klass = SystemDictionary::resolve_or_null(name, class_loader, protection_domain, THREAD); - // We are loading classes eagerly. If a ClassNotFoundException was generated, - // be sure to ignore it. + // We are loading classes eagerly. If a ClassNotFoundException or + // a LinkageError was generated, be sure to ignore it. if (HAS_PENDING_EXCEPTION) { - if (PENDING_EXCEPTION->is_a(SystemDictionary::classNotFoundException_klass())) { + if (PENDING_EXCEPTION->is_a(SystemDictionary::classNotFoundException_klass()) || + PENDING_EXCEPTION->is_a(SystemDictionary::linkageError_klass())) { CLEAR_PENDING_EXCEPTION; } else { return false; From 3093e354db2671d203d5134040a5cea39c47c52b Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Thu, 3 Apr 2008 21:26:03 -0700 Subject: [PATCH 026/119] 6646020: assert(in_bb(n),"must be in block") in -Xcomp mode Reviewed-by: kvn, rasbold --- hotspot/src/share/vm/opto/superword.cpp | 5 + hotspot/test/compiler/6646020/Tester.java | 886 ++++++++++++++++++++++ 2 files changed, 891 insertions(+) create mode 100644 hotspot/test/compiler/6646020/Tester.java diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index 625acd85efa..b9b8a98bb2d 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -65,6 +65,11 @@ void SuperWord::transform_loop(IdealLoopTree* lpt) { Node *cl_exit = cl->loopexit(); if (cl_exit->in(0) != lpt->_head) return; + // Make sure the are no extra control users of the loop backedge + if (cl->back_control()->outcnt() != 1) { + return; + } + // Check for pre-loop ending with CountedLoopEnd(Bool(Cmp(x,Opaque1(limit)))) CountedLoopEndNode* pre_end = get_pre_loop_end(cl); if (pre_end == NULL) return; diff --git a/hotspot/test/compiler/6646020/Tester.java b/hotspot/test/compiler/6646020/Tester.java new file mode 100644 index 00000000000..1035a7bd8eb --- /dev/null +++ b/hotspot/test/compiler/6646020/Tester.java @@ -0,0 +1,886 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6646020 + * @summary assert(in_bb(n),"must be in block") in -Xcomp mode + */ + +/* Complexity upper bound: 3361 ops */ + +class Tester_Class_0 { + static byte var_1; + + + public Tester_Class_0() + { + "".length(); + { + var_1 = (var_1 = (new byte[(byte)'D'])[(byte)2.40457E38F]); + var_1 = (var_1 = (byte)1.738443503665377E307); + var_1 = (var_1 = (byte)1237144669662298112L); + } + var_1 = "baldh".equalsIgnoreCase("") ? (var_1 = (byte)7.2932087E37F) : (byte)3909726578709910528L; + var_1 = (var_1 = (var_1 = (var_1 = (byte)7.223761846153971E307))); + var_1 = (var_1 = (var_1 = (var_1 = (var_1 = (byte)((short)7860452029249754112L + (byte)1.7374232546809952E308))))); + var_1 = (!true ? (var_1 = (byte)4359229782598970368L) : (short)(byte)1.7509836746850026E308) >= 'P' ? (var_1 = (byte)3.275114793095594E307) : (byte)(- ((byte)1.5595572E38F) / 8.2971296E37F); + byte var_9 = (true ? true : (false ? true : false)) ? (var_1 = (var_1 = (byte)9.928434E37F)) : (var_1 = (byte)9.785060633966518E307); + final byte var_10 = 53; + var_9 <<= (true | true) & (((var_10 == "".substring(2001075014).compareToIgnoreCase("rhbytggv") ? !true : ! !true) ? !false : false) ? !true & true : !false) ? var_10 : var_10; + var_9 <<= - (var_9 -= - ~6397182310329038848L >> (char)955837891 << (short)- - -8.4452034E37F >> + ~5485157895941338112L); + --var_9; + var_9 >>= 'V'; + var_9 -= (new char[var_10])[var_9]; + double var_11; + var_11 = (var_11 = (new int[var_9 = (var_9 %= 684423748)])[var_9]); + var_9 /= 'q'; + var_9 *= ~var_9 | (short)1.7667766368850557E308 - "w".trim().charAt(- (var_9 /= + (var_11 = 'q'))); + if (var_10 <= 605036859609030656L | !false & false) + { + var_9 >>>= false ^ false ? (new short[var_10])[var_10] : (short)1013619326108001280L; + } + else + { + var_11 = var_9; + } + var_9 -= 'X'; + var_9 *= 'E'; + { + var_9 ^= (new short[var_9])[var_9 >>>= 'c']; + } + var_11 = 4315867074042433536L; + double var_12 = 1.2183900219527627E308; + var_9 <<= (false ? !false : false) ? '\\' : 'D'; + } + + + + + private final long func_0() + { + float var_2 = 0F; + var_1 = (var_1 = (var_1 = (byte)((short)1.4106931056021857E308 % var_2))); + for (new String(); true & (! !true ^ !false | false) && var_2 < 1; var_1 = (var_1 = (var_1 = (var_1 = (byte)1183673628639185920L)))) + { + var_1 = true | false ? (var_1 = (byte)1.6263855E37F) : (byte)'O'; + var_2++; + "fui".toUpperCase(); + final int var_3 = (var_1 = (var_1 = (byte)'i')) + (byte)2008561384 / (byte)1.4413369179905006E308; + } + var_1 = (var_1 = false ^ false ? (byte)2.3850814E38F : (byte)4.42887E37F); + final float var_4 = 3.052265E38F; + var_1 = (var_1 = (var_1 = (var_1 = (var_1 = (byte)'o')))); + long var_5; + var_1 = (var_1 = (byte)((var_1 = (byte)1913212786) * (var_1 = (byte)var_2))); + var_5 = (short)3.2024069E38F * (short)(var_5 = 'Q'); + var_5 = (false ? true : false) ? (short)1098137179 : (byte)~695765814858203136L; + var_1 = (var_1 = true & false ^ true ? (byte)1662737306 : (byte)'r'); + { + (true ? "a" : "lymivj".toString()).codePointCount((short)3.032349E38F + (var_1 = (var_1 = (var_1 = (var_1 = (byte)1.3159799E37F)))), (byte)2.0898819853138264E307 & (new short[(byte)(short)var_2])[var_1 = (byte)(short)4.859332921376913E307]); + } + double var_6; + var_6 = 1359078277; + final float var_7 = 3.5952457E37F; + var_5 = ('u' | 9005660398910009344L) << 'j'; + int var_8; + var_5 = (!false || true & !false) && false ? (byte)1836342254 : (byte)1.4836203E38F; + var_1 = (var_1 = (var_1 = (var_1 = (byte)1.5824984701060493E308))); + var_1 = (var_1 = (var_1 = (byte)~ (var_1 = (var_1 = (var_1 = (byte)var_7))))); + return +9.067416E37F <= (true | true ^ false ? (var_1 = (byte)(short)1.5243446E38F) : (var_1 = (byte)1.6893049E37F)) ? (byte)~4408841475280588800L - (var_5 = (var_1 = (byte)2.1542209E38F)) : (var_8 = (short)var_4); + } + + protected final static double func_1(final char arg_0, final long arg_1) + { + var_1 = (short)8779631802405542912L << 'x' <= arg_0 ? (byte)+9.96859509852443E307 : (var_1 = (var_1 = (byte)(short)5.218454879223281E307)); + return 5.57437404144192E307; + } + + double func_2(byte arg_0, final boolean arg_1, Object arg_2) + { + arg_2 = arg_1 != arg_1 ? "wq" : "w"; + arg_2 = arg_2; + if (arg_1) + { + arg_2 = false & arg_1 ? "hasmp" : (arg_2 = arg_2); + } + else + { + arg_2 = "lcquv"; + } + arg_0 -= arg_1 ^ false ? (arg_0 |= (short)arg_0) : (~3462197988186869760L | 7274210797196514304L) % - - + +130998764279904256L; + arg_0 &= (true ? - - ~7861994999369861120L << 'l' : 'c') * 1246069704; + return (arg_1 ? 9.311174E37F : 1.7085558737202237E308) * 1168887722; + } + + public String toString() + { + String result = "[\n"; + result += "Tester_Class_0.var_1 = "; result += Tester.Printer.print(var_1); + result += ""; + result += "\n]"; + return result; + } +} + + +final class Tester_Class_1 extends Tester_Class_0 { + static Object var_13; + final static boolean var_14 = false | (false ? false : true); + Object var_15; + static byte var_16; + final long var_17 = (long)(-9.40561658911133E307 - (short)2.2016736E38F) ^ (char)1099667310; + static boolean var_18; + static float var_19; + final static byte var_20 = 123; + static byte var_21 = var_1 = (var_1 = var_20); + final static float var_22 = 1.5415572E38F; + + + public Tester_Class_1() + { + char[][] var_39; + boolean var_40 = false | !var_14; + if (var_14) + { + final String[] var_41 = (new String[var_21][var_20])[var_21 *= var_21]; + var_15 = (new Tester_Class_0[var_20])[var_20]; + --var_21; + int var_42; + } + else + { + var_19 = (short)325110146; + } + var_40 &= true; + var_13 = (((new Tester_Class_1[var_21 |= (new char[var_20])[var_21]])[var_21]).var_15 = (new String[var_21][var_20][var_20])[var_21 >>= (byte)(int)var_22]); + var_15 = "m"; + } + + + + + + protected final static Tester_Class_0 func_0(final char arg_0, boolean arg_1) + { + final short var_23 = false ? (short)2.2956268E38F : var_20; + { + ((new Tester_Class_1[var_21])[var_20]).var_15 = ((new Tester_Class_0[var_20][var_21])[var_21])[var_20]; + } + var_19 = var_23; + { + var_21++; + --var_21; + var_13 = (false ? arg_1 : arg_1) ? "" : "aianteahl"; + arg_1 ^= ! (var_14 ? var_14 : !var_14); + } + (arg_1 ? "rq" : "certd").trim(); + arg_1 ^= 's' < var_22; + var_19 = 'T'; + var_19 = var_14 ? --var_21 : var_20; + var_19 = (var_21 >>>= ~ -1559436447128426496L >> 88912720393932800L) | (new char[var_20][var_21])[var_21][var_20]; + short var_24 = 7601; + if (arg_1) + { + var_13 = (new Tester_Class_0[var_20])[var_21]; + } + else + { + var_19 = var_23; + } + var_19 = var_24; + var_19 = 174274929356416000L; + return arg_1 ? (Tester_Class_0)(new Object[var_20])[var_21 >>>= - ((byte)6471979169965446144L)] : (new Tester_Class_0[var_21])[var_20]; + } + + private static int func_1(final Object arg_0, final boolean arg_1) + { + var_19 = 'N'; + var_13 = "ftspm".toUpperCase(); + var_18 = arg_1 ? !arg_1 : var_14; + var_19 = var_21 % 'j'; + { + var_13 = new short[var_21 >>= 8019540572802872320L]; + } + final Tester_Class_0 var_25 = arg_1 ? ((short)1.3614569631193786E308 >= (short)var_20 ? func_0('O', true) : (Tester_Class_0)arg_0) : func_0('e', false); + "cltpxrg".offsetByCodePoints((new short[var_20])[(byte)'F'] & var_20, 942627356); + final Object var_26 = ((new Tester_Class_1[var_21])[var_20]).var_15 = arg_0; + { + var_21 |= 'H'; + } + var_19 = 4705089801895780352L; + var_19 = (var_18 = arg_1 & false) ? var_20 : (! (~var_21 > var_22) ? (new short[var_20])[var_21] : (short)3904907750551380992L); + var_18 = false; + { + var_18 = "aoy".startsWith("ia", 18060804); + if (true) + { + final short var_27 = 4832; + } + else + { + var_18 = (var_18 = arg_1) ? !false : !var_14; + } + var_18 = (var_18 = var_14); + var_19 = 'L'; + } + func_0((false ? ! ((var_21 -= 4.670301365216022E307) > 1.1839209E37F) : (var_18 = false)) ? 's' : 'R', 'Z' > - ((long)var_21) << 2585724390819764224L & var_25.func_2(var_21, false, var_13 = var_25) != 4918861136400833536L); + double var_28 = 0; + var_21 %= -var_28; + for (byte var_29 = 91; arg_1 && (var_28 < 1 && false); var_19 = var_20) + { + var_19 = (var_18 = arg_1) & (var_18 = false) ? 'm' : '['; + var_28++; + var_18 = var_14; + var_21 += (short)1363703973; + } + var_19 = (var_19 = var_22); + var_18 = (var_18 = false | false ? 1743087391 <= (var_21 >>= 8790741242417599488L) : !arg_1); + var_18 = true | true; + --var_21; + var_18 = !var_14 & false; + "mt".indexOf(var_14 ? new String("fpu") : "awivb", (var_14 ? !true : (var_18 = var_14)) ? + ++var_21 : ~var_20); + return (short)(new float[var_21--])[var_21] & ((var_18 = false) ? (var_21 *= 'N') : var_20 + (short)1680927063794178048L) & 1839004800; + } + + protected static int func_2(Tester_Class_0[][] arg_0) + { + ((new Tester_Class_1[var_20][var_21])[var_20][var_20]).var_15 = ((new int[var_21][var_21][(byte)var_22])[var_21 <<= var_20])[var_20]; + ((new Tester_Class_1[var_20])[var_20]).var_15 = "d"; + int var_30 = 0; + "joxjgpywp".lastIndexOf(1834367264 >> var_21, (byte)7.572305E37F >>> (false ? (short)2.3909862E38F : + - +3939434849912855552L)); + while (var_14 | false ^ var_14 && (var_30 < 1 && true)) + { + var_1 = var_20; + var_30++; + var_13 = new float[var_21][--var_21]; + boolean var_31; + } + var_19 = ((new Tester_Class_1[var_21])[var_20]).var_17 <= (~2158227803735181312L & 6001748808824762368L) ? (short)var_20 : var_20; + var_18 = (var_18 = true); + return (byte)(new short[var_20])[var_20] >>> ((new char[var_21][var_21])[var_21 |= 6074708801143703552L])[var_20]; + } + + private final String func_3(boolean arg_0, short arg_1, short arg_2) + { + var_13 = (Tester_Class_0)((arg_0 ^= arg_0) ? (var_13 = (var_15 = (var_15 = "grfphyrs"))) : (var_13 = new Object[var_21 *= ']'])); + if (true & ! (arg_0 ^= !arg_0 | true)) + { + boolean var_32 = true; + var_19 = --arg_1; + arg_2 <<= var_21; + } + else + { + arg_0 |= false; + } + var_21 >>>= arg_1; + final float var_33 = 2.5500976E38F; + return ""; + } + + private static String func_4(final double arg_0, final Object arg_1, final short[] arg_2, final char arg_3) + { + float var_34; + var_21++; + ((new Tester_Class_1[var_20])[var_20]).var_15 = false ? arg_1 : arg_1; + var_13 = arg_1; + var_19 = var_22; + var_13 = new long[var_21 /= 1038797776 + var_21][--var_21]; + ++var_21; + var_18 = false && false; + var_21--; + "".lastIndexOf("kjro"); + final int var_35 = (var_21 <<= var_21--) * var_21--; + if ("kohilkx".startsWith("gy", var_35)) + { + var_34 = 2.0849673E37F; + } + else + { + double var_36 = arg_0; + } + var_34 = (var_21 /= var_20); + { + func_2(new Tester_Class_0[var_20][var_21]); + var_34 = var_20 * (- ~5805881602002385920L / arg_3) << (short)~8041668398152312832L; + var_13 = (var_13 = "qfwbfdf"); + } + ((new Tester_Class_1[var_20])[var_21 += var_20]).var_15 = false ? func_0(arg_3, var_14) : func_0('J', var_18 = var_14); + var_18 = (var_18 = var_14) & var_14; + if ((new boolean[var_21])[var_21 >>= 121380821]) + { + var_34 = 1382979413; + } + else + { + var_34 = (var_20 & var_20) + (true ? 'I' : arg_3); + } + byte var_37; + ((new Tester_Class_1[var_20][var_21])[var_14 ^ var_14 | !var_14 ? var_20 : var_20][var_21 ^= (short)1692053070 & + ~7232298887878750208L - 1512699919]).var_15 = arg_2; + byte var_38 = 1; + var_38 -= arg_0; + var_34 = arg_3; + return var_14 ? "" : "xgkr".toUpperCase(); + } + + public String toString() + { + String result = "[\n"; + result += "Tester_Class_1.var_1 = "; result += Tester.Printer.print(var_1); + result += "\n"; + result += "Tester_Class_1.var_16 = "; result += Tester.Printer.print(var_16); + result += "\n"; + result += "Tester_Class_1.var_20 = "; result += Tester.Printer.print(var_20); + result += "\n"; + result += "Tester_Class_1.var_21 = "; result += Tester.Printer.print(var_21); + result += "\n"; + result += "Tester_Class_1.var_14 = "; result += Tester.Printer.print(var_14); + result += "\n"; + result += "Tester_Class_1.var_18 = "; result += Tester.Printer.print(var_18); + result += "\n"; + result += "Tester_Class_1.var_17 = "; result += Tester.Printer.print(var_17); + result += "\n"; + result += "Tester_Class_1.var_19 = "; result += Tester.Printer.print(var_19); + result += "\n"; + result += "Tester_Class_1.var_22 = "; result += Tester.Printer.print(var_22); + result += "\n"; + result += "Tester_Class_1.var_13 = "; result += Tester.Printer.print(var_13); + result += "\n"; + result += "Tester_Class_1.var_15 = "; result += Tester.Printer.print(var_15); + result += ""; + result += "\n]"; + return result; + } +} + + +class Tester_Class_2 extends Tester_Class_0 { + final int var_43 = 1600723343; + static long var_44 = ~1297640037857117184L; + static String var_45 = "ejaglds"; + double var_46; + static float var_47 = 7.9423827E37F; + static Tester_Class_1[][] var_48; + + + public Tester_Class_2() + { + var_45 = (var_45 = "nkulkweqt"); + var_47 %= (new char[Tester_Class_1.var_21 >>= (short)Tester_Class_1.var_20])[Tester_Class_1.var_20]; + { + Tester_Class_1.var_18 = Tester_Class_1.var_14; + } + var_47 %= 1.559461406041646E308; + var_44 -= Tester_Class_1.var_21++ & ((new Tester_Class_1[Tester_Class_1.var_20])[Tester_Class_1.var_20]).var_17; + var_44 *= false ? (short)Tester_Class_1.var_20 : (short)var_47; + Tester_Class_1.var_13 = (new Tester_Class_1().var_15 = new char[Tester_Class_1.var_20]); + var_46 = 'i'; + double var_49 = var_46 = false ? (var_47 *= (var_46 = var_43)) : Tester_Class_1.var_20; + var_49 += 'k'; + } + + + + + public String toString() + { + String result = "[\n"; + result += "Tester_Class_2.var_43 = "; result += Tester.Printer.print(var_43); + result += "\n"; + result += "Tester_Class_2.var_48 = "; result += Tester.Printer.print(var_48); + result += "\n"; + result += "Tester_Class_2.var_44 = "; result += Tester.Printer.print(var_44); + result += "\n"; + result += "Tester_Class_2.var_46 = "; result += Tester.Printer.print(var_46); + result += "\n"; + result += "Tester_Class_2.var_47 = "; result += Tester.Printer.print(var_47); + result += "\n"; + result += "Tester_Class_2.var_1 = "; result += Tester.Printer.print(var_1); + result += "\n"; + result += "Tester_Class_2.var_45 = "; result += Tester.Printer.print(var_45); + result += ""; + result += "\n]"; + return result; + } +} + + +class Tester_Class_3 extends Tester_Class_0 { + byte var_50; + int var_51; + static double var_52; + static boolean var_53 = true; + long var_54; + static short var_55; + short var_56; + + + public Tester_Class_3() + { + var_53 |= false; + (Tester_Class_2.var_45 = "gpbcgq").replaceAll("m".concat(Tester_Class_2.var_45 = "q"), Tester_Class_2.var_45).indexOf(Tester_Class_2.var_45 = "d"); + Tester_Class_2.var_45 = Tester_Class_2.var_45; + double var_68 = 0; + Tester_Class_1.var_19 = (var_55 = Tester_Class_1.var_20); + do + { + var_53 ^= 'T' > Tester_Class_1.var_21-- & (var_53 |= Tester_Class_1.var_14); + Tester_Class_2.var_44 >>= (char)3.928497616986412E307; + var_68++; + new Tester_Class_2().func_2(Tester_Class_1.var_20, !var_53 & Tester_Class_1.var_14, Tester_Class_1.var_13 = (Tester_Class_2.var_45 = Tester_Class_2.var_45)); + } while ((((var_56 = (short)1161292485) != 'M' ? var_53 : Tester_Class_1.var_14) ? Tester_Class_1.var_14 ^ true : var_53) && var_68 < 1); + Tester_Class_2.var_45 = Tester_Class_2.var_45; + ((Tester_Class_1)(Tester_Class_1.var_13 = new Tester_Class_2())).var_15 = Tester_Class_2.var_45; + var_55 = func_1() | ((Tester_Class_1.var_18 = var_53) | (var_53 |= Tester_Class_1.var_14) | Tester_Class_1.var_14 | !Tester_Class_1.var_14) || false ? (short)Tester_Class_2.var_44 : (var_56 = (var_56 = (short)'[')); + var_52 = (var_51 = (var_55 = Tester_Class_1.var_20)); + double var_69 = 0; + Tester_Class_2.var_44 |= (Tester_Class_1.var_14 ? (Tester_Class_2)(Tester_Class_1.var_13 = (Tester_Class_2)(Tester_Class_1.var_13 = Tester_Class_2.var_45)) : (Tester_Class_2)(Tester_Class_0)(Tester_Class_1.var_13 = Tester_Class_2.var_45)).var_43; + do + { + var_51 = 495861255; + var_69++; + } while (var_69 < 3); + Tester_Class_2.var_47 -= Tester_Class_1.var_20; + Tester_Class_2.var_47 %= '['; + } + + + + + static Object func_0(final Tester_Class_0 arg_0, String arg_1, final float arg_2, final long arg_3) + { + (!var_53 | (var_53 &= var_53) ^ false ? new Tester_Class_1() : (Tester_Class_1)(new Tester_Class_0[Tester_Class_1.var_21])[Tester_Class_1.var_21]).var_15 = Tester_Class_1.var_14 ? new Tester_Class_1() : new Tester_Class_1(); + Tester_Class_2.var_47 /= !var_53 || var_53 ? (short)(((Tester_Class_2)arg_0).var_46 = (new char[Tester_Class_1.var_21][Tester_Class_1.var_21])[Tester_Class_1.var_20][Tester_Class_1.var_20]) : Tester_Class_1.var_21; + return (new Object[Tester_Class_1.var_21])[Tester_Class_1.var_21]; + } + + boolean func_1() + { + { + Tester_Class_1.var_21 >>= (var_56 = (Tester_Class_1.var_21 |= (Tester_Class_1.var_21 -= Tester_Class_1.var_20))); + Tester_Class_2.var_45 = "w"; + var_51 = Tester_Class_1.var_21; + Object var_57; + ((Tester_Class_2)(Tester_Class_0)((new Object[Tester_Class_1.var_21][Tester_Class_1.var_21])[Tester_Class_1.var_20])[Tester_Class_1.var_20]).var_46 = (var_52 = 1.3957085765622284E308); + } + Tester_Class_1.var_21 &= (var_55 = (byte)(Tester_Class_1.var_14 ? -Tester_Class_1.var_20 : 4290961666344782848L)); + Tester_Class_2.var_45 = Tester_Class_2.var_45; + var_51 = (var_53 ^= ((var_53 &= Tester_Class_1.var_14) ? 'J' : 'M') > (var_56 = Tester_Class_1.var_21)) && (var_53 = Tester_Class_1.var_14) ? (Tester_Class_1.var_21 &= ~Tester_Class_1.var_20) : Tester_Class_1.var_20; + { + final Tester_Class_1 var_58 = (Tester_Class_1)(Tester_Class_0)(Tester_Class_1.var_13 = (new Object[Tester_Class_1.var_21])[Tester_Class_1.var_20]); + Object var_59; + Tester_Class_1.var_21 |= 'X'; + var_53 ^= Tester_Class_1.var_14; + } + int var_60 = 0; + var_53 |= var_53; + for (char var_61 = 'i'; (Tester_Class_1.var_14 ? false : Tester_Class_1.var_14) | (true | Tester_Class_1.var_14) && var_60 < 1; var_53 &= !Tester_Class_1.var_14) + { + var_51 = var_61; + var_60++; + var_61 &= (new short[Tester_Class_1.var_20][Tester_Class_1.var_20])[Tester_Class_1.var_20][Tester_Class_1.var_21]; + Tester_Class_2.var_45 = "vsuy"; + } + Tester_Class_2 var_62 = ((var_53 &= Tester_Class_1.var_14 | Tester_Class_1.var_14 || Tester_Class_1.var_14) ? Tester_Class_1.var_14 : "hgwne".startsWith("etyhd", var_60)) ? (var_53 ? (Tester_Class_2)(Tester_Class_1.var_13 = "uyiaxtqc") : (Tester_Class_2)(Tester_Class_1.var_13 = Tester_Class_2.var_45)) : new Tester_Class_2(); + var_62 = var_62; + float var_63; + Object var_64; + Tester_Class_2.var_44 <<= 'v'; + String var_65; + { + var_51 = Tester_Class_1.var_21; + } + var_55 = true ? (var_56 = Tester_Class_1.var_20) : (var_55 = Tester_Class_1.var_20); + var_56 = Tester_Class_1.var_21; + Tester_Class_1.var_21 |= var_60; + Object var_66; + Tester_Class_2 var_67; + return true & Tester_Class_1.var_14 ^ (false ? var_53 : var_53); + } + + public String toString() + { + String result = "[\n"; + result += "Tester_Class_3.var_51 = "; result += Tester.Printer.print(var_51); + result += "\n"; + result += "Tester_Class_3.var_54 = "; result += Tester.Printer.print(var_54); + result += "\n"; + result += "Tester_Class_3.var_52 = "; result += Tester.Printer.print(var_52); + result += "\n"; + result += "Tester_Class_3.var_55 = "; result += Tester.Printer.print(var_55); + result += "\n"; + result += "Tester_Class_3.var_56 = "; result += Tester.Printer.print(var_56); + result += "\n"; + result += "Tester_Class_3.var_1 = "; result += Tester.Printer.print(var_1); + result += "\n"; + result += "Tester_Class_3.var_50 = "; result += Tester.Printer.print(var_50); + result += "\n"; + result += "Tester_Class_3.var_53 = "; result += Tester.Printer.print(var_53); + result += ""; + result += "\n]"; + return result; + } +} + +public class Tester { + final long var_70 = Tester_Class_2.var_44; + int var_71; + static double var_72; + static short var_73 = (Tester_Class_3.var_53 &= (Tester_Class_3.var_53 ^= Tester_Class_3.var_53)) ? (short)(byte)(Tester_Class_3.var_55 = Tester_Class_1.var_20) : (Tester_Class_3.var_55 = Tester_Class_1.var_20); + final static short var_74 = (Tester_Class_3.var_53 &= Tester_Class_3.var_53) ? (Tester_Class_3.var_53 ? var_73 : var_73++) : (var_73 *= (Tester_Class_1.var_21 |= var_73)); + float var_75; + + + protected final Tester_Class_2 func_0() + { + Tester_Class_1.var_21 ^= ~Tester_Class_1.var_21; + if (false) + { + ((Tester_Class_3)(new Object[Tester_Class_1.var_21])[Tester_Class_1.var_21 -= + + (Tester_Class_2.var_44 >>>= Tester_Class_1.var_21)]).var_50 = (Tester_Class_1.var_21 &= (var_71 = 554295231)); + } + else + { + Tester_Class_2.var_47 += 'H'; + } + final Tester_Class_0 var_76 = ((new Tester_Class_0[Tester_Class_1.var_20][Tester_Class_1.var_21])[Tester_Class_1.var_20])[Tester_Class_1.var_20]; + (Tester_Class_1.var_14 ? (Tester_Class_2)var_76 : (Tester_Class_2)var_76).var_46 = (var_73 %= var_74 / (((new Tester_Class_2[Tester_Class_1.var_20])[Tester_Class_1.var_21 |= Tester_Class_1.var_20]).var_46 = Tester_Class_1.var_22)); + var_73 |= ((Tester_Class_2)(Tester_Class_1.var_13 = var_76)).var_43 | Tester_Class_1.var_20; + return new Tester_Class_2(); + } + + private static Tester_Class_3 func_1(byte arg_0, Tester_Class_1 arg_1, Tester_Class_1 arg_2, final int arg_3) + { + arg_0 <<= '`'; + return false ? (Tester_Class_3)(Tester_Class_0)(arg_1.var_15 = (arg_1 = arg_2)) : (Tester_Class_3)((new Tester_Class_0[Tester_Class_1.var_20][arg_0])[Tester_Class_1.var_20])[Tester_Class_1.var_20]; + } + + public static String execute() + { + try { + Tester t = new Tester(); + try { t.test(); } + catch(Throwable e) { } + try { return t.toString(); } + catch (Throwable e) { return "Error during result conversion to String"; } + } catch (Throwable e) { return "Error during test execution"; } + } + + public static void main(String[] args) + { + for (int i = 0; i < 20000; i++) { + Tester t = new Tester(); + try { t.test(); } + catch(Throwable e) { } + if (t.var_71 != 0 || + t.var_70 != -1297640037857117185L || + t.var_72 != 0.0 || + t.var_75 != 0.0 || + t.var_73 != -1 || + t.var_74 != 15129) { + throw new InternalError("wrong answer"); + } + } + } + + private void test() + { + long var_77 = 0L; + var_73 /= (Tester_Class_2.var_47 = 'D' | 'Q'); + Tester_Class_2.var_47 *= 't'; + while (var_77 < 36) + { + var_73 += Tester_Class_1.var_22; + Tester_Class_2.var_47 += Tester_Class_1.var_20; + var_77++; + Tester_Class_2.var_45 = ""; + Tester_Class_2.var_45 = (Tester_Class_2.var_45 = Tester_Class_2.var_45); + } + if (Tester_Class_3.var_53 |= false) + { + int var_78 = 0; + (false ? "idipdjrln" : "l").startsWith(Tester_Class_2.var_45); + while ((Tester_Class_3.var_53 |= (Tester_Class_3.var_53 &= ! (Tester_Class_1.var_18 = true)) | Tester_Class_3.var_53) && (var_78 < 15 && (Tester_Class_3.var_53 &= Tester_Class_1.var_14))) + { + Tester_Class_2.var_44 <<= 'b'; + var_78++; + var_72 = var_74; + var_71 = (char)6792782617594333184L; + } + float var_79 = Tester_Class_2.var_47 /= 1.5148047552641134E308; + ((new boolean[Tester_Class_1.var_20])[Tester_Class_1.var_21 <= (Tester_Class_1.var_21 -= 9.675021723726166E307) / - + (var_72 = 4.3844763012510596E307) ? (byte)(Tester_Class_2.var_44 += ~Tester_Class_1.var_21) : (Tester_Class_1.var_21 += 1.7430965313164616E308)] ? (Tester_Class_2)(new Tester_Class_1().var_15 = func_0()) : new Tester_Class_2()).var_46 = (var_72 = (Tester_Class_1.var_21 *= 'j')); + Tester_Class_1.var_13 = (new Tester_Class_3[Tester_Class_1.var_21 >>>= var_78][Tester_Class_1.var_21])[Tester_Class_1.var_21][Tester_Class_1.var_20]; + } + else + { + long var_80 = 0L; + ((Tester_Class_2)(Tester_Class_1.var_13 = new long[Tester_Class_1.var_21])).var_46 = 'r'; + do + { + final float var_81 = 7.3633934E37F; + var_80++; + var_73 ^= Tester_Class_2.var_44; + } while (Tester_Class_3.var_53 && var_80 < 4); + Tester_Class_1.var_18 = Tester_Class_2.var_47 >= var_73; + Tester_Class_2.var_45 = "xvodcylp"; + Tester_Class_2.var_45.codePointCount("indreb".charAt(+(new byte[Tester_Class_1.var_20][Tester_Class_1.var_20])[Tester_Class_1.var_21][Tester_Class_1.var_21]) * ~ (Tester_Class_1.var_21 %= (var_71 = --var_73)), ((Tester_Class_3.var_53 ^= Tester_Class_2.var_45.equalsIgnoreCase("rkxwa")) || Tester_Class_2.var_47 <= (Tester_Class_2.var_47 %= -var_80) ? (Tester_Class_1.var_21 ^= var_70) : var_73) & (var_71 = 'k')); + Tester_Class_1.var_13 = ((new long[Tester_Class_1.var_21][Tester_Class_1.var_20][Tester_Class_1.var_21])[Tester_Class_1.var_21])[Tester_Class_1.var_21]; + } + var_73 <<= (Tester_Class_1.var_18 = false) ? 't' : (false ? 'E' : 'u'); + var_73++; + int var_82 = 0; + Tester_Class_1.var_13 = func_1(Tester_Class_1.var_20, new Tester_Class_1(), (new Tester_Class_1[Tester_Class_1.var_21])[Tester_Class_1.var_21], 'M' & var_74); + "gdrlrsubb".substring(12438522, var_82); + Tester_Class_2.var_44 |= (((new Tester_Class_3[Tester_Class_1.var_21][Tester_Class_1.var_21])[Tester_Class_1.var_21 >>= 7993744087962264576L][Tester_Class_1.var_21]).var_51 = Tester_Class_3.var_53 ? 'B' : '['); + final long var_83 = ~ (4544638910183665664L << (((Tester_Class_3)((new Tester_Class_0[Tester_Class_1.var_20][Tester_Class_1.var_21])[Tester_Class_1.var_21])[Tester_Class_1.var_21]).var_56 = (Tester_Class_3.var_53 &= Tester_Class_3.var_53) ? Tester_Class_1.var_21 : Tester_Class_1.var_20)); + Tester_Class_2.var_45 = Tester_Class_2.var_45; + while (var_82 < 2 && Tester_Class_3.var_53 & (Tester_Class_3.var_53 ^= !false)) + { + (Tester_Class_3.var_53 ? "xqeisnyf" : (Tester_Class_2.var_45 = (Tester_Class_2.var_45 = (Tester_Class_2.var_45 = Tester_Class_2.var_45)))).concat(Tester_Class_2.var_45 = "i"); + var_82++; + boolean var_84 = false; + Tester_Class_2.var_45 = Tester_Class_2.var_45; + } + var_71 = ~Tester_Class_2.var_44 != Tester_Class_2.var_44-- ? (var_73 = var_73) : (var_73 >>>= var_73); + char var_85; + Tester_Class_3.var_53 |= (Tester_Class_3.var_53 ^= true); + int var_86 = 0; + Tester_Class_1.var_21 %= (var_73 | (Tester_Class_1.var_21 *= 9.831691E37F)) * (Tester_Class_1.var_21 += 6784278051481715712L); + while (Tester_Class_3.var_53 && (var_86 < 24 && ((((Tester_Class_3.var_53 ^= true) ? Tester_Class_3.var_53 : Tester_Class_1.var_14) ? !Tester_Class_3.var_53 : Tester_Class_3.var_53) ? (Tester_Class_1.var_18 = Tester_Class_3.var_53) : Tester_Class_1.var_14 || true))) + { + final byte var_87 = (byte)((false & true ? Tester_Class_1.var_20 : 257407175) & 4242055901066916864L * (var_73 *= 1621204618) / ((((Tester_Class_1)(new Object[(byte)4.925362697409246E307])[Tester_Class_1.var_21]).var_17 ^ (var_71 = var_86)) & 1859382584)); + var_86++; + Tester_Class_2.var_45 = (Tester_Class_2.var_45 = (Tester_Class_2.var_45 = "arceo")); + float var_88; + } + "a".lastIndexOf(var_71 = Tester_Class_3.var_53 ^ false ? (var_71 = 1058420888) : Tester_Class_1.var_20); + int var_89 = 0; + { + var_71 = 661164411; + } + boolean var_90; + --var_73; + Tester_Class_2.var_45.concat(Tester_Class_2.var_45); + { + var_85 = (Tester_Class_3.var_53 ? Tester_Class_3.var_53 : Tester_Class_3.var_53) ? 'R' : '['; + } + ((new Tester_Class_2[Tester_Class_1.var_21][Tester_Class_1.var_21])[Tester_Class_1.var_20][Tester_Class_1.var_20]).var_46 = Tester_Class_1.var_20; + final float var_91 = ((new Tester_Class_0[Tester_Class_1.var_21][Tester_Class_1.var_21])[Tester_Class_1.var_20][Tester_Class_1.var_21 -= Tester_Class_1.var_21]).equals(((new Tester_Class_1[Tester_Class_1.var_20])[Tester_Class_1.var_21]).var_15 = (Tester_Class_2.var_45 = Tester_Class_2.var_45)) ? (var_71 = Tester_Class_1.var_20) : 2.2259766E38F + Tester_Class_2.var_44; + Tester_Class_2.var_47 *= ((Tester_Class_2)(Tester_Class_0)(Tester_Class_1.var_13 = Tester_Class_2.var_45)).var_43; + Tester_Class_2.var_45 = Tester_Class_2.var_45; + Tester_Class_3.var_53 &= Tester_Class_1.var_14; + while (Tester_Class_1.var_20 >= ++Tester_Class_1.var_21 && var_89 < 2) + { + Tester_Class_1.var_13 = (Tester_Class_3)(new Tester_Class_0[Tester_Class_1.var_21])[Tester_Class_1.var_21]; + var_89++; + if (true) + { + Tester_Class_3.var_53 |= true; + break; + } + else + { + Tester_Class_2 var_92; + } + ((Tester_Class_3)((Tester_Class_3.var_53 |= Tester_Class_3.var_53) ? (new Tester_Class_1().var_15 = (Tester_Class_0)(Tester_Class_1.var_13 = new boolean[Tester_Class_1.var_20][Tester_Class_1.var_21])) : new Tester_Class_0[Tester_Class_1.var_21][Tester_Class_1.var_21])).var_54 = (Tester_Class_1.var_21 = (Tester_Class_1.var_21 /= (Tester_Class_2.var_44 |= (int)(Tester_Class_1.var_21 >>>= var_82)))); + ((Tester_Class_3)(Tester_Class_1.var_13 = (new Tester_Class_1().var_15 = new Tester_Class_1()))).var_51 = Tester_Class_1.var_20; + final char var_93 = 'u'; + ((Tester_Class_2)(new Tester_Class_1().var_15 = (Tester_Class_2.var_45 = Tester_Class_2.var_45))).var_46 = var_93; + Tester_Class_2.var_45.toUpperCase(); + Tester_Class_2.var_45 = "mhk"; + (true | false ? new Tester_Class_1() : (new Tester_Class_1[Tester_Class_1.var_20])[Tester_Class_1.var_20]).var_15 = (Tester_Class_1)(((new Tester_Class_1[Tester_Class_1.var_21 |= Tester_Class_1.var_20][Tester_Class_1.var_21])[Tester_Class_1.var_21][Tester_Class_1.var_21]).var_15 = (Tester_Class_1.var_13 = (Tester_Class_1)(Tester_Class_1.var_13 = (Tester_Class_2.var_45 = "ofkbg")))); + } + float var_94 = 0F; + Tester_Class_2.var_44 |= (var_73 >>>= (var_85 = (var_85 = 'j'))); + Tester_Class_3.var_52 = 1835242863964218368L; + do + { + int var_95 = 1361237611; + var_94++; + Tester_Class_3.var_53 ^= (Tester_Class_3.var_53 |= Tester_Class_1.var_14); + } while (var_94 < 16); + { + var_73 = var_73--; + Tester_Class_2.var_45 = (Tester_Class_1.var_14 ? Tester_Class_1.var_14 : !false) ? "oaxg" : "igdnja"; + } + ((new Tester_Class_1[Tester_Class_1.var_21])[Tester_Class_1.var_21]).equals(new Tester_Class_1().var_15 = (Tester_Class_2.var_45 = "agdnue").charAt(1416972150) != Tester_Class_2.var_47 ? new Tester_Class_1() : new Tester_Class_1()); + byte var_96 = Tester_Class_1.var_21 >>>= (var_85 = (var_85 = '`')); + Tester_Class_2.var_45 = ""; + Tester_Class_2.var_47 += Tester_Class_2.var_47; + Tester_Class_2.var_45 = Tester_Class_2.var_45; + } + public String toString() + { + String result = "[\n"; + result += "Tester.var_71 = "; result += Printer.print(var_71); + result += "\n"; + result += "Tester.var_70 = "; result += Printer.print(var_70); + result += "\n"; + result += "Tester.var_72 = "; result += Printer.print(var_72); + result += "\n"; + result += "Tester.var_75 = "; result += Printer.print(var_75); + result += "\n"; + result += "Tester.var_73 = "; result += Printer.print(var_73); + result += "\n"; + result += "Tester.var_74 = "; result += Printer.print(var_74); + result += ""; + result += "\n]"; + return result; + } + static class Printer + { + public static String print(boolean arg) { return String.valueOf(arg); } + public static String print(byte arg) { return String.valueOf(arg); } + public static String print(short arg) { return String.valueOf(arg); } + public static String print(char arg) { return String.valueOf((int)arg); } + public static String print(int arg) { return String.valueOf(arg); } + public static String print(long arg) { return String.valueOf(arg); } + public static String print(float arg) { return String.valueOf(arg); } + public static String print(double arg) { return String.valueOf(arg); } + + + public static String print(Object arg) + { + return print_r(new java.util.Stack(), arg); + } + + private static String print_r(java.util.Stack visitedObjects, Object arg) + { + String result = ""; + if (arg == null) + result += "null"; + else + if (arg.getClass().isArray()) + { + for (int i = 0; i < visitedObjects.size(); i++) + if (visitedObjects.elementAt(i) == arg) return ""; + + visitedObjects.push(arg); + + final String delimiter = ", "; + result += "["; + + if (arg instanceof Object[]) + { + Object[] array = (Object[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print_r(visitedObjects, array[i]); + if (i < array.length - 1) result += delimiter; + } + } + else + if (arg instanceof boolean[]) + { + boolean[] array = (boolean[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print(array[i]); + if (i < array.length - 1) result += delimiter; + } + } + else + if (arg instanceof byte[]) + { + byte[] array = (byte[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print(array[i]); + if (i < array.length - 1) result += delimiter; + } + } + else + if (arg instanceof short[]) + { + short[] array = (short[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print(array[i]); + if (i < array.length - 1) result += delimiter; + } + } + else + if (arg instanceof char[]) + { + char[] array = (char[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print(array[i]); + if (i < array.length - 1) result += delimiter; + } + } + else + if (arg instanceof int[]) + { + int[] array = (int[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print(array[i]); + if (i < array.length - 1) result += delimiter; + } + } + else + if (arg instanceof long[]) + { + long[] array = (long[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print(array[i]); + if (i < array.length - 1) result += delimiter; + } + } + else + if (arg instanceof float[]) + { + float[] array = (float[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print(array[i]); + if (i < array.length - 1) result += delimiter; + } + } + else + if (arg instanceof double[]) + { + double[] array = (double[]) arg; + for (int i = 0; i < array.length; i++) + { + result += print(array[i]); + if (i < array.length - 1) result += delimiter; + } + } + + result += "]"; + visitedObjects.pop(); + + } else + { + result += arg.toString(); + } + + return result; + } + } +} + + From c54c100fd7e8b78559cea77ca008a7887292452b Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Fri, 4 Apr 2008 20:20:16 +0400 Subject: [PATCH 027/119] 6573289: api/java_awt/Color/index.html#CreateContextTesttestCase4,5,6,7 fail since JDK 7 b14 Specify current behavior - not caching the painting context Reviewed-by: flar, son --- jdk/src/share/classes/java/awt/Color.java | 40 +++++++---- .../share/classes/java/awt/GradientPaint.java | 36 +++++++--- .../classes/java/awt/LinearGradientPaint.java | 27 +++++++- jdk/src/share/classes/java/awt/Paint.java | 68 ++++++++++++------- .../classes/java/awt/RadialGradientPaint.java | 26 ++++++- .../share/classes/java/awt/TexturePaint.java | 39 +++++++---- 6 files changed, 169 insertions(+), 67 deletions(-) diff --git a/jdk/src/share/classes/java/awt/Color.java b/jdk/src/share/classes/java/awt/Color.java index c06b573d7ca..22a8455f2b5 100644 --- a/jdk/src/share/classes/java/awt/Color.java +++ b/jdk/src/share/classes/java/awt/Color.java @@ -51,6 +51,7 @@ import java.awt.color.ColorSpace; * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html * . *

+ * @version 10 Feb 1997 * @author Sami Shaio * @author Arthur van Hoff * @see ColorSpace @@ -1176,23 +1177,32 @@ public class Color implements Paint, java.io.Serializable { } /** - * Creates and returns a {@link PaintContext} used to generate a solid - * color pattern. This enables a Color object to be used - * as an argument to any method requiring an object implementing the - * {@link Paint} interface. - * The same PaintContext is returned, regardless of - * whether or not r, r2d, - * xform, or hints are null. - * @param cm the specified ColorModel - * @param r the specified {@link Rectangle} - * @param r2d the specified {@link Rectangle2D} - * @param xform the specified {@link AffineTransform} - * @param hints the specified {@link RenderingHints} - * @return a PaintContext that is used to generate a - * solid color pattern. + * Creates and returns a {@link PaintContext} used to + * generate a solid color field pattern. + * See the {@link Paint#createContext specification} of the + * method in the {@link Paint} interface for information + * on null parameter handling. + * + * @param cm the preferred {@link ColorModel} which represents the most convenient + * format for the caller to receive the pixel data, or {@code null} + * if there is no preference. + * @param r the device space bounding box + * of the graphics primitive being rendered. + * @param r2d the user space bounding box + * of the graphics primitive being rendered. + * @param xform the {@link AffineTransform} from user + * space into device space. + * @param hints the set of hints that the context object can use to + * choose between rendering alternatives. + * @return the {@code PaintContext} for + * generating color patterns. * @see Paint * @see PaintContext - * @see Graphics2D#setPaint + * @see ColorModel + * @see Rectangle + * @see Rectangle2D + * @see AffineTransform + * @see RenderingHints */ public synchronized PaintContext createContext(ColorModel cm, Rectangle r, Rectangle2D r2d, diff --git a/jdk/src/share/classes/java/awt/GradientPaint.java b/jdk/src/share/classes/java/awt/GradientPaint.java index 840e7aec826..105fcd1f607 100644 --- a/jdk/src/share/classes/java/awt/GradientPaint.java +++ b/jdk/src/share/classes/java/awt/GradientPaint.java @@ -53,6 +53,7 @@ import java.awt.image.ColorModel; * * @see Paint * @see Graphics2D#setPaint + * @version 10 Feb 1997 */ public class GradientPaint implements Paint { @@ -223,19 +224,32 @@ public class GradientPaint implements Paint { } /** - * Creates and returns a context used to generate the color pattern. - * @param cm {@link ColorModel} that receives - * the Paint data. This is used only as a hint. - * @param deviceBounds the device space bounding box of the - * graphics primitive being rendered - * @param userBounds the user space bounding box of the - * graphics primitive being rendered + * Creates and returns a {@link PaintContext} used to + * generate a linear color gradient pattern. + * See the {@link Paint#createContext specification} of the + * method in the {@link Paint} interface for information + * on null parameter handling. + * + * @param cm the preferred {@link ColorModel} which represents the most convenient + * format for the caller to receive the pixel data, or {@code null} + * if there is no preference. + * @param deviceBounds the device space bounding box + * of the graphics primitive being rendered. + * @param userBounds the user space bounding box + * of the graphics primitive being rendered. * @param xform the {@link AffineTransform} from user - * space into device space - * @param hints the hints that the context object uses to choose - * between rendering alternatives - * @return the {@link PaintContext} that generates color patterns. + * space into device space. + * @param hints the set of hints that the context object can use to + * choose between rendering alternatives. + * @return the {@code PaintContext} for + * generating color patterns. + * @see Paint * @see PaintContext + * @see ColorModel + * @see Rectangle + * @see Rectangle2D + * @see AffineTransform + * @see RenderingHints */ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, diff --git a/jdk/src/share/classes/java/awt/LinearGradientPaint.java b/jdk/src/share/classes/java/awt/LinearGradientPaint.java index ea5a7339d16..2cf21cbe86d 100644 --- a/jdk/src/share/classes/java/awt/LinearGradientPaint.java +++ b/jdk/src/share/classes/java/awt/LinearGradientPaint.java @@ -296,7 +296,32 @@ public final class LinearGradientPaint extends MultipleGradientPaint { } /** - * {@inheritDoc} + * Creates and returns a {@link PaintContext} used to + * generate a linear color gradient pattern. + * See the {@link Paint#createContext specification} of the + * method in the {@link Paint} interface for information + * on null parameter handling. + * + * @param cm the preferred {@link ColorModel} which represents the most convenient + * format for the caller to receive the pixel data, or {@code null} + * if there is no preference. + * @param deviceBounds the device space bounding box + * of the graphics primitive being rendered. + * @param userBounds the user space bounding box + * of the graphics primitive being rendered. + * @param transform the {@link AffineTransform} from user + * space into device space. + * @param hints the set of hints that the context object can use to + * choose between rendering alternatives. + * @return the {@code PaintContext} for + * generating color patterns. + * @see Paint + * @see PaintContext + * @see ColorModel + * @see Rectangle + * @see Rectangle2D + * @see AffineTransform + * @see RenderingHints */ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, diff --git a/jdk/src/share/classes/java/awt/Paint.java b/jdk/src/share/classes/java/awt/Paint.java index 07c4274a08f..8e572db7eab 100644 --- a/jdk/src/share/classes/java/awt/Paint.java +++ b/jdk/src/share/classes/java/awt/Paint.java @@ -46,42 +46,58 @@ import java.awt.geom.Rectangle2D; * @see GradientPaint * @see TexturePaint * @see Graphics2D#setPaint + * @version 1.36, 06/05/07 */ public interface Paint extends Transparency { /** * Creates and returns a {@link PaintContext} used to * generate the color pattern. - * Since the ColorModel argument to createContext is only a - * hint, implementations of Paint should accept a null argument - * for ColorModel. Note that if the application does not - * prefer a specific ColorModel, the null ColorModel argument - * will give the Paint implementation full leeway in using the - * most efficient ColorModel it prefers for its raster processing. - *

- * Since the API documentation was not specific about this in - * releases before 1.4, there may be implementations of - * Paint that do not accept a null - * ColorModel argument. - * If a developer is writing code which passes a null - * ColorModel argument to the - * createContext method of Paint - * objects from arbitrary sources it would be wise to code defensively - * by manufacturing a non-null ColorModel for those - * objects which throw a NullPointerException. - * @param cm the {@link ColorModel} that receives the - * Paint data. This is used only as a hint. + * The arguments to this method convey additional information + * about the rendering operation that may be + * used or ignored on various implementations of the {@code Paint} interface. + * A caller must pass non-{@code null} values for all of the arguments + * except for the {@code ColorModel} argument which may be {@code null} to + * indicate that no specific {@code ColorModel} type is preferred. + * Implementations of the {@code Paint} interface are allowed to use or ignore + * any of the arguments as makes sense for their function, and are + * not constrained to use the specified {@code ColorModel} for the returned + * {@code PaintContext}, even if it is not {@code null}. + * Implementations are allowed to throw {@code NullPointerException} for + * any {@code null} argument other than the {@code ColorModel} argument, + * but are not required to do so. + * + * @param cm the preferred {@link ColorModel} which represents the most convenient + * format for the caller to receive the pixel data, or {@code null} + * if there is no preference. * @param deviceBounds the device space bounding box - * of the graphics primitive being rendered + * of the graphics primitive being rendered. + * Implementations of the {@code Paint} interface + * are allowed to throw {@code NullPointerException} + * for a {@code null} {@code deviceBounds}. * @param userBounds the user space bounding box - * of the graphics primitive being rendered + * of the graphics primitive being rendered. + * Implementations of the {@code Paint} interface + * are allowed to throw {@code NullPointerException} + * for a {@code null} {@code userBounds}. * @param xform the {@link AffineTransform} from user - * space into device space - * @param hints the hint that the context object uses to - * choose between rendering alternatives - * @return the PaintContext for - * generating color patterns + * space into device space. + * Implementations of the {@code Paint} interface + * are allowed to throw {@code NullPointerException} + * for a {@code null} {@code xform}. + * @param hints the set of hints that the context object can use to + * choose between rendering alternatives. + * Implementations of the {@code Paint} interface + * are allowed to throw {@code NullPointerException} + * for a {@code null} {@code hints}. + * @return the {@code PaintContext} for + * generating color patterns. * @see PaintContext + * @see ColorModel + * @see Rectangle + * @see Rectangle2D + * @see AffineTransform + * @see RenderingHints */ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, diff --git a/jdk/src/share/classes/java/awt/RadialGradientPaint.java b/jdk/src/share/classes/java/awt/RadialGradientPaint.java index 278906bb771..494daa57d1e 100644 --- a/jdk/src/share/classes/java/awt/RadialGradientPaint.java +++ b/jdk/src/share/classes/java/awt/RadialGradientPaint.java @@ -543,7 +543,31 @@ public final class RadialGradientPaint extends MultipleGradientPaint { } /** - * {@inheritDoc} + * Creates and returns a {@link PaintContext} used to + * generate a circular radial color gradient pattern. + * See the description of the {@link Paint#createContext createContext} method + * for information on null parameter handling. + * + * @param cm the preferred {@link ColorModel} which represents the most convenient + * format for the caller to receive the pixel data, or {@code null} + * if there is no preference. + * @param deviceBounds the device space bounding box + * of the graphics primitive being rendered. + * @param userBounds the user space bounding box + * of the graphics primitive being rendered. + * @param transform the {@link AffineTransform} from user + * space into device space. + * @param hints the set of hints that the context object can use to + * choose between rendering alternatives. + * @return the {@code PaintContext} for + * generating color patterns. + * @see Paint + * @see PaintContext + * @see ColorModel + * @see Rectangle + * @see Rectangle2D + * @see AffineTransform + * @see RenderingHints */ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, diff --git a/jdk/src/share/classes/java/awt/TexturePaint.java b/jdk/src/share/classes/java/awt/TexturePaint.java index 7c5dd5de01e..c4054e5783a 100644 --- a/jdk/src/share/classes/java/awt/TexturePaint.java +++ b/jdk/src/share/classes/java/awt/TexturePaint.java @@ -45,6 +45,7 @@ import java.awt.image.ColorModel; * replicated Rectangle2D. * @see Paint * @see Graphics2D#setPaint + * @version 1.48, 06/05/07 */ public class TexturePaint implements Paint { @@ -93,20 +94,32 @@ public class TexturePaint implements Paint { } /** - * Creates and returns a context used to generate the color pattern. - * @param cm the {@link ColorModel} that receives the - * Paint data. This is used only as a hint. - * @param deviceBounds the device space bounding box of the graphics - * primitive being rendered - * @param userBounds the user space bounding box of the graphics - * primitive being rendered - * @param xform the {@link AffineTransform} from user space - * into device space - * @param hints a {@link RenderingHints} object that can be used to - * specify how the pattern is ultimately rendered - * @return the {@link PaintContext} used for generating color - * patterns. + * Creates and returns a {@link PaintContext} used to + * generate a tiled image pattern. + * See the {@link Paint#createContext specification} of the + * method in the {@link Paint} interface for information + * on null parameter handling. + * + * @param cm the preferred {@link ColorModel} which represents the most convenient + * format for the caller to receive the pixel data, or {@code null} + * if there is no preference. + * @param deviceBounds the device space bounding box + * of the graphics primitive being rendered. + * @param userBounds the user space bounding box + * of the graphics primitive being rendered. + * @param xform the {@link AffineTransform} from user + * space into device space. + * @param hints the set of hints that the context object can use to + * choose between rendering alternatives. + * @return the {@code PaintContext} for + * generating color patterns. + * @see Paint * @see PaintContext + * @see ColorModel + * @see Rectangle + * @see Rectangle2D + * @see AffineTransform + * @see RenderingHints */ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, From f3cc321cb27cf735a02905ecefa86640e13c59e0 Mon Sep 17 00:00:00 2001 From: Peter Zhelezniakov Date: Mon, 7 Apr 2008 13:07:04 +0400 Subject: [PATCH 028/119] 4765383: JTextArea.append(String) not thread safe Several swing.text methods are not marked thread-safe anymore. Reviewed-by: gsm --- .../classes/javax/swing/JEditorPane.java | 10 ------- .../share/classes/javax/swing/JTextArea.java | 15 ---------- .../share/classes/javax/swing/JTextPane.java | 30 ------------------- .../javax/swing/text/JTextComponent.java | 11 +------ 4 files changed, 1 insertion(+), 65 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/JEditorPane.java b/jdk/src/share/classes/javax/swing/JEditorPane.java index 4cf18c009c3..c126fe70c01 100644 --- a/jdk/src/share/classes/javax/swing/JEditorPane.java +++ b/jdk/src/share/classes/javax/swing/JEditorPane.java @@ -1120,11 +1120,6 @@ public class JEditorPane extends JTextComponent { * current selection. The replacement text will have the * attributes currently defined for input. If the component is not * editable, beep and return. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param content the content to replace the selection with. This * value can be null @@ -1395,11 +1390,6 @@ public class JEditorPane extends JTextComponent { * create a StringReader and call the read method. In this case the model * would be replaced after it was initialized with the contents of the * string. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param t the new text to be set; if null the old * text will be deleted diff --git a/jdk/src/share/classes/javax/swing/JTextArea.java b/jdk/src/share/classes/javax/swing/JTextArea.java index 8f53daf2aca..f7718198bf7 100644 --- a/jdk/src/share/classes/javax/swing/JTextArea.java +++ b/jdk/src/share/classes/javax/swing/JTextArea.java @@ -444,11 +444,6 @@ public class JTextArea extends JTextComponent { /** * Inserts the specified text at the specified position. Does nothing * if the model is null or if the text is null or empty. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param str the text to insert * @param pos the position at which to insert >= 0 @@ -471,11 +466,6 @@ public class JTextArea extends JTextComponent { /** * Appends the given text to the end of the document. Does nothing if * the model is null or the string is null or empty. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param str the text to insert * @see #insert @@ -494,11 +484,6 @@ public class JTextArea extends JTextComponent { * Replaces text from the indicated start to end position with the * new text specified. Does nothing if the model is null. Simply * does a delete if the new string is null or empty. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param str the text to use as the replacement * @param start the start position >= 0 diff --git a/jdk/src/share/classes/javax/swing/JTextPane.java b/jdk/src/share/classes/javax/swing/JTextPane.java index 69b94a30e42..c820f512d7e 100644 --- a/jdk/src/share/classes/javax/swing/JTextPane.java +++ b/jdk/src/share/classes/javax/swing/JTextPane.java @@ -167,11 +167,6 @@ public class JTextPane extends JEditorPane { * current selection. The replacement text will have the * attributes currently defined for input at the point of * insertion. If the document is not editable, beep and return. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param content the content to replace the selection with */ @@ -229,11 +224,6 @@ public class JTextPane extends JEditorPane { * a value of 0.75 will cause 75 percent of the * component to be above the baseline, and 25 percent of the * component to be below the baseline. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param c the component to insert */ @@ -252,11 +242,6 @@ public class JTextPane extends JEditorPane { * current position of the caret. This is represented in * the associated document as an attribute of one character * of content. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param g the icon to insert * @see Icon @@ -320,11 +305,6 @@ public class JTextPane extends JEditorPane { * through the logical style assigned to the paragraph, which * in term may resolve through some hierarchy completely * independent of the element hierarchy in the document. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param s the logical style to assign to the paragraph, * or null for no style @@ -367,11 +347,6 @@ public class JTextPane extends JEditorPane { * is no selection, the attributes are applied to * the input attribute set which defines the attributes * for any new text that gets inserted. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param attr the attributes * @param replace if true, then replace the existing attributes first @@ -412,11 +387,6 @@ public class JTextPane extends JEditorPane { * to the paragraphs that intersect the selection. * If there is no selection, the attributes are applied * to the paragraph at the current caret position. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param attr the non-null attributes * @param replace if true, replace the existing attributes first diff --git a/jdk/src/share/classes/javax/swing/text/JTextComponent.java b/jdk/src/share/classes/javax/swing/text/JTextComponent.java index 9ba89895682..d340f281eff 100644 --- a/jdk/src/share/classes/javax/swing/text/JTextComponent.java +++ b/jdk/src/share/classes/javax/swing/text/JTextComponent.java @@ -1349,11 +1349,6 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A * This is the method that is used by the default implementation * of the action for inserting content that gets bound to the * keymap actions. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * * @param content the content to replace the selection with */ @@ -1687,12 +1682,8 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A * or empty, has the effect of simply deleting the old text. * When text has been inserted, the resulting caret location * is determined by the implementation of the caret class. - *

- * This method is thread safe, although most Swing methods - * are not. Please see - * How - * to Use Threads for more information. * + *

* Note that text is not a bound property, so no PropertyChangeEvent * is fired when it changes. To listen for changes to the text, * use DocumentListener. From 0e36651f33707dfd5761bd2242b8793f24b6659e Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Mon, 7 Apr 2008 14:53:51 +0400 Subject: [PATCH 029/119] 6613529: Avoid duplicate object creation within JDK packages Avoid using constructors when unique values are not necessary Reviewed-by: volk, igor, peterz --- .../imageio/plugins/gif/GIFImageReader.java | 2 +- .../plugins/gif/GIFWritableImageMetadata.java | 2 +- .../swing/plaf/gtk/GTKColorChooserPanel.java | 30 ++++----- .../java/swing/plaf/gtk/GTKLookAndFeel.java | 32 +++++----- .../com/sun/java/swing/plaf/gtk/GTKStyle.java | 14 ++--- .../com/sun/java/swing/plaf/gtk/Metacity.java | 4 +- .../swing/plaf/motif/MotifLookAndFeel.java | 14 ++--- .../plaf/windows/WindowsLookAndFeel.java | 62 +++++++++---------- jdk/src/share/classes/java/awt/Button.java | 2 +- jdk/src/share/classes/java/awt/MenuItem.java | 2 +- .../awt/datatransfer/SystemFlavorMap.java | 4 +- .../classes/java/awt/image/BufferedImage.java | 6 +- .../text/DictionaryBasedBreakIterator.java | 6 +- .../classes/java/text/MessageFormat.java | 4 +- .../imageio/stream/ImageInputStreamImpl.java | 4 +- .../classes/javax/swing/AbstractButton.java | 12 ++-- .../javax/swing/DebugGraphicsInfo.java | 2 +- .../classes/javax/swing/JInternalFrame.java | 8 +-- .../classes/javax/swing/JOptionPane.java | 2 +- .../classes/javax/swing/JProgressBar.java | 14 ++--- .../share/classes/javax/swing/JScrollBar.java | 14 ++--- .../share/classes/javax/swing/JSlider.java | 20 +++--- .../share/classes/javax/swing/JSplitPane.java | 6 +- .../classes/javax/swing/JTabbedPane.java | 2 +- jdk/src/share/classes/javax/swing/JTable.java | 8 +-- .../share/classes/javax/swing/JTextArea.java | 2 +- .../javax/swing/SpinnerNumberModel.java | 12 ++-- .../classes/javax/swing/TablePrintable.java | 2 +- .../javax/swing/plaf/basic/BasicButtonUI.java | 2 +- .../swing/plaf/basic/BasicLookAndFeel.java | 2 +- .../swing/plaf/basic/BasicMenuItemUI.java | 2 +- .../swing/plaf/basic/BasicOptionPaneUI.java | 6 +- .../swing/plaf/basic/BasicTabbedPaneUI.java | 4 +- .../swing/plaf/basic/BasicToolBarUI.java | 2 +- .../swing/plaf/metal/MetalLookAndFeel.java | 6 +- .../swing/plaf/synth/SynthArrowButton.java | 2 +- .../swing/plaf/synth/SynthDesktopPaneUI.java | 2 +- .../swing/plaf/synth/SynthSplitPaneUI.java | 2 +- .../javax/swing/table/TableColumn.java | 2 +- .../javax/swing/text/AbstractDocument.java | 4 +- .../javax/swing/text/NumberFormatter.java | 13 ++-- .../javax/swing/text/PlainDocument.java | 2 +- .../classes/javax/swing/text/Segment.java | 2 +- .../javax/swing/text/StyleConstants.java | 6 +- .../javax/swing/text/html/AccessibleHTML.java | 8 +-- .../classes/javax/swing/text/html/CSS.java | 2 +- .../javax/swing/text/html/HTMLEditorKit.java | 4 +- .../swing/text/html/parser/AttributeList.java | 14 ++--- .../javax/swing/text/html/parser/DTD.java | 4 +- .../javax/swing/text/html/parser/Element.java | 8 +-- .../javax/swing/text/html/parser/Entity.java | 18 +++--- .../javax/swing/text/html/parser/Parser.java | 2 +- .../javax/swing/text/rtf/RTFAttributes.java | 6 +- .../javax/swing/text/rtf/RTFGenerator.java | 14 +---- .../swing/tree/DefaultTreeSelectionModel.java | 4 +- .../share/classes/sun/applet/AppletPanel.java | 2 +- .../classes/sun/applet/AppletViewer.java | 4 +- .../classes/sun/awt/FontConfiguration.java | 2 +- .../classes/sun/awt/im/InputContext.java | 4 +- .../classes/sun/font/FileFontStrike.java | 4 +- .../share/classes/sun/font/FontManager.java | 2 +- .../share/classes/sun/font/FontResolver.java | 2 +- .../classes/sun/font/PhysicalStrike.java | 2 +- .../classes/sun/java2d/SunGraphics2D.java | 2 +- .../classes/sun/java2d/loops/SurfaceType.java | 2 +- .../share/classes/sun/print/PSPrinterJob.java | 18 +++--- .../classes/sun/print/RasterPrinterJob.java | 2 +- .../sun/text/normalizer/VersionInfo.java | 2 +- .../sun/awt/X11/XDropTargetProtocol.java | 2 +- .../sun/awt/X11/XDropTargetRegistry.java | 2 +- .../sun/awt/X11/XEmbedServerTester.java | 4 +- .../classes/sun/awt/X11/XFileDialogPeer.java | 2 +- .../classes/sun/awt/X11/XScrollbar.java | 8 +-- .../classes/sun/awt/X11GraphicsConfig.java | 2 +- .../classes/sun/awt/X11GraphicsDevice.java | 6 +- .../classes/sun/print/UnixPrintJob.java | 21 +++---- .../sun/awt/windows/WDataTransferer.java | 2 +- .../classes/sun/awt/windows/WInputMethod.java | 2 +- .../classes/sun/awt/windows/WWindowPeer.java | 2 +- .../classes/sun/print/Win32PrintService.java | 8 +-- 80 files changed, 268 insertions(+), 276 deletions(-) diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java index b41450257a0..ae2bcb56a20 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java @@ -504,7 +504,7 @@ public class GIFImageReader extends ImageReader { } // Found position of metadata for image 0 - imageStartPosition.add(new Long(stream.getStreamPosition())); + imageStartPosition.add(Long.valueOf(stream.getStreamPosition())); } catch (IOException e) { throw new IIOException("I/O error reading header!", e); } diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFWritableImageMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFWritableImageMetadata.java index 66d647f6856..58d819f11ea 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFWritableImageMetadata.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFWritableImageMetadata.java @@ -98,7 +98,7 @@ class GIFWritableImageMetadata extends GIFImageMetadata { try { return data.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException e) { - return (new String("")).getBytes(); + return "".getBytes(); } } diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java index f5b671e7cd4..ba1c8da7958 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java @@ -328,7 +328,7 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements setHSB(hue, saturation, brightness); if (update) { settingColor = true; - hueSpinner.setValue(new Integer((int)(hue * 360))); + hueSpinner.setValue(Integer.valueOf((int)(hue * 360))); settingColor = false; } } @@ -376,8 +376,8 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements setHSB(hue, s, b); if (update) { settingColor = true; - saturationSpinner.setValue(new Integer((int)(s * 255))); - valueSpinner.setValue(new Integer((int)(b * 255))); + saturationSpinner.setValue(Integer.valueOf((int)(s * 255))); + valueSpinner.setValue(Integer.valueOf((int)(b * 255))); settingColor = false; } } @@ -391,9 +391,9 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements setColor(color, false, true, true); settingColor = true; - hueSpinner.setValue(new Integer((int)(hue * 360))); - saturationSpinner.setValue(new Integer((int)(saturation * 255))); - valueSpinner.setValue(new Integer((int)(brightness * 255))); + hueSpinner.setValue(Integer.valueOf((int)(hue * 360))); + saturationSpinner.setValue(Integer.valueOf((int)(saturation * 255))); + valueSpinner.setValue(Integer.valueOf((int)(brightness * 255))); settingColor = false; } @@ -409,9 +409,9 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements setColor(color, false, false, true); settingColor = true; - redSpinner.setValue(new Integer(color.getRed())); - greenSpinner.setValue(new Integer(color.getGreen())); - blueSpinner.setValue(new Integer(color.getBlue())); + redSpinner.setValue(Integer.valueOf(color.getRed())); + greenSpinner.setValue(Integer.valueOf(color.getGreen())); + blueSpinner.setValue(Integer.valueOf(color.getBlue())); settingColor = false; } @@ -454,13 +454,13 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements colorNameTF.setText("#" + hexString.substring(1)); if (updateSpinners) { - redSpinner.setValue(new Integer(color.getRed())); - greenSpinner.setValue(new Integer(color.getGreen())); - blueSpinner.setValue(new Integer(color.getBlue())); + redSpinner.setValue(Integer.valueOf(color.getRed())); + greenSpinner.setValue(Integer.valueOf(color.getGreen())); + blueSpinner.setValue(Integer.valueOf(color.getBlue())); - hueSpinner.setValue(new Integer((int)(hue * 360))); - saturationSpinner.setValue(new Integer((int)(saturation * 255))); - valueSpinner.setValue(new Integer((int)(brightness * 255))); + hueSpinner.setValue(Integer.valueOf((int)(hue * 360))); + saturationSpinner.setValue(Integer.valueOf((int)(saturation * 255))); + valueSpinner.setValue(Integer.valueOf((int)(brightness * 255))); } settingColor = false; } diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java index b4f435798a1..3c565604174 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java @@ -336,7 +336,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel { // populate the table with the values from basic. super.initComponentDefaults(table); - Integer zero = new Integer(0); + Integer zero = Integer.valueOf(0); Object zeroBorder = new sun.swing.SwingLazyValue( "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", new Object[] {zero, zero, zero, zero}); @@ -371,7 +371,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel { int vProgWidth = 22 - (progXThickness * 2); int vProgHeight = 80 - (progYThickness * 2); - Integer caretBlinkRate = new Integer(500); + Integer caretBlinkRate = Integer.valueOf(500); Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0); Double defaultCaretAspectRatio = new Double(0.025); @@ -540,7 +540,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel { } Object[] defaults = new Object[] { - "ArrowButton.size", new Integer(13), + "ArrowButton.size", Integer.valueOf(13), "Button.defaultButtonFollowsFocus", Boolean.FALSE, @@ -893,8 +893,8 @@ public class GTKLookAndFeel extends SynthLookAndFeel { "ScrollBar.squareButtons", Boolean.FALSE, - "ScrollBar.thumbHeight", new Integer(14), - "ScrollBar.width", new Integer(16), + "ScrollBar.thumbHeight", Integer.valueOf(14), + "ScrollBar.width", Integer.valueOf(16), "ScrollBar.minimumThumbSize", new Dimension(8, 8), "ScrollBar.maximumThumbSize", new Dimension(4096, 4096), "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE, @@ -954,12 +954,12 @@ public class GTKLookAndFeel extends SynthLookAndFeel { "Separator.insets", zeroInsets, - "Separator.thickness", new Integer(2), + "Separator.thickness", Integer.valueOf(2), "Slider.paintValue", Boolean.TRUE, - "Slider.thumbWidth", new Integer(30), - "Slider.thumbHeight", new Integer(14), + "Slider.thumbWidth", Integer.valueOf(30), + "Slider.thumbHeight", Integer.valueOf(14), "Slider.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "RIGHT", "positiveUnitIncrement", @@ -1013,9 +1013,9 @@ public class GTKLookAndFeel extends SynthLookAndFeel { }), - "SplitPane.size", new Integer(7), - "SplitPane.oneTouchOffset", new Integer(2), - "SplitPane.oneTouchButtonSize", new Integer(5), + "SplitPane.size", Integer.valueOf(7), + "SplitPane.oneTouchOffset", Integer.valueOf(2), + "SplitPane.oneTouchButtonSize", Integer.valueOf(5), "SplitPane.supportsOneTouchButtons", Boolean.FALSE, @@ -1223,13 +1223,13 @@ public class GTKLookAndFeel extends SynthLookAndFeel { "ToolTip.font", new FontLazyValue(Region.TOOL_TIP), - "Tree.padding", new Integer(4), + "Tree.padding", Integer.valueOf(4), "Tree.background", tableBg, "Tree.drawHorizontalLines", Boolean.FALSE, "Tree.drawVerticalLines", Boolean.FALSE, - "Tree.rowHeight", new Integer(-1), + "Tree.rowHeight", Integer.valueOf(-1), "Tree.scrollsOnExpand", Boolean.FALSE, - "Tree.expanderSize", new Integer(10), + "Tree.expanderSize", Integer.valueOf(10), "Tree.repaintWholeRow", Boolean.TRUE, "Tree.closedIcon", null, "Tree.leafIcon", null, @@ -1240,8 +1240,8 @@ public class GTKLookAndFeel extends SynthLookAndFeel { "Tree.collapsedIcon", new GTKStyle.GTKLazyValue( "com.sun.java.swing.plaf.gtk.GTKIconFactory", "getTreeCollapsedIcon"), - "Tree.leftChildIndent", new Integer(2), - "Tree.rightChildIndent", new Integer(12), + "Tree.leftChildIndent", Integer.valueOf(2), + "Tree.rightChildIndent", Integer.valueOf(12), "Tree.scrollsHorizontallyAndVertically", Boolean.FALSE, "Tree.drawsFocusBorder", Boolean.TRUE, "Tree.focusInputMap", diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java index 0d008907248..4f6e42c784c 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java @@ -851,7 +851,7 @@ class GTKStyle extends SynthStyle implements GTKConstants { int focusLineWidth = getClassSpecificIntValue(context, "focus-line-width", 0); if (value == null && focusLineWidth > 0) { - value = new Integer(16 + 2 * focusLineWidth); + value = Integer.valueOf(16 + 2 * focusLineWidth); } } return value; @@ -975,12 +975,12 @@ class GTKStyle extends SynthStyle implements GTKConstants { private static void initIconTypeMap() { ICON_TYPE_MAP = new HashMap(); - ICON_TYPE_MAP.put("gtk-menu", new Integer(1)); - ICON_TYPE_MAP.put("gtk-small-toolbar", new Integer(2)); - ICON_TYPE_MAP.put("gtk-large-toolbar", new Integer(3)); - ICON_TYPE_MAP.put("gtk-button", new Integer(4)); - ICON_TYPE_MAP.put("gtk-dnd", new Integer(5)); - ICON_TYPE_MAP.put("gtk-dialog", new Integer(6)); + ICON_TYPE_MAP.put("gtk-menu", Integer.valueOf(1)); + ICON_TYPE_MAP.put("gtk-small-toolbar", Integer.valueOf(2)); + ICON_TYPE_MAP.put("gtk-large-toolbar", Integer.valueOf(3)); + ICON_TYPE_MAP.put("gtk-button", Integer.valueOf(4)); + ICON_TYPE_MAP.put("gtk-dnd", Integer.valueOf(5)); + ICON_TYPE_MAP.put("gtk-dialog", Integer.valueOf(6)); } } diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java index 274ac510c0b..e6117989134 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java @@ -178,7 +178,7 @@ class Metacity implements SynthConstants { name = child.getNodeName(); Object value = null; if ("distance".equals(name)) { - value = new Integer(getIntAttr(child, "value", 0)); + value = Integer.valueOf(getIntAttr(child, "value", 0)); } else if ("border".equals(name)) { value = new Insets(getIntAttr(child, "top", 0), getIntAttr(child, "left", 0), @@ -808,7 +808,7 @@ class Metacity implements SynthConstants { protected void setFrameGeometry(JComponent titlePane, Map gm) { this.frameGeometry = gm; if (getInt("top_height") == 0 && titlePane != null) { - gm.put("top_height", new Integer(titlePane.getHeight())); + gm.put("top_height", Integer.valueOf(titlePane.getHeight())); } } diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java index 63994ff6732..995d195c34f 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java @@ -567,7 +567,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "ProgressBar.selectionBackground", table.get("controlText"), "ProgressBar.border", loweredBevelBorder, "ProgressBar.cellLength", new Integer(6), - "ProgressBar.cellSpacing", new Integer(0), + "ProgressBar.cellSpacing", Integer.valueOf(0), // Buttons "Button.margin", new InsetsUIResource(2, 4, 2, 4), @@ -859,7 +859,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "SplitPane.background", table.get("control"), "SplitPane.highlight", table.get("controlHighlight"), "SplitPane.shadow", table.get("controlShadow"), - "SplitPane.dividerSize", new Integer(20), + "SplitPane.dividerSize", Integer.valueOf(20), "SplitPane.activeThumb", table.get("activeCaptionBorder"), "SplitPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { @@ -1160,7 +1160,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel }), "TextField.caretForeground", black, - "TextField.caretBlinkRate", new Integer(500), + "TextField.caretBlinkRate", Integer.valueOf(500), "TextField.inactiveForeground", table.get("textInactiveText"), "TextField.selectionBackground", table.get("textHighlight"), "TextField.selectionForeground", table.get("textHighlightText"), @@ -1171,7 +1171,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "TextField.focusInputMap", fieldInputMap, "PasswordField.caretForeground", black, - "PasswordField.caretBlinkRate", new Integer(500), + "PasswordField.caretBlinkRate", Integer.valueOf(500), "PasswordField.inactiveForeground", table.get("textInactiveText"), "PasswordField.selectionBackground", table.get("textHighlight"), "PasswordField.selectionForeground", table.get("textHighlightText"), @@ -1182,7 +1182,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "PasswordField.focusInputMap", passwordInputMap, "TextArea.caretForeground", black, - "TextArea.caretBlinkRate", new Integer(500), + "TextArea.caretBlinkRate", Integer.valueOf(500), "TextArea.inactiveForeground", table.get("textInactiveText"), "TextArea.selectionBackground", table.get("textHighlight"), "TextArea.selectionForeground", table.get("textHighlightText"), @@ -1193,7 +1193,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "TextArea.focusInputMap", multilineInputMap, "TextPane.caretForeground", black, - "TextPane.caretBlinkRate", new Integer(500), + "TextPane.caretBlinkRate", Integer.valueOf(500), "TextPane.inactiveForeground", table.get("textInactiveText"), "TextPane.selectionBackground", lightGray, "TextPane.selectionForeground", table.get("textHighlightText"), @@ -1204,7 +1204,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "TextPane.focusInputMap", multilineInputMap, "EditorPane.caretForeground", red, - "EditorPane.caretBlinkRate", new Integer(500), + "EditorPane.caretBlinkRate", Integer.valueOf(500), "EditorPane.inactiveForeground", table.get("textInactiveText"), "EditorPane.selectionBackground", lightGray, "EditorPane.selectionForeground", table.get("textHighlightText"), diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java index 3977b4d1de6..9af41fc39c8 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java @@ -299,9 +299,9 @@ public class WindowsLookAndFeel extends BasicLookAndFeel initResourceBundle(table); // *** Shared Fonts - Integer twelve = new Integer(12); - Integer fontPlain = new Integer(Font.PLAIN); - Integer fontBold = new Integer(Font.BOLD); + Integer twelve = Integer.valueOf(12); + Integer fontPlain = Integer.valueOf(Font.PLAIN); + Integer fontBold = Integer.valueOf(Font.BOLD); Object dialogPlain12 = new SwingLazyValue( "javax.swing.plaf.FontUIResource", @@ -522,19 +522,19 @@ public class WindowsLookAndFeel extends BasicLookAndFeel toolkit); Object WindowBorderWidth = new DesktopProperty( "win.frame.sizingBorderWidth", - new Integer(1), + Integer.valueOf(1), toolkit); Object TitlePaneHeight = new DesktopProperty( "win.frame.captionHeight", - new Integer(18), + Integer.valueOf(18), toolkit); Object TitleButtonWidth = new DesktopProperty( "win.frame.captionButtonWidth", - new Integer(16), + Integer.valueOf(16), toolkit); Object TitleButtonHeight = new DesktopProperty( "win.frame.captionButtonHeight", - new Integer(16), + Integer.valueOf(16), toolkit); Object InactiveTextColor = new DesktopProperty( "win.text.grayedTextColor", @@ -567,7 +567,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel Object IconFont = ControlFont; Object scrollBarWidth = new DesktopProperty("win.scrollbar.width", - new Integer(16), toolkit); + Integer.valueOf(16), toolkit); Object menuBarHeight = new DesktopProperty("win.menu.height", null, toolkit); @@ -673,12 +673,12 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "Button.disabledForeground", InactiveTextColor, "Button.disabledShadow", ControlHighlightColor, "Button.focus", black, - "Button.dashedRectGapX", new XPValue(new Integer(3), new Integer(5)), - "Button.dashedRectGapY", new XPValue(new Integer(3), new Integer(4)), - "Button.dashedRectGapWidth", new XPValue(new Integer(6), new Integer(10)), - "Button.dashedRectGapHeight", new XPValue(new Integer(6), new Integer(8)), - "Button.textShiftOffset", new XPValue(new Integer(0), - new Integer(1)), + "Button.dashedRectGapX", new XPValue(Integer.valueOf(3), Integer.valueOf(5)), + "Button.dashedRectGapY", new XPValue(Integer.valueOf(3), Integer.valueOf(4)), + "Button.dashedRectGapWidth", new XPValue(Integer.valueOf(6), Integer.valueOf(10)), + "Button.dashedRectGapHeight", new XPValue(Integer.valueOf(6), Integer.valueOf(8)), + "Button.textShiftOffset", new XPValue(Integer.valueOf(0), + Integer.valueOf(1)), // W2K keyboard navigation hidding. "Button.showMnemonics", showMnemonics, "Button.focusInputMap", @@ -780,7 +780,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel }), // DesktopIcon - "DesktopIcon.width", new Integer(160), + "DesktopIcon.width", Integer.valueOf(160), "EditorPane.font", ControlFont, "EditorPane.background", WindowBackgroundColor, @@ -814,9 +814,9 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "icons/NewFolder.gif"), "FileChooser.useSystemExtensionHiding", Boolean.TRUE, - "FileChooser.lookInLabelMnemonic", new Integer(KeyEvent.VK_I), - "FileChooser.fileNameLabelMnemonic", new Integer(KeyEvent.VK_N), - "FileChooser.filesOfTypeLabelMnemonic", new Integer(KeyEvent.VK_T), + "FileChooser.lookInLabelMnemonic", Integer.valueOf(KeyEvent.VK_I), + "FileChooser.fileNameLabelMnemonic", Integer.valueOf(KeyEvent.VK_N), + "FileChooser.filesOfTypeLabelMnemonic", Integer.valueOf(KeyEvent.VK_T), "FileChooser.usesSingleFilePane", Boolean.TRUE, "FileChooser.noPlacesBar", new DesktopProperty("win.comdlg.noPlacesBar", Boolean.FALSE, toolkit), @@ -1021,10 +1021,10 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "Menu.selectionBackground", SelectionBackgroundColor, "Menu.acceleratorForeground", MenuTextColor, "Menu.acceleratorSelectionForeground", SelectionTextColor, - "Menu.menuPopupOffsetX", new Integer(0), - "Menu.menuPopupOffsetY", new Integer(0), - "Menu.submenuPopupOffsetX", new Integer(-4), - "Menu.submenuPopupOffsetY", new Integer(-3), + "Menu.menuPopupOffsetX", Integer.valueOf(0), + "Menu.menuPopupOffsetY", Integer.valueOf(0), + "Menu.submenuPopupOffsetX", Integer.valueOf(-4), + "Menu.submenuPopupOffsetY", Integer.valueOf(-3), "Menu.crossMenuMnemonic", Boolean.FALSE, "Menu.preserveTopLevelSelection", Boolean.TRUE, @@ -1184,8 +1184,8 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "ProgressBar.highlight", ControlHighlightColor, "ProgressBar.selectionForeground", ControlBackgroundColor, "ProgressBar.selectionBackground", SelectionBackgroundColor, - "ProgressBar.cellLength", new Integer(7), - "ProgressBar.cellSpacing", new Integer(2), + "ProgressBar.cellLength", Integer.valueOf(7), + "ProgressBar.cellSpacing", Integer.valueOf(2), "ProgressBar.indeterminateInsets", new Insets(3, 3, 3, 3), // *** RootPane. @@ -1292,7 +1292,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "SplitPane.highlight", ControlHighlightColor, "SplitPane.shadow", ControlShadowColor, "SplitPane.darkShadow", ControlDarkShadowColor, - "SplitPane.dividerSize", new Integer(5), + "SplitPane.dividerSize", Integer.valueOf(5), "SplitPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { "UP", "negativeIncrement", @@ -1496,7 +1496,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "ToggleButton.light", ControlLightColor, "ToggleButton.highlight", ControlHighlightColor, "ToggleButton.focus", ControlTextColor, - "ToggleButton.textShiftOffset", new Integer(1), + "ToggleButton.textShiftOffset", Integer.valueOf(1), "ToggleButton.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "SPACE", "pressed", @@ -1548,8 +1548,8 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "Tree.background", WindowBackgroundColor, "Tree.foreground", WindowTextColor, "Tree.hash", gray, - "Tree.leftChildIndent", new Integer(8), - "Tree.rightChildIndent", new Integer(11), + "Tree.leftChildIndent", Integer.valueOf(8), + "Tree.rightChildIndent", Integer.valueOf(11), "Tree.textForeground", WindowTextColor, "Tree.textBackground", WindowBackgroundColor, "Tree.selectionForeground", SelectionTextColor, @@ -2488,18 +2488,18 @@ public class WindowsLookAndFeel extends BasicLookAndFeel private int direction; XPDLUValue(int xpdlu, int classicdlu, int direction) { - super(new Integer(xpdlu), new Integer(classicdlu)); + super(Integer.valueOf(xpdlu), Integer.valueOf(classicdlu)); this.direction = direction; } public Object getXPValue(UIDefaults table) { int px = dluToPixels(((Integer)xpValue).intValue(), direction); - return new Integer(px); + return Integer.valueOf(px); } public Object getClassicValue(UIDefaults table) { int px = dluToPixels(((Integer)classicValue).intValue(), direction); - return new Integer(px); + return Integer.valueOf(px); } } diff --git a/jdk/src/share/classes/java/awt/Button.java b/jdk/src/share/classes/java/awt/Button.java index 46d0d072424..fcb33ddecc2 100644 --- a/jdk/src/share/classes/java/awt/Button.java +++ b/jdk/src/share/classes/java/awt/Button.java @@ -597,7 +597,7 @@ public class Button extends Component implements Accessible { public String getAccessibleActionDescription(int i) { if (i == 0) { // [[[PENDING: WDW -- need to provide a localized string]]] - return new String("click"); + return "click"; } else { return null; } diff --git a/jdk/src/share/classes/java/awt/MenuItem.java b/jdk/src/share/classes/java/awt/MenuItem.java index 899cab485ee..54756b8f488 100644 --- a/jdk/src/share/classes/java/awt/MenuItem.java +++ b/jdk/src/share/classes/java/awt/MenuItem.java @@ -847,7 +847,7 @@ public class MenuItem extends MenuComponent implements Accessible { public String getAccessibleActionDescription(int i) { if (i == 0) { // [[[PENDING: WDW -- need to provide a localized string]]] - return new String("click"); + return "click"; } else { return null; } diff --git a/jdk/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java b/jdk/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java index 77eb2bcec61..57936eb6045 100644 --- a/jdk/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java +++ b/jdk/src/share/classes/java/awt/datatransfer/SystemFlavorMap.java @@ -298,7 +298,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { while (continueLine(line)) { String nextLine = in.readLine(); if (nextLine == null) { - nextLine = new String(""); + nextLine = ""; } String loppedLine = line.substring(0, line.length() - 1); @@ -313,7 +313,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } nextLine = nextLine.substring(startIndex, nextLine.length()); - line = new String(loppedLine+nextLine); + line = loppedLine+nextLine; } // Find start of key diff --git a/jdk/src/share/classes/java/awt/image/BufferedImage.java b/jdk/src/share/classes/java/awt/image/BufferedImage.java index 763fc31df69..e5b77bec510 100644 --- a/jdk/src/share/classes/java/awt/image/BufferedImage.java +++ b/jdk/src/share/classes/java/awt/image/BufferedImage.java @@ -1210,9 +1210,9 @@ public class BufferedImage extends java.awt.Image * BufferedImage. */ public String toString() { - return new String("BufferedImage@"+Integer.toHexString(hashCode()) - +": type = "+imageType - +" "+colorModel+" "+raster); + return "BufferedImage@"+Integer.toHexString(hashCode()) + +": type = "+imageType + +" "+colorModel+" "+raster; } /** diff --git a/jdk/src/share/classes/java/text/DictionaryBasedBreakIterator.java b/jdk/src/share/classes/java/text/DictionaryBasedBreakIterator.java index 4a598155496..dac78aeda4b 100644 --- a/jdk/src/share/classes/java/text/DictionaryBasedBreakIterator.java +++ b/jdk/src/share/classes/java/text/DictionaryBasedBreakIterator.java @@ -384,7 +384,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { // on the last character of a legal word. Push that position onto // the possible-break-positions stack if (dictionary.getNextState(state, 0) == -1) { - possibleBreakPositions.push(new Integer(text.getIndex())); + possibleBreakPositions.push(Integer.valueOf(text.getIndex())); } // look up the new state to transition to in the dictionary @@ -395,7 +395,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { // and we've successfully traversed the whole range. Drop out // of the loop. if (state == -1) { - currentBreakPositions.push(new Integer(text.getIndex())); + currentBreakPositions.push(Integer.valueOf(text.getIndex())); break; } @@ -496,7 +496,7 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator { if (!currentBreakPositions.isEmpty()) { currentBreakPositions.pop(); } - currentBreakPositions.push(new Integer(endPos)); + currentBreakPositions.push(Integer.valueOf(endPos)); // create a regular array to hold the break positions and copy // the break positions from the stack to the array (in addition, diff --git a/jdk/src/share/classes/java/text/MessageFormat.java b/jdk/src/share/classes/java/text/MessageFormat.java index b16fefe646e..7f3db05402b 100644 --- a/jdk/src/share/classes/java/text/MessageFormat.java +++ b/jdk/src/share/classes/java/text/MessageFormat.java @@ -1286,7 +1286,7 @@ public class MessageFormat extends Format { characterIterators.add( createAttributedCharacterIterator( subIterator, Field.ARGUMENT, - new Integer(argumentNumber))); + Integer.valueOf(argumentNumber))); last = result.length(); } arg = null; @@ -1296,7 +1296,7 @@ public class MessageFormat extends Format { characterIterators.add( createAttributedCharacterIterator( arg, Field.ARGUMENT, - new Integer(argumentNumber))); + Integer.valueOf(argumentNumber))); last = result.length(); } } diff --git a/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java b/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java index b6a146c3dfd..a43578f8c66 100644 --- a/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java +++ b/jdk/src/share/classes/javax/imageio/stream/ImageInputStreamImpl.java @@ -778,8 +778,8 @@ public abstract class ImageInputStreamImpl implements ImageInputStream { */ public void mark() { try { - markByteStack.push(new Long(getStreamPosition())); - markBitStack.push(new Integer(getBitOffset())); + markByteStack.push(Long.valueOf(getStreamPosition())); + markBitStack.push(Integer.valueOf(getBitOffset())); } catch (IOException e) { } } diff --git a/jdk/src/share/classes/javax/swing/AbstractButton.java b/jdk/src/share/classes/javax/swing/AbstractButton.java index b4d4ae1e29a..6522cef8315 100644 --- a/jdk/src/share/classes/javax/swing/AbstractButton.java +++ b/jdk/src/share/classes/javax/swing/AbstractButton.java @@ -2047,14 +2047,14 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl null, AccessibleState.SELECTED); accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, - new Integer(0), new Integer(1)); + Integer.valueOf(0), Integer.valueOf(1)); } else { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_STATE_PROPERTY, AccessibleState.SELECTED, null); accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, - new Integer(1), new Integer(0)); + Integer.valueOf(1), Integer.valueOf(0)); } } } @@ -2552,9 +2552,9 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl */ public Number getCurrentAccessibleValue() { if (isSelected()) { - return new Integer(1); + return Integer.valueOf(1); } else { - return new Integer(0); + return Integer.valueOf(0); } } @@ -2583,7 +2583,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl * @return an Integer of 0. */ public Number getMinimumAccessibleValue() { - return new Integer(0); + return Integer.valueOf(0); } /** @@ -2592,7 +2592,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl * @return An Integer of 1. */ public Number getMaximumAccessibleValue() { - return new Integer(1); + return Integer.valueOf(1); } diff --git a/jdk/src/share/classes/javax/swing/DebugGraphicsInfo.java b/jdk/src/share/classes/javax/swing/DebugGraphicsInfo.java index 72bf9445bd0..635be42475e 100644 --- a/jdk/src/share/classes/javax/swing/DebugGraphicsInfo.java +++ b/jdk/src/share/classes/javax/swing/DebugGraphicsInfo.java @@ -49,7 +49,7 @@ class DebugGraphicsInfo { componentToDebug = new Hashtable(); } if (debug > 0) { - componentToDebug.put(component, new Integer(debug)); + componentToDebug.put(component, Integer.valueOf(debug)); } else { componentToDebug.remove(component); } diff --git a/jdk/src/share/classes/javax/swing/JInternalFrame.java b/jdk/src/share/classes/javax/swing/JInternalFrame.java index cc8480fc455..67d39b0cbb7 100644 --- a/jdk/src/share/classes/javax/swing/JInternalFrame.java +++ b/jdk/src/share/classes/javax/swing/JInternalFrame.java @@ -1285,7 +1285,7 @@ public class JInternalFrame extends JComponent implements * description: Specifies what desktop layer is used. */ public void setLayer(int layer) { - this.setLayer(new Integer(layer)); + this.setLayer(Integer.valueOf(layer)); } /** @@ -2092,7 +2092,7 @@ public class JInternalFrame extends JComponent implements * have a value */ public Number getCurrentAccessibleValue() { - return new Integer(getLayer()); + return Integer.valueOf(getLayer()); } /** @@ -2116,7 +2116,7 @@ public class JInternalFrame extends JComponent implements * have a minimum value */ public Number getMinimumAccessibleValue() { - return new Integer(Integer.MIN_VALUE); + return Integer.MIN_VALUE; } /** @@ -2126,7 +2126,7 @@ public class JInternalFrame extends JComponent implements * have a maximum value */ public Number getMaximumAccessibleValue() { - return new Integer(Integer.MAX_VALUE); + return Integer.MAX_VALUE; } } // AccessibleJInternalFrame diff --git a/jdk/src/share/classes/javax/swing/JOptionPane.java b/jdk/src/share/classes/javax/swing/JOptionPane.java index 0591f3dface..130d9f666a0 100644 --- a/jdk/src/share/classes/javax/swing/JOptionPane.java +++ b/jdk/src/share/classes/javax/swing/JOptionPane.java @@ -1512,7 +1512,7 @@ public class JOptionPane extends JComponent implements Accessible iFrame.putClientProperty("JInternalFrame.frameType", "optionDialog"); iFrame.putClientProperty("JInternalFrame.messageType", - new Integer(getMessageType())); + Integer.valueOf(getMessageType())); iFrame.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { diff --git a/jdk/src/share/classes/javax/swing/JProgressBar.java b/jdk/src/share/classes/javax/swing/JProgressBar.java index 337f5b118ef..68a6322c39a 100644 --- a/jdk/src/share/classes/javax/swing/JProgressBar.java +++ b/jdk/src/share/classes/javax/swing/JProgressBar.java @@ -775,9 +775,9 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, (oldModel== null - ? null : new Integer(oldModel.getValue())), + ? null : Integer.valueOf(oldModel.getValue())), (newModel== null - ? null : new Integer(newModel.getValue()))); + ? null : Integer.valueOf(newModel.getValue()))); } if (model != null) { @@ -850,8 +850,8 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, - new Integer(oldValue), - new Integer(brm.getValue())); + Integer.valueOf(oldValue), + Integer.valueOf(brm.getValue())); } } @@ -1087,7 +1087,7 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib * @return the current value of this object */ public Number getCurrentAccessibleValue() { - return new Integer(getValue()); + return Integer.valueOf(getValue()); } /** @@ -1110,7 +1110,7 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib * @return the minimum value of this object */ public Number getMinimumAccessibleValue() { - return new Integer(getMinimum()); + return Integer.valueOf(getMinimum()); } /** @@ -1120,7 +1120,7 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib */ public Number getMaximumAccessibleValue() { // TIGER - 4422362 - return new Integer(model.getMaximum() - model.getExtent()); + return Integer.valueOf(model.getMaximum() - model.getExtent()); } } // AccessibleJProgressBar diff --git a/jdk/src/share/classes/javax/swing/JScrollBar.java b/jdk/src/share/classes/javax/swing/JScrollBar.java index 0b646ac90b2..2136fe62975 100644 --- a/jdk/src/share/classes/javax/swing/JScrollBar.java +++ b/jdk/src/share/classes/javax/swing/JScrollBar.java @@ -314,7 +314,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible BoundedRangeModel oldModel = model; if (model != null) { model.removeChangeListener(fwdAdjustmentEvents); - oldValue = new Integer(model.getValue()); + oldValue = Integer.valueOf(model.getValue()); } model = newModel; if (model != null) { @@ -465,8 +465,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, - new Integer(oldValue), - new Integer(m.getValue())); + Integer.valueOf(oldValue), + Integer.valueOf(m.getValue())); } } @@ -611,8 +611,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, - new Integer(oldValue), - new Integer(m.getValue())); + Integer.valueOf(oldValue), + Integer.valueOf(m.getValue())); } } @@ -880,7 +880,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * @return The current value of this object. */ public Number getCurrentAccessibleValue() { - return new Integer(getValue()); + return Integer.valueOf(getValue()); } /** @@ -903,7 +903,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * @return The minimum value of this object. */ public Number getMinimumAccessibleValue() { - return new Integer(getMinimum()); + return Integer.valueOf(getMinimum()); } /** diff --git a/jdk/src/share/classes/javax/swing/JSlider.java b/jdk/src/share/classes/javax/swing/JSlider.java index 7a9c4439f24..e1a7909b073 100644 --- a/jdk/src/share/classes/javax/swing/JSlider.java +++ b/jdk/src/share/classes/javax/swing/JSlider.java @@ -485,9 +485,9 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, (oldModel == null - ? null : new Integer(oldModel.getValue())), + ? null : Integer.valueOf(oldModel.getValue())), (newModel == null - ? null : new Integer(newModel.getValue()))); + ? null : Integer.valueOf(newModel.getValue()))); } } @@ -538,8 +538,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, - new Integer(oldValue), - new Integer(m.getValue())); + Integer.valueOf(oldValue), + Integer.valueOf(m.getValue())); } } @@ -581,7 +581,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { public void setMinimum(int minimum) { int oldMin = getModel().getMinimum(); getModel().setMinimum(minimum); - firePropertyChange( "minimum", new Integer( oldMin ), new Integer( minimum ) ); + firePropertyChange( "minimum", Integer.valueOf( oldMin ), Integer.valueOf( minimum ) ); } @@ -622,7 +622,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { public void setMaximum(int maximum) { int oldMax = getModel().getMaximum(); getModel().setMaximum(maximum); - firePropertyChange( "maximum", new Integer( oldMax ), new Integer( maximum ) ); + firePropertyChange( "maximum", Integer.valueOf( oldMax ), Integer.valueOf( maximum ) ); } @@ -989,7 +989,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { void createLabels() { for ( int labelIndex = start; labelIndex <= getMaximum(); labelIndex += increment ) { - put( new Integer( labelIndex ), new LabelUIResource( ""+labelIndex, JLabel.CENTER ) ); + put( Integer.valueOf( labelIndex ), new LabelUIResource( ""+labelIndex, JLabel.CENTER ) ); } } } @@ -1463,7 +1463,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { * @return The current value of this object. */ public Number getCurrentAccessibleValue() { - return new Integer(getValue()); + return Integer.valueOf(getValue()); } /** @@ -1486,7 +1486,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { * @return The minimum value of this object. */ public Number getMinimumAccessibleValue() { - return new Integer(getMinimum()); + return Integer.valueOf(getMinimum()); } /** @@ -1497,7 +1497,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible { public Number getMaximumAccessibleValue() { // TIGER - 4422362 BoundedRangeModel model = JSlider.this.getModel(); - return new Integer(model.getMaximum() - model.getExtent()); + return Integer.valueOf(model.getMaximum() - model.getExtent()); } } // AccessibleJSlider } diff --git a/jdk/src/share/classes/javax/swing/JSplitPane.java b/jdk/src/share/classes/javax/swing/JSplitPane.java index 22465c4805a..d96a7ee7445 100644 --- a/jdk/src/share/classes/javax/swing/JSplitPane.java +++ b/jdk/src/share/classes/javax/swing/JSplitPane.java @@ -1195,7 +1195,7 @@ public class JSplitPane extends JComponent implements Accessible * @return a localized String describing the value of this object */ public Number getCurrentAccessibleValue() { - return new Integer(getDividerLocation()); + return Integer.valueOf(getDividerLocation()); } @@ -1220,7 +1220,7 @@ public class JSplitPane extends JComponent implements Accessible * @return The minimum value of this object. */ public Number getMinimumAccessibleValue() { - return new Integer(getUI().getMinimumDividerLocation( + return Integer.valueOf(getUI().getMinimumDividerLocation( JSplitPane.this)); } @@ -1231,7 +1231,7 @@ public class JSplitPane extends JComponent implements Accessible * @return The maximum value of this object. */ public Number getMaximumAccessibleValue() { - return new Integer(getUI().getMaximumDividerLocation( + return Integer.valueOf(getUI().getMaximumDividerLocation( JSplitPane.this)); } diff --git a/jdk/src/share/classes/javax/swing/JTabbedPane.java b/jdk/src/share/classes/javax/swing/JTabbedPane.java index defffc711a4..fb058ccaed7 100644 --- a/jdk/src/share/classes/javax/swing/JTabbedPane.java +++ b/jdk/src/share/classes/javax/swing/JTabbedPane.java @@ -967,7 +967,7 @@ public class JTabbedPane extends JComponent // currently no IndexPropertyChangeEvent. Once // IndexPropertyChangeEvents have been added this code should be // modified to use it. - putClientProperty("__index_to_remove__", new Integer(index)); + putClientProperty("__index_to_remove__", Integer.valueOf(index)); /* if the selected tab is after the removal */ if (selected > index) { diff --git a/jdk/src/share/classes/javax/swing/JTable.java b/jdk/src/share/classes/javax/swing/JTable.java index 562208939c9..62485a1c925 100644 --- a/jdk/src/share/classes/javax/swing/JTable.java +++ b/jdk/src/share/classes/javax/swing/JTable.java @@ -7680,7 +7680,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable */ public Accessible getAccessibleRowDescription(int r) { if (r < 0 || r >= getAccessibleRowCount()) { - throw new IllegalArgumentException(new Integer(r).toString()); + throw new IllegalArgumentException(Integer.toString(r)); } if (rowDescription == null) { return null; @@ -7698,7 +7698,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable */ public void setAccessibleRowDescription(int r, Accessible a) { if (r < 0 || r >= getAccessibleRowCount()) { - throw new IllegalArgumentException(new Integer(r).toString()); + throw new IllegalArgumentException(Integer.toString(r)); } if (rowDescription == null) { int numRows = getAccessibleRowCount(); @@ -7716,7 +7716,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable */ public Accessible getAccessibleColumnDescription(int c) { if (c < 0 || c >= getAccessibleColumnCount()) { - throw new IllegalArgumentException(new Integer(c).toString()); + throw new IllegalArgumentException(Integer.toString(c)); } if (columnDescription == null) { return null; @@ -7734,7 +7734,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable */ public void setAccessibleColumnDescription(int c, Accessible a) { if (c < 0 || c >= getAccessibleColumnCount()) { - throw new IllegalArgumentException(new Integer(c).toString()); + throw new IllegalArgumentException(Integer.toString(c)); } if (columnDescription == null) { int numColumns = getAccessibleColumnCount(); diff --git a/jdk/src/share/classes/javax/swing/JTextArea.java b/jdk/src/share/classes/javax/swing/JTextArea.java index 8f53daf2aca..18e3b45c35b 100644 --- a/jdk/src/share/classes/javax/swing/JTextArea.java +++ b/jdk/src/share/classes/javax/swing/JTextArea.java @@ -267,7 +267,7 @@ public class JTextArea extends JTextComponent { Document doc = getDocument(); if (doc != null) { int old = getTabSize(); - doc.putProperty(PlainDocument.tabSizeAttribute, new Integer(size)); + doc.putProperty(PlainDocument.tabSizeAttribute, Integer.valueOf(size)); firePropertyChange("tabSize", old, size); } } diff --git a/jdk/src/share/classes/javax/swing/SpinnerNumberModel.java b/jdk/src/share/classes/javax/swing/SpinnerNumberModel.java index e9b89b68ecf..fb8521b16f4 100644 --- a/jdk/src/share/classes/javax/swing/SpinnerNumberModel.java +++ b/jdk/src/share/classes/javax/swing/SpinnerNumberModel.java @@ -144,7 +144,7 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializ * minimum <= value <= maximum */ public SpinnerNumberModel(int value, int minimum, int maximum, int stepSize) { - this(new Integer(value), new Integer(minimum), new Integer(maximum), new Integer(stepSize)); + this(Integer.valueOf(value), Integer.valueOf(minimum), Integer.valueOf(maximum), Integer.valueOf(stepSize)); } @@ -171,7 +171,7 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializ * stepSize equal to one, and an initial value of zero. */ public SpinnerNumberModel() { - this(new Integer(0), null, null, new Integer(1)); + this(Integer.valueOf(0), null, null, Integer.valueOf(1)); } @@ -333,16 +333,16 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializ long v = value.longValue() + (stepSize.longValue() * (long)dir); if (value instanceof Long) { - newValue = new Long(v); + newValue = Long.valueOf(v); } else if (value instanceof Integer) { - newValue = new Integer((int)v); + newValue = Integer.valueOf((int)v); } else if (value instanceof Short) { - newValue = new Short((short)v); + newValue = Short.valueOf((short)v); } else { - newValue = new Byte((byte)v); + newValue = Byte.valueOf((byte)v); } } diff --git a/jdk/src/share/classes/javax/swing/TablePrintable.java b/jdk/src/share/classes/javax/swing/TablePrintable.java index ffef3054735..864b550b3c8 100644 --- a/jdk/src/share/classes/javax/swing/TablePrintable.java +++ b/jdk/src/share/classes/javax/swing/TablePrintable.java @@ -215,7 +215,7 @@ class TablePrintable implements Printable { } // to pass the page number when formatting the header and footer text - Object[] pageNumber = new Object[]{new Integer(pageIndex + 1)}; + Object[] pageNumber = new Object[]{Integer.valueOf(pageIndex + 1)}; // fetch the formatted header text, if any String headerText = null; diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java index fd3d84b2833..d6ad0643c1e 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java @@ -109,7 +109,7 @@ public class BasicButtonUI extends ButtonUI{ LookAndFeel.installProperty(b, "rolloverEnabled", rollover); } - LookAndFeel.installProperty(b, "iconTextGap", new Integer(4)); + LookAndFeel.installProperty(b, "iconTextGap", Integer.valueOf(4)); } protected void installListeners(AbstractButton b) { diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java index 77f46be88c1..87ade48cd78 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -654,7 +654,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab "javax.swing.plaf.basic.BasicIconFactory", "getRadioButtonMenuItemIcon"); - Object menuItemAcceleratorDelimiter = new String("+"); + Object menuItemAcceleratorDelimiter = "+"; // *** OptionPane value objects diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java index afe007aeb78..c56a1b49d39 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java @@ -146,7 +146,7 @@ public class BasicMenuItemUI extends MenuItemUI menuItem.setMargin(UIManager.getInsets(prefix + ".margin")); } - LookAndFeel.installProperty(menuItem, "iconTextGap", new Integer(4)); + LookAndFeel.installProperty(menuItem, "iconTextGap", Integer.valueOf(4)); defaultTextIconGap = menuItem.getIconTextGap(); LookAndFeel.installBorder(menuItem, prefix + ".border"); diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java index 86e458f3162..5ad6c2b92df 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java @@ -1195,10 +1195,10 @@ public class BasicOptionPaneUI extends OptionPaneUI { if (options == null) { if (optionType == JOptionPane.OK_CANCEL_OPTION && buttonIndex == 1) { - optionPane.setValue(new Integer(2)); + optionPane.setValue(Integer.valueOf(2)); } else { - optionPane.setValue(new Integer(buttonIndex)); + optionPane.setValue(Integer.valueOf(buttonIndex)); } } else { optionPane.setValue(options[buttonIndex]); @@ -1393,7 +1393,7 @@ public class BasicOptionPaneUI extends OptionPaneUI { if (getName() == CLOSE) { JOptionPane optionPane = (JOptionPane)e.getSource(); - optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION)); + optionPane.setValue(Integer.valueOf(JOptionPane.CLOSED_OPTION)); } } } diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java index 3afdc74d16e..2d0873cfcd2 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java @@ -539,7 +539,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { } mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, Event.ALT_MASK), "setSelectedIndex"); - mnemonicToIndexMap.put(new Integer(mnemonic), new Integer(index)); + mnemonicToIndexMap.put(Integer.valueOf(mnemonic), Integer.valueOf(index)); } /** @@ -2231,7 +2231,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { mnemonic -= ('a' - 'A'); } Integer index = (Integer)ui.mnemonicToIndexMap. - get(new Integer(mnemonic)); + get(Integer.valueOf(mnemonic)); if (index != null && pane.isEnabledAt(index.intValue())) { pane.setSelectedIndex(index.intValue()); } diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java index c2dff6035c4..e039d1b425b 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java @@ -178,7 +178,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants dragWindow = null; dockingSource = null; - c.putClientProperty( FOCUSED_COMP_INDEX, new Integer( focusedCompIndex ) ); + c.putClientProperty( FOCUSED_COMP_INDEX, Integer.valueOf( focusedCompIndex ) ); } protected void installDefaults( ) diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java index af0405f5774..d1f7c05935d 100644 --- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java +++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java @@ -455,7 +455,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0); - Integer zero = new Integer(0); + Integer zero = Integer.valueOf(0); Object textFieldBorder = new SwingLazyValue("javax.swing.plaf.metal.MetalBorders", @@ -904,7 +904,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel "ProgressBar.selectionBackground", primaryControlDarkShadow, "ProgressBar.border", progressBarBorder, "ProgressBar.cellSpacing", zero, - "ProgressBar.cellLength", new Integer(1), + "ProgressBar.cellLength", Integer.valueOf(1), // Combo Box "ComboBox.background", control, @@ -971,7 +971,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel "DesktopIcon.font", controlTextValue, "DesktopIcon.foreground", controlTextColor, "DesktopIcon.background", control, - "DesktopIcon.width", new Integer(160), + "DesktopIcon.width", Integer.valueOf(160), "Desktop.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthArrowButton.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthArrowButton.java index 51cc619a41b..dd703d0b517 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthArrowButton.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthArrowButton.java @@ -53,7 +53,7 @@ class SynthArrowButton extends JButton implements SwingConstants, UIResource { public void setDirection(int dir) { direction = dir; - putClientProperty("__arrow_direction__", new Integer(dir)); + putClientProperty("__arrow_direction__", Integer.valueOf(dir)); repaint(); } diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java index 88e15c6bcf9..e41fead8add 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java @@ -96,7 +96,7 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements } taskBar.setBackground(desktop.getBackground()); desktop.add(taskBar, - new Integer(JLayeredPane.PALETTE_LAYER.intValue() + 1)); + Integer.valueOf(JLayeredPane.PALETTE_LAYER.intValue() + 1)); if (desktop.isShowing()) { taskBar.adjustSize(); } diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java index 84c84de4912..ddbc7ae7e69 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java @@ -127,7 +127,7 @@ class SynthSplitPaneUI extends BasicSplitPaneUI implements if (style != oldStyle) { Object value = style.get(context, "SplitPane.size"); if (value == null) { - value = new Integer(6); + value = Integer.valueOf(6); } LookAndFeel.installProperty(splitPane, "dividerSize", value); diff --git a/jdk/src/share/classes/javax/swing/table/TableColumn.java b/jdk/src/share/classes/javax/swing/table/TableColumn.java index dddcdc3312d..890b855c746 100644 --- a/jdk/src/share/classes/javax/swing/table/TableColumn.java +++ b/jdk/src/share/classes/javax/swing/table/TableColumn.java @@ -281,7 +281,7 @@ public class TableColumn extends Object implements Serializable { private void firePropertyChange(String propertyName, int oldValue, int newValue) { if (oldValue != newValue) { - firePropertyChange(propertyName, new Integer(oldValue), new Integer(newValue)); + firePropertyChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue)); } } diff --git a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java index d9ca3f387dc..406350a9b10 100644 --- a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java +++ b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java @@ -351,7 +351,7 @@ public abstract class AbstractDocument implements Document, Serializable { * loaded asynchronously */ public void setAsynchronousLoadPriority(int p) { - Integer loadPriority = (p >= 0) ? new Integer(p) : null; + Integer loadPriority = (p >= 0) ? Integer.valueOf(p) : null; putProperty(AbstractDocument.AsyncLoadPriority, loadPriority); } @@ -2675,7 +2675,7 @@ public abstract class AbstractDocument implements Document, Serializable { */ BidiElement(Element parent, int start, int end, int level) { super(parent, new SimpleAttributeSet(), start, end); - addAttribute(StyleConstants.BidiLevel, new Integer(level)); + addAttribute(StyleConstants.BidiLevel, Integer.valueOf(level)); //System.out.println("BidiElement: start = " + start // + " end = " + end + " level = " + level ); } diff --git a/jdk/src/share/classes/javax/swing/text/NumberFormatter.java b/jdk/src/share/classes/javax/swing/text/NumberFormatter.java index c9c47193825..76e3a24029e 100644 --- a/jdk/src/share/classes/javax/swing/text/NumberFormatter.java +++ b/jdk/src/share/classes/javax/swing/text/NumberFormatter.java @@ -173,23 +173,24 @@ public class NumberFormatter extends InternationalFormatter { */ private Object convertValueToValueClass(Object value, Class valueClass) { if (valueClass != null && (value instanceof Number)) { + Number numberValue = (Number)value; if (valueClass == Integer.class) { - return new Integer(((Number)value).intValue()); + return Integer.valueOf(numberValue.intValue()); } else if (valueClass == Long.class) { - return new Long(((Number)value).longValue()); + return Long.valueOf(numberValue.longValue()); } else if (valueClass == Float.class) { - return new Float(((Number)value).floatValue()); + return Float.valueOf(numberValue.floatValue()); } else if (valueClass == Double.class) { - return new Double(((Number)value).doubleValue()); + return Double.valueOf(numberValue.doubleValue()); } else if (valueClass == Byte.class) { - return new Byte(((Number)value).byteValue()); + return Byte.valueOf(numberValue.byteValue()); } else if (valueClass == Short.class) { - return new Short(((Number)value).shortValue()); + return Short.valueOf(numberValue.shortValue()); } } return value; diff --git a/jdk/src/share/classes/javax/swing/text/PlainDocument.java b/jdk/src/share/classes/javax/swing/text/PlainDocument.java index 85ea6c8d262..2a3b6dbea92 100644 --- a/jdk/src/share/classes/javax/swing/text/PlainDocument.java +++ b/jdk/src/share/classes/javax/swing/text/PlainDocument.java @@ -89,7 +89,7 @@ public class PlainDocument extends AbstractDocument { */ public PlainDocument(Content c) { super(c); - putProperty(tabSizeAttribute, new Integer(8)); + putProperty(tabSizeAttribute, Integer.valueOf(8)); defaultRoot = createDefaultRoot(); } diff --git a/jdk/src/share/classes/javax/swing/text/Segment.java b/jdk/src/share/classes/javax/swing/text/Segment.java index 0186c900d4e..55d17a9a5cd 100644 --- a/jdk/src/share/classes/javax/swing/text/Segment.java +++ b/jdk/src/share/classes/javax/swing/text/Segment.java @@ -118,7 +118,7 @@ public class Segment implements Cloneable, CharacterIterator, CharSequence { if (array != null) { return new String(array, offset, count); } - return new String(); + return ""; } // --- CharacterIterator methods ------------------------------------- diff --git a/jdk/src/share/classes/javax/swing/text/StyleConstants.java b/jdk/src/share/classes/javax/swing/text/StyleConstants.java index fa59a783f5d..aaefef88f50 100644 --- a/jdk/src/share/classes/javax/swing/text/StyleConstants.java +++ b/jdk/src/share/classes/javax/swing/text/StyleConstants.java @@ -296,7 +296,7 @@ public class StyleConstants { * @param o the bidi level value */ public static void setBidiLevel(MutableAttributeSet a, int o) { - a.addAttribute(BidiLevel, new Integer(o)); + a.addAttribute(BidiLevel, Integer.valueOf(o)); } /** @@ -386,7 +386,7 @@ public class StyleConstants { * @param s the font size */ public static void setFontSize(MutableAttributeSet a, int s) { - a.addAttribute(FontSize, new Integer(s)); + a.addAttribute(FontSize, Integer.valueOf(s)); } /** @@ -753,7 +753,7 @@ public class StyleConstants { * @param align the alignment value */ public static void setAlignment(MutableAttributeSet a, int align) { - a.addAttribute(Alignment, new Integer(align)); + a.addAttribute(Alignment, Integer.valueOf(align)); } /** diff --git a/jdk/src/share/classes/javax/swing/text/html/AccessibleHTML.java b/jdk/src/share/classes/javax/swing/text/html/AccessibleHTML.java index a4680179c38..d0643bf342c 100644 --- a/jdk/src/share/classes/javax/swing/text/html/AccessibleHTML.java +++ b/jdk/src/share/classes/javax/swing/text/html/AccessibleHTML.java @@ -1970,7 +1970,7 @@ class AccessibleHTML implements Accessible { for (int i = 0; i < nRows; i++) { if (isAccessibleRowSelected(i)) { - vec.addElement(new Integer(i)); + vec.addElement(Integer.valueOf(i)); } } int retval[] = new int[vec.size()]; @@ -1995,7 +1995,7 @@ class AccessibleHTML implements Accessible { for (int i = 0; i < nColumns; i++) { if (isAccessibleColumnSelected(i)) { - vec.addElement(new Integer(i)); + vec.addElement(Integer.valueOf(i)); } } int retval[] = new int[vec.size()]; @@ -2139,7 +2139,7 @@ class AccessibleHTML implements Accessible { private int columnCount = 0; public void addHeader(TableCellElementInfo cellInfo, int rowNumber) { - Integer rowInteger = new Integer(rowNumber); + Integer rowInteger = Integer.valueOf(rowNumber); ArrayList list = (ArrayList)headers.get(rowInteger); if (list == null) { list = new ArrayList(); @@ -2201,7 +2201,7 @@ class AccessibleHTML implements Accessible { } private TableCellElementInfo getElementInfoAt(int r, int c) { - ArrayList list = (ArrayList)headers.get(new Integer(r)); + ArrayList list = (ArrayList)headers.get(Integer.valueOf(r)); if (list != null) { return (TableCellElementInfo)list.get(c); } else { diff --git a/jdk/src/share/classes/javax/swing/text/html/CSS.java b/jdk/src/share/classes/javax/swing/text/html/CSS.java index 40b5977e07a..56cb0fcb26c 100644 --- a/jdk/src/share/classes/javax/swing/text/html/CSS.java +++ b/jdk/src/share/classes/javax/swing/text/html/CSS.java @@ -1099,7 +1099,7 @@ public class CSS implements Serializable { */ static String colorToHex(Color color) { - String colorstr = new String("#"); + String colorstr = "#"; // Red String str = Integer.toHexString(color.getRed()); diff --git a/jdk/src/share/classes/javax/swing/text/html/HTMLEditorKit.java b/jdk/src/share/classes/javax/swing/text/html/HTMLEditorKit.java index 980817d964a..1f5d498f812 100644 --- a/jdk/src/share/classes/javax/swing/text/html/HTMLEditorKit.java +++ b/jdk/src/share/classes/javax/swing/text/html/HTMLEditorKit.java @@ -1899,8 +1899,8 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { // assistive technologies listening for such events. comp.getAccessibleContext().firePropertyChange( AccessibleContext.ACCESSIBLE_HYPERTEXT_OFFSET, - new Integer(kit.prevHypertextOffset), - new Integer(e.getDot())); + Integer.valueOf(kit.prevHypertextOffset), + Integer.valueOf(e.getDot())); } } } diff --git a/jdk/src/share/classes/javax/swing/text/html/parser/AttributeList.java b/jdk/src/share/classes/javax/swing/text/html/parser/AttributeList.java index a2d48603da7..3eb1cdb3d90 100644 --- a/jdk/src/share/classes/javax/swing/text/html/parser/AttributeList.java +++ b/jdk/src/share/classes/javax/swing/text/html/parser/AttributeList.java @@ -132,7 +132,7 @@ class AttributeList implements DTDConstants, Serializable { static Hashtable attributeTypes = new Hashtable(); static void defineAttributeType(String nm, int val) { - Integer num = new Integer(val); + Integer num = Integer.valueOf(val); attributeTypes.put(nm, num); attributeTypes.put(num, nm); } @@ -154,11 +154,11 @@ class AttributeList implements DTDConstants, Serializable { defineAttributeType("NUTOKEN", NUTOKEN); defineAttributeType("NUTOKENS", NUTOKENS); - attributeTypes.put("fixed", new Integer(FIXED)); - attributeTypes.put("required", new Integer(REQUIRED)); - attributeTypes.put("current", new Integer(CURRENT)); - attributeTypes.put("conref", new Integer(CONREF)); - attributeTypes.put("implied", new Integer(IMPLIED)); + attributeTypes.put("fixed", Integer.valueOf(FIXED)); + attributeTypes.put("required", Integer.valueOf(REQUIRED)); + attributeTypes.put("current", Integer.valueOf(CURRENT)); + attributeTypes.put("conref", Integer.valueOf(CONREF)); + attributeTypes.put("implied", Integer.valueOf(IMPLIED)); } public static int name2type(String nm) { @@ -167,6 +167,6 @@ class AttributeList implements DTDConstants, Serializable { } public static String type2name(int tp) { - return (String)attributeTypes.get(new Integer(tp)); + return (String)attributeTypes.get(Integer.valueOf(tp)); } } diff --git a/jdk/src/share/classes/javax/swing/text/html/parser/DTD.java b/jdk/src/share/classes/javax/swing/text/html/parser/DTD.java index 3fd48f16b20..9ee714371cb 100644 --- a/jdk/src/share/classes/javax/swing/text/html/parser/DTD.java +++ b/jdk/src/share/classes/javax/swing/text/html/parser/DTD.java @@ -113,7 +113,7 @@ class DTD implements DTDConstants { * ch character */ public Entity getEntity(int ch) { - return (Entity)entityHash.get(new Integer(ch)); + return (Entity)entityHash.get(Integer.valueOf(ch)); } /** @@ -178,7 +178,7 @@ class DTD implements DTDConstants { switch (type & ~GENERAL) { case CDATA: case SDATA: - entityHash.put(new Integer(data[0]), ent); + entityHash.put(Integer.valueOf(data[0]), ent); break; } } diff --git a/jdk/src/share/classes/javax/swing/text/html/parser/Element.java b/jdk/src/share/classes/javax/swing/text/html/parser/Element.java index 54b68618d50..7807b430632 100644 --- a/jdk/src/share/classes/javax/swing/text/html/parser/Element.java +++ b/jdk/src/share/classes/javax/swing/text/html/parser/Element.java @@ -162,10 +162,10 @@ class Element implements DTDConstants, Serializable { static Hashtable contentTypes = new Hashtable(); static { - contentTypes.put("CDATA", new Integer(CDATA)); - contentTypes.put("RCDATA", new Integer(RCDATA)); - contentTypes.put("EMPTY", new Integer(EMPTY)); - contentTypes.put("ANY", new Integer(ANY)); + contentTypes.put("CDATA", Integer.valueOf(CDATA)); + contentTypes.put("RCDATA", Integer.valueOf(RCDATA)); + contentTypes.put("EMPTY", Integer.valueOf(EMPTY)); + contentTypes.put("ANY", Integer.valueOf(ANY)); } public static int name2type(String nm) { diff --git a/jdk/src/share/classes/javax/swing/text/html/parser/Entity.java b/jdk/src/share/classes/javax/swing/text/html/parser/Entity.java index f4a5cb9a73c..01e56125ae8 100644 --- a/jdk/src/share/classes/javax/swing/text/html/parser/Entity.java +++ b/jdk/src/share/classes/javax/swing/text/html/parser/Entity.java @@ -110,15 +110,15 @@ class Entity implements DTDConstants { static Hashtable entityTypes = new Hashtable(); static { - entityTypes.put("PUBLIC", new Integer(PUBLIC)); - entityTypes.put("CDATA", new Integer(CDATA)); - entityTypes.put("SDATA", new Integer(SDATA)); - entityTypes.put("PI", new Integer(PI)); - entityTypes.put("STARTTAG", new Integer(STARTTAG)); - entityTypes.put("ENDTAG", new Integer(ENDTAG)); - entityTypes.put("MS", new Integer(MS)); - entityTypes.put("MD", new Integer(MD)); - entityTypes.put("SYSTEM", new Integer(SYSTEM)); + entityTypes.put("PUBLIC", Integer.valueOf(PUBLIC)); + entityTypes.put("CDATA", Integer.valueOf(CDATA)); + entityTypes.put("SDATA", Integer.valueOf(SDATA)); + entityTypes.put("PI", Integer.valueOf(PI)); + entityTypes.put("STARTTAG", Integer.valueOf(STARTTAG)); + entityTypes.put("ENDTAG", Integer.valueOf(ENDTAG)); + entityTypes.put("MS", Integer.valueOf(MS)); + entityTypes.put("MD", Integer.valueOf(MD)); + entityTypes.put("SYSTEM", Integer.valueOf(SYSTEM)); } /** diff --git a/jdk/src/share/classes/javax/swing/text/html/parser/Parser.java b/jdk/src/share/classes/javax/swing/text/html/parser/Parser.java index 24ba58fffb3..7be7bf5ebf8 100644 --- a/jdk/src/share/classes/javax/swing/text/html/parser/Parser.java +++ b/jdk/src/share/classes/javax/swing/text/html/parser/Parser.java @@ -1842,7 +1842,7 @@ class Parser implements DTDConstants { String elemStr = getString(0); if (elemStr.equals("image")) { - elemStr = new String("img"); + elemStr = "img"; } /* determine if this element is part of the dtd. */ diff --git a/jdk/src/share/classes/javax/swing/text/rtf/RTFAttributes.java b/jdk/src/share/classes/javax/swing/text/rtf/RTFAttributes.java index 2bf54b31b94..fb1b95e9307 100644 --- a/jdk/src/share/classes/javax/swing/text/rtf/RTFAttributes.java +++ b/jdk/src/share/classes/javax/swing/text/rtf/RTFAttributes.java @@ -281,7 +281,7 @@ class RTFAttributes public AssertiveAttribute(int d, Object s, String r, int v) { super(d, s, r); - swingValue = new Integer(v); + swingValue = Integer.valueOf(v); } public boolean set(MutableAttributeSet target) @@ -343,7 +343,7 @@ class RTFAttributes public NumericAttribute(int d, Object s, String r, int ds, int dr) { - this(d, s, r, new Integer(ds), dr, 1f); + this(d, s, r, Integer.valueOf(ds), dr, 1f); } public NumericAttribute(int d, Object s, @@ -377,7 +377,7 @@ class RTFAttributes Number swingValue; if (scale == 1f) - swingValue = new Integer(parameter); + swingValue = Integer.valueOf(parameter); else swingValue = new Float(parameter / scale); target.addAttribute(swingName, swingValue); diff --git a/jdk/src/share/classes/javax/swing/text/rtf/RTFGenerator.java b/jdk/src/share/classes/javax/swing/text/rtf/RTFGenerator.java index 0c7a92f911d..201ba5364ad 100644 --- a/jdk/src/share/classes/javax/swing/text/rtf/RTFGenerator.java +++ b/jdk/src/share/classes/javax/swing/text/rtf/RTFGenerator.java @@ -83,11 +83,7 @@ class RTFGenerator extends Object static public final String defaultFontFamily = "Helvetica"; /* constants so we can avoid allocating objects in inner loops */ - /* these should all be final, but javac seems to be a bit buggy */ - static protected Integer One, Zero; - static protected Boolean False; - static protected Float ZeroPointZero; - static private Object MagicToken; + final static private Object MagicToken; /* An array of character-keyword pairs. This could be done as a dictionary (and lookup would be quicker), but that @@ -98,11 +94,7 @@ class RTFGenerator extends Object static protected CharacterKeywordPair[] textKeywords; static { - One = new Integer(1); - Zero = new Integer(0); - False = Boolean.valueOf(false); MagicToken = new Object(); - ZeroPointZero = new Float(0); Dictionary textKeywordDictionary = RTFReader.textKeywords; Enumeration keys = textKeywordDictionary.keys(); @@ -142,7 +134,7 @@ static public void writeDocument(Document d, OutputStream to) public RTFGenerator(OutputStream to) { colorTable = new Hashtable(); - colorTable.put(defaultRTFColor, new Integer(0)); + colorTable.put(defaultRTFColor, Integer.valueOf(0)); colorCount = 1; fontTable = new Hashtable(); @@ -693,7 +685,7 @@ protected void resetParagraphAttributes(MutableAttributeSet currentAttributes) { writeControlWord("pard"); - currentAttributes.addAttribute(StyleConstants.Alignment, Zero); + currentAttributes.addAttribute(StyleConstants.Alignment, Integer.valueOf(0)); int wordIndex; int wordCount = RTFAttributes.attributes.length; diff --git a/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java b/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java index 8ca40d8beab..cbf9ead8c37 100644 --- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java +++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java @@ -157,8 +157,8 @@ public class DefaultTreeSelectionModel extends Object implements Cloneable, Seri selectionMode = TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION; if(oldMode != selectionMode && changeSupport != null) changeSupport.firePropertyChange(SELECTION_MODE_PROPERTY, - new Integer(oldMode), - new Integer(selectionMode)); + Integer.valueOf(oldMode), + Integer.valueOf(selectionMode)); } /** diff --git a/jdk/src/share/classes/sun/applet/AppletPanel.java b/jdk/src/share/classes/sun/applet/AppletPanel.java index fe4c356fe03..e02428b146b 100644 --- a/jdk/src/share/classes/sun/applet/AppletPanel.java +++ b/jdk/src/share/classes/sun/applet/AppletPanel.java @@ -285,7 +285,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable { //System.out.println("SEND0= " + id); queue = new Queue(); } - Integer eventId = new Integer(id); + Integer eventId = Integer.valueOf(id); queue.enqueue(eventId); notifyAll(); } diff --git a/jdk/src/share/classes/sun/applet/AppletViewer.java b/jdk/src/share/classes/sun/applet/AppletViewer.java index 5170b0258a1..69bd80e261c 100644 --- a/jdk/src/share/classes/sun/applet/AppletViewer.java +++ b/jdk/src/share/classes/sun/applet/AppletViewer.java @@ -587,9 +587,9 @@ public class AppletViewer extends Frame implements AppletContext, Dimension d = panel.size(); Insets in = panel.insets(); panel.atts.put("width", - new Integer(d.width - (in.left + in.right)).toString()); + Integer.toString(d.width - (in.left + in.right))); panel.atts.put("height", - new Integer(d.height - (in.top + in.bottom)).toString()); + Integer.toString(d.height - (in.top + in.bottom))); } /** diff --git a/jdk/src/share/classes/sun/awt/FontConfiguration.java b/jdk/src/share/classes/sun/awt/FontConfiguration.java index 9a1effd39a8..a6b94870b3f 100644 --- a/jdk/src/share/classes/sun/awt/FontConfiguration.java +++ b/jdk/src/share/classes/sun/awt/FontConfiguration.java @@ -1956,7 +1956,7 @@ public abstract class FontConfiguration { /*Init these tables to allow componentFontNameID, fontfileNameIDs to start from "1". */ - componentFontNameIDs.put("", new Short((short)0)); + componentFontNameIDs.put("", Short.valueOf((short)0)); fontfileNameIDs = new HashMap(); filenames = new HashMap(); diff --git a/jdk/src/share/classes/sun/awt/im/InputContext.java b/jdk/src/share/classes/sun/awt/im/InputContext.java index 5cb7e26705d..1ef31f1ded4 100644 --- a/jdk/src/share/classes/sun/awt/im/InputContext.java +++ b/jdk/src/share/classes/sun/awt/im/InputContext.java @@ -556,7 +556,7 @@ public class InputContext extends java.awt.im.InputContext } usedInputMethods.put(inputMethodLocator.deriveLocator(null), inputMethod); perInputMethodState.put(inputMethod, - new Boolean(clientWindowNotificationEnabled)); + Boolean.valueOf(clientWindowNotificationEnabled)); enableClientWindowNotification(inputMethod, false); if (this == inputMethodWindowContext) { inputMethod.hideWindows(); @@ -921,7 +921,7 @@ public class InputContext extends java.awt.im.InputContext if (perInputMethodState == null) { perInputMethodState = new HashMap(5); } - perInputMethodState.put(requester, new Boolean(enable)); + perInputMethodState.put(requester, Boolean.valueOf(enable)); return; } diff --git a/jdk/src/share/classes/sun/font/FileFontStrike.java b/jdk/src/share/classes/sun/font/FileFontStrike.java index edc9e67b6cb..76616d8ce39 100644 --- a/jdk/src/share/classes/sun/font/FileFontStrike.java +++ b/jdk/src/share/classes/sun/font/FileFontStrike.java @@ -657,7 +657,7 @@ public class FileFontStrike extends PhysicalStrike { * we first obtain this information, then the image, and never * will access this value again. */ - Integer key = new Integer(glyphCode); + Integer key = Integer.valueOf(glyphCode); Point2D.Float value = null; ConcurrentHashMap glyphMetricsMap = null; if (glyphMetricsMapRef != null) { @@ -724,7 +724,7 @@ public class FileFontStrike extends PhysicalStrike { boundsMap = new ConcurrentHashMap(); } - Integer key = new Integer(glyphCode); + Integer key = Integer.valueOf(glyphCode); Rectangle2D.Float bounds = boundsMap.get(key); if (bounds == null) { diff --git a/jdk/src/share/classes/sun/font/FontManager.java b/jdk/src/share/classes/sun/font/FontManager.java index 820c72728d3..d7fddd16d2b 100644 --- a/jdk/src/share/classes/sun/font/FontManager.java +++ b/jdk/src/share/classes/sun/font/FontManager.java @@ -2124,7 +2124,7 @@ public final class FontManager { private static void addLCIDMapEntry(Map map, String key, short value) { - map.put(key, new Short(value)); + map.put(key, Short.valueOf(value)); } private static synchronized void createLCIDMap() { diff --git a/jdk/src/share/classes/sun/font/FontResolver.java b/jdk/src/share/classes/sun/font/FontResolver.java index 5d130236e77..938fe3cade5 100644 --- a/jdk/src/share/classes/sun/font/FontResolver.java +++ b/jdk/src/share/classes/sun/font/FontResolver.java @@ -117,7 +117,7 @@ public final class FontResolver { Font2D font2D = FontManager.getFont2D(font); if (font2D.hasSupplementaryChars()) { fonts.add(font); - indices.add(new Integer(i)); + indices.add(Integer.valueOf(i)); } } diff --git a/jdk/src/share/classes/sun/font/PhysicalStrike.java b/jdk/src/share/classes/sun/font/PhysicalStrike.java index 31d8ff66281..b6f326bef53 100644 --- a/jdk/src/share/classes/sun/font/PhysicalStrike.java +++ b/jdk/src/share/classes/sun/font/PhysicalStrike.java @@ -114,7 +114,7 @@ public abstract class PhysicalStrike extends FontStrike { */ Point2D.Float getGlyphPoint(int glyphCode, int ptNumber) { Point2D.Float gp = null; - Integer ptKey = new Integer(glyphCode<<16|ptNumber); + Integer ptKey = Integer.valueOf(glyphCode<<16|ptNumber); if (glyphPointMapCache == null) { synchronized (this) { if (glyphPointMapCache == null) { diff --git a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java index 887f4c91e97..018fad4b9bf 100644 --- a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java +++ b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java @@ -1374,7 +1374,7 @@ public final class SunGraphics2D SunHints.Value.get(SunHints.INTKEY_FRACTIONALMETRICS, fractionalMetricsHint)); model.put(SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST, - new Integer(lcdTextContrast)); + Integer.valueOf(lcdTextContrast)); Object value; switch (interpolationHint) { case SunHints.INTVAL_INTERPOLATION_NEAREST_NEIGHBOR: diff --git a/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java b/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java index c89d95a6a70..fc56cd9c77c 100644 --- a/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java +++ b/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java @@ -408,7 +408,7 @@ public final class SurfaceType { if (unusedUID > 255) { throw new InternalError("surface type id overflow"); } - i = new Integer(unusedUID++); + i = Integer.valueOf(unusedUID++); surfaceUIDMap.put(desc, i); } return i.intValue(); diff --git a/jdk/src/share/classes/sun/print/PSPrinterJob.java b/jdk/src/share/classes/sun/print/PSPrinterJob.java index 0b519599d13..5c2a9a5f216 100644 --- a/jdk/src/share/classes/sun/print/PSPrinterJob.java +++ b/jdk/src/share/classes/sun/print/PSPrinterJob.java @@ -1536,16 +1536,16 @@ public class PSPrinterJob extends RasterPrinterJob { execCmd = new String[ncomps]; execCmd[n++] = "/usr/bin/lpr"; if ((pFlags & PRINTER) != 0) { - execCmd[n++] = new String("-P" + printer); + execCmd[n++] = "-P" + printer; } if ((pFlags & BANNER) != 0) { - execCmd[n++] = new String("-J" + banner); + execCmd[n++] = "-J" + banner; } if ((pFlags & COPIES) != 0) { - execCmd[n++] = new String("-#" + new Integer(copies).toString()); + execCmd[n++] = "-#" + copies; } if ((pFlags & NOSHEET) != 0) { - execCmd[n++] = new String("-h"); + execCmd[n++] = "-h"; } if ((pFlags & OPTIONS) != 0) { execCmd[n++] = new String(options); @@ -1556,19 +1556,19 @@ public class PSPrinterJob extends RasterPrinterJob { execCmd[n++] = "/usr/bin/lp"; execCmd[n++] = "-c"; // make a copy of the spool file if ((pFlags & PRINTER) != 0) { - execCmd[n++] = new String("-d" + printer); + execCmd[n++] = "-d" + printer; } if ((pFlags & BANNER) != 0) { - execCmd[n++] = new String("-t" + banner); + execCmd[n++] = "-t" + banner; } if ((pFlags & COPIES) != 0) { - execCmd[n++] = new String("-n" + new Integer(copies).toString()); + execCmd[n++] = "-n" + copies; } if ((pFlags & NOSHEET) != 0) { - execCmd[n++] = new String("-o nobanner"); + execCmd[n++] = "-o nobanner"; } if ((pFlags & OPTIONS) != 0) { - execCmd[n++] = new String("-o" + options); + execCmd[n++] = "-o" + options; } } execCmd[n++] = spoolFile; diff --git a/jdk/src/share/classes/sun/print/RasterPrinterJob.java b/jdk/src/share/classes/sun/print/RasterPrinterJob.java index 9e2d2ffcfb5..1c0c0a8a2f4 100644 --- a/jdk/src/share/classes/sun/print/RasterPrinterJob.java +++ b/jdk/src/share/classes/sun/print/RasterPrinterJob.java @@ -245,7 +245,7 @@ public abstract class RasterPrinterJob extends PrinterJob { /** * The name of the job being printed. */ - private String mDocName = new String("Java Printing"); + private String mDocName = "Java Printing"; /** diff --git a/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java b/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java index e6039722316..3b3cc4d24b9 100644 --- a/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java +++ b/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java @@ -116,7 +116,7 @@ public final class VersionInfo throw new IllegalArgumentException(INVALID_VERSION_NUMBER_); } int version = getInt(major, minor, milli, micro); - Integer key = new Integer(version); + Integer key = Integer.valueOf(version); Object result = MAP_.get(key); if (result == null) { result = new VersionInfo(version); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java index bc6bacb2417..658b7cbf3d5 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java @@ -317,7 +317,7 @@ abstract class XDropTargetProtocol { protected final void removeEmbedderRegistryEntry(long embedder) { synchronized (this) { - embedderRegistry.remove(new Long(embedder)); + embedderRegistry.remove(Long.valueOf(embedder)); } } } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java index eecad17af89..2d05578dd04 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java @@ -329,7 +329,7 @@ final class XDropTargetRegistry { embedderProtocols = Collections.unmodifiableList(embedderProtocols); - Long lToplevel = new Long(embedder); + Long lToplevel = Long.valueOf(embedder); boolean isXEmbedServer = false; synchronized (this) { EmbeddedDropSiteEntry entry = diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java index a5ce2df7404..28fd3c2246a 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java @@ -383,11 +383,11 @@ public class XEmbedServerTester implements XEventDispatcher { try { XCreateWindowParams params = new XCreateWindowParams(new Object[] { - XBaseWindow.PARENT_WINDOW, new Long(reparent?XToolkit.getDefaultRootWindow():parent), + XBaseWindow.PARENT_WINDOW, Long.valueOf(reparent?XToolkit.getDefaultRootWindow():parent), XBaseWindow.BOUNDS, initialBounds, XBaseWindow.EMBEDDED, Boolean.TRUE, XBaseWindow.VISIBLE, Boolean.valueOf(mapped == XEmbedHelper.XEMBED_MAPPED), - XBaseWindow.EVENT_MASK, new Long(VisibilityChangeMask | StructureNotifyMask | + XBaseWindow.EVENT_MASK, Long.valueOf(VisibilityChangeMask | StructureNotifyMask | SubstructureNotifyMask | KeyPressMask)}); window = new XBaseWindow(params); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java index d3baad68ed3..4e06328b9ae 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java @@ -908,7 +908,7 @@ class FileDialogFilter implements FilenameFilter { * Converts the filter into the form which is acceptable by Java's regexps */ private String convert(String filter) { - String regex = new String("^" + filter + "$"); + String regex = "^" + filter + "$"; regex = regex.replaceAll("\\.", "\\\\."); regex = regex.replaceAll("\\?", "."); regex = regex.replaceAll("\\*", ".*"); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XScrollbar.java b/jdk/src/solaris/classes/sun/awt/X11/XScrollbar.java index 14316beed91..8a2d21b7ccd 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XScrollbar.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XScrollbar.java @@ -458,16 +458,16 @@ abstract class XScrollbar { String type; switch (id) { case MouseEvent.MOUSE_PRESSED: - type = new String("press"); + type = "press"; break; case MouseEvent.MOUSE_RELEASED: - type = new String("release"); + type = "release"; break; case MouseEvent.MOUSE_DRAGGED: - type = new String("drag"); + type = "drag"; break; default: - type = new String("other"); + type = "other"; } log.finer("Mouse " + type + " event in scroll bar " + this + "x = " + x + ", y = " + y + diff --git a/jdk/src/solaris/classes/sun/awt/X11GraphicsConfig.java b/jdk/src/solaris/classes/sun/awt/X11GraphicsConfig.java index 897142223da..78fd9db279b 100644 --- a/jdk/src/solaris/classes/sun/awt/X11GraphicsConfig.java +++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsConfig.java @@ -421,7 +421,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration { return new SunVolatileImage(target, target.getWidth(), target.getHeight(), - new Long(backBuffer)); + Long.valueOf(backBuffer)); } /** diff --git a/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java b/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java index 755e77aa860..bdb178e8918 100644 --- a/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java +++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java @@ -164,7 +164,7 @@ public class X11GraphicsDevice if (ret[i] == null) { boolean doubleBuffer = (dbeSupported && - doubleBufferVisuals.contains(new Integer(visNum))); + doubleBufferVisuals.contains(Integer.valueOf(visNum))); ret[i] = X11GraphicsConfig.getConfig(this, visNum, depth, getConfigColormap(i, screen), doubleBuffer); @@ -199,7 +199,7 @@ public class X11GraphicsDevice public static native boolean isDBESupported(); // Callback for adding a new double buffer visual into our set private void addDoubleBufferVisual(int visNum) { - doubleBufferVisuals.add(new Integer(visNum)); + doubleBufferVisuals.add(Integer.valueOf(visNum)); } // Enumerates all visuals that support double buffering private native void getDoubleBufferVisuals(int screen); @@ -239,7 +239,7 @@ public class X11GraphicsDevice doubleBufferVisuals = new HashSet(); getDoubleBufferVisuals(screen); doubleBuffer = - doubleBufferVisuals.contains(new Integer(visNum)); + doubleBufferVisuals.contains(Integer.valueOf(visNum)); } defaultConfig = X11GraphicsConfig.getConfig(this, visNum, depth, getConfigColormap(0, screen), diff --git a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java index b3ab80a6f92..ad86ee2545c 100644 --- a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java +++ b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java @@ -867,39 +867,38 @@ public class UnixPrintJob implements CancelablePrintJob { execCmd[n++] = "/usr/bin/lp"; execCmd[n++] = "-c"; // make a copy of the spool file if ((pFlags & PRINTER) != 0) { - execCmd[n++] = new String("-d" + printer); + execCmd[n++] = "-d" + printer; } if ((pFlags & BANNER) != 0) { String quoteChar = "\""; - execCmd[n++] = new String("-t " + quoteChar+banner+quoteChar); + execCmd[n++] = "-t " + quoteChar+banner+quoteChar; } if ((pFlags & COPIES) != 0) { - execCmd[n++] = new String("-n " + - new Integer(copies).toString()); + execCmd[n++] = "-n " + copies; } if ((pFlags & NOSHEET) != 0) { - execCmd[n++] = new String("-o nobanner"); + execCmd[n++] = "-o nobanner"; } if ((pFlags & OPTIONS) != 0) { - execCmd[n++] = new String("-o " + options); + execCmd[n++] = "-o " + options; } } else { execCmd = new String[ncomps]; execCmd[n++] = "/usr/bin/lpr"; if ((pFlags & PRINTER) != 0) { - execCmd[n++] = new String("-P" + printer); + execCmd[n++] = "-P" + printer; } if ((pFlags & BANNER) != 0) { - execCmd[n++] = new String("-J " + banner); + execCmd[n++] = "-J " + banner; } if ((pFlags & COPIES) != 0) { - execCmd[n++] = new String("-#" + new Integer(copies).toString()); + execCmd[n++] = "-#" + copies; } if ((pFlags & NOSHEET) != 0) { - execCmd[n++] = new String("-h"); + execCmd[n++] = "-h"; } if ((pFlags & OPTIONS) != 0) { - execCmd[n++] = new String("-o" + options); + execCmd[n++] = "-o" + options; } } execCmd[n++] = spoolFile; diff --git a/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java b/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java index fbab9e602ab..7e9429d4512 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java @@ -568,7 +568,7 @@ class HTMLCodec extends InputStream { byte[] headerBytes = null, trailerBytes = null; try { - headerBytes = new String(header).getBytes(ENCODING); + headerBytes = header.toString().getBytes(ENCODING); trailerBytes = htmlSuffix.getBytes(ENCODING); } catch (UnsupportedEncodingException cannotHappen) { } diff --git a/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java b/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java index 1c3600ffb66..494ce4c0f45 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java +++ b/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java @@ -488,7 +488,7 @@ public class WInputMethod extends InputMethodAdapter attrStr.addAttribute(Attribute.INPUT_METHOD_SEGMENT, new Annotation(null), 0, text.length()); attrStr.addAttribute(Attribute.READING, - new Annotation(new String("")), 0, text.length()); + new Annotation(""), 0, text.length()); } // set Hilight Information diff --git a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java index 070c67dd15e..2db3e8829ac 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java @@ -123,7 +123,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer { public void setTitle(String title) { // allow a null title to pass as an empty string. if (title == null) { - title = new String(""); + title = ""; } _setTitle(title); } diff --git a/jdk/src/windows/classes/sun/print/Win32PrintService.java b/jdk/src/windows/classes/sun/print/Win32PrintService.java index ea5771b3ad2..f0f05267ae6 100644 --- a/jdk/src/windows/classes/sun/print/Win32PrintService.java +++ b/jdk/src/windows/classes/sun/print/Win32PrintService.java @@ -348,7 +348,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, idList = new ArrayList(); for (int i=0; i < media.length; i++) { - idList.add(new Integer(media[i])); + idList.add(Integer.valueOf(media[i])); } mediaSizes = getMediaSizes(idList, media); @@ -517,7 +517,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, if ((wid <= 0) || (ht <= 0)) { //Remove corresponding ID from list if (nMedia == media.length) { - Integer remObj = new Integer(media[i]); + Integer remObj = Integer.valueOf(media[i]); idList.remove(idList.indexOf(remObj)); } continue; @@ -539,7 +539,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, msList.add(ms); } catch(IllegalArgumentException e) { if (nMedia == media.length) { - Integer remObj = new Integer(media[i]); + Integer remObj = Integer.valueOf(media[i]); idList.remove(idList.indexOf(remObj)); } } @@ -984,7 +984,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, // cannot be null but to be safe, add a check if ((idList != null) && (mediaSizes != null) && (idList.size() == mediaSizes.length)) { - Integer defIdObj = new Integer(defPaper); + Integer defIdObj = Integer.valueOf(defPaper); int index = idList.indexOf(defIdObj); if (index>=0 && index Date: Mon, 7 Apr 2008 16:52:51 +0400 Subject: [PATCH 030/119] 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern Access to interface's fiels via their name rather then implementation Reviewed-by: volk, son --- .../classes/sun/awt/X11/MWMConstants.java | 6 +- .../sun/awt/X11/MotifDnDConstants.java | 38 ++-- .../awt/X11/MotifDnDDragSourceProtocol.java | 32 ++-- .../awt/X11/MotifDnDDropTargetProtocol.java | 40 ++--- .../sun/awt/X11/WindowPropertyGetter.java | 6 +- .../classes/sun/awt/X11/XAWTXSettings.java | 4 +- .../solaris/classes/sun/awt/X11/XAtom.java | 22 +-- .../classes/sun/awt/X11/XBaseMenuWindow.java | 18 +- .../classes/sun/awt/X11/XBaseWindow.java | 166 +++++++++--------- .../classes/sun/awt/X11/XClipboard.java | 8 +- .../classes/sun/awt/X11/XComponentPeer.java | 24 +-- .../classes/sun/awt/X11/XConstants.java | 13 +- .../classes/sun/awt/X11/XContentWindow.java | 16 +- .../sun/awt/X11/XCursorFontConstants.java | 7 +- .../classes/sun/awt/X11/XCustomCursor.java | 6 +- .../classes/sun/awt/X11/XDecoratedPeer.java | 30 ++-- .../classes/sun/awt/X11/XDialogPeer.java | 16 +- .../sun/awt/X11/XDnDDragSourceProtocol.java | 38 ++-- .../sun/awt/X11/XDnDDropTargetProtocol.java | 70 ++++---- .../sun/awt/X11/XDragSourceContextPeer.java | 64 +++---- .../sun/awt/X11/XDragSourceProtocol.java | 8 +- .../awt/X11/XDropTargetEventProcessor.java | 8 +- .../sun/awt/X11/XDropTargetProtocol.java | 4 +- .../sun/awt/X11/XDropTargetRegistry.java | 22 +-- .../classes/sun/awt/X11/XEmbedCanvasPeer.java | 32 ++-- .../sun/awt/X11/XEmbedChildProxyPeer.java | 8 +- .../sun/awt/X11/XEmbedClientHelper.java | 6 +- .../classes/sun/awt/X11/XEmbedHelper.java | 6 +- .../sun/awt/X11/XEmbedServerTester.java | 8 +- .../sun/awt/X11/XEmbeddedFramePeer.java | 6 +- .../sun/awt/X11/XEmbeddingContainer.java | 6 +- .../sun/awt/X11/XFocusProxyWindow.java | 8 +- .../classes/sun/awt/X11/XFramePeer.java | 12 +- .../sun/awt/X11/XGlobalCursorManager.java | 30 ++-- .../classes/sun/awt/X11/XIconWindow.java | 12 +- .../classes/sun/awt/X11/XMSelection.java | 16 +- .../classes/sun/awt/X11/XNETProtocol.java | 8 +- .../classes/sun/awt/X11/XProtocol.java | 4 +- .../sun/awt/X11/XProtocolConstants.java | 7 +- .../classes/sun/awt/X11/XSelection.java | 46 ++--- .../classes/sun/awt/X11/XSystemTrayPeer.java | 6 +- .../solaris/classes/sun/awt/X11/XToolkit.java | 37 ++-- .../classes/sun/awt/X11/XTrayIconPeer.java | 8 +- .../classes/sun/awt/X11/XUtilConstants.java | 7 +- .../classes/sun/awt/X11/XWINProtocol.java | 10 +- jdk/src/solaris/classes/sun/awt/X11/XWM.java | 102 +++++------ .../solaris/classes/sun/awt/X11/XWindow.java | 80 ++++----- .../classes/sun/awt/X11/XWindowPeer.java | 50 +++--- .../solaris/classes/sun/awt/X11/XlibUtil.java | 8 +- .../classes/sun/awt/X11/XlibWrapper.java | 21 ++- 50 files changed, 611 insertions(+), 599 deletions(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11/MWMConstants.java b/jdk/src/solaris/classes/sun/awt/X11/MWMConstants.java index eceeee2622d..4be49190289 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/MWMConstants.java +++ b/jdk/src/solaris/classes/sun/awt/X11/MWMConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,9 @@ package sun.awt.X11; -public interface MWMConstants { +final public class MWMConstants { + + private MWMConstants(){} /* bit definitions for MwmHints.flags */ static final int MWM_HINTS_FUNCTIONS= (1 << 0); diff --git a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java index 9302361b04d..df4e857c6d4 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java +++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java @@ -118,11 +118,11 @@ class MotifDnDConstants { XA_MOTIF_DRAG_WINDOW, 0, 1, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && + if (status == XConstants.Success && wpg.getData() != 0 && wpg.getActualType() == XAtom.XA_WINDOW && wpg.getActualFormat() == 32 && @@ -163,20 +163,20 @@ class MotifDnDConstants { XlibWrapper.XGrabServer(newDisplay); try { - XlibWrapper.XSetCloseDownMode(newDisplay, (int)XlibWrapper.RetainPermanent); + XlibWrapper.XSetCloseDownMode(newDisplay, (int)XConstants.RetainPermanent); XSetWindowAttributes xwa = new XSetWindowAttributes(); try { xwa.set_override_redirect(true); - xwa.set_event_mask(XlibWrapper.PropertyChangeMask); + xwa.set_event_mask(XConstants.PropertyChangeMask); motifWindow = XlibWrapper.XCreateWindow(newDisplay, defaultRootWindow, -10, -10, 1, 1, 0, 0, - XlibWrapper.InputOnly, - XlibWrapper.CopyFromParent, - (XlibWrapper.CWOverrideRedirect | - XlibWrapper.CWEventMask), + XConstants.InputOnly, + XConstants.CopyFromParent, + (XConstants.CWOverrideRedirect | + XConstants.CWEventMask), xwa.pData); if (motifWindow == 0) { @@ -195,13 +195,13 @@ class MotifDnDConstants { defaultRootWindow, XA_MOTIF_DRAG_WINDOW.getAtom(), XAtom.XA_WINDOW, 32, - XlibWrapper.PropModeReplace, + XConstants.PropModeReplace, data, 1); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("Cannot write motif drag window handle."); } @@ -282,7 +282,7 @@ class MotifDnDConstants { try { int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success + if (status != XConstants.Success || wpg.getActualType() != XA_MOTIF_DRAG_TARGETS.getAtom() || wpg.getData() == 0) { @@ -399,13 +399,13 @@ class MotifDnDConstants { motifWindow, XA_MOTIF_DRAG_TARGETS.getAtom(), XA_MOTIF_DRAG_TARGETS.getAtom(), 8, - XlibWrapper.PropModeReplace, + XConstants.PropModeReplace, data, tableSize); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { // Create a new motif window and retry. motifWindow = createMotifWindow(); @@ -415,13 +415,13 @@ class MotifDnDConstants { motifWindow, XA_MOTIF_DRAG_TARGETS.getAtom(), XA_MOTIF_DRAG_TARGETS.getAtom(), 8, - XlibWrapper.PropModeReplace, + XConstants.PropModeReplace, data, tableSize); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("Cannot write motif drag targets property."); } } @@ -538,12 +538,12 @@ class MotifDnDConstants { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, XA_MOTIF_ATOM_0.getAtom(), XA_MOTIF_DRAG_INITIATOR_INFO.getAtom(), - 8, XlibWrapper.PropModeReplace, + 8, XConstants.PropModeReplace, structData, MOTIF_INITIATOR_INFO_SIZE); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("Cannot write drag initiator info"); } } finally { @@ -571,12 +571,12 @@ class MotifDnDConstants { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), - 8, XlibWrapper.PropModeReplace, + 8, XConstants.PropModeReplace, data, dataSize); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("Cannot write Motif receiver info property"); } } finally { diff --git a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java index a2c07ad226d..b7e534c773f 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol private static final Unsafe unsafe = XlibWrapper.unsafe; - private long targetEnterServerTime = XlibWrapper.CurrentTime; + private long targetEnterServerTime = XConstants.CurrentTime; protected MotifDnDDragSourceProtocol(XDragSourceProtocolListener listener) { super(listener); @@ -86,7 +86,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol if (!MotifDnDConstants.MotifDnDSelection.setOwner(contents, formatMap, formats, - XlibWrapper.CurrentTime)) { + XConstants.CurrentTime)) { cleanup(); throw new InvalidDnDOperationException("Cannot acquire selection ownership"); } @@ -137,7 +137,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol long time = t; /* Discard events from the previous receiver. */ - if (targetEnterServerTime == XlibWrapper.CurrentTime || + if (targetEnterServerTime == XConstants.CurrentTime || time < targetEnterServerTime) { return true; } @@ -181,7 +181,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol new WindowPropertyGetter(window, MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO, 0, 0xFFFF, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); @@ -200,7 +200,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol * CARD32 heap_offset B32; * } xmDragReceiverInfoStruct; */ - if (status == (int)XlibWrapper.Success && wpg.getData() != 0 && + if (status == (int)XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { @@ -243,7 +243,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type(XlibWrapper.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(8); msg.set_message_type(MotifDnDConstants.XA_MOTIF_DRAG_AND_DROP_MESSAGE.getAtom()); @@ -267,7 +267,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol XlibWrapper.XSendEvent(XToolkit.getDisplay(), getTargetProxyWindow(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { msg.dispose(); @@ -281,7 +281,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type(XlibWrapper.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(8); msg.set_message_type(MotifDnDConstants.XA_MOTIF_DRAG_AND_DROP_MESSAGE.getAtom()); @@ -305,7 +305,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol XlibWrapper.XSendEvent(XToolkit.getDisplay(), getTargetProxyWindow(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { msg.dispose(); @@ -318,7 +318,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type(XlibWrapper.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(8); msg.set_message_type(MotifDnDConstants.XA_MOTIF_DRAG_AND_DROP_MESSAGE.getAtom()); @@ -336,7 +336,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol XlibWrapper.XSendEvent(XToolkit.getDisplay(), getTargetProxyWindow(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { msg.dispose(); @@ -356,7 +356,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type(XlibWrapper.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(8); msg.set_message_type(MotifDnDConstants.XA_MOTIF_DRAG_AND_DROP_MESSAGE.getAtom()); @@ -382,7 +382,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol XlibWrapper.XSendEvent(XToolkit.getDisplay(), getTargetProxyWindow(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { msg.dispose(); @@ -397,12 +397,12 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol public void cleanupTargetInfo() { super.cleanupTargetInfo(); - targetEnterServerTime = XlibWrapper.CurrentTime; + targetEnterServerTime = XConstants.CurrentTime; } public void dispatchEvent(XEvent ev) { switch (ev.get_type()) { - case XlibWrapper.SelectionRequest: + case XConstants.SelectionRequest: XSelectionRequestEvent xsre = ev.get_xselectionrequest(); long atom = xsre.get_selection(); diff --git a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java index df348594fc5..383c21ec1ea 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java @@ -99,7 +99,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { new WindowPropertyGetter(embedder, MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO, 0, 0xFFFF, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { status = wpg.execute(XToolkit.IgnoreBadWindowHandler); @@ -118,7 +118,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { * CARD32 heap_offset B32; * } xmDragReceiverInfoStruct; */ - if (status == (int)XlibWrapper.Success && wpg.getData() != 0 && + if (status == (int)XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { @@ -166,12 +166,12 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder, MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), - 8, XlibWrapper.PropModeReplace, + 8, XConstants.PropModeReplace, data, dataSize); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("Cannot write Motif receiver info property"); } } finally { @@ -201,7 +201,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { new WindowPropertyGetter(embedder, MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO, 0, 0xFFFF, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { status = wpg.execute(XToolkit.IgnoreBadWindowHandler); @@ -220,7 +220,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { * CARD32 heap_offset B32; * } xmDragReceiverInfoStruct; */ - if (status == (int)XlibWrapper.Success && wpg.getData() != 0 && + if (status == (int)XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { @@ -240,12 +240,12 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder, MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(), - 8, XlibWrapper.PropModeReplace, + 8, XConstants.PropModeReplace, data, dataSize); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("Cannot write Motif receiver info property"); } } @@ -273,7 +273,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { new WindowPropertyGetter(embedded, MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO, 0, 0xFFFF, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { status = wpg.execute(XToolkit.IgnoreBadWindowHandler); @@ -292,7 +292,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { * CARD32 heap_offset B32; * } xmDragReceiverInfoStruct; */ - if (status == (int)XlibWrapper.Success && wpg.getData() != 0 && + if (status == (int)XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { @@ -322,12 +322,12 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { new WindowPropertyGetter(window, MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO, 0, 0xFFFF, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); - if (status == (int)XlibWrapper.Success && wpg.getData() != 0 && + if (status == (int)XConstants.Success && wpg.getData() != 0 && wpg.getActualType() != 0 && wpg.getActualFormat() == 8 && wpg.getNumberOfItems() >= MotifDnDConstants.MOTIF_RECEIVER_INFO_SIZE) { @@ -377,7 +377,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { try { int status = wpg.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && wpg.getData() != 0 && + if (status == XConstants.Success && wpg.getData() != 0 && wpg.getActualType() == MotifDnDConstants.XA_MOTIF_DRAG_INITIATOR_INFO.getAtom() && wpg.getActualFormat() == 8 && @@ -420,7 +420,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { if (status == 0 || (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success)) { + XToolkit.saved_error.get_error_code() != XConstants.Success)) { throw new XException("XGetWindowAttributes failed"); } @@ -432,12 +432,12 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win, source_win_mask | - XlibWrapper.StructureNotifyMask); + XConstants.StructureNotifyMask); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("XSelectInput failed"); } @@ -590,7 +590,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { XClientMessageEvent dummy = new XClientMessageEvent(); try { - dummy.set_type(XlibWrapper.ClientMessage); + dummy.set_type(XConstants.ClientMessage); dummy.set_window(xclient.get_window()); dummy.set_format(32); dummy.set_message_type(0); @@ -600,7 +600,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { dummy.set_data(3, 0); dummy.set_data(4, 0); XlibWrapper.XSendEvent(XToolkit.getDisplay(), - proxy, false, XlibWrapper.NoEventMask, + proxy, false, XConstants.NoEventMask, dummy.pData); } finally { dummy.dispose(); @@ -821,7 +821,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type(XlibWrapper.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_window(MotifDnDConstants.Swapper.getInt(data + 12, eventByteOrder)); msg.set_format(8); msg.set_message_type(MotifDnDConstants.XA_MOTIF_DRAG_AND_DROP_MESSAGE.getAtom()); @@ -878,7 +878,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { try { XlibWrapper.XSendEvent(XToolkit.getDisplay(), msg.get_window(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { XToolkit.awtUnlock(); diff --git a/jdk/src/solaris/classes/sun/awt/X11/WindowPropertyGetter.java b/jdk/src/solaris/classes/sun/awt/X11/WindowPropertyGetter.java index ba5f3837bd7..6926f8c8271 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/WindowPropertyGetter.java +++ b/jdk/src/solaris/classes/sun/awt/X11/WindowPropertyGetter.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,7 +89,7 @@ public class WindowPropertyGetter { if (isCachingSupported() && isCached()) { readFromCache(); - return XlibWrapper.Success; + return XConstants.Success; } // Fix for performance problem - IgnodeBadWindowHandler is @@ -106,7 +106,7 @@ public class WindowPropertyGetter { offset, length, (auto_delete?1:0), type, actual_type, actual_format, nitems_ptr, bytes_after, data); - if (isCachingSupported() && status == XlibWrapper.Success && getData() != 0 && isCacheableProperty(property)) { + if (isCachingSupported() && status == XConstants.Success && getData() != 0 && isCacheableProperty(property)) { // Property has some data, we cache them cacheProperty(); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java b/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java index 2db97c44a95..6727912c9a7 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -128,7 +128,7 @@ class XAWTXSettings extends XSettings implements XMSelectionListener { try { int status = getter.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { if (log.isLoggable(Level.FINE)) log.fine("OH OH : getter failed status = " + status ); settings = null; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XAtom.java b/jdk/src/solaris/classes/sun/awt/X11/XAtom.java index b72e790a043..335917abf79 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XAtom.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XAtom.java @@ -370,7 +370,7 @@ public final class XAtom { false, property_type); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { return 0; } if (getter.getActualType() != property_type || getter.getActualFormat() != 32) { @@ -401,7 +401,7 @@ public final class XAtom { try { Native.putCard32(XlibWrapper.larg1, value); XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, - atom, XA_CARDINAL, 32, XlibWrapper.PropModeReplace, + atom, XA_CARDINAL, 32, XConstants.PropModeReplace, XlibWrapper.larg1, 1); } finally { XToolkit.awtUnlock(); @@ -432,7 +432,7 @@ public final class XAtom { false, this); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { return false; } if (getter.getActualType() != atom @@ -466,7 +466,7 @@ public final class XAtom { false, type); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { return false; } if (getter.getActualType() != type @@ -497,7 +497,7 @@ public final class XAtom { XToolkit.awtLock(); try { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, - atom, atom, 32, XlibWrapper.PropModeReplace, + atom, atom, 32, XConstants.PropModeReplace, data_ptr, length); } finally { XToolkit.awtUnlock(); @@ -518,7 +518,7 @@ public final class XAtom { XToolkit.awtLock(); try { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, - atom, type, 32, XlibWrapper.PropModeReplace, + atom, type, 32, XConstants.PropModeReplace, data_ptr, length); } finally { XToolkit.awtUnlock(); @@ -539,7 +539,7 @@ public final class XAtom { XToolkit.awtLock(); try { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, - atom, type, 8, XlibWrapper.PropModeReplace, + atom, type, 8, XConstants.PropModeReplace, data_ptr, length); } finally { XToolkit.awtUnlock(); @@ -602,7 +602,7 @@ public final class XAtom { false, property_type); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { return null; } if (getter.getActualType() != property_type || getter.getActualFormat() != 8) { @@ -674,7 +674,7 @@ public final class XAtom { false, XA_ATOM); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { return emptyList; } if (getter.getActualType() != XA_ATOM || getter.getActualFormat() != 32) { @@ -797,7 +797,7 @@ public final class XAtom { try { Native.putWindow(XlibWrapper.larg1, window_value); XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window, - atom, XA_WINDOW, 32, XlibWrapper.PropModeReplace, + atom, XA_WINDOW, 32, XConstants.PropModeReplace, XlibWrapper.larg1, 1); } finally { XToolkit.awtUnlock(); @@ -821,7 +821,7 @@ public final class XAtom { false, XA_WINDOW); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { return 0; } if (getter.getActualType() != XA_WINDOW || getter.getActualFormat() != 32) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java index cb241c121b6..1655be61ece 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -885,14 +885,14 @@ abstract public class XBaseMenuWindow extends XWindow { */ protected boolean isEventDisabled(XEvent e) { switch (e.get_type()) { - case XlibWrapper.Expose : - case XlibWrapper.GraphicsExpose : - case XlibWrapper.ButtonPress: - case XlibWrapper.ButtonRelease: - case XlibWrapper.MotionNotify: - case XlibWrapper.KeyPress: - case XlibWrapper.KeyRelease: - case XlibWrapper.DestroyNotify: + case XConstants.Expose : + case XConstants.GraphicsExpose : + case XConstants.ButtonPress: + case XConstants.ButtonRelease: + case XConstants.MotionNotify: + case XConstants.KeyPress: + case XConstants.KeyRelease: + case XConstants.DestroyNotify: return super.isEventDisabled(e); default: return true; diff --git a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java index cdac58a1240..f853d506784 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ import sun.awt.*; import java.util.logging.*; import java.util.*; -public class XBaseWindow implements XConstants, XUtilConstants { +public class XBaseWindow { private static final Logger log = Logger.getLogger("sun.awt.X11.XBaseWindow"); private static final Logger insLog = Logger.getLogger("sun.awt.X11.insets.XBaseWindow"); private static final Logger eventLog = Logger.getLogger("sun.awt.X11.event.XBaseWindow"); @@ -148,7 +148,7 @@ public class XBaseWindow implements XConstants, XUtilConstants { Long eventMask = (Long)params.get(EVENT_MASK); if (eventMask != null) { long mask = eventMask.longValue(); - mask |= SubstructureNotifyMask; + mask |= XConstants.SubstructureNotifyMask; params.put(EVENT_MASK, mask); } @@ -281,10 +281,10 @@ public class XBaseWindow implements XConstants, XUtilConstants { } params.putIfNull(PARENT_WINDOW, Long.valueOf(XToolkit.getDefaultRootWindow())); params.putIfNull(BOUNDS, new Rectangle(DEF_LOCATION, DEF_LOCATION, MIN_SIZE, MIN_SIZE)); - params.putIfNull(DEPTH, Integer.valueOf((int)XlibWrapper.CopyFromParent)); - params.putIfNull(VISUAL, Long.valueOf(XlibWrapper.CopyFromParent)); - params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XlibWrapper.InputOnly)); - params.putIfNull(VALUE_MASK, Long.valueOf(XlibWrapper.CWEventMask)); + params.putIfNull(DEPTH, Integer.valueOf((int)XConstants.CopyFromParent)); + params.putIfNull(VISUAL, Long.valueOf(XConstants.CopyFromParent)); + params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOnly)); + params.putIfNull(VALUE_MASK, Long.valueOf(XConstants.CWEventMask)); Rectangle bounds = (Rectangle)params.get(BOUNDS); bounds.width = Math.max(MIN_SIZE, bounds.width); bounds.height = Math.max(MIN_SIZE, bounds.height); @@ -293,7 +293,7 @@ public class XBaseWindow implements XConstants, XUtilConstants { long eventMask = eventMaskObj != null ? eventMaskObj.longValue() : 0; // We use our own synthetic grab see XAwtState.getGrabWindow() // (see X vol. 1, 8.3.3.2) - eventMask |= PropertyChangeMask | OwnerGrabButtonMask; + eventMask |= XConstants.PropertyChangeMask | XConstants.OwnerGrabButtonMask; params.put(EVENT_MASK, Long.valueOf(eventMask)); } @@ -312,23 +312,23 @@ public class XBaseWindow implements XConstants, XUtilConstants { Long eventMask = (Long)params.get(EVENT_MASK); xattr.set_event_mask(eventMask.longValue()); - value_mask |= XlibWrapper.CWEventMask; + value_mask |= XConstants.CWEventMask; Long border_pixel = (Long)params.get(BORDER_PIXEL); if (border_pixel != null) { xattr.set_border_pixel(border_pixel.longValue()); - value_mask |= XlibWrapper.CWBorderPixel; + value_mask |= XConstants.CWBorderPixel; } Long colormap = (Long)params.get(COLORMAP); if (colormap != null) { xattr.set_colormap(colormap.longValue()); - value_mask |= XlibWrapper.CWColormap; + value_mask |= XConstants.CWColormap; } Long background_pixmap = (Long)params.get(BACKGROUND_PIXMAP); if (background_pixmap != null) { xattr.set_background_pixmap(background_pixmap.longValue()); - value_mask |= XlibWrapper.CWBackPixmap; + value_mask |= XConstants.CWBackPixmap; } Long parentWindow = (Long)params.get(PARENT_WINDOW); @@ -339,25 +339,25 @@ public class XBaseWindow implements XConstants, XUtilConstants { Boolean overrideRedirect = (Boolean)params.get(OVERRIDE_REDIRECT); if (overrideRedirect != null) { xattr.set_override_redirect(overrideRedirect.booleanValue()); - value_mask |= XlibWrapper.CWOverrideRedirect; + value_mask |= XConstants.CWOverrideRedirect; } Boolean saveUnder = (Boolean)params.get(SAVE_UNDER); if (saveUnder != null) { xattr.set_save_under(saveUnder.booleanValue()); - value_mask |= XlibWrapper.CWSaveUnder; + value_mask |= XConstants.CWSaveUnder; } Integer backingStore = (Integer)params.get(BACKING_STORE); if (backingStore != null) { xattr.set_backing_store(backingStore.intValue()); - value_mask |= XlibWrapper.CWBackingStore; + value_mask |= XConstants.CWBackingStore; } Integer bitGravity = (Integer)params.get(BIT_GRAVITY); if (bitGravity != null) { xattr.set_bit_gravity(bitGravity.intValue()); - value_mask |= XlibWrapper.CWBitGravity; + value_mask |= XConstants.CWBitGravity; } if (log.isLoggable(Level.FINE)) { @@ -487,25 +487,25 @@ public class XBaseWindow implements XConstants, XUtilConstants { // Note: if PPosition is not set in flags this means that // we want to reset PPosition in hints. This is necessary // for locationByPlatform functionality - if ((flags & XlibWrapper.PPosition) != 0) { + if ((flags & XUtilConstants.PPosition) != 0) { hints.set_x(x); hints.set_y(y); } - if ((flags & XlibWrapper.PSize) != 0) { + if ((flags & XUtilConstants.PSize) != 0) { hints.set_width(width); hints.set_height(height); - } else if ((hints.get_flags() & XlibWrapper.PSize) != 0) { - flags |= XlibWrapper.PSize; + } else if ((hints.get_flags() & XUtilConstants.PSize) != 0) { + flags |= XUtilConstants.PSize; } - if ((flags & XlibWrapper.PMinSize) != 0) { + if ((flags & XUtilConstants.PMinSize) != 0) { hints.set_min_width(width); hints.set_min_height(height); - } else if ((hints.get_flags() & XlibWrapper.PMinSize) != 0) { - flags |= XlibWrapper.PMinSize; + } else if ((hints.get_flags() & XUtilConstants.PMinSize) != 0) { + flags |= XUtilConstants.PMinSize; //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced. //We don't need to reset minimum size if it's already set } - if ((flags & XlibWrapper.PMaxSize) != 0) { + if ((flags & XUtilConstants.PMaxSize) != 0) { if (maxBounds != null) { if (maxBounds.width != Integer.MAX_VALUE) { hints.set_max_width(maxBounds.width); @@ -521,8 +521,8 @@ public class XBaseWindow implements XConstants, XUtilConstants { hints.set_max_width(width); hints.set_max_height(height); } - } else if ((hints.get_flags() & XlibWrapper.PMaxSize) != 0) { - flags |= XlibWrapper.PMaxSize; + } else if ((hints.get_flags() & XUtilConstants.PMaxSize) != 0) { + flags |= XUtilConstants.PMaxSize; if (maxBounds != null) { if (maxBounds.width != Integer.MAX_VALUE) { hints.set_max_width(maxBounds.width); @@ -538,9 +538,9 @@ public class XBaseWindow implements XConstants, XUtilConstants { // Leave intact } } - flags |= XlibWrapper.PWinGravity; + flags |= XUtilConstants.PWinGravity; hints.set_flags(flags); - hints.set_win_gravity((int)XlibWrapper.NorthWestGravity); + hints.set_win_gravity((int)XConstants.NorthWestGravity); if (insLog.isLoggable(Level.FINER)) insLog.finer("Setting hints, resulted flags " + XlibWrapper.hintsToString(flags) + ", values " + hints); XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), getWindow(), hints.pData); @@ -552,7 +552,7 @@ public class XBaseWindow implements XConstants, XUtilConstants { public boolean isMinSizeSet() { XSizeHints hints = getHints(); long flags = hints.get_flags(); - return ((flags & XlibWrapper.PMinSize) == XlibWrapper.PMinSize); + return ((flags & XUtilConstants.PMinSize) == XUtilConstants.PMinSize); } /** @@ -837,29 +837,29 @@ public class XBaseWindow implements XConstants, XUtilConstants { //6273031: PIT. Choice drop down does not close once it is right clicked to show a popup menu //remember previous window having grab and if it's not null ungrab it. XBaseWindow prevGrabWindow = XAwtState.getGrabWindow(); - final int eventMask = (int) (ButtonPressMask | ButtonReleaseMask - | EnterWindowMask | LeaveWindowMask | PointerMotionMask - | ButtonMotionMask); + final int eventMask = (int) (XConstants.ButtonPressMask | XConstants.ButtonReleaseMask + | XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask + | XConstants.ButtonMotionMask); final int ownerEvents = 1; int ptrGrab = XlibWrapper.XGrabPointer(XToolkit.getDisplay(), - getContentWindow(), ownerEvents, eventMask, GrabModeAsync, - GrabModeAsync, None, (XWM.isMotif() ? XToolkit.arrowCursor : None), - CurrentTime); + getContentWindow(), ownerEvents, eventMask, XConstants.GrabModeAsync, + XConstants.GrabModeAsync, XConstants.None, (XWM.isMotif() ? XToolkit.arrowCursor : XConstants.None), + XConstants.CurrentTime); // Check grab results to be consistent with X server grab - if (ptrGrab != GrabSuccess) { - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); + if (ptrGrab != XConstants.GrabSuccess) { + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); XAwtState.setGrabWindow(null); grabLog.fine(" Grab Failure - mouse"); return false; } int keyGrab = XlibWrapper.XGrabKeyboard(XToolkit.getDisplay(), - getContentWindow(), ownerEvents, GrabModeAsync, GrabModeAsync, - CurrentTime); - if (keyGrab != GrabSuccess) { - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); - XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), CurrentTime); + getContentWindow(), ownerEvents, XConstants.GrabModeAsync, XConstants.GrabModeAsync, + XConstants.CurrentTime); + if (keyGrab != XConstants.GrabSuccess) { + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); + XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime); XAwtState.setGrabWindow(null); grabLog.fine(" Grab Failure - keyboard"); return false; @@ -882,8 +882,8 @@ public class XBaseWindow implements XConstants, XUtilConstants { grabLog.log(Level.FINE, "UnGrab input on {0}", new Object[] {grabWindow}); if (grabWindow != null) { grabWindow.ungrabInputImpl(); - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); - XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), CurrentTime); + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); + XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime); XAwtState.setGrabWindow(null); // we need to call XFlush() here to force ungrab // see 6384219 for details @@ -979,15 +979,15 @@ public class XBaseWindow implements XConstants, XUtilConstants { */ public void handleButtonPressRelease(XEvent xev) { XButtonEvent xbe = xev.get_xbutton(); - final int buttonState = xbe.get_state() & (Button1Mask | Button2Mask - | Button3Mask | Button4Mask | Button5Mask); + final int buttonState = xbe.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask + | XConstants.Button3Mask | XConstants.Button4Mask | XConstants.Button5Mask); switch (xev.get_type()) { - case ButtonPress: + case XConstants.ButtonPress: if (buttonState == 0) { XAwtState.setAutoGrabWindow(this); } break; - case ButtonRelease: + case XConstants.ButtonRelease: if (isFullRelease(buttonState, xbe.get_button())) { XAwtState.setAutoGrabWindow(null); } @@ -1012,30 +1012,30 @@ public class XBaseWindow implements XConstants, XUtilConstants { */ static boolean isFullRelease(int buttonState, int button) { switch (button) { - case Button1: - return buttonState == Button1Mask; - case Button2: - return buttonState == Button2Mask; - case Button3: - return buttonState == Button3Mask; - case Button4: - return buttonState == Button4Mask; - case Button5: - return buttonState == Button5Mask; + case XConstants.Button1: + return buttonState == XConstants.Button1Mask; + case XConstants.Button2: + return buttonState == XConstants.Button2Mask; + case XConstants.Button3: + return buttonState == XConstants.Button3Mask; + case XConstants.Button4: + return buttonState == XConstants.Button4Mask; + case XConstants.Button5: + return buttonState == XConstants.Button5Mask; } return buttonState == 0; } static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) { switch (ev.get_type()) { - case ButtonPress: - case ButtonRelease: - case MotionNotify: - case KeyPress: - case KeyRelease: + case XConstants.ButtonPress: + case XConstants.ButtonRelease: + case XConstants.MotionNotify: + case XConstants.KeyPress: + case XConstants.KeyRelease: return true; - case LeaveNotify: - case EnterNotify: + case XConstants.LeaveNotify: + case XConstants.EnterNotify: // We shouldn't dispatch this events to the grabbed components (see 6317481) // But this logic is important if the grabbed component is top-level (see realSync) return (target instanceof XWindowPeer); @@ -1067,53 +1067,53 @@ public class XBaseWindow implements XConstants, XUtilConstants { switch (type) { - case VisibilityNotify: + case XConstants.VisibilityNotify: handleVisibilityEvent(xev); break; - case ClientMessage: + case XConstants.ClientMessage: handleClientMessage(xev); break; - case Expose : - case GraphicsExpose : + case XConstants.Expose : + case XConstants.GraphicsExpose : handleExposeEvent(xev); break; - case ButtonPress: - case ButtonRelease: + case XConstants.ButtonPress: + case XConstants.ButtonRelease: handleButtonPressRelease(xev); break; - case MotionNotify: + case XConstants.MotionNotify: handleMotionNotify(xev); break; - case KeyPress: + case XConstants.KeyPress: handleKeyPress(xev); break; - case KeyRelease: + case XConstants.KeyRelease: handleKeyRelease(xev); break; - case EnterNotify: - case LeaveNotify: + case XConstants.EnterNotify: + case XConstants.LeaveNotify: handleXCrossingEvent(xev); break; - case ConfigureNotify: + case XConstants.ConfigureNotify: handleConfigureNotifyEvent(xev); break; - case MapNotify: + case XConstants.MapNotify: handleMapNotifyEvent(xev); break; - case UnmapNotify: + case XConstants.UnmapNotify: handleUnmapNotifyEvent(xev); break; - case ReparentNotify: + case XConstants.ReparentNotify: handleReparentNotifyEvent(xev); break; - case PropertyNotify: + case XConstants.PropertyNotify: handlePropertyNotify(xev); break; - case DestroyNotify: + case XConstants.DestroyNotify: handleDestroyNotify(xev); break; - case CreateNotify: + case XConstants.CreateNotify: handleCreateNotify(xev); break; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java b/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java index 138e11d9a8c..f6009e79c12 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java @@ -185,7 +185,7 @@ public final class XClipboard extends SunClipboard implements OwnershipListener private static class SelectionNotifyHandler implements XEventDispatcher { public void dispatchEvent(XEvent ev) { - if (ev.get_type() == XlibWrapper.SelectionNotify) { + if (ev.get_type() == XConstants.SelectionNotify) { final XSelectionEvent xse = ev.get_xselection(); XClipboard clipboard = null; synchronized (XClipboard.classLock) { @@ -223,7 +223,7 @@ public final class XClipboard extends SunClipboard implements OwnershipListener XDataTransferer.TARGETS_ATOM.getAtom(), getTargetsPropertyAtom().getAtom(), XWindow.getXAWTRootWindow().getWindow(), - XlibWrapper.CurrentTime); + XConstants.CurrentTime); isSelectionNotifyProcessed = false; } } finally { @@ -260,7 +260,7 @@ public final class XClipboard extends SunClipboard implements OwnershipListener long[] formats = null; - if (propertyAtom == XlibWrapper.None) { + if (propertyAtom == XConstants.None) { // We treat None property atom as "empty selection". formats = new long[0]; } else { @@ -268,7 +268,7 @@ public final class XClipboard extends SunClipboard implements OwnershipListener new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(), XAtom.get(propertyAtom), 0, XSelection.MAX_LENGTH, true, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { targetsGetter.execute(); formats = XSelection.getFormats(targetsGetter); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java index fb687e36830..8e9c930889f 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java @@ -72,7 +72,7 @@ import sun.awt.image.SunVolatileImage; import sun.awt.image.ToolkitImage; import sun.java2d.pipe.Region; -public class XComponentPeer extends XWindow implements ComponentPeer, DropTargetPeer, XConstants { +public class XComponentPeer extends XWindow implements ComponentPeer, DropTargetPeer { /* FIX ME: these constants copied from java.awt.KeyboardFocusManager */ static final int SNFH_FAILURE = 0; static final int SNFH_SUCCESS_HANDLED = 1; @@ -718,7 +718,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget * handleJavaMouseEvent() would be more suitable place to do this * but we want Swing to have this functionality also. */ - if (xev.get_type() == ButtonPress) { + if (xev.get_type() == XConstants.ButtonPress) { final XWindowPeer parentXWindow = getParentTopLevel(); Window parentWindow = (Window)parentXWindow.getTarget(); if (parentXWindow.isFocusableWindow() && parentXWindow.isSimpleWindow() && @@ -841,7 +841,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget XSetWindowAttributes xwa = new XSetWindowAttributes(); xwa.set_cursor(xcursor); - long valuemask = XlibWrapper.CWCursor; + long valuemask = XConstants.CWCursor; XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),getWindow(),valuemask,xwa.pData); XlibWrapper.XFlush(XToolkit.getDisplay()); @@ -1342,20 +1342,20 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget enableLog.log(Level.FINEST, "Component is {1}, checking for disabled event {0}", new Object[] {e, (isEnabled()?"enabled":"disable")}); if (!isEnabled()) { switch (e.get_type()) { - case ButtonPress: - case ButtonRelease: - case KeyPress: - case KeyRelease: - case EnterNotify: - case LeaveNotify: - case MotionNotify: + case XConstants.ButtonPress: + case XConstants.ButtonRelease: + case XConstants.KeyPress: + case XConstants.KeyRelease: + case XConstants.EnterNotify: + case XConstants.LeaveNotify: + case XConstants.MotionNotify: enableLog.log(Level.FINER, "Event {0} is disable", new Object[] {e}); return true; } } switch(e.get_type()) { - case MapNotify: - case UnmapNotify: + case XConstants.MapNotify: + case XConstants.UnmapNotify: return true; } return super.isEventDisabled(e); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XConstants.java b/jdk/src/solaris/classes/sun/awt/X11/XConstants.java index 4c75f03fd34..e9de6804bea 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XConstants.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,10 @@ package sun.awt.X11; -public interface XConstants { +final public class XConstants { + + private XConstants(){} + public static final int X_PROTOCOL = 11 ; /* current protocol version */ public static final int X_PROTOCOL_REVISION = 0 ; /* current minor version */ @@ -292,9 +295,9 @@ public interface XConstants { public static final int RevertToParent = 2 ; /* Used in XEventsQueued */ - int QueuedAlready = 0; - int QueuedAfterReading = 1; - int QueuedAfterFlush = 2; + public static final int QueuedAlready = 0; + public static final int QueuedAfterReading = 1; + public static final int QueuedAfterFlush = 2; /***************************************************************** diff --git a/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java index 268f7f5d151..6a32fe9bdc3 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java @@ -43,7 +43,7 @@ import sun.awt.ComponentAccessor; * It should always be located at (- left inset, - top inset) in the associated * decorated window. So coordinates in it would be the same as java coordinates. */ -public final class XContentWindow extends XWindow implements XConstants { +public final class XContentWindow extends XWindow { private static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XContentWindow"); static XContentWindow createContent(XDecoratedPeer parentFrame) { @@ -76,10 +76,10 @@ public final class XContentWindow extends XWindow implements XConstants { void preInit(XCreateWindowParams params) { super.preInit(params); - params.putIfNull(BIT_GRAVITY, Integer.valueOf(NorthWestGravity)); + params.putIfNull(BIT_GRAVITY, Integer.valueOf(XConstants.NorthWestGravity)); Long eventMask = (Long)params.get(EVENT_MASK); if (eventMask != null) { - eventMask = eventMask & ~(StructureNotifyMask); + eventMask = eventMask & ~(XConstants.StructureNotifyMask); params.put(EVENT_MASK, eventMask); } } @@ -90,15 +90,15 @@ public final class XContentWindow extends XWindow implements XConstants { protected boolean isEventDisabled(XEvent e) { switch (e.get_type()) { // Override parentFrame to receive MouseEnter/Exit - case EnterNotify: - case LeaveNotify: + case XConstants.EnterNotify: + case XConstants.LeaveNotify: return false; // We handle ConfigureNotify specifically in XDecoratedPeer - case ConfigureNotify: + case XConstants.ConfigureNotify: return true; // We don't want SHOWN/HIDDEN on content window since it will duplicate XDecoratedPeer - case MapNotify: - case UnmapNotify: + case XConstants.MapNotify: + case XConstants.UnmapNotify: return true; default: return super.isEventDisabled(e) || parentFrame.isEventDisabled(e); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XCursorFontConstants.java b/jdk/src/solaris/classes/sun/awt/X11/XCursorFontConstants.java index d57041523ca..baf33ab3b15 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XCursorFontConstants.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XCursorFontConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,10 @@ package sun.awt.X11; -public interface XCursorFontConstants { +final public class XCursorFontConstants { + + private XCursorFontConstants(){} + /* cursorfont defines */ static final int XC_num_glyphs=154; static final int XC_X_cursor=0; diff --git a/jdk/src/solaris/classes/sun/awt/X11/XCustomCursor.java b/jdk/src/solaris/classes/sun/awt/X11/XCustomCursor.java index 32f269595b0..d308ffd774c 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XCustomCursor.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XCustomCursor.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,7 @@ public class XCustomCursor extends X11CustomCursor { long colormap = XToolkit.getDefaultXColormap(); XColor fore_color = new XColor(); - fore_color.set_flags((byte) (XlibWrapper.DoRed | XlibWrapper.DoGreen | XlibWrapper.DoBlue)); + fore_color.set_flags((byte) (XConstants.DoRed | XConstants.DoGreen | XConstants.DoBlue)); fore_color.set_red((short)(((fcolor >> 16) & 0x000000ff) << 8)); fore_color.set_green((short) (((fcolor >> 8) & 0x000000ff) << 8)); fore_color.set_blue((short)(((fcolor >> 0) & 0x000000ff) << 8)); @@ -92,7 +92,7 @@ public class XCustomCursor extends X11CustomCursor { XColor back_color = new XColor(); - back_color.set_flags((byte) (XlibWrapper.DoRed | XlibWrapper.DoGreen | XlibWrapper.DoBlue)); + back_color.set_flags((byte) (XConstants.DoRed | XConstants.DoGreen | XConstants.DoBlue)); back_color.set_red((short) (((bcolor >> 16) & 0x000000ff) << 8)); back_color.set_green((short) (((bcolor >> 8) & 0x000000ff) << 8)); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java index a930dfb2be8..aea3baac72b 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,7 +89,7 @@ abstract class XDecoratedPeer extends XWindowPeer { // Deny default processing of these events on the shell - proxy will take care of // them instead Long eventMask = (Long)params.get(EVENT_MASK); - params.add(EVENT_MASK, Long.valueOf(eventMask.longValue() & ~(FocusChangeMask | KeyPressMask | KeyReleaseMask))); + params.add(EVENT_MASK, Long.valueOf(eventMask.longValue() & ~(XConstants.FocusChangeMask | XConstants.KeyPressMask | XConstants.KeyReleaseMask))); } void postInit(XCreateWindowParams params) { @@ -131,7 +131,7 @@ abstract class XDecoratedPeer extends XWindowPeer { int minHeight = minimumSize.height - insets.top - insets.bottom; if (minWidth < 0) minWidth = 0; if (minHeight < 0) minHeight = 0; - setSizeHints(XlibWrapper.PMinSize | (isLocationByPlatform()?0:(XlibWrapper.PPosition | XlibWrapper.USPosition)), + setSizeHints(XUtilConstants.PMinSize | (isLocationByPlatform()?0:(XUtilConstants.PPosition | XUtilConstants.USPosition)), getX(), getY(), minWidth, minHeight); if (isVisible()) { Rectangle bounds = getShellBounds(); @@ -143,7 +143,7 @@ abstract class XDecoratedPeer extends XWindowPeer { } } else { boolean isMinSizeSet = isMinSizeSet(); - XWM.removeSizeHints(this, XlibWrapper.PMinSize); + XWM.removeSizeHints(this, XUtilConstants.PMinSize); /* Some WMs need remap to redecorate the window */ if (isMinSizeSet && isShowing() && XWM.needRemap(this)) { /* @@ -365,7 +365,7 @@ abstract class XDecoratedPeer extends XWindowPeer { return; } - if ((getHints().get_flags() & (USPosition | PPosition)) != 0) { + if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) { reshape(dimensions, SET_BOUNDS, false); } else { reshape(dimensions, SET_SIZE, false); @@ -841,10 +841,10 @@ abstract class XDecoratedPeer extends XWindowPeer { setReparented(false); } winAttr.isResizable = resizable; - if ((fs & MWM_FUNC_ALL) != 0) { - fs &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); + if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { + fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); } else { - fs |= (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); + fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); } winAttr.functions = fs; XWM.setShellResizable(this); @@ -855,10 +855,10 @@ abstract class XDecoratedPeer extends XWindowPeer { setReparented(false); } winAttr.isResizable = resizable; - if ((fs & MWM_FUNC_ALL) != 0) { - fs |= (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); + if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { + fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); } else { - fs &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); + fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); } winAttr.functions = fs; XWM.setShellNotResizable(this, dimensions, dimensions.getBounds(), false); @@ -936,10 +936,10 @@ abstract class XDecoratedPeer extends XWindowPeer { protected boolean isEventDisabled(XEvent e) { switch (e.get_type()) { // Do not generate MOVED/RESIZED events since we generate them by ourselves - case ConfigureNotify: + case XConstants.ConfigureNotify: return true; - case EnterNotify: - case LeaveNotify: + case XConstants.EnterNotify: + case XConstants.LeaveNotify: // Disable crossing event on outer borders of Frame so // we receive only one set of cross notifications(first set is from content window) return true; @@ -964,7 +964,7 @@ abstract class XDecoratedPeer extends XWindowPeer { if (winAttr.isResizable) { //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced. //We need to update frame's minimum size, not to reset it - XWM.removeSizeHints(this, XlibWrapper.PMaxSize); + XWM.removeSizeHints(this, XUtilConstants.PMaxSize); updateMinimumSize(); } } else { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java index 40822e2c27d..2f81c9fe681 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDialogPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer { } else { winAttr.decorations = winAttr.AWT_DECOR_NONE; } - winAttr.functions = MWM_FUNC_ALL; + winAttr.functions = MWMConstants.MWM_FUNC_ALL; winAttr.isResizable = true; //target.isResizable(); winAttr.initialResizability = target.isResizable(); winAttr.title = target.getTitle(); @@ -100,10 +100,10 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer { int getDecorations() { int d = super.getDecorations(); // remove minimize and maximize buttons for dialogs - if ((d & MWM_DECOR_ALL) != 0) { - d |= (MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE); + if ((d & MWMConstants.MWM_DECOR_ALL) != 0) { + d |= (MWMConstants.MWM_DECOR_MINIMIZE | MWMConstants.MWM_DECOR_MAXIMIZE); } else { - d &= ~(MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE); + d &= ~(MWMConstants.MWM_DECOR_MINIMIZE | MWMConstants.MWM_DECOR_MAXIMIZE); } return d; } @@ -111,10 +111,10 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer { int getFunctions() { int f = super.getFunctions(); // remove minimize and maximize functions for dialogs - if ((f & MWM_FUNC_ALL) != 0) { - f |= (MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE); + if ((f & MWMConstants.MWM_FUNC_ALL) != 0) { + f |= (MWMConstants.MWM_FUNC_MINIMIZE | MWMConstants.MWM_FUNC_MAXIMIZE); } else { - f &= ~(MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE); + f &= ~(MWMConstants.MWM_FUNC_MINIMIZE | MWMConstants.MWM_FUNC_MAXIMIZE); } return f; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java index 5c2a329eea6..62ae6219244 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,7 +103,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { cleanup(); throw new XException("Cannot write XdndActionList property"); } @@ -124,7 +124,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { cleanup(); throw new XException("Cannot write XdndActionList property"); } @@ -134,7 +134,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { } if (!XDnDConstants.XDnDSelection.setOwner(contents, formatMap, formats, - XlibWrapper.CurrentTime)) { + XConstants.CurrentTime)) { cleanup(); throw new InvalidDnDOperationException("Cannot acquire selection ownership"); } @@ -193,11 +193,11 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { WindowPropertyGetter wpg1 = new WindowPropertyGetter(window, XDnDConstants.XA_XdndAware, 0, 1, - false, XlibWrapper.AnyPropertyType); + false, XConstants.AnyPropertyType); int status = wpg1.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && + if (status == XConstants.Success && wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) { int targetVersion = (int)Native.getLong(wpg1.getData()); @@ -217,7 +217,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { try { status = wpg2.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && + if (status == XConstants.Success && wpg2.getData() != 0 && wpg2.getActualType() == XAtom.XA_WINDOW) { @@ -235,7 +235,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { try { status = wpg3.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || + if (status != XConstants.Success || wpg3.getData() == 0 || wpg3.getActualType() != XAtom.XA_WINDOW || Native.getLong(wpg3.getData()) != proxy) { @@ -246,12 +246,12 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { new WindowPropertyGetter(proxy, XDnDConstants.XA_XdndAware, 0, 1, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { status = wpg4.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || + if (status != XConstants.Success || wpg4.getData() == 0 || wpg4.getActualType() != XAtom.XA_ATOM) { @@ -283,7 +283,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XlibWrapper.ClientMessage); + msg.set_type((int)XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndEnter.getAtom()); @@ -297,7 +297,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { msg.set_data(4, formats.length > 2 ? formats[2] : 0); XlibWrapper.XSendEvent(XToolkit.getDisplay(), getTargetProxyWindow(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { msg.dispose(); @@ -311,7 +311,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XlibWrapper.ClientMessage); + msg.set_type((int)XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndPosition.getAtom()); @@ -322,7 +322,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { msg.set_data(4, XDnDConstants.getXDnDActionForJavaAction(sourceAction)); XlibWrapper.XSendEvent(XToolkit.getDisplay(), getTargetProxyWindow(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { msg.dispose(); @@ -335,7 +335,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XlibWrapper.ClientMessage); + msg.set_type((int)XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndLeave.getAtom()); @@ -346,7 +346,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { msg.set_data(4, 0); XlibWrapper.XSendEvent(XToolkit.getDisplay(), getTargetProxyWindow(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { msg.dispose(); @@ -361,7 +361,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XlibWrapper.ClientMessage); + msg.set_type((int)XConstants.ClientMessage); msg.set_window(getTargetWindow()); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndDrop.getAtom()); @@ -372,7 +372,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { msg.set_data(4, 0); XlibWrapper.XSendEvent(XToolkit.getDisplay(), getTargetProxyWindow(), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { msg.dispose(); @@ -406,7 +406,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol { assert XToolkit.isAWTLockHeldByCurrentThread(); XlibWrapper.XSendEvent(XToolkit.getDisplay(), sourceWindow, - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, xclient.pData); return true; diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java index 00fe0430d36..5b518321626 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("Cannot write XdndAware property"); } } finally { @@ -119,12 +119,12 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { WindowPropertyGetter wpg1 = new WindowPropertyGetter(embedder, XDnDConstants.XA_XdndAware, 0, 1, - false, XlibWrapper.AnyPropertyType); + false, XConstants.AnyPropertyType); try { status = wpg1.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && + if (status == XConstants.Success && wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) { overriden = true; @@ -143,7 +143,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { try { status = wpg2.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && + if (status == XConstants.Success && wpg2.getData() != 0 && wpg2.getActualType() == XAtom.XA_WINDOW) { @@ -161,7 +161,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { try { status = wpg3.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || + if (status != XConstants.Success || wpg3.getData() == 0 || wpg3.getActualType() != XAtom.XA_WINDOW || Native.getLong(wpg3.getData()) != proxy) { @@ -172,12 +172,12 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { new WindowPropertyGetter(proxy, XDnDConstants.XA_XdndAware, 0, 1, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { status = wpg4.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || + if (status != XConstants.Success || wpg4.getData() == 0 || wpg4.getActualType() != XAtom.XA_ATOM) { @@ -212,7 +212,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != - XlibWrapper.Success) { + XConstants.Success) { throw new XException("Cannot write XdndAware property"); } @@ -226,7 +226,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != - XlibWrapper.Success) { + XConstants.Success) { throw new XException("Cannot write XdndProxy property"); } @@ -239,7 +239,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != - XlibWrapper.Success) { + XConstants.Success) { throw new XException("Cannot write XdndAware property"); } @@ -252,7 +252,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != - XlibWrapper.Success) { + XConstants.Success) { throw new XException("Cannot write XdndProxy property"); } } finally { @@ -285,7 +285,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != - XlibWrapper.Success) { + XConstants.Success) { throw new XException("Cannot write XdndAware property"); } @@ -298,7 +298,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != - XlibWrapper.Success) { + XConstants.Success) { throw new XException("Cannot write XdndProxy property"); } } finally { @@ -326,12 +326,12 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { WindowPropertyGetter wpg1 = new WindowPropertyGetter(embedded, XDnDConstants.XA_XdndAware, 0, 1, - false, XlibWrapper.AnyPropertyType); + false, XConstants.AnyPropertyType); try { status = wpg1.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && + if (status == XConstants.Success && wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) { overriden = true; @@ -350,7 +350,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { try { status = wpg2.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && + if (status == XConstants.Success && wpg2.getData() != 0 && wpg2.getActualType() == XAtom.XA_WINDOW) { @@ -368,7 +368,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { try { status = wpg3.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || + if (status != XConstants.Success || wpg3.getData() == 0 || wpg3.getActualType() != XAtom.XA_WINDOW || Native.getLong(wpg3.getData()) != proxy) { @@ -379,12 +379,12 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { new WindowPropertyGetter(proxy, XDnDConstants.XA_XdndAware, 0, 1, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { status = wpg4.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || + if (status != XConstants.Success || wpg4.getData() == 0 || wpg4.getActualType() != XAtom.XA_ATOM) { @@ -408,12 +408,12 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { WindowPropertyGetter wpg1 = new WindowPropertyGetter(window, XDnDConstants.XA_XdndAware, 0, 1, - false, XlibWrapper.AnyPropertyType); + false, XConstants.AnyPropertyType); try { int status = wpg1.execute(XToolkit.IgnoreBadWindowHandler); - if (status == XlibWrapper.Success && + if (status == XConstants.Success && wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) { return true; @@ -523,7 +523,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { for (int i = 0; i < 3; i++) { long j; - if ((j = xclient.get_data(2 + i)) != XlibWrapper.None) { + if ((j = xclient.get_data(2 + i)) != XConstants.None) { formats3[countFormats++] = j; } } @@ -549,7 +549,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { if (status == 0 || (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success)) { + XToolkit.saved_error.get_error_code() != XConstants.Success)) { throw new XException("XGetWindowAttributes failed"); } @@ -561,12 +561,12 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win, source_win_mask | - XlibWrapper.StructureNotifyMask); + XConstants.StructureNotifyMask); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("XSelectInput failed"); } @@ -581,7 +581,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { } private boolean processXdndPosition(XClientMessageEvent xclient) { - long time_stamp = (int)XlibWrapper.CurrentTime; + long time_stamp = (int)XConstants.CurrentTime; long xdnd_action = 0; int java_action = DnDConstants.ACTION_NONE; int x = 0; @@ -748,7 +748,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { long data3, long data4) { XClientMessageEvent enter = new XClientMessageEvent(); try { - enter.set_type((int)XlibWrapper.ClientMessage); + enter.set_type((int)XConstants.ClientMessage); enter.set_window(toplevel); enter.set_format(32); enter.set_message_type(XDnDConstants.XA_XdndEnter.getAtom()); @@ -774,7 +774,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { long sourceWindow) { XClientMessageEvent leave = new XClientMessageEvent(); try { - leave.set_type((int)XlibWrapper.ClientMessage); + leave.set_type((int)XConstants.ClientMessage); leave.set_window(toplevel); leave.set_format(32); leave.set_message_type(XDnDConstants.XA_XdndLeave.getAtom()); @@ -804,7 +804,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XlibWrapper.ClientMessage); + msg.set_type((int)XConstants.ClientMessage); msg.set_window(xclient.get_data(0)); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndStatus.getAtom()); @@ -826,7 +826,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { try { XlibWrapper.XSendEvent(XToolkit.getDisplay(), xclient.get_data(0), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { XToolkit.awtUnlock(); @@ -842,7 +842,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { throws IllegalArgumentException, IOException { XClientMessageEvent xclient = new XClientMessageEvent(ctxt); long message_type = xclient.get_message_type(); - long time_stamp = XlibWrapper.CurrentTime; + long time_stamp = XConstants.CurrentTime; // NOTE: we assume that the source supports at least version 1, so we // can use the time stamp @@ -892,7 +892,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { XClientMessageEvent msg = new XClientMessageEvent(); try { - msg.set_type((int)XlibWrapper.ClientMessage); + msg.set_type((int)XConstants.ClientMessage); msg.set_window(xclient.get_data(0)); msg.set_format(32); msg.set_message_type(XDnDConstants.XA_XdndFinished.getAtom()); @@ -914,7 +914,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { try { XlibWrapper.XSendEvent(XToolkit.getDisplay(), xclient.get_data(0), - false, XlibWrapper.NoEventMask, + false, XConstants.NoEventMask, msg.pData); } finally { XToolkit.awtUnlock(); @@ -1119,7 +1119,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol { XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { if (logger.isLoggable(Level.WARNING)) { logger.warning("Cannot set XdndTypeList on the proxy window"); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java index 48ecd886c21..af3a3219cff 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,11 +55,11 @@ public final class XDragSourceContextPeer Logger.getLogger("sun.awt.X11.xembed.xdnd.XDragSourceContextPeer"); /* The events selected on the root window when the drag begins. */ - private static final int ROOT_EVENT_MASK = (int)XlibWrapper.ButtonMotionMask | - (int)XlibWrapper.KeyPressMask | (int)XlibWrapper.KeyReleaseMask; + private static final int ROOT_EVENT_MASK = (int)XConstants.ButtonMotionMask | + (int)XConstants.KeyPressMask | (int)XConstants.KeyReleaseMask; /* The events to be delivered during grab. */ - private static final int GRAB_EVENT_MASK = (int)XlibWrapper.ButtonPressMask | - (int)XlibWrapper.ButtonMotionMask | (int)XlibWrapper.ButtonReleaseMask; + private static final int GRAB_EVENT_MASK = (int)XConstants.ButtonPressMask | + (int)XConstants.ButtonMotionMask | (int)XConstants.ButtonReleaseMask; /* The event mask of the root window before the drag operation starts. */ private long rootEventMask = 0; @@ -196,11 +196,11 @@ public final class XDragSourceContextPeer status = XlibWrapper.XGrabPointer(XToolkit.getDisplay(), rootWindow, 0, GRAB_EVENT_MASK, - XlibWrapper.GrabModeAsync, - XlibWrapper.GrabModeAsync, - XlibWrapper.None, xcursor, timeStamp); + XConstants.GrabModeAsync, + XConstants.GrabModeAsync, + XConstants.None, xcursor, timeStamp); - if (status != XlibWrapper.GrabSuccess) { + if (status != XConstants.GrabSuccess) { cleanup(timeStamp); throwGrabFailureException("Cannot grab pointer", status); return; @@ -208,11 +208,11 @@ public final class XDragSourceContextPeer status = XlibWrapper.XGrabKeyboard(XToolkit.getDisplay(), rootWindow, 0, - XlibWrapper.GrabModeAsync, - XlibWrapper.GrabModeAsync, + XConstants.GrabModeAsync, + XConstants.GrabModeAsync, timeStamp); - if (status != XlibWrapper.GrabSuccess) { + if (status != XConstants.GrabSuccess) { cleanup(timeStamp); throwGrabFailureException("Cannot grab keyboard", status); return; @@ -276,7 +276,7 @@ public final class XDragSourceContextPeer XlibWrapper.XChangeActivePointerGrab(XToolkit.getDisplay(), GRAB_EVENT_MASK, xcursor, - XlibWrapper.CurrentTime); + XConstants.CurrentTime); } protected boolean needsBogusExitBeforeDrop() { @@ -287,10 +287,10 @@ public final class XDragSourceContextPeer throws InvalidDnDOperationException { String msgCause = ""; switch (grabStatus) { - case XlibWrapper.GrabNotViewable: msgCause = "not viewable"; break; - case XlibWrapper.AlreadyGrabbed: msgCause = "already grabbed"; break; - case XlibWrapper.GrabInvalidTime: msgCause = "invalid time"; break; - case XlibWrapper.GrabFrozen: msgCause = "grab frozen"; break; + case XConstants.GrabNotViewable: msgCause = "not viewable"; break; + case XConstants.AlreadyGrabbed: msgCause = "already grabbed"; break; + case XConstants.GrabInvalidTime: msgCause = "invalid time"; break; + case XConstants.GrabFrozen: msgCause = "grab frozen"; break; default: msgCause = "unknown failure"; break; } throw new InvalidDnDOperationException(msg + ": " + msgCause); @@ -537,7 +537,7 @@ public final class XDragSourceContextPeer return false; } - if (ev.get_type() != (int)XlibWrapper.ClientMessage) { + if (ev.get_type() != (int)XConstants.ClientMessage) { return false; } @@ -579,18 +579,18 @@ public final class XDragSourceContextPeer } switch (ev.get_type()) { - case XlibWrapper.ClientMessage: { + case XConstants.ClientMessage: { XClientMessageEvent xclient = ev.get_xclient(); return processClientMessage(xclient); } - case XlibWrapper.DestroyNotify: { + case XConstants.DestroyNotify: { XDestroyWindowEvent xde = ev.get_xdestroywindow(); /* Target crashed during drop processing - cleanup. */ if (!dragInProgress && dragProtocol != null && xde.get_window() == dragProtocol.getTargetWindow()) { - cleanup(XlibWrapper.CurrentTime); + cleanup(XConstants.CurrentTime); return true; } /* Pass along */ @@ -604,14 +604,14 @@ public final class XDragSourceContextPeer /* Process drag-only messages. */ switch (ev.get_type()) { - case XlibWrapper.KeyRelease: - case XlibWrapper.KeyPress: { + case XConstants.KeyRelease: + case XConstants.KeyPress: { XKeyEvent xkey = ev.get_xkey(); long keysym = XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), xkey.get_keycode(), 0); switch ((int)keysym) { case (int)XKeySymConstants.XK_Escape: { - if (ev.get_type() == (int)XlibWrapper.KeyRelease) { + if (ev.get_type() == (int)XConstants.KeyRelease) { cleanup(xkey.get_time()); } break; @@ -631,7 +631,7 @@ public final class XDragSourceContextPeer XlibWrapper.larg7); // modifiers XMotionEvent xmotion = new XMotionEvent(); try { - xmotion.set_type(XlibWrapper.MotionNotify); + xmotion.set_type(XConstants.MotionNotify); xmotion.set_serial(xkey.get_serial()); xmotion.set_send_event(xkey.get_send_event()); xmotion.set_display(xkey.get_display()); @@ -658,12 +658,12 @@ public final class XDragSourceContextPeer } return true; } - case XlibWrapper.ButtonPress: + case XConstants.ButtonPress: return true; - case XlibWrapper.MotionNotify: + case XConstants.MotionNotify: processMouseMove(ev.get_xmotion()); return true; - case XlibWrapper.ButtonRelease: { + case XConstants.ButtonRelease: { XButtonEvent xbutton = ev.get_xbutton(); /* * On some X servers it could happen that ButtonRelease coordinates @@ -672,7 +672,7 @@ public final class XDragSourceContextPeer */ XMotionEvent xmotion = new XMotionEvent(); try { - xmotion.set_type(XlibWrapper.MotionNotify); + xmotion.set_type(XConstants.MotionNotify); xmotion.set_serial(xbutton.get_serial()); xmotion.set_send_event(xbutton.get_send_event()); xmotion.set_display(xbutton.get_display()); @@ -694,8 +694,8 @@ public final class XDragSourceContextPeer } finally { xmotion.dispose(); } - if (xbutton.get_button() == XlibWrapper.Button1 - || xbutton.get_button() == XlibWrapper.Button2) { + if (xbutton.get_button() == XConstants.Button1 + || xbutton.get_button() == XConstants.Button2) { // drag is initiated with Button1 or Button2 pressed and // ended on release of either of these buttons (as the same // behavior was with our old Motif DnD-based implementation) @@ -789,6 +789,6 @@ public final class XDragSourceContextPeer dragDropFinished(success, action, x, y); dndInProgress = false; - cleanup(XlibWrapper.CurrentTime); + cleanup(XConstants.CurrentTime); } } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java index baf58c48d26..40a7b045834 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -189,7 +189,7 @@ abstract class XDragSourceProtocol { if (status == 0 || (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success)) { + XToolkit.saved_error.get_error_code() != XConstants.Success)) { throw new XException("XGetWindowAttributes failed"); } @@ -201,12 +201,12 @@ abstract class XDragSourceProtocol { XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow, targetWindowMask | - XlibWrapper.StructureNotifyMask); + XConstants.StructureNotifyMask); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("XSelectInput failed"); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java index 23bdf39a202..d8d6c25d16f 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ final class XDropTargetEventProcessor { private XDropTargetEventProcessor() {} private boolean doProcessEvent(XEvent ev) { - if (ev.get_type() == (int)XlibWrapper.DestroyNotify && + if (ev.get_type() == (int)XConstants.DestroyNotify && protocol != null && ev.get_xany().get_window() == protocol.getSourceWindow()) { protocol.cleanup(); @@ -51,7 +51,7 @@ final class XDropTargetEventProcessor { return false; } - if (ev.get_type() == (int)XlibWrapper.PropertyNotify) { + if (ev.get_type() == (int)XConstants.PropertyNotify) { XPropertyEvent xproperty = ev.get_xproperty(); if (xproperty.get_atom() == MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom()) { @@ -60,7 +60,7 @@ final class XDropTargetEventProcessor { } } - if (ev.get_type() != (int)XlibWrapper.ClientMessage) { + if (ev.get_type() != (int)XConstants.ClientMessage) { return false; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java index 658b7cbf3d5..7a7c7c10ee2 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -149,7 +149,7 @@ abstract class XDropTargetProtocol { XToolkit.awtLock(); try { XlibWrapper.XSendEvent(XToolkit.getDisplay(), proxy, false, - XlibWrapper.NoEventMask, xclient.pData); + XConstants.NoEventMask, xclient.pData); } finally { XToolkit.awtUnlock(); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java index 2d05578dd04..47353e03ebe 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,18 +27,14 @@ package sun.awt.X11; import java.util.ArrayList; import java.util.Collections; -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; -import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.logging.*; import java.awt.Point; -import sun.awt.dnd.SunDropTargetContextPeer; -import sun.awt.dnd.SunDropTargetEvent; /** * The class responsible for registration/deregistration of drop sites. @@ -179,11 +175,11 @@ final class XDropTargetRegistry { if (status == 0 || (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success)) { + XToolkit.saved_error.get_error_code() != XConstants.Success)) { continue; } - if (wattr.get_map_state() != XlibWrapper.IsUnmapped + if (wattr.get_map_state() != XConstants.IsUnmapped && dest_x < wattr.get_width() && dest_y < wattr.get_height()) { return window; @@ -233,7 +229,7 @@ final class XDropTargetRegistry { if (status == 0 || (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success)) { + XToolkit.saved_error.get_error_code() != XConstants.Success)) { throw new XException("XGetWindowAttributes failed"); } @@ -243,14 +239,14 @@ final class XDropTargetRegistry { wattr.dispose(); } - if ((event_mask & XlibWrapper.PropertyChangeMask) == 0) { + if ((event_mask & XConstants.PropertyChangeMask) == 0) { XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder, - event_mask | XlibWrapper.PropertyChangeMask); + event_mask | XConstants.PropertyChangeMask); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("XSelectInput failed"); } } @@ -397,14 +393,14 @@ final class XDropTargetRegistry { long event_mask = entry.getEventMask(); /* Restore the original event mask for the embedder. */ - if ((event_mask & XlibWrapper.PropertyChangeMask) == 0) { + if ((event_mask & XConstants.PropertyChangeMask) == 0) { XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler); XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder, event_mask); XToolkit.RESTORE_XERROR_HANDLER(); if (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + XToolkit.saved_error.get_error_code() != XConstants.Success) { throw new XException("XSelectInput failed"); } } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java index 10b71a453b4..3d2c25658c4 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,10 +81,10 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener super.preInit(params); params.put(EVENT_MASK, - KeyPressMask | KeyReleaseMask - | FocusChangeMask | ButtonPressMask | ButtonReleaseMask - | EnterWindowMask | LeaveWindowMask | PointerMotionMask - | ButtonMotionMask | ExposureMask | StructureNotifyMask | SubstructureNotifyMask); + XConstants.KeyPressMask | XConstants.KeyReleaseMask + | XConstants.FocusChangeMask | XConstants.ButtonPressMask | XConstants.ButtonReleaseMask + | XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask + | XConstants.ButtonMotionMask | XConstants.ExposureMask | XConstants.StructureNotifyMask | XConstants.SubstructureNotifyMask); } @@ -134,7 +134,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener try { XToolkit.addEventDispatcher(xembed.handle, xembed); XlibWrapper.XSelectInput(XToolkit.getDisplay(), xembed.handle, - XlibWrapper.StructureNotifyMask | XlibWrapper.PropertyChangeMask); + XConstants.StructureNotifyMask | XConstants.PropertyChangeMask); XDropTargetRegistry.getRegistry().registerXEmbedClient(getWindow(), xembed.handle); } finally { @@ -194,7 +194,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener public void dispatchEvent(XEvent ev) { super.dispatchEvent(ev); switch (ev.get_type()) { - case CreateNotify: + case XConstants.CreateNotify: XCreateWindowEvent cr = ev.get_xcreatewindow(); if (xembedLog.isLoggable(Level.FINEST)) { xembedLog.finest("Message on embedder: " + cr); @@ -205,7 +205,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener } embedChild(cr.get_window()); break; - case DestroyNotify: + case XConstants.DestroyNotify: XDestroyWindowEvent dn = ev.get_xdestroywindow(); if (xembedLog.isLoggable(Level.FINEST)) { xembedLog.finest("Message on embedder: " + dn); @@ -215,7 +215,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener } childDestroyed(); break; - case ReparentNotify: + case XConstants.ReparentNotify: XReparentEvent rep = ev.get_xreparent(); if (xembedLog.isLoggable(Level.FINEST)) { xembedLog.finest("Message on embedder: " + rep); @@ -309,7 +309,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener if (status == 0 || (XToolkit.saved_error != null && - XToolkit.saved_error.get_error_code() != XlibWrapper.Success)) { + XToolkit.saved_error.get_error_code() != XConstants.Success)) { return null; } @@ -480,7 +480,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Forwarding native key event: " + ke); XToolkit.awtLock(); try { - XlibWrapper.XSendEvent(XToolkit.getDisplay(), xembed.handle, false, XlibWrapper.NoEventMask, data); + XlibWrapper.XSendEvent(XToolkit.getDisplay(), xembed.handle, false, XConstants.NoEventMask, data); } finally { XToolkit.awtUnlock(); } @@ -742,7 +742,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener version = Native.getCard32(xembed_info_data, 0); flags = Native.getCard32(xembed_info_data, 1); boolean new_mapped = (flags & XEMBED_MAPPED) != 0; - boolean currently_mapped = XlibUtil.getWindowMapState(handle) != XlibWrapper.IsUnmapped; + boolean currently_mapped = XlibUtil.getWindowMapState(handle) != XConstants.IsUnmapped; if (new_mapped != currently_mapped) { if (xembedLog.isLoggable(Level.FINER)) xembedLog.fine("Mapping state of the client has changed, old state: " + currently_mapped + ", new state: " + new_mapped); @@ -803,13 +803,13 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener public void dispatchEvent(XEvent xev) { int type = xev.get_type(); switch (type) { - case PropertyNotify: + case XConstants.PropertyNotify: handlePropertyNotify(xev); break; - case ConfigureNotify: + case XConstants.ConfigureNotify: handleConfigureNotify(xev); break; - case ClientMessage: + case XConstants.ClientMessage: handleClientMessage(xev); break; } @@ -844,7 +844,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener XKeyEvent ke = new XKeyEvent(data); // We recognize only these masks - modifiers = ke.get_state() & (ShiftMask | ControlMask | LockMask); + modifiers = ke.get_state() & (XConstants.ShiftMask | XConstants.ControlMask | XConstants.LockMask); if (xembedLog.isLoggable(Level.FINEST)) xembedLog.finest("Mapped " + e + " to " + this); } finally { XlibWrapper.unsafe.freeMemory(data); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java index 7e6ae054a87..b2a342757bd 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{ try { XToolkit.addEventDispatcher(handle, this); XlibWrapper.XSelectInput(XToolkit.getDisplay(), handle, - XlibWrapper.StructureNotifyMask | XlibWrapper.PropertyChangeMask); + XConstants.StructureNotifyMask | XConstants.PropertyChangeMask); } finally { XToolkit.awtUnlock(); @@ -341,10 +341,10 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{ public void dispatchEvent(XEvent xev) { int type = xev.get_type(); switch (type) { - case XlibWrapper.PropertyNotify: + case XConstants.PropertyNotify: handlePropertyNotify(xev); break; - case XlibWrapper.ConfigureNotify: + case XConstants.ConfigureNotify: handleConfigureNotify(xev); break; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java index c56883e46af..139f375fa40 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedClientHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -145,10 +145,10 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher public void dispatchEvent(XEvent xev) { switch(xev.get_type()) { - case XlibWrapper.ClientMessage: + case XConstants.ClientMessage: handleClientMessage(xev); break; - case XlibWrapper.ReparentNotify: + case XConstants.ReparentNotify: handleReparentNotify(xev); break; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java index aab78552007..4b3c7d9fd88 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -94,7 +94,7 @@ public class XEmbedHelper { } void sendMessage(long window, int message, long detail, long data1, long data2) { XClientMessageEvent msg = new XClientMessageEvent(); - msg.set_type((int)XlibWrapper.ClientMessage); + msg.set_type((int)XConstants.ClientMessage); msg.set_window(window); msg.set_message_type(XEmbed.getAtom()); msg.set_format(32); @@ -106,7 +106,7 @@ public class XEmbedHelper { XToolkit.awtLock(); try { if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Sending " + XEmbedMessageToString(msg)); - XlibWrapper.XSendEvent(XToolkit.getDisplay(), window, false, XlibWrapper.NoEventMask, msg.pData); + XlibWrapper.XSendEvent(XToolkit.getDisplay(), window, false, XConstants.NoEventMask, msg.pData); } finally { XToolkit.awtUnlock(); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java index 28fd3c2246a..932f8bd31d6 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedServerTester.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -260,7 +260,7 @@ public class XEmbedServerTester implements XEventDispatcher { mapped = 0; embedCompletely(); sleep(1000); - if (XlibUtil.getWindowMapState(window.getWindow()) != XlibWrapper.IsUnmapped) { + if (XlibUtil.getWindowMapState(window.getWindow()) != IsUnmapped) { throw new RuntimeException("Client has been mapped"); } } @@ -613,12 +613,12 @@ public class XEmbedServerTester implements XEventDispatcher { } } private void checkMapped() { - if (XlibUtil.getWindowMapState(window.getWindow()) == XlibWrapper.IsUnmapped) { + if (XlibUtil.getWindowMapState(window.getWindow()) == IsUnmapped) { throw new RuntimeException("Client is not mapped"); } } private void checkNotMapped() { - if (XlibUtil.getWindowMapState(window.getWindow()) != XlibWrapper.IsUnmapped) { + if (XlibUtil.getWindowMapState(window.getWindow()) != IsUnmapped) { throw new RuntimeException("Client is mapped"); } } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java index b0cb3aa6d07..90eb7ff8ddc 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -114,8 +114,8 @@ public class XEmbeddedFramePeer extends XFramePeer { protected boolean isEventDisabled(XEvent e) { if (embedder != null && embedder.isActive()) { switch (e.get_type()) { - case FocusIn: - case FocusOut: + case XConstants.FocusIn: + case XConstants.FocusOut: return true; } } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java index e5d5bed6bac..763729800c3 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -121,7 +121,7 @@ public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatche } public void dispatchEvent(XEvent xev) { switch(xev.get_type()) { - case XlibWrapper.ClientMessage: + case XConstants.ClientMessage: handleClientMessage(xev); break; } @@ -149,7 +149,7 @@ public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatche ke.set_window(child); XToolkit.awtLock(); try { - XlibWrapper.XSendEvent(XToolkit.getDisplay(), child, false, XlibWrapper.NoEventMask, data); + XlibWrapper.XSendEvent(XToolkit.getDisplay(), child, false, XConstants.NoEventMask, data); } finally { XToolkit.awtUnlock(); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java index 045d10687d3..361ef87eeb6 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class XFocusProxyWindow extends XBaseWindow { super(new XCreateWindowParams(new Object[] { BOUNDS, new Rectangle(-1, -1, 1, 1), PARENT_WINDOW, new Long(owner.getWindow()), - EVENT_MASK, new Long(FocusChangeMask | KeyPressMask | KeyReleaseMask) + EVENT_MASK, new Long(XConstants.FocusChangeMask | XConstants.KeyPressMask | XConstants.KeyReleaseMask) })); this.owner = owner; } @@ -67,8 +67,8 @@ public class XFocusProxyWindow extends XBaseWindow { int type = ev.get_type(); switch (type) { - case XlibWrapper.FocusIn: - case XlibWrapper.FocusOut: + case XConstants.FocusIn: + case XConstants.FocusOut: handleFocusEvent(ev); break; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java index 28989acc609..9493b453feb 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java @@ -37,7 +37,7 @@ import java.awt.peer.FramePeer; import java.util.logging.Level; import java.util.logging.Logger; -class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { +class XFramePeer extends XDecoratedPeer implements FramePeer { private static Logger log = Logger.getLogger("sun.awt.X11.XFramePeer"); private static Logger stateLog = Logger.getLogger("sun.awt.X11.states"); private static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XFramePeer"); @@ -71,7 +71,7 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { } else { winAttr.decorations = winAttr.AWT_DECOR_NONE; } - winAttr.functions = MWM_FUNC_ALL; + winAttr.functions = MWMConstants.MWM_FUNC_ALL; winAttr.isResizable = true; // target.isResizable(); winAttr.title = target.getTitle(); winAttr.initialResizability = target.isResizable(); @@ -109,9 +109,9 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { state = winAttr.initialState; } if ((state & Frame.ICONIFIED) != 0) { - setInitialState(IconicState); + setInitialState(XUtilConstants.IconicState); } else { - setInitialState(NormalState); + setInitialState(XUtilConstants.NormalState); } setExtendedState(state); } @@ -221,7 +221,7 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { XToolkit.awtLock(); try { XSizeHints hints = getHints(); - hints.set_flags(hints.get_flags() | (int)XlibWrapper.PMaxSize); + hints.set_flags(hints.get_flags() | (int)XUtilConstants.PMaxSize); if (b.width != Integer.MAX_VALUE) { hints.set_max_width(b.width); } else { @@ -344,7 +344,7 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { XToolkit.awtLock(); try { XWMHints hints = getWMHints(); - hints.set_flags((int)XlibWrapper.StateHint | hints.get_flags()); + hints.set_flags((int)XUtilConstants.StateHint | hints.get_flags()); hints.set_initial_state(wm_state); if (stateLog.isLoggable(Level.FINE)) stateLog.fine("Setting initial WM state on " + this + " to " + wm_state); XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java b/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java index eae5bbc2f5f..43ae1f89004 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -229,46 +229,46 @@ public final class XGlobalCursorManager extends GlobalCursorManager { int cursorType = 0; switch (type) { case Cursor.DEFAULT_CURSOR: - cursorType = XlibWrapper.XC_left_ptr; + cursorType = XCursorFontConstants.XC_left_ptr; break; case Cursor.CROSSHAIR_CURSOR: - cursorType = XlibWrapper.XC_crosshair; + cursorType = XCursorFontConstants.XC_crosshair; break; case Cursor.TEXT_CURSOR: - cursorType = XlibWrapper.XC_xterm; + cursorType = XCursorFontConstants.XC_xterm; break; case Cursor.WAIT_CURSOR: - cursorType = XlibWrapper.XC_watch; + cursorType = XCursorFontConstants.XC_watch; break; case Cursor.SW_RESIZE_CURSOR: - cursorType = XlibWrapper.XC_bottom_left_corner; + cursorType = XCursorFontConstants.XC_bottom_left_corner; break; case Cursor.NW_RESIZE_CURSOR: - cursorType = XlibWrapper.XC_top_left_corner; + cursorType = XCursorFontConstants.XC_top_left_corner; break; case Cursor.SE_RESIZE_CURSOR: - cursorType = XlibWrapper.XC_bottom_right_corner; + cursorType = XCursorFontConstants.XC_bottom_right_corner; break; case Cursor.NE_RESIZE_CURSOR: - cursorType = XlibWrapper.XC_top_right_corner; + cursorType = XCursorFontConstants.XC_top_right_corner; break; case Cursor.S_RESIZE_CURSOR: - cursorType = XlibWrapper.XC_bottom_side; + cursorType = XCursorFontConstants.XC_bottom_side; break; case Cursor.N_RESIZE_CURSOR: - cursorType = XlibWrapper.XC_top_side; + cursorType = XCursorFontConstants.XC_top_side; break; case Cursor.W_RESIZE_CURSOR: - cursorType = XlibWrapper.XC_left_side; + cursorType = XCursorFontConstants.XC_left_side; break; case Cursor.E_RESIZE_CURSOR: - cursorType = XlibWrapper.XC_right_side; + cursorType = XCursorFontConstants.XC_right_side; break; case Cursor.HAND_CURSOR: - cursorType = XlibWrapper.XC_hand2; + cursorType = XCursorFontConstants.XC_hand2; break; case Cursor.MOVE_CURSOR: - cursorType = XlibWrapper.XC_fleur; + cursorType = XCursorFontConstants.XC_fleur; break; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java index eab55f6b5fc..a6211a0e0b6 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -293,7 +293,7 @@ public class XIconWindow extends XBaseWindow { long dst = XlibWrapper.XCreateImage(XToolkit.getDisplay(), visInfo.get_visual(), (int)awtImage.get_Depth(), - (int)XlibWrapper.ZPixmap, + (int)XConstants.ZPixmap, 0, bytes, iconWidth, @@ -470,9 +470,9 @@ public class XIconWindow extends XBaseWindow { params.add(BACKGROUND_PIXMAP, iconPixmap); params.add(COLORMAP, adata.get_awt_cmap()); params.add(DEPTH, awtImage.get_Depth()); - params.add(VISUAL_CLASS, (int)XlibWrapper.InputOutput); + params.add(VISUAL_CLASS, (int)XConstants.InputOutput); params.add(VISUAL, visInfo.get_visual()); - params.add(VALUE_MASK, XlibWrapper.CWBorderPixel | XlibWrapper.CWColormap | XlibWrapper.CWBackPixmap); + params.add(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWColormap | XConstants.CWBackPixmap); params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), visInfo.get_screen())); params.add(BOUNDS, new Rectangle(0, 0, iconWidth, iconHeight)); params.remove(DELAYED); @@ -488,9 +488,9 @@ public class XIconWindow extends XBaseWindow { XlibWrapper.XClearWindow(XToolkit.getDisplay(), getWindow()); } // Provide both pixmap and window, WM or Taskbar will use the one they find more appropriate - long newFlags = hints.get_flags() | XlibWrapper.IconPixmapHint | XlibWrapper.IconMaskHint; + long newFlags = hints.get_flags() | XUtilConstants.IconPixmapHint | XUtilConstants.IconMaskHint; if (getWindow() != 0) { - newFlags |= XlibWrapper.IconWindowHint; + newFlags |= XUtilConstants.IconWindowHint; } hints.set_flags(newFlags); hints.set_icon_pixmap(iconPixmap); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XMSelection.java b/jdk/src/solaris/classes/sun/awt/X11/XMSelection.java index 9d7059a8d05..8fb4f4bf3c0 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XMSelection.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XMSelection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,7 +98,7 @@ public class XMSelection { XToolkit.awtLock(); try { long root = XlibWrapper.RootWindow(display,screen); - XlibWrapper.XSelectInput(display, root, XlibWrapper.StructureNotifyMask); + XlibWrapper.XSelectInput(display, root, XConstants.StructureNotifyMask); XToolkit.addEventDispatcher(root, new XEventDispatcher() { public void dispatchEvent(XEvent ev) { @@ -130,7 +130,7 @@ public class XMSelection { synchronized(this) { setOwner(owner, screen); if (log.isLoggable(Level.FINE)) log.fine("New Selection Owner for screen " + screen + " = " + owner ); - XlibWrapper.XSelectInput(display, owner, XlibWrapper.StructureNotifyMask | eventMask); + XlibWrapper.XSelectInput(display, owner, XConstants.StructureNotifyMask | eventMask); XToolkit.addEventDispatcher(owner, new XEventDispatcher() { public void dispatchEvent(XEvent ev) { @@ -162,7 +162,7 @@ public class XMSelection { if (owner != 0) { setOwner(owner, screen); if (log.isLoggable(Level.FINE)) log.fine("Selection Owner for screen " + screen + " = " + owner ); - XlibWrapper.XSelectInput(display, owner, XlibWrapper.StructureNotifyMask | extra_mask); + XlibWrapper.XSelectInput(display, owner, XConstants.StructureNotifyMask | extra_mask); XToolkit.addEventDispatcher(owner, new XEventDispatcher() { public void dispatchEvent(XEvent ev) { @@ -205,7 +205,7 @@ public class XMSelection { static boolean processRootEvent(XEvent xev, int screen) { switch (xev.get_type()) { - case XlibWrapper.ClientMessage: { + case XConstants.ClientMessage: { return processClientMessage(xev, screen); } } @@ -225,7 +225,7 @@ public class XMSelection { */ public XMSelection (String selname) { - this(selname, XlibWrapper.PropertyChangeMask); + this(selname, XConstants.PropertyChangeMask); } @@ -319,11 +319,11 @@ public class XMSelection { void dispatchSelectionEvent(XEvent xev, int screen) { if (log.isLoggable(Level.FINE)) log.fine("Event =" + xev); - if (xev.get_type() == XlibWrapper.DestroyNotify) { + if (xev.get_type() == XConstants.DestroyNotify) { XDestroyWindowEvent de = xev.get_xdestroywindow(); dispatchOwnerDeath( de, screen); } - else if (xev.get_type() == XlibWrapper.PropertyNotify) { + else if (xev.get_type() == XConstants.PropertyNotify) { XPropertyEvent xpe = xev.get_xproperty(); dispatchSelectionChanged( xpe, screen); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java index f61c476e57e..ccc1b124204 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java @@ -99,7 +99,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt return; } if (log.isLoggable(Level.FINE)) log.fine("Requesting state on " + window + " for " + state); - req.set_type((int)XlibWrapper.ClientMessage); + req.set_type((int)XConstants.ClientMessage); req.set_window(window.getWindow()); req.set_message_type(XA_NET_WM_STATE.getAtom()); req.set_format(32); @@ -109,7 +109,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt XlibWrapper.XSendEvent(XToolkit.getDisplay(), XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()), false, - XlibWrapper.SubstructureRedirectMask | XlibWrapper.SubstructureNotifyMask, + XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, req.pData); } finally { @@ -183,7 +183,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt if (window.isShowing()) { XClientMessageEvent req = new XClientMessageEvent(); try { - req.set_type((int)XlibWrapper.ClientMessage); + req.set_type((int)XConstants.ClientMessage); req.set_window(window.getWindow()); req.set_message_type(XA_NET_WM_STATE.getAtom()); req.set_format(32); @@ -195,7 +195,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt XlibWrapper.XSendEvent(XToolkit.getDisplay(), XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()), false, - XlibWrapper.SubstructureRedirectMask | XlibWrapper.SubstructureNotifyMask, + XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, req.pData); } finally { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XProtocol.java index 34c900ed4d0..1fb3de9fa31 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ class XProtocol { static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() { public int handleError(long display, XErrorEvent err) { XToolkit.XERROR_SAVE(err); - if (err.get_request_code() == XlibWrapper.X_ChangeProperty) { + if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) { return 0; } else { return XToolkit.SAVED_ERROR_HANDLER(display, err); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XProtocolConstants.java b/jdk/src/solaris/classes/sun/awt/X11/XProtocolConstants.java index 475a348fc69..70aae76064c 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XProtocolConstants.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XProtocolConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,10 @@ package sun.awt.X11; -public interface XProtocolConstants { +final public class XProtocolConstants { + + private XProtocolConstants(){} + /* Reply codes */ public static final int X_Reply = 1 ; /* Normal reply */ public static final int X_Error = 0 ; /* Error */ diff --git a/jdk/src/solaris/classes/sun/awt/X11/XSelection.java b/jdk/src/solaris/classes/sun/awt/X11/XSelection.java index b472bec7646..0e7a8aafdc0 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XSelection.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XSelection.java @@ -141,7 +141,7 @@ public final class XSelection { long selection = selectionAtom.getAtom(); // ICCCM prescribes that CurrentTime should not be used for SetSelectionOwner. - if (time == XlibWrapper.CurrentTime) { + if (time == XConstants.CurrentTime) { time = XToolkit.getCurrentServerTime(); } @@ -199,7 +199,7 @@ public final class XSelection { WindowPropertyGetter targetsGetter = new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(), selectionPropertyAtom, 0, MAX_LENGTH, - true, XlibWrapper.AnyPropertyType); + true, XConstants.AnyPropertyType); try { XToolkit.awtLock(); @@ -274,7 +274,7 @@ public final class XSelection { new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(), selectionPropertyAtom, 0, MAX_LENGTH, false, // don't delete to handle INCR properly. - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { XToolkit.awtLock(); @@ -353,7 +353,7 @@ public final class XSelection { new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(), selectionPropertyAtom, 0, MAX_LENGTH, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { XToolkit.awtLock(); @@ -520,7 +520,7 @@ public final class XSelection { try { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), requestor, property, format, dataFormat, - XlibWrapper.PropModeReplace, + XConstants.PropModeReplace, nativeDataPtr, count); } finally { XToolkit.awtUnlock(); @@ -543,14 +543,14 @@ public final class XSelection { boolean conversionSucceeded = false; if (ownershipTime != 0 && - (requestTime == XlibWrapper.CurrentTime || requestTime >= ownershipTime)) + (requestTime == XConstants.CurrentTime || requestTime >= ownershipTime)) { // Handle MULTIPLE requests as per ICCCM. if (format == XDataTransferer.MULTIPLE_ATOM.getAtom()) { conversionSucceeded = handleMultipleRequest(requestor, property); } else { // Support for obsolete clients as per ICCCM. - if (property == XlibWrapper.None) { + if (property == XConstants.None) { property = format; } @@ -564,12 +564,12 @@ public final class XSelection { if (!conversionSucceeded) { // None property indicates conversion failure. - property = XlibWrapper.None; + property = XConstants.None; } XSelectionEvent xse = new XSelectionEvent(); try { - xse.set_type(XlibWrapper.SelectionNotify); + xse.set_type(XConstants.SelectionNotify); xse.set_send_event(true); xse.set_requestor(requestor); xse.set_selection(selectionAtom.getAtom()); @@ -580,7 +580,7 @@ public final class XSelection { XToolkit.awtLock(); try { XlibWrapper.XSendEvent(XToolkit.getDisplay(), requestor, false, - XlibWrapper.NoEventMask, xse.pData); + XConstants.NoEventMask, xse.pData); } finally { XToolkit.awtUnlock(); } @@ -590,7 +590,7 @@ public final class XSelection { } private boolean handleMultipleRequest(final long requestor, long property) { - if (XlibWrapper.None == property) { + if (XConstants.None == property) { // The property cannot be None for a MULTIPLE request. return false; } @@ -601,7 +601,7 @@ public final class XSelection { WindowPropertyGetter wpg = new WindowPropertyGetter(requestor, XAtom.get(property), 0, MAX_LENGTH, false, - XlibWrapper.AnyPropertyType); + XConstants.AnyPropertyType); try { wpg.execute(); @@ -629,7 +629,7 @@ public final class XSelection { property, wpg.getActualType(), wpg.getActualFormat(), - XlibWrapper.PropModeReplace, + XConstants.PropModeReplace, wpg.getData(), wpg.getNumberOfItems()); } finally { @@ -673,7 +673,7 @@ public final class XSelection { try { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), requestor, property, XAtom.XA_ATOM, dataFormat, - XlibWrapper.PropModeReplace, + XConstants.PropModeReplace, nativeDataPtr, count); } finally { XToolkit.awtUnlock(); @@ -712,7 +712,7 @@ public final class XSelection { private static class SelectionEventHandler implements XEventDispatcher { public void dispatchEvent(XEvent ev) { switch (ev.get_type()) { - case XlibWrapper.SelectionNotify: { + case XConstants.SelectionNotify: { XToolkit.awtLock(); try { XSelectionEvent xse = ev.get_xselection(); @@ -733,7 +733,7 @@ public final class XSelection { } break; } - case XlibWrapper.SelectionRequest: { + case XConstants.SelectionRequest: { XSelectionRequestEvent xsre = ev.get_xselectionrequest(); long atom = xsre.get_selection(); XSelection selection = XSelection.getSelection(XAtom.get(atom)); @@ -743,7 +743,7 @@ public final class XSelection { } break; } - case XlibWrapper.SelectionClear: { + case XConstants.SelectionClear: { XSelectionClearEvent xsce = ev.get_xselectionclear(); long atom = xsce.get_selection(); XSelection selection = XSelection.getSelection(XAtom.get(atom)); @@ -793,7 +793,7 @@ public final class XSelection { wattr.pData); XlibWrapper.XSelectInput(XToolkit.getDisplay(), requestor, wattr.get_your_event_mask() | - XlibWrapper.PropertyChangeMask); + XConstants.PropertyChangeMask); } finally { XToolkit.awtUnlock(); } @@ -805,10 +805,10 @@ public final class XSelection { public void dispatchEvent(XEvent ev) { switch (ev.get_type()) { - case XlibWrapper.PropertyNotify: + case XConstants.PropertyNotify: XPropertyEvent xpe = ev.get_xproperty(); if (xpe.get_window() == requestor && - xpe.get_state() == XlibWrapper.PropertyDelete && + xpe.get_state() == XConstants.PropertyDelete && xpe.get_atom() == property) { int count = data.length - offset; @@ -834,7 +834,7 @@ public final class XSelection { XlibWrapper.XChangeProperty(XToolkit.getDisplay(), requestor, property, target, format, - XlibWrapper.PropModeReplace, + XConstants.PropModeReplace, nativeDataPtr, count); } finally { XToolkit.awtUnlock(); @@ -853,9 +853,9 @@ public final class XSelection { private static class IncrementalTransferHandler implements XEventDispatcher { public void dispatchEvent(XEvent ev) { switch (ev.get_type()) { - case XlibWrapper.PropertyNotify: + case XConstants.PropertyNotify: XPropertyEvent xpe = ev.get_xproperty(); - if (xpe.get_state() == XlibWrapper.PropertyNewValue && + if (xpe.get_state() == XConstants.PropertyNewValue && xpe.get_atom() == selectionPropertyAtom.getAtom()) { XToolkit.awtLock(); try { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java index fa09a6f862c..83ba45ccbe8 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,7 +131,7 @@ public class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListener { XClientMessageEvent xev = new XClientMessageEvent(); try { - xev.set_type(XlibWrapper.ClientMessage); + xev.set_type(XConstants.ClientMessage); xev.set_window(win); xev.set_format(32); xev.set_message_type(_NET_SYSTEM_TRAY_OPCODE.getAtom()); @@ -144,7 +144,7 @@ public class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListener { XToolkit.awtLock(); try { XlibWrapper.XSendEvent(XToolkit.getDisplay(), win, false, - XlibWrapper.NoEventMask, xev.pData); + XConstants.NoEventMask, xev.pData); } finally { XToolkit.awtUnlock(); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index 069568519d8..871f99368b6 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -54,8 +54,7 @@ import sun.font.FontManager; import sun.misc.PerformanceLogger; import sun.print.PrintJob2D; -public final class XToolkit extends UNIXToolkit implements Runnable, XConstants -{ +public final class XToolkit extends UNIXToolkit implements Runnable { private static Logger log = Logger.getLogger("sun.awt.X11.XToolkit"); private static Logger eventLog = Logger.getLogger("sun.awt.X11.event.XToolkit"); private static final Logger timeoutTaskLog = Logger.getLogger("sun.awt.X11.timeoutTask.XToolkit"); @@ -169,7 +168,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants static XErrorHandler IgnoreBadWindowHandler = new XErrorHandler() { public int handleError(long display, XErrorEvent err) { XERROR_SAVE(err); - if (err.get_error_code() == BadWindow) { + if (err.get_error_code() == XConstants.BadWindow) { return 0; } else { return SAVED_ERROR_HANDLER(display, err); @@ -425,7 +424,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants // Only our windows guaranteely generate MotionNotify, so we // should track enter/leave, to catch the moment when to // switch to XQueryPointer - if (e.get_type() == MotionNotify) { + if (e.get_type() == XConstants.MotionNotify) { XMotionEvent ev = e.get_xmotion(); awtLock(); try { @@ -437,7 +436,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants } finally { awtUnlock(); } - } else if (e.get_type() == LeaveNotify) { + } else if (e.get_type() == XConstants.LeaveNotify) { // Leave from our window awtLock(); try { @@ -445,7 +444,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants } finally { awtUnlock(); } - } else if (e.get_type() == EnterNotify) { + } else if (e.get_type() == XConstants.EnterNotify) { // Entrance into our window XCrossingEvent ev = e.get_xcrossing(); awtLock(); @@ -492,7 +491,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants final XAnyEvent xany = ev.get_xany(); if (windowToXWindow(xany.get_window()) != null && - (ev.get_type() == MotionNotify || ev.get_type() == EnterNotify || ev.get_type() == LeaveNotify)) + (ev.get_type() == XConstants.MotionNotify || ev.get_type() == XConstants.EnterNotify || ev.get_type() == XConstants.LeaveNotify)) { processGlobalMotionEvent(ev); } @@ -549,15 +548,15 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants // If no events are queued, waitForEvents() causes calls to // awtUnlock(), awtJNI_ThreadYield, poll, awtLock(), // so it spends most of its time in poll, without holding the lock. - while ((XlibWrapper.XEventsQueued(getDisplay(), XlibWrapper.QueuedAfterReading) == 0) && - (XlibWrapper.XEventsQueued(getDisplay(), XlibWrapper.QueuedAfterFlush) == 0)) { + while ((XlibWrapper.XEventsQueued(getDisplay(), XConstants.QueuedAfterReading) == 0) && + (XlibWrapper.XEventsQueued(getDisplay(), XConstants.QueuedAfterFlush) == 0)) { callTimeoutTasks(); waitForEvents(getNextTaskTime()); } XlibWrapper.XNextEvent(getDisplay(),ev.pData); } - if (ev.get_type() != NoExpose) { + if (ev.get_type() != XConstants.NoExpose) { eventNumber++; } @@ -582,13 +581,13 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants } } } - if( keyEventLog.isLoggable(Level.FINE) && (ev.get_type() == KeyPress || ev.get_type() == KeyRelease) ) { + if( keyEventLog.isLoggable(Level.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) { keyEventLog.fine("before XFilterEvent:"+ev); } if (XlibWrapper.XFilterEvent(ev.getPData(), w)) { continue; } - if( keyEventLog.isLoggable(Level.FINE) && (ev.get_type() == KeyPress || ev.get_type() == KeyRelease) ) { + if( keyEventLog.isLoggable(Level.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) { keyEventLog.fine("after XFilterEvent:"+ev); // IS THIS CORRECT? } @@ -750,7 +749,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants * _NET_WM_STRUT[_PARTIAL] hints for iconified windows * are not included to the screen insets. */ - if (XlibUtil.getWindowMapState(window) == XlibWrapper.IsUnmapped) + if (XlibUtil.getWindowMapState(window) == XConstants.IsUnmapped) { continue; } @@ -1289,7 +1288,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants new XEventDispatcher() { public void dispatchEvent(XEvent ev) { switch (ev.get_type()) { - case PropertyNotify: + case XConstants.PropertyNotify: XPropertyEvent xpe = ev.get_xproperty(); awtLock(); @@ -1322,7 +1321,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants XlibWrapper.XChangeProperty(XToolkit.getDisplay(), XBaseWindow.getXAWTRootWindow().getWindow(), _XA_JAVA_TIME_PROPERTY_ATOM.getAtom(), XAtom.XA_ATOM, 32, - PropModeAppend, + XConstants.PropModeAppend, 0, 0); XlibWrapper.XFlush(XToolkit.getDisplay()); @@ -1539,8 +1538,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants final int shiftLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Shift_Lock); final int capsLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Caps_Lock); - final int modmask[] = { ShiftMask, LockMask, ControlMask, Mod1Mask, - Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask }; + final int modmask[] = { XConstants.ShiftMask, XConstants.LockMask, XConstants.ControlMask, XConstants.Mod1Mask, + XConstants.Mod2Mask, XConstants.Mod3Mask, XConstants.Mod4Mask, XConstants.Mod5Mask }; log.fine("In setupModifierMap"); awtLock(); @@ -2047,7 +2046,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants if (oops_waiter == null) { oops_waiter = new XEventDispatcher() { public void dispatchEvent(XEvent e) { - if (e.get_type() == SelectionNotify) { + if (e.get_type() == XConstants.SelectionNotify) { XSelectionEvent pe = e.get_xselection(); if (pe.get_property() == oops.getAtom()) { oops_updated = true; @@ -2083,7 +2082,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable, XConstants eventLog.log(Level.FINER, "WM_S0 selection owner {0}", new Object[] {XlibWrapper.XGetSelectionOwner(getDisplay(), atom.getAtom())}); XlibWrapper.XConvertSelection(getDisplay(), atom.getAtom(), XAtom.get("VERSION").getAtom(), oops.getAtom(), - win.getWindow(), XlibWrapper.CurrentTime); + win.getWindow(), XConstants.CurrentTime); XSync(); diff --git a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java index e3bfacb4353..ff690bf9d06 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java @@ -98,7 +98,7 @@ public class XTrayIconPeer implements TrayIconPeer { parentXED = new XEventDispatcher() { // It's executed under AWTLock. public void dispatchEvent(XEvent ev) { - if (isDisposed() || ev.get_type() != XlibWrapper.ConfigureNotify) { + if (isDisposed() || ev.get_type() != XConstants.ConfigureNotify) { return; } @@ -194,7 +194,7 @@ public class XTrayIconPeer implements TrayIconPeer { XTrayIconPeer xtiPeer = XTrayIconPeer.this; public void dispatchEvent(XEvent ev) { - if (isDisposed() || ev.get_type() != XlibWrapper.ReparentNotify) { + if (isDisposed() || ev.get_type() != XConstants.ReparentNotify) { return; } @@ -214,7 +214,7 @@ public class XTrayIconPeer implements TrayIconPeer { } if (!isTrayIconDisplayed) { - addXED(eframeParentID, parentXED, XlibWrapper.StructureNotifyMask); + addXED(eframeParentID, parentXED, XConstants.StructureNotifyMask); isTrayIconDisplayed = true; XToolkit.awtLockNotifyAll(); @@ -222,7 +222,7 @@ public class XTrayIconPeer implements TrayIconPeer { } }; - addXED(getWindow(), eframeXED, XlibWrapper.StructureNotifyMask); + addXED(getWindow(), eframeXED, XConstants.StructureNotifyMask); XSystemTrayPeer.getPeerInstance().addTrayIcon(this); // throws AWTException diff --git a/jdk/src/solaris/classes/sun/awt/X11/XUtilConstants.java b/jdk/src/solaris/classes/sun/awt/X11/XUtilConstants.java index 9b15fc079ba..048ab113439 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XUtilConstants.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XUtilConstants.java @@ -1,5 +1,5 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,10 @@ package sun.awt.X11; -public interface XUtilConstants { +final public class XUtilConstants { + + private XUtilConstants(){} + /* * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding * value (x, y, width, height) was found in the parsed string. diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWINProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XWINProtocol.java index 94465466950..83b676a1a60 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWINProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWINProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,7 @@ class XWINProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { } XClientMessageEvent req = new XClientMessageEvent(); - req.set_type(XlibWrapper.ClientMessage); + req.set_type(XConstants.ClientMessage); req.set_window(window.getWindow()); req.set_message_type(XA_WIN_STATE.getAtom()); req.set_format(32); @@ -71,7 +71,7 @@ class XWINProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()), false, - XlibWrapper.SubstructureRedirectMask | XlibWrapper.SubstructureNotifyMask, + XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, req.pData); } finally { @@ -150,7 +150,7 @@ class XWINProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { public void setLayer(XWindowPeer window, int layer) { if (window.isShowing()) { XClientMessageEvent req = new XClientMessageEvent(); - req.set_type(XlibWrapper.ClientMessage); + req.set_type(XConstants.ClientMessage); req.set_window(window.getWindow()); req.set_message_type(XA_WIN_LAYER.getAtom()); req.set_format(32); @@ -164,7 +164,7 @@ class XWINProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()), false, - /*XlibWrapper.SubstructureRedirectMask | */XlibWrapper.SubstructureNotifyMask, + /*XConstants.SubstructureRedirectMask | */XConstants.SubstructureNotifyMask, req.pData); } finally { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWM.java b/jdk/src/solaris/classes/sun/awt/X11/XWM.java index d8e0d6b031d..c3adec9aa02 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWM.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWM.java @@ -46,7 +46,7 @@ import java.util.regex.Pattern; * Class incapsulating knowledge about window managers in general * Descendants should provide some information about specific window manager. */ -final class XWM implements MWMConstants, XUtilConstants +final class XWM { private final static Logger log = Logger.getLogger("sun.awt.X11.XWM"); @@ -274,12 +274,12 @@ final class XWM implements MWMConstants, XUtilConstants } winmgr_running = false; - substruct.set_event_mask(XlibWrapper.SubstructureRedirectMask); + substruct.set_event_mask(XConstants.SubstructureRedirectMask); XToolkit.WITH_XERROR_HANDLER(DetectWMHandler); XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), - XlibWrapper.CWEventMask, + XConstants.CWEventMask, substruct.pData); XToolkit.RESTORE_XERROR_HANDLER(); @@ -291,7 +291,7 @@ final class XWM implements MWMConstants, XUtilConstants substruct.set_event_mask(0); XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), - XlibWrapper.CWEventMask, + XConstants.CWEventMask, substruct.pData); if (insLog.isLoggable(Level.FINE)) { insLog.finer("It looks like there is no WM thus NO_WM"); @@ -322,7 +322,7 @@ final class XWM implements MWMConstants, XUtilConstants XAtom.XA_STRING); try { int status = getter.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { return 0; } @@ -411,7 +411,7 @@ final class XWM implements MWMConstants, XUtilConstants false, XA_DT_SM_WINDOW_INFO); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { log.finer("Getting of _DT_SM_WINDOW_INFO is not successfull"); return false; } @@ -442,7 +442,7 @@ final class XWM implements MWMConstants, XUtilConstants status = getter2.execute(XToolkit.IgnoreBadWindowHandler); - if (status != XlibWrapper.Success || getter2.getData() == 0) { + if (status != XConstants.Success || getter2.getData() == 0) { log.finer("Getting of _DT_SM_STATE_INFO is not successfull"); return false; } @@ -480,18 +480,18 @@ final class XWM implements MWMConstants, XUtilConstants WindowPropertyGetter getter = new WindowPropertyGetter(XToolkit.getDefaultRootWindow(), XA_MOTIF_WM_INFO, 0, - PROP_MOTIF_WM_INFO_ELEMENTS, + MWMConstants.PROP_MOTIF_WM_INFO_ELEMENTS, false, XA_MOTIF_WM_INFO); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { + if (status != XConstants.Success || getter.getData() == 0) { return false; } if (getter.getActualType() != XA_MOTIF_WM_INFO.getAtom() || getter.getActualFormat() != 32 - || getter.getNumberOfItems() != PROP_MOTIF_WM_INFO_ELEMENTS + || getter.getNumberOfItems() != MWMConstants.PROP_MOTIF_WM_INFO_ELEMENTS || getter.getBytesAfter() != 0) { return false; @@ -516,7 +516,7 @@ final class XWM implements MWMConstants, XUtilConstants 0, 1, false, XA_WM_STATE); try { - if (state_getter.execute() == XlibWrapper.Success && + if (state_getter.execute() == XConstants.Success && state_getter.getData() != 0 && state_getter.getActualType() == XA_WM_STATE.getAtom()) { @@ -577,7 +577,7 @@ final class XWM implements MWMConstants, XUtilConstants static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() { public int handleError(long display, XErrorEvent err) { XToolkit.XERROR_SAVE(err); - if (err.get_request_code() == XlibWrapper.X_ChangeProperty) { + if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) { return 0; } else { return XToolkit.SAVED_ERROR_HANDLER(display, err); @@ -621,11 +621,11 @@ final class XWM implements MWMConstants, XUtilConstants XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), XA_ICEWM_WINOPTHINT.getAtom(), XA_ICEWM_WINOPTHINT.getAtom(), - 8, XlibWrapper.PropModeReplace, + 8, XConstants.PropModeReplace, new String(opt)); XToolkit.RESTORE_XERROR_HANDLER(); - if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { + if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != XConstants.Success) { log.finer("Erorr getting XA_ICEWM_WINOPTHINT property"); return false; } @@ -654,7 +654,7 @@ final class XWM implements MWMConstants, XUtilConstants true, XA_ICEWM_WINOPTHINT); try { int status = getter.execute(); - boolean res = (status == XlibWrapper.Success && getter.getActualType() != 0); + boolean res = (status == XConstants.Success && getter.getActualType() != 0); log.finer("Status getting XA_ICEWM_WINOPTHINT: " + !res); return !res || isNetWMName("IceWM"); } finally { @@ -686,8 +686,8 @@ final class XWM implements MWMConstants, XUtilConstants static XToolkit.XErrorHandler DetectWMHandler = new XToolkit.XErrorHandler() { public int handleError(long display, XErrorEvent err) { XToolkit.XERROR_SAVE(err); - if (err.get_request_code() == XlibWrapper.X_ChangeWindowAttributes - && err.get_error_code() == XlibWrapper.BadAccess) + if (err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes + && err.get_error_code() == XConstants.BadAccess) { winmgr_running = true; return 0; @@ -804,7 +804,7 @@ final class XWM implements MWMConstants, XUtilConstants * XXX: Why do we need this in the first place??? */ static void removeSizeHints(XDecoratedPeer window, long mask) { - mask &= PMaxSize | PMinSize; + mask &= XUtilConstants.PMaxSize | XUtilConstants.PMinSize; XToolkit.awtLock(); try { @@ -830,13 +830,13 @@ final class XWM implements MWMConstants, XUtilConstants * rest of the code. */ static int normalizeMotifDecor(int decorations) { - if ((decorations & MWM_DECOR_ALL) == 0) { + if ((decorations & MWMConstants.MWM_DECOR_ALL) == 0) { return decorations; } - int d = MWM_DECOR_BORDER | MWM_DECOR_RESIZEH - | MWM_DECOR_TITLE - | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE - | MWM_DECOR_MAXIMIZE; + int d = MWMConstants.MWM_DECOR_BORDER | MWMConstants.MWM_DECOR_RESIZEH + | MWMConstants.MWM_DECOR_TITLE + | MWMConstants.MWM_DECOR_MENU | MWMConstants.MWM_DECOR_MINIMIZE + | MWMConstants.MWM_DECOR_MAXIMIZE; d &= ~decorations; return d; } @@ -848,14 +848,14 @@ final class XWM implements MWMConstants, XUtilConstants * rest of the code. */ static int normalizeMotifFunc(int functions) { - if ((functions & MWM_FUNC_ALL) == 0) { + if ((functions & MWMConstants.MWM_FUNC_ALL) == 0) { return functions; } - int f = MWM_FUNC_RESIZE | - MWM_FUNC_MOVE | - MWM_FUNC_MAXIMIZE | - MWM_FUNC_MINIMIZE | - MWM_FUNC_CLOSE; + int f = MWMConstants.MWM_FUNC_RESIZE | + MWMConstants.MWM_FUNC_MOVE | + MWMConstants.MWM_FUNC_MAXIMIZE | + MWMConstants.MWM_FUNC_MINIMIZE | + MWMConstants.MWM_FUNC_CLOSE; f &= ~functions; return f; } @@ -872,15 +872,15 @@ final class XWM implements MWMConstants, XUtilConstants XAtomList decorDel = new XAtomList(); decorations = normalizeMotifDecor(decorations); if (insLog.isLoggable(Level.FINER)) insLog.finer("Setting OL_DECOR to " + Integer.toBinaryString(decorations)); - if ((decorations & MWM_DECOR_TITLE) == 0) { + if ((decorations & MWMConstants.MWM_DECOR_TITLE) == 0) { decorDel.add(XA_OL_DECOR_HEADER); } - if ((decorations & (MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE)) == 0) { + if ((decorations & (MWMConstants.MWM_DECOR_RESIZEH | MWMConstants.MWM_DECOR_MAXIMIZE)) == 0) { decorDel.add(XA_OL_DECOR_RESIZE); } - if ((decorations & (MWM_DECOR_MENU | - MWM_DECOR_MAXIMIZE | - MWM_DECOR_MINIMIZE)) == 0) + if ((decorations & (MWMConstants.MWM_DECOR_MENU | + MWMConstants.MWM_DECOR_MAXIMIZE | + MWMConstants.MWM_DECOR_MINIMIZE)) == 0) { decorDel.add(XA_OL_DECOR_CLOSE); } @@ -898,19 +898,21 @@ final class XWM implements MWMConstants, XUtilConstants */ static void setMotifDecor(XWindowPeer window, boolean resizable, int decorations, int functions) { /* Apparently some WMs don't implement MWM_*_ALL semantic correctly */ - if ((decorations & MWM_DECOR_ALL) != 0 - && (decorations != MWM_DECOR_ALL)) + if ((decorations & MWMConstants.MWM_DECOR_ALL) != 0 + && (decorations != MWMConstants.MWM_DECOR_ALL)) { decorations = normalizeMotifDecor(decorations); } - if ((functions & MWM_FUNC_ALL) != 0 - && (functions != MWM_FUNC_ALL)) + if ((functions & MWMConstants.MWM_FUNC_ALL) != 0 + && (functions != MWMConstants.MWM_FUNC_ALL)) { functions = normalizeMotifFunc(functions); } PropMwmHints hints = window.getMWMHints(); - hints.set_flags(hints.get_flags() | MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS); + hints.set_flags(hints.get_flags() | + MWMConstants.MWM_HINTS_FUNCTIONS | + MWMConstants.MWM_HINTS_DECORATIONS); hints.set_functions(functions); hints.set_decorations(decorations); @@ -950,10 +952,10 @@ final class XWM implements MWMConstants, XUtilConstants boolean resizable = window.isResizable(); if (!resizable) { - if ((decorations & MWM_DECOR_ALL) != 0) { - decorations |= MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE; + if ((decorations & MWMConstants.MWM_DECOR_ALL) != 0) { + decorations |= MWMConstants.MWM_DECOR_RESIZEH | MWMConstants.MWM_DECOR_MAXIMIZE; } else { - decorations &= ~(MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE); + decorations &= ~(MWMConstants.MWM_DECOR_RESIZEH | MWMConstants.MWM_DECOR_MAXIMIZE); } } setMotifDecor(window, resizable, decorations, functions); @@ -988,7 +990,7 @@ final class XWM implements MWMConstants, XUtilConstants /* REMINDER: will need to revisit when setExtendedStateBounds is added */ //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced. //We need to update frame's minimum size, not to reset it - removeSizeHints(window, PMaxSize); + removeSizeHints(window, XUtilConstants.PMaxSize); window.updateMinimumSize(); /* Restore decorations */ @@ -1134,7 +1136,7 @@ final class XWM implements MWMConstants, XUtilConstants } int wm_state = window.getWMState(); - if (wm_state == XlibWrapper.WithdrawnState) { + if (wm_state == XUtilConstants.WithdrawnState) { stateLog.finer("WithdrawnState"); return false; } else { @@ -1158,7 +1160,7 @@ final class XWM implements MWMConstants, XUtilConstants int getState(XDecoratedPeer window) { int res = 0; final int wm_state = window.getWMState(); - if (wm_state == XlibWrapper.IconicState) { + if (wm_state == XUtilConstants.IconicState) { res = Frame.ICONIFIED; } else { res = Frame.NORMAL; @@ -1397,7 +1399,7 @@ final class XWM implements MWMConstants, XUtilConstants new WindowPropertyGetter(window, atom, 0, 4, false, XAtom.XA_CARDINAL); try { - if (getter.execute() != XlibWrapper.Success + if (getter.execute() != XConstants.Success || getter.getData() == 0 || getter.getActualType() != XAtom.XA_CARDINAL || getter.getActualFormat() != 32) @@ -1426,7 +1428,7 @@ final class XWM implements MWMConstants, XUtilConstants XClientMessageEvent msg = new XClientMessageEvent(); msg.zero(); - msg.set_type(XlibWrapper.ClientMessage); + msg.set_type(XConstants.ClientMessage); msg.set_display(XToolkit.getDisplay()); msg.set_window(window); msg.set_format(32); @@ -1436,13 +1438,15 @@ final class XWM implements MWMConstants, XUtilConstants if (net_protocol != null && net_protocol.active()) { msg.set_message_type(XA_NET_REQUEST_FRAME_EXTENTS.getAtom()); XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), - false, XlibWrapper.SubstructureRedirectMask | XlibWrapper.SubstructureNotifyMask, + false, + XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, msg.getPData()); } if (getWMID() == XWM.KDE2_WM) { msg.set_message_type(XA_KDE_NET_WM_FRAME_STRUT.getAtom()); XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), - false, XlibWrapper.SubstructureRedirectMask | XlibWrapper.SubstructureNotifyMask, + false, + XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, msg.getPData()); } // XXX: should we wait for response? XIfEvent() would be useful here :) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java index 2d55ef889fb..f7ef09b2e11 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java @@ -178,10 +178,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { AwtGraphicsConfigData gData = getGraphicsConfigurationData(); X11GraphicsConfig config = (X11GraphicsConfig) getGraphicsConfiguration(); XVisualInfo visInfo = gData.get_awt_visInfo(); - params.putIfNull(EVENT_MASK, KeyPressMask | KeyReleaseMask - | FocusChangeMask | ButtonPressMask | ButtonReleaseMask - | EnterWindowMask | LeaveWindowMask | PointerMotionMask - | ButtonMotionMask | ExposureMask | StructureNotifyMask); + params.putIfNull(EVENT_MASK, XConstants.KeyPressMask | XConstants.KeyReleaseMask + | XConstants.FocusChangeMask | XConstants.ButtonPressMask | XConstants.ButtonReleaseMask + | XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask + | XConstants.ButtonMotionMask | XConstants.ExposureMask | XConstants.StructureNotifyMask); if (target != null) { params.putIfNull(BOUNDS, target.getBounds()); @@ -192,9 +192,9 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { getColorModel(); // fix 4948833: this call forces the color map to be initialized params.putIfNull(COLORMAP, gData.get_awt_cmap()); params.putIfNull(DEPTH, gData.get_awt_depth()); - params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XlibWrapper.InputOutput)); + params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOutput)); params.putIfNull(VISUAL, visInfo.get_visual()); - params.putIfNull(VALUE_MASK, XlibWrapper.CWBorderPixel | XlibWrapper.CWEventMask | XlibWrapper.CWColormap); + params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap); Long parentWindow = (Long)params.get(PARENT_WINDOW); if (parentWindow == null || parentWindow.longValue() == 0) { XToolkit.awtLock(); @@ -553,10 +553,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { static int getModifiers(int state, int button, int keyCode) { int modifiers = 0; - if (((state & XlibWrapper.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) { + if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) { modifiers |= InputEvent.SHIFT_DOWN_MASK; } - if (((state & XlibWrapper.ControlMask) != 0) ^ (keyCode == KeyEvent.VK_CONTROL)) { + if (((state & XConstants.ControlMask) != 0) ^ (keyCode == KeyEvent.VK_CONTROL)) { modifiers |= InputEvent.CTRL_DOWN_MASK; } if (((state & XToolkit.metaMask) != 0) ^ (keyCode == KeyEvent.VK_META)) { @@ -568,13 +568,13 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { if (((state & XToolkit.modeSwitchMask) != 0) ^ (keyCode == KeyEvent.VK_ALT_GRAPH)) { modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK; } - if (((state & XlibWrapper.Button1Mask) != 0) ^ (button == MouseEvent.BUTTON1)) { + if (((state & XConstants.Button1Mask) != 0) ^ (button == MouseEvent.BUTTON1)) { modifiers |= InputEvent.BUTTON1_DOWN_MASK; } - if (((state & XlibWrapper.Button2Mask) != 0) ^ (button == MouseEvent.BUTTON2)) { + if (((state & XConstants.Button2Mask) != 0) ^ (button == MouseEvent.BUTTON2)) { modifiers |= InputEvent.BUTTON2_DOWN_MASK; } - if (((state & XlibWrapper.Button3Mask) != 0) ^ (button == MouseEvent.BUTTON3)) { + if (((state & XConstants.Button3Mask) != 0) ^ (button == MouseEvent.BUTTON3)) { modifiers |= InputEvent.BUTTON3_DOWN_MASK; } return modifiers; @@ -584,10 +584,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { int mods = stroke.getModifiers(); int res = 0; if ((mods & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) { - res |= XToolkit.ShiftMask; + res |= XConstants.ShiftMask; } if ((mods & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) { - res |= XToolkit.ControlMask; + res |= XConstants.ControlMask; } if ((mods & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) { res |= XToolkit.altMask; @@ -602,12 +602,12 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } private static int getButtonMask(long mouseButton) { - if (mouseButton == XlibWrapper.Button1) { - return XlibWrapper.Button1Mask; - } else if (mouseButton == XlibWrapper.Button2) { - return XlibWrapper.Button2Mask; - } else if (mouseButton == XlibWrapper.Button3) { - return XlibWrapper.Button3Mask; + if (mouseButton == XConstants.Button1) { + return XConstants.Button1Mask; + } else if (mouseButton == XConstants.Button2) { + return XConstants.Button2Mask; + } else if (mouseButton == XConstants.Button3) { + return XConstants.Button3Mask; } return 0; } @@ -659,7 +659,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { y = localXY.y; } - if (type == XlibWrapper.ButtonPress) { + if (type == XConstants.ButtonPress) { XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null); /* multiclick checking @@ -689,16 +689,16 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } } - if (lbutton == XlibWrapper.Button1) + if (lbutton == XConstants.Button1) button = MouseEvent.BUTTON1; - else if (lbutton == XlibWrapper.Button2 ) + else if (lbutton == XConstants.Button2 ) button = MouseEvent.BUTTON2; - else if (lbutton == XlibWrapper.Button3) + else if (lbutton == XConstants.Button3) button = MouseEvent.BUTTON3; - else if (lbutton == XlibWrapper.Button4) { + else if (lbutton == XConstants.Button4) { button = 4; wheel_mouse = true; - } else if (lbutton == XlibWrapper.Button5) { + } else if (lbutton == XConstants.Button5) { button = 5; wheel_mouse = true; } @@ -707,7 +707,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { if (!wheel_mouse) { MouseEvent me = new MouseEvent((Component)getEventSource(), - type == XlibWrapper.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED, + type == XConstants.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED, jWhen,modifiers, x, y, xbe.get_x_root(), xbe.get_y_root(), @@ -716,7 +716,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { postEventToEventQueue(me); if (((mouseDragState & getButtonMask(lbutton)) == 0) && // No up-button in the drag-state - (type == XlibWrapper.ButtonRelease)) + (type == XConstants.ButtonRelease)) { postEventToEventQueue(me = new MouseEvent((Component)getEventSource(), MouseEvent.MOUSE_CLICKED, @@ -731,7 +731,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } else { - if (xev.get_type() == XlibWrapper.ButtonPress) { + if (xev.get_type() == XConstants.ButtonPress) { MouseWheelEvent mwe = new MouseWheelEvent((Component)getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen, modifiers, x, y, @@ -753,7 +753,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { return; } - int mouseKeyState = (xme.get_state() & (Button1Mask | Button2Mask | Button3Mask)); + int mouseKeyState = (xme.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask | XConstants.Button3Mask)); boolean isDragging = (mouseKeyState != 0); int mouseEventType = 0; @@ -823,10 +823,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { // accordingly. This leads to impossibility to make a double click on Component (6404708) XWindowPeer toplevel = getToplevelXWindow(); if (toplevel != null && !toplevel.isModalBlocked()){ - if (xce.get_mode() != NotifyNormal) { + if (xce.get_mode() != XConstants.NotifyNormal) { // 6404708 : need update cursor in accordance with skipping Leave/EnterNotify event // whereas it doesn't need to handled further. - if (xce.get_type() == EnterNotify) { + if (xce.get_type() == XConstants.EnterNotify) { XAwtState.setComponentMouseEntered(getEventSource()); XGlobalCursorManager.nativeUpdateCursor(getEventSource()); } else { // LeaveNotify: @@ -840,7 +840,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { // From java point the event is bogus as ancestor is obscured, so if // the child can get java event itself, we skip it on ancestor. long childWnd = xce.get_subwindow(); - if (childWnd != None) { + if (childWnd != XConstants.None) { XBaseWindow child = XToolkit.windowToXWindow(childWnd); if (child != null && child instanceof XWindow && !child.isEventDisabled(xev)) @@ -853,7 +853,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { final Component compWithMouse = XAwtState.getComponentMouseEntered(); if (toplevel != null) { if(!toplevel.isModalBlocked()){ - if (xce.get_type() == EnterNotify) { + if (xce.get_type() == XConstants.EnterNotify) { // Change XAwtState's component mouse entered to the up-to-date one before requesting // to update the cursor since XAwtState.getComponentMouseEntered() is used when the // cursor is updated (in XGlobalCursorManager.findHeavyweightUnderCursor()). @@ -895,7 +895,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { eventLog.finest("Clearing last window ref"); lastWindowRef = null; } - if (xce.get_type() == EnterNotify) { + if (xce.get_type() == XConstants.EnterNotify) { MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED, jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, popupTrigger, MouseEvent.NOBUTTON); @@ -990,7 +990,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { final void handleKeyPress(XKeyEvent ev) { long keysym[] = new long[2]; char unicodeKey = 0; - keysym[0] = NoSymbol; + keysym[0] = XConstants.NoSymbol; if (keyEventLog.isLoggable(Level.FINE)) { logIncomingKeyEvent( ev ); @@ -1073,7 +1073,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { private void handleKeyRelease(XKeyEvent ev) { long keysym[] = new long[2]; char unicodeKey = 0; - keysym[0] = NoSymbol; + keysym[0] = XConstants.NoSymbol; if (keyEventLog.isLoggable(Level.FINE)) { logIncomingKeyEvent( ev ); @@ -1153,10 +1153,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } void updateSizeHints(int x, int y, int width, int height) { - long flags = XlibWrapper.PSize | (isLocationByPlatform() ? 0 : (XlibWrapper.PPosition | XlibWrapper.USPosition)); + long flags = XUtilConstants.PSize | (isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition)); if (!isResizable()) { log.log(Level.FINER, "Window {0} is not resizable", new Object[] {this}); - flags |= XlibWrapper.PMinSize | XlibWrapper.PMaxSize; + flags |= XUtilConstants.PMinSize | XUtilConstants.PMaxSize; } else { log.log(Level.FINER, "Window {0} is resizable", new Object[] {this}); } @@ -1164,10 +1164,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } void updateSizeHints(int x, int y) { - long flags = isLocationByPlatform() ? 0 : (XlibWrapper.PPosition | XlibWrapper.USPosition); + long flags = isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition); if (!isResizable()) { log.log(Level.FINER, "Window {0} is not resizable", new Object[] {this}); - flags |= XlibWrapper.PMinSize | XlibWrapper.PMaxSize | XlibWrapper.PSize; + flags |= XUtilConstants.PMinSize | XUtilConstants.PMaxSize | XUtilConstants.PSize; } else { log.log(Level.FINER, "Window {0} is resizable", new Object[] {this}); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java index c5fc7e1a7d4..2222163b4ab 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java @@ -50,7 +50,7 @@ import sun.awt.X11GraphicsDevice; import sun.awt.X11GraphicsEnvironment; class XWindowPeer extends XPanelPeer implements WindowPeer, - DisplayChangedListener, MWMConstants { + DisplayChangedListener { private static final Logger log = Logger.getLogger("sun.awt.X11.XWindowPeer"); private static final Logger focusLog = Logger.getLogger("sun.awt.X11.focus.XWindowPeer"); @@ -133,9 +133,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, params.put(REPARENTED, Boolean.valueOf(isOverrideRedirect() || isSimpleWindow())); super.preInit(params); - params.putIfNull(BIT_GRAVITY, Integer.valueOf(NorthWestGravity)); + params.putIfNull(BIT_GRAVITY, Integer.valueOf(XConstants.NorthWestGravity)); - savedState = WithdrawnState; + savedState = XUtilConstants.WithdrawnState; XA_NET_WM_STATE = XAtom.get("_NET_WM_STATE"); winAttr = new XWindowAttributesData(); @@ -239,7 +239,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, // Set group leader XWMHints hints = getWMHints(); - hints.set_flags(hints.get_flags() | (int)XlibWrapper.WindowGroupHint); + hints.set_flags(hints.get_flags() | (int)XUtilConstants.WindowGroupHint); hints.set_window_group(ownerWindow); XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData); } @@ -503,7 +503,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, Rectangle bounds = getBounds(); XSizeHints hints = getHints(); - setSizeHints(hints.get_flags() | XlibWrapper.PPosition | XlibWrapper.PSize, + setSizeHints(hints.get_flags() | XUtilConstants.PPosition | XUtilConstants.PSize, bounds.x, bounds.y, bounds.width, bounds.height); XWM.setMotifDecor(this, false, 0, 0); @@ -531,7 +531,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, XToolkit.awtLock(); try { XWMHints hints = getWMHints(); - hints.set_flags(hints.get_flags() | (int)XlibWrapper.InputHint); + hints.set_flags(hints.get_flags() | (int)XUtilConstants.InputHint); hints.set_input(false/*isNativelyNonFocusableWindow() ? (0):(1)*/); XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData); } @@ -821,12 +821,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, if (isEventDisabled(xev)) { return; } - if (xev.get_type() == XlibWrapper.FocusIn) + if (xev.get_type() == XConstants.FocusIn) { // If this window is non-focusable don't post any java focus event if (focusAllowedFor()) { - if (xfe.get_mode() == XlibWrapper.NotifyNormal // Normal notify - || xfe.get_mode() == XlibWrapper.NotifyWhileGrabbed) // Alt-Tab notify + if (xfe.get_mode() == XConstants.NotifyNormal // Normal notify + || xfe.get_mode() == XConstants.NotifyWhileGrabbed) // Alt-Tab notify { handleWindowFocusIn(xfe.get_serial()); } @@ -834,8 +834,8 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, } else { - if (xfe.get_mode() == XlibWrapper.NotifyNormal // Normal notify - || xfe.get_mode() == XlibWrapper.NotifyWhileGrabbed) // Alt-Tab notify + if (xfe.get_mode() == XConstants.NotifyNormal // Normal notify + || xfe.get_mode() == XConstants.NotifyWhileGrabbed) // Alt-Tab notify { // If this window is non-focusable don't post any java focus event if (!isNativelyNonFocusableWindow()) { @@ -1022,7 +1022,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, try { Rectangle bounds = getBounds(); XSizeHints hints = getHints(); - setSizeHints(hints.get_flags() & ~(USPosition | PPosition), + setSizeHints(hints.get_flags() & ~(XUtilConstants.USPosition | XUtilConstants.PPosition), bounds.x, bounds.y, bounds.width, bounds.height); } finally { XToolkit.awtUnlock(); @@ -1059,10 +1059,10 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, XUnmapEvent unmap = new XUnmapEvent(); unmap.set_window(window); unmap.set_event(XToolkit.getDefaultRootWindow()); - unmap.set_type((int)XlibWrapper.UnmapNotify); + unmap.set_type((int)XConstants.UnmapNotify); unmap.set_from_configure(false); XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), - false, XlibWrapper.SubstructureNotifyMask | XlibWrapper.SubstructureRedirectMask, + false, XConstants.SubstructureNotifyMask | XConstants.SubstructureRedirectMask, unmap.pData); unmap.dispose(); } @@ -1305,12 +1305,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, XWM.XA_WM_STATE); try { int status = getter.execute(); - if (status != XlibWrapper.Success || getter.getData() == 0) { - return savedState = XlibWrapper.WithdrawnState; + if (status != XConstants.Success || getter.getData() == 0) { + return savedState = XUtilConstants.WithdrawnState; } if (getter.getActualType() != XWM.XA_WM_STATE.getAtom() && getter.getActualFormat() != 32) { - return savedState = XlibWrapper.WithdrawnState; + return savedState = XUtilConstants.WithdrawnState; } savedState = (int)Native.getCard32(getter.getData()); } finally { @@ -1321,7 +1321,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, } boolean isWithdrawn() { - return getWMState() == XlibWrapper.WithdrawnState; + return getWMState() == XUtilConstants.WithdrawnState; } boolean hasDecorations(int decor) { @@ -1818,14 +1818,14 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, if( rootPropertyEventDispatcher == null ) { rootPropertyEventDispatcher = new XEventDispatcher() { public void dispatchEvent(XEvent ev) { - if( ev.get_type() == PropertyNotify ) { + if( ev.get_type() == XConstants.PropertyNotify ) { handleRootPropertyNotify( ev ); } } }; XlibWrapper.XSelectInput( XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), - XlibWrapper.PropertyChangeMask); + XConstants.PropertyChangeMask); XToolkit.addEventDispatcher(XToolkit.getDefaultRootWindow(), rootPropertyEventDispatcher); } @@ -1860,7 +1860,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, public PropMwmHints getMWMHints() { if (mwm_hints == null) { mwm_hints = new PropMwmHints(); - if (!XWM.XA_MWM_HINTS.getAtomData(getWindow(), mwm_hints.pData, PROP_MWM_HINTS_ELEMENTS)) { + if (!XWM.XA_MWM_HINTS.getAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS)) { mwm_hints.zero(); } } @@ -1870,7 +1870,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, public void setMWMHints(PropMwmHints hints) { mwm_hints = hints; if (hints != null) { - XWM.XA_MWM_HINTS.setAtomData(getWindow(), mwm_hints.pData, PROP_MWM_HINTS_ELEMENTS); + XWM.XA_MWM_HINTS.setAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS); } } @@ -1960,7 +1960,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, new Object[] {xme, isGrabbed(), containsGlobal(xme.get_x_root(), xme.get_y_root())}); } if (isGrabbed()) { - boolean dragging = (xme.get_state() & (Button1Mask | Button2Mask | Button3Mask)) != 0; + boolean dragging = (xme.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask | XConstants.Button3Mask)) != 0; // When window is grabbed, all events are dispatched to // it. Retarget them to the corresponding windows (notice // that XBaseWindow.dispatchEvent does the opposite @@ -2014,12 +2014,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, try { grabLog.log(Level.FINER, " - Grab event target {0} (press target {1})", new Object[] {target, pressTarget}); if (xbe.get_type() == XConstants.ButtonPress - && xbe.get_button() == XlibWrapper.Button1) + && xbe.get_button() == XConstants.Button1) { // need to keep it to retarget mouse release pressTarget = target; } else if (xbe.get_type() == XConstants.ButtonRelease - && xbe.get_button() == XlibWrapper.Button1 + && xbe.get_button() == XConstants.Button1 && pressTarget != target) { // during grab we do receive mouse release on different component (not on the source diff --git a/jdk/src/solaris/classes/sun/awt/X11/XlibUtil.java b/jdk/src/solaris/classes/sun/awt/X11/XlibUtil.java index b6086ef469b..bdc6e7c376e 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XlibUtil.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XlibUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -152,7 +152,7 @@ public class XlibUtil int status = xtc.execute(XToolkit.IgnoreBadWindowHandler); if ((status != 0) && ((XToolkit.saved_error == null) || - (XToolkit.saved_error.get_error_code() == XlibWrapper.Success))) + (XToolkit.saved_error.get_error_code() == XConstants.Success))) { translated = new Point(xtc.get_dest_x(), xtc.get_dest_y()); } @@ -351,7 +351,7 @@ public class XlibUtil XToolkit.RESTORE_XERROR_HANDLER(); if ((status != 0) && ((XToolkit.saved_error == null) || - (XToolkit.saved_error.get_error_code() == XlibWrapper.Success))) + (XToolkit.saved_error.get_error_code() == XConstants.Success))) { return wattr.get_map_state(); } @@ -362,7 +362,7 @@ public class XlibUtil XToolkit.awtUnlock(); } - return XlibWrapper.IsUnmapped; + return XConstants.IsUnmapped; } /** diff --git a/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java b/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java index 079f7ac8d28..50be5f54da7 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,8 +29,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import sun.misc.*; -public class XlibWrapper implements XConstants, XUtilConstants, XProtocolConstants, - XCursorFontConstants +final public class XlibWrapper { static Unsafe unsafe = Unsafe.getUnsafe(); // strange constants @@ -321,7 +320,7 @@ static native String XSetLocaleModifiers(String modifier_list); if (XPropertyCache.isCachingSupported() && XToolkit.windowToXWindow(window) != null && WindowPropertyGetter.isCacheableProperty(XAtom.get(atom)) && - mode == PropModeReplace) + mode == XConstants.PropModeReplace) { int length = (format / 8) * nelements; XPropertyCache.storeCache( @@ -585,25 +584,25 @@ static native String XSetLocaleModifiers(String modifier_list); static String hintsToString(long flags) { StringBuffer buf = new StringBuffer(); - if ((flags & PMaxSize) != 0) { + if ((flags & XUtilConstants.PMaxSize) != 0) { buf.append("PMaxSize "); } - if ((flags & PMinSize) != 0) { + if ((flags & XUtilConstants.PMinSize) != 0) { buf.append("PMinSize "); } - if ((flags & USSize) != 0) { + if ((flags & XUtilConstants.USSize) != 0) { buf.append("USSize "); } - if ((flags & USPosition) != 0) { + if ((flags & XUtilConstants.USPosition) != 0) { buf.append("USPosition "); } - if ((flags & PPosition) != 0) { + if ((flags & XUtilConstants.PPosition) != 0) { buf.append("PPosition "); } - if ((flags & PSize) != 0) { + if ((flags & XUtilConstants.PSize) != 0) { buf.append("PSize "); } - if ((flags & PWinGravity) != 0) { + if ((flags & XUtilConstants.PWinGravity) != 0) { buf.append("PWinGravity "); } return buf.toString(); From bfbfdfa4289ac351182ed2a643b110ef68b2b60a Mon Sep 17 00:00:00 2001 From: Chuck Rasbold Date: Mon, 7 Apr 2008 15:15:16 -0700 Subject: [PATCH 031/119] 6663908: NegativeArraySizeException is not thrown Don't optimize zero length array allocations at compile time. Reviewed-by: kvn, never --- hotspot/src/share/vm/opto/parse3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/opto/parse3.cpp b/hotspot/src/share/vm/opto/parse3.cpp index d32053ce299..cfd042959c9 100644 --- a/hotspot/src/share/vm/opto/parse3.cpp +++ b/hotspot/src/share/vm/opto/parse3.cpp @@ -408,7 +408,7 @@ void Parse::do_multianewarray() { jint dim_con = find_int_con(length[j], -1); expand_fanout *= dim_con; expand_count += expand_fanout; // count the level-J sub-arrays - if (dim_con < 0 + if (dim_con <= 0 || dim_con > expand_limit || expand_count > expand_limit) { expand_count = 0; From 5887f56e62e1861fae6bd0c09dbcd62f3863494d Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Tue, 8 Apr 2008 12:46:39 +0400 Subject: [PATCH 032/119] 6520716: event classes lack info about parameters Clarify allowed values for event constructors Reviewed-by: son, denis --- .../java/awt/dnd/DragGestureEvent.java | 34 +++- .../classes/java/awt/dnd/DropTargetEvent.java | 9 +- .../classes/java/awt/event/ActionEvent.java | 69 +++++-- .../java/awt/event/AdjustmentEvent.java | 62 ++++-- .../java/awt/event/ComponentEvent.java | 15 +- .../java/awt/event/ContainerEvent.java | 16 +- .../classes/java/awt/event/FocusEvent.java | 52 +++-- .../java/awt/event/HierarchyEvent.java | 99 +++++---- .../classes/java/awt/event/InputEvent.java | 37 +++- .../java/awt/event/InvocationEvent.java | 39 ++-- .../classes/java/awt/event/ItemEvent.java | 33 ++- .../classes/java/awt/event/KeyEvent.java | 87 +++++--- .../classes/java/awt/event/MouseEvent.java | 192 ++++++++++++------ .../java/awt/event/MouseWheelEvent.java | 2 +- .../classes/java/awt/event/PaintEvent.java | 18 +- .../classes/java/awt/event/TextEvent.java | 15 +- .../classes/java/awt/event/WindowEvent.java | 89 +++++--- 17 files changed, 591 insertions(+), 277 deletions(-) diff --git a/jdk/src/share/classes/java/awt/dnd/DragGestureEvent.java b/jdk/src/share/classes/java/awt/dnd/DragGestureEvent.java index 9996275225c..73885d436a1 100644 --- a/jdk/src/share/classes/java/awt/dnd/DragGestureEvent.java +++ b/jdk/src/share/classes/java/awt/dnd/DragGestureEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,9 +55,19 @@ import java.io.ObjectOutputStream; * platform dependent drag initiating gesture has occurred * on the Component that it is tracking. * + * The {@code action} field of any {@code DragGestureEvent} instance should take one of the following + * values: + *

    + *
  • {@code DnDConstants.ACTION_COPY} + *
  • {@code DnDConstants.ACTION_MOVE} + *
  • {@code DnDConstants.ACTION_LINK} + *
+ * Assigning the value different from listed above will cause an unspecified behavior. + * * @see java.awt.dnd.DragGestureRecognizer * @see java.awt.dnd.DragGestureListener * @see java.awt.dnd.DragSource + * @see java.awt.dnd.DnDConstants */ public class DragGestureEvent extends EventObject { @@ -65,19 +75,25 @@ public class DragGestureEvent extends EventObject { private static final long serialVersionUID = 9080172649166731306L; /** - * Constructs a DragGestureEvent given the - * DragGestureRecognizer firing this event, - * an int representing - * the user's preferred action, a Point - * indicating the origin of the drag, and a List - * of events that comprise the gesture. + * Constructs a DragGestureEvent object given by the + * DragGestureRecognizer instance firing this event, + * an {@code act} parameter representing + * the user's preferred action, an {@code ori} parameter + * indicating the origin of the drag, and a {@code List} of + * events that comprise the gesture({@code evs} parameter). *

* @param dgr The DragGestureRecognizer firing this event - * @param act The the user's preferred action + * @param act The user's preferred action. + * For information on allowable values, see + * the class description for {@link DragGestureEvent} * @param ori The origin of the drag * @param evs The List of events that comprise the gesture *

- * @throws IllegalArgumentException if input parameters are {@code null} + * @throws IllegalArgumentException if any parameter equals {@code null} + * @throws IllegalArgumentException if the act parameter does not comply with + * the values given in the class + * description for {@link DragGestureEvent} + * @see java.awt.dnd.DnDConstants */ public DragGestureEvent(DragGestureRecognizer dgr, int act, Point ori, diff --git a/jdk/src/share/classes/java/awt/dnd/DropTargetEvent.java b/jdk/src/share/classes/java/awt/dnd/DropTargetEvent.java index 64d0b44d170..42fd397c701 100644 --- a/jdk/src/share/classes/java/awt/dnd/DropTargetEvent.java +++ b/jdk/src/share/classes/java/awt/dnd/DropTargetEvent.java @@ -45,10 +45,13 @@ public class DropTargetEvent extends java.util.EventObject { private static final long serialVersionUID = 2821229066521922993L; /** - * Construct a DropTargetEvent with - * a specified DropTargetContext. + * Construct a DropTargetEvent object with + * the specified DropTargetContext. *

- * @param dtc the DropTargetContext + * @param dtc The DropTargetContext + * @throws NullPointerException if {@code dtc} equals {@code null}. + * @see #getSource() + * @see #getDropTargetContext() */ public DropTargetEvent(DropTargetContext dtc) { diff --git a/jdk/src/share/classes/java/awt/event/ActionEvent.java b/jdk/src/share/classes/java/awt/event/ActionEvent.java index 41ed7d6488c..b81ab8a8f4f 100644 --- a/jdk/src/share/classes/java/awt/event/ActionEvent.java +++ b/jdk/src/share/classes/java/awt/event/ActionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,10 @@ import java.awt.Event; * is therefore spared the details of processing individual mouse movements * and mouse clicks, and can instead process a "meaningful" (semantic) * event like "button pressed". + *

+ * An unspecified behavior will be caused if the {@code id} parameter + * of any particular {@code ActionEvent} instance is not + * in the range from {@code ACTION_FIRST} to {@code ACTION_LAST}. * * @see ActionListener * @see Tutorial: Java 1.1 Event Model @@ -134,18 +138,22 @@ public class ActionEvent extends AWTEvent { /** * Constructs an ActionEvent object. *

- * Note that passing in an invalid id results in - * unspecified behavior. This method throws an + * This method throws an * IllegalArgumentException if source * is null. * A null command string is legal, * but not recommended. * - * @param source the object that originated the event - * @param id an integer that identifies the event - * @param command a string that may specify a command (possibly one + * @param source The object that originated the event + * @param id An integer that identifies the event. + * For information on allowable values, see + * the class description for {@link ActionEvent} + * @param command A string that may specify a command (possibly one * of several) associated with the event * @throws IllegalArgumentException if source is null + * @see #getSource() + * @see #getID() + * @see #getActionCommand() */ public ActionEvent(Object source, int id, String command) { this(source, id, command, 0); @@ -154,19 +162,27 @@ public class ActionEvent extends AWTEvent { /** * Constructs an ActionEvent object with modifier keys. *

- * Note that passing in an invalid id results in - * unspecified behavior. This method throws an + * This method throws an * IllegalArgumentException if source * is null. * A null command string is legal, * but not recommended. * - * @param source the object that originated the event - * @param id an integer that identifies the event - * @param command a string that may specify a command (possibly one - * of several) associated with the event - * @param modifiers the modifier keys held down during this action + * @param source The object that originated the event + * @param id An integer that identifies the event. + * For information on allowable values, see + * the class description for {@link ActionEvent} + * @param command A string that may specify a command (possibly one + * of several) associated with the event + * @param modifiers The modifier keys down during event + * (shift, ctrl, alt, meta). + * Passing negative parameter is not recommended. + * Zero value means that no modifiers were passed * @throws IllegalArgumentException if source is null + * @see #getSource() + * @see #getID() + * @see #getActionCommand() + * @see #getModifiers() */ public ActionEvent(Object source, int id, String command, int modifiers) { this(source, id, command, 0, modifiers); @@ -176,20 +192,31 @@ public class ActionEvent extends AWTEvent { * Constructs an ActionEvent object with the specified * modifier keys and timestamp. *

- * Note that passing in an invalid id results in - * unspecified behavior. This method throws an + * This method throws an * IllegalArgumentException if source * is null. * A null command string is legal, * but not recommended. * - * @param source the object that originated the event - * @param id an integer that identifies the event - * @param command a string that may specify a command (possibly one - * of several) associated with the event - * @param when the time the event occurred - * @param modifiers the modifier keys held down during this action + * @param source The object that originated the event + * @param id An integer that identifies the event. + * For information on allowable values, see + * the class description for {@link ActionEvent} + * @param command A string that may specify a command (possibly one + * of several) associated with the event + * @param modifiers The modifier keys down during event + * (shift, ctrl, alt, meta). + * Passing negative parameter is not recommended. + * Zero value means that no modifiers were passed + * @param when A long that gives the time the event occurred. + * Passing negative or zero value + * is not recommended * @throws IllegalArgumentException if source is null + * @see #getSource() + * @see #getID() + * @see #getActionCommand() + * @see #getModifiers() + * @see #getWhen() * * @since 1.4 */ diff --git a/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java b/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java index b928899b2ec..590dae60ffb 100644 --- a/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java +++ b/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java @@ -29,7 +29,25 @@ import java.awt.Adjustable; import java.awt.AWTEvent; /** - * The adjustment event emitted by Adjustable objects. + * The adjustment event emitted by Adjustable objects like + * {@link java.awt.Scrollbar} and {@link java.awt.ScrollPane}. + * When the user changes the value of the scrolling component, + * it receives an instance of {@code AdjustmentEvent}. + *

+ * An unspecified behavior will be caused if the {@code id} parameter + * of any particular {@code AdjustmentEvent} instance is not + * in the range from {@code ADJUSTMENT_FIRST} to {@code ADJUSTMENT_LAST}. + *

+ * The {@code type} of any {@code AdjustmentEvent} instance takes one of the following + * values: + *

    + *
  • {@code UNIT_INCREMENT} + *
  • {@code UNIT_DECREMENT} + *
  • {@code BLOCK_INCREMENT} + *
  • {@code BLOCK_DECREMENT} + *
  • {@code TRACK} + *
+ * Assigning the value different from listed above will cause an unspecified behavior. * @see java.awt.Adjustable * @see AdjustmentListener * @@ -130,17 +148,24 @@ public class AdjustmentEvent extends AWTEvent { * Constructs an AdjustmentEvent object with the * specified Adjustable source, event type, * adjustment type, and value. - *

Note that passing in an invalid id results in - * unspecified behavior. This method throws an + *

This method throws an * IllegalArgumentException if source * is null. * - * @param source the Adjustable object where the + * @param source The Adjustable object where the * event originated - * @param id the event type - * @param type the adjustment type - * @param value the current value of the adjustment + * @param id An integer indicating the type of event. + * For information on allowable values, see + * the class description for {@link AdjustmentEvent} + * @param type An integer indicating the adjustment type. + * For information on allowable values, see + * the class description for {@link AdjustmentEvent} + * @param value The current value of the adjustment * @throws IllegalArgumentException if source is null + * @see #getSource() + * @see #getID() + * @see #getAdjustmentType() + * @see #getValue() */ public AdjustmentEvent(Adjustable source, int id, int type, int value) { this(source, id, type, value, false); @@ -149,22 +174,29 @@ public class AdjustmentEvent extends AWTEvent { /** * Constructs an AdjustmentEvent object with the * specified Adjustable source, event type, adjustment type, and value. - *

Note that passing in an invalid id results in - * unspecified behavior. This method throws an + *

This method throws an * IllegalArgumentException if source * is null. - * - * @param source the Adjustable object where the + * @param source The Adjustable object where the * event originated - * @param id the event type - * @param type the adjustment type - * @param value the current value of the adjustment - * @param isAdjusting true if the event is one + * @param id An integer indicating the type of event. + * For information on allowable values, see + * the class description for {@link AdjustmentEvent} + * @param type An integer indicating the adjustment type. + * For information on allowable values, see + * the class description for {@link AdjustmentEvent} + * @param value The current value of the adjustment + * @param isAdjusting A boolean that equals true if the event is one * of a series of multiple adjusting events, * otherwise false * @throws IllegalArgumentException if source is null * @since 1.4 + * @see #getSource() + * @see #getID() + * @see #getAdjustmentType() + * @see #getValue() + * @see #getValueIsAdjusting() */ public AdjustmentEvent(Adjustable source, int id, int type, int value, boolean isAdjusting) { super(source, id); diff --git a/jdk/src/share/classes/java/awt/event/ComponentEvent.java b/jdk/src/share/classes/java/awt/event/ComponentEvent.java index a0264b81af0..bd51d262ef7 100644 --- a/jdk/src/share/classes/java/awt/event/ComponentEvent.java +++ b/jdk/src/share/classes/java/awt/event/ComponentEvent.java @@ -52,6 +52,10 @@ import java.awt.Rectangle; * (ComponentAdapter objects implement the * ComponentListener interface.) Each such listener object * gets this ComponentEvent when the event occurs. + *

+ * An unspecified behavior will be caused if the {@code id} parameter + * of any particular {@code ComponentEvent} instance is not + * in the range from {@code COMPONENT_FIRST} to {@code COMPONENT_LAST}. * * @see ComponentAdapter * @see ComponentListener @@ -99,14 +103,17 @@ public class ComponentEvent extends AWTEvent { /** * Constructs a ComponentEvent object. - *

Note that passing in an invalid id results in - * unspecified behavior. This method throws an + *

This method throws an * IllegalArgumentException if source * is null. * - * @param source the Component that originated the event - * @param id an integer indicating the type of event + * @param source The Component that originated the event + * @param id An integer indicating the type of event. + * For information on allowable values, see + * the class description for {@link ComponentEvent} * @throws IllegalArgumentException if source is null + * @see #getComponent() + * @see #getID() */ public ComponentEvent(Component source, int id) { super(source, id); diff --git a/jdk/src/share/classes/java/awt/event/ContainerEvent.java b/jdk/src/share/classes/java/awt/event/ContainerEvent.java index f927312ba0b..16ef5b1c92f 100644 --- a/jdk/src/share/classes/java/awt/event/ContainerEvent.java +++ b/jdk/src/share/classes/java/awt/event/ContainerEvent.java @@ -45,6 +45,10 @@ import java.awt.Component; * (ContainerAdapter objects implement the * ContainerListener interface.) Each such listener object * gets this ContainerEvent when the event occurs. + *

+ * An unspecified behavior will be caused if the {@code id} parameter + * of any particular {@code ContainerEvent} instance is not + * in the range from {@code CONTAINER_FIRST} to {@code CONTAINER_LAST}. * * @see ContainerAdapter * @see ContainerListener @@ -92,16 +96,20 @@ public class ContainerEvent extends ComponentEvent { /** * Constructs a ContainerEvent object. - *

Note that passing in an invalid id results in - * unspecified behavior. This method throws an + *

This method throws an * IllegalArgumentException if source * is null. * - * @param source the Component object (container) + * @param source The Component object (container) * that originated the event - * @param id an integer indicating the type of event + * @param id An integer indicating the type of event. + * For information on allowable values, see + * the class description for {@link ContainerEvent} * @param child the component that was added or removed * @throws IllegalArgumentException if source is null + * @see #getContainer() + * @see #getID() + * @see #getChild() */ public ContainerEvent(Component source, int id, Component child) { super(source, id); diff --git a/jdk/src/share/classes/java/awt/event/FocusEvent.java b/jdk/src/share/classes/java/awt/event/FocusEvent.java index 188ce44b720..ec018e0126e 100644 --- a/jdk/src/share/classes/java/awt/event/FocusEvent.java +++ b/jdk/src/share/classes/java/awt/event/FocusEvent.java @@ -50,6 +50,10 @@ import sun.awt.SunToolkit; * reactivated. Both permanent and temporary focus events are delivered using * the FOCUS_GAINED and FOCUS_LOST event ids; the level may be distinguished in * the event using the isTemporary() method. + *

+ * An unspecified behavior will be caused if the {@code id} parameter + * of any particular {@code FocusEvent} instance is not + * in the range from {@code FOCUS_FIRST} to {@code FOCUS_LAST}. * * @see FocusAdapter * @see FocusListener @@ -121,18 +125,23 @@ public class FocusEvent extends ComponentEvent { * application, with a Java application in a different VM, * or with no other Component, then the opposite * Component is null. - *

Note that passing in an invalid id results in - * unspecified behavior. This method throws an + *

This method throws an * IllegalArgumentException if source * is null. * - * @param source the Component that originated the event - * @param id FOCUS_GAINED or FOCUS_LOST - * @param temporary true if the focus change is temporary; + * @param source The Component that originated the event + * @param id An integer indicating the type of event. + * For information on allowable values, see + * the class description for {@link FocusEvent} + * @param temporary Equals true if the focus change is temporary; * false otherwise - * @param opposite the other Component involved in the focus change, + * @param opposite The other Component involved in the focus change, * or null - * @throws IllegalArgumentException if source is null + * @throws IllegalArgumentException if source equals {@code null} + * @see #getSource() + * @see #getID() + * @see #isTemporary() + * @see #getOppositeComponent() * @since 1.4 */ public FocusEvent(Component source, int id, boolean temporary, @@ -145,16 +154,20 @@ public class FocusEvent extends ComponentEvent { /** * Constructs a FocusEvent object and identifies * whether or not the change is temporary. - *

Note that passing in an invalid id results in - * unspecified behavior. This method throws an + *

This method throws an * IllegalArgumentException if source * is null. * - * @param source the Component that originated the event - * @param id an integer indicating the type of event - * @param temporary true if the focus change is temporary; + * @param source The Component that originated the event + * @param id An integer indicating the type of event. + * For information on allowable values, see + * the class description for {@link FocusEvent} + * @param temporary Equals true if the focus change is temporary; * false otherwise - * @throws IllegalArgumentException if source is null + * @throws IllegalArgumentException if source equals {@code null} + * @see #getSource() + * @see #getID() + * @see #isTemporary() */ public FocusEvent(Component source, int id, boolean temporary) { this(source, id, temporary, null); @@ -163,14 +176,17 @@ public class FocusEvent extends ComponentEvent { /** * Constructs a FocusEvent object and identifies it * as a permanent change in focus. - *

Note that passing in an invalid id results in - * unspecified behavior. This method throws an + *

This method throws an * IllegalArgumentException if source * is null. * - * @param source the Component that originated the event - * @param id an integer indicating the type of event - * @throws IllegalArgumentException if source is null + * @param source The Component that originated the event + * @param id An integer indicating the type of event. + * For information on allowable values, see + * the class description for {@link FocusEvent} + * @throws IllegalArgumentException if source equals {@code null} + * @see #getSource() + * @see #getID() */ public FocusEvent(Component source, int id) { this(source, id, false); diff --git a/jdk/src/share/classes/java/awt/event/HierarchyEvent.java b/jdk/src/share/classes/java/awt/event/HierarchyEvent.java index d57256a45a2..6ed6ab18edb 100644 --- a/jdk/src/share/classes/java/awt/event/HierarchyEvent.java +++ b/jdk/src/share/classes/java/awt/event/HierarchyEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ import java.awt.Container; /** * An event which indicates a change to the Component - * hierarchy to which a Component belongs. + * hierarchy to which Component belongs. *