Merge
This commit is contained in:
commit
31eeaafbcf
2
.hgtags
2
.hgtags
@ -20,3 +20,5 @@ caf58ffa084568990cbb3441f9ae188e36b31770 jdk7-b42
|
||||
41bd0a702bc8ec6feebd725a63e7c3227f82ab11 jdk7-b43
|
||||
5843778bda89b1d5ac8e1aa05e26930ac90b3145 jdk7-b44
|
||||
54dffad0bf066791a2793305875250c395011d5f jdk7-b45
|
||||
04b2620edc72de93671646e4720c5992c74ac8b5 jdk7-b46
|
||||
0c4657194eec95c08ba478aee9cfc3c295e41657 jdk7-b47
|
||||
|
@ -20,3 +20,5 @@ ab523b49de1fc73fefe6855ce1e0349bdbd7af29 jdk7-b39
|
||||
848e684279d2ba42577d9621d5b2e5af3823d12d jdk7-b43
|
||||
a395e3aac4744cc9033fcd819fad1239a45add52 jdk7-b44
|
||||
99846f001ca214015578d593802d26e27246a802 jdk7-b45
|
||||
e8a2a4d187773a62f3309b0fa265c13425bc2258 jdk7-b46
|
||||
d7744e86dedc21a8ecf6bdb73eb191b8eaf5b0da jdk7-b47
|
||||
|
@ -20,3 +20,5 @@ ccd6a16502e0650d91d85c4b86be05cbcd461a87 jdk7-b42
|
||||
9cd740d48a4855321d69f137a7109c00bcda76be jdk7-b43
|
||||
9803dac7254041b30ca65e3852d4c566b9757c3b jdk7-b44
|
||||
68814aa5b44b1f16931a97e7cd4028c70eb9586b jdk7-b45
|
||||
1691dbfc08f8ee3f4e23a1ff30cdff920718696c jdk7-b46
|
||||
167ad0164301f318b069a947e1c9c07ed667748a jdk7-b47
|
||||
|
@ -20,3 +20,5 @@ ad8c8ca4ab0f4c86e74c061958f44a8f4a930f2c jdk7-b42
|
||||
fc6a5ae3fef5ebacfa896dbb3ae37715e388e282 jdk7-b43
|
||||
809e899c638bd9b21836abf9d09ab2a30ff3900b jdk7-b44
|
||||
945bf754069766e76873c53102fae48abf04cf5b jdk7-b45
|
||||
16bb38eeda35b46268eefa4c1f829eb086e0ca46 jdk7-b46
|
||||
fcb923bad68e2b10380a030ea83a723f4dc3d4d6 jdk7-b47
|
||||
|
@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2008
|
||||
|
||||
HS_MAJOR_VER=15
|
||||
HS_MINOR_VER=0
|
||||
HS_BUILD_NUMBER=01
|
||||
HS_BUILD_NUMBER=02
|
||||
|
||||
JDK_MAJOR_VER=1
|
||||
JDK_MINOR_VER=7
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2009 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
|
||||
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
# include "incls/_precompiled.incl"
|
||||
# include "incls/_vm_version_x86_32.cpp.incl"
|
||||
# include "incls/_vm_version_x86.cpp.incl"
|
||||
|
||||
|
||||
int VM_Version::_cpu;
|
||||
@ -67,8 +67,14 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
|
||||
//
|
||||
// void getPsrInfo(VM_Version::CpuidInfo* cpuid_info);
|
||||
//
|
||||
// LP64: rcx and rdx are first and second argument registers on windows
|
||||
|
||||
__ push(rbp);
|
||||
#ifdef _LP64
|
||||
__ mov(rbp, c_rarg0); // cpuid_info address
|
||||
#else
|
||||
__ movptr(rbp, Address(rsp, 8)); // cpuid_info address
|
||||
#endif
|
||||
__ push(rbx);
|
||||
__ push(rsi);
|
||||
__ pushf(); // preserve rbx, and flags
|
||||
@ -110,12 +116,12 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
|
||||
__ jmp(done);
|
||||
|
||||
//
|
||||
// at this point, we have a chip which supports the "cpuid" instruction
|
||||
// At this point, we have a chip which supports the "cpuid" instruction
|
||||
//
|
||||
__ bind(detect_586);
|
||||
__ xorptr(rax, rax);
|
||||
__ xorl(rax, rax);
|
||||
__ cpuid();
|
||||
__ orptr(rax, rax);
|
||||
__ orl(rax, rax);
|
||||
__ jcc(Assembler::equal, cpu486); // if cpuid doesn't support an input
|
||||
// value of at least 1, we give up and
|
||||
// assume a 486
|
||||
@ -131,12 +137,12 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
|
||||
//
|
||||
// cpuid(0x4) Deterministic cache params
|
||||
//
|
||||
__ movl(rax, 4); // and rcx already set to 0x0
|
||||
__ xorl(rcx, rcx);
|
||||
__ movl(rax, 4);
|
||||
__ xorl(rcx, rcx); // L1 cache
|
||||
__ cpuid();
|
||||
__ push(rax);
|
||||
__ andl(rax, 0x1f); // Determine if valid cache parameters used
|
||||
__ orl(rax, rax); // rax,[4:0] == 0 indicates invalid cache
|
||||
__ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache
|
||||
__ pop(rax);
|
||||
__ jccb(Assembler::equal, std_cpuid1);
|
||||
|
||||
@ -225,6 +231,7 @@ void VM_Version::get_processor_features() {
|
||||
_stepping = 0;
|
||||
_cpuFeatures = 0;
|
||||
_logical_processors_per_package = 1;
|
||||
|
||||
if (!Use486InstrsOnly) {
|
||||
// Get raw processor info
|
||||
getPsrInfo_stub(&_cpuid_info);
|
||||
@ -232,6 +239,7 @@ void VM_Version::get_processor_features() {
|
||||
_cpu = extended_cpu_family();
|
||||
_model = extended_cpu_model();
|
||||
_stepping = cpu_stepping();
|
||||
|
||||
if (cpu_family() > 4) { // it supports CPUID
|
||||
_cpuFeatures = feature_flags();
|
||||
// Logical processors are only available on P4s and above,
|
||||
@ -239,21 +247,34 @@ void VM_Version::get_processor_features() {
|
||||
_logical_processors_per_package = logical_processor_count();
|
||||
}
|
||||
}
|
||||
|
||||
_supports_cx8 = supports_cmpxchg8();
|
||||
// if the OS doesn't support SSE, we can't use this feature even if the HW does
|
||||
if( !os::supports_sse())
|
||||
|
||||
#ifdef _LP64
|
||||
// OS should support SSE for x64 and hardware should support at least SSE2.
|
||||
if (!VM_Version::supports_sse2()) {
|
||||
vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported");
|
||||
}
|
||||
#endif
|
||||
|
||||
// If the OS doesn't support SSE, we can't use this feature even if the HW does
|
||||
if (!os::supports_sse())
|
||||
_cpuFeatures &= ~(CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE4A|CPU_SSE4_1|CPU_SSE4_2);
|
||||
|
||||
if (UseSSE < 4) {
|
||||
_cpuFeatures &= ~CPU_SSE4_1;
|
||||
_cpuFeatures &= ~CPU_SSE4_2;
|
||||
}
|
||||
|
||||
if (UseSSE < 3) {
|
||||
_cpuFeatures &= ~CPU_SSE3;
|
||||
_cpuFeatures &= ~CPU_SSSE3;
|
||||
_cpuFeatures &= ~CPU_SSE4A;
|
||||
}
|
||||
|
||||
if (UseSSE < 2)
|
||||
_cpuFeatures &= ~CPU_SSE2;
|
||||
|
||||
if (UseSSE < 1)
|
||||
_cpuFeatures &= ~CPU_SSE;
|
||||
|
||||
@ -418,10 +439,21 @@ void VM_Version::get_processor_features() {
|
||||
|
||||
if( AllocatePrefetchStyle == 2 && is_intel() &&
|
||||
cpu_family() == 6 && supports_sse3() ) { // watermark prefetching on Core
|
||||
#ifdef _LP64
|
||||
AllocatePrefetchDistance = 384;
|
||||
#else
|
||||
AllocatePrefetchDistance = 320;
|
||||
#endif
|
||||
}
|
||||
assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
|
||||
|
||||
#ifdef _LP64
|
||||
// Prefetch settings
|
||||
PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
|
||||
PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
|
||||
PrefetchFieldsAhead = prefetch_fields_ahead();
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
tty->print_cr("Logical CPUs per core: %u",
|
||||
@ -450,6 +482,16 @@ void VM_Version::get_processor_features() {
|
||||
tty->print_cr(" %d, one line", AllocatePrefetchDistance);
|
||||
}
|
||||
}
|
||||
|
||||
if (PrefetchCopyIntervalInBytes > 0) {
|
||||
tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
|
||||
}
|
||||
if (PrefetchScanIntervalInBytes > 0) {
|
||||
tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
|
||||
}
|
||||
if (PrefetchFieldsAhead > 0) {
|
||||
tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
|
||||
}
|
||||
}
|
||||
#endif // !PRODUCT
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2009 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
|
||||
@ -112,20 +112,6 @@ public:
|
||||
} bits;
|
||||
};
|
||||
|
||||
union ExtCpuid1Edx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t : 22,
|
||||
mmx_amd : 1,
|
||||
mmx : 1,
|
||||
fxsr : 1,
|
||||
: 4,
|
||||
long_mode : 1,
|
||||
tdnow2 : 1,
|
||||
tdnow : 1;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union ExtCpuid1Ecx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
@ -140,6 +126,20 @@ public:
|
||||
} bits;
|
||||
};
|
||||
|
||||
union ExtCpuid1Edx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t : 22,
|
||||
mmx_amd : 1,
|
||||
mmx : 1,
|
||||
fxsr : 1,
|
||||
: 4,
|
||||
long_mode : 1,
|
||||
tdnow2 : 1,
|
||||
tdnow : 1;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union ExtCpuid5Ex {
|
||||
uint32_t value;
|
||||
struct {
|
||||
@ -167,17 +167,17 @@ protected:
|
||||
static const char* _features_str;
|
||||
|
||||
enum {
|
||||
CPU_CX8 = (1 << 0), // next bits are from cpuid 1 (EDX)
|
||||
CPU_CMOV = (1 << 1),
|
||||
CPU_FXSR = (1 << 2),
|
||||
CPU_HT = (1 << 3),
|
||||
CPU_MMX = (1 << 4),
|
||||
CPU_3DNOW= (1 << 5),
|
||||
CPU_SSE = (1 << 6),
|
||||
CPU_SSE2 = (1 << 7),
|
||||
CPU_SSE3 = (1 << 8),
|
||||
CPU_SSSE3= (1 << 9),
|
||||
CPU_SSE4A= (1 <<10),
|
||||
CPU_CX8 = (1 << 0), // next bits are from cpuid 1 (EDX)
|
||||
CPU_CMOV = (1 << 1),
|
||||
CPU_FXSR = (1 << 2),
|
||||
CPU_HT = (1 << 3),
|
||||
CPU_MMX = (1 << 4),
|
||||
CPU_3DNOW = (1 << 5), // 3DNow comes from cpuid 0x80000001 (EDX)
|
||||
CPU_SSE = (1 << 6),
|
||||
CPU_SSE2 = (1 << 7),
|
||||
CPU_SSE3 = (1 << 8), // SSE3 comes from cpuid 1 (ECX)
|
||||
CPU_SSSE3 = (1 << 9),
|
||||
CPU_SSE4A = (1 << 10),
|
||||
CPU_SSE4_1 = (1 << 11),
|
||||
CPU_SSE4_2 = (1 << 12)
|
||||
} cpuFeatureFlags;
|
||||
@ -360,7 +360,7 @@ public:
|
||||
result = _cpuid_info.ext_cpuid5_ecx.bits.L1_line_size;
|
||||
}
|
||||
if (result < 32) // not defined ?
|
||||
result = 32; // 32 bytes by default for other x64
|
||||
result = 32; // 32 bytes by default on x86 and other x64
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -395,26 +395,36 @@ public:
|
||||
// This method should be called before allocate_prefetch_style().
|
||||
//
|
||||
// Hardware prefetching (distance/size in bytes):
|
||||
// Pentium 3 - 64 / 32
|
||||
// Pentium 4 - 256 / 128
|
||||
// Athlon - 64 / 32 ????
|
||||
// Opteron - 128 / 64 only when 2 sequential cache lines accessed
|
||||
// Core - 128 / 64
|
||||
//
|
||||
// Software prefetching (distance in bytes / instruction with best score):
|
||||
// Pentium 3 - 128 / prefetchnta
|
||||
// Pentium 4 - 512 / prefetchnta
|
||||
// Athlon - 128 / prefetchnta
|
||||
// Opteron - 256 / prefetchnta
|
||||
// Core - 256 / prefetchnta
|
||||
// It will be used only when AllocatePrefetchStyle > 0
|
||||
|
||||
intx count = AllocatePrefetchDistance;
|
||||
if (count < 0) { // default ?
|
||||
if (is_amd()) { // AMD
|
||||
count = 256; // Opteron
|
||||
} else { // Intel
|
||||
if (cpu_family() == 6) {
|
||||
count = 256;// Pentium M, Core, Core2
|
||||
} else {
|
||||
count = 512;// Pentium 4
|
||||
}
|
||||
if (count < 0) { // default ?
|
||||
if (is_amd()) { // AMD
|
||||
if (supports_sse2())
|
||||
count = 256; // Opteron
|
||||
else
|
||||
count = 128; // Athlon
|
||||
} else { // Intel
|
||||
if (supports_sse2())
|
||||
if (cpu_family() == 6) {
|
||||
count = 256; // Pentium M, Core, Core2
|
||||
} else {
|
||||
count = 512; // Pentium 4
|
||||
}
|
||||
else
|
||||
count = 128; // Pentium 3 (and all other old CPUs)
|
||||
}
|
||||
}
|
||||
return count;
|
@ -1,439 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along 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 VM_Version: public Abstract_VM_Version {
|
||||
public:
|
||||
// cpuid result register layouts. These are all unions of a uint32_t
|
||||
// (in case anyone wants access to the register as a whole) and a bitfield.
|
||||
|
||||
union StdCpuid1Eax {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t stepping : 4,
|
||||
model : 4,
|
||||
family : 4,
|
||||
proc_type : 2,
|
||||
: 2,
|
||||
ext_model : 4,
|
||||
ext_family : 8,
|
||||
: 4;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union StdCpuid1Ebx { // example, unused
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t brand_id : 8,
|
||||
clflush_size : 8,
|
||||
threads_per_cpu : 8,
|
||||
apic_id : 8;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union StdCpuid1Ecx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t sse3 : 1,
|
||||
: 2,
|
||||
monitor : 1,
|
||||
: 1,
|
||||
vmx : 1,
|
||||
: 1,
|
||||
est : 1,
|
||||
: 1,
|
||||
ssse3 : 1,
|
||||
cid : 1,
|
||||
: 2,
|
||||
cmpxchg16: 1,
|
||||
: 4,
|
||||
dca : 1,
|
||||
sse4_1 : 1,
|
||||
sse4_2 : 1,
|
||||
: 11;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union StdCpuid1Edx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t : 4,
|
||||
tsc : 1,
|
||||
: 3,
|
||||
cmpxchg8 : 1,
|
||||
: 6,
|
||||
cmov : 1,
|
||||
: 7,
|
||||
mmx : 1,
|
||||
fxsr : 1,
|
||||
sse : 1,
|
||||
sse2 : 1,
|
||||
: 1,
|
||||
ht : 1,
|
||||
: 3;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union DcpCpuid4Eax {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t cache_type : 5,
|
||||
: 21,
|
||||
cores_per_cpu : 6;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union DcpCpuid4Ebx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t L1_line_size : 12,
|
||||
partitions : 10,
|
||||
associativity : 10;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union ExtCpuid1Ecx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t LahfSahf : 1,
|
||||
CmpLegacy : 1,
|
||||
: 4,
|
||||
abm : 1,
|
||||
sse4a : 1,
|
||||
misalignsse : 1,
|
||||
prefetchw : 1,
|
||||
: 22;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union ExtCpuid1Edx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t : 22,
|
||||
mmx_amd : 1,
|
||||
mmx : 1,
|
||||
fxsr : 1,
|
||||
: 4,
|
||||
long_mode : 1,
|
||||
tdnow2 : 1,
|
||||
tdnow : 1;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union ExtCpuid5Ex {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t L1_line_size : 8,
|
||||
L1_tag_lines : 8,
|
||||
L1_assoc : 8,
|
||||
L1_size : 8;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union ExtCpuid8Ecx {
|
||||
uint32_t value;
|
||||
struct {
|
||||
uint32_t cores_per_cpu : 8,
|
||||
: 24;
|
||||
} bits;
|
||||
};
|
||||
|
||||
protected:
|
||||
static int _cpu;
|
||||
static int _model;
|
||||
static int _stepping;
|
||||
static int _cpuFeatures; // features returned by the "cpuid" instruction
|
||||
// 0 if this instruction is not available
|
||||
static const char* _features_str;
|
||||
|
||||
enum {
|
||||
CPU_CX8 = (1 << 0), // next bits are from cpuid 1 (EDX)
|
||||
CPU_CMOV = (1 << 1),
|
||||
CPU_FXSR = (1 << 2),
|
||||
CPU_HT = (1 << 3),
|
||||
CPU_MMX = (1 << 4),
|
||||
CPU_3DNOW= (1 << 5), // 3DNow comes from cpuid 0x80000001 (EDX)
|
||||
CPU_SSE = (1 << 6),
|
||||
CPU_SSE2 = (1 << 7),
|
||||
CPU_SSE3 = (1 << 8), // sse3 comes from cpuid 1 (ECX)
|
||||
CPU_SSSE3= (1 << 9),
|
||||
CPU_SSE4A= (1 <<10),
|
||||
CPU_SSE4_1 = (1 << 11),
|
||||
CPU_SSE4_2 = (1 << 12)
|
||||
} cpuFeatureFlags;
|
||||
|
||||
// cpuid information block. All info derived from executing cpuid with
|
||||
// various function numbers is stored here. Intel and AMD info is
|
||||
// merged in this block: accessor methods disentangle it.
|
||||
//
|
||||
// The info block is laid out in subblocks of 4 dwords corresponding to
|
||||
// rax, rbx, rcx and rdx, whether or not they contain anything useful.
|
||||
struct CpuidInfo {
|
||||
// cpuid function 0
|
||||
uint32_t std_max_function;
|
||||
uint32_t std_vendor_name_0;
|
||||
uint32_t std_vendor_name_1;
|
||||
uint32_t std_vendor_name_2;
|
||||
|
||||
// cpuid function 1
|
||||
StdCpuid1Eax std_cpuid1_rax;
|
||||
StdCpuid1Ebx std_cpuid1_rbx;
|
||||
StdCpuid1Ecx std_cpuid1_rcx;
|
||||
StdCpuid1Edx std_cpuid1_rdx;
|
||||
|
||||
// cpuid function 4 (deterministic cache parameters)
|
||||
DcpCpuid4Eax dcp_cpuid4_rax;
|
||||
DcpCpuid4Ebx dcp_cpuid4_rbx;
|
||||
uint32_t dcp_cpuid4_rcx; // unused currently
|
||||
uint32_t dcp_cpuid4_rdx; // unused currently
|
||||
|
||||
// cpuid function 0x80000000 // example, unused
|
||||
uint32_t ext_max_function;
|
||||
uint32_t ext_vendor_name_0;
|
||||
uint32_t ext_vendor_name_1;
|
||||
uint32_t ext_vendor_name_2;
|
||||
|
||||
// cpuid function 0x80000001
|
||||
uint32_t ext_cpuid1_rax; // reserved
|
||||
uint32_t ext_cpuid1_rbx; // reserved
|
||||
ExtCpuid1Ecx ext_cpuid1_rcx;
|
||||
ExtCpuid1Edx ext_cpuid1_rdx;
|
||||
|
||||
// cpuid functions 0x80000002 thru 0x80000004: example, unused
|
||||
uint32_t proc_name_0, proc_name_1, proc_name_2, proc_name_3;
|
||||
uint32_t proc_name_4, proc_name_5, proc_name_6, proc_name_7;
|
||||
uint32_t proc_name_8, proc_name_9, proc_name_10,proc_name_11;
|
||||
|
||||
// cpuid function 0x80000005 //AMD L1, Intel reserved
|
||||
uint32_t ext_cpuid5_rax; // unused currently
|
||||
uint32_t ext_cpuid5_rbx; // reserved
|
||||
ExtCpuid5Ex ext_cpuid5_rcx; // L1 data cache info (AMD)
|
||||
ExtCpuid5Ex ext_cpuid5_rdx; // L1 instruction cache info (AMD)
|
||||
|
||||
// cpuid function 0x80000008
|
||||
uint32_t ext_cpuid8_rax; // unused currently
|
||||
uint32_t ext_cpuid8_rbx; // reserved
|
||||
ExtCpuid8Ecx ext_cpuid8_rcx;
|
||||
uint32_t ext_cpuid8_rdx; // reserved
|
||||
};
|
||||
|
||||
// The actual cpuid info block
|
||||
static CpuidInfo _cpuid_info;
|
||||
|
||||
// Extractors and predicates
|
||||
static uint32_t extended_cpu_family() {
|
||||
uint32_t result = _cpuid_info.std_cpuid1_rax.bits.family;
|
||||
result += _cpuid_info.std_cpuid1_rax.bits.ext_family;
|
||||
return result;
|
||||
}
|
||||
static uint32_t extended_cpu_model() {
|
||||
uint32_t result = _cpuid_info.std_cpuid1_rax.bits.model;
|
||||
result |= _cpuid_info.std_cpuid1_rax.bits.ext_model << 4;
|
||||
return result;
|
||||
}
|
||||
static uint32_t cpu_stepping() {
|
||||
uint32_t result = _cpuid_info.std_cpuid1_rax.bits.stepping;
|
||||
return result;
|
||||
}
|
||||
static uint logical_processor_count() {
|
||||
uint result = threads_per_core();
|
||||
return result;
|
||||
}
|
||||
static uint32_t feature_flags() {
|
||||
uint32_t result = 0;
|
||||
if (_cpuid_info.std_cpuid1_rdx.bits.cmpxchg8 != 0)
|
||||
result |= CPU_CX8;
|
||||
if (_cpuid_info.std_cpuid1_rdx.bits.cmov != 0)
|
||||
result |= CPU_CMOV;
|
||||
if (_cpuid_info.std_cpuid1_rdx.bits.fxsr != 0 || is_amd() &&
|
||||
_cpuid_info.ext_cpuid1_rdx.bits.fxsr != 0)
|
||||
result |= CPU_FXSR;
|
||||
// HT flag is set for multi-core processors also.
|
||||
if (threads_per_core() > 1)
|
||||
result |= CPU_HT;
|
||||
if (_cpuid_info.std_cpuid1_rdx.bits.mmx != 0 || is_amd() &&
|
||||
_cpuid_info.ext_cpuid1_rdx.bits.mmx != 0)
|
||||
result |= CPU_MMX;
|
||||
if (is_amd() && _cpuid_info.ext_cpuid1_rdx.bits.tdnow != 0)
|
||||
result |= CPU_3DNOW;
|
||||
if (_cpuid_info.std_cpuid1_rdx.bits.sse != 0)
|
||||
result |= CPU_SSE;
|
||||
if (_cpuid_info.std_cpuid1_rdx.bits.sse2 != 0)
|
||||
result |= CPU_SSE2;
|
||||
if (_cpuid_info.std_cpuid1_rcx.bits.sse3 != 0)
|
||||
result |= CPU_SSE3;
|
||||
if (_cpuid_info.std_cpuid1_rcx.bits.ssse3 != 0)
|
||||
result |= CPU_SSSE3;
|
||||
if (is_amd() && _cpuid_info.ext_cpuid1_rcx.bits.sse4a != 0)
|
||||
result |= CPU_SSE4A;
|
||||
if (_cpuid_info.std_cpuid1_rcx.bits.sse4_1 != 0)
|
||||
result |= CPU_SSE4_1;
|
||||
if (_cpuid_info.std_cpuid1_rcx.bits.sse4_2 != 0)
|
||||
result |= CPU_SSE4_2;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void get_processor_features();
|
||||
|
||||
public:
|
||||
// Offsets for cpuid asm stub
|
||||
static ByteSize std_cpuid0_offset() { return byte_offset_of(CpuidInfo, std_max_function); }
|
||||
static ByteSize std_cpuid1_offset() { return byte_offset_of(CpuidInfo, std_cpuid1_rax); }
|
||||
static ByteSize dcp_cpuid4_offset() { return byte_offset_of(CpuidInfo, dcp_cpuid4_rax); }
|
||||
static ByteSize ext_cpuid1_offset() { return byte_offset_of(CpuidInfo, ext_cpuid1_rax); }
|
||||
static ByteSize ext_cpuid5_offset() { return byte_offset_of(CpuidInfo, ext_cpuid5_rax); }
|
||||
static ByteSize ext_cpuid8_offset() { return byte_offset_of(CpuidInfo, ext_cpuid8_rax); }
|
||||
|
||||
// Initialization
|
||||
static void initialize();
|
||||
|
||||
// Asserts
|
||||
static void assert_is_initialized() {
|
||||
assert(_cpuid_info.std_cpuid1_rax.bits.family != 0, "VM_Version not initialized");
|
||||
}
|
||||
|
||||
//
|
||||
// Processor family:
|
||||
// 3 - 386
|
||||
// 4 - 486
|
||||
// 5 - Pentium
|
||||
// 6 - PentiumPro, Pentium II, Celeron, Xeon, Pentium III, Athlon,
|
||||
// Pentium M, Core Solo, Core Duo, Core2 Duo
|
||||
// family 6 model: 9, 13, 14, 15
|
||||
// 0x0f - Pentium 4, Opteron
|
||||
//
|
||||
// Note: The cpu family should be used to select between
|
||||
// instruction sequences which are valid on all Intel
|
||||
// processors. Use the feature test functions below to
|
||||
// determine whether a particular instruction is supported.
|
||||
//
|
||||
static int cpu_family() { return _cpu;}
|
||||
static bool is_P6() { return cpu_family() >= 6; }
|
||||
|
||||
static bool is_amd() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA'
|
||||
static bool is_intel() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG'
|
||||
|
||||
static uint cores_per_cpu() {
|
||||
uint result = 1;
|
||||
if (is_intel()) {
|
||||
result = (_cpuid_info.dcp_cpuid4_rax.bits.cores_per_cpu + 1);
|
||||
} else if (is_amd()) {
|
||||
result = (_cpuid_info.ext_cpuid8_rcx.bits.cores_per_cpu + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint threads_per_core() {
|
||||
uint result = 1;
|
||||
if (_cpuid_info.std_cpuid1_rdx.bits.ht != 0) {
|
||||
result = _cpuid_info.std_cpuid1_rbx.bits.threads_per_cpu /
|
||||
cores_per_cpu();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static intx L1_data_cache_line_size() {
|
||||
intx result = 0;
|
||||
if (is_intel()) {
|
||||
result = (_cpuid_info.dcp_cpuid4_rbx.bits.L1_line_size + 1);
|
||||
} else if (is_amd()) {
|
||||
result = _cpuid_info.ext_cpuid5_rcx.bits.L1_line_size;
|
||||
}
|
||||
if (result < 32) // not defined ?
|
||||
result = 32; // 32 bytes by default on x86
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Feature identification
|
||||
//
|
||||
static bool supports_cpuid() { return _cpuFeatures != 0; }
|
||||
static bool supports_cmpxchg8() { return (_cpuFeatures & CPU_CX8) != 0; }
|
||||
static bool supports_cmov() { return (_cpuFeatures & CPU_CMOV) != 0; }
|
||||
static bool supports_fxsr() { return (_cpuFeatures & CPU_FXSR) != 0; }
|
||||
static bool supports_ht() { return (_cpuFeatures & CPU_HT) != 0; }
|
||||
static bool supports_mmx() { return (_cpuFeatures & CPU_MMX) != 0; }
|
||||
static bool supports_sse() { return (_cpuFeatures & CPU_SSE) != 0; }
|
||||
static bool supports_sse2() { return (_cpuFeatures & CPU_SSE2) != 0; }
|
||||
static bool supports_sse3() { return (_cpuFeatures & CPU_SSE3) != 0; }
|
||||
static bool supports_ssse3() { return (_cpuFeatures & CPU_SSSE3)!= 0; }
|
||||
static bool supports_sse4_1() { return (_cpuFeatures & CPU_SSE4_1) != 0; }
|
||||
static bool supports_sse4_2() { return (_cpuFeatures & CPU_SSE4_2) != 0; }
|
||||
//
|
||||
// AMD features
|
||||
//
|
||||
static bool supports_3dnow() { return (_cpuFeatures & CPU_3DNOW) != 0; }
|
||||
static bool supports_mmx_ext() { return is_amd() && _cpuid_info.ext_cpuid1_rdx.bits.mmx_amd != 0; }
|
||||
static bool supports_3dnow2() { return is_amd() && _cpuid_info.ext_cpuid1_rdx.bits.tdnow2 != 0; }
|
||||
static bool supports_sse4a() { return (_cpuFeatures & CPU_SSE4A) != 0; }
|
||||
|
||||
static bool supports_compare_and_exchange() { return true; }
|
||||
|
||||
static const char* cpu_features() { return _features_str; }
|
||||
|
||||
static intx allocate_prefetch_distance() {
|
||||
// This method should be called before allocate_prefetch_style().
|
||||
//
|
||||
// Hardware prefetching (distance/size in bytes):
|
||||
// Pentium 3 - 64 / 32
|
||||
// Pentium 4 - 256 / 128
|
||||
// Athlon - 64 / 32 ????
|
||||
// Opteron - 128 / 64 only when 2 sequential cache lines accessed
|
||||
// Core - 128 / 64
|
||||
//
|
||||
// Software prefetching (distance in bytes / instruction with best score):
|
||||
// Pentium 3 - 128 / prefetchnta
|
||||
// Pentium 4 - 512 / prefetchnta
|
||||
// Athlon - 128 / prefetchnta
|
||||
// Opteron - 256 / prefetchnta
|
||||
// Core - 256 / prefetchnta
|
||||
// It will be used only when AllocatePrefetchStyle > 0
|
||||
|
||||
intx count = AllocatePrefetchDistance;
|
||||
if (count < 0) { // default ?
|
||||
if (is_amd()) { // AMD
|
||||
if (supports_sse2())
|
||||
count = 256; // Opteron
|
||||
else
|
||||
count = 128; // Athlon
|
||||
} else { // Intel
|
||||
if (supports_sse2())
|
||||
if (cpu_family() == 6) {
|
||||
count = 256; // Pentium M, Core, Core2
|
||||
} else {
|
||||
count = 512; // Pentium 4
|
||||
}
|
||||
else
|
||||
count = 128; // Pentium 3 (and all other old CPUs)
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
static intx allocate_prefetch_style() {
|
||||
assert(AllocatePrefetchStyle >= 0, "AllocatePrefetchStyle should be positive");
|
||||
// Return 0 if AllocatePrefetchDistance was not defined or
|
||||
// prefetch instruction is not supported.
|
||||
return (AllocatePrefetchDistance > 0 &&
|
||||
(supports_3dnow() || supports_sse())) ? AllocatePrefetchStyle : 0;
|
||||
}
|
||||
};
|
@ -1,419 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along 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/_vm_version_x86_64.cpp.incl"
|
||||
|
||||
int VM_Version::_cpu;
|
||||
int VM_Version::_model;
|
||||
int VM_Version::_stepping;
|
||||
int VM_Version::_cpuFeatures;
|
||||
const char* VM_Version::_features_str = "";
|
||||
VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, };
|
||||
|
||||
static BufferBlob* stub_blob;
|
||||
static const int stub_size = 300;
|
||||
|
||||
extern "C" {
|
||||
typedef void (*getPsrInfo_stub_t)(void*);
|
||||
}
|
||||
static getPsrInfo_stub_t getPsrInfo_stub = NULL;
|
||||
|
||||
|
||||
class VM_Version_StubGenerator: public StubCodeGenerator {
|
||||
public:
|
||||
|
||||
VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
|
||||
|
||||
address generate_getPsrInfo() {
|
||||
|
||||
Label std_cpuid1, ext_cpuid1, ext_cpuid5, done;
|
||||
|
||||
StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub");
|
||||
# define __ _masm->
|
||||
|
||||
address start = __ pc();
|
||||
|
||||
//
|
||||
// void getPsrInfo(VM_Version::CpuidInfo* cpuid_info);
|
||||
//
|
||||
// rcx and rdx are first and second argument registers on windows
|
||||
|
||||
__ push(rbp);
|
||||
__ mov(rbp, c_rarg0); // cpuid_info address
|
||||
__ push(rbx);
|
||||
__ push(rsi);
|
||||
|
||||
//
|
||||
// we have a chip which supports the "cpuid" instruction
|
||||
//
|
||||
__ xorl(rax, rax);
|
||||
__ cpuid();
|
||||
__ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset())));
|
||||
__ movl(Address(rsi, 0), rax);
|
||||
__ movl(Address(rsi, 4), rbx);
|
||||
__ movl(Address(rsi, 8), rcx);
|
||||
__ movl(Address(rsi,12), rdx);
|
||||
|
||||
__ cmpl(rax, 3); // Is cpuid(0x4) supported?
|
||||
__ jccb(Assembler::belowEqual, std_cpuid1);
|
||||
|
||||
//
|
||||
// cpuid(0x4) Deterministic cache params
|
||||
//
|
||||
__ movl(rax, 4);
|
||||
__ xorl(rcx, rcx); // L1 cache
|
||||
__ cpuid();
|
||||
__ push(rax);
|
||||
__ andl(rax, 0x1f); // Determine if valid cache parameters used
|
||||
__ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache
|
||||
__ pop(rax);
|
||||
__ jccb(Assembler::equal, std_cpuid1);
|
||||
|
||||
__ lea(rsi, Address(rbp, in_bytes(VM_Version::dcp_cpuid4_offset())));
|
||||
__ movl(Address(rsi, 0), rax);
|
||||
__ movl(Address(rsi, 4), rbx);
|
||||
__ movl(Address(rsi, 8), rcx);
|
||||
__ movl(Address(rsi,12), rdx);
|
||||
|
||||
//
|
||||
// Standard cpuid(0x1)
|
||||
//
|
||||
__ bind(std_cpuid1);
|
||||
__ movl(rax, 1);
|
||||
__ cpuid();
|
||||
__ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())));
|
||||
__ movl(Address(rsi, 0), rax);
|
||||
__ movl(Address(rsi, 4), rbx);
|
||||
__ movl(Address(rsi, 8), rcx);
|
||||
__ movl(Address(rsi,12), rdx);
|
||||
|
||||
__ movl(rax, 0x80000000);
|
||||
__ cpuid();
|
||||
__ cmpl(rax, 0x80000000); // Is cpuid(0x80000001) supported?
|
||||
__ jcc(Assembler::belowEqual, done);
|
||||
__ cmpl(rax, 0x80000004); // Is cpuid(0x80000005) supported?
|
||||
__ jccb(Assembler::belowEqual, ext_cpuid1);
|
||||
__ cmpl(rax, 0x80000007); // Is cpuid(0x80000008) supported?
|
||||
__ jccb(Assembler::belowEqual, ext_cpuid5);
|
||||
//
|
||||
// Extended cpuid(0x80000008)
|
||||
//
|
||||
__ movl(rax, 0x80000008);
|
||||
__ cpuid();
|
||||
__ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset())));
|
||||
__ movl(Address(rsi, 0), rax);
|
||||
__ movl(Address(rsi, 4), rbx);
|
||||
__ movl(Address(rsi, 8), rcx);
|
||||
__ movl(Address(rsi,12), rdx);
|
||||
|
||||
//
|
||||
// Extended cpuid(0x80000005)
|
||||
//
|
||||
__ bind(ext_cpuid5);
|
||||
__ movl(rax, 0x80000005);
|
||||
__ cpuid();
|
||||
__ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid5_offset())));
|
||||
__ movl(Address(rsi, 0), rax);
|
||||
__ movl(Address(rsi, 4), rbx);
|
||||
__ movl(Address(rsi, 8), rcx);
|
||||
__ movl(Address(rsi,12), rdx);
|
||||
|
||||
//
|
||||
// Extended cpuid(0x80000001)
|
||||
//
|
||||
__ bind(ext_cpuid1);
|
||||
__ movl(rax, 0x80000001);
|
||||
__ cpuid();
|
||||
__ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid1_offset())));
|
||||
__ movl(Address(rsi, 0), rax);
|
||||
__ movl(Address(rsi, 4), rbx);
|
||||
__ movl(Address(rsi, 8), rcx);
|
||||
__ movl(Address(rsi,12), rdx);
|
||||
|
||||
//
|
||||
// return
|
||||
//
|
||||
__ bind(done);
|
||||
__ pop(rsi);
|
||||
__ pop(rbx);
|
||||
__ pop(rbp);
|
||||
__ ret(0);
|
||||
|
||||
# undef __
|
||||
|
||||
return start;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
void VM_Version::get_processor_features() {
|
||||
|
||||
_logical_processors_per_package = 1;
|
||||
// Get raw processor info
|
||||
getPsrInfo_stub(&_cpuid_info);
|
||||
assert_is_initialized();
|
||||
_cpu = extended_cpu_family();
|
||||
_model = extended_cpu_model();
|
||||
_stepping = cpu_stepping();
|
||||
_cpuFeatures = feature_flags();
|
||||
// Logical processors are only available on P4s and above,
|
||||
// and only if hyperthreading is available.
|
||||
_logical_processors_per_package = logical_processor_count();
|
||||
_supports_cx8 = supports_cmpxchg8();
|
||||
// OS should support SSE for x64 and hardware should support at least SSE2.
|
||||
if (!VM_Version::supports_sse2()) {
|
||||
vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported");
|
||||
}
|
||||
if (UseSSE < 4) {
|
||||
_cpuFeatures &= ~CPU_SSE4_1;
|
||||
_cpuFeatures &= ~CPU_SSE4_2;
|
||||
}
|
||||
if (UseSSE < 3) {
|
||||
_cpuFeatures &= ~CPU_SSE3;
|
||||
_cpuFeatures &= ~CPU_SSSE3;
|
||||
_cpuFeatures &= ~CPU_SSE4A;
|
||||
}
|
||||
if (UseSSE < 2)
|
||||
_cpuFeatures &= ~CPU_SSE2;
|
||||
if (UseSSE < 1)
|
||||
_cpuFeatures &= ~CPU_SSE;
|
||||
|
||||
if (logical_processors_per_package() == 1) {
|
||||
// HT processor could be installed on a system which doesn't support HT.
|
||||
_cpuFeatures &= ~CPU_HT;
|
||||
}
|
||||
|
||||
char buf[256];
|
||||
jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
||||
cores_per_cpu(), threads_per_core(),
|
||||
cpu_family(), _model, _stepping,
|
||||
(supports_cmov() ? ", cmov" : ""),
|
||||
(supports_cmpxchg8() ? ", cx8" : ""),
|
||||
(supports_fxsr() ? ", fxsr" : ""),
|
||||
(supports_mmx() ? ", mmx" : ""),
|
||||
(supports_sse() ? ", sse" : ""),
|
||||
(supports_sse2() ? ", sse2" : ""),
|
||||
(supports_sse3() ? ", sse3" : ""),
|
||||
(supports_ssse3()? ", ssse3": ""),
|
||||
(supports_sse4_1() ? ", sse4.1" : ""),
|
||||
(supports_sse4_2() ? ", sse4.2" : ""),
|
||||
(supports_mmx_ext() ? ", mmxext" : ""),
|
||||
(supports_3dnow() ? ", 3dnow" : ""),
|
||||
(supports_3dnow2() ? ", 3dnowext" : ""),
|
||||
(supports_sse4a() ? ", sse4a": ""),
|
||||
(supports_ht() ? ", ht": ""));
|
||||
_features_str = strdup(buf);
|
||||
|
||||
// UseSSE is set to the smaller of what hardware supports and what
|
||||
// the command line requires. I.e., you cannot set UseSSE to 2 on
|
||||
// older Pentiums which do not support it.
|
||||
if( UseSSE > 4 ) UseSSE=4;
|
||||
if( UseSSE < 0 ) UseSSE=0;
|
||||
if( !supports_sse4_1() ) // Drop to 3 if no SSE4 support
|
||||
UseSSE = MIN2((intx)3,UseSSE);
|
||||
if( !supports_sse3() ) // Drop to 2 if no SSE3 support
|
||||
UseSSE = MIN2((intx)2,UseSSE);
|
||||
if( !supports_sse2() ) // Drop to 1 if no SSE2 support
|
||||
UseSSE = MIN2((intx)1,UseSSE);
|
||||
if( !supports_sse () ) // Drop to 0 if no SSE support
|
||||
UseSSE = 0;
|
||||
|
||||
// On new cpus instructions which update whole XMM register should be used
|
||||
// to prevent partial register stall due to dependencies on high half.
|
||||
//
|
||||
// UseXmmLoadAndClearUpper == true --> movsd(xmm, mem)
|
||||
// UseXmmLoadAndClearUpper == false --> movlpd(xmm, mem)
|
||||
// UseXmmRegToRegMoveAll == true --> movaps(xmm, xmm), movapd(xmm, xmm).
|
||||
// UseXmmRegToRegMoveAll == false --> movss(xmm, xmm), movsd(xmm, xmm).
|
||||
|
||||
if( is_amd() ) { // AMD cpus specific settings
|
||||
if( FLAG_IS_DEFAULT(UseAddressNop) ) {
|
||||
// Use it on all AMD cpus starting from Opteron (don't need
|
||||
// a cpu check since only Opteron and new cpus support 64-bits mode).
|
||||
UseAddressNop = true;
|
||||
}
|
||||
if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
|
||||
if( supports_sse4a() ) {
|
||||
UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron
|
||||
} else {
|
||||
UseXmmLoadAndClearUpper = false;
|
||||
}
|
||||
}
|
||||
if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
|
||||
if( supports_sse4a() ) {
|
||||
UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h'
|
||||
} else {
|
||||
UseXmmRegToRegMoveAll = false;
|
||||
}
|
||||
}
|
||||
if( FLAG_IS_DEFAULT(UseXmmI2F) ) {
|
||||
if( supports_sse4a() ) {
|
||||
UseXmmI2F = true;
|
||||
} else {
|
||||
UseXmmI2F = false;
|
||||
}
|
||||
}
|
||||
if( FLAG_IS_DEFAULT(UseXmmI2D) ) {
|
||||
if( supports_sse4a() ) {
|
||||
UseXmmI2D = true;
|
||||
} else {
|
||||
UseXmmI2D = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( is_intel() ) { // Intel cpus specific settings
|
||||
if( FLAG_IS_DEFAULT(UseStoreImmI16) ) {
|
||||
UseStoreImmI16 = false; // don't use it on Intel cpus
|
||||
}
|
||||
if( FLAG_IS_DEFAULT(UseAddressNop) ) {
|
||||
// Use it on all Intel cpus starting from PentiumPro
|
||||
// (don't need a cpu check since only new cpus support 64-bits mode).
|
||||
UseAddressNop = true;
|
||||
}
|
||||
if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
|
||||
UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus
|
||||
}
|
||||
if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
|
||||
if( supports_sse3() ) {
|
||||
UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus
|
||||
} else {
|
||||
UseXmmRegToRegMoveAll = false;
|
||||
}
|
||||
}
|
||||
if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus
|
||||
#ifdef COMPILER2
|
||||
if( FLAG_IS_DEFAULT(MaxLoopPad) ) {
|
||||
// For new Intel cpus do the next optimization:
|
||||
// don't align the beginning of a loop if there are enough instructions
|
||||
// left (NumberOfLoopInstrToAlign defined in c2_globals.hpp)
|
||||
// in current fetch line (OptoLoopAlignment) or the padding
|
||||
// is big (> MaxLoopPad).
|
||||
// Set MaxLoopPad to 11 for new Intel cpus to reduce number of
|
||||
// generated NOP instructions. 11 is the largest size of one
|
||||
// address NOP instruction '0F 1F' (see Assembler::nop(i)).
|
||||
MaxLoopPad = 11;
|
||||
}
|
||||
#endif // COMPILER2
|
||||
if( FLAG_IS_DEFAULT(UseXMMForArrayCopy) ) {
|
||||
UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus
|
||||
}
|
||||
if( supports_sse4_2() && supports_ht() ) { // Newest Intel cpus
|
||||
if( FLAG_IS_DEFAULT(UseUnalignedLoadStores) && UseXMMForArrayCopy ) {
|
||||
UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value");
|
||||
assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value");
|
||||
|
||||
// set valid Prefetch instruction
|
||||
if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
|
||||
if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3;
|
||||
if( ReadPrefetchInstr == 3 && !supports_3dnow() ) ReadPrefetchInstr = 0;
|
||||
|
||||
if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
|
||||
if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3;
|
||||
if( AllocatePrefetchInstr == 3 && !supports_3dnow() ) AllocatePrefetchInstr=0;
|
||||
|
||||
// Allocation prefetch settings
|
||||
intx cache_line_size = L1_data_cache_line_size();
|
||||
if( cache_line_size > AllocatePrefetchStepSize )
|
||||
AllocatePrefetchStepSize = cache_line_size;
|
||||
if( FLAG_IS_DEFAULT(AllocatePrefetchLines) )
|
||||
AllocatePrefetchLines = 3; // Optimistic value
|
||||
assert(AllocatePrefetchLines > 0, "invalid value");
|
||||
if( AllocatePrefetchLines < 1 ) // set valid value in product VM
|
||||
AllocatePrefetchLines = 1; // Conservative value
|
||||
|
||||
AllocatePrefetchDistance = allocate_prefetch_distance();
|
||||
AllocatePrefetchStyle = allocate_prefetch_style();
|
||||
|
||||
if( AllocatePrefetchStyle == 2 && is_intel() &&
|
||||
cpu_family() == 6 && supports_sse3() ) { // watermark prefetching on Core
|
||||
AllocatePrefetchDistance = 384;
|
||||
}
|
||||
assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
|
||||
|
||||
// Prefetch settings
|
||||
PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
|
||||
PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
|
||||
PrefetchFieldsAhead = prefetch_fields_ahead();
|
||||
|
||||
#ifndef PRODUCT
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
tty->print_cr("Logical CPUs per core: %u",
|
||||
logical_processors_per_package());
|
||||
tty->print_cr("UseSSE=%d",UseSSE);
|
||||
tty->print("Allocation: ");
|
||||
if (AllocatePrefetchStyle <= 0) {
|
||||
tty->print_cr("no prefetching");
|
||||
} else {
|
||||
if (AllocatePrefetchInstr == 0) {
|
||||
tty->print("PREFETCHNTA");
|
||||
} else if (AllocatePrefetchInstr == 1) {
|
||||
tty->print("PREFETCHT0");
|
||||
} else if (AllocatePrefetchInstr == 2) {
|
||||
tty->print("PREFETCHT2");
|
||||
} else if (AllocatePrefetchInstr == 3) {
|
||||
tty->print("PREFETCHW");
|
||||
}
|
||||
if (AllocatePrefetchLines > 1) {
|
||||
tty->print_cr(" %d, %d lines with step %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize);
|
||||
} else {
|
||||
tty->print_cr(" %d, one line", AllocatePrefetchDistance);
|
||||
}
|
||||
}
|
||||
if (PrefetchCopyIntervalInBytes > 0) {
|
||||
tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
|
||||
}
|
||||
if (PrefetchScanIntervalInBytes > 0) {
|
||||
tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
|
||||
}
|
||||
if (PrefetchFieldsAhead > 0) {
|
||||
tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
|
||||
}
|
||||
}
|
||||
#endif // !PRODUCT
|
||||
}
|
||||
|
||||
void VM_Version::initialize() {
|
||||
ResourceMark rm;
|
||||
// Making this stub must be FIRST use of assembler
|
||||
|
||||
stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size);
|
||||
if (stub_blob == NULL) {
|
||||
vm_exit_during_initialization("Unable to allocate getPsrInfo_stub");
|
||||
}
|
||||
CodeBuffer c(stub_blob->instructions_begin(),
|
||||
stub_blob->instructions_size());
|
||||
VM_Version_StubGenerator g(&c);
|
||||
getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t,
|
||||
g.generate_getPsrInfo());
|
||||
|
||||
get_processor_features();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1999-2009 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
|
||||
@ -299,13 +299,17 @@ static void check_for_sse_support() {
|
||||
|
||||
}
|
||||
|
||||
#endif // AMD64
|
||||
|
||||
bool os::supports_sse() {
|
||||
#ifdef AMD64
|
||||
return true;
|
||||
#else
|
||||
if (sse_status == SSE_UNKNOWN)
|
||||
check_for_sse_support();
|
||||
return sse_status == SSE_SUPPORTED;
|
||||
}
|
||||
|
||||
#endif // AMD64
|
||||
}
|
||||
|
||||
bool os::is_allocatable(size_t bytes) {
|
||||
#ifdef AMD64
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1999-2009 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,9 +41,10 @@
|
||||
static void fence_bootstrap ();
|
||||
|
||||
static void setup_fpu();
|
||||
static bool supports_sse();
|
||||
#endif // AMD64
|
||||
|
||||
static bool supports_sse();
|
||||
|
||||
static bool is_allocatable(size_t bytes);
|
||||
|
||||
// Used to register dynamic code cache area with the OS
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
// Copyright 1997-2009 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
|
||||
@ -176,7 +176,7 @@ arguments.cpp management.hpp
|
||||
arguments.cpp oop.inline.hpp
|
||||
arguments.cpp os_<os_family>.inline.hpp
|
||||
arguments.cpp universe.inline.hpp
|
||||
arguments.cpp vm_version_<arch_model>.hpp
|
||||
arguments.cpp vm_version_<arch>.hpp
|
||||
|
||||
arguments.hpp java.hpp
|
||||
arguments.hpp perfData.hpp
|
||||
@ -241,7 +241,7 @@ assembler.hpp oopRecorder.hpp
|
||||
assembler.hpp register_<arch>.hpp
|
||||
assembler.hpp relocInfo.hpp
|
||||
assembler.hpp top.hpp
|
||||
assembler.hpp vm_version_<arch_model>.hpp
|
||||
assembler.hpp vm_version_<arch>.hpp
|
||||
|
||||
assembler.inline.hpp assembler.hpp
|
||||
assembler.inline.hpp codeBuffer.hpp
|
||||
@ -280,7 +280,7 @@ atomic.hpp allocation.hpp
|
||||
|
||||
atomic_<os_arch>.inline.hpp atomic.hpp
|
||||
atomic_<os_arch>.inline.hpp os.hpp
|
||||
atomic_<os_arch>.inline.hpp vm_version_<arch_model>.hpp
|
||||
atomic_<os_arch>.inline.hpp vm_version_<arch>.hpp
|
||||
|
||||
// attachListener is jck optional, put cpp deps in includeDB_features
|
||||
|
||||
@ -2176,7 +2176,7 @@ interpreterRuntime.cpp templateTable.hpp
|
||||
interpreterRuntime.cpp threadCritical.hpp
|
||||
interpreterRuntime.cpp universe.inline.hpp
|
||||
interpreterRuntime.cpp vmSymbols.hpp
|
||||
interpreterRuntime.cpp vm_version_<arch_model>.hpp
|
||||
interpreterRuntime.cpp vm_version_<arch>.hpp
|
||||
|
||||
interpreterRuntime.hpp bytecode.hpp
|
||||
interpreterRuntime.hpp frame.inline.hpp
|
||||
@ -2279,7 +2279,7 @@ java.cpp timer.hpp
|
||||
java.cpp universe.hpp
|
||||
java.cpp vmError.hpp
|
||||
java.cpp vm_operations.hpp
|
||||
java.cpp vm_version_<arch_model>.hpp
|
||||
java.cpp vm_version_<arch>.hpp
|
||||
java.cpp vtune.hpp
|
||||
|
||||
java.hpp os.hpp
|
||||
@ -3485,7 +3485,7 @@ register.hpp top.hpp
|
||||
register_<arch>.cpp register_<arch>.hpp
|
||||
|
||||
register_<arch>.hpp register.hpp
|
||||
register_<arch>.hpp vm_version_<arch_model>.hpp
|
||||
register_<arch>.hpp vm_version_<arch>.hpp
|
||||
|
||||
registerMap.hpp globalDefinitions.hpp
|
||||
registerMap.hpp register_<arch>.hpp
|
||||
@ -3835,7 +3835,7 @@ statSampler.cpp resourceArea.hpp
|
||||
statSampler.cpp statSampler.hpp
|
||||
statSampler.cpp systemDictionary.hpp
|
||||
statSampler.cpp vmSymbols.hpp
|
||||
statSampler.cpp vm_version_<arch_model>.hpp
|
||||
statSampler.cpp vm_version_<arch>.hpp
|
||||
|
||||
statSampler.hpp perfData.hpp
|
||||
statSampler.hpp task.hpp
|
||||
@ -4579,22 +4579,22 @@ vm_operations.hpp top.hpp
|
||||
vm_version.cpp arguments.hpp
|
||||
vm_version.cpp oop.inline.hpp
|
||||
vm_version.cpp universe.hpp
|
||||
vm_version.cpp vm_version_<arch_model>.hpp
|
||||
vm_version.cpp vm_version_<arch>.hpp
|
||||
|
||||
vm_version.hpp allocation.hpp
|
||||
vm_version.hpp ostream.hpp
|
||||
|
||||
vm_version_<arch_model>.cpp assembler_<arch>.inline.hpp
|
||||
vm_version_<arch_model>.cpp java.hpp
|
||||
vm_version_<arch_model>.cpp os_<os_family>.inline.hpp
|
||||
vm_version_<arch_model>.cpp resourceArea.hpp
|
||||
vm_version_<arch_model>.cpp stubCodeGenerator.hpp
|
||||
vm_version_<arch_model>.cpp vm_version_<arch_model>.hpp
|
||||
vm_version_<arch>.cpp assembler_<arch>.inline.hpp
|
||||
vm_version_<arch>.cpp java.hpp
|
||||
vm_version_<arch>.cpp os_<os_family>.inline.hpp
|
||||
vm_version_<arch>.cpp resourceArea.hpp
|
||||
vm_version_<arch>.cpp stubCodeGenerator.hpp
|
||||
vm_version_<arch>.cpp vm_version_<arch>.hpp
|
||||
|
||||
vm_version_<arch_model>.hpp globals_extension.hpp
|
||||
vm_version_<arch_model>.hpp vm_version.hpp
|
||||
vm_version_<arch>.hpp globals_extension.hpp
|
||||
vm_version_<arch>.hpp vm_version.hpp
|
||||
|
||||
vm_version_<os_arch>.cpp vm_version_<arch_model>.hpp
|
||||
vm_version_<os_arch>.cpp vm_version_<arch>.hpp
|
||||
|
||||
vmreg.cpp assembler.hpp
|
||||
vmreg.cpp vmreg.hpp
|
||||
|
@ -756,6 +756,16 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (result->Opcode() == Op_SCMemProj) {
|
||||
assert(result->in(0)->is_LoadStore(), "sanity");
|
||||
const Type *at = phase->type(result->in(0)->in(MemNode::Address));
|
||||
if (at != Type::TOP) {
|
||||
assert (at->isa_ptr() != NULL, "pointer type required.");
|
||||
int idx = C->get_alias_index(at->is_ptr());
|
||||
assert(idx != alias_idx, "Object is not scalar replaceable if a LoadStore node access its field");
|
||||
break;
|
||||
}
|
||||
result = result->in(0)->in(MemNode::Memory);
|
||||
}
|
||||
}
|
||||
if (result->is_Phi()) {
|
||||
|
@ -250,6 +250,15 @@ static Node *scan_mem_chain(Node *mem, int alias_idx, int offset, Node *start_me
|
||||
assert(adr_idx == Compile::AliasIdxRaw, "address must match or be raw");
|
||||
}
|
||||
mem = mem->in(MemNode::Memory);
|
||||
} else if (mem->Opcode() == Op_SCMemProj) {
|
||||
assert(mem->in(0)->is_LoadStore(), "sanity");
|
||||
const TypePtr* atype = mem->in(0)->in(MemNode::Address)->bottom_type()->is_ptr();
|
||||
int adr_idx = Compile::current()->get_alias_index(atype);
|
||||
if (adr_idx == alias_idx) {
|
||||
assert(false, "Object is not scalar replaceable if a LoadStore node access its field");
|
||||
return NULL;
|
||||
}
|
||||
mem = mem->in(0)->in(MemNode::Memory);
|
||||
} else {
|
||||
return mem;
|
||||
}
|
||||
@ -329,8 +338,15 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type *
|
||||
return NULL;
|
||||
}
|
||||
values.at_put(j, val);
|
||||
} else if (val->Opcode() == Op_SCMemProj) {
|
||||
assert(val->in(0)->is_LoadStore(), "sanity");
|
||||
assert(false, "Object is not scalar replaceable if a LoadStore node access its field");
|
||||
return NULL;
|
||||
} else {
|
||||
#ifdef ASSERT
|
||||
val->dump();
|
||||
assert(false, "unknown node on this path");
|
||||
#endif
|
||||
return NULL; // unknown node on this path
|
||||
}
|
||||
}
|
||||
|
@ -1707,11 +1707,18 @@ OptoReg::Name Matcher::find_receiver( bool is_outgoing ) {
|
||||
void Matcher::find_shared( Node *n ) {
|
||||
// Allocate stack of size C->unique() * 2 to avoid frequent realloc
|
||||
MStack mstack(C->unique() * 2);
|
||||
// Mark nodes as address_visited if they are inputs to an address expression
|
||||
VectorSet address_visited(Thread::current()->resource_area());
|
||||
mstack.push(n, Visit); // Don't need to pre-visit root node
|
||||
while (mstack.is_nonempty()) {
|
||||
n = mstack.node(); // Leave node on stack
|
||||
Node_State nstate = mstack.state();
|
||||
uint nop = n->Opcode();
|
||||
if (nstate == Pre_Visit) {
|
||||
if (address_visited.test(n->_idx)) { // Visited in address already?
|
||||
// Flag as visited and shared now.
|
||||
set_visited(n);
|
||||
}
|
||||
if (is_visited(n)) { // Visited already?
|
||||
// Node is shared and has no reason to clone. Flag it as shared.
|
||||
// This causes it to match into a register for the sharing.
|
||||
@ -1726,7 +1733,7 @@ void Matcher::find_shared( Node *n ) {
|
||||
set_visited(n); // Flag as visited now
|
||||
bool mem_op = false;
|
||||
|
||||
switch( n->Opcode() ) { // Handle some opcodes special
|
||||
switch( nop ) { // Handle some opcodes special
|
||||
case Op_Phi: // Treat Phis as shared roots
|
||||
case Op_Parm:
|
||||
case Op_Proj: // All handled specially during matching
|
||||
@ -1887,34 +1894,51 @@ void Matcher::find_shared( Node *n ) {
|
||||
// to have a single use so force sharing here.
|
||||
set_shared(m->in(AddPNode::Base)->in(1));
|
||||
}
|
||||
|
||||
// Some inputs for address expression are not put on stack
|
||||
// to avoid marking them as shared and forcing them into register
|
||||
// if they are used only in address expressions.
|
||||
// But they should be marked as shared if there are other uses
|
||||
// besides address expressions.
|
||||
|
||||
Node *off = m->in(AddPNode::Offset);
|
||||
if( off->is_Con() ) {
|
||||
set_visited(m); // Flag as visited now
|
||||
if( off->is_Con() &&
|
||||
// When there are other uses besides address expressions
|
||||
// put it on stack and mark as shared.
|
||||
!is_visited(m) ) {
|
||||
address_visited.test_set(m->_idx); // Flag as address_visited
|
||||
Node *adr = m->in(AddPNode::Address);
|
||||
|
||||
// Intel, ARM and friends can handle 2 adds in addressing mode
|
||||
if( clone_shift_expressions && adr->is_AddP() &&
|
||||
// AtomicAdd is not an addressing expression.
|
||||
// Cheap to find it by looking for screwy base.
|
||||
!adr->in(AddPNode::Base)->is_top() ) {
|
||||
set_visited(adr); // Flag as visited now
|
||||
!adr->in(AddPNode::Base)->is_top() &&
|
||||
// Are there other uses besides address expressions?
|
||||
!is_visited(adr) ) {
|
||||
address_visited.set(adr->_idx); // Flag as address_visited
|
||||
Node *shift = adr->in(AddPNode::Offset);
|
||||
// Check for shift by small constant as well
|
||||
if( shift->Opcode() == Op_LShiftX && shift->in(2)->is_Con() &&
|
||||
shift->in(2)->get_int() <= 3 ) {
|
||||
set_visited(shift); // Flag as visited now
|
||||
shift->in(2)->get_int() <= 3 &&
|
||||
// Are there other uses besides address expressions?
|
||||
!is_visited(shift) ) {
|
||||
address_visited.set(shift->_idx); // Flag as address_visited
|
||||
mstack.push(shift->in(2), Visit);
|
||||
Node *conv = shift->in(1);
|
||||
#ifdef _LP64
|
||||
// Allow Matcher to match the rule which bypass
|
||||
// ConvI2L operation for an array index on LP64
|
||||
// if the index value is positive.
|
||||
if( shift->in(1)->Opcode() == Op_ConvI2L &&
|
||||
shift->in(1)->as_Type()->type()->is_long()->_lo >= 0 ) {
|
||||
set_visited(shift->in(1)); // Flag as visited now
|
||||
mstack.push(shift->in(1)->in(1), Pre_Visit);
|
||||
if( conv->Opcode() == Op_ConvI2L &&
|
||||
conv->as_Type()->type()->is_long()->_lo >= 0 &&
|
||||
// Are there other uses besides address expressions?
|
||||
!is_visited(conv) ) {
|
||||
address_visited.set(conv->_idx); // Flag as address_visited
|
||||
mstack.push(conv->in(1), Pre_Visit);
|
||||
} else
|
||||
#endif
|
||||
mstack.push(shift->in(1), Pre_Visit);
|
||||
mstack.push(conv, Pre_Visit);
|
||||
} else {
|
||||
mstack.push(shift, Pre_Visit);
|
||||
}
|
||||
|
@ -1066,11 +1066,11 @@ Node* LoadNode::eliminate_autobox(PhaseGVN* phase) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
LoadNode* load = NULL;
|
||||
if (allocation != NULL && base->in(load_index)->is_Load()) {
|
||||
load = base->in(load_index)->as_Load();
|
||||
}
|
||||
if (load != NULL && in(Memory)->is_Phi() && in(Memory)->in(0) == base->in(0)) {
|
||||
bool has_load = ( allocation != NULL &&
|
||||
(base->in(load_index)->is_Load() ||
|
||||
base->in(load_index)->is_DecodeN() &&
|
||||
base->in(load_index)->in(1)->is_Load()) );
|
||||
if (has_load && in(Memory)->is_Phi() && in(Memory)->in(0) == base->in(0)) {
|
||||
// Push the loads from the phi that comes from valueOf up
|
||||
// through it to allow elimination of the loads and the recovery
|
||||
// of the original value.
|
||||
@ -1106,11 +1106,20 @@ Node* LoadNode::eliminate_autobox(PhaseGVN* phase) {
|
||||
result->set_req(load_index, in2);
|
||||
return result;
|
||||
}
|
||||
} else if (base->is_Load()) {
|
||||
} else if (base->is_Load() ||
|
||||
base->is_DecodeN() && base->in(1)->is_Load()) {
|
||||
if (base->is_DecodeN()) {
|
||||
// Get LoadN node which loads cached Integer object
|
||||
base = base->in(1);
|
||||
}
|
||||
// Eliminate the load of Integer.value for integers from the cache
|
||||
// array by deriving the value from the index into the array.
|
||||
// Capture the offset of the load and then reverse the computation.
|
||||
Node* load_base = base->in(Address)->in(AddPNode::Base);
|
||||
if (load_base->is_DecodeN()) {
|
||||
// Get LoadN node which loads IntegerCache.cache field
|
||||
load_base = load_base->in(1);
|
||||
}
|
||||
if (load_base != NULL) {
|
||||
Compile::AliasType* atp = phase->C->alias_type(load_base->adr_type());
|
||||
intptr_t cache_offset;
|
||||
|
@ -20,3 +20,5 @@ e9f750f0a3a00413a7b77028b2ecdabb7129ae32 jdk7-b38
|
||||
96fe28d4a9131e1a97bfe00f779e5626cd09c4d0 jdk7-b43
|
||||
b203df0741af3eb08687bc5eb798bac87363758d jdk7-b44
|
||||
0f113667880d335cfa2c35721b1b45144fb757f5 jdk7-b45
|
||||
b2271877894af809b7703767fe8d4e38591a02a2 jdk7-b46
|
||||
d711ad1954b294957737ea386cfd4d3c05028a36 jdk7-b47
|
||||
|
@ -20,3 +20,5 @@ a8379d24aa03386610169cb0f4e4b8ed266a2e8d jdk7-b41
|
||||
1ad2f51564db6ca4c6d95760cf13fb083d3dec94 jdk7-b43
|
||||
344485a03674b6950a7a23d01a6efb8055afb6ec jdk7-b44
|
||||
dea7753d713936c5b6fd942a91811b0676537fd0 jdk7-b45
|
||||
af4a3eeb7812a5d09a241c50b51b3c648a9d45c1 jdk7-b46
|
||||
223011570edbd49bb0fe51cdeb2089f95d305267 jdk7-b47
|
||||
|
@ -20,3 +20,5 @@ cc5f810b5af8a3a83b0df5a29d9e24d7a0ff8086 jdk7-b38
|
||||
50c67678b0d180063ade199d398b67a54063fa7f jdk7-b43
|
||||
d8eb2738db6b148911177d9bcfe888109b7f2f71 jdk7-b44
|
||||
527b426497a259d0605d069e3930e838948531a6 jdk7-b45
|
||||
4b03e27a44090d1f646af28dc58f9ead827e24c7 jdk7-b46
|
||||
b4ac413b1f129eeef0acab3f31081c1b7dfe3b27 jdk7-b47
|
||||
|
@ -153,7 +153,6 @@ FILES_cpp = \
|
||||
awt_Menu.cpp \
|
||||
awt_MenuBar.cpp \
|
||||
awt_MenuItem.cpp \
|
||||
awt_MMStub.cpp \
|
||||
awt_MouseEvent.cpp \
|
||||
awt_Object.cpp \
|
||||
awt_Palette.cpp \
|
||||
@ -171,7 +170,6 @@ FILES_cpp = \
|
||||
awt_TextComponent.cpp \
|
||||
awt_TextField.cpp \
|
||||
awt_Toolkit.cpp \
|
||||
awt_Unicode.cpp \
|
||||
awt_Window.cpp \
|
||||
awt_Win32GraphicsEnv.cpp \
|
||||
awt_Win32GraphicsDevice.cpp \
|
||||
@ -202,6 +200,4 @@ FILES_cpp = \
|
||||
ThemeReader.cpp \
|
||||
ComCtl32Util.cpp \
|
||||
initIDs.cpp \
|
||||
awt_dlls.cpp \
|
||||
UnicowsLoader.cpp \
|
||||
MouseInfo.cpp
|
||||
|
@ -47,7 +47,7 @@ OTHER_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES
|
||||
# sun/awt/resources handled by java/awt/Makefile
|
||||
# sun/java2d/pisces handled by sun/pisces/Makefile
|
||||
#
|
||||
AUTO_FILES_JAVA_DIRS = sun/awt sun/java2d
|
||||
AUTO_FILES_JAVA_DIRS = sun/awt sun/java2d com/sun/awt
|
||||
AUTO_JAVA_PRUNE = resources pisces
|
||||
|
||||
ifeq ($(PLATFORM), windows)
|
||||
@ -247,8 +247,14 @@ endif # PLATFORM
|
||||
ifeq ($(PLATFORM), windows)
|
||||
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WINDOWS
|
||||
OTHER_LDLIBS = kernel32.lib user32.lib gdi32.lib winspool.lib \
|
||||
imm32.lib ole32.lib uuid.lib $(JVMLIB) \
|
||||
shell32.lib
|
||||
imm32.lib ole32.lib uuid.lib shell32.lib \
|
||||
comdlg32.lib winmm.lib comctl32.lib delayimp.lib \
|
||||
$(JVMLIB) \
|
||||
/DELAYLOAD:user32.dll /DELAYLOAD:gdi32.dll \
|
||||
/DELAYLOAD:shell32.dll /DELAYLOAD:winmm.dll \
|
||||
/DELAYLOAD:winspool.drv /DELAYLOAD:imm32.dll \
|
||||
/DELAYLOAD:ole32.dll /DELAYLOAD:comdlg32.dll \
|
||||
/DELAYLOAD:comctl32.dll
|
||||
|
||||
clean:: awt.clean
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/UnicowsLoader.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_MMStub.h ../../../src/windows/native/sun/windows/awt_Multimon.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Unicode.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h
|
||||
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h
|
||||
|
@ -67,7 +67,7 @@ ifneq ($(PLATFORM), windows)
|
||||
OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpthread
|
||||
else # PLATFORM
|
||||
CFLAGS += -DWITH_WIN32
|
||||
OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib
|
||||
OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib /DELAYLOAD:user32.dll
|
||||
#$(JVMLIB) $(OBJDIR)/../../jpeg/$(OBJDIRNAME)/jpeg$(SUFFIX).lib
|
||||
endif # PLATFORM
|
||||
|
||||
@ -85,13 +85,6 @@ vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen
|
||||
CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen
|
||||
CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
|
||||
|
||||
ifeq ($(PLATFORM), linux)
|
||||
ifeq ($(ARCH_DATA_MODEL), 64)
|
||||
# 64-bit gcc has problems compiling MMX instructions.
|
||||
# Google it for more details. Possibly the newer versions of
|
||||
# the PNG-library and/or the new compiler will not need this
|
||||
# option in the future.
|
||||
CPPFLAGS += -DPNG_NO_MMX_CODE
|
||||
endif
|
||||
endif
|
||||
|
||||
# Shun the less than portable MMX assembly code in pnggccrd.c,
|
||||
# and use alternative implementations in C.
|
||||
CPPFLAGS += -DPNG_NO_MMX_CODE
|
||||
|
@ -151,6 +151,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
|
||||
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
|
||||
Java_sun_awt_X11_XRobotPeer_setup;
|
||||
Java_sun_awt_X11_XRobotPeer_getNumberOfButtonsImpl;
|
||||
Java_java_awt_Component_initIDs;
|
||||
Java_java_awt_Container_initIDs;
|
||||
Java_java_awt_Button_initIDs;
|
||||
@ -288,6 +289,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_awt_X11_XlibWrapper_XGetIconSizes;
|
||||
Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym;
|
||||
Java_sun_awt_X11_XlibWrapper_XKeysymToKeycode;
|
||||
Java_sun_awt_X11_XlibWrapper_XQueryKeymap;
|
||||
Java_sun_awt_X11_XlibWrapper_XGetModifierMapping;
|
||||
Java_sun_awt_X11_XlibWrapper_XFreeModifiermap;
|
||||
Java_sun_awt_X11_XlibWrapper_XChangeActivePointerGrab;
|
||||
|
@ -1718,6 +1718,7 @@ javax/swing/plaf/basic/BasicToolBarSeparatorUI
|
||||
sun/awt/color/CMM
|
||||
java/applet/Applet
|
||||
java/awt/Panel
|
||||
com/sun/awt/AWTUtilities
|
||||
javax/swing/KeyboardManager$ComponentKeyStrokePair
|
||||
sun/awt/EmbeddedFrame
|
||||
sun/awt/im/InputMethodContext
|
||||
|
@ -961,6 +961,7 @@ sun/awt/SunToolkit$3
|
||||
javax/swing/SystemEventQueueUtilities$ComponentWorkRequest
|
||||
java/applet/Applet
|
||||
java/awt/Panel
|
||||
com/sun/awt/AWTUtilities
|
||||
sun/awt/X11/XExposeEvent
|
||||
java/util/jar/Manifest
|
||||
java/io/ByteArrayInputStream
|
||||
|
@ -1621,6 +1621,7 @@ javax/swing/plaf/basic/BasicToolBarSeparatorUI
|
||||
sun/font/FontDesignMetrics$MetricsKey
|
||||
java/applet/Applet
|
||||
java/awt/Panel
|
||||
com/sun/awt/AWTUtilities
|
||||
javax/swing/KeyboardManager$ComponentKeyStrokePair
|
||||
sun/awt/im/InputMethodContext
|
||||
java/awt/im/spi/InputMethodContext
|
||||
|
104
jdk/src/share/classes/com/sun/awt/AWTUtilities.java
Normal file
104
jdk/src/share/classes/com/sun/awt/AWTUtilities.java
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2009 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.
|
||||
*/
|
||||
|
||||
package com.sun.awt;
|
||||
|
||||
import java.awt.*;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
|
||||
/**
|
||||
* A collection of utility methods for AWT.
|
||||
*
|
||||
* The functionality provided by the static methods of the class includes:
|
||||
* <ul>
|
||||
* <li>Setting a 'mixing-cutout' shape for a component.
|
||||
* </ul>
|
||||
* <p>
|
||||
* <b>WARNING</b>: This class is an implementation detail and only meant
|
||||
* for limited use outside of the core platform. This API may change
|
||||
* drastically between update release, and it may even be
|
||||
* removed or be moved in some other package(s)/class(es).
|
||||
*/
|
||||
public final class AWTUtilities {
|
||||
|
||||
/**
|
||||
* The AWTUtilities class should not be instantiated
|
||||
*/
|
||||
private AWTUtilities() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a 'mixing-cutout' shape for the given component.
|
||||
*
|
||||
* By default a lightweight component is treated as an opaque rectangle for
|
||||
* the purposes of the Heavyweight/Lightweight Components Mixing feature.
|
||||
* This method enables developers to set an arbitrary shape to be cut out
|
||||
* from heavyweight components positioned underneath the lightweight
|
||||
* component in the z-order.
|
||||
* <p>
|
||||
* The {@code shape} argument may have the following values:
|
||||
* <ul>
|
||||
* <li>{@code null} - reverts the default cutout shape (the rectangle equal
|
||||
* to the component's {@code getBounds()})
|
||||
* <li><i>empty-shape</i> - does not cut out anything from heavyweight
|
||||
* components. This makes the given lightweight component effectively
|
||||
* transparent. Note that descendants of the lightweight component still
|
||||
* affect the shapes of heavyweight components. An example of an
|
||||
* <i>empty-shape</i> is {@code new Rectangle()}.
|
||||
* <li><i>non-empty-shape</i> - the given shape will be cut out from
|
||||
* heavyweight components.
|
||||
* </ul>
|
||||
* <p>
|
||||
* The most common example when the 'mixing-cutout' shape is needed is a
|
||||
* glass pane component. The {@link JRootPane#setGlassPane()} method
|
||||
* automatically sets the <i>empty-shape</i> as the 'mixing-cutout' shape
|
||||
* for the given glass pane component. If a developer needs some other
|
||||
* 'mixing-cutout' shape for the glass pane (which is rare), this must be
|
||||
* changed manually after installing the glass pane to the root pane.
|
||||
* <p>
|
||||
* Note that the 'mixing-cutout' shape neither affects painting, nor the
|
||||
* mouse events handling for the given component. It is used exclusively
|
||||
* for the purposes of the Heavyweight/Lightweight Components Mixing
|
||||
* feature.
|
||||
*
|
||||
* @param component the component that needs non-default
|
||||
* 'mixing-cutout' shape
|
||||
* @param shape the new 'mixing-cutout' shape
|
||||
* @throws NullPointerException if the component argument is {@code null}
|
||||
*/
|
||||
public static void setComponentMixingCutoutShape(Component component,
|
||||
Shape shape)
|
||||
{
|
||||
if (component == null) {
|
||||
throw new NullPointerException(
|
||||
"The component argument should not be null.");
|
||||
}
|
||||
|
||||
AWTAccessor.getComponentAccessor().setMixingCutoutShape(component,
|
||||
shape);
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ public class Choice extends Component implements ItemSelectable, Accessible {
|
||||
pItems.insertElementAt(item, index);
|
||||
ChoicePeer peer = (ChoicePeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.addItem(item, index);
|
||||
peer.add(item, index);
|
||||
}
|
||||
// no selection or selection shifted up
|
||||
if (selectedIndex < 0 || selectedIndex >= index) {
|
||||
|
@ -65,8 +65,10 @@ import java.applet.Applet;
|
||||
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.ConstrainableGraphics;
|
||||
import sun.awt.SubRegionShowable;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.WindowClosingListener;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.EmbeddedFrame;
|
||||
@ -758,22 +760,26 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* The shape set with the applyCompoundShape() method. It uncludes the result
|
||||
* of the HW/LW mixing related shape computation. It may also include
|
||||
* the user-specified shape of the component.
|
||||
* The 'null' value means the component has normal shape (or has no shape at all)
|
||||
* and applyCompoundShape() will skip the following shape identical to normal.
|
||||
*/
|
||||
private transient Region compoundShape = null;
|
||||
|
||||
/*
|
||||
* Represents the shape of this lightweight component to be cut out from
|
||||
* heavyweight components should they intersect. Possible values:
|
||||
* 1. null - consider the shape rectangular
|
||||
* 2. EMPTY_REGION - nothing gets cut out (children still get cut out)
|
||||
* 3. non-empty - this shape gets cut out.
|
||||
*/
|
||||
private transient Region mixingCutoutRegion = null;
|
||||
|
||||
/*
|
||||
* Indicates whether addNotify() is complete
|
||||
* (i.e. the peer is created).
|
||||
*/
|
||||
private transient boolean isAddNotifyComplete = false;
|
||||
|
||||
private static final PropertyChangeListener opaquePropertyChangeListener =
|
||||
new PropertyChangeListener() {
|
||||
public void propertyChange(java.beans.PropertyChangeEvent evt) {
|
||||
((Component)evt.getSource()).mixOnOpaqueChanging();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Should only be used in subclass getBounds to check that part of bounds
|
||||
* is actualy changing
|
||||
@ -793,6 +799,39 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
AWTAccessor.setComponentAccessor(new AWTAccessor.ComponentAccessor() {
|
||||
public void setMixingCutoutShape(Component comp, Shape shape) {
|
||||
Region region = shape == null ? null :
|
||||
Region.getInstance(shape, null);
|
||||
|
||||
synchronized (comp.getTreeLock()) {
|
||||
boolean needShowing = false;
|
||||
boolean needHiding = false;
|
||||
|
||||
if (!comp.isNonOpaqueForMixing()) {
|
||||
needHiding = true;
|
||||
}
|
||||
|
||||
comp.mixingCutoutRegion = region;
|
||||
|
||||
if (!comp.isNonOpaqueForMixing()) {
|
||||
needShowing = true;
|
||||
}
|
||||
|
||||
if (comp.isMixingNeeded()) {
|
||||
if (needHiding) {
|
||||
comp.mixOnHiding(comp.isLightweight());
|
||||
}
|
||||
if (needShowing) {
|
||||
comp.mixOnShowing();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new component. Class <code>Component</code> can be
|
||||
* extended directly to create a lightweight component that does not
|
||||
@ -1306,7 +1345,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
enabled = true;
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer != null) {
|
||||
peer.enable();
|
||||
peer.setEnabled(true);
|
||||
if (visible) {
|
||||
updateCursorImmediately();
|
||||
}
|
||||
@ -1355,7 +1394,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer != null) {
|
||||
peer.disable();
|
||||
peer.setEnabled(false);
|
||||
if (visible) {
|
||||
updateCursorImmediately();
|
||||
}
|
||||
@ -1447,7 +1486,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
mixOnShowing();
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer != null) {
|
||||
peer.show();
|
||||
peer.setVisible(true);
|
||||
createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
|
||||
this, parent,
|
||||
HierarchyEvent.SHOWING_CHANGED,
|
||||
@ -1517,7 +1556,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer != null) {
|
||||
peer.hide();
|
||||
peer.setVisible(false);
|
||||
createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
|
||||
this, parent,
|
||||
HierarchyEvent.SHOWING_CHANGED,
|
||||
@ -2414,7 +2453,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (dim == null || !(isPreferredSizeSet() || isValid())) {
|
||||
synchronized (getTreeLock()) {
|
||||
prefSize = (peer != null) ?
|
||||
peer.preferredSize() :
|
||||
peer.getPreferredSize() :
|
||||
getMinimumSize();
|
||||
dim = prefSize;
|
||||
}
|
||||
@ -2484,7 +2523,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (dim == null || !(isMinimumSizeSet() || isValid())) {
|
||||
synchronized (getTreeLock()) {
|
||||
minSize = (peer != null) ?
|
||||
peer.minimumSize() :
|
||||
peer.getMinimumSize() :
|
||||
size();
|
||||
dim = minSize;
|
||||
}
|
||||
@ -3171,7 +3210,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
private Insets getInsets_NoClientCode() {
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer instanceof ContainerPeer) {
|
||||
return (Insets)((ContainerPeer)peer).insets().clone();
|
||||
return (Insets)((ContainerPeer)peer).getInsets().clone();
|
||||
}
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
@ -6643,7 +6682,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
|
||||
if (!isAddNotifyComplete) {
|
||||
addPropertyChangeListener("opaque", opaquePropertyChangeListener);
|
||||
mixOnShowing();
|
||||
}
|
||||
|
||||
@ -6722,7 +6760,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
|
||||
// Hide peer first to stop system events such as cursor moves.
|
||||
if (visible) {
|
||||
p.hide();
|
||||
p.setVisible(false);
|
||||
}
|
||||
|
||||
peer = null; // Stop peer updates.
|
||||
@ -6735,9 +6773,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
p.dispose();
|
||||
|
||||
mixOnHiding(isLightweight);
|
||||
removePropertyChangeListener("opaque", opaquePropertyChangeListener);
|
||||
|
||||
isAddNotifyComplete = false;
|
||||
// Nullifying compoundShape means that the component has normal shape
|
||||
// (or has no shape at all).
|
||||
this.compoundShape = null;
|
||||
}
|
||||
|
||||
if (hierarchyListener != null ||
|
||||
@ -9401,10 +9441,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* Null-layout of the container or absence of the container mean
|
||||
* the bounds of the component are final and can be trusted.
|
||||
*/
|
||||
private boolean areBoundsValid() {
|
||||
final boolean areBoundsValid() {
|
||||
Container cont = getContainer();
|
||||
return cont == null || cont.isValid()
|
||||
|| cont.getLayout() == null;
|
||||
return cont == null || cont.isValid() || cont.getLayout() == null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -9413,6 +9452,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
*/
|
||||
void applyCompoundShape(Region shape) {
|
||||
checkTreeLock();
|
||||
|
||||
if (!areBoundsValid()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isLightweight()) {
|
||||
ComponentPeer peer = getPeer();
|
||||
if (peer != null) {
|
||||
@ -9422,22 +9469,31 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
// with some incorrect Region object with loX being
|
||||
// greater than the hiX for instance.
|
||||
if (shape.isEmpty()) {
|
||||
shape = Region.getInstanceXYWH(0, 0, 0, 0);
|
||||
shape = Region.EMPTY_REGION;
|
||||
}
|
||||
|
||||
|
||||
// Note: the shape is not really copied/cloned. We create
|
||||
// the Region object ourselves, so there's no any possibility
|
||||
// to modify the object outside of the mixing code.
|
||||
this.compoundShape = shape;
|
||||
|
||||
if (areBoundsValid()) {
|
||||
// Nullifying compoundShape means that the component has normal shape
|
||||
// (or has no shape at all).
|
||||
if (shape.equals(getNormalShape())) {
|
||||
if (this.compoundShape == null) {
|
||||
return;
|
||||
}
|
||||
this.compoundShape = null;
|
||||
peer.applyShape(null);
|
||||
} else {
|
||||
if (shape.equals(getAppliedShape())) {
|
||||
return;
|
||||
}
|
||||
this.compoundShape = shape;
|
||||
Point compAbsolute = getLocationOnWindow();
|
||||
|
||||
if (mixingLog.isLoggable(Level.FINER)) {
|
||||
mixingLog.fine("this = " + this +
|
||||
"; compAbsolute=" + compAbsolute + "; shape=" + shape);
|
||||
"; compAbsolute=" + compAbsolute + "; shape=" + shape);
|
||||
}
|
||||
|
||||
peer.applyShape(shape.getTranslatedRegion(-compAbsolute.x, -compAbsolute.y));
|
||||
}
|
||||
}
|
||||
@ -9460,7 +9516,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
Point curLocation = getLocation();
|
||||
|
||||
for (Container parent = getContainer();
|
||||
parent != null;
|
||||
parent != null && !(parent instanceof Window);
|
||||
parent = parent.getContainer())
|
||||
{
|
||||
curLocation.x += parent.getX();
|
||||
@ -9486,7 +9542,28 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
);
|
||||
}
|
||||
|
||||
private int getSiblingIndexAbove() {
|
||||
/**
|
||||
* Returns the "opaque shape" of the component.
|
||||
*
|
||||
* The opaque shape of a lightweight components is the actual shape that
|
||||
* needs to be cut off of the heavyweight components in order to mix this
|
||||
* lightweight component correctly with them.
|
||||
*
|
||||
* The method is overriden in the java.awt.Container to handle non-opaque
|
||||
* containers containing opaque children.
|
||||
*
|
||||
* See 6637655 for details.
|
||||
*/
|
||||
Region getOpaqueShape() {
|
||||
checkTreeLock();
|
||||
if (mixingCutoutRegion != null) {
|
||||
return mixingCutoutRegion;
|
||||
} else {
|
||||
return getNormalShape();
|
||||
}
|
||||
}
|
||||
|
||||
final int getSiblingIndexAbove() {
|
||||
checkTreeLock();
|
||||
Container parent = getContainer();
|
||||
if (parent == null) {
|
||||
@ -9498,7 +9575,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
return nextAbove < 0 ? -1 : nextAbove;
|
||||
}
|
||||
|
||||
private int getSiblingIndexBelow() {
|
||||
final int getSiblingIndexBelow() {
|
||||
checkTreeLock();
|
||||
Container parent = getContainer();
|
||||
if (parent == null) {
|
||||
@ -9510,6 +9587,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
return nextBelow >= parent.getComponentCount() ? -1 : nextBelow;
|
||||
}
|
||||
|
||||
final boolean isNonOpaqueForMixing() {
|
||||
return mixingCutoutRegion != null &&
|
||||
mixingCutoutRegion.isEmpty();
|
||||
}
|
||||
|
||||
private Region calculateCurrentShape() {
|
||||
checkTreeLock();
|
||||
Region s = getNormalShape();
|
||||
@ -9532,8 +9614,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* implementation of the Container class.
|
||||
*/
|
||||
Component c = cont.getComponent(index);
|
||||
if (c.isLightweight() && c.isShowing() && c.isOpaque()) {
|
||||
s = s.getDifference(c.getNormalShape());
|
||||
if (c.isLightweight() && c.isShowing()) {
|
||||
s = s.getDifference(c.getOpaqueShape());
|
||||
}
|
||||
}
|
||||
|
||||
@ -9558,6 +9640,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
void applyCurrentShape() {
|
||||
checkTreeLock();
|
||||
if (!areBoundsValid()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
|
||||
}
|
||||
return; // Because applyCompoundShape() ignores such components anyway
|
||||
}
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
@ -9576,16 +9661,54 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
applyCompoundShape(getAppliedShape().getDifference(s));
|
||||
}
|
||||
|
||||
private final void applyCurrentShapeBelowMe() {
|
||||
checkTreeLock();
|
||||
Container parent = getContainer();
|
||||
if (parent != null && parent.isShowing()) {
|
||||
// First, reapply shapes of my siblings
|
||||
parent.recursiveApplyCurrentShape(getSiblingIndexBelow());
|
||||
|
||||
// Second, if my container is non-opaque, reapply shapes of siblings of my container
|
||||
Container parent2 = parent.getContainer();
|
||||
while (!parent.isOpaque() && parent2 != null) {
|
||||
parent2.recursiveApplyCurrentShape(parent.getSiblingIndexBelow());
|
||||
|
||||
parent = parent2;
|
||||
parent2 = parent.getContainer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final void subtractAndApplyShapeBelowMe() {
|
||||
checkTreeLock();
|
||||
Container parent = getContainer();
|
||||
if (parent != null && isShowing()) {
|
||||
Region opaqueShape = getOpaqueShape();
|
||||
|
||||
// First, cut my siblings
|
||||
parent.recursiveSubtractAndApplyShape(opaqueShape, getSiblingIndexBelow());
|
||||
|
||||
// Second, if my container is non-opaque, cut siblings of my container
|
||||
Container parent2 = parent.getContainer();
|
||||
while (!parent.isOpaque() && parent2 != null) {
|
||||
parent2.recursiveSubtractAndApplyShape(opaqueShape, parent.getSiblingIndexBelow());
|
||||
|
||||
parent = parent2;
|
||||
parent2 = parent.getContainer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mixOnShowing() {
|
||||
synchronized (getTreeLock()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
if (isLightweight()) {
|
||||
Container parent = getContainer();
|
||||
if (parent != null && isShowing() && isOpaque()) {
|
||||
parent.recursiveSubtractAndApplyShape(getNormalShape(), getSiblingIndexBelow());
|
||||
}
|
||||
subtractAndApplyShapeBelowMe();
|
||||
} else {
|
||||
applyCurrentShape();
|
||||
}
|
||||
@ -9599,12 +9722,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this + "; isLightweight = " + isLightweight);
|
||||
}
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
if (isLightweight) {
|
||||
Container parent = getContainer();
|
||||
if (parent != null) {
|
||||
parent.recursiveApplyCurrentShape(getSiblingIndexBelow());
|
||||
}
|
||||
} //XXX: else applyNormalShape() ???
|
||||
applyCurrentShapeBelowMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9613,11 +9736,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
if (isLightweight()) {
|
||||
Container parent = getContainer();
|
||||
if (parent != null) {
|
||||
parent.recursiveApplyCurrentShape(parent.getComponentZOrder(this));
|
||||
}
|
||||
applyCurrentShapeBelowMe();
|
||||
} else {
|
||||
applyCurrentShape();
|
||||
}
|
||||
@ -9633,11 +9756,13 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
mixingLog.fine("this = " + this +
|
||||
"; oldZorder=" + oldZorder + "; newZorder=" + newZorder + "; parent=" + parent);
|
||||
}
|
||||
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
if (isLightweight()) {
|
||||
if (becameHigher) {
|
||||
if (parent != null && isShowing() && isOpaque()) {
|
||||
parent.recursiveSubtractAndApplyShape(getNormalShape(), getSiblingIndexBelow(), oldZorder);
|
||||
if (parent != null && isShowing()) {
|
||||
parent.recursiveSubtractAndApplyShape(getOpaqueShape(), getSiblingIndexBelow(), oldZorder);
|
||||
}
|
||||
} else {
|
||||
if (parent != null) {
|
||||
@ -9653,8 +9778,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
|
||||
for (int index = oldZorder; index < newZorder; index++) {
|
||||
Component c = parent.getComponent(index);
|
||||
if (c.isLightweight() && c.isShowing() && c.isOpaque()) {
|
||||
shape = shape.getDifference(c.getNormalShape());
|
||||
if (c.isLightweight() && c.isShowing()) {
|
||||
shape = shape.getDifference(c.getOpaqueShape());
|
||||
}
|
||||
}
|
||||
applyCompoundShape(shape);
|
||||
@ -9664,21 +9789,42 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
}
|
||||
|
||||
void mixOnOpaqueChanging() {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
if (isOpaque()) {
|
||||
mixOnShowing();
|
||||
} else {
|
||||
mixOnHiding(isLightweight());
|
||||
}
|
||||
}
|
||||
|
||||
void mixOnValidating() {
|
||||
// This method gets overriden in the Container. Obviously, a plain
|
||||
// non-container components don't need to handle validation.
|
||||
}
|
||||
|
||||
final boolean isMixingNeeded() {
|
||||
if (SunToolkit.getSunAwtDisableMixing()) {
|
||||
if (mixingLog.isLoggable(Level.FINEST)) {
|
||||
mixingLog.finest("this = " + this + "; Mixing disabled via sun.awt.disableMixing");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!areBoundsValid()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this + "; areBoundsValid = " + areBoundsValid());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Window window = getContainingWindow();
|
||||
if (window != null) {
|
||||
if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants()) {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("containing window = " + window +
|
||||
"; has h/w descendants = " + window.hasHeavyweightDescendants() +
|
||||
"; has l/w descendants = " + window.hasLightweightDescendants());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.finest("this = " + this + "; containing window is null");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ****************** END OF MIXING CODE ********************************
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ public class Container extends Component {
|
||||
ComponentPeer peer = this.peer;
|
||||
if (peer instanceof ContainerPeer) {
|
||||
ContainerPeer cpeer = (ContainerPeer)peer;
|
||||
return (Insets)cpeer.insets().clone();
|
||||
return (Insets)cpeer.getInsets().clone();
|
||||
}
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
@ -569,7 +569,7 @@ public class Container extends Component {
|
||||
* @return true if there is at least one heavyweight children in a container, false otherwise
|
||||
* @since 1.5
|
||||
*/
|
||||
private boolean hasHeavyweightDescendants() {
|
||||
final boolean hasHeavyweightDescendants() {
|
||||
checkTreeLock();
|
||||
return numOfHWComponents > 0;
|
||||
}
|
||||
@ -580,7 +580,7 @@ public class Container extends Component {
|
||||
* @return true if there is at least one lightweight children in a container, false otherwise
|
||||
* @since 1.7
|
||||
*/
|
||||
private boolean hasLightweightDescendants() {
|
||||
final boolean hasLightweightDescendants() {
|
||||
checkTreeLock();
|
||||
return numOfLWComponents > 0;
|
||||
}
|
||||
@ -3861,6 +3861,28 @@ public class Container extends Component {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is overriden to handle opaque children in non-opaque
|
||||
* containers.
|
||||
*/
|
||||
@Override
|
||||
final Region getOpaqueShape() {
|
||||
checkTreeLock();
|
||||
if (isLightweight() && isNonOpaqueForMixing()
|
||||
&& hasLightweightDescendants())
|
||||
{
|
||||
Region s = Region.EMPTY_REGION;
|
||||
for (int index = 0; index < getComponentCount(); index++) {
|
||||
Component c = getComponent(index);
|
||||
if (c.isLightweight() && c.isShowing()) {
|
||||
s = s.getUnion(c.getOpaqueShape());
|
||||
}
|
||||
}
|
||||
return s.getIntersection(getNormalShape());
|
||||
}
|
||||
return super.getOpaqueShape();
|
||||
}
|
||||
|
||||
final void recursiveSubtractAndApplyShape(Region shape) {
|
||||
recursiveSubtractAndApplyShape(shape, getTopmostComponentIndex(), getBottommostComponentIndex());
|
||||
}
|
||||
@ -3878,6 +3900,15 @@ public class Container extends Component {
|
||||
if (fromZorder == -1) {
|
||||
return;
|
||||
}
|
||||
if (shape.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// An invalid container with not-null layout should be ignored
|
||||
// by the mixing code, the container will be validated later
|
||||
// and the mixing code will be executed later.
|
||||
if (getLayout() != null && !isValid()) {
|
||||
return;
|
||||
}
|
||||
for (int index = fromZorder; index <= toZorder; index++) {
|
||||
Component comp = getComponent(index);
|
||||
if (!comp.isLightweight()) {
|
||||
@ -3906,10 +3937,19 @@ public class Container extends Component {
|
||||
if (fromZorder == -1) {
|
||||
return;
|
||||
}
|
||||
// An invalid container with not-null layout should be ignored
|
||||
// by the mixing code, the container will be validated later
|
||||
// and the mixing code will be executed later.
|
||||
if (getLayout() != null && !isValid()) {
|
||||
return;
|
||||
}
|
||||
for (int index = fromZorder; index <= toZorder; index++) {
|
||||
Component comp = getComponent(index);
|
||||
if (!comp.isLightweight()) {
|
||||
comp.applyCurrentShape();
|
||||
if (comp instanceof Container && ((Container)comp).getLayout() == null) {
|
||||
((Container)comp).recursiveApplyCurrentShape();
|
||||
}
|
||||
} else if (comp instanceof Container &&
|
||||
((Container)comp).hasHeavyweightDescendants()) {
|
||||
((Container)comp).recursiveApplyCurrentShape();
|
||||
@ -3931,7 +3971,7 @@ public class Container extends Component {
|
||||
if (comp.isVisible()) {
|
||||
ComponentPeer peer = comp.getPeer();
|
||||
if (peer != null) {
|
||||
peer.show();
|
||||
peer.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3952,7 +3992,7 @@ public class Container extends Component {
|
||||
if (comp.isVisible()) {
|
||||
ComponentPeer peer = comp.getPeer();
|
||||
if (peer != null) {
|
||||
peer.hide();
|
||||
peer.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4000,6 +4040,10 @@ public class Container extends Component {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isLightweight = isLightweight();
|
||||
|
||||
if (isLightweight && isRecursivelyVisibleUpToHeavyweightContainer()) {
|
||||
@ -4034,6 +4078,9 @@ public class Container extends Component {
|
||||
if (mixingLog.isLoggable(Level.FINE)) {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
|
||||
boolean isMixingNeeded = isMixingNeeded();
|
||||
|
||||
if (isLightweight() && hasHeavyweightDescendants()) {
|
||||
final Point origin = new Point(getX(), getY());
|
||||
for (Container cont = getContainer();
|
||||
@ -4044,7 +4091,18 @@ public class Container extends Component {
|
||||
}
|
||||
|
||||
recursiveRelocateHeavyweightChildren(origin);
|
||||
|
||||
if (!isMixingNeeded) {
|
||||
return;
|
||||
}
|
||||
|
||||
recursiveApplyCurrentShape();
|
||||
}
|
||||
|
||||
if (!isMixingNeeded) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.mixOnReshaping();
|
||||
}
|
||||
}
|
||||
@ -4057,6 +4115,10 @@ public class Container extends Component {
|
||||
"; oldZ=" + oldZorder + "; newZ=" + newZorder);
|
||||
}
|
||||
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean becameHigher = newZorder < oldZorder;
|
||||
|
||||
if (becameHigher && isLightweight() && hasHeavyweightDescendants()) {
|
||||
@ -4073,10 +4135,18 @@ public class Container extends Component {
|
||||
mixingLog.fine("this = " + this);
|
||||
}
|
||||
|
||||
if (!isMixingNeeded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasHeavyweightDescendants()) {
|
||||
recursiveApplyCurrentShape();
|
||||
}
|
||||
|
||||
if (isLightweight() && isNonOpaqueForMixing()) {
|
||||
subtractAndApplyShapeBelowMe();
|
||||
}
|
||||
|
||||
super.mixOnValidating();
|
||||
}
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ public class Dialog extends Window {
|
||||
// does not invoke the super.show(). So wried... :(
|
||||
mixOnShowing();
|
||||
|
||||
peer.show(); // now guaranteed never to block
|
||||
peer.setVisible(true); // now guaranteed never to block
|
||||
if (isModalBlocked()) {
|
||||
modalBlocker.toFront();
|
||||
}
|
||||
|
@ -300,119 +300,19 @@ class EventDispatchThread extends Thread {
|
||||
}
|
||||
// Can get and throw only unchecked exceptions
|
||||
catch (RuntimeException e) {
|
||||
processException(e, modalFiltersCount > 0);
|
||||
processException(e);
|
||||
} catch (Error e) {
|
||||
processException(e, modalFiltersCount > 0);
|
||||
processException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void processException(Throwable e, boolean isModal) {
|
||||
private void processException(Throwable e) {
|
||||
if (eventLog.isLoggable(Level.FINE)) {
|
||||
eventLog.log(Level.FINE, "Processing exception: " + e +
|
||||
", isModal = " + isModal);
|
||||
eventLog.log(Level.FINE, "Processing exception: " + e);
|
||||
}
|
||||
if (!handleException(e)) {
|
||||
// See bug ID 4499199.
|
||||
// If we are in a modal dialog, we cannot throw
|
||||
// an exception for the ThreadGroup to handle (as added
|
||||
// in RFE 4063022). If we did, the message pump of
|
||||
// the modal dialog would be interrupted.
|
||||
// We instead choose to handle the exception ourselves.
|
||||
// It may be useful to add either a runtime flag or API
|
||||
// later if someone would like to instead dispose the
|
||||
// dialog and allow the thread group to handle it.
|
||||
if (isModal) {
|
||||
System.err.println(
|
||||
"Exception occurred during event dispatching:");
|
||||
e.printStackTrace();
|
||||
} else if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException)e;
|
||||
} else if (e instanceof Error) {
|
||||
throw (Error)e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String handlerPropName = "sun.awt.exception.handler";
|
||||
private static String handlerClassName = null;
|
||||
private static String NO_HANDLER = new String();
|
||||
|
||||
/**
|
||||
* Handles an exception thrown in the event-dispatch thread.
|
||||
*
|
||||
* <p> If the system property "sun.awt.exception.handler" is defined, then
|
||||
* when this method is invoked it will attempt to do the following:
|
||||
*
|
||||
* <ol>
|
||||
* <li> Load the class named by the value of that property, using the
|
||||
* current thread's context class loader,
|
||||
* <li> Instantiate that class using its zero-argument constructor,
|
||||
* <li> Find the resulting handler object's <tt>public void handle</tt>
|
||||
* method, which should take a single argument of type
|
||||
* <tt>Throwable</tt>, and
|
||||
* <li> Invoke the handler's <tt>handle</tt> method, passing it the
|
||||
* <tt>thrown</tt> argument that was passed to this method.
|
||||
* </ol>
|
||||
*
|
||||
* If any of the first three steps fail then this method will return
|
||||
* <tt>false</tt> and all following invocations of this method will return
|
||||
* <tt>false</tt> immediately. An exception thrown by the handler object's
|
||||
* <tt>handle</tt> will be caught, and will cause this method to return
|
||||
* <tt>false</tt>. If the handler's <tt>handle</tt> method is successfully
|
||||
* invoked, then this method will return <tt>true</tt>. This method will
|
||||
* never throw any sort of exception.
|
||||
*
|
||||
* <p> <i>Note:</i> This method is a temporary hack to work around the
|
||||
* absence of a real API that provides the ability to replace the
|
||||
* event-dispatch thread. The magic "sun.awt.exception.handler" property
|
||||
* <i>will be removed</i> in a future release.
|
||||
*
|
||||
* @param thrown The Throwable that was thrown in the event-dispatch
|
||||
* thread
|
||||
*
|
||||
* @return <tt>false</tt> if any of the above steps failed, otherwise
|
||||
* <tt>true</tt>
|
||||
*/
|
||||
private boolean handleException(Throwable thrown) {
|
||||
|
||||
try {
|
||||
|
||||
if (handlerClassName == NO_HANDLER) {
|
||||
return false; /* Already tried, and failed */
|
||||
}
|
||||
|
||||
/* Look up the class name */
|
||||
if (handlerClassName == null) {
|
||||
handlerClassName = ((String) AccessController.doPrivileged(
|
||||
new GetPropertyAction(handlerPropName)));
|
||||
if (handlerClassName == null) {
|
||||
handlerClassName = NO_HANDLER; /* Do not try this again */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Load the class, instantiate it, and find its handle method */
|
||||
Method m;
|
||||
Object h;
|
||||
try {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
Class c = Class.forName(handlerClassName, true, cl);
|
||||
m = c.getMethod("handle", new Class[] { Throwable.class });
|
||||
h = c.newInstance();
|
||||
} catch (Throwable x) {
|
||||
handlerClassName = NO_HANDLER; /* Do not try this again */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Finally, invoke the handler */
|
||||
m.invoke(h, new Object[] { thrown });
|
||||
|
||||
} catch (Throwable x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
getUncaughtExceptionHandler().uncaughtException(this, e);
|
||||
// don't rethrow the exception to avoid EDT recreation
|
||||
}
|
||||
|
||||
boolean isDispatching(EventQueue eq) {
|
||||
|
@ -378,7 +378,7 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
|
||||
ListPeer peer = (ListPeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.addItem(item, index);
|
||||
peer.add(item, index);
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
public synchronized void clear() {
|
||||
ListPeer peer = (ListPeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.clear();
|
||||
peer.removeAll();
|
||||
}
|
||||
items = new Vector();
|
||||
selected = new int[0];
|
||||
@ -718,7 +718,7 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
multipleMode = b;
|
||||
ListPeer peer = (ListPeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.setMultipleSelections(b);
|
||||
peer.setMultipleMode(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -768,7 +768,7 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
synchronized (getTreeLock()) {
|
||||
ListPeer peer = (ListPeer)this.peer;
|
||||
return (peer != null) ?
|
||||
peer.preferredSize(rows) :
|
||||
peer.getPreferredSize(rows) :
|
||||
super.preferredSize();
|
||||
}
|
||||
}
|
||||
@ -818,7 +818,7 @@ public class List extends Component implements ItemSelectable, Accessible {
|
||||
synchronized (getTreeLock()) {
|
||||
ListPeer peer = (ListPeer)this.peer;
|
||||
return (peer != null) ?
|
||||
peer.minimumSize(rows) :
|
||||
peer.getMinimumSize(rows) :
|
||||
super.minimumSize();
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public class MenuItem extends MenuComponent implements Accessible {
|
||||
enabled = true;
|
||||
MenuItemPeer peer = (MenuItemPeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.enable();
|
||||
peer.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ public class MenuItem extends MenuComponent implements Accessible {
|
||||
enabled = false;
|
||||
MenuItemPeer peer = (MenuItemPeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.disable();
|
||||
peer.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,7 @@ public class Robot {
|
||||
private RobotPeer peer;
|
||||
private boolean isAutoWaitForIdle = false;
|
||||
private int autoDelay = 0;
|
||||
private static final int LEGAL_BUTTON_MASK =
|
||||
InputEvent.BUTTON1_MASK|
|
||||
InputEvent.BUTTON2_MASK|
|
||||
InputEvent.BUTTON3_MASK;
|
||||
private static int LEGAL_BUTTON_MASK;
|
||||
|
||||
// location of robot's GC, used in mouseMove(), getPixelColor() and captureScreenImage()
|
||||
private Point gdLoc;
|
||||
@ -98,6 +95,19 @@ public class Robot {
|
||||
}
|
||||
init(GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice());
|
||||
int tmpMask = 0;
|
||||
if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
|
||||
for (int i = 0; i < peer.getNumberOfButtons(); i++){
|
||||
tmpMask |= InputEvent.getMaskForButton(i+1);
|
||||
}
|
||||
}
|
||||
tmpMask |= InputEvent.BUTTON1_MASK|
|
||||
InputEvent.BUTTON2_MASK|
|
||||
InputEvent.BUTTON3_MASK|
|
||||
InputEvent.BUTTON1_DOWN_MASK|
|
||||
InputEvent.BUTTON2_DOWN_MASK|
|
||||
InputEvent.BUTTON3_DOWN_MASK;
|
||||
LEGAL_BUTTON_MASK = tmpMask;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,18 +197,55 @@ public class Robot {
|
||||
|
||||
/**
|
||||
* Presses one or more mouse buttons. The mouse buttons should
|
||||
* be released using the <code>mouseRelease</code> method.
|
||||
* be released using the {@link #mouseRelease(int)} method.
|
||||
*
|
||||
* @param buttons the Button mask; a combination of one or more
|
||||
* of these flags:
|
||||
* @param buttons the Button mask; a combination of one or more
|
||||
* mouse button masks.
|
||||
* <p>
|
||||
* It is allowed to use only a combination of valid values as a {@code buttons} parameter.
|
||||
* A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK},
|
||||
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK}
|
||||
* and values returned by the
|
||||
* {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)} method.
|
||||
*
|
||||
* The valid combination also depends on a
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows:
|
||||
* <ul>
|
||||
* <li><code>InputEvent.BUTTON1_MASK</code>
|
||||
* <li><code>InputEvent.BUTTON2_MASK</code>
|
||||
* <li><code>InputEvent.BUTTON3_MASK</code>
|
||||
* <li> If support for extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* then it is allowed to use only the following standard button masks:
|
||||
* {@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
|
||||
* {@code InputEvent.BUTTON3_DOWN_MASK}.
|
||||
* <li> If support for extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
|
||||
* then it is allowed to use the standard button masks
|
||||
* and masks for existing extended mouse buttons, if the mouse has more then three buttons.
|
||||
* In that way, it is allowed to use the button masks corresponding to the buttons
|
||||
* in the range from 1 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
|
||||
* <br>
|
||||
* It is recommended to use the {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)}
|
||||
* method to obtain the mask for any mouse button by its number.
|
||||
* </ul>
|
||||
* @throws IllegalArgumentException if the button mask is not a
|
||||
* valid combination
|
||||
* <p>
|
||||
* The following standard button masks are also accepted:
|
||||
* <ul>
|
||||
* <li>{@code InputEvent.BUTTON1_MASK}
|
||||
* <li>{@code InputEvent.BUTTON2_MASK}
|
||||
* <li>{@code InputEvent.BUTTON3_MASK}
|
||||
* </ul>
|
||||
* However, it is recommended to use {@code InputEvent.BUTTON1_DOWN_MASK},
|
||||
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK} instead.
|
||||
* Either extended {@code _DOWN_MASK} or old {@code _MASK} values
|
||||
* should be used, but both those models should not be mixed.
|
||||
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
|
||||
* and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
|
||||
* that does not exist on the mouse and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
|
||||
* @see #mouseRelease(int)
|
||||
* @see InputEvent#getMaskForButton(int)
|
||||
* @see Toolkit#areExtraMouseButtonsEnabled()
|
||||
* @see java.awt.MouseInfo#getNumberOfButtons()
|
||||
* @see java.awt.event.MouseEvent
|
||||
*/
|
||||
public synchronized void mousePress(int buttons) {
|
||||
checkButtonsArgument(buttons);
|
||||
@ -209,16 +256,53 @@ public class Robot {
|
||||
/**
|
||||
* Releases one or more mouse buttons.
|
||||
*
|
||||
* @param buttons the Button mask; a combination of one or more
|
||||
* of these flags:
|
||||
* @param buttons the Button mask; a combination of one or more
|
||||
* mouse button masks.
|
||||
* <p>
|
||||
* It is allowed to use only a combination of valid values as a {@code buttons} parameter.
|
||||
* A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK},
|
||||
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK}
|
||||
* and values returned by the
|
||||
* {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)} method.
|
||||
*
|
||||
* The valid combination also depends on a
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() Toolkit.areExtraMouseButtonsEnabled()} value as follows:
|
||||
* <ul>
|
||||
* <li><code>InputEvent.BUTTON1_MASK</code>
|
||||
* <li><code>InputEvent.BUTTON2_MASK</code>
|
||||
* <li><code>InputEvent.BUTTON3_MASK</code>
|
||||
* <li> If the support for extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* then it is allowed to use only the following standard button masks:
|
||||
* {@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
|
||||
* {@code InputEvent.BUTTON3_DOWN_MASK}.
|
||||
* <li> If the support for extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
|
||||
* then it is allowed to use the standard button masks
|
||||
* and masks for existing extended mouse buttons, if the mouse has more then three buttons.
|
||||
* In that way, it is allowed to use the button masks corresponding to the buttons
|
||||
* in the range from 1 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
|
||||
* <br>
|
||||
* It is recommended to use the {@link InputEvent#getMaskForButton(int) InputEvent.getMaskForButton(button)}
|
||||
* method to obtain the mask for any mouse button by its number.
|
||||
* </ul>
|
||||
* <p>
|
||||
* The following standard button masks are also accepted:
|
||||
* <ul>
|
||||
* <li>{@code InputEvent.BUTTON1_MASK}
|
||||
* <li>{@code InputEvent.BUTTON2_MASK}
|
||||
* <li>{@code InputEvent.BUTTON3_MASK}
|
||||
* </ul>
|
||||
* However, it is recommended to use {@code InputEvent.BUTTON1_DOWN_MASK},
|
||||
* {@code InputEvent.BUTTON2_DOWN_MASK}, {@code InputEvent.BUTTON3_DOWN_MASK} instead.
|
||||
* Either extended {@code _DOWN_MASK} or old {@code _MASK} values
|
||||
* should be used, but both those models should not be mixed.
|
||||
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
|
||||
* and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* @throws IllegalArgumentException if the {@code buttons} mask contains the mask for extra mouse button
|
||||
* that does not exist on the mouse and support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
|
||||
* @see #mousePress(int)
|
||||
* @throws IllegalArgumentException if the button mask is not a valid
|
||||
* combination
|
||||
* @see InputEvent#getMaskForButton(int)
|
||||
* @see Toolkit#areExtraMouseButtonsEnabled()
|
||||
* @see java.awt.MouseInfo#getNumberOfButtons()
|
||||
* @see java.awt.event.MouseEvent
|
||||
*/
|
||||
public synchronized void mouseRelease(int buttons) {
|
||||
checkButtonsArgument(buttons);
|
||||
|
@ -321,7 +321,7 @@ public class TextArea extends TextComponent {
|
||||
public synchronized void insertText(String str, int pos) {
|
||||
TextAreaPeer peer = (TextAreaPeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.insertText(str, pos);
|
||||
peer.insert(str, pos);
|
||||
} else {
|
||||
text = text.substring(0, pos) + str + text.substring(pos);
|
||||
}
|
||||
@ -385,7 +385,7 @@ public class TextArea extends TextComponent {
|
||||
public synchronized void replaceText(String str, int start, int end) {
|
||||
TextAreaPeer peer = (TextAreaPeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.replaceText(str, start, end);
|
||||
peer.replaceRange(str, start, end);
|
||||
} else {
|
||||
text = text.substring(0, start) + str + text.substring(end);
|
||||
}
|
||||
@ -500,7 +500,7 @@ public class TextArea extends TextComponent {
|
||||
synchronized (getTreeLock()) {
|
||||
TextAreaPeer peer = (TextAreaPeer)this.peer;
|
||||
return (peer != null) ?
|
||||
peer.preferredSize(rows, columns) :
|
||||
peer.getPreferredSize(rows, columns) :
|
||||
super.preferredSize();
|
||||
}
|
||||
}
|
||||
@ -552,7 +552,7 @@ public class TextArea extends TextComponent {
|
||||
synchronized (getTreeLock()) {
|
||||
TextAreaPeer peer = (TextAreaPeer)this.peer;
|
||||
return (peer != null) ?
|
||||
peer.minimumSize(rows, columns) :
|
||||
peer.getMinimumSize(rows, columns) :
|
||||
super.minimumSize();
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ public class TextField extends TextComponent {
|
||||
echoChar = c;
|
||||
TextFieldPeer peer = (TextFieldPeer)this.peer;
|
||||
if (peer != null) {
|
||||
peer.setEchoCharacter(c);
|
||||
peer.setEchoChar(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -376,7 +376,7 @@ public class TextField extends TextComponent {
|
||||
synchronized (getTreeLock()) {
|
||||
TextFieldPeer peer = (TextFieldPeer)this.peer;
|
||||
return (peer != null) ?
|
||||
peer.preferredSize(columns) :
|
||||
peer.getPreferredSize(columns) :
|
||||
super.preferredSize();
|
||||
}
|
||||
}
|
||||
@ -424,7 +424,7 @@ public class TextField extends TextComponent {
|
||||
synchronized (getTreeLock()) {
|
||||
TextFieldPeer peer = (TextFieldPeer)this.peer;
|
||||
return (peer != null) ?
|
||||
peer.minimumSize(columns) :
|
||||
peer.getMinimumSize(columns) :
|
||||
super.minimumSize();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1995-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
|
||||
@ -2550,4 +2550,37 @@ public abstract class Toolkit {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports whether events from extra mouse buttons are allowed to be processed and posted into
|
||||
* {@code EventQueue}.
|
||||
* <br>
|
||||
* To change the returned value it is necessary to set the {@code sun.awt.enableExtraMouseButtons}
|
||||
* property before the {@code Toolkit} class initialization. This setting could be done on the application
|
||||
* startup by the following command:
|
||||
* <pre>
|
||||
* java -Dsun.awt.enableExtraMouseButtons=false Application
|
||||
* </pre>
|
||||
* Alternatively, the property could be set in the application by using the following code:
|
||||
* <pre>
|
||||
* System.setProperty("sun.awt.enableExtraMouseButtons", "true");
|
||||
* </pre>
|
||||
* before the {@code Toolkit} class initialization.
|
||||
* If not set by the time of the {@code Toolkit} class initialization, this property will be
|
||||
* initialized with {@code true}.
|
||||
* Changing this value after the {@code Toolkit} class initialization will have no effect.
|
||||
* <p>
|
||||
* The current value could be queried by using the
|
||||
* {@code System.getProperty("sun.awt.enableExtraMouseButtons")} method.
|
||||
* @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
|
||||
* @return {@code true} if events from extra mouse buttons are allowed to be processed and posted;
|
||||
* {@code false} otherwise
|
||||
* @see System#getProperty(String propertyName)
|
||||
* @see System#setProperty(String propertyName, String value)
|
||||
* @see java.awt.EventQueue
|
||||
* @since 1.7
|
||||
*/
|
||||
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
|
||||
return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled();
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ import sun.awt.AppContext;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.util.IdentityArrayList;
|
||||
import sun.java2d.Disposer;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.security.util.SecurityConstants;
|
||||
@ -409,8 +410,6 @@ public class Window extends Container implements Accessible {
|
||||
}
|
||||
|
||||
modalExclusionType = Dialog.ModalExclusionType.NO_EXCLUDE;
|
||||
|
||||
sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -540,6 +539,10 @@ public class Window extends Container implements Accessible {
|
||||
if (owner != null) {
|
||||
owner.addOwnedWindow(weakThis);
|
||||
}
|
||||
|
||||
// Fix for 6758673: this call is moved here from init(gc), because
|
||||
// WindowDisposerRecord requires a proper value of parent field.
|
||||
Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
Copyright 2005-2006 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
|
||||
@ -64,6 +64,11 @@ here, and their value types.
|
||||
<td valign="TOP"><a href="../../util/Map.html">java.util.Map<a/></td>
|
||||
<td valign="TOP">Font smoothing (text antialiasing) settings.<a/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="TOP"><A href=#"sun.awt.enableExtraMouseButtons">sun.awt.enableExtraMouseButtons</A</td>
|
||||
<td valign="TOP"><a href="../../lang/Boolean.html">java.lang.Boolean<a/></td>
|
||||
<td valign="TOP">Controls if mouse events from extra buttons are to be generated or not<a/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
<h2>Desktop Font Rendering Hints</h2>
|
||||
@ -219,5 +224,50 @@ So to determine if there are per-device settings it is sufficient to
|
||||
determine that there is a non-null return for any screen device using
|
||||
the per-device property name.
|
||||
</ul>
|
||||
<h2>Mouse Functionality</h2>
|
||||
<b>Desktop Property: <A name="sun.awt.enableExtraMouseButtons">"sun.awt.enableExtraMouseButtons"</A></b>
|
||||
<p>
|
||||
This property determines if events from extra mouse buttons (if they are exist and are
|
||||
enabled by the underlying operating system) are allowed to be processed and posted into
|
||||
{@code EventQueue}.
|
||||
<br>
|
||||
The value could be changed by passing "sun.awt.enableExtraMouseButtons"
|
||||
property value into java before application starts. This could be done with the following command:
|
||||
<pre>
|
||||
java -Dsun.awt.enableExtraMouseButtons=false Application
|
||||
</pre>
|
||||
Once set on application startup, it is impossible to change this value after.
|
||||
<br>
|
||||
Current value could also be queried using getDesktopProperty("sun.awt.enableExtraMouseButtons")
|
||||
method.
|
||||
<br>
|
||||
If the property is set to {@code true} then
|
||||
<ul>
|
||||
<li> it is still legal to create {@code MouseEvent} objects with
|
||||
standard buttons and, if the mouse has more
|
||||
then three buttons, it is also legal to use buttons from the range started
|
||||
from 0 up to {@link java.awt.MouseInfo#getNumberOfButtons() getNumberOfButtons()}.
|
||||
|
||||
<li> it is legal to use standard button masks when using {@code Robot.mousePress()}
|
||||
and {@code Robot.mouseRelease()} methods and, if the mouse has more then three buttons,
|
||||
it is also legal to use masks for existing extended mouse buttons.
|
||||
That way, if there are more then three buttons on the mouse then it is allowed to
|
||||
use button masks corresponding to the buttons
|
||||
in the range from 1 up to {@link java.awt.MouseInfo#getNumberOfButtons() getNumberOfButtons()}
|
||||
</ul>
|
||||
<br>
|
||||
If the property is set to {@code false} then
|
||||
<ul>
|
||||
<li> it is legal to create {@code MouseEvent} objects with standard buttons
|
||||
only: {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2} and
|
||||
{@code BUTTON3}
|
||||
<li> it is legal to use standard button masks only:
|
||||
{@code InputEvent.BUTTON1_DOWN_MASK}, {@code InputEvent.BUTTON2_DOWN_MASK},
|
||||
{@code InputEvent.BUTTON3_DOWN_MASK}
|
||||
</ul>
|
||||
|
||||
This property should be used when there is no need in listening mouse events fired as a result of
|
||||
activity with extra mouse button.
|
||||
By default this property is set to {@code true}.
|
||||
</body>
|
||||
</html>
|
||||
|
@ -31,6 +31,7 @@ import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* The root event class for all component-level input events.
|
||||
@ -153,13 +154,93 @@ public abstract class InputEvent extends ComponentEvent {
|
||||
*/
|
||||
public static final int ALT_GRAPH_DOWN_MASK = 1 << 13;
|
||||
|
||||
/**
|
||||
* An array of extended modifiers for additional buttons.
|
||||
* @see getButtonDownMasks
|
||||
* @since 7.0
|
||||
*/
|
||||
private static final int [] BUTTON_DOWN_MASK = new int [] { BUTTON1_DOWN_MASK,
|
||||
BUTTON2_DOWN_MASK,
|
||||
BUTTON3_DOWN_MASK,
|
||||
1<<14, //4th phisical button (this is not a wheel!)
|
||||
1<<15, //(this is not a wheel!)
|
||||
1<<16,
|
||||
1<<17,
|
||||
1<<18,
|
||||
1<<19,
|
||||
1<<20,
|
||||
1<<21 };
|
||||
|
||||
/**
|
||||
* A method to access an array of extended modifiers for additional buttons.
|
||||
* @since 7.0
|
||||
*/
|
||||
private static int [] getButtonDownMasks(){
|
||||
return Arrays.copyOf(BUTTON_DOWN_MASK, BUTTON_DOWN_MASK.length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A method to obtain a mask for any existing mouse button.
|
||||
* The returned mask may be used for different purposes. Following are some of them:
|
||||
* <ul>
|
||||
* <li> {@link java.awt.Robot#mousePress(int) mousePress(buttons)} and
|
||||
* {@link java.awt.Robot#mouseRelease(int) mouseRelease(buttons)}
|
||||
* <li> as a {@code modifiers} parameter when creating a new {@link MouseEvent} instance
|
||||
* <li> to check {@link MouseEvent#getModifiersEx() modifiersEx} of existing {@code MouseEvent}
|
||||
* </ul>
|
||||
* @param button is a number to represent a button starting from 1.
|
||||
* For example,
|
||||
* <pre>
|
||||
* int button = InputEvent.getMaskForButton(1);
|
||||
* </pre>
|
||||
* will have the same meaning as
|
||||
* <pre>
|
||||
* int button = InputEvent.getMaskForButton(MouseEvent.BUTTON1);
|
||||
* </pre>
|
||||
* because {@link MouseEvent#BUTTON1 MouseEvent.BUTTON1} equals to 1.
|
||||
* If a mouse has three enabled buttons(see {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()})
|
||||
* then the values from the left column passed into the method will return
|
||||
* corresponding values from the right column:
|
||||
* <PRE>
|
||||
* <b>button </b> <b>returned mask</b>
|
||||
* {@link MouseEvent#BUTTON1 BUTTON1} {@link MouseEvent#BUTTON1_DOWN_MASK BUTTON1_DOWN_MASK}
|
||||
* {@link MouseEvent#BUTTON2 BUTTON2} {@link MouseEvent#BUTTON2_DOWN_MASK BUTTON2_DOWN_MASK}
|
||||
* {@link MouseEvent#BUTTON3 BUTTON3} {@link MouseEvent#BUTTON3_DOWN_MASK BUTTON3_DOWN_MASK}
|
||||
* </PRE>
|
||||
* If a mouse has more than three enabled buttons then more values
|
||||
* are admissible (4, 5, etc.). There is no assigned constants for these extended buttons.
|
||||
* The button masks for the extra buttons returned by this method have no assigned names like the
|
||||
* first three button masks.
|
||||
* <p>
|
||||
* This method has the following implementation restriction.
|
||||
* It returns masks for a limited number of buttons only. The maximum number is
|
||||
* implementation dependent and may vary.
|
||||
* This limit is defined by the relevant number
|
||||
* of buttons that may hypothetically exist on the mouse but it is greater than the
|
||||
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}.
|
||||
* <p>
|
||||
* @throws IllegalArgumentException if {@code button} is less than zero or greater than the number
|
||||
* of button masks reserved for buttons
|
||||
* @since 7.0
|
||||
* @see java.awt.MouseInfo#getNumberOfButtons()
|
||||
* @see Toolkit#areExtraMouseButtonsEnabled()
|
||||
* @see MouseEvent#getModifiers()
|
||||
* @see MouseEvent#getModifiersEx()
|
||||
*/
|
||||
public static int getMaskForButton(int button) {
|
||||
if (button <= 0 || button > BUTTON_DOWN_MASK.length) {
|
||||
throw new IllegalArgumentException("button doesn\'t exist " + button);
|
||||
}
|
||||
return BUTTON_DOWN_MASK[button - 1];
|
||||
}
|
||||
|
||||
// the constant below MUST be updated if any extra modifier
|
||||
// bits are to be added!
|
||||
// in fact, it is undesirable to add modifier bits
|
||||
// to the same field as this may break applications
|
||||
// see bug# 5066958
|
||||
|
||||
static final int FIRST_HIGH_BIT = 1 << 14;
|
||||
static final int FIRST_HIGH_BIT = 1 << 22;
|
||||
|
||||
static final int JDK_1_3_MODIFIERS = SHIFT_DOWN_MASK - 1;
|
||||
static final int HIGH_MODIFIERS = ~( FIRST_HIGH_BIT - 1 );
|
||||
@ -382,7 +463,7 @@ public abstract class InputEvent extends ComponentEvent {
|
||||
* cause the returning an empty string.
|
||||
*
|
||||
* @param modifiers a modifier mask describing the extended
|
||||
* modifier keys and mouse buttons for the event
|
||||
* modifier keys and mouse buttons for the event
|
||||
* @return a text description of the combination of extended
|
||||
* modifier keys and mouse buttons that were held down
|
||||
* during the event.
|
||||
@ -410,17 +491,14 @@ public abstract class InputEvent extends ComponentEvent {
|
||||
buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph"));
|
||||
buf.append("+");
|
||||
}
|
||||
if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
|
||||
buf.append(Toolkit.getProperty("AWT.button1", "Button1"));
|
||||
buf.append("+");
|
||||
}
|
||||
if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
|
||||
buf.append(Toolkit.getProperty("AWT.button2", "Button2"));
|
||||
buf.append("+");
|
||||
}
|
||||
if ((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
|
||||
buf.append(Toolkit.getProperty("AWT.button3", "Button3"));
|
||||
buf.append("+");
|
||||
|
||||
int buttonNumber = 1;
|
||||
for (int mask : InputEvent.BUTTON_DOWN_MASK){
|
||||
if ((modifiers & mask) != 0) {
|
||||
buf.append(Toolkit.getProperty("AWT.button"+buttonNumber, "Button"+buttonNumber));
|
||||
buf.append("+");
|
||||
}
|
||||
buttonNumber++;
|
||||
}
|
||||
if (buf.length() > 0) {
|
||||
buf.setLength(buf.length()-1); // remove trailing '+'
|
||||
|
@ -32,6 +32,7 @@ import java.awt.Toolkit;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.awt.IllegalComponentStateException;
|
||||
import java.awt.MouseInfo;
|
||||
|
||||
/**
|
||||
* An event which indicates that a mouse action occurred in a component.
|
||||
@ -135,7 +136,15 @@ import java.awt.IllegalComponentStateException;
|
||||
* for <code>BUTTON2_MASK</code> arrives first,
|
||||
* followed by the pair for <code>BUTTON1_MASK</code>.
|
||||
* <p>
|
||||
*
|
||||
* Some extra mouse buttons are added to extend the standard set of buttons
|
||||
* represented by the following constants:{@code BUTTON1}, {@code BUTTON2}, and {@code BUTTON3}.
|
||||
* Extra buttons have no assigned {@code BUTTONx}
|
||||
* constants as well as their button masks have no assigned {@code BUTTONx_DOWN_MASK}
|
||||
* constants. Nevertheless, ordinal numbers starting from 4 may be
|
||||
* used as button numbers (button ids). Values obtained by the
|
||||
* {@link InputEvent#getMaskForButton(int) getMaskForButton(button)} method may be used
|
||||
* as button masks.
|
||||
* <p>
|
||||
* <code>MOUSE_DRAGGED</code> events are delivered to the <code>Component</code>
|
||||
* in which the mouse button was pressed until the mouse button is released
|
||||
* (regardless of whether the mouse position is within the bounds of the
|
||||
@ -324,13 +333,31 @@ public class MouseEvent extends InputEvent {
|
||||
/**
|
||||
* Indicates which, if any, of the mouse buttons has changed state.
|
||||
*
|
||||
* The only legal values are the following constants:
|
||||
* <code>NOBUTTON</code>,
|
||||
* <code>BUTTON1</code>,
|
||||
* <code>BUTTON2</code> or
|
||||
* <code>BUTTON3</code>.
|
||||
* The valid values are ranged from 0 to the value returned by the
|
||||
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()} method.
|
||||
* This range already includes constants {@code NOBUTTON}, {@code BUTTON1},
|
||||
* {@code BUTTON2}, and {@code BUTTON3}
|
||||
* if these buttons are present. So it is allowed to use these constants too.
|
||||
* For example, for a mouse with two buttons this field may contain the following values:
|
||||
* <ul>
|
||||
* <li> 0 ({@code NOBUTTON})
|
||||
* <li> 1 ({@code BUTTON1})
|
||||
* <li> 2 ({@code BUTTON2})
|
||||
* </ul>
|
||||
* If a mouse has 5 buttons, this field may contain the following values:
|
||||
* <ul>
|
||||
* <li> 0 ({@code NOBUTTON})
|
||||
* <li> 1 ({@code BUTTON1})
|
||||
* <li> 2 ({@code BUTTON2})
|
||||
* <li> 3 ({@code BUTTON3})
|
||||
* <li> 4
|
||||
* <li> 5
|
||||
* </ul>
|
||||
* If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled()} disabled by Java
|
||||
* then the field may not contain the value larger than {@code BUTTON3}.
|
||||
* @serial
|
||||
* @see #getButton().
|
||||
* @see #getButton()
|
||||
* @see java.awt.Toolkit#areExtraMouseButtonsEnabled()
|
||||
*/
|
||||
int button;
|
||||
|
||||
@ -384,6 +411,15 @@ public class MouseEvent extends InputEvent {
|
||||
return new Point(xAbs, yAbs);
|
||||
}
|
||||
|
||||
/**
|
||||
* A number of buttons available on the mouse at the {@code Toolkit} machinery startup.
|
||||
*/
|
||||
private static int cachedNumberOfButtons;
|
||||
|
||||
static {
|
||||
cachedNumberOfButtons = MouseInfo.getNumberOfButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute horizontal x position of the event.
|
||||
* In a virtual device multi-screen environment in which the
|
||||
@ -421,7 +457,8 @@ public class MouseEvent extends InputEvent {
|
||||
/**
|
||||
* Constructs a <code>MouseEvent</code> object with the
|
||||
* specified source component,
|
||||
* type, modifiers, coordinates, and click count.
|
||||
* type, time, modifiers, coordinates, click count, popupTrigger flag,
|
||||
* and button number.
|
||||
* <p>
|
||||
* Creating an invalid event (such
|
||||
* as by using more than one of the old _MASKs, or modifier/button
|
||||
@ -464,7 +501,33 @@ public class MouseEvent extends InputEvent {
|
||||
* @param popupTrigger A boolean that equals {@code true} if this event
|
||||
* is a trigger for a popup menu
|
||||
* @param button An integer that indicates, which of the mouse buttons has
|
||||
* changed its state
|
||||
* changed its state.
|
||||
* The following rules are applied to this parameter:
|
||||
* <ul>
|
||||
* <li>If support for the extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
|
||||
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
|
||||
* {@code BUTTON3}.
|
||||
* <li> If support for the extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
|
||||
* then it is allowed to create {@code MouseEvent} objects with
|
||||
* the standard buttons.
|
||||
* In case the support for extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
|
||||
* in addition to the standard buttons, {@code MouseEvent} objects can be created
|
||||
* using buttons from the range starting from 4 to
|
||||
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
|
||||
* if the mouse has more than three buttons.
|
||||
* </ul>
|
||||
* @throws IllegalArgumentException if {@code button} is less then zero
|
||||
* @throws IllegalArgumentException if <code>source</code> is null
|
||||
* @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* @throws IllegalArgumentException if {@code button} is greater then the
|
||||
* {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
|
||||
* for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
|
||||
* by Java
|
||||
* @throws IllegalArgumentException if an invalid <code>button</code>
|
||||
* value is passed in
|
||||
* @throws IllegalArgumentException if <code>source</code> is null
|
||||
@ -498,7 +561,7 @@ public class MouseEvent extends InputEvent {
|
||||
/**
|
||||
* Constructs a <code>MouseEvent</code> object with the
|
||||
* specified source component,
|
||||
* type, modifiers, coordinates, and click count.
|
||||
* type, modifiers, coordinates, click count, and popupTrigger flag.
|
||||
* An invocation of the form
|
||||
* <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger)</tt>
|
||||
* behaves in exactly the same way as the invocation
|
||||
@ -551,10 +614,26 @@ public class MouseEvent extends InputEvent {
|
||||
}
|
||||
|
||||
|
||||
/* if the button is an extra button and it is released or clicked then in Xsystem its state
|
||||
is not modified. Exclude this button number from ExtModifiers mask.*/
|
||||
transient private boolean shouldExcludeButtonFromExtModifiers = false;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int getModifiersEx() {
|
||||
int tmpModifiers = modifiers;
|
||||
if (shouldExcludeButtonFromExtModifiers) {
|
||||
tmpModifiers &= ~(InputEvent.getMaskForButton(getButton()));
|
||||
}
|
||||
return tmpModifiers & ~JDK_1_3_MODIFIERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>MouseEvent</code> object with the
|
||||
* specified source component,
|
||||
* type, modifiers, coordinates, absolute coordinates, and click count.
|
||||
* type, time, modifiers, coordinates, absolute coordinates, click count, popupTrigger flag,
|
||||
* and button number.
|
||||
* <p>
|
||||
* Creating an invalid event (such
|
||||
* as by using more than one of the old _MASKs, or modifier/button
|
||||
@ -595,7 +674,33 @@ public class MouseEvent extends InputEvent {
|
||||
* @param popupTrigger A boolean that equals {@code true} if this event
|
||||
* is a trigger for a popup menu
|
||||
* @param button An integer that indicates, which of the mouse buttons has
|
||||
* changed its state
|
||||
* changed its state.
|
||||
* The following rules are applied to this parameter:
|
||||
* <ul>
|
||||
* <li>If support for the extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* then it is allowed to create {@code MouseEvent} objects only with the standard buttons:
|
||||
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, and
|
||||
* {@code BUTTON3}.
|
||||
* <li> If support for the extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java
|
||||
* then it is allowed to create {@code MouseEvent} objects with
|
||||
* the standard buttons.
|
||||
* In case the support for extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java, then
|
||||
* in addition to the standard buttons, {@code MouseEvent} objects can be created
|
||||
* using buttons from the range starting from 4 to
|
||||
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
|
||||
* if the mouse has more than three buttons.
|
||||
* </ul>
|
||||
* @throws IllegalArgumentException if {@code button} is less then zero
|
||||
* @throws IllegalArgumentException if <code>source</code> is null
|
||||
* @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
|
||||
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* @throws IllegalArgumentException if {@code button} is greater then the
|
||||
* {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
|
||||
* for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
|
||||
* by Java
|
||||
* @throws IllegalArgumentException if an invalid <code>button</code>
|
||||
* value is passed in
|
||||
* @throws IllegalArgumentException if <code>source</code> is null
|
||||
@ -610,6 +715,10 @@ public class MouseEvent extends InputEvent {
|
||||
* @see #getClickCount()
|
||||
* @see #isPopupTrigger()
|
||||
* @see #getButton()
|
||||
* @see #button
|
||||
* @see Toolkit#areExtraMouseButtonsEnabled()
|
||||
* @see java.awt.MouseInfo#getNumberOfButtons()
|
||||
* @see InputEvent#getMaskForButton(int)
|
||||
* @since 1.6
|
||||
*/
|
||||
public MouseEvent(Component source, int id, long when, int modifiers,
|
||||
@ -623,14 +732,41 @@ public class MouseEvent extends InputEvent {
|
||||
this.yAbs = yAbs;
|
||||
this.clickCount = clickCount;
|
||||
this.popupTrigger = popupTrigger;
|
||||
if (button < NOBUTTON || button >BUTTON3) {
|
||||
throw new IllegalArgumentException("Invalid button value");
|
||||
if (button < NOBUTTON){
|
||||
throw new IllegalArgumentException("Invalid button value :" + button);
|
||||
}
|
||||
//TODO: initialize MouseInfo.cachedNumber on toolkit creation.
|
||||
if (button > BUTTON3) {
|
||||
if (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
|
||||
throw new IllegalArgumentException("Extra mouse events are disabled " + button);
|
||||
} else {
|
||||
if (button > cachedNumberOfButtons) {
|
||||
throw new IllegalArgumentException("Nonexistent button " + button);
|
||||
}
|
||||
}
|
||||
// XToolkit: extra buttons are not reporting about their state correctly.
|
||||
// Being pressed they report the state=0 both on the press and on the release.
|
||||
// For 1-3 buttons the state value equals zero on press and non-zero on release.
|
||||
// Other modifiers like Shift, ALT etc seem report well with extra buttons.
|
||||
// The problem reveals as follows: one button is pressed and then another button is pressed and released.
|
||||
// So, the getModifiersEx() would not be zero due to a first button and we will skip this modifier.
|
||||
// This may have to be moved into the peer code instead if possible.
|
||||
|
||||
if (getModifiersEx() != 0) { //There is at least one more button in a pressed state.
|
||||
if (id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED){
|
||||
System.out.println("MEvent. CASE!");
|
||||
shouldExcludeButtonFromExtModifiers = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.button = button;
|
||||
|
||||
if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
|
||||
setNewModifiers();
|
||||
} else if ((getModifiers() == 0) &&
|
||||
(getModifiersEx() != 0 || button != NOBUTTON))
|
||||
(getModifiersEx() != 0 || button != NOBUTTON) &&
|
||||
(button <= BUTTON3))
|
||||
{
|
||||
setOldModifiers();
|
||||
}
|
||||
@ -701,13 +837,55 @@ public class MouseEvent extends InputEvent {
|
||||
|
||||
/**
|
||||
* Returns which, if any, of the mouse buttons has changed state.
|
||||
* The returned value is ranged
|
||||
* from 0 to the {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
|
||||
* value.
|
||||
* The returned value includes at least the following constants:
|
||||
* <ul>
|
||||
* <li> {@code NOBUTTON}
|
||||
* <li> {@code BUTTON1}
|
||||
* <li> {@code BUTTON2}
|
||||
* <li> {@code BUTTON3}
|
||||
* </ul>
|
||||
* It is allowed to use those constants to compare with the returned button number in the application.
|
||||
* For example,
|
||||
* <pre>
|
||||
* if (anEvent.getButton() == MouseEvent.BUTTON1) {
|
||||
* </pre>
|
||||
* In particular, for a mouse with one, two, or three buttons this method may return the following values:
|
||||
* <ul>
|
||||
* <li> 0 ({@code NOBUTTON})
|
||||
* <li> 1 ({@code BUTTON1})
|
||||
* <li> 2 ({@code BUTTON2})
|
||||
* <li> 3 ({@code BUTTON3})
|
||||
* </ul>
|
||||
* Button numbers greater then {@code BUTTON3} have no constant identifier. So if a mouse with five buttons is
|
||||
* installed, this method may return the following values:
|
||||
* <ul>
|
||||
* <li> 0 ({@code NOBUTTON})
|
||||
* <li> 1 ({@code BUTTON1})
|
||||
* <li> 2 ({@code BUTTON2})
|
||||
* <li> 3 ({@code BUTTON3})
|
||||
* <li> 4
|
||||
* <li> 5
|
||||
* </ul>
|
||||
* <p>
|
||||
* Note: If support for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* then the AWT event subsystem does not produce mouse events for the extended mouse
|
||||
* buttons. So it is not expected that this method returns anything except {@code NOBUTTON}, {@code BUTTON1},
|
||||
* {@code BUTTON2}, {@code BUTTON3}.
|
||||
*
|
||||
* @return one of the following constants:
|
||||
* <code>NOBUTTON</code>,
|
||||
* <code>BUTTON1</code>,
|
||||
* <code>BUTTON2</code> or
|
||||
* <code>BUTTON3</code>.
|
||||
* @return one of the values from 0 to {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
|
||||
* if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled} by Java.
|
||||
* That range includes {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2}, {@code BUTTON3};
|
||||
* <br>
|
||||
* {@code NOBUTTON}, {@code BUTTON1}, {@code BUTTON2} or {@code BUTTON3}
|
||||
* if support for the extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
|
||||
* @since 1.4
|
||||
* @see Toolkit#areExtraMouseButtonsEnabled()
|
||||
* @see java.awt.MouseInfo#getNumberOfButtons()
|
||||
* @see #MouseEvent(Component, int, long, int, int, int, int, int, int, boolean, int)
|
||||
* @see InputEvent#getMaskForButton(int)
|
||||
*/
|
||||
public int getButton() {
|
||||
return button;
|
||||
@ -746,7 +924,7 @@ public class MouseEvent extends InputEvent {
|
||||
* and will cause the returning an unspecified string.
|
||||
* Zero parameter means that no modifiers were passed and will
|
||||
* cause the returning an empty string.
|
||||
*
|
||||
* <p>
|
||||
* @param modifiers A modifier mask describing the modifier keys and
|
||||
* mouse buttons that were down during the event
|
||||
* @return string string text description of the combination of modifier
|
||||
@ -788,6 +966,24 @@ public class MouseEvent extends InputEvent {
|
||||
buf.append(Toolkit.getProperty("AWT.button3", "Button3"));
|
||||
buf.append("+");
|
||||
}
|
||||
|
||||
int mask;
|
||||
|
||||
// TODO: add a toolkit field that holds a number of button on the mouse.
|
||||
// As the method getMouseModifiersText() is static and obtain
|
||||
// an integer as a parameter then we may not restrict this with the number
|
||||
// of buttons installed on the mouse.
|
||||
// It's a temporary solution. We need to somehow hold the number of buttons somewhere else.
|
||||
for (int i = 1; i <= cachedNumberOfButtons; i++){
|
||||
mask = InputEvent.getMaskForButton(i);
|
||||
if ((modifiers & mask) != 0 &&
|
||||
buf.indexOf(Toolkit.getProperty("AWT.button"+i, "Button"+i)) == -1) //1,2,3 buttons may already be there; so don't duplicate it.
|
||||
{
|
||||
buf.append(Toolkit.getProperty("AWT.button"+i, "Button"+i));
|
||||
buf.append("+");
|
||||
}
|
||||
}
|
||||
|
||||
if (buf.length() > 0) {
|
||||
buf.setLength(buf.length()-1); // remove trailing '+'
|
||||
}
|
||||
@ -836,14 +1032,18 @@ public class MouseEvent extends InputEvent {
|
||||
str.append(",(").append(x).append(",").append(y).append(")");
|
||||
str.append(",absolute(").append(xAbs).append(",").append(yAbs).append(")");
|
||||
|
||||
str.append(",button=").append(getButton());
|
||||
if (id != MOUSE_DRAGGED && id != MOUSE_MOVED){
|
||||
str.append(",button=").append(getButton());
|
||||
}
|
||||
|
||||
if (getModifiers() != 0) {
|
||||
str.append(",modifiers=").append(getMouseModifiersText(modifiers));
|
||||
}
|
||||
|
||||
if (getModifiersEx() != 0) {
|
||||
str.append(",extModifiers=").append(getModifiersExText(modifiers));
|
||||
//Using plain "modifiers" here does show an excluded extended buttons in the string event representation.
|
||||
//getModifiersEx() solves the problem.
|
||||
str.append(",extModifiers=").append(getModifiersExText(getModifiersEx()));
|
||||
}
|
||||
|
||||
str.append(",clickCount=").append(clickCount);
|
||||
|
@ -25,7 +25,11 @@
|
||||
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Button;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Button}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -33,5 +37,14 @@ package java.awt.peer;
|
||||
* instances.
|
||||
*/
|
||||
public interface ButtonPeer extends ComponentPeer {
|
||||
|
||||
/**
|
||||
* Sets the label that is displayed on the button. Can be {@code null}
|
||||
* when the button should not display a label.
|
||||
*
|
||||
* @param label the label string to set
|
||||
*
|
||||
* @see Button#setLabel
|
||||
*/
|
||||
void setLabel(String label);
|
||||
}
|
||||
|
@ -24,7 +24,11 @@
|
||||
*/
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Canvas;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Canvas}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
|
@ -24,7 +24,11 @@
|
||||
*/
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.CheckboxMenuItem;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link CheckboxMenuItem}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -32,5 +36,14 @@ package java.awt.peer;
|
||||
* instances.
|
||||
*/
|
||||
public interface CheckboxMenuItemPeer extends MenuItemPeer {
|
||||
|
||||
/**
|
||||
* Sets the state of the checkbox to be checked ({@code true}) or
|
||||
* unchecked ({@code false}).
|
||||
*
|
||||
* @param t the state to set on the checkbox
|
||||
*
|
||||
* @see CheckboxMenuItemPeer#setState(boolean)
|
||||
*/
|
||||
void setState(boolean t);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ package java.awt.peer;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Checkbox}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,7 +36,36 @@ import java.awt.*;
|
||||
* instances.
|
||||
*/
|
||||
public interface CheckboxPeer extends ComponentPeer {
|
||||
|
||||
/**
|
||||
* Sets the state of the checkbox to be checked ({@code true}) or
|
||||
* unchecked ({@code false}).
|
||||
*
|
||||
* @param t the state to set on the checkbox
|
||||
*
|
||||
* @see Checkbox#setState(boolean)
|
||||
*/
|
||||
void setState(boolean state);
|
||||
|
||||
/**
|
||||
* Sets the checkbox group for this checkbox. Checkboxes in one checkbox
|
||||
* group can only be selected exclusively (like radio buttons). A value
|
||||
* of {@code null} removes this checkbox from any checkbox group.
|
||||
*
|
||||
* @param g the checkbox group to set, or {@code null} when this
|
||||
* checkbox should not be placed in any group
|
||||
*
|
||||
* @see Checkbox#setCheckboxGroup(CheckboxGroup)
|
||||
*/
|
||||
void setCheckboxGroup(CheckboxGroup g);
|
||||
|
||||
/**
|
||||
* Sets the label that should be displayed on the ckeckbox. A value of
|
||||
* {@code null} means that no label should be displayed.
|
||||
*
|
||||
* @param label the label to be displayed on the checkbox, or
|
||||
* {@code null} when no label should be displayed.
|
||||
*/
|
||||
void setLabel(String label);
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,11 @@
|
||||
*/
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Choice;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Choice}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -32,13 +36,41 @@ package java.awt.peer;
|
||||
* instances.
|
||||
*/
|
||||
public interface ChoicePeer extends ComponentPeer {
|
||||
|
||||
/**
|
||||
* Adds an item with the string {@code item} to the combo box list
|
||||
* at index {@code index}.
|
||||
*
|
||||
* @param item the label to be added to the list
|
||||
* @param index the index where to add the item
|
||||
*
|
||||
* @see Choice#add(String)
|
||||
*/
|
||||
void add(String item, int index);
|
||||
|
||||
/**
|
||||
* Removes the item at index {@code index} from the combo box list.
|
||||
*
|
||||
* @param index the index where to remove the item
|
||||
*
|
||||
* @see Choice#remove(int)
|
||||
*/
|
||||
void remove(int index);
|
||||
|
||||
/**
|
||||
* Removes all items from the combo box list.
|
||||
*
|
||||
* @see Choice#removeAll()
|
||||
*/
|
||||
void removeAll();
|
||||
|
||||
/**
|
||||
* Selects the item at index {@code index}.
|
||||
*
|
||||
* @param index the index which should be selected
|
||||
*
|
||||
* @see Choice#select(int)
|
||||
*/
|
||||
void select(int index);
|
||||
|
||||
/*
|
||||
* DEPRECATED: Replaced by add(String, int).
|
||||
*/
|
||||
void addItem(String item, int index);
|
||||
}
|
||||
|
@ -37,6 +37,12 @@ import sun.java2d.pipe.Region;
|
||||
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Component}. This is the top level peer
|
||||
* interface for widgets and defines the bulk of methods for AWT component
|
||||
* peers. Most component peers have to implement this interface (via one
|
||||
* of the subinterfaces), except menu components, which implement
|
||||
* {@link MenuComponentPeer}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -44,63 +50,474 @@ import sun.java2d.pipe.Region;
|
||||
* instances.
|
||||
*/
|
||||
public interface ComponentPeer {
|
||||
public static final int SET_LOCATION = 1,
|
||||
SET_SIZE = 2,
|
||||
SET_BOUNDS = 3,
|
||||
SET_CLIENT_SIZE = 4,
|
||||
RESET_OPERATION = 5,
|
||||
NO_EMBEDDED_CHECK = (1 << 14),
|
||||
DEFAULT_OPERATION = SET_BOUNDS;
|
||||
boolean isObscured();
|
||||
boolean canDetermineObscurity();
|
||||
void setVisible(boolean b);
|
||||
void setEnabled(boolean b);
|
||||
void paint(Graphics g);
|
||||
void repaint(long tm, int x, int y, int width, int height);
|
||||
void print(Graphics g);
|
||||
void setBounds(int x, int y, int width, int height, int op);
|
||||
void handleEvent(AWTEvent e);
|
||||
void coalescePaintEvent(PaintEvent e);
|
||||
Point getLocationOnScreen();
|
||||
Dimension getPreferredSize();
|
||||
Dimension getMinimumSize();
|
||||
ColorModel getColorModel();
|
||||
Toolkit getToolkit();
|
||||
Graphics getGraphics();
|
||||
FontMetrics getFontMetrics(Font font);
|
||||
void dispose();
|
||||
void setForeground(Color c);
|
||||
void setBackground(Color c);
|
||||
void setFont(Font f);
|
||||
void updateCursorImmediately();
|
||||
boolean requestFocus(Component lightweightChild,
|
||||
boolean temporary,
|
||||
boolean focusedWindowChangeAllowed,
|
||||
long time, CausedFocusEvent.Cause cause);
|
||||
boolean isFocusable();
|
||||
|
||||
Image createImage(ImageProducer producer);
|
||||
Image createImage(int width, int height);
|
||||
VolatileImage createVolatileImage(int width, int height);
|
||||
boolean prepareImage(Image img, int w, int h, ImageObserver o);
|
||||
int checkImage(Image img, int w, int h, ImageObserver o);
|
||||
/**
|
||||
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
|
||||
* a change in the component location only.
|
||||
*
|
||||
* @see #setBounds(int, int, int, int, int)
|
||||
*/
|
||||
public static final int SET_LOCATION = 1;
|
||||
|
||||
/**
|
||||
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
|
||||
* a change in the component size only.
|
||||
*
|
||||
* @see #setBounds(int, int, int, int, int)
|
||||
*/
|
||||
public static final int SET_SIZE = 2;
|
||||
|
||||
/**
|
||||
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
|
||||
* a change in the component size and location.
|
||||
*
|
||||
* @see #setBounds(int, int, int, int, int)
|
||||
*/
|
||||
public static final int SET_BOUNDS = 3;
|
||||
|
||||
/**
|
||||
* Operation for {@link #setBounds(int, int, int, int, int)}, indicating
|
||||
* a change in the component client size. This is used for setting
|
||||
* the 'inside' size of windows, without the border insets.
|
||||
*
|
||||
* @see #setBounds(int, int, int, int, int)
|
||||
*/
|
||||
public static final int SET_CLIENT_SIZE = 4;
|
||||
|
||||
/**
|
||||
* Resets the setBounds() operation to DEFAULT_OPERATION. This is not
|
||||
* passed into {@link #setBounds(int, int, int, int, int)}.
|
||||
*
|
||||
* TODO: This is only used internally and should probably be moved outside
|
||||
* the peer interface.
|
||||
*
|
||||
* @see Component#setBoundsOp
|
||||
*/
|
||||
public static final int RESET_OPERATION = 5;
|
||||
|
||||
/**
|
||||
* A flag that is used to suppress checks for embedded frames.
|
||||
*
|
||||
* TODO: This is only used internally and should probably be moved outside
|
||||
* the peer interface.
|
||||
*/
|
||||
public static final int NO_EMBEDDED_CHECK = (1 << 14);
|
||||
|
||||
/**
|
||||
* The default operation, which is to set size and location.
|
||||
*
|
||||
* TODO: This is only used internally and should probably be moved outside
|
||||
* the peer interface.
|
||||
*
|
||||
* @see Component#setBoundsOp
|
||||
*/
|
||||
public static final int DEFAULT_OPERATION = SET_BOUNDS;
|
||||
|
||||
/**
|
||||
* Determines if a component has been obscured, i.e. by an overlapping
|
||||
* window or similar. This is used by JViewport for optimizing performance.
|
||||
* This doesn't have to be implemented, when
|
||||
* {@link #canDetermineObscurity()} returns {@code false}.
|
||||
*
|
||||
* @return {@code true} when the component has been obscured,
|
||||
* {@code false} otherwise
|
||||
*
|
||||
* @see #canDetermineObscurity()
|
||||
* @see javax.swing.JViewport#needsRepaintAfterBlit
|
||||
*/
|
||||
boolean isObscured();
|
||||
|
||||
/**
|
||||
* Returns {@code true} when the peer can determine if a component
|
||||
* has been obscured, {@code false} false otherwise.
|
||||
*
|
||||
* @return {@code true} when the peer can determine if a component
|
||||
* has been obscured, {@code false} false otherwise
|
||||
*
|
||||
* @see #isObscured()
|
||||
* @see javax.swing.JViewport#needsRepaintAfterBlit
|
||||
*/
|
||||
boolean canDetermineObscurity();
|
||||
|
||||
/**
|
||||
* Makes a component visible or invisible.
|
||||
*
|
||||
* @param v {@code true} to make a component visible,
|
||||
* {@code false} to make it invisible
|
||||
*
|
||||
* @see Component#setVisible(boolean)
|
||||
*/
|
||||
void setVisible(boolean v);
|
||||
|
||||
/**
|
||||
* Enables or disables a component. Disabled components are usually grayed
|
||||
* out and cannot be activated.
|
||||
*
|
||||
* @param e {@code true} to enable the component, {@code false}
|
||||
* to disable it
|
||||
*
|
||||
* @see Component#setEnabled(boolean)
|
||||
*/
|
||||
void setEnabled(boolean e);
|
||||
|
||||
/**
|
||||
* Paints the component to the specified graphics context. This is called
|
||||
* by {@link Component#paintAll(Graphics)} to paint the component.
|
||||
*
|
||||
* @param g the graphics context to paint to
|
||||
*
|
||||
* @see Component#paintAll(Graphics)
|
||||
*/
|
||||
void paint(Graphics g);
|
||||
|
||||
/**
|
||||
* Prints the component to the specified graphics context. This is called
|
||||
* by {@link Component#printAll(Graphics)} to print the component.
|
||||
*
|
||||
* @param g the graphics context to print to
|
||||
*
|
||||
* @see Component#printAll(Graphics)
|
||||
*/
|
||||
void print(Graphics g);
|
||||
|
||||
/**
|
||||
* Sets the location or size or both of the component. The location is
|
||||
* specified relative to the component's parent. The {@code op}
|
||||
* parameter specifies which properties change. If it is
|
||||
* {@link #SET_LOCATION}, then only the location changes (and the size
|
||||
* parameters can be ignored). If {@code op} is {@link #SET_SIZE},
|
||||
* then only the size changes (and the location can be ignored). If
|
||||
* {@code op} is {@link #SET_BOUNDS}, then both change. There is a
|
||||
* special value {@link #SET_CLIENT_SIZE}, which is used only for
|
||||
* window-like components to set the size of the client (i.e. the 'inner'
|
||||
* size, without the insets of the window borders).
|
||||
*
|
||||
* @param x the X location of the component
|
||||
* @param y the Y location of the component
|
||||
* @param width the width of the component
|
||||
* @param height the height of the component
|
||||
* @param op the operation flag
|
||||
*
|
||||
* @see #SET_BOUNDS
|
||||
* @see #SET_LOCATION
|
||||
* @see #SET_SIZE
|
||||
* @see #SET_CLIENT_SIZE
|
||||
*/
|
||||
void setBounds(int x, int y, int width, int height, int op);
|
||||
|
||||
/**
|
||||
* Called to let the component peer handle events.
|
||||
*
|
||||
* @param e the AWT event to handle
|
||||
*
|
||||
* @see Component#dispatchEvent(AWTEvent)
|
||||
*/
|
||||
void handleEvent(AWTEvent e);
|
||||
|
||||
/**
|
||||
* Called to coalesce paint events.
|
||||
*
|
||||
* @param e the paint event to consider to coalesce
|
||||
*
|
||||
* @see EventQueue#coalescePaintEvent
|
||||
*/
|
||||
void coalescePaintEvent(PaintEvent e);
|
||||
|
||||
/**
|
||||
* Determines the location of the component on the screen.
|
||||
*
|
||||
* @return the location of the component on the screen
|
||||
*
|
||||
* @see Component#getLocationOnScreen()
|
||||
*/
|
||||
Point getLocationOnScreen();
|
||||
|
||||
/**
|
||||
* Determines the preferred size of the component.
|
||||
*
|
||||
* @return the preferred size of the component
|
||||
*
|
||||
* @see Component#getPreferredSize()
|
||||
*/
|
||||
Dimension getPreferredSize();
|
||||
|
||||
/**
|
||||
* Determines the minimum size of the component.
|
||||
*
|
||||
* @return the minimum size of the component
|
||||
*
|
||||
* @see Component#getMinimumSize()
|
||||
*/
|
||||
Dimension getMinimumSize();
|
||||
|
||||
/**
|
||||
* Returns the color model used by the component.
|
||||
*
|
||||
* @return the color model used by the component
|
||||
*
|
||||
* @see Component#getColorModel()
|
||||
*/
|
||||
ColorModel getColorModel();
|
||||
|
||||
/**
|
||||
* Returns the toolkit that is responsible for the component.
|
||||
*
|
||||
* @return the toolkit that is responsible for the component
|
||||
*
|
||||
* @see Component#getToolkit()
|
||||
*/
|
||||
Toolkit getToolkit();
|
||||
|
||||
/**
|
||||
* Returns a graphics object to paint on the component.
|
||||
*
|
||||
* @return a graphics object to paint on the component
|
||||
*
|
||||
* @see Component#getGraphics()
|
||||
*/
|
||||
// TODO: Maybe change this to force Graphics2D, since many things will
|
||||
// break with plain Graphics nowadays.
|
||||
Graphics getGraphics();
|
||||
|
||||
/**
|
||||
* Returns a font metrics object to determine the metrics properties of
|
||||
* the specified font.
|
||||
*
|
||||
* @param font the font to determine the metrics for
|
||||
*
|
||||
* @return a font metrics object to determine the metrics properties of
|
||||
* the specified font
|
||||
*
|
||||
* @see Component#getFontMetrics(Font)
|
||||
*/
|
||||
FontMetrics getFontMetrics(Font font);
|
||||
|
||||
/**
|
||||
* Disposes all resources held by the component peer. This is called
|
||||
* when the component has been disconnected from the component hierarchy
|
||||
* and is about to be garbage collected.
|
||||
*
|
||||
* @see Component#removeNotify()
|
||||
*/
|
||||
void dispose();
|
||||
|
||||
/**
|
||||
* Sets the foreground color of this component.
|
||||
*
|
||||
* @param c the foreground color to set
|
||||
*
|
||||
* @see Component#setForeground(Color)
|
||||
*/
|
||||
void setForeground(Color c);
|
||||
|
||||
/**
|
||||
* Sets the background color of this component.
|
||||
*
|
||||
* @param c the background color to set
|
||||
*
|
||||
* @see Component#setBackground(Color)
|
||||
*/
|
||||
void setBackground(Color c);
|
||||
|
||||
/**
|
||||
* Sets the font of this component.
|
||||
*
|
||||
* @param f the font of this component
|
||||
*
|
||||
* @see Component#setFont(Font)
|
||||
*/
|
||||
void setFont(Font f);
|
||||
|
||||
/**
|
||||
* Updates the cursor of the component.
|
||||
*
|
||||
* @see Component#updateCursorImmediately
|
||||
*/
|
||||
void updateCursorImmediately();
|
||||
|
||||
/**
|
||||
* Requests focus on this component.
|
||||
*
|
||||
* @param lightweightChild the actual lightweight child that requests the
|
||||
* focus
|
||||
* @param temporary {@code true} if the focus change is temporary,
|
||||
* {@code false} otherwise
|
||||
* @param focusedWindowChangeAllowed {@code true} if changing the
|
||||
* focus of the containing window is allowed or not
|
||||
* @param time the time of the focus change request
|
||||
* @param cause the cause of the focus change request
|
||||
*
|
||||
* @return {@code true} if the focus change is guaranteed to be
|
||||
* granted, {@code false} otherwise
|
||||
*/
|
||||
boolean requestFocus(Component lightweightChild, boolean temporary,
|
||||
boolean focusedWindowChangeAllowed, long time,
|
||||
CausedFocusEvent.Cause cause);
|
||||
|
||||
/**
|
||||
* Returns {@code true} when the component takes part in the focus
|
||||
* traversal, {@code false} otherwise.
|
||||
*
|
||||
* @return {@code true} when the component takes part in the focus
|
||||
* traversal, {@code false} otherwise
|
||||
*/
|
||||
boolean isFocusable();
|
||||
|
||||
/**
|
||||
* Creates an image using the specified image producer.
|
||||
*
|
||||
* @param producer the image producer from which the image pixels will be
|
||||
* produced
|
||||
*
|
||||
* @return the created image
|
||||
*
|
||||
* @see Component#createImage(ImageProducer)
|
||||
*/
|
||||
Image createImage(ImageProducer producer);
|
||||
|
||||
/**
|
||||
* Creates an empty image with the specified width and height. This is
|
||||
* generally used as a non-accelerated backbuffer for drawing onto the
|
||||
* component (e.g. by Swing).
|
||||
*
|
||||
* @param width the width of the image
|
||||
* @param height the height of the image
|
||||
*
|
||||
* @return the created image
|
||||
*
|
||||
* @see Component#createImage(int, int)
|
||||
*/
|
||||
// TODO: Maybe make that return a BufferedImage, because some stuff will
|
||||
// break if a different kind of image is returned.
|
||||
Image createImage(int width, int height);
|
||||
|
||||
/**
|
||||
* Creates an empty volatile image with the specified width and height.
|
||||
* This is generally used as an accelerated backbuffer for drawing onto
|
||||
* the component (e.g. by Swing).
|
||||
*
|
||||
* @param width the width of the image
|
||||
* @param height the height of the image
|
||||
*
|
||||
* @return the created volatile image
|
||||
*
|
||||
* @see Component#createVolatileImage(int, int)
|
||||
*/
|
||||
// TODO: Include capabilities here and fix Component#createVolatileImage
|
||||
VolatileImage createVolatileImage(int width, int height);
|
||||
|
||||
/**
|
||||
* Prepare the specified image for rendering on this component. This should
|
||||
* start loading the image (if not already loaded) and create an
|
||||
* appropriate screen representation.
|
||||
*
|
||||
* @param img the image to prepare
|
||||
* @param w the width of the screen representation
|
||||
* @param h the height of the screen representation
|
||||
* @param o an image observer to observe the progress
|
||||
*
|
||||
* @return {@code true} if the image is already fully prepared,
|
||||
* {@code false} otherwise
|
||||
*
|
||||
* @see Component#prepareImage(Image, int, int, ImageObserver)
|
||||
*/
|
||||
boolean prepareImage(Image img, int w, int h, ImageObserver o);
|
||||
|
||||
/**
|
||||
* Determines the status of the construction of the screen representaion
|
||||
* of the specified image.
|
||||
*
|
||||
* @param img the image to check
|
||||
* @param w the target width
|
||||
* @param h the target height
|
||||
* @param o the image observer to notify
|
||||
*
|
||||
* @return the status as bitwise ORed ImageObserver flags
|
||||
*
|
||||
* @see Component#checkImage(Image, int, int, ImageObserver)
|
||||
*/
|
||||
int checkImage(Image img, int w, int h, ImageObserver o);
|
||||
|
||||
/**
|
||||
* Returns the graphics configuration that corresponds to this component.
|
||||
*
|
||||
* @return the graphics configuration that corresponds to this component
|
||||
*
|
||||
* @see Component#getGraphicsConfiguration()
|
||||
*/
|
||||
GraphicsConfiguration getGraphicsConfiguration();
|
||||
boolean handlesWheelScrolling();
|
||||
void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException;
|
||||
|
||||
/**
|
||||
* Determines if the component handles wheel scrolling itself. Otherwise
|
||||
* it is delegated to the component's parent.
|
||||
*
|
||||
* @return {@code true} if the component handles wheel scrolling,
|
||||
* {@code false} otherwise
|
||||
*
|
||||
* @see Component#dispatchEventImpl(AWTEvent)
|
||||
*/
|
||||
boolean handlesWheelScrolling();
|
||||
|
||||
/**
|
||||
* Create {@code numBuffers} flipping buffers with the specified
|
||||
* buffer capabilities.
|
||||
*
|
||||
* @param numBuffers the number of buffers to create
|
||||
* @param caps the buffer capabilities
|
||||
*
|
||||
* @throws AWTException if flip buffering is not supported
|
||||
*
|
||||
* @see Component.FlipBufferStrategy#createBuffers
|
||||
*/
|
||||
void createBuffers(int numBuffers, BufferCapabilities caps)
|
||||
throws AWTException;
|
||||
|
||||
/**
|
||||
* Returns the back buffer as image.
|
||||
*
|
||||
* @return the back buffer as image
|
||||
*
|
||||
* @see Component.FlipBufferStrategy#getBackBuffer
|
||||
*/
|
||||
Image getBackBuffer();
|
||||
|
||||
/**
|
||||
* Move the back buffer to the front buffer.
|
||||
*
|
||||
* @param x1 the area to be flipped, upper left X coordinate
|
||||
* @param y1 the area to be flipped, upper left Y coordinate
|
||||
* @param x2 the area to be flipped, lower right X coordinate
|
||||
* @param y2 the area to be flipped, lower right Y coordinate
|
||||
* @param flipAction the flip action to perform
|
||||
*
|
||||
* @see Component.FlipBufferStrategy#flip
|
||||
*/
|
||||
void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction);
|
||||
|
||||
/**
|
||||
* Destroys all created buffers.
|
||||
*
|
||||
* @see Component.FlipBufferStrategy#destroyBuffers
|
||||
*/
|
||||
void destroyBuffers();
|
||||
|
||||
/**
|
||||
* Reparents this peer to the new parent referenced by <code>newContainer</code> peer
|
||||
* Implementation depends on toolkit and container.
|
||||
* Reparents this peer to the new parent referenced by
|
||||
* {@code newContainer} peer. Implementation depends on toolkit and
|
||||
* container.
|
||||
*
|
||||
* @param newContainer peer of the new parent container
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
void reparent(ContainerPeer newContainer);
|
||||
|
||||
/**
|
||||
* Returns whether this peer supports reparenting to another parent withour destroying the peer
|
||||
* Returns whether this peer supports reparenting to another parent without
|
||||
* destroying the peer.
|
||||
*
|
||||
* @return true if appropriate reparent is supported, false otherwise
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
boolean isReparentSupported();
|
||||
@ -109,50 +526,17 @@ public interface ComponentPeer {
|
||||
* 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.
|
||||
*
|
||||
* @see Component#validate()
|
||||
*/
|
||||
void layout();
|
||||
|
||||
|
||||
Rectangle getBounds();
|
||||
void layout();
|
||||
|
||||
/**
|
||||
* Applies the shape to the native component window.
|
||||
* @since 1.7
|
||||
*
|
||||
* @see Component#applyCompoundShape
|
||||
*/
|
||||
void applyShape(Region shape);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getPreferredSize().
|
||||
*/
|
||||
Dimension preferredSize();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getMinimumSize().
|
||||
*/
|
||||
Dimension minimumSize();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setVisible(boolean).
|
||||
*/
|
||||
void show();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setVisible(boolean).
|
||||
*/
|
||||
void hide();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
*/
|
||||
void enable();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
*/
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setBounds(int, int, int, int).
|
||||
*/
|
||||
void reshape(int x, int y, int width, int height);
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ package java.awt.peer;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Container}. This is the parent interface
|
||||
* for all container like widgets.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,30 +37,60 @@ import java.awt.*;
|
||||
* instances.
|
||||
*/
|
||||
public interface ContainerPeer extends ComponentPeer {
|
||||
Insets getInsets();
|
||||
void beginValidate();
|
||||
void endValidate();
|
||||
void beginLayout();
|
||||
void endLayout();
|
||||
boolean isPaintPending();
|
||||
|
||||
/**
|
||||
* Restacks native windows - children of this native window - according to Java container order
|
||||
* Returns the insets of this container. Insets usually is the space that
|
||||
* is occupied by things like borders.
|
||||
*
|
||||
* @return the insets of this container
|
||||
*/
|
||||
Insets getInsets();
|
||||
|
||||
/**
|
||||
* Notifies the peer that validation of the component tree is about to
|
||||
* begin.
|
||||
*
|
||||
* @see Container#validate()
|
||||
*/
|
||||
void beginValidate();
|
||||
|
||||
/**
|
||||
* Notifies the peer that validation of the component tree is finished.
|
||||
*
|
||||
* @see Container#validate()
|
||||
*/
|
||||
void endValidate();
|
||||
|
||||
/**
|
||||
* Notifies the peer that layout is about to begin. This is called
|
||||
* before the container itself and its children are laid out.
|
||||
*
|
||||
* @see Container#validateTree()
|
||||
*/
|
||||
void beginLayout();
|
||||
|
||||
/**
|
||||
* Notifies the peer that layout is finished. This is called after the
|
||||
* container and its children have been laid out.
|
||||
*
|
||||
* @see Container#validateTree()
|
||||
*/
|
||||
void endLayout();
|
||||
|
||||
/**
|
||||
* Restacks native windows - children of this native window - according to
|
||||
* Java container order.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
void restack();
|
||||
|
||||
/**
|
||||
* Indicates availabiltity of restacking operation in this container.
|
||||
* Indicates availability of restacking operation in this container.
|
||||
*
|
||||
* @return Returns true if restack is supported, false otherwise
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
boolean isRestackSupported();
|
||||
/**
|
||||
|
||||
|
||||
|
||||
* DEPRECATED: Replaced by getInsets().
|
||||
*/
|
||||
Insets insets();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import java.net.URI;
|
||||
import java.awt.Desktop.Action;
|
||||
|
||||
/**
|
||||
* The <code>DesktopPeer</code> interface provides methods for the operation
|
||||
* The {@code DesktopPeer} interface provides methods for the operation
|
||||
* of open, edit, print, browse and mail with the given URL or file, by
|
||||
* launching the associated application.
|
||||
* <p>
|
||||
@ -40,14 +40,15 @@ import java.awt.Desktop.Action;
|
||||
*
|
||||
*/
|
||||
public interface DesktopPeer {
|
||||
|
||||
/**
|
||||
* Returns whether the given action is supported on the current platform.
|
||||
* @param action the action type to be tested if it's supported on the
|
||||
* current platform.
|
||||
* @return <code>true</code> if the given action is supported on
|
||||
* the current platform; <code>false</code> otherwise.
|
||||
* @return {@code true} if the given action is supported on
|
||||
* the current platform; {@code false} otherwise.
|
||||
*/
|
||||
public boolean isSupported(Action action);
|
||||
boolean isSupported(Action action);
|
||||
|
||||
/**
|
||||
* Launches the associated application to open the given file. The
|
||||
@ -58,7 +59,7 @@ public interface DesktopPeer {
|
||||
* @throws IOException If the given file has no associated application,
|
||||
* or the associated application fails to be launched.
|
||||
*/
|
||||
public void open(File file) throws IOException;
|
||||
void open(File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Launches the associated editor and opens the given file for editing. The
|
||||
@ -69,7 +70,7 @@ public interface DesktopPeer {
|
||||
* @throws IOException If the given file has no associated editor, or
|
||||
* the associated application fails to be launched.
|
||||
*/
|
||||
public void edit(File file) throws IOException;
|
||||
void edit(File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Prints the given file with the native desktop printing facility, using
|
||||
@ -79,7 +80,7 @@ public interface DesktopPeer {
|
||||
* @throws IOException If the given file has no associated application
|
||||
* that can be used to print it.
|
||||
*/
|
||||
public void print(File file) throws IOException;
|
||||
void print(File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Launches the mail composing window of the user default mail client,
|
||||
@ -93,7 +94,7 @@ public interface DesktopPeer {
|
||||
* @throws IOException If the user default mail client is not found,
|
||||
* or it fails to be launched.
|
||||
*/
|
||||
public void mail(URI mailtoURL) throws IOException;
|
||||
void mail(URI mailtoURL) throws IOException;
|
||||
|
||||
/**
|
||||
* Launches the user default browser to display the given URI.
|
||||
@ -102,5 +103,5 @@ public interface DesktopPeer {
|
||||
* @throws IOException If the user default browser is not found,
|
||||
* or it fails to be launched.
|
||||
*/
|
||||
public void browse(URI url) throws IOException;
|
||||
void browse(URI url) throws IOException;
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ package java.awt.peer;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Dialog}. This adds a couple of dialog specific
|
||||
* features to the {@link WindowPeer} interface.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -35,7 +38,33 @@ import java.awt.*;
|
||||
* instances.
|
||||
*/
|
||||
public interface DialogPeer extends WindowPeer {
|
||||
|
||||
/**
|
||||
* Sets the title on the dialog window.
|
||||
*
|
||||
* @param title the title to set
|
||||
*
|
||||
* @see Dialog#setTitle(String)
|
||||
*/
|
||||
void setTitle(String title);
|
||||
|
||||
/**
|
||||
* Sets if the dialog should be resizable or not.
|
||||
*
|
||||
* @param resizeable {@code true} when the dialog should be resizable,
|
||||
* {@code false} if not
|
||||
*
|
||||
* @see Dialog#setResizable(boolean)
|
||||
*/
|
||||
void setResizable(boolean resizeable);
|
||||
|
||||
/**
|
||||
* Block the specified windows. This is used for modal dialogs.
|
||||
*
|
||||
* @param windows the windows to block
|
||||
*
|
||||
* @see Dialog#modalShow()
|
||||
* @see Dialog#blockWindows()
|
||||
*/
|
||||
void blockWindows(java.util.List<Window> windows);
|
||||
}
|
||||
|
@ -25,9 +25,12 @@
|
||||
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.FileDialog;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link FileDialog}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -35,7 +38,32 @@ import java.io.FilenameFilter;
|
||||
* instances.
|
||||
*/
|
||||
public interface FileDialogPeer extends DialogPeer {
|
||||
|
||||
/**
|
||||
* Sets the selected file for this file dialog.
|
||||
*
|
||||
* @param file the file to set as selected file, or {@code null} for
|
||||
* no selected file
|
||||
*
|
||||
* @see FileDialog#setFile(String)
|
||||
*/
|
||||
void setFile(String file);
|
||||
|
||||
/**
|
||||
* Sets the current directory for this file dialog.
|
||||
*
|
||||
* @param dir the directory to set
|
||||
*
|
||||
* @see FileDialog#setDirectory(String)
|
||||
*/
|
||||
void setDirectory(String dir);
|
||||
|
||||
/**
|
||||
* Sets the filename filter for filtering the displayed files.
|
||||
*
|
||||
* @param filter the filter to set
|
||||
*
|
||||
* @see FileDialog#setFilenameFilter(FilenameFilter)
|
||||
*/
|
||||
void setFilenameFilter(FilenameFilter filter);
|
||||
}
|
||||
|
@ -26,6 +26,9 @@
|
||||
package java.awt.peer;
|
||||
|
||||
/**
|
||||
* The peer interface for fonts. This is only a marker interface and not
|
||||
* used by AWT itself.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
|
@ -27,7 +27,12 @@ package java.awt.peer;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import sun.awt.EmbeddedFrame;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Frame}. This adds a couple of frame specific
|
||||
* methods to the {@link WindowPeer} interface.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -35,12 +40,89 @@ import java.awt.*;
|
||||
* instances.
|
||||
*/
|
||||
public interface FramePeer extends WindowPeer {
|
||||
|
||||
/**
|
||||
* Sets the title on the frame.
|
||||
*
|
||||
* @param title the title to set
|
||||
*
|
||||
* @see Frame#setTitle(String)
|
||||
*/
|
||||
void setTitle(String title);
|
||||
|
||||
/**
|
||||
* Sets the menu bar for the frame.
|
||||
*
|
||||
* @param mb the menu bar to set
|
||||
*
|
||||
* @see Frame#setMenuBar(MenuBar)
|
||||
*/
|
||||
void setMenuBar(MenuBar mb);
|
||||
|
||||
/**
|
||||
* Sets if the frame should be resizable or not.
|
||||
*
|
||||
* @param resizeable {@code true} when the frame should be resizable,
|
||||
* {@code false} if not
|
||||
*
|
||||
* @see Frame#setResizable(boolean)
|
||||
*/
|
||||
void setResizable(boolean resizeable);
|
||||
|
||||
/**
|
||||
* Changes the state of the frame.
|
||||
*
|
||||
* @param state the new state
|
||||
*
|
||||
* @see Frame#setExtendedState(int)
|
||||
*/
|
||||
void setState(int state);
|
||||
int getState();
|
||||
void setMaximizedBounds(Rectangle bounds); // XXX
|
||||
|
||||
/**
|
||||
* Returns the current state of the frame.
|
||||
*
|
||||
* @return the current state of the frame
|
||||
*
|
||||
* @see Frame#getExtendedState()
|
||||
*/
|
||||
int getState();
|
||||
|
||||
/**
|
||||
* Sets the bounds of the frame when it becomes maximized.
|
||||
*
|
||||
* @param bounds the maximized bounds of the frame
|
||||
*
|
||||
* @see Frame#setMaximizedBounds(Rectangle)
|
||||
*/
|
||||
void setMaximizedBounds(Rectangle bounds);
|
||||
|
||||
/**
|
||||
* Sets the size and location for embedded frames. (On embedded frames,
|
||||
* setLocation() and setBounds() always set the frame to (0,0) for
|
||||
* backwards compatibility.
|
||||
*
|
||||
* @param x the X location
|
||||
* @param y the Y location
|
||||
* @param width the width of the frame
|
||||
* @param height the height of the frame
|
||||
*
|
||||
* @see EmbeddedFrame#setBoundsPrivate(int, int, int, int)
|
||||
*/
|
||||
// TODO: This is only used in EmbeddedFrame, and should probably be moved
|
||||
// into an EmbeddedFramePeer which would extend FramePeer
|
||||
void setBoundsPrivate(int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Returns the size and location for embedded frames. (On embedded frames,
|
||||
* setLocation() and setBounds() always set the frame to (0,0) for
|
||||
* backwards compatibility.
|
||||
*
|
||||
* @return the bounds of an embedded frame
|
||||
*
|
||||
* @see EmbeddedFrame#getBoundsPrivate()
|
||||
*/
|
||||
// TODO: This is only used in EmbeddedFrame, and should probably be moved
|
||||
// into an EmbeddedFramePeer which would extend FramePeer
|
||||
Rectangle getBoundsPrivate();
|
||||
|
||||
}
|
||||
|
@ -28,11 +28,45 @@ package java.awt.peer;
|
||||
import java.awt.Component;
|
||||
import java.awt.Window;
|
||||
|
||||
/**
|
||||
* The native peer interface for {@link KeyboardFocusManager}.
|
||||
*/
|
||||
public interface KeyboardFocusManagerPeer {
|
||||
|
||||
/**
|
||||
* Returns the currently focused window.
|
||||
*
|
||||
* @return the currently focused window
|
||||
*
|
||||
* @see KeyboardFocusManager#getNativeFocusedWindow()
|
||||
*/
|
||||
Window getCurrentFocusedWindow();
|
||||
|
||||
/**
|
||||
* Sets the component that should become the focus owner.
|
||||
*
|
||||
* @param comp the component to become the focus owner
|
||||
*
|
||||
* @see KeyboardFocusManager#setNativeFocusOwner(Component)
|
||||
*/
|
||||
void setCurrentFocusOwner(Component comp);
|
||||
|
||||
/**
|
||||
* Returns the component that currently owns the input focus.
|
||||
*
|
||||
* @return the component that currently owns the input focus
|
||||
*
|
||||
* @see KeyboardFocusManager#getNativeFocusOwner()
|
||||
*/
|
||||
Component getCurrentFocusOwner();
|
||||
|
||||
/**
|
||||
* Clears the current global focus owner.
|
||||
*
|
||||
* @param activeWindow
|
||||
*
|
||||
* @see KeyboardFocusManager#clearGlobalFocusOwner()
|
||||
*/
|
||||
void clearGlobalFocusOwner(Window activeWindow);
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,11 @@
|
||||
*/
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Label;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Label}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -32,6 +36,25 @@ package java.awt.peer;
|
||||
* instances.
|
||||
*/
|
||||
public interface LabelPeer extends ComponentPeer {
|
||||
|
||||
/**
|
||||
* Sets the text to be displayed on the label.
|
||||
*
|
||||
* @param label the text to be displayed on the label
|
||||
*
|
||||
* @see Label#setText
|
||||
*/
|
||||
void setText(String label);
|
||||
|
||||
/**
|
||||
* Sets the alignment of the label text.
|
||||
*
|
||||
* @param alignment the alignment of the label text
|
||||
*
|
||||
* @see Label#setAlignment(int)
|
||||
* @see Label#CENTER
|
||||
* @see Label#RIGHT
|
||||
* @see Label#LEFT
|
||||
*/
|
||||
void setAlignment(int alignment);
|
||||
}
|
||||
|
@ -25,8 +25,11 @@
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.List;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link List}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,39 +37,102 @@ import java.awt.Dimension;
|
||||
* instances.
|
||||
*/
|
||||
public interface ListPeer extends ComponentPeer {
|
||||
|
||||
/**
|
||||
* Returns the indices of the list items that are currently selected.
|
||||
* The returned array is not required to be a copy, the callers of this
|
||||
* method already make sure it is not modified.
|
||||
*
|
||||
* @return the indices of the list items that are currently selected
|
||||
*
|
||||
* @see List#getSelectedIndexes()
|
||||
*/
|
||||
int[] getSelectedIndexes();
|
||||
|
||||
/**
|
||||
* Adds an item to the list at the specified index.
|
||||
*
|
||||
* @param item the item to add to the list
|
||||
* @param index the index where to add the item into the list
|
||||
*
|
||||
* @see List#add(String, int)
|
||||
*/
|
||||
void add(String item, int index);
|
||||
|
||||
/**
|
||||
* Deletes items from the list. All items from start to end should are
|
||||
* deleted, including the item at the start and end indices.
|
||||
*
|
||||
* @param start the first item to be deleted
|
||||
* @param end the last item to be deleted
|
||||
*/
|
||||
void delItems(int start, int end);
|
||||
|
||||
/**
|
||||
* Removes all items from the list.
|
||||
*
|
||||
* @see List#removeAll()
|
||||
*/
|
||||
void removeAll();
|
||||
|
||||
/**
|
||||
* Selects the item at the specified {@code index}.
|
||||
*
|
||||
* @param index the index of the item to select
|
||||
*
|
||||
* @see List#select(int)
|
||||
*/
|
||||
void select(int index);
|
||||
|
||||
/**
|
||||
* De-selects the item at the specified {@code index}.
|
||||
*
|
||||
* @param index the index of the item to de-select
|
||||
*
|
||||
* @see List#deselect(int)
|
||||
*/
|
||||
void deselect(int index);
|
||||
|
||||
/**
|
||||
* Makes sure that the item at the specified {@code index} is visible,
|
||||
* by scrolling the list or similar.
|
||||
*
|
||||
* @param index the index of the item to make visible
|
||||
*
|
||||
* @see List#makeVisible(int)
|
||||
*/
|
||||
void makeVisible(int index);
|
||||
void setMultipleMode(boolean b);
|
||||
|
||||
/**
|
||||
* Toggles multiple selection mode on or off.
|
||||
*
|
||||
* @param m {@code true} for multiple selection mode,
|
||||
* {@code false} for single selection mode
|
||||
*
|
||||
* @see List#setMultipleMode(boolean)
|
||||
*/
|
||||
void setMultipleMode(boolean m);
|
||||
|
||||
/**
|
||||
* Returns the preferred size for a list with the specified number of rows.
|
||||
*
|
||||
* @param rows the number of rows
|
||||
*
|
||||
* @return the preferred size of the list
|
||||
*
|
||||
* @see List#getPreferredSize(int)
|
||||
*/
|
||||
Dimension getPreferredSize(int rows);
|
||||
|
||||
/**
|
||||
* Returns the minimum size for a list with the specified number of rows.
|
||||
*
|
||||
* @param rows the number of rows
|
||||
*
|
||||
* @return the minimum size of the list
|
||||
*
|
||||
* @see List#getMinimumSize(int)
|
||||
*/
|
||||
Dimension getMinimumSize(int rows);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by add(String, int).
|
||||
*/
|
||||
void addItem(String item, int index);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by removeAll().
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setMultipleMode(boolean).
|
||||
*/
|
||||
void setMultipleSelections(boolean v);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getPreferredSize(int).
|
||||
*/
|
||||
Dimension preferredSize(int v);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getMinimumSize(int).
|
||||
*/
|
||||
Dimension minimumSize(int v);
|
||||
}
|
||||
|
@ -25,8 +25,11 @@
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link MenuBar}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,7 +37,31 @@ import java.awt.Menu;
|
||||
* instances.
|
||||
*/
|
||||
public interface MenuBarPeer extends MenuComponentPeer {
|
||||
|
||||
/**
|
||||
* Adds a menu to the menu bar.
|
||||
*
|
||||
* @param m the menu to add
|
||||
*
|
||||
* @see MenuBar#add(Menu)
|
||||
*/
|
||||
void addMenu(Menu m);
|
||||
|
||||
/**
|
||||
* Deletes a menu from the menu bar.
|
||||
*
|
||||
* @param index the index of the menu to remove
|
||||
*
|
||||
* @see MenuBar#remove(int)
|
||||
*/
|
||||
void delMenu(int index);
|
||||
|
||||
/**
|
||||
* Adds a help menu to the menu bar.
|
||||
*
|
||||
* @param m the help menu to add
|
||||
*
|
||||
* @see MenuBar#setHelpMenu(Menu)
|
||||
*/
|
||||
void addHelpMenu(Menu m);
|
||||
}
|
||||
|
@ -25,8 +25,12 @@
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.MenuComponent;
|
||||
|
||||
/**
|
||||
* The base interface for all kinds of menu components. This is used by
|
||||
* {@link MenuComponent}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,6 +38,20 @@ import java.awt.Font;
|
||||
* instances.
|
||||
*/
|
||||
public interface MenuComponentPeer {
|
||||
|
||||
/**
|
||||
* Disposes the menu component.
|
||||
*
|
||||
* @see MenuComponent#removeNotify()
|
||||
*/
|
||||
void dispose();
|
||||
|
||||
/**
|
||||
* Sets the font for the menu component.
|
||||
*
|
||||
* @param f the font to use for the menu component
|
||||
*
|
||||
* @see MenuComponent#setFont(Font)
|
||||
*/
|
||||
void setFont(Font f);
|
||||
}
|
||||
|
@ -24,7 +24,11 @@
|
||||
*/
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.MenuItem;
|
||||
|
||||
/**
|
||||
* The peer interface for menu items. This is used by {@link MenuItem}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -32,16 +36,20 @@ package java.awt.peer;
|
||||
* instances.
|
||||
*/
|
||||
public interface MenuItemPeer extends MenuComponentPeer {
|
||||
|
||||
/**
|
||||
* Sets the label to be displayed in this menu item.
|
||||
*
|
||||
* @param label the label to be displayed
|
||||
*/
|
||||
void setLabel(String label);
|
||||
void setEnabled(boolean b);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
* Enables or disables the menu item.
|
||||
*
|
||||
* @param e {@code true} to enable the menu item, {@code false}
|
||||
* to disable it
|
||||
*/
|
||||
void enable();
|
||||
void setEnabled(boolean e);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
*/
|
||||
void disable();
|
||||
}
|
||||
|
@ -24,9 +24,12 @@
|
||||
*/
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuItem;
|
||||
|
||||
/**
|
||||
* The peer interface for menus. This is used by {@link Menu}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,7 +37,29 @@ import java.awt.MenuItem;
|
||||
* instances.
|
||||
*/
|
||||
public interface MenuPeer extends MenuItemPeer {
|
||||
|
||||
/**
|
||||
* Adds a separator (e.g. a horizontal line or similar) to the menu.
|
||||
*
|
||||
* @see Menu#addSeparator()
|
||||
*/
|
||||
void addSeparator();
|
||||
|
||||
/**
|
||||
* Adds the specified menu item to the menu.
|
||||
*
|
||||
* @param item the menu item to add
|
||||
*
|
||||
* @see Menu#add(MenuItem)
|
||||
*/
|
||||
void addItem(MenuItem item);
|
||||
|
||||
/**
|
||||
* Removes the menu item at the specified index.
|
||||
*
|
||||
* @param index the index of the item to remove
|
||||
*
|
||||
* @see Menu#remove(int)
|
||||
*/
|
||||
void delItem(int index);
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ import java.awt.Window;
|
||||
import java.awt.Point;
|
||||
|
||||
/**
|
||||
* Peer interface for {@link MouseInfo}. This is used to get some additional
|
||||
* information about the mouse.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
|
@ -25,6 +25,10 @@
|
||||
package java.awt.peer;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Panel}. This is a subinterface of
|
||||
* ContainerPeer and does not declare any additional methods because a Panel
|
||||
* is just that, a concrete Container.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
|
@ -25,8 +25,11 @@
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Event;
|
||||
import java.awt.PopupMenu;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link PopupMenu}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,5 +37,14 @@ import java.awt.Event;
|
||||
* instances.
|
||||
*/
|
||||
public interface PopupMenuPeer extends MenuPeer {
|
||||
|
||||
/**
|
||||
* Shows the popup menu.
|
||||
*
|
||||
* @param e a synthetic event describing the origin and location of the
|
||||
* popup menu
|
||||
*
|
||||
* @see PopupMenu#show(java.awt.Component, int, int)
|
||||
*/
|
||||
void show(Event e);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2007 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
|
||||
@ -39,17 +39,93 @@ import java.awt.*;
|
||||
*/
|
||||
public interface RobotPeer
|
||||
{
|
||||
public void mouseMove(int x, int y);
|
||||
public void mousePress(int buttons);
|
||||
public void mouseRelease(int buttons);
|
||||
/**
|
||||
* Moves the mouse pointer to the specified screen location.
|
||||
*
|
||||
* @param x the X location on screen
|
||||
* @param y the Y location on screen
|
||||
*
|
||||
* @see Robot#mouseMove(int, int)
|
||||
*/
|
||||
void mouseMove(int x, int y);
|
||||
|
||||
public void mouseWheel(int wheelAmt);
|
||||
/**
|
||||
* Simulates a mouse press with the specified button(s).
|
||||
*
|
||||
* @param buttons the button mask
|
||||
*
|
||||
* @see Robot#mousePress(int)
|
||||
*/
|
||||
void mousePress(int buttons);
|
||||
|
||||
public void keyPress(int keycode);
|
||||
public void keyRelease(int keycode);
|
||||
/**
|
||||
* Simulates a mouse release with the specified button(s).
|
||||
*
|
||||
* @param buttons the button mask
|
||||
*
|
||||
* @see Robot#mouseRelease(int)
|
||||
*/
|
||||
void mouseRelease(int buttons);
|
||||
|
||||
public int getRGBPixel(int x, int y);
|
||||
public int [] getRGBPixels(Rectangle bounds);
|
||||
/**
|
||||
* Simulates mouse wheel action.
|
||||
*
|
||||
* @param wheelAmt number of notches to move the mouse wheel
|
||||
*
|
||||
* @see Robot#mouseWheel(int)
|
||||
*/
|
||||
void mouseWheel(int wheelAmt);
|
||||
|
||||
public void dispose();
|
||||
/**
|
||||
* Simulates a key press of the specified key.
|
||||
*
|
||||
* @param keycode the key code to press
|
||||
*
|
||||
* @see Robot#keyPress(int)
|
||||
*/
|
||||
void keyPress(int keycode);
|
||||
|
||||
/**
|
||||
* Simulates a key release of the specified key.
|
||||
*
|
||||
* @param keycode the key code to release
|
||||
*
|
||||
* @see Robot#keyRelease(int)
|
||||
*/
|
||||
void keyRelease(int keycode);
|
||||
|
||||
/**
|
||||
* Gets the RGB value of the specified pixel on screen.
|
||||
*
|
||||
* @param x the X screen coordinate
|
||||
* @param y the Y screen coordinate
|
||||
*
|
||||
* @return the RGB value of the specified pixel on screen
|
||||
*
|
||||
* @see Robot#getPixelColor(int, int)
|
||||
*/
|
||||
int getRGBPixel(int x, int y);
|
||||
|
||||
/**
|
||||
* Gets the RGB values of the specified screen area as an array.
|
||||
*
|
||||
* @param bounds the screen area to capture the RGB values from
|
||||
*
|
||||
* @return the RGB values of the specified screen area
|
||||
*
|
||||
* @see Robot#createScreenCapture(Rectangle)
|
||||
*/
|
||||
int[] getRGBPixels(Rectangle bounds);
|
||||
|
||||
/**
|
||||
* Disposes the robot peer when it is not needed anymore.
|
||||
*/
|
||||
void dispose();
|
||||
|
||||
/**
|
||||
* Returns the number of buttons that the robot simulates.
|
||||
*
|
||||
* @return the number of buttons that the robot simulates
|
||||
*/
|
||||
int getNumberOfButtons();
|
||||
}
|
||||
|
@ -25,8 +25,12 @@
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Adjustable;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.ScrollPaneAdjustable;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link ScrollPane}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,10 +38,60 @@ import java.awt.Adjustable;
|
||||
* instances.
|
||||
*/
|
||||
public interface ScrollPanePeer extends ContainerPeer {
|
||||
|
||||
/**
|
||||
* Returns the height of the horizontal scroll bar.
|
||||
*
|
||||
* @return the height of the horizontal scroll bar
|
||||
*
|
||||
* @see ScrollPane#getHScrollbarHeight()
|
||||
*/
|
||||
int getHScrollbarHeight();
|
||||
|
||||
/**
|
||||
* Returns the width of the vertical scroll bar.
|
||||
*
|
||||
* @return the width of the vertical scroll bar
|
||||
*
|
||||
* @see ScrollPane#getVScrollbarWidth()
|
||||
*/
|
||||
int getVScrollbarWidth();
|
||||
|
||||
/**
|
||||
* Sets the scroll position of the child.
|
||||
*
|
||||
* @param x the X coordinate of the scroll position
|
||||
* @param y the Y coordinate of the scroll position
|
||||
*
|
||||
* @see ScrollPane#setScrollPosition(int, int)
|
||||
*/
|
||||
void setScrollPosition(int x, int y);
|
||||
|
||||
/**
|
||||
* Called when the child component changes its size.
|
||||
*
|
||||
* @param w the new width of the child component
|
||||
* @param h the new height of the child component
|
||||
*
|
||||
* @see ScrollPane#layout()
|
||||
*/
|
||||
void childResized(int w, int h);
|
||||
|
||||
/**
|
||||
* Sets the unit increment of one of the scroll pane's adjustables.
|
||||
*
|
||||
* @param adj the scroll pane adjustable object
|
||||
* @param u the unit increment
|
||||
*
|
||||
* @see ScrollPaneAdjustable#setUnitIncrement(int)
|
||||
*/
|
||||
void setUnitIncrement(Adjustable adj, int u);
|
||||
|
||||
/**
|
||||
* Sets the value for one of the scroll pane's adjustables.
|
||||
*
|
||||
* @param adj the scroll pane adjustable object
|
||||
* @param v the value to set
|
||||
*/
|
||||
void setValue(Adjustable adj, int v);
|
||||
}
|
||||
|
@ -24,7 +24,11 @@
|
||||
*/
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Scrollbar;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Scrollbar}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -32,7 +36,34 @@ package java.awt.peer;
|
||||
* instances.
|
||||
*/
|
||||
public interface ScrollbarPeer extends ComponentPeer {
|
||||
|
||||
/**
|
||||
* Sets the parameters for the scrollbar.
|
||||
*
|
||||
* @param value the current value
|
||||
* @param visible how much of the whole scale is visible
|
||||
* @param minimum the minimum value
|
||||
* @param maximum the maximum value
|
||||
*
|
||||
* @see Scrollbar#setValues(int, int, int, int)
|
||||
*/
|
||||
void setValues(int value, int visible, int minimum, int maximum);
|
||||
|
||||
/**
|
||||
* Sets the line increment of the scrollbar.
|
||||
*
|
||||
* @param l the line increment
|
||||
*
|
||||
* @see Scrollbar#setLineIncrement(int)
|
||||
*/
|
||||
void setLineIncrement(int l);
|
||||
|
||||
/**
|
||||
* Sets the page increment of the scrollbar.
|
||||
*
|
||||
* @param l the page increment
|
||||
*
|
||||
* @see Scrollbar#setPageIncrement(int)
|
||||
*/
|
||||
void setPageIncrement(int l);
|
||||
}
|
||||
|
@ -26,7 +26,20 @@
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.SystemTray;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link SystemTray}. This doesn't need to be
|
||||
* implemented if {@link SystemTray#isSupported()} returns false.
|
||||
*/
|
||||
public interface SystemTrayPeer {
|
||||
|
||||
/**
|
||||
* Returns the size of the system tray icon.
|
||||
*
|
||||
* @return the size of the system tray icon
|
||||
*
|
||||
* @see SystemTray#getTrayIconSize()
|
||||
*/
|
||||
Dimension getTrayIconSize();
|
||||
}
|
||||
|
@ -25,8 +25,11 @@
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.TextArea;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link TexTArea}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,28 +37,52 @@ import java.awt.Dimension;
|
||||
* instances.
|
||||
*/
|
||||
public interface TextAreaPeer extends TextComponentPeer {
|
||||
|
||||
/**
|
||||
* Inserts the specified text at the specified position in the document.
|
||||
*
|
||||
* @param text the text to insert
|
||||
* @param pos the position to insert
|
||||
*
|
||||
* @see TextArea#insert(String, int)
|
||||
*/
|
||||
void insert(String text, int pos);
|
||||
|
||||
/**
|
||||
* Replaces a range of text by the specified string
|
||||
*
|
||||
* @param text the replacement string
|
||||
* @param start the begin of the range to replace
|
||||
* @param end the end of the range to replace
|
||||
*
|
||||
* @see TextArea#replaceRange(String, int, int)
|
||||
*/
|
||||
void replaceRange(String text, int start, int end);
|
||||
|
||||
/**
|
||||
* Returns the preferred size of a textarea with the specified number of
|
||||
* columns and rows.
|
||||
*
|
||||
* @param rows the number of rows
|
||||
* @param columns the number of columns
|
||||
*
|
||||
* @return the preferred size of a textarea
|
||||
*
|
||||
* @see TextArea#getPreferredSize(int, int)
|
||||
*/
|
||||
Dimension getPreferredSize(int rows, int columns);
|
||||
|
||||
/**
|
||||
* Returns the minimum size of a textarea with the specified number of
|
||||
* columns and rows.
|
||||
*
|
||||
* @param rows the number of rows
|
||||
* @param columns the number of columns
|
||||
*
|
||||
* @return the minimum size of a textarea
|
||||
*
|
||||
* @see TextArea#getMinimumSize(int, int)
|
||||
*/
|
||||
Dimension getMinimumSize(int rows, int columns);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by insert(String, int).
|
||||
*/
|
||||
void insertText(String txt, int pos);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by ReplaceRange(String, int, int).
|
||||
*/
|
||||
void replaceText(String txt, int start, int end);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getPreferredSize(int, int).
|
||||
*/
|
||||
Dimension preferredSize(int rows, int cols);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getMinimumSize(int, int).
|
||||
*/
|
||||
Dimension minimumSize(int rows, int cols);
|
||||
}
|
||||
|
@ -24,10 +24,12 @@
|
||||
*/
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.TextComponent;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link TextComponent}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -35,16 +37,85 @@ import java.awt.im.InputMethodRequests;
|
||||
* instances.
|
||||
*/
|
||||
public interface TextComponentPeer extends ComponentPeer {
|
||||
|
||||
/**
|
||||
* Sets if the text component should be editable or not.
|
||||
*
|
||||
* @param editable {@code true} for editable text components,
|
||||
* {@code false} for non-editable text components
|
||||
*
|
||||
* @see TextComponent#setEditable(boolean)
|
||||
*/
|
||||
void setEditable(boolean editable);
|
||||
|
||||
/**
|
||||
* Returns the current content of the text component.
|
||||
*
|
||||
* @return the current content of the text component
|
||||
*
|
||||
* @see TextComponent#getText()
|
||||
*/
|
||||
String getText();
|
||||
|
||||
/**
|
||||
* Sets the content for the text component.
|
||||
*
|
||||
* @param l the content to set
|
||||
*
|
||||
* @see TextComponent#setText(String)
|
||||
*/
|
||||
void setText(String l);
|
||||
|
||||
/**
|
||||
* Returns the start index of the current selection.
|
||||
*
|
||||
* @return the start index of the current selection
|
||||
*
|
||||
* @see TextComponent#getSelectionStart()
|
||||
*/
|
||||
int getSelectionStart();
|
||||
|
||||
/**
|
||||
* Returns the end index of the current selection.
|
||||
*
|
||||
* @return the end index of the current selection
|
||||
*
|
||||
* @see TextComponent#getSelectionEnd()
|
||||
*/
|
||||
int getSelectionEnd();
|
||||
|
||||
/**
|
||||
* Selects an area of the text component.
|
||||
*
|
||||
* @param selStart the start index of the new selection
|
||||
* @param selEnd the end index of the new selection
|
||||
*
|
||||
* @see TextComponent#select(int, int)
|
||||
*/
|
||||
void select(int selStart, int selEnd);
|
||||
|
||||
/**
|
||||
* Sets the caret position of the text component.
|
||||
*
|
||||
* @param pos the caret position to set
|
||||
*
|
||||
* @see TextComponent#setCaretPosition(int)
|
||||
*/
|
||||
void setCaretPosition(int pos);
|
||||
|
||||
/**
|
||||
* Returns the current caret position.
|
||||
*
|
||||
* @return the current caret position
|
||||
*
|
||||
* @see TextComponent#getCaretPosition()
|
||||
*/
|
||||
int getCaretPosition();
|
||||
int getIndexAtPoint(int x, int y);
|
||||
Rectangle getCharacterBounds(int i);
|
||||
long filterEvents(long mask);
|
||||
|
||||
/**
|
||||
* Returns the input method requests.
|
||||
*
|
||||
* @return the input method requests
|
||||
*/
|
||||
InputMethodRequests getInputMethodRequests();
|
||||
}
|
||||
|
@ -25,8 +25,11 @@
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.TextField;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link TextField}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -34,22 +37,38 @@ import java.awt.Dimension;
|
||||
* instances.
|
||||
*/
|
||||
public interface TextFieldPeer extends TextComponentPeer {
|
||||
|
||||
/**
|
||||
* Sets the echo character.
|
||||
*
|
||||
* @param echoChar the echo character to set
|
||||
*
|
||||
* @see TextField#getEchoChar()
|
||||
*/
|
||||
void setEchoChar(char echoChar);
|
||||
|
||||
/**
|
||||
* Returns the preferred size of the text field with the specified number
|
||||
* of columns.
|
||||
*
|
||||
* @param columns the number of columns
|
||||
*
|
||||
* @return the preferred size of the text field
|
||||
*
|
||||
* @see TextField#getPreferredSize(int)
|
||||
*/
|
||||
Dimension getPreferredSize(int columns);
|
||||
|
||||
/**
|
||||
* Returns the minimum size of the text field with the specified number
|
||||
* of columns.
|
||||
*
|
||||
* @param columns the number of columns
|
||||
*
|
||||
* @return the minimum size of the text field
|
||||
*
|
||||
* @see TextField#getMinimumSize(int)
|
||||
*/
|
||||
Dimension getMinimumSize(int columns);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEchoChar(char echoChar).
|
||||
*/
|
||||
void setEchoCharacter(char c);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getPreferredSize(int).
|
||||
*/
|
||||
Dimension preferredSize(int cols);
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getMinimumSize(int).
|
||||
*/
|
||||
Dimension minimumSize(int cols);
|
||||
}
|
||||
|
@ -25,10 +25,56 @@
|
||||
|
||||
package java.awt.peer;
|
||||
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.TrayIcon;
|
||||
|
||||
/**
|
||||
* The peer interface for the {@link TrayIcon}. This doesn't need to be
|
||||
* implemented if {@link SystemTray#isSupported()} returns false.
|
||||
*/
|
||||
public interface TrayIconPeer {
|
||||
|
||||
/**
|
||||
* Disposes the tray icon and releases and resources held by it.
|
||||
*
|
||||
* @see TrayIcon#removeNotify()
|
||||
*/
|
||||
void dispose();
|
||||
|
||||
/**
|
||||
* Sets the tool tip for the tray icon.
|
||||
*
|
||||
* @param tooltip the tooltip to set
|
||||
*
|
||||
* @see TrayIcon#setToolTip(String)
|
||||
*/
|
||||
void setToolTip(String tooltip);
|
||||
|
||||
/**
|
||||
* Updates the icon image. This is supposed to display the current icon
|
||||
* from the TrayIcon component in the actual tray icon.
|
||||
*
|
||||
* @see TrayIcon#setImage(java.awt.Image)
|
||||
* @see TrayIcon#setImageAutoSize(boolean)
|
||||
*/
|
||||
void updateImage();
|
||||
|
||||
/**
|
||||
* Displays a message at the tray icon.
|
||||
*
|
||||
* @param caption the message caption
|
||||
* @param text the actual message text
|
||||
* @param messageType the message type
|
||||
*
|
||||
* @see TrayIcon#displayMessage(String, String, java.awt.TrayIcon.MessageType)
|
||||
*/
|
||||
void displayMessage(String caption, String text, String messageType);
|
||||
|
||||
/**
|
||||
* Shows the popup menu of this tray icon at the specified position.
|
||||
*
|
||||
* @param x the X location for the popup menu
|
||||
* @param y the Y location for the popup menu
|
||||
*/
|
||||
void showPopupMenu(int x, int y);
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ package java.awt.peer;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The peer interface for {@link Window}.
|
||||
*
|
||||
* The peer interfaces are intended only for use in porting
|
||||
* the AWT. They are not intended for use by application
|
||||
* developers, and developers should not implement peers
|
||||
@ -35,12 +37,59 @@ import java.awt.*;
|
||||
* instances.
|
||||
*/
|
||||
public interface WindowPeer extends ContainerPeer {
|
||||
|
||||
/**
|
||||
* Makes this window the topmost window on the desktop.
|
||||
*
|
||||
* @see Window#toFront()
|
||||
*/
|
||||
void toFront();
|
||||
|
||||
/**
|
||||
* Makes this window the bottommost window on the desktop.
|
||||
*
|
||||
* @see Window#toBack()
|
||||
*/
|
||||
void toBack();
|
||||
|
||||
/**
|
||||
* Sets if the window should always stay on top of all other windows or
|
||||
* not.
|
||||
*
|
||||
* @param alwaysOnTop if the window should always stay on top of all other
|
||||
* windows or not
|
||||
*
|
||||
* @see Window#setAlwaysOnTop(boolean)
|
||||
*/
|
||||
void setAlwaysOnTop(boolean alwaysOnTop);
|
||||
|
||||
/**
|
||||
* Updates the window's focusable state.
|
||||
*
|
||||
* @see Window#setFocusableWindowState(boolean)
|
||||
*/
|
||||
void updateFocusableWindowState();
|
||||
boolean requestWindowFocus();
|
||||
|
||||
/**
|
||||
* Sets if this window is blocked by a modal dialog or not.
|
||||
*
|
||||
* @param blocker the blocking modal dialog
|
||||
* @param blocked {@code true} to block the window, {@code false}
|
||||
* to unblock it
|
||||
*/
|
||||
void setModalBlocked(Dialog blocker, boolean blocked);
|
||||
|
||||
/**
|
||||
* Updates the minimum size on the peer.
|
||||
*
|
||||
* @see Window#setMinimumSize(Dimension)
|
||||
*/
|
||||
void updateMinimumSize();
|
||||
|
||||
/**
|
||||
* Updates the icons for the window.
|
||||
*
|
||||
* @see Window#setIconImages(java.util.List)
|
||||
*/
|
||||
void updateIconImages();
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public abstract class InputStream implements Closeable {
|
||||
*
|
||||
* @param b the buffer into which the data is read.
|
||||
* @return the total number of bytes read into the buffer, or
|
||||
* <code>-1</code> is there is no more data because the end of
|
||||
* <code>-1</code> if there is no more data because the end of
|
||||
* the stream has been reached.
|
||||
* @exception IOException If the first byte cannot be read for any reason
|
||||
* other than the end of the file, if the input stream has been closed, or
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2009 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
|
||||
@ -34,6 +34,13 @@ import java.io.ObjectStreamException;
|
||||
/**
|
||||
* This is the common base class of all Java language enumeration types.
|
||||
*
|
||||
* More information about enums, including descriptions of the
|
||||
* implicitly declared methods synthesized by the compiler, can be
|
||||
* found in <i>The Java™ Language Specification, Third
|
||||
* Edition</i>, <a
|
||||
* href="http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.9">§8.9</a>.
|
||||
*
|
||||
* @param <E> The enum type subclass
|
||||
* @author Josh Bloch
|
||||
* @author Neal Gafter
|
||||
* @see Class#getEnumConstants()
|
||||
@ -192,6 +199,15 @@ public abstract class Enum<E extends Enum<E>>
|
||||
* to declare an enum constant in this type. (Extraneous whitespace
|
||||
* characters are not permitted.)
|
||||
*
|
||||
* <p>Note that for a particular enum type {@code T}, the
|
||||
* implicitly declared {@code public static T valueOf(String)}
|
||||
* method on that enum may be used instead of this method to map
|
||||
* from a name to the corresponding enum constant. All the
|
||||
* constants of an enum type can be obtained by calling the
|
||||
* implicit {@code public static T[] values()} method of that
|
||||
* type.
|
||||
*
|
||||
* @param <T> The enum type whose constant is to be returned
|
||||
* @param enumType the {@code Class} object of the enum type from which
|
||||
* to return a constant
|
||||
* @param name the name of the constant to return
|
||||
@ -212,7 +228,7 @@ public abstract class Enum<E extends Enum<E>>
|
||||
if (name == null)
|
||||
throw new NullPointerException("Name is null");
|
||||
throw new IllegalArgumentException(
|
||||
"No enum const " + enumType +"." + name);
|
||||
"No enum constant " + enumType.getCanonicalName() + "." + name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -225,10 +241,10 @@ public abstract class Enum<E extends Enum<E>>
|
||||
*/
|
||||
private void readObject(ObjectInputStream in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
throw new InvalidObjectException("can't deserialize enum");
|
||||
throw new InvalidObjectException("can't deserialize enum");
|
||||
}
|
||||
|
||||
private void readObjectNoData() throws ObjectStreamException {
|
||||
throw new InvalidObjectException("can't deserialize enum");
|
||||
throw new InvalidObjectException("can't deserialize enum");
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@
|
||||
package java.lang;
|
||||
|
||||
/**
|
||||
* Class <code>Object</code> is the root of the class hierarchy.
|
||||
* Every class has <code>Object</code> as a superclass. All objects,
|
||||
* Class {@code Object} is the root of the class hierarchy.
|
||||
* Every class has {@code Object} as a superclass. All objects,
|
||||
* including arrays, implement the methods of this class.
|
||||
*
|
||||
* @author unascribed
|
||||
@ -66,30 +66,30 @@ public class Object {
|
||||
|
||||
/**
|
||||
* Returns a hash code value for the object. This method is
|
||||
* supported for the benefit of hashtables such as those provided by
|
||||
* <code>java.util.Hashtable</code>.
|
||||
* supported for the benefit of hash tables such as those provided by
|
||||
* {@link java.util.HashMap}.
|
||||
* <p>
|
||||
* The general contract of <code>hashCode</code> is:
|
||||
* The general contract of {@code hashCode} is:
|
||||
* <ul>
|
||||
* <li>Whenever it is invoked on the same object more than once during
|
||||
* an execution of a Java application, the <tt>hashCode</tt> method
|
||||
* an execution of a Java application, the {@code hashCode} method
|
||||
* must consistently return the same integer, provided no information
|
||||
* used in <tt>equals</tt> comparisons on the object is modified.
|
||||
* used in {@code equals} comparisons on the object is modified.
|
||||
* This integer need not remain consistent from one execution of an
|
||||
* application to another execution of the same application.
|
||||
* <li>If two objects are equal according to the <tt>equals(Object)</tt>
|
||||
* method, then calling the <code>hashCode</code> method on each of
|
||||
* <li>If two objects are equal according to the {@code equals(Object)}
|
||||
* method, then calling the {@code hashCode} method on each of
|
||||
* the two objects must produce the same integer result.
|
||||
* <li>It is <em>not</em> required that if two objects are unequal
|
||||
* according to the {@link java.lang.Object#equals(java.lang.Object)}
|
||||
* method, then calling the <tt>hashCode</tt> method on each of the
|
||||
* method, then calling the {@code hashCode} method on each of the
|
||||
* two objects must produce distinct integer results. However, the
|
||||
* programmer should be aware that producing distinct integer results
|
||||
* for unequal objects may improve the performance of hashtables.
|
||||
* for unequal objects may improve the performance of hash tables.
|
||||
* </ul>
|
||||
* <p>
|
||||
* As much as is reasonably practical, the hashCode method defined by
|
||||
* class <tt>Object</tt> does return distinct integers for distinct
|
||||
* class {@code Object} does return distinct integers for distinct
|
||||
* objects. (This is typically implemented by converting the internal
|
||||
* address of the object into an integer, but this implementation
|
||||
* technique is not required by the
|
||||
@ -97,55 +97,55 @@ public class Object {
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
* @see java.util.Hashtable
|
||||
* @see java.lang.System#identityHashCode
|
||||
*/
|
||||
public native int hashCode();
|
||||
|
||||
/**
|
||||
* Indicates whether some other object is "equal to" this one.
|
||||
* <p>
|
||||
* The <code>equals</code> method implements an equivalence relation
|
||||
* The {@code equals} method implements an equivalence relation
|
||||
* on non-null object references:
|
||||
* <ul>
|
||||
* <li>It is <i>reflexive</i>: for any non-null reference value
|
||||
* <code>x</code>, <code>x.equals(x)</code> should return
|
||||
* <code>true</code>.
|
||||
* {@code x}, {@code x.equals(x)} should return
|
||||
* {@code true}.
|
||||
* <li>It is <i>symmetric</i>: for any non-null reference values
|
||||
* <code>x</code> and <code>y</code>, <code>x.equals(y)</code>
|
||||
* should return <code>true</code> if and only if
|
||||
* <code>y.equals(x)</code> returns <code>true</code>.
|
||||
* {@code x} and {@code y}, {@code x.equals(y)}
|
||||
* should return {@code true} if and only if
|
||||
* {@code y.equals(x)} returns {@code true}.
|
||||
* <li>It is <i>transitive</i>: for any non-null reference values
|
||||
* <code>x</code>, <code>y</code>, and <code>z</code>, if
|
||||
* <code>x.equals(y)</code> returns <code>true</code> and
|
||||
* <code>y.equals(z)</code> returns <code>true</code>, then
|
||||
* <code>x.equals(z)</code> should return <code>true</code>.
|
||||
* {@code x}, {@code y}, and {@code z}, if
|
||||
* {@code x.equals(y)} returns {@code true} and
|
||||
* {@code y.equals(z)} returns {@code true}, then
|
||||
* {@code x.equals(z)} should return {@code true}.
|
||||
* <li>It is <i>consistent</i>: for any non-null reference values
|
||||
* <code>x</code> and <code>y</code>, multiple invocations of
|
||||
* <tt>x.equals(y)</tt> consistently return <code>true</code>
|
||||
* or consistently return <code>false</code>, provided no
|
||||
* information used in <code>equals</code> comparisons on the
|
||||
* {@code x} and {@code y}, multiple invocations of
|
||||
* {@code x.equals(y)} consistently return {@code true}
|
||||
* or consistently return {@code false}, provided no
|
||||
* information used in {@code equals} comparisons on the
|
||||
* objects is modified.
|
||||
* <li>For any non-null reference value <code>x</code>,
|
||||
* <code>x.equals(null)</code> should return <code>false</code>.
|
||||
* <li>For any non-null reference value {@code x},
|
||||
* {@code x.equals(null)} should return {@code false}.
|
||||
* </ul>
|
||||
* <p>
|
||||
* The <tt>equals</tt> method for class <code>Object</code> implements
|
||||
* The {@code equals} method for class {@code Object} implements
|
||||
* the most discriminating possible equivalence relation on objects;
|
||||
* that is, for any non-null reference values <code>x</code> and
|
||||
* <code>y</code>, this method returns <code>true</code> if and only
|
||||
* if <code>x</code> and <code>y</code> refer to the same object
|
||||
* (<code>x == y</code> has the value <code>true</code>).
|
||||
* that is, for any non-null reference values {@code x} and
|
||||
* {@code y}, this method returns {@code true} if and only
|
||||
* if {@code x} and {@code y} refer to the same object
|
||||
* ({@code x == y} has the value {@code true}).
|
||||
* <p>
|
||||
* Note that it is generally necessary to override the <tt>hashCode</tt>
|
||||
* Note that it is generally necessary to override the {@code hashCode}
|
||||
* method whenever this method is overridden, so as to maintain the
|
||||
* general contract for the <tt>hashCode</tt> method, which states
|
||||
* general contract for the {@code hashCode} method, which states
|
||||
* that equal objects must have equal hash codes.
|
||||
*
|
||||
* @param obj the reference object with which to compare.
|
||||
* @return <code>true</code> if this object is the same as the obj
|
||||
* argument; <code>false</code> otherwise.
|
||||
* @return {@code true} if this object is the same as the obj
|
||||
* argument; {@code false} otherwise.
|
||||
* @see #hashCode()
|
||||
* @see java.util.Hashtable
|
||||
* @see java.util.HashMap
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj);
|
||||
@ -154,7 +154,7 @@ public class Object {
|
||||
/**
|
||||
* Creates and returns a copy of this object. The precise meaning
|
||||
* of "copy" may depend on the class of the object. The general
|
||||
* intent is that, for any object <tt>x</tt>, the expression:
|
||||
* intent is that, for any object {@code x}, the expression:
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* x.clone() != x</pre></blockquote>
|
||||
@ -162,49 +162,49 @@ public class Object {
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* x.clone().getClass() == x.getClass()</pre></blockquote>
|
||||
* will be <tt>true</tt>, but these are not absolute requirements.
|
||||
* will be {@code true}, but these are not absolute requirements.
|
||||
* While it is typically the case that:
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* x.clone().equals(x)</pre></blockquote>
|
||||
* will be <tt>true</tt>, this is not an absolute requirement.
|
||||
* will be {@code true}, this is not an absolute requirement.
|
||||
* <p>
|
||||
* By convention, the returned object should be obtained by calling
|
||||
* <tt>super.clone</tt>. If a class and all of its superclasses (except
|
||||
* <tt>Object</tt>) obey this convention, it will be the case that
|
||||
* <tt>x.clone().getClass() == x.getClass()</tt>.
|
||||
* {@code super.clone}. If a class and all of its superclasses (except
|
||||
* {@code Object}) obey this convention, it will be the case that
|
||||
* {@code x.clone().getClass() == x.getClass()}.
|
||||
* <p>
|
||||
* By convention, the object returned by this method should be independent
|
||||
* of this object (which is being cloned). To achieve this independence,
|
||||
* it may be necessary to modify one or more fields of the object returned
|
||||
* by <tt>super.clone</tt> before returning it. Typically, this means
|
||||
* by {@code super.clone} before returning it. Typically, this means
|
||||
* copying any mutable objects that comprise the internal "deep structure"
|
||||
* of the object being cloned and replacing the references to these
|
||||
* objects with references to the copies. If a class contains only
|
||||
* primitive fields or references to immutable objects, then it is usually
|
||||
* the case that no fields in the object returned by <tt>super.clone</tt>
|
||||
* the case that no fields in the object returned by {@code super.clone}
|
||||
* need to be modified.
|
||||
* <p>
|
||||
* The method <tt>clone</tt> for class <tt>Object</tt> performs a
|
||||
* The method {@code clone} for class {@code Object} performs a
|
||||
* specific cloning operation. First, if the class of this object does
|
||||
* not implement the interface <tt>Cloneable</tt>, then a
|
||||
* <tt>CloneNotSupportedException</tt> is thrown. Note that all arrays
|
||||
* are considered to implement the interface <tt>Cloneable</tt>.
|
||||
* not implement the interface {@code Cloneable}, then a
|
||||
* {@code CloneNotSupportedException} is thrown. Note that all arrays
|
||||
* are considered to implement the interface {@code Cloneable}.
|
||||
* Otherwise, this method creates a new instance of the class of this
|
||||
* object and initializes all its fields with exactly the contents of
|
||||
* the corresponding fields of this object, as if by assignment; the
|
||||
* contents of the fields are not themselves cloned. Thus, this method
|
||||
* performs a "shallow copy" of this object, not a "deep copy" operation.
|
||||
* <p>
|
||||
* The class <tt>Object</tt> does not itself implement the interface
|
||||
* <tt>Cloneable</tt>, so calling the <tt>clone</tt> method on an object
|
||||
* whose class is <tt>Object</tt> will result in throwing an
|
||||
* The class {@code Object} does not itself implement the interface
|
||||
* {@code Cloneable}, so calling the {@code clone} method on an object
|
||||
* whose class is {@code Object} will result in throwing an
|
||||
* exception at run time.
|
||||
*
|
||||
* @return a clone of this instance.
|
||||
* @exception CloneNotSupportedException if the object's class does not
|
||||
* support the <code>Cloneable</code> interface. Subclasses
|
||||
* that override the <code>clone</code> method can also
|
||||
* support the {@code Cloneable} interface. Subclasses
|
||||
* that override the {@code clone} method can also
|
||||
* throw this exception to indicate that an instance cannot
|
||||
* be cloned.
|
||||
* @see java.lang.Cloneable
|
||||
@ -213,15 +213,15 @@ public class Object {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object. In general, the
|
||||
* <code>toString</code> method returns a string that
|
||||
* {@code toString} method returns a string that
|
||||
* "textually represents" this object. The result should
|
||||
* be a concise but informative representation that is easy for a
|
||||
* person to read.
|
||||
* It is recommended that all subclasses override this method.
|
||||
* <p>
|
||||
* The <code>toString</code> method for class <code>Object</code>
|
||||
* The {@code toString} method for class {@code Object}
|
||||
* returns a string consisting of the name of the class of which the
|
||||
* object is an instance, the at-sign character `<code>@</code>', and
|
||||
* object is an instance, the at-sign character `{@code @}', and
|
||||
* the unsigned hexadecimal representation of the hash code of the
|
||||
* object. In other words, this method returns a string equal to the
|
||||
* value of:
|
||||
@ -241,7 +241,7 @@ public class Object {
|
||||
* monitor. If any threads are waiting on this object, one of them
|
||||
* is chosen to be awakened. The choice is arbitrary and occurs at
|
||||
* the discretion of the implementation. A thread waits on an object's
|
||||
* monitor by calling one of the <code>wait</code> methods.
|
||||
* monitor by calling one of the {@code wait} methods.
|
||||
* <p>
|
||||
* The awakened thread will not be able to proceed until the current
|
||||
* thread relinquishes the lock on this object. The awakened thread will
|
||||
@ -255,9 +255,9 @@ public class Object {
|
||||
* object's monitor in one of three ways:
|
||||
* <ul>
|
||||
* <li>By executing a synchronized instance method of that object.
|
||||
* <li>By executing the body of a <code>synchronized</code> statement
|
||||
* <li>By executing the body of a {@code synchronized} statement
|
||||
* that synchronizes on the object.
|
||||
* <li>For objects of type <code>Class,</code> by executing a
|
||||
* <li>For objects of type {@code Class,} by executing a
|
||||
* synchronized static method of that class.
|
||||
* </ul>
|
||||
* <p>
|
||||
@ -273,7 +273,7 @@ public class Object {
|
||||
/**
|
||||
* Wakes up all threads that are waiting on this object's monitor. A
|
||||
* thread waits on an object's monitor by calling one of the
|
||||
* <code>wait</code> methods.
|
||||
* {@code wait} methods.
|
||||
* <p>
|
||||
* The awakened threads will not be able to proceed until the current
|
||||
* thread relinquishes the lock on this object. The awakened threads
|
||||
@ -283,7 +283,7 @@ public class Object {
|
||||
* being the next thread to lock this object.
|
||||
* <p>
|
||||
* This method should only be called by a thread that is the owner
|
||||
* of this object's monitor. See the <code>notify</code> method for a
|
||||
* of this object's monitor. See the {@code notify} method for a
|
||||
* description of the ways in which a thread can become the owner of
|
||||
* a monitor.
|
||||
*
|
||||
@ -308,15 +308,15 @@ public class Object {
|
||||
* becomes disabled for thread scheduling purposes and lies dormant
|
||||
* until one of four things happens:
|
||||
* <ul>
|
||||
* <li>Some other thread invokes the <tt>notify</tt> method for this
|
||||
* <li>Some other thread invokes the {@code notify} method for this
|
||||
* object and thread <var>T</var> happens to be arbitrarily chosen as
|
||||
* the thread to be awakened.
|
||||
* <li>Some other thread invokes the <tt>notifyAll</tt> method for this
|
||||
* <li>Some other thread invokes the {@code notifyAll} method for this
|
||||
* object.
|
||||
* <li>Some other thread {@linkplain Thread#interrupt() interrupts}
|
||||
* thread <var>T</var>.
|
||||
* <li>The specified amount of real time has elapsed, more or less. If
|
||||
* <tt>timeout</tt> is zero, however, then real time is not taken into
|
||||
* {@code timeout} is zero, however, then real time is not taken into
|
||||
* consideration and the thread simply waits until notified.
|
||||
* </ul>
|
||||
* The thread <var>T</var> is then removed from the wait set for this
|
||||
@ -324,11 +324,11 @@ public class Object {
|
||||
* usual manner with other threads for the right to synchronize on the
|
||||
* object; once it has gained control of the object, all its
|
||||
* synchronization claims on the object are restored to the status quo
|
||||
* ante - that is, to the situation as of the time that the <tt>wait</tt>
|
||||
* ante - that is, to the situation as of the time that the {@code wait}
|
||||
* method was invoked. Thread <var>T</var> then returns from the
|
||||
* invocation of the <tt>wait</tt> method. Thus, on return from the
|
||||
* <tt>wait</tt> method, the synchronization state of the object and of
|
||||
* thread <tt>T</tt> is exactly as it was when the <tt>wait</tt> method
|
||||
* invocation of the {@code wait} method. Thus, on return from the
|
||||
* {@code wait} method, the synchronization state of the object and of
|
||||
* thread {@code T} is exactly as it was when the {@code wait} method
|
||||
* was invoked.
|
||||
* <p>
|
||||
* A thread can also wake up without being notified, interrupted, or
|
||||
@ -351,18 +351,18 @@ public class Object {
|
||||
*
|
||||
* <p>If the current thread is {@linkplain java.lang.Thread#interrupt()
|
||||
* interrupted} by any thread before or while it is waiting, then an
|
||||
* <tt>InterruptedException</tt> is thrown. This exception is not
|
||||
* {@code InterruptedException} is thrown. This exception is not
|
||||
* thrown until the lock status of this object has been restored as
|
||||
* described above.
|
||||
*
|
||||
* <p>
|
||||
* Note that the <tt>wait</tt> method, as it places the current thread
|
||||
* Note that the {@code wait} method, as it places the current thread
|
||||
* into the wait set for this object, unlocks only this object; any
|
||||
* other objects on which the current thread may be synchronized remain
|
||||
* locked while the thread waits.
|
||||
* <p>
|
||||
* This method should only be called by a thread that is the owner
|
||||
* of this object's monitor. See the <code>notify</code> method for a
|
||||
* of this object's monitor. See the {@code notify} method for a
|
||||
* description of the ways in which a thread can become the owner of
|
||||
* a monitor.
|
||||
*
|
||||
@ -388,7 +388,7 @@ public class Object {
|
||||
* some other thread interrupts the current thread, or a certain
|
||||
* amount of real time has elapsed.
|
||||
* <p>
|
||||
* This method is similar to the <code>wait</code> method of one
|
||||
* This method is similar to the {@code wait} method of one
|
||||
* argument, but it allows finer control over the amount of time to
|
||||
* wait for a notification before giving up. The amount of real time,
|
||||
* measured in nanoseconds, is given by:
|
||||
@ -398,17 +398,17 @@ public class Object {
|
||||
* <p>
|
||||
* In all other respects, this method does the same thing as the
|
||||
* method {@link #wait(long)} of one argument. In particular,
|
||||
* <tt>wait(0, 0)</tt> means the same thing as <tt>wait(0)</tt>.
|
||||
* {@code wait(0, 0)} means the same thing as {@code wait(0)}.
|
||||
* <p>
|
||||
* The current thread must own this object's monitor. The thread
|
||||
* releases ownership of this monitor and waits until either of the
|
||||
* following two conditions has occurred:
|
||||
* <ul>
|
||||
* <li>Another thread notifies threads waiting on this object's monitor
|
||||
* to wake up either through a call to the <code>notify</code> method
|
||||
* or the <code>notifyAll</code> method.
|
||||
* <li>The timeout period, specified by <code>timeout</code>
|
||||
* milliseconds plus <code>nanos</code> nanoseconds arguments, has
|
||||
* to wake up either through a call to the {@code notify} method
|
||||
* or the {@code notifyAll} method.
|
||||
* <li>The timeout period, specified by {@code timeout}
|
||||
* milliseconds plus {@code nanos} nanoseconds arguments, has
|
||||
* elapsed.
|
||||
* </ul>
|
||||
* <p>
|
||||
@ -425,7 +425,7 @@ public class Object {
|
||||
* }
|
||||
* </pre>
|
||||
* This method should only be called by a thread that is the owner
|
||||
* of this object's monitor. See the <code>notify</code> method for a
|
||||
* of this object's monitor. See the {@code notify} method for a
|
||||
* description of the ways in which a thread can become the owner of
|
||||
* a monitor.
|
||||
*
|
||||
@ -465,13 +465,13 @@ public class Object {
|
||||
* {@link java.lang.Object#notify()} method or the
|
||||
* {@link java.lang.Object#notifyAll()} method for this object.
|
||||
* In other words, this method behaves exactly as if it simply
|
||||
* performs the call <tt>wait(0)</tt>.
|
||||
* performs the call {@code wait(0)}.
|
||||
* <p>
|
||||
* The current thread must own this object's monitor. The thread
|
||||
* releases ownership of this monitor and waits until another thread
|
||||
* notifies threads waiting on this object's monitor to wake up
|
||||
* either through a call to the <code>notify</code> method or the
|
||||
* <code>notifyAll</code> method. The thread then waits until it can
|
||||
* either through a call to the {@code notify} method or the
|
||||
* {@code notifyAll} method. The thread then waits until it can
|
||||
* re-obtain ownership of the monitor and resumes execution.
|
||||
* <p>
|
||||
* As in the one argument version, interrupts and spurious wakeups are
|
||||
@ -484,7 +484,7 @@ public class Object {
|
||||
* }
|
||||
* </pre>
|
||||
* This method should only be called by a thread that is the owner
|
||||
* of this object's monitor. See the <code>notify</code> method for a
|
||||
* of this object's monitor. See the {@code notify} method for a
|
||||
* description of the ways in which a thread can become the owner of
|
||||
* a monitor.
|
||||
*
|
||||
@ -505,49 +505,49 @@ public class Object {
|
||||
/**
|
||||
* Called by the garbage collector on an object when garbage collection
|
||||
* determines that there are no more references to the object.
|
||||
* A subclass overrides the <code>finalize</code> method to dispose of
|
||||
* A subclass overrides the {@code finalize} method to dispose of
|
||||
* system resources or to perform other cleanup.
|
||||
* <p>
|
||||
* The general contract of <tt>finalize</tt> is that it is invoked
|
||||
* The general contract of {@code finalize} is that it is invoked
|
||||
* if and when the Java<font size="-2"><sup>TM</sup></font> virtual
|
||||
* machine has determined that there is no longer any
|
||||
* means by which this object can be accessed by any thread that has
|
||||
* not yet died, except as a result of an action taken by the
|
||||
* finalization of some other object or class which is ready to be
|
||||
* finalized. The <tt>finalize</tt> method may take any action, including
|
||||
* finalized. The {@code finalize} method may take any action, including
|
||||
* making this object available again to other threads; the usual purpose
|
||||
* of <tt>finalize</tt>, however, is to perform cleanup actions before
|
||||
* of {@code finalize}, however, is to perform cleanup actions before
|
||||
* the object is irrevocably discarded. For example, the finalize method
|
||||
* for an object that represents an input/output connection might perform
|
||||
* explicit I/O transactions to break the connection before the object is
|
||||
* permanently discarded.
|
||||
* <p>
|
||||
* The <tt>finalize</tt> method of class <tt>Object</tt> performs no
|
||||
* The {@code finalize} method of class {@code Object} performs no
|
||||
* special action; it simply returns normally. Subclasses of
|
||||
* <tt>Object</tt> may override this definition.
|
||||
* {@code Object} may override this definition.
|
||||
* <p>
|
||||
* The Java programming language does not guarantee which thread will
|
||||
* invoke the <tt>finalize</tt> method for any given object. It is
|
||||
* invoke the {@code finalize} method for any given object. It is
|
||||
* guaranteed, however, that the thread that invokes finalize will not
|
||||
* be holding any user-visible synchronization locks when finalize is
|
||||
* invoked. If an uncaught exception is thrown by the finalize method,
|
||||
* the exception is ignored and finalization of that object terminates.
|
||||
* <p>
|
||||
* After the <tt>finalize</tt> method has been invoked for an object, no
|
||||
* After the {@code finalize} method has been invoked for an object, no
|
||||
* further action is taken until the Java virtual machine has again
|
||||
* determined that there is no longer any means by which this object can
|
||||
* be accessed by any thread that has not yet died, including possible
|
||||
* actions by other objects or classes which are ready to be finalized,
|
||||
* at which point the object may be discarded.
|
||||
* <p>
|
||||
* The <tt>finalize</tt> method is never invoked more than once by a Java
|
||||
* The {@code finalize} method is never invoked more than once by a Java
|
||||
* virtual machine for any given object.
|
||||
* <p>
|
||||
* Any exception thrown by the <code>finalize</code> method causes
|
||||
* Any exception thrown by the {@code finalize} method causes
|
||||
* the finalization of this object to be halted, but is otherwise
|
||||
* ignored.
|
||||
*
|
||||
* @throws Throwable the <code>Exception</code> raised by this method
|
||||
* @throws Throwable the {@code Exception} raised by this method
|
||||
*/
|
||||
protected void finalize() throws Throwable { }
|
||||
}
|
||||
|
@ -100,6 +100,13 @@ import java.util.StringTokenizer;
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>closeClassLoader</td>
|
||||
* <td>Closing of a ClassLoader</td>
|
||||
* <td>Granting this permission allows code to close any URLClassLoader
|
||||
* that it has a reference to.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>setSecurityManager</td>
|
||||
* <td>Setting of the security manager (possibly replacing an existing one)
|
||||
* </td>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2009 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,6 +31,10 @@ package java.lang.annotation;
|
||||
* an annotation type. Also note that this interface does not itself
|
||||
* define an annotation type.
|
||||
*
|
||||
* More information about annotation types can be found in <i>The
|
||||
* Java™ Language Specification, Third Edition</i>, <a
|
||||
* href="http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.6">§9.6</a>.
|
||||
*
|
||||
* @author Josh Bloch
|
||||
* @since 1.5
|
||||
*/
|
||||
|
@ -1,3 +1,28 @@
|
||||
<!--
|
||||
Copyright 2003-2006 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
|
@ -107,8 +107,9 @@ import java.io.IOException;
|
||||
* </ul>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p>The implementation conforms to RFC 2965, section 3.3.
|
||||
* <p>The implementation conforms to <a href="http://www.ietf.org/rfc/rfc2965.txt">RFC 2965</a>, section 3.3.
|
||||
*
|
||||
* @see CookiePolicy
|
||||
* @author Edward Wang
|
||||
* @since 1.6
|
||||
*/
|
||||
|
@ -33,6 +33,7 @@ import java.util.TimeZone;
|
||||
import java.util.Date;
|
||||
|
||||
import java.lang.NullPointerException; // for javadoc
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* An HttpCookie object represents an http cookie, which carries state
|
||||
@ -1058,8 +1059,7 @@ public final class HttpCookie implements Cloneable {
|
||||
if (assignor != null) {
|
||||
assignor.assign(cookie, attrName, attrValue);
|
||||
} else {
|
||||
// must be an error
|
||||
throw new IllegalArgumentException("Illegal cookie attribute");
|
||||
// Ignore the attribute as per RFC 2965
|
||||
}
|
||||
}
|
||||
|
||||
@ -1097,7 +1097,7 @@ public final class HttpCookie implements Cloneable {
|
||||
static {
|
||||
cDateFormats = new SimpleDateFormat[COOKIE_DATE_FORMATS.length];
|
||||
for (int i = 0; i < COOKIE_DATE_FORMATS.length; i++) {
|
||||
cDateFormats[i] = new SimpleDateFormat(COOKIE_DATE_FORMATS[i]);
|
||||
cDateFormats[i] = new SimpleDateFormat(COOKIE_DATE_FORMATS[i], Locale.US);
|
||||
cDateFormats[i].setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
}
|
||||
|
@ -31,10 +31,12 @@ import java.io.File;
|
||||
import java.io.FilePermission;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Closeable;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.jar.Manifest;
|
||||
@ -70,7 +72,7 @@ import sun.security.util.SecurityConstants;
|
||||
* @author David Connelly
|
||||
* @since 1.2
|
||||
*/
|
||||
public class URLClassLoader extends SecureClassLoader {
|
||||
public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
/* The search path for classes and resources */
|
||||
URLClassPath ucp;
|
||||
|
||||
@ -85,13 +87,13 @@ public class URLClassLoader extends SecureClassLoader {
|
||||
* to refer to a JAR file which will be downloaded and opened as needed.
|
||||
*
|
||||
* <p>If there is a security manager, this method first
|
||||
* calls the security manager's <code>checkCreateClassLoader</code> method
|
||||
* calls the security manager's {@code checkCreateClassLoader} method
|
||||
* to ensure creation of a class loader is allowed.
|
||||
*
|
||||
* @param urls the URLs from which to load classes and resources
|
||||
* @param parent the parent class loader for delegation
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkCreateClassLoader</code> method doesn't allow
|
||||
* {@code checkCreateClassLoader} method doesn't allow
|
||||
* creation of a class loader.
|
||||
* @see SecurityManager#checkCreateClassLoader
|
||||
*/
|
||||
@ -169,12 +171,65 @@ public class URLClassLoader extends SecureClassLoader {
|
||||
acc = AccessController.getContext();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closes this URLClassLoader, so that it can no longer be used to load
|
||||
* new classes or resources that are defined by this loader.
|
||||
* Classes and resources defined by any of this loader's parents in the
|
||||
* delegation hierarchy are still accessible. Also, any classes or resources
|
||||
* that are already loaded, are still accessible.
|
||||
* <p>
|
||||
* In the case of jar: and file: URLs, it also closes any class files,
|
||||
* or JAR files that were opened by it. If another thread is loading a
|
||||
* class when the {@code close} method is invoked, then the result of
|
||||
* that load is undefined.
|
||||
* <p>
|
||||
* The method makes a best effort attempt to close all opened files,
|
||||
* by catching {@link IOException}s internally. Unchecked exceptions
|
||||
* and errors are not caught. Calling close on an already closed
|
||||
* loader has no effect.
|
||||
* <p>
|
||||
* @throws IOException if closing any file opened by this class loader
|
||||
* resulted in an IOException. Any such exceptions are caught, and a
|
||||
* single IOException is thrown after the last file has been closed.
|
||||
* If only one exception was thrown, it will be set as the <i>cause</i>
|
||||
* of this IOException.
|
||||
*
|
||||
* @throws SecurityException if a security manager is set, and it denies
|
||||
* {@link RuntimePermission}<tt>("closeClassLoader")</tt>
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPermission(new RuntimePermission("closeClassLoader"));
|
||||
}
|
||||
List<IOException> errors = ucp.closeLoaders();
|
||||
if (errors.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (errors.size() == 1) {
|
||||
throw new IOException (
|
||||
"Error closing URLClassLoader resource",
|
||||
errors.get(0)
|
||||
);
|
||||
}
|
||||
// Several exceptions. So, just combine the error messages
|
||||
String errormsg = "Error closing resources: ";
|
||||
for (IOException error: errors) {
|
||||
errormsg = errormsg + "[" + error.toString() + "] ";
|
||||
}
|
||||
throw new IOException (errormsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the specified URL to the list of URLs to search for
|
||||
* classes and resources.
|
||||
* <p>
|
||||
* If the URL specified is <code>null</code> or is already in the
|
||||
* list of URLs, then invoking this method has no effect.
|
||||
* list of URLs, or if this loader is closed, then invoking this
|
||||
* method has no effect.
|
||||
*
|
||||
* @param url the URL to be added to the search path of URLs
|
||||
*/
|
||||
@ -199,7 +254,8 @@ public class URLClassLoader extends SecureClassLoader {
|
||||
*
|
||||
* @param name the name of the class
|
||||
* @return the resulting class
|
||||
* @exception ClassNotFoundException if the class could not be found
|
||||
* @exception ClassNotFoundException if the class could not be found,
|
||||
* or if the loader is closed.
|
||||
*/
|
||||
protected Class<?> findClass(final String name)
|
||||
throws ClassNotFoundException
|
||||
@ -370,7 +426,7 @@ public class URLClassLoader extends SecureClassLoader {
|
||||
*
|
||||
* @param name the name of the resource
|
||||
* @return a <code>URL</code> for the resource, or <code>null</code>
|
||||
* if the resource could not be found.
|
||||
* if the resource could not be found, or if the loader is closed.
|
||||
*/
|
||||
public URL findResource(final String name) {
|
||||
/*
|
||||
@ -393,6 +449,7 @@ public class URLClassLoader extends SecureClassLoader {
|
||||
* @param name the resource name
|
||||
* @exception IOException if an I/O exception occurs
|
||||
* @return an <code>Enumeration</code> of <code>URL</code>s
|
||||
* If the loader is closed, the Enumeration will be empty.
|
||||
*/
|
||||
public Enumeration<URL> findResources(final String name)
|
||||
throws IOException
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,7 @@
|
||||
package java.util.logging;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.security.*;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@ -165,10 +166,11 @@ public class Logger {
|
||||
private static final int offValue = Level.OFF.intValue();
|
||||
private LogManager manager;
|
||||
private String name;
|
||||
private ArrayList<Handler> handlers;
|
||||
private final CopyOnWriteArrayList<Handler> handlers =
|
||||
new CopyOnWriteArrayList<Handler>();
|
||||
private String resourceBundleName;
|
||||
private boolean useParentHandlers = true;
|
||||
private Filter filter;
|
||||
private volatile boolean useParentHandlers = true;
|
||||
private volatile Filter filter;
|
||||
private boolean anonymous;
|
||||
|
||||
private ResourceBundle catalog; // Cached resource bundle
|
||||
@ -180,9 +182,9 @@ public class Logger {
|
||||
private static Object treeLock = new Object();
|
||||
// We keep weak references from parents to children, but strong
|
||||
// references from children to parents.
|
||||
private Logger parent; // our nearest parent.
|
||||
private volatile Logger parent; // our nearest parent.
|
||||
private ArrayList<WeakReference<Logger>> kids; // WeakReferences to loggers that have us as parent
|
||||
private Level levelObject;
|
||||
private volatile Level levelObject;
|
||||
private volatile int levelValue; // current effective level value
|
||||
|
||||
/**
|
||||
@ -438,7 +440,7 @@ public class Logger {
|
||||
* @exception SecurityException if a security manager exists and if
|
||||
* the caller does not have LoggingPermission("control").
|
||||
*/
|
||||
public synchronized void setFilter(Filter newFilter) throws SecurityException {
|
||||
public void setFilter(Filter newFilter) throws SecurityException {
|
||||
checkAccess();
|
||||
filter = newFilter;
|
||||
}
|
||||
@ -448,7 +450,7 @@ public class Logger {
|
||||
*
|
||||
* @return a filter object (may be null)
|
||||
*/
|
||||
public synchronized Filter getFilter() {
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@ -465,10 +467,9 @@ public class Logger {
|
||||
if (record.getLevel().intValue() < levelValue || levelValue == offValue) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (filter != null && !filter.isLoggable(record)) {
|
||||
return;
|
||||
}
|
||||
Filter theFilter = filter;
|
||||
if (theFilter != null && !theFilter.isLoggable(record)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Post the LogRecord to all our Handlers, and then to
|
||||
@ -476,12 +477,8 @@ public class Logger {
|
||||
|
||||
Logger logger = this;
|
||||
while (logger != null) {
|
||||
Handler targets[] = logger.getHandlers();
|
||||
|
||||
if (targets != null) {
|
||||
for (int i = 0; i < targets.length; i++) {
|
||||
targets[i].publish(record);
|
||||
}
|
||||
for (Handler handler : logger.handlers) {
|
||||
handler.publish(record);
|
||||
}
|
||||
|
||||
if (!logger.getUseParentHandlers()) {
|
||||
@ -1182,13 +1179,10 @@ public class Logger {
|
||||
* @exception SecurityException if a security manager exists and if
|
||||
* the caller does not have LoggingPermission("control").
|
||||
*/
|
||||
public synchronized void addHandler(Handler handler) throws SecurityException {
|
||||
public void addHandler(Handler handler) throws SecurityException {
|
||||
// Check for null handler
|
||||
handler.getClass();
|
||||
checkAccess();
|
||||
if (handlers == null) {
|
||||
handlers = new ArrayList<Handler>();
|
||||
}
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
||||
@ -1201,14 +1195,11 @@ public class Logger {
|
||||
* @exception SecurityException if a security manager exists and if
|
||||
* the caller does not have LoggingPermission("control").
|
||||
*/
|
||||
public synchronized void removeHandler(Handler handler) throws SecurityException {
|
||||
public void removeHandler(Handler handler) throws SecurityException {
|
||||
checkAccess();
|
||||
if (handler == null) {
|
||||
return;
|
||||
}
|
||||
if (handlers == null) {
|
||||
return;
|
||||
}
|
||||
handlers.remove(handler);
|
||||
}
|
||||
|
||||
@ -1217,11 +1208,8 @@ public class Logger {
|
||||
* <p>
|
||||
* @return an array of all registered Handlers
|
||||
*/
|
||||
public synchronized Handler[] getHandlers() {
|
||||
if (handlers == null) {
|
||||
return emptyHandlers;
|
||||
}
|
||||
return handlers.toArray(new Handler[handlers.size()]);
|
||||
public Handler[] getHandlers() {
|
||||
return handlers.toArray(emptyHandlers);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1235,7 +1223,7 @@ public class Logger {
|
||||
* @exception SecurityException if a security manager exists and if
|
||||
* the caller does not have LoggingPermission("control").
|
||||
*/
|
||||
public synchronized void setUseParentHandlers(boolean useParentHandlers) {
|
||||
public void setUseParentHandlers(boolean useParentHandlers) {
|
||||
checkAccess();
|
||||
this.useParentHandlers = useParentHandlers;
|
||||
}
|
||||
@ -1246,7 +1234,7 @@ public class Logger {
|
||||
*
|
||||
* @return true if output is to be sent to the logger's parent
|
||||
*/
|
||||
public synchronized boolean getUseParentHandlers() {
|
||||
public boolean getUseParentHandlers() {
|
||||
return useParentHandlers;
|
||||
}
|
||||
|
||||
@ -1354,9 +1342,12 @@ public class Logger {
|
||||
* @return nearest existing parent Logger
|
||||
*/
|
||||
public Logger getParent() {
|
||||
synchronized (treeLock) {
|
||||
return parent;
|
||||
}
|
||||
// Note: this used to be synchronized on treeLock. However, this only
|
||||
// provided memory semantics, as there was no guarantee that the caller
|
||||
// would synchronize on treeLock (in fact, there is no way for external
|
||||
// callers to so synchronize). Therefore, we have made parent volatile
|
||||
// instead.
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.plaf.RootPaneUI;
|
||||
import java.util.Vector;
|
||||
import java.io.Serializable;
|
||||
import javax.swing.border.*;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
|
||||
|
||||
@ -688,6 +689,9 @@ public class JRootPane extends JComponent implements Accessible {
|
||||
throw new NullPointerException("glassPane cannot be set to null.");
|
||||
}
|
||||
|
||||
AWTAccessor.getComponentAccessor().setMixingCutoutShape(glass,
|
||||
new Rectangle());
|
||||
|
||||
boolean visible = false;
|
||||
if (glassPane != null && glassPane.getParent() == this) {
|
||||
this.remove(glassPane);
|
||||
|
77
jdk/src/share/classes/sun/awt/AWTAccessor.java
Normal file
77
jdk/src/share/classes/sun/awt/AWTAccessor.java
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2009 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.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.*;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/** The AWTAccessor utility class.
|
||||
* The main purpose of this class is to enable accessing
|
||||
* private and package-private fields of classes from
|
||||
* different classes/packages. See sun.misc.SharedSecretes
|
||||
* for another example.
|
||||
*/
|
||||
public final class AWTAccessor {
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
|
||||
/** We don't need any objects of this class.
|
||||
* It's rather a collection of static methods
|
||||
* and interfaces.
|
||||
*/
|
||||
private AWTAccessor() {
|
||||
}
|
||||
|
||||
/** An accessor for the java.awt.Component class.
|
||||
*/
|
||||
public interface ComponentAccessor {
|
||||
// See 6797587
|
||||
// Also see: 6776743, 6768307, and 6768332.
|
||||
/**
|
||||
* Sets the shape of a lw component to cut out from hw components.
|
||||
*/
|
||||
void setMixingCutoutShape(Component comp, Shape shape);
|
||||
}
|
||||
|
||||
/* The java.awt.Component class accessor object.
|
||||
*/
|
||||
private static ComponentAccessor componentAccessor;
|
||||
|
||||
/** Set an accessor object for the java.awt.Component class.
|
||||
*/
|
||||
public static void setComponentAccessor(ComponentAccessor ca) {
|
||||
componentAccessor = ca;
|
||||
}
|
||||
|
||||
/** Retrieve the accessor object for the java.awt.Window class.
|
||||
*/
|
||||
public static ComponentAccessor getComponentAccessor() {
|
||||
if (componentAccessor == null) {
|
||||
unsafe.ensureClassInitialized(Component.class);
|
||||
}
|
||||
|
||||
return componentAccessor;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2000-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
|
||||
@ -456,6 +456,10 @@ public class HeadlessToolkit extends Toolkit
|
||||
return tk.getAWTEventListeners();
|
||||
}
|
||||
|
||||
public AWTEventListener[] getAWTEventListeners(long eventMask) {
|
||||
return tk.getAWTEventListeners(eventMask);
|
||||
}
|
||||
|
||||
public boolean isDesktopSupported() {
|
||||
return false;
|
||||
}
|
||||
@ -464,4 +468,8 @@ public class HeadlessToolkit extends Toolkit
|
||||
throws HeadlessException{
|
||||
throw new HeadlessException();
|
||||
}
|
||||
|
||||
public boolean areExtraMouseButtonsEnabled() throws HeadlessException{
|
||||
throw new HeadlessException();
|
||||
}
|
||||
}
|
||||
|
@ -1972,6 +1972,21 @@ public abstract class SunToolkit extends Toolkit
|
||||
AWTAutoShutdown.getInstance().dumpPeers(aLog);
|
||||
}
|
||||
|
||||
private static Boolean sunAwtDisableMixing = null;
|
||||
|
||||
/**
|
||||
* Returns the value of "sun.awt.disableMixing" property. Default
|
||||
* value is {@code false}.
|
||||
*/
|
||||
public synchronized static boolean getSunAwtDisableMixing() {
|
||||
if (sunAwtDisableMixing == null) {
|
||||
sunAwtDisableMixing = Boolean.valueOf(
|
||||
AccessController.doPrivileged(
|
||||
new GetBooleanAction("sun.awt.disableMixing")));
|
||||
}
|
||||
return sunAwtDisableMixing.booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the native GTK libraries are available. The
|
||||
* default implementation returns false, but UNIXToolkit overrides this
|
||||
@ -2008,26 +2023,12 @@ class PostEventQueue {
|
||||
/*
|
||||
* Continually post pending AWTEvents to the Java EventQueue.
|
||||
*/
|
||||
public void flush() {
|
||||
if (queueHead != null) {
|
||||
EventQueueItem tempQueue;
|
||||
/*
|
||||
* We have to execute the loop inside the synchronized block
|
||||
* to ensure that the flush is completed before a new event
|
||||
* can be posted to this queue.
|
||||
*/
|
||||
synchronized (this) {
|
||||
tempQueue = queueHead;
|
||||
queueHead = queueTail = null;
|
||||
/*
|
||||
* If this PostEventQueue is flushed in parallel on two
|
||||
* different threads tempQueue will be null for one of them.
|
||||
*/
|
||||
while (tempQueue != null) {
|
||||
eventQueue.postEvent(tempQueue.event);
|
||||
tempQueue = tempQueue.next;
|
||||
}
|
||||
}
|
||||
public synchronized void flush() {
|
||||
EventQueueItem tempQueue = queueHead;
|
||||
queueHead = queueTail = null;
|
||||
while (tempQueue != null) {
|
||||
eventQueue.postEvent(tempQueue.event);
|
||||
tempQueue = tempQueue.next;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ package sun.java2d.pipe;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.RectangularShape;
|
||||
|
||||
/**
|
||||
* This class encapsulates a definition of a two dimensional region which
|
||||
@ -63,11 +64,28 @@ public class Region {
|
||||
static final int INIT_SIZE = 50;
|
||||
static final int GROW_SIZE = 50;
|
||||
|
||||
static final Region EMPTY_REGION = new Region(0, 0, 0, 0);
|
||||
static final Region WHOLE_REGION = new Region(Integer.MIN_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MAX_VALUE);
|
||||
/**
|
||||
* Immutable Region.
|
||||
*/
|
||||
private static final class ImmutableRegion extends Region {
|
||||
protected ImmutableRegion(int lox, int loy, int hix, int hiy) {
|
||||
super(lox, loy, hix, hiy);
|
||||
}
|
||||
|
||||
// Override all the methods that mutate the object
|
||||
public void appendSpans(sun.java2d.pipe.SpanIterator si) {}
|
||||
public void setOutputArea(java.awt.Rectangle r) {}
|
||||
public void setOutputAreaXYWH(int x, int y, int w, int h) {}
|
||||
public void setOutputArea(int[] box) {}
|
||||
public void setOutputAreaXYXY(int lox, int loy, int hix, int hiy) {}
|
||||
}
|
||||
|
||||
public static final Region EMPTY_REGION = new ImmutableRegion(0, 0, 0, 0);
|
||||
public static final Region WHOLE_REGION = new ImmutableRegion(
|
||||
Integer.MIN_VALUE,
|
||||
Integer.MIN_VALUE,
|
||||
Integer.MAX_VALUE,
|
||||
Integer.MAX_VALUE);
|
||||
|
||||
int lox;
|
||||
int loy;
|
||||
@ -113,7 +131,7 @@ public class Region {
|
||||
return newv;
|
||||
}
|
||||
|
||||
private Region(int lox, int loy, int hix, int hiy) {
|
||||
protected Region(int lox, int loy, int hix, int hiy) {
|
||||
this.lox = lox;
|
||||
this.loy = loy;
|
||||
this.hix = hix;
|
||||
@ -194,6 +212,13 @@ public class Region {
|
||||
public static Region getInstance(Region devBounds, boolean normalize,
|
||||
Shape s, AffineTransform at)
|
||||
{
|
||||
// Optimize for empty shapes to avoid involving the SpanIterator
|
||||
if (s instanceof RectangularShape &&
|
||||
((RectangularShape)s).isEmpty())
|
||||
{
|
||||
return EMPTY_REGION;
|
||||
}
|
||||
|
||||
int box[] = new int[4];
|
||||
ShapeSpanIterator sr = new ShapeSpanIterator(normalize);
|
||||
try {
|
||||
@ -1206,7 +1231,7 @@ public class Region {
|
||||
return false;
|
||||
}
|
||||
if (r.lox != this.lox || r.loy != this.loy ||
|
||||
r.hiy != this.hiy || r.hiy != this.hiy)
|
||||
r.hix != this.hix || r.hiy != this.hiy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -25,17 +25,7 @@
|
||||
|
||||
package sun.misc;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Stack;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarFile;
|
||||
import sun.misc.JarIndex;
|
||||
import sun.misc.InvalidJarIndexException;
|
||||
@ -52,12 +42,7 @@ import java.net.URLConnection;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.AccessControlException;
|
||||
import java.security.CodeSigner;
|
||||
@ -100,6 +85,9 @@ public class URLClassPath {
|
||||
/* The jar protocol handler to use when creating new URLs */
|
||||
private URLStreamHandler jarHandler;
|
||||
|
||||
/* Whether this URLClassLoader has been closed yet */
|
||||
private boolean closed = false;
|
||||
|
||||
/**
|
||||
* Creates a new URLClassPath for the given URLs. The URLs will be
|
||||
* searched in the order specified for classes and resources. A URL
|
||||
@ -124,6 +112,22 @@ public class URLClassPath {
|
||||
this(urls, null);
|
||||
}
|
||||
|
||||
public synchronized List<IOException> closeLoaders() {
|
||||
if (closed) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<IOException> result = new LinkedList<IOException>();
|
||||
for (Loader loader : loaders) {
|
||||
try {
|
||||
loader.close();
|
||||
} catch (IOException e) {
|
||||
result.add (e);
|
||||
}
|
||||
}
|
||||
closed = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the specified URL to the search path of directory and JAR
|
||||
* file URLs from which to load classes and resources.
|
||||
@ -293,6 +297,9 @@ public class URLClassPath {
|
||||
* if the specified index is out of range.
|
||||
*/
|
||||
private synchronized Loader getLoader(int index) {
|
||||
if (closed) {
|
||||
return null;
|
||||
}
|
||||
// Expand URL search path until the request can be satisfied
|
||||
// or the URL stack is empty.
|
||||
while (loaders.size() < index + 1) {
|
||||
@ -453,7 +460,7 @@ public class URLClassPath {
|
||||
* Inner class used to represent a loader of resources and classes
|
||||
* from a base URL.
|
||||
*/
|
||||
private static class Loader {
|
||||
private static class Loader implements Closeable {
|
||||
private final URL base;
|
||||
|
||||
/*
|
||||
@ -544,6 +551,12 @@ public class URLClassPath {
|
||||
return getResource(name, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* close this loader and release all resources
|
||||
* method overridden in sub-classes
|
||||
*/
|
||||
public void close () throws IOException {}
|
||||
|
||||
/*
|
||||
* Returns the local class path for this loader, or null if none.
|
||||
*/
|
||||
@ -562,6 +575,7 @@ public class URLClassPath {
|
||||
private MetaIndex metaIndex;
|
||||
private URLStreamHandler handler;
|
||||
private HashMap<URL, Loader> lmap;
|
||||
private boolean closed = false;
|
||||
|
||||
/*
|
||||
* Creates a new JarLoader for the specified URL referring to
|
||||
@ -604,6 +618,17 @@ public class URLClassPath {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close () throws IOException {
|
||||
// closing is synchronized at higher level
|
||||
if (!closed) {
|
||||
closed = true;
|
||||
// in case not already open.
|
||||
ensureOpen();
|
||||
jar.close();
|
||||
}
|
||||
}
|
||||
|
||||
JarFile getJarFile () {
|
||||
return jar;
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
@ -156,11 +155,7 @@ public class Config {
|
||||
configFile = loadConfigFile();
|
||||
stanzaTable = parseStanzaTable(configFile);
|
||||
} catch (IOException ioe) {
|
||||
KrbException ke = new KrbException("Could not load " +
|
||||
"configuration file " +
|
||||
ioe.getMessage());
|
||||
ke.initCause(ioe);
|
||||
throw(ke);
|
||||
// No krb5.conf, no problem. We'll use DNS etc.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1057,7 +1052,12 @@ public class Config {
|
||||
public boolean useDNS(String name) {
|
||||
String value = getDefault(name, "libdefaults");
|
||||
if (value == null) {
|
||||
return getDefaultBooleanValue("dns_fallback", "libdefaults");
|
||||
value = getDefault("dns_fallback", "libdefaults");
|
||||
if ("false".equalsIgnoreCase(value)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return value.equalsIgnoreCase("true");
|
||||
}
|
||||
@ -1079,12 +1079,39 @@ public class Config {
|
||||
|
||||
/**
|
||||
* Gets default realm.
|
||||
* @throws KrbException where no realm can be located
|
||||
* @return the default realm, always non null
|
||||
*/
|
||||
public String getDefaultRealm() throws KrbException {
|
||||
Exception cause = null;
|
||||
String realm = getDefault("default_realm", "libdefaults");
|
||||
if ((realm == null) && useDNS_Realm()) {
|
||||
// use DNS to locate Kerberos realm
|
||||
realm = getRealmFromDNS();
|
||||
try {
|
||||
realm = getRealmFromDNS();
|
||||
} catch (KrbException ke) {
|
||||
cause = ke;
|
||||
}
|
||||
}
|
||||
if (realm == null) {
|
||||
realm = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<String>() {
|
||||
@Override
|
||||
public String run() {
|
||||
String osname = System.getProperty("os.name");
|
||||
if (osname.startsWith("Windows")) {
|
||||
return System.getenv("USERDNSDOMAIN");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (realm == null) {
|
||||
KrbException ke = new KrbException("Cannot locate default realm");
|
||||
if (cause != null) {
|
||||
ke.initCause(cause);
|
||||
}
|
||||
throw ke;
|
||||
}
|
||||
return realm;
|
||||
}
|
||||
@ -1092,17 +1119,48 @@ public class Config {
|
||||
/**
|
||||
* Returns a list of KDC's with each KDC separated by a space
|
||||
*
|
||||
* @param realm the realm for which the master KDC is desired
|
||||
* @return the list of KDCs
|
||||
* @param realm the realm for which the KDC list is desired
|
||||
* @throws KrbException if there's no way to find KDC for the realm
|
||||
* @return the list of KDCs separated by a space, always non null
|
||||
*/
|
||||
public String getKDCList(String realm) throws KrbException {
|
||||
if (realm == null) {
|
||||
realm = getDefaultRealm();
|
||||
}
|
||||
Exception cause = null;
|
||||
String kdcs = getDefault("kdc", realm);
|
||||
if ((kdcs == null) && useDNS_KDC()) {
|
||||
// use DNS to locate KDC
|
||||
kdcs = getKDCFromDNS(realm);
|
||||
try {
|
||||
kdcs = getKDCFromDNS(realm);
|
||||
} catch (KrbException ke) {
|
||||
cause = ke;
|
||||
}
|
||||
}
|
||||
if (kdcs == null) {
|
||||
kdcs = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<String>() {
|
||||
@Override
|
||||
public String run() {
|
||||
String osname = System.getProperty("os.name");
|
||||
if (osname.startsWith("Windows")) {
|
||||
String logonServer = System.getenv("LOGONSERVER");
|
||||
if (logonServer != null
|
||||
&& logonServer.startsWith("\\\\")) {
|
||||
logonServer = logonServer.substring(2);
|
||||
}
|
||||
return logonServer;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (kdcs == null) {
|
||||
KrbException ke = new KrbException("Cannot locate KDC");
|
||||
if (cause != null) {
|
||||
ke.initCause(cause);
|
||||
}
|
||||
throw ke;
|
||||
}
|
||||
return kdcs;
|
||||
}
|
||||
@ -1117,7 +1175,7 @@ public class Config {
|
||||
String realm = null;
|
||||
String hostName = null;
|
||||
try {
|
||||
hostName = InetAddress.getLocalHost().getHostName();
|
||||
hostName = InetAddress.getLocalHost().getCanonicalHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
KrbException ke = new KrbException(Krb5.KRB_ERR_GENERIC,
|
||||
"Unable to locate Kerberos realm: " + e.getMessage());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2009 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
|
||||
@ -133,7 +133,7 @@ class KrbServiceLocator {
|
||||
*/
|
||||
static String[] getKerberosService(String realmName, String protocol) {
|
||||
|
||||
String dnsUrl = "dns:///_kerberos." + protocol + realmName;
|
||||
String dnsUrl = "dns:///_kerberos." + protocol + "." + realmName;
|
||||
String[] hostports = null;
|
||||
|
||||
try {
|
||||
|
@ -32,10 +32,18 @@ class WindowDimensions {
|
||||
private Insets insets;
|
||||
private boolean isClientSizeSet;
|
||||
|
||||
/**
|
||||
* If isClient is true, the bounds represent the client window area.
|
||||
* Otherwise, they represent the entire window area, with the insets included
|
||||
*/
|
||||
public WindowDimensions(int x, int y, int width, int height, boolean isClient) {
|
||||
this(new Rectangle(x, y, width, height), null, isClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* If isClient is true, the bounds represent the client window area.
|
||||
* Otherwise, they represent the entire window area, with the insets included
|
||||
*/
|
||||
public WindowDimensions(Rectangle rec, Insets ins, boolean isClient) {
|
||||
if (rec == null) {
|
||||
throw new IllegalArgumentException("Client bounds can't be null");
|
||||
@ -46,10 +54,18 @@ class WindowDimensions {
|
||||
setInsets(ins);
|
||||
}
|
||||
|
||||
/**
|
||||
* If isClient is true, the bounds represent the client window area.
|
||||
* Otherwise, they represent the entire window area, with the insets included
|
||||
*/
|
||||
public WindowDimensions(Point loc, Dimension size, Insets in, boolean isClient) {
|
||||
this(new Rectangle(loc, size), in, isClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* If isClient is true, the bounds represent the client window area.
|
||||
* Otherwise, they represent the entire window area, with the insets included
|
||||
*/
|
||||
public WindowDimensions(Rectangle bounds, boolean isClient) {
|
||||
this(bounds, null, isClient);
|
||||
}
|
||||
|
@ -979,8 +979,13 @@ public class XBaseWindow {
|
||||
*/
|
||||
public void handleButtonPressRelease(XEvent xev) {
|
||||
XButtonEvent xbe = xev.get_xbutton();
|
||||
final int buttonState = xbe.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask
|
||||
| XConstants.Button3Mask | XConstants.Button4Mask | XConstants.Button5Mask);
|
||||
int buttonState = 0;
|
||||
for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){
|
||||
// A bug in WM implementation: extra buttons doesn't have state!=0 as they should on Release message.
|
||||
if ((i != 4) && (i != 5)){
|
||||
buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
|
||||
}
|
||||
}
|
||||
switch (xev.get_type()) {
|
||||
case XConstants.ButtonPress:
|
||||
if (buttonState == 0) {
|
||||
@ -1011,19 +1016,11 @@ public class XBaseWindow {
|
||||
* Checks ButtonRelease released all Mouse buttons
|
||||
*/
|
||||
static boolean isFullRelease(int buttonState, int button) {
|
||||
switch (button) {
|
||||
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;
|
||||
if (button < 0 || button > XToolkit.getNumMouseButtons()) {
|
||||
return buttonState == 0;
|
||||
} else {
|
||||
return buttonState == XConstants.buttonsMask[button - 1];
|
||||
}
|
||||
return buttonState == 0;
|
||||
}
|
||||
|
||||
static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) {
|
||||
|
@ -1534,13 +1534,23 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
|
||||
}
|
||||
XToolkit.awtLock();
|
||||
try {
|
||||
XlibWrapper.SetRectangularShape(
|
||||
XToolkit.getDisplay(),
|
||||
getWindow(),
|
||||
shape.getLoX(), shape.getLoY(),
|
||||
shape.getHiX(), shape.getHiY(),
|
||||
(shape.isRectangular() ? null : shape)
|
||||
);
|
||||
if (shape != null) {
|
||||
XlibWrapper.SetRectangularShape(
|
||||
XToolkit.getDisplay(),
|
||||
getWindow(),
|
||||
shape.getLoX(), shape.getLoY(),
|
||||
shape.getHiX(), shape.getHiY(),
|
||||
(shape.isRectangular() ? null : shape)
|
||||
);
|
||||
} else {
|
||||
XlibWrapper.SetRectangularShape(
|
||||
XToolkit.getDisplay(),
|
||||
getWindow(),
|
||||
0, 0,
|
||||
0, 0,
|
||||
null
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
XToolkit.awtUnlock();
|
||||
}
|
||||
|
@ -197,12 +197,30 @@ final public class XConstants {
|
||||
|
||||
/* button masks. Used in same manner as Key masks above. Not to be confused
|
||||
with button names below. */
|
||||
|
||||
public static final int Button1Mask = (1<<8) ;
|
||||
public static final int Button2Mask = (1<<9) ;
|
||||
public static final int Button3Mask = (1<<10) ;
|
||||
public static final int Button4Mask = (1<<11) ;
|
||||
public static final int Button5Mask = (1<<12) ;
|
||||
public static final int [] buttonsMask = new int []{ 1<<8,
|
||||
1<<9,
|
||||
1<<10,
|
||||
1<<11,
|
||||
1<<12,
|
||||
1<<13,
|
||||
1<<14,
|
||||
1<<15,
|
||||
1<<16,
|
||||
1<<17,
|
||||
1<<18,
|
||||
1<<19,
|
||||
1<<20,
|
||||
1<<21,
|
||||
1<<22,
|
||||
1<<23,
|
||||
1<<24,
|
||||
1<<25,
|
||||
1<<26,
|
||||
1<<27,
|
||||
1<<28,
|
||||
1<<29,
|
||||
1<<30,
|
||||
1<<31 };
|
||||
|
||||
public static final int AnyModifier = (1<<15) ; /* used in GrabButton, GrabKey */
|
||||
|
||||
@ -211,11 +229,7 @@ final public class XConstants {
|
||||
and ButtonRelease events. Not to be confused with button masks above.
|
||||
Note that 0 is already defined above as "AnyButton". */
|
||||
|
||||
public static final int Button1 = 1 ;
|
||||
public static final int Button2 = 2 ;
|
||||
public static final int Button3 = 3 ;
|
||||
public static final int Button4 = 4 ;
|
||||
public static final int Button5 = 5 ;
|
||||
public static final int buttons [] = new int [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
|
||||
|
||||
/* Notify modes */
|
||||
|
||||
|
@ -492,7 +492,14 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
// do nothing but accept it.
|
||||
Rectangle reqBounds = newDimensions.getBounds();
|
||||
Rectangle newBounds = constrainBounds(reqBounds.x, reqBounds.y, reqBounds.width, reqBounds.height);
|
||||
newDimensions = new WindowDimensions(newBounds, newDimensions.getInsets(), newDimensions.isClientSizeSet());
|
||||
Insets insets = newDimensions.getInsets();
|
||||
// Inherit isClientSizeSet from newDimensions
|
||||
if (newDimensions.isClientSizeSet()) {
|
||||
newBounds = new Rectangle(newBounds.x, newBounds.y,
|
||||
newBounds.width - insets.left - insets.right,
|
||||
newBounds.height - insets.top - insets.bottom);
|
||||
}
|
||||
newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet());
|
||||
}
|
||||
XToolkit.awtLock();
|
||||
try {
|
||||
|
@ -694,8 +694,8 @@ public final class XDragSourceContextPeer
|
||||
} finally {
|
||||
xmotion.dispose();
|
||||
}
|
||||
if (xbutton.get_button() == XConstants.Button1
|
||||
|| xbutton.get_button() == XConstants.Button2) {
|
||||
if (xbutton.get_button() == XConstants.buttons[0]
|
||||
|| xbutton.get_button() == XConstants.buttons[1]) {
|
||||
// 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)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user