Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b5293c84
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b5293c84
编写于
3月 07, 2011
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
6c555dae
d51a626e
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
1177 addition
and
199 deletion
+1177
-199
make/sun/awt/Makefile
make/sun/awt/Makefile
+1
-1
src/share/classes/com/sun/media/sound/AiffFileWriter.java
src/share/classes/com/sun/media/sound/AiffFileWriter.java
+2
-3
src/share/classes/com/sun/media/sound/AlawCodec.java
src/share/classes/com/sun/media/sound/AlawCodec.java
+5
-6
src/share/classes/com/sun/media/sound/AuFileWriter.java
src/share/classes/com/sun/media/sound/AuFileWriter.java
+4
-5
src/share/classes/com/sun/media/sound/DirectAudioDevice.java
src/share/classes/com/sun/media/sound/DirectAudioDevice.java
+32
-73
src/share/classes/com/sun/media/sound/RealTimeSequencer.java
src/share/classes/com/sun/media/sound/RealTimeSequencer.java
+10
-3
src/share/classes/com/sun/media/sound/StandardMidiFileReader.java
...e/classes/com/sun/media/sound/StandardMidiFileReader.java
+1
-1
src/share/classes/com/sun/media/sound/SunFileWriter.java
src/share/classes/com/sun/media/sound/SunFileWriter.java
+58
-5
src/share/classes/com/sun/media/sound/WaveFileWriter.java
src/share/classes/com/sun/media/sound/WaveFileWriter.java
+2
-3
src/share/classes/java/awt/Font.java
src/share/classes/java/awt/Font.java
+49
-12
src/share/classes/java/util/Calendar.java
src/share/classes/java/util/Calendar.java
+2
-2
src/share/classes/java/util/GregorianCalendar.java
src/share/classes/java/util/GregorianCalendar.java
+2
-2
src/share/classes/java/util/TimeZone.java
src/share/classes/java/util/TimeZone.java
+17
-11
src/share/classes/javax/sound/midi/MidiSystem.java
src/share/classes/javax/sound/midi/MidiSystem.java
+0
-7
src/share/classes/javax/swing/DefaultDesktopManager.java
src/share/classes/javax/swing/DefaultDesktopManager.java
+4
-4
src/share/classes/javax/swing/JComponent.java
src/share/classes/javax/swing/JComponent.java
+21
-22
src/share/classes/javax/swing/JViewport.java
src/share/classes/javax/swing/JViewport.java
+2
-0
src/share/classes/javax/swing/text/Utilities.java
src/share/classes/javax/swing/text/Utilities.java
+8
-23
src/share/classes/javax/swing/text/WrappedPlainView.java
src/share/classes/javax/swing/text/WrappedPlainView.java
+3
-5
src/share/classes/javax/swing/text/html/CSSBorder.java
src/share/classes/javax/swing/text/html/CSSBorder.java
+9
-8
src/share/classes/sun/util/calendar/ZoneInfo.java
src/share/classes/sun/util/calendar/ZoneInfo.java
+39
-3
test/java/awt/FontClass/SurrogateTest/SupplementaryCanDisplayUpToTest.java
...tClass/SurrogateTest/SupplementaryCanDisplayUpToTest.java
+105
-0
test/java/util/TimeZone/Bug6772689.java
test/java/util/TimeZone/Bug6772689.java
+91
-0
test/javax/sound/midi/File/SMPTESequence.java
test/javax/sound/midi/File/SMPTESequence.java
+75
-0
test/javax/sound/midi/Sequencer/SequencerImplicitSynthOpen.java
...avax/sound/midi/Sequencer/SequencerImplicitSynthOpen.java
+110
-0
test/javax/sound/sampled/Clip/ClipSetPos.java
test/javax/sound/sampled/Clip/ClipSetPos.java
+90
-0
test/javax/sound/sampled/FileWriter/AlawEncoderSync.java
test/javax/sound/sampled/FileWriter/AlawEncoderSync.java
+113
-0
test/javax/sound/sampled/FileWriter/WriterCloseInput.java
test/javax/sound/sampled/FileWriter/WriterCloseInput.java
+127
-0
test/javax/swing/regtesthelpers/Util.java
test/javax/swing/regtesthelpers/Util.java
+75
-0
test/javax/swing/text/CSSBorder/6796710/bug6796710.java
test/javax/swing/text/CSSBorder/6796710/bug6796710.java
+120
-0
未找到文件。
make/sun/awt/Makefile
浏览文件 @
b5293c84
...
...
@@ -368,7 +368,7 @@ else
FONTCONFIGS_SRC
=
$(CLOSED_SRC)
/solaris/classes/sun/awt/fontconfigs
_FONTCONFIGS
=
\
fontconfig.properties
\
fontconfig.RedHat.
properties
\
fontconfig.RedHat.
5.5.properties
\
fontconfig.Turbo.properties
\
fontconfig.SuSE.10.properties
\
fontconfig.SuSE.11.properties
...
...
src/share/classes/com/sun/media/sound/AiffFileWriter.java
浏览文件 @
b5293c84
...
...
@@ -25,12 +25,10 @@
package
com.sun.media.sound
;
import
java.util.Vector
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.IOException
;
import
java.io.DataInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.DataOutputStream
;
...
...
@@ -398,7 +396,8 @@ public class AiffFileWriter extends SunFileWriter {
header
=
baos
.
toByteArray
();
headerStream
=
new
ByteArrayInputStream
(
header
);
aiffStream
=
new
SequenceInputStream
(
headerStream
,
codedAudioStream
);
aiffStream
=
new
SequenceInputStream
(
headerStream
,
new
NoCloseInputStream
(
codedAudioStream
));
return
aiffStream
;
...
...
src/share/classes/com/sun/media/sound/AlawCodec.java
浏览文件 @
b5293c84
...
...
@@ -52,9 +52,6 @@ public class AlawCodec extends SunCodec {
private
static
final
short
seg_end
[]
=
{
0xFF
,
0x1FF
,
0x3FF
,
0x7FF
,
0xFFF
,
0x1FFF
,
0x3FFF
,
0x7FFF
};
private
static
final
int
tempBufferSize
=
64
;
private
byte
tempBuffer
[]
=
null
;
/**
* Initializes the decode tables
*/
...
...
@@ -199,12 +196,9 @@ public class AlawCodec extends SunCodec {
AudioFormat
inputFormat
=
stream
.
getFormat
();
if
(
inputFormat
.
matches
(
outputFormat
)
)
{
cs
=
stream
;
}
else
{
cs
=
(
AudioInputStream
)
(
new
AlawCodecStream
(
stream
,
outputFormat
));
tempBuffer
=
new
byte
[
tempBufferSize
];
}
return
cs
;
...
...
@@ -264,6 +258,10 @@ public class AlawCodec extends SunCodec {
class
AlawCodecStream
extends
AudioInputStream
{
// tempBuffer required only for encoding (when encode is true)
private
static
final
int
tempBufferSize
=
64
;
private
byte
tempBuffer
[]
=
null
;
/**
* True to encode to a-law, false to decode to linear
*/
...
...
@@ -303,6 +301,7 @@ public class AlawCodec extends SunCodec {
encodeFormat
=
outputFormat
;
decodeFormat
=
inputFormat
;
PCMIsBigEndian
=
inputFormat
.
isBigEndian
();
tempBuffer
=
new
byte
[
tempBufferSize
];
}
if
(
PCMIsBigEndian
)
{
...
...
src/share/classes/com/sun/media/sound/AuFileWriter.java
浏览文件 @
b5293c84
...
...
@@ -25,12 +25,10 @@
package
com.sun.media.sound
;
import
java.util.Vector
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.IOException
;
import
java.lang.IllegalArgumentException
;
import
java.io.BufferedOutputStream
;
import
java.io.DataOutputStream
;
...
...
@@ -131,10 +129,10 @@ public class AuFileWriter extends SunFileWriter {
// $$fb: 2001-07-13: done. Fixes Bug 4479981
RandomAccessFile
raf
=
new
RandomAccessFile
(
out
,
"rw"
);
if
(
raf
.
length
()<=
0x7FFFFFFF
l
)
{
// skip AU magic and data offset field
// skip AU magic and data offset field
raf
.
skipBytes
(
8
);
raf
.
writeInt
(
bytesWritten
-
AuFileFormat
.
AU_HEADERSIZE
);
// that's all
// that's all
}
raf
.
close
();
}
...
...
@@ -303,7 +301,8 @@ public class AuFileWriter extends SunFileWriter {
dos
.
close
();
header
=
baos
.
toByteArray
();
headerStream
=
new
ByteArrayInputStream
(
header
);
auStream
=
new
SequenceInputStream
(
headerStream
,
codedAudioStream
);
auStream
=
new
SequenceInputStream
(
headerStream
,
new
NoCloseInputStream
(
codedAudioStream
));
return
auStream
;
}
...
...
src/share/classes/com/sun/media/sound/DirectAudioDevice.java
浏览文件 @
b5293c84
...
...
@@ -395,11 +395,7 @@ class DirectAudioDevice extends AbstractMixer {
protected
volatile
boolean
noService
=
false
;
// do not run the nService method
// Guards all native calls.
protected
Object
lockNative
=
new
Object
();
// Guards the lastOpened static variable in implOpen and implClose.
protected
static
Object
lockLast
=
new
Object
();
// Keeps track of last opened line, see implOpen "trick".
protected
static
DirectDL
lastOpened
;
protected
final
Object
lockNative
=
new
Object
();
// CONSTRUCTOR
protected
DirectDL
(
DataLine
.
Info
info
,
...
...
@@ -501,48 +497,21 @@ class DirectAudioDevice extends AbstractMixer {
// align buffer to full frames
bufferSize
=
((
int
)
bufferSize
/
format
.
getFrameSize
())
*
format
.
getFrameSize
();
synchronized
(
lockLast
)
{
id
=
nOpen
(
mixerIndex
,
deviceID
,
isSource
,
encoding
,
hardwareFormat
.
getSampleRate
(),
hardwareFormat
.
getSampleSizeInBits
(),
hardwareFormat
.
getFrameSize
(),
hardwareFormat
.
getChannels
(),
hardwareFormat
.
getEncoding
().
equals
(
AudioFormat
.
Encoding
.
PCM_SIGNED
),
hardwareFormat
.
isBigEndian
(),
bufferSize
);
if
(
id
==
0
)
{
// Bah... Dirty trick. The most likely cause is an application
// already having a line open for this particular hardware
// format and forgetting about it. If so, silently close that
// implementation and try again. Unfortuantely we can only
// open one line per hardware format currently.
if
(
lastOpened
!=
null
&&
hardwareFormat
.
matches
(
lastOpened
.
hardwareFormat
))
{
lastOpened
.
implClose
();
lastOpened
=
null
;
id
=
nOpen
(
mixerIndex
,
deviceID
,
isSource
,
encoding
,
hardwareFormat
.
getSampleRate
(),
hardwareFormat
.
getSampleSizeInBits
(),
hardwareFormat
.
getFrameSize
(),
hardwareFormat
.
getChannels
(),
hardwareFormat
.
getEncoding
().
equals
(
AudioFormat
.
Encoding
.
PCM_SIGNED
),
hardwareFormat
.
isBigEndian
(),
bufferSize
);
}
id
=
nOpen
(
mixerIndex
,
deviceID
,
isSource
,
encoding
,
hardwareFormat
.
getSampleRate
(),
hardwareFormat
.
getSampleSizeInBits
(),
hardwareFormat
.
getFrameSize
(),
hardwareFormat
.
getChannels
(),
hardwareFormat
.
getEncoding
().
equals
(
AudioFormat
.
Encoding
.
PCM_SIGNED
),
hardwareFormat
.
isBigEndian
(),
bufferSize
);
if
(
id
==
0
)
{
// TODO: nicer error messages...
throw
new
LineUnavailableException
(
"line with format "
+
format
+
" not supported."
);
}
}
lastOpened
=
this
;
if
(
id
==
0
)
{
// TODO: nicer error messages...
throw
new
LineUnavailableException
(
"line with format "
+
format
+
" not supported."
);
}
this
.
bufferSize
=
nGetBufferSize
(
id
,
isSource
);
...
...
@@ -615,14 +584,13 @@ class DirectAudioDevice extends AbstractMixer {
}
synchronized
(
lockNative
)
{
nStop
(
id
,
isSource
);
}
// wake up any waiting threads
synchronized
(
lock
)
{
// need to set doIO to false before notifying the
// read/write thread, that's why isStartedRunning()
// cannot be used
doIO
=
false
;
}
// wake up any waiting threads
synchronized
(
lock
)
{
lock
.
notifyAll
();
}
setActive
(
false
);
...
...
@@ -649,12 +617,8 @@ class DirectAudioDevice extends AbstractMixer {
doIO
=
false
;
long
oldID
=
id
;
id
=
0
;
synchronized
(
lockLast
)
{
synchronized
(
lockNative
)
{
nClose
(
oldID
,
isSource
);
if
(
lastOpened
==
this
)
lastOpened
=
null
;
}
synchronized
(
lockNative
)
{
nClose
(
oldID
,
isSource
);
}
bytePosition
=
0
;
softwareConversionSize
=
0
;
...
...
@@ -667,10 +631,9 @@ class DirectAudioDevice extends AbstractMixer {
if
(
id
==
0
)
{
return
0
;
}
int
a
=
0
;
int
a
;
synchronized
(
lockNative
)
{
if
(
doIO
)
a
=
nAvailable
(
id
,
isSource
);
a
=
nAvailable
(
id
,
isSource
);
}
return
a
;
}
...
...
@@ -726,7 +689,7 @@ class DirectAudioDevice extends AbstractMixer {
lock
.
notifyAll
();
}
synchronized
(
lockNative
)
{
if
(
id
!=
0
&&
doIO
)
{
if
(
id
!=
0
)
{
// then flush native buffers
nFlush
(
id
,
isSource
);
}
...
...
@@ -737,10 +700,9 @@ class DirectAudioDevice extends AbstractMixer {
// replacement for getFramePosition (see AbstractDataLine)
public
long
getLongFramePosition
()
{
long
pos
=
0
;
long
pos
;
synchronized
(
lockNative
)
{
if
(
doIO
)
pos
=
nGetBytePosition
(
id
,
isSource
,
bytePosition
);
pos
=
nGetBytePosition
(
id
,
isSource
,
bytePosition
);
}
// hack because ALSA sometimes reports wrong framepos
if
(
pos
<
0
)
{
...
...
@@ -786,12 +748,11 @@ class DirectAudioDevice extends AbstractMixer {
}
int
written
=
0
;
while
(!
flushing
)
{
int
thisWritten
=
0
;
int
thisWritten
;
synchronized
(
lockNative
)
{
if
(
doIO
)
thisWritten
=
nWrite
(
id
,
b
,
off
,
len
,
softwareConversionSize
,
leftGain
,
rightGain
);
thisWritten
=
nWrite
(
id
,
b
,
off
,
len
,
softwareConversionSize
,
leftGain
,
rightGain
);
if
(
thisWritten
<
0
)
{
// error in native layer
break
;
...
...
@@ -1014,10 +975,9 @@ class DirectAudioDevice extends AbstractMixer {
}
int
read
=
0
;
while
(
doIO
&&
!
flushing
)
{
int
thisRead
=
0
;
int
thisRead
;
synchronized
(
lockNative
)
{
if
(
doIO
)
thisRead
=
nRead
(
id
,
b
,
off
,
len
,
softwareConversionSize
);
thisRead
=
nRead
(
id
,
b
,
off
,
len
,
softwareConversionSize
);
if
(
thisRead
<
0
)
{
// error in native layer
break
;
...
...
@@ -1252,8 +1212,7 @@ class DirectAudioDevice extends AbstractMixer {
// set new native position (if necessary)
// this must come after the flush!
synchronized
(
lockNative
)
{
if
(
doIO
)
nSetBytePosition
(
id
,
isSource
,
frames
*
frameSize
);
nSetBytePosition
(
id
,
isSource
,
frames
*
frameSize
);
}
if
(
Printer
.
debug
)
Printer
.
debug
(
" DirectClip.setFramePosition: "
...
...
src/share/classes/com/sun/media/sound/RealTimeSequencer.java
浏览文件 @
b5293c84
...
...
@@ -775,15 +775,22 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon
Receiver
rec
=
null
;
// first try to connect to the default synthesizer
// IMPORTANT: this code needs to be synch'ed with
// MidiSystem.get
Receiv
er(boolean), because the same
// MidiSystem.get
Sequenc
er(boolean), because the same
// algorithm needs to be used!
try
{
Synthesizer
synth
=
MidiSystem
.
getSynthesizer
();
synth
.
open
();
if
(
synth
instanceof
ReferenceCountingDevice
)
{
rec
=
((
ReferenceCountingDevice
)
synth
).
getReceiverReferenceCounting
();
}
else
{
rec
=
synth
.
getReceiver
();
synth
.
open
();
try
{
rec
=
synth
.
getReceiver
();
}
finally
{
// make sure that the synth is properly closed
if
(
rec
==
null
)
{
synth
.
close
();
}
}
}
}
catch
(
Exception
e
)
{
// something went wrong with synth
...
...
src/share/classes/com/sun/media/sound/StandardMidiFileReader.java
浏览文件 @
b5293c84
...
...
@@ -127,7 +127,7 @@ public class StandardMidiFileReader extends MidiFileReader {
resolution
=
timing
;
}
else
{
// SMPTE based timing. first decipher the frame code.
int
frameCode
=
(-
1
*
timing
)
>>
8
;
int
frameCode
=
-
1
*
(
timing
>>
8
)
;
switch
(
frameCode
)
{
case
24
:
divisionType
=
Sequence
.
SMPTE_24
;
...
...
src/share/classes/com/sun/media/sound/SunFileWriter.java
浏览文件 @
b5293c84
...
...
@@ -30,14 +30,9 @@ import java.io.InputStream;
import
java.io.OutputStream
;
import
java.io.IOException
;
import
java.io.DataInputStream
;
import
java.io.RandomAccessFile
;
import
java.net.URL
;
import
javax.sound.sampled.AudioFormat
;
import
javax.sound.sampled.AudioFileFormat
;
import
javax.sound.sampled.AudioInputStream
;
import
javax.sound.sampled.AudioSystem
;
import
javax.sound.sampled.UnsupportedAudioFileException
;
import
javax.sound.sampled.spi.AudioFileWriter
;
...
...
@@ -177,4 +172,62 @@ abstract class SunFileWriter extends AudioFileWriter {
return
i
;
}
/**
* InputStream wrapper class which prevent source stream from being closed.
* The class is usefull for use with SequenceInputStream to prevent
* closing of the source input streams.
*/
protected
class
NoCloseInputStream
extends
InputStream
{
private
final
InputStream
in
;
public
NoCloseInputStream
(
InputStream
in
)
{
this
.
in
=
in
;
}
@Override
public
int
read
()
throws
IOException
{
return
in
.
read
();
}
@Override
public
int
read
(
byte
b
[])
throws
IOException
{
return
in
.
read
(
b
);
}
@Override
public
int
read
(
byte
b
[],
int
off
,
int
len
)
throws
IOException
{
return
in
.
read
(
b
,
off
,
len
);
}
@Override
public
long
skip
(
long
n
)
throws
IOException
{
return
in
.
skip
(
n
);
}
@Override
public
int
available
()
throws
IOException
{
return
in
.
available
();
}
@Override
public
void
close
()
throws
IOException
{
// don't propagate the call
}
@Override
public
void
mark
(
int
readlimit
)
{
in
.
mark
(
readlimit
);
}
@Override
public
void
reset
()
throws
IOException
{
in
.
reset
();
}
@Override
public
boolean
markSupported
()
{
return
in
.
markSupported
();
}
}
}
src/share/classes/com/sun/media/sound/WaveFileWriter.java
浏览文件 @
b5293c84
...
...
@@ -25,12 +25,10 @@
package
com.sun.media.sound
;
import
java.util.Vector
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.IOException
;
import
java.lang.IllegalArgumentException
;
import
java.io.BufferedOutputStream
;
import
java.io.DataOutputStream
;
...
...
@@ -371,7 +369,8 @@ public class WaveFileWriter extends SunFileWriter {
dos
.
close
();
header
=
baos
.
toByteArray
();
headerStream
=
new
ByteArrayInputStream
(
header
);
waveStream
=
new
SequenceInputStream
(
headerStream
,
codedAudioStream
);
waveStream
=
new
SequenceInputStream
(
headerStream
,
new
NoCloseInputStream
(
codedAudioStream
));
return
(
InputStream
)
waveStream
;
}
...
...
src/share/classes/java/awt/Font.java
浏览文件 @
b5293c84
...
...
@@ -1985,8 +1985,22 @@ public class Font implements java.io.Serializable
* @since 1.2
*/
public
int
canDisplayUpTo
(
String
str
)
{
return
canDisplayUpTo
(
new
StringCharacterIterator
(
str
),
0
,
str
.
length
());
Font2D
font2d
=
getFont2D
();
int
len
=
str
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c
=
str
.
charAt
(
i
);
if
(
font2d
.
canDisplay
(
c
))
{
continue
;
}
if
(!
Character
.
isHighSurrogate
(
c
))
{
return
i
;
}
if
(!
font2d
.
canDisplay
(
str
.
codePointAt
(
i
)))
{
return
i
;
}
i
++;
}
return
-
1
;
}
/**
...
...
@@ -2009,11 +2023,21 @@ public class Font implements java.io.Serializable
* @since 1.2
*/
public
int
canDisplayUpTo
(
char
[]
text
,
int
start
,
int
limit
)
{
while
(
start
<
limit
&&
canDisplay
(
text
[
start
]))
{
++
start
;
Font2D
font2d
=
getFont2D
();
for
(
int
i
=
start
;
i
<
limit
;
i
++)
{
char
c
=
text
[
i
];
if
(
font2d
.
canDisplay
(
c
))
{
continue
;
}
if
(!
Character
.
isHighSurrogate
(
c
))
{
return
i
;
}
if
(!
font2d
.
canDisplay
(
Character
.
codePointAt
(
text
,
i
,
limit
)))
{
return
i
;
}
i
++;
}
return
start
==
limit
?
-
1
:
start
;
return
-
1
;
}
/**
...
...
@@ -2034,13 +2058,26 @@ public class Font implements java.io.Serializable
* @since 1.2
*/
public
int
canDisplayUpTo
(
CharacterIterator
iter
,
int
start
,
int
limit
)
{
for
(
char
c
=
iter
.
setIndex
(
start
);
iter
.
getIndex
()
<
limit
&&
canDisplay
(
c
);
c
=
iter
.
next
())
{
Font2D
font2d
=
getFont2D
();
char
c
=
iter
.
setIndex
(
start
);
for
(
int
i
=
start
;
i
<
limit
;
i
++,
c
=
iter
.
next
())
{
if
(
font2d
.
canDisplay
(
c
))
{
continue
;
}
if
(!
Character
.
isHighSurrogate
(
c
))
{
return
i
;
}
char
c2
=
iter
.
next
();
// c2 could be CharacterIterator.DONE which is not a low surrogate.
if
(!
Character
.
isLowSurrogate
(
c2
))
{
return
i
;
}
if
(!
font2d
.
canDisplay
(
Character
.
toCodePoint
(
c
,
c2
)))
{
return
i
;
}
i
++;
}
int
result
=
iter
.
getIndex
();
return
result
==
limit
?
-
1
:
result
;
return
-
1
;
}
/**
...
...
src/share/classes/java/util/Calendar.java
浏览文件 @
b5293c84
/*
* Copyright (c) 1996, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
1
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -554,7 +554,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
/**
* Field number for <code>get</code> and <code>set</code> indicating the
* daylight saving
s
offset in milliseconds.
* daylight saving offset in milliseconds.
* <p>
* This field reflects the correct daylight saving offset value of
* the time zone of this <code>Calendar</code> if the
...
...
src/share/classes/java/util/GregorianCalendar.java
浏览文件 @
b5293c84
/*
* Copyright (c) 1996, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
1
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -260,7 +260,7 @@ import sun.util.calendar.ZoneInfo;
* // create a Pacific Standard Time time zone
* SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
*
* // set up rules for
daylight savings t
ime
* // set up rules for
Daylight Saving T
ime
* pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
* pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
*
...
...
src/share/classes/java/util/TimeZone.java
浏览文件 @
b5293c84
...
...
@@ -339,8 +339,9 @@ abstract public class TimeZone implements Serializable, Cloneable {
/**
* Returns a name in the specified {@code style} of this {@code TimeZone}
* suitable for presentation to the user in the default locale. If the
* specified {@code daylight} is {@code true}, a daylight saving time name
* is returned. Otherwise, a standard time name is returned.
* specified {@code daylight} is {@code true}, a Daylight Saving Time name
* is returned (even if this {@code TimeZone} doesn't observe Daylight Saving
* Time). Otherwise, a Standard Time name is returned.
*
* <p>This method is equivalent to:
* <pre><blockquote>
...
...
@@ -348,7 +349,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
* Locale.getDefault({@link Locale.Category#DISPLAY}))
* </blockquote></pre>
*
* @param daylight if {@code true}, return the daylight saving time name.
* @param daylight {@code true} specifying a Daylight Saving Time name, or
* {@code false} specifying a Standard Time name
* @param style either {@link #LONG} or {@link #SHORT}
* @return the human-readable name of this time zone in the default locale.
* @exception IllegalArgumentException if {@code style} is invalid.
...
...
@@ -356,6 +358,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* @see #getDisplayName(boolean, int, Locale)
* @see Locale#getDefault(Locale.Category)
* @see Locale.Category
* @see java.text.DateFormatSymbols#getZoneStrings()
*/
public
final
String
getDisplayName
(
boolean
daylight
,
int
style
)
{
return
getDisplayName
(
daylight
,
style
,
...
...
@@ -365,8 +368,9 @@ abstract public class TimeZone implements Serializable, Cloneable {
/**
* Returns a name in the specified {@code style} of this {@code TimeZone}
* suitable for presentation to the user in the specified {@code
* locale}. If the specified {@code daylight} is {@code true}, a daylight
* saving time name is returned. Otherwise, a standard time name is
* locale}. If the specified {@code daylight} is {@code true}, a Daylight
* Saving Time name is returned (even if this {@code TimeZone} doesn't
* observe Daylight Saving Time). Otherwise, a Standard Time name is
* returned.
*
* <p>When looking up a time zone name, the {@linkplain
...
...
@@ -379,13 +383,15 @@ abstract public class TimeZone implements Serializable, Cloneable {
* found, the name is returned. Otherwise, a string in the
* <a href="#NormalizedCustomID">normalized custom ID format</a> is returned.
*
* @param daylight if {@code true}, return the daylight saving time name.
* @param daylight {@code true} specifying a Daylight Saving Time name, or
* {@code false} specifying a Standard Time name
* @param style either {@link #LONG} or {@link #SHORT}
* @param locale the locale in which to supply the display name.
* @param locale
the locale in which to supply the display name.
* @return the human-readable name of this time zone in the given locale.
* @exception IllegalArgumentException if {@code style} is invalid.
* @exception NullPointerException if {@code locale} is {@code null}.
* @since 1.2
* @see java.text.DateFormatSymbols#getZoneStrings()
*/
public
String
getDisplayName
(
boolean
daylight
,
int
style
,
Locale
locale
)
{
if
(
style
!=
SHORT
&&
style
!=
LONG
)
{
...
...
@@ -526,10 +532,10 @@ abstract public class TimeZone implements Serializable, Cloneable {
/**
* Queries if the given {@code date} is in Daylight Saving Time in
* this
{@code TimeZone}
.
* this
time zone
.
*
* @param date the given
{@code Date}
.
* @return {@code true} if the given
{@code date}
is in Daylight Saving Time,
* @param date the given
Date
.
* @return {@code true} if the given
date
is in Daylight Saving Time,
* {@code false}, otherwise.
*/
abstract
public
boolean
inDaylightTime
(
Date
date
);
...
...
@@ -566,7 +572,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* @param rawOffset the given time zone GMT offset in milliseconds.
* @return an array of IDs, where the time zone for that ID has
* the specified GMT offset. For example, "America/Phoenix" and "America/Denver"
* both have GMT-07:00, but differ in daylight saving
s
behavior.
* both have GMT-07:00, but differ in daylight saving behavior.
* @see #getRawOffset()
*/
public
static
synchronized
String
[]
getAvailableIDs
(
int
rawOffset
)
{
...
...
src/share/classes/javax/sound/midi/MidiSystem.java
浏览文件 @
b5293c84
...
...
@@ -441,13 +441,6 @@ public class MidiSystem {
Synthesizer
synth
=
getSynthesizer
();
if
(
synth
instanceof
ReferenceCountingDevice
)
{
rec
=
((
ReferenceCountingDevice
)
synth
).
getReceiverReferenceCounting
();
// only use MixerSynth if it could successfully load a soundbank
if
(
synth
.
getClass
().
toString
().
contains
(
"com.sun.media.sound.MixerSynth"
)
&&
(
synth
.
getDefaultSoundbank
()
==
null
))
{
// don't use this receiver if no soundbank available
rec
=
null
;
synth
.
close
();
}
}
else
{
synth
.
open
();
try
{
...
...
src/share/classes/javax/swing/DefaultDesktopManager.java
浏览文件 @
b5293c84
...
...
@@ -174,6 +174,8 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
if
(!
wasIcon
(
f
))
{
Rectangle
r
=
getBoundsForIconOf
(
f
);
desktopIcon
.
setBounds
(
r
.
x
,
r
.
y
,
r
.
width
,
r
.
height
);
// we must validate the hierarchy to not break the hw/lw mixing
desktopIcon
.
revalidate
();
setWasIcon
(
f
,
Boolean
.
TRUE
);
}
...
...
@@ -453,11 +455,9 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
/** This moves the <code>JComponent</code> and repaints the damaged areas. */
public
void
setBoundsForFrame
(
JComponent
f
,
int
newX
,
int
newY
,
int
newWidth
,
int
newHeight
)
{
boolean
didResize
=
(
f
.
getWidth
()
!=
newWidth
||
f
.
getHeight
()
!=
newHeight
);
f
.
setBounds
(
newX
,
newY
,
newWidth
,
newHeight
);
if
(
didResize
)
{
f
.
validate
();
}
// we must validate the hierarchy to not break the hw/lw mixing
f
.
revalidate
();
}
/** Convenience method to remove the desktopIcon of <b>f</b> is necessary. */
...
...
src/share/classes/javax/swing/JComponent.java
浏览文件 @
b5293c84
...
...
@@ -5158,31 +5158,30 @@ public abstract class JComponent extends Container implements Serializable,
}
}
}
try
{
g
=
safelyGetGraphics
(
paintingComponent
,
c
);
try
{
if
(
hasBuffer
)
{
RepaintManager
rm
=
RepaintManager
.
currentManager
(
bufferedComponent
);
rm
.
beginPaint
();
try
{
rm
.
paint
(
paintingComponent
,
bufferedComponent
,
g
,
paintImmediatelyClip
.
x
,
paintImmediatelyClip
.
y
,
paintImmediatelyClip
.
width
,
paintImmediatelyClip
.
height
);
}
finally
{
rm
.
endPaint
();
if
((
g
=
safelyGetGraphics
(
paintingComponent
,
c
))
!=
null
)
{
try
{
if
(
hasBuffer
)
{
RepaintManager
rm
=
RepaintManager
.
currentManager
(
bufferedComponent
);
rm
.
beginPaint
();
try
{
rm
.
paint
(
paintingComponent
,
bufferedComponent
,
g
,
paintImmediatelyClip
.
x
,
paintImmediatelyClip
.
y
,
paintImmediatelyClip
.
width
,
paintImmediatelyClip
.
height
);
}
finally
{
rm
.
endPaint
();
}
}
else
{
g
.
setClip
(
paintImmediatelyClip
.
x
,
paintImmediatelyClip
.
y
,
paintImmediatelyClip
.
width
,
paintImmediatelyClip
.
height
);
paintingComponent
.
paint
(
g
);
}
}
finally
{
g
.
dispose
();
}
else
{
g
.
setClip
(
paintImmediatelyClip
.
x
,
paintImmediatelyClip
.
y
,
paintImmediatelyClip
.
width
,
paintImmediatelyClip
.
height
);
paintingComponent
.
paint
(
g
);
}
}
finally
{
g
.
dispose
();
}
}
finally
{
...
...
src/share/classes/javax/swing/JViewport.java
浏览文件 @
b5293c84
...
...
@@ -1111,6 +1111,8 @@ public class JViewport extends JComponent implements Accessible
view
.
setLocation
(
newX
,
newY
);
repaintAll
=
false
;
}
// we must validate the hierarchy to not break the hw/lw mixing
revalidate
();
fireStateChanged
();
}
}
...
...
src/share/classes/javax/swing/text/Utilities.java
浏览文件 @
b5293c84
...
...
@@ -390,11 +390,15 @@ public class Utilities {
}
if
((
x
>=
currX
)
&&
(
x
<
nextX
))
{
// found the hit position... return the appropriate side
if
((
round
==
false
)
||
((
x
-
currX
)
<
(
nextX
-
x
)))
{
return
i
-
txtOffset
;
}
else
{
return
i
+
1
-
txtOffset
;
int
offset
=
((
round
==
false
)
||
((
x
-
currX
)
<
(
nextX
-
x
)))
?
(
i
-
txtOffset
)
:
(
i
+
1
-
txtOffset
);
// the length of the string measured as a whole may differ from
// the sum of individual character lengths, for example if
// fractional metrics are enabled; and we must guard from this.
while
(
metrics
.
charsWidth
(
txt
,
txtOffset
,
offset
+
1
)
>
(
x
-
x0
))
{
offset
--;
}
return
(
offset
<
0
?
0
:
offset
);
}
currX
=
nextX
;
}
...
...
@@ -403,24 +407,6 @@ public class Utilities {
return
txtCount
;
}
/**
* Adjust text offset so that the length of a resulting string as a whole
* fits into the specified width.
*/
static
int
adjustOffsetForFractionalMetrics
(
Segment
s
,
FontMetrics
fm
,
int
offset
,
int
width
)
{
// Sometimes the offset returned by getTabbedTextOffset is beyond the
// available area, when fractional metrics are enabled. We should
// guard against this.
if
(
offset
<
s
.
count
)
{
while
(
offset
>
0
&&
fm
.
charsWidth
(
s
.
array
,
s
.
offset
,
offset
+
1
)
>
width
)
{
offset
--;
}
}
return
offset
;
}
/**
* Determine where to break the given text to fit
* within the given span. This tries to find a word boundary.
...
...
@@ -443,7 +429,6 @@ public class Utilities {
int
txtCount
=
s
.
count
;
int
index
=
Utilities
.
getTabbedTextOffset
(
s
,
metrics
,
x0
,
x
,
e
,
startOffset
,
false
);
index
=
adjustOffsetForFractionalMetrics
(
s
,
metrics
,
index
,
x
-
x0
);
if
(
index
>=
txtCount
-
1
)
{
return
txtCount
;
...
...
src/share/classes/javax/swing/text/WrappedPlainView.java
浏览文件 @
b5293c84
...
...
@@ -239,11 +239,9 @@ public class WrappedPlainView extends BoxView implements TabExpander {
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
);
}
else
{
int
offset
=
Utilities
.
getTabbedTextOffset
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
,
false
);
offset
=
Utilities
.
adjustOffsetForFractionalMetrics
(
segment
,
metrics
,
offset
,
currentWidth
);
p
=
p0
+
offset
;
p
=
p0
+
Utilities
.
getTabbedTextOffset
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
,
false
);
}
SegmentCache
.
releaseSharedSegment
(
segment
);
return
p
;
...
...
src/share/classes/javax/swing/text/html/CSSBorder.java
浏览文件 @
b5293c84
...
...
@@ -203,10 +203,11 @@ class CSSBorder extends AbstractBorder {
public
void
paintBorder
(
Component
c
,
Graphics
g
,
int
x
,
int
y
,
int
width
,
int
height
)
{
assert
(
g
instanceof
Graphics2D
)
:
"need Graphics2D instanse"
;
Graphics2D
g2
=
(
Graphics2D
)
g
;
Color
savedColor
=
g2
.
getColor
();
Shape
savedClip
=
g2
.
getClip
();
if
(!(
g
instanceof
Graphics2D
))
{
return
;
}
Graphics2D
g2
=
(
Graphics2D
)
g
.
create
();
int
[]
widths
=
getWidths
();
...
...
@@ -238,16 +239,16 @@ class CSSBorder extends AbstractBorder {
BorderPainter
painter
=
getBorderPainter
(
i
);
double
angle
=
i
*
Math
.
PI
/
2
;
g2
.
setClip
(
g
.
getClip
());
// Restore initial clip
g2
.
translate
(
intCorners
[
i
][
0
],
intCorners
[
i
][
1
]);
g2
.
rotate
(
angle
);
g2
.
setC
lip
(
shape
);
painter
.
paint
(
shape
,
g
,
color
,
i
);
g2
.
c
lip
(
shape
);
painter
.
paint
(
shape
,
g
2
,
color
,
i
);
g2
.
rotate
(-
angle
);
g2
.
translate
(-
intCorners
[
i
][
0
],
-
intCorners
[
i
][
1
]);
}
}
g2
.
setColor
(
savedColor
);
g2
.
setClip
(
savedClip
);
g2
.
dispose
();
}
...
...
src/share/classes/sun/util/calendar/ZoneInfo.java
浏览文件 @
b5293c84
/*
* Copyright (c) 2000, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 20
11
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -266,7 +266,7 @@ public class ZoneInfo extends TimeZone {
int
index
=
getTransitionIndex
(
date
,
type
);
// prior to the transition table, returns the raw offset.
// should support LMT.
//
FIXME:
should support LMT.
if
(
index
<
0
)
{
int
offset
=
getLastRawOffset
();
if
(
offsets
!=
null
)
{
...
...
@@ -297,7 +297,13 @@ public class ZoneInfo extends TimeZone {
if
(
type
!=
UTC_TIME
)
{
msec
-=
rawOffset
;
}
int
dstoffset
=
tz
.
inDaylightTime
(
new
Date
(
msec
))
?
tz
.
getDSTSavings
()
:
0
;
int
dstoffset
=
tz
.
getOffset
(
msec
)
-
rawOffset
;
// Check if it's in a standard-to-daylight transition.
if
(
dstoffset
>
0
&&
tz
.
getOffset
(
msec
-
dstoffset
)
==
rawoffset
)
{
dstoffset
=
0
;
}
if
(
offsets
!=
null
)
{
offsets
[
0
]
=
rawoffset
;
offsets
[
1
]
=
dstoffset
;
...
...
@@ -452,6 +458,36 @@ public class ZoneInfo extends TimeZone {
return
(
simpleTimeZoneParams
!=
null
);
}
@Override
public
boolean
observesDaylightTime
()
{
if
(
simpleTimeZoneParams
!=
null
)
{
return
true
;
}
if
(
transitions
==
null
)
{
return
false
;
}
// Look up the transition table to see if it's in DST right
// now or if there's any standard-to-daylight transition at
// any future.
long
utc
=
System
.
currentTimeMillis
()
-
rawOffsetDiff
;
int
index
=
getTransitionIndex
(
utc
,
UTC_TIME
);
// before transitions in the transition table
if
(
index
<
0
)
{
return
false
;
}
// the time is in the table range.
for
(
int
i
=
index
;
i
<
transitions
.
length
;
i
++)
{
if
((
transitions
[
i
]
&
DST_MASK
)
!=
0
)
{
return
true
;
}
}
// No further DST is observed.
return
false
;
}
/**
* Queries if the specified date is in Daylight Saving Time.
*/
...
...
test/java/awt/FontClass/SurrogateTest/SupplementaryCanDisplayUpToTest.java
0 → 100644
浏览文件 @
b5293c84
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6623219
* @summary Test canDisplayUpTo with supplementary characters.
*/
import
java.awt.*
;
import
java.text.*
;
public
class
SupplementaryCanDisplayUpToTest
{
// Lists consisting of a font name, test text, and its expected
// return value. Test text uses private area code point U+F0000
// (\udb80\udc00).
private
static
String
[][]
DATA
=
{
// Windows
{
"Meiryo"
,
"\ud87e\udd45\ud87e\udd47\udb80\udc00"
,
"4"
},
{
"Meiryo"
,
"\ud87e\udd45\ud87e\udd47\udb80Z"
,
"4"
},
{
"Meiryo"
,
"\ud87e\udd45\ud87e\udd47\udb80"
,
"4"
},
{
"Meiryo"
,
"\ud87e\udd45\ud87e\udd47\udc00"
,
"4"
},
{
"Meiryo"
,
"\ud87e\udd45\ud87e\udd47"
,
"-1"
},
// Linux
{
"AR PL UMing TW"
,
"\ud87e\udc25\ud87e\udc3b\udb80\udc00"
,
"4"
},
{
"AR PL UMing TW"
,
"\ud87e\udc25\ud87e\udc3b\udb80Z"
,
"4"
},
{
"AR PL UMing TW"
,
"\ud87e\udc25\ud87e\udc3b\udb80"
,
"4"
},
{
"AR PL UMing TW"
,
"\ud87e\udc25\ud87e\udc3b\udc00"
,
"4"
},
{
"AR PL UMing TW"
,
"\ud87e\udc25\ud87e\udc3b"
,
"-1"
},
// Solaris
{
"FZMingTi"
,
"\ud87e\udc25\ud87e\udc3b\udb80\udc00"
,
"4"
},
{
"FZMingTi"
,
"\ud87e\udc25\ud87e\udc3b\udb80Z"
,
"4"
},
{
"FZMingTi"
,
"\ud87e\udc25\ud87e\udc3b\udb80"
,
"4"
},
{
"FZMingTi"
,
"\ud87e\udc25\ud87e\udc3b\udc00"
,
"4"
},
{
"FZMingTi"
,
"\ud87e\udc25\ud87e\udc3b"
,
"-1"
},
};
private
static
int
errorcount
=
0
;
public
static
void
main
(
String
[]
args
)
{
for
(
String
[]
data
:
DATA
)
{
String
fontname
=
data
[
0
];
Font
font
=
new
Font
(
fontname
,
Font
.
PLAIN
,
16
);
if
(
font
.
getFamily
().
equals
(
Font
.
DIALOG
))
{
// Skip any unavailable fonts.
continue
;
}
System
.
out
.
printf
(
"Testing with font '%s'... "
,
fontname
);
int
errors
=
0
;
String
text
=
data
[
1
];
int
expected
=
Integer
.
parseInt
(
data
[
2
]);
int
result
=
font
.
canDisplayUpTo
(
text
);
if
(
result
!=
expected
)
{
System
.
err
.
println
(
"canDisplayUpTo(String) returns "
+
result
);
errors
++;
}
result
=
font
.
canDisplayUpTo
(
text
.
toCharArray
(),
0
,
text
.
length
());
if
(
result
!=
expected
)
{
System
.
err
.
println
(
"canDisplayUpTo(char[], int, int) returns "
+
result
);
errors
++;
}
CharacterIterator
iter
=
new
StringCharacterIterator
(
text
);
result
=
font
.
canDisplayUpTo
(
iter
,
iter
.
getBeginIndex
(),
iter
.
getEndIndex
());
if
(
result
!=
expected
)
{
System
.
err
.
println
(
"canDisplayUpTo(CharacterIterator, int, int) returns "
+
result
);
errors
++;
}
if
(
errors
==
0
)
{
System
.
out
.
println
(
"passed"
);
}
else
{
System
.
out
.
println
(
"failed"
);
errorcount
+=
errors
;
}
}
if
(
errorcount
>
0
)
{
throw
new
RuntimeException
(
"SupplementaryCanDisplayUpToTest: failed"
);
}
}
}
test/java/util/TimeZone/Bug6772689.java
0 → 100644
浏览文件 @
b5293c84
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6772689
* @summary Test for standard-to-daylight transitions at midnight:
* date stays on the given day.
*/
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
import
java.util.TimeZone
;
import
static
java
.
util
.
GregorianCalendar
.*;
public
class
Bug6772689
{
private
static
final
int
BEGIN_YEAR
=
2035
;
private
static
final
int
END_YEAR
=
BEGIN_YEAR
+
28
;
public
static
void
main
(
String
[]
args
)
{
TimeZone
defaultTimeZone
=
TimeZone
.
getDefault
();
int
errors
=
0
;
Calendar
cal
=
new
GregorianCalendar
(
BEGIN_YEAR
,
MARCH
,
1
);
String
[]
tzids
=
TimeZone
.
getAvailableIDs
();
try
{
for
(
String
id
:
tzids
)
{
TimeZone
tz
=
TimeZone
.
getTimeZone
(
id
);
if
(!
tz
.
useDaylightTime
())
{
continue
;
}
TimeZone
.
setDefault
(
tz
);
dateloop:
// Use future dates because sun.util.calendar.ZoneInfo
// delegates offset transition calculations to a SimpleTimeZone
// (after 2038 as of JDK7).
for
(
int
year
=
BEGIN_YEAR
;
year
<
END_YEAR
;
year
++)
{
for
(
int
month
=
MARCH
;
month
<=
NOVEMBER
;
month
++)
{
cal
.
set
(
year
,
month
,
1
,
15
,
0
,
0
);
int
maxDom
=
cal
.
getActualMaximum
(
DAY_OF_MONTH
);
for
(
int
dom
=
1
;
dom
<=
maxDom
;
dom
++)
{
Date
date
=
new
Date
(
year
-
1900
,
month
,
dom
);
if
(
date
.
getYear
()+
1900
!=
year
||
date
.
getMonth
()
!=
month
||
date
.
getDate
()
!=
dom
)
{
System
.
err
.
printf
(
"%s: got %04d-%02d-%02d, expected %04d-%02d-%02d%n"
,
id
,
date
.
getYear
()
+
1900
,
date
.
getMonth
()
+
1
,
date
.
getDate
(),
year
,
month
+
1
,
dom
);
errors
++;
break
dateloop
;
}
}
}
}
}
}
finally
{
// Restore the default TimeZone.
TimeZone
.
setDefault
(
defaultTimeZone
);
}
if
(
errors
>
0
)
{
throw
new
RuntimeException
(
"Transition test failed"
);
}
}
}
test/javax/sound/midi/File/SMPTESequence.java
0 → 100644
浏览文件 @
b5293c84
/**
* @test
* @bug 6835393
* @summary Tests that MidiFileReader correctly reads sequences with different division types
* @author Alex Menkov
*/
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
javax.sound.midi.InvalidMidiDataException
;
import
javax.sound.midi.MidiSystem
;
import
javax.sound.midi.Sequence
;
public
class
SMPTESequence
{
static
int
failed
=
0
;
public
static
void
main
(
String
[]
args
)
{
test
(
Sequence
.
PPQ
);
test
(
Sequence
.
SMPTE_24
);
test
(
Sequence
.
SMPTE_25
);
test
(
Sequence
.
SMPTE_30
);
test
(
Sequence
.
SMPTE_30DROP
);
if
(
failed
>
0
)
{
throw
new
RuntimeException
(
""
+
failed
+
" tests failed"
);
}
}
static
boolean
test
(
float
divisionType
)
{
boolean
result
=
false
;
try
{
log
(
"Testing divisionType == "
+
divisionType
);
Sequence
sequence
=
new
Sequence
(
divisionType
,
16
,
1
);
float
div1
=
sequence
.
getDivisionType
();
ByteArrayOutputStream
outStream
=
new
ByteArrayOutputStream
();
MidiSystem
.
write
(
sequence
,
1
,
outStream
);
InputStream
inStream
=
new
ByteArrayInputStream
(
outStream
.
toByteArray
());
sequence
=
MidiSystem
.
getSequence
(
inStream
);
float
div2
=
sequence
.
getDivisionType
();
log
(
"After write/read got divisionType == "
+
div2
);
if
(
Math
.
abs
(
div2
-
div1
)
<
0.001f
)
{
result
=
true
;
}
}
catch
(
InvalidMidiDataException
ex
)
{
log
(
ex
);
}
catch
(
IOException
ex
)
{
log
(
ex
);
}
catch
(
IllegalArgumentException
ex
)
{
log
(
ex
);
}
if
(
result
)
{
log
(
"OK"
);
}
else
{
log
(
"FAIL"
);
failed
++;
}
return
result
;
}
static
void
log
(
String
s
)
{
System
.
out
.
println
(
s
);
}
static
void
log
(
Exception
ex
)
{
log
(
"got exception ("
+
ex
.
getClass
().
getSimpleName
()
+
"): "
+
ex
.
getMessage
());
}
}
test/javax/sound/midi/Sequencer/SequencerImplicitSynthOpen.java
0 → 100644
浏览文件 @
b5293c84
/**
* @test
* @bug 6660470
* @summary Tests that sequencer correctly opens/closes (implicitly) devices
* @author Alex Menkov
*/
import
java.util.List
;
import
javax.sound.midi.MidiDevice
;
import
javax.sound.midi.MidiDeviceReceiver
;
import
javax.sound.midi.MidiSystem
;
import
javax.sound.midi.MidiUnavailableException
;
import
javax.sound.midi.Receiver
;
import
javax.sound.midi.Sequencer
;
import
javax.sound.midi.Transmitter
;
public
class
SequencerImplicitSynthOpen
{
static
int
TEST_COUNT
=
5
;
public
static
void
main
(
String
[]
args
)
{
try
{
log
(
"getting sequencer..."
);
Sequencer
sequencer
=
MidiSystem
.
getSequencer
();
log
(
" - got "
+
getDeviceStr
(
sequencer
));
// obtain connected device (usually synthesizer)
MidiDevice
synth
=
getConnectedDevice
(
sequencer
);
if
(
synth
==
null
)
{
log
(
"could not get connected device, returning"
);
return
;
}
log
(
"connected device: "
+
getDeviceStr
(
synth
));
int
success
=
0
;
for
(
int
i
=
0
;
i
<
TEST_COUNT
;
i
++)
{
if
(
test
(
sequencer
))
{
success
++;
}
}
if
(
success
!=
TEST_COUNT
)
{
throw
new
RuntimeException
(
"test FAILS"
);
}
}
catch
(
MidiUnavailableException
ex
)
{
// this is not a failure
log
(
"Could not get Sequencer"
);
}
log
(
"test PASSED."
);
}
static
boolean
test
(
Sequencer
sequencer
)
throws
MidiUnavailableException
{
log
(
""
);
log
(
"opening sequencer..."
);
sequencer
.
open
();
// opens connected synthesizer implicitly
MidiDevice
synth
=
getConnectedDevice
(
sequencer
);
log
(
" connected device: "
+
getDeviceStr
(
synth
));
log
(
"closing sequencer..."
);
sequencer
.
close
();
// closes the synth implicitly
log
(
" synth is "
+
getDeviceStr
(
synth
));
MidiDevice
synth2
=
getConnectedDevice
(
sequencer
);
log
(
" currently connected device: "
+
getDeviceStr
(
synth2
));
if
(
synth
!=
null
&&
synth
.
isOpen
())
{
log
(
"FAIL."
);
return
false
;
}
log
(
"OK."
);
return
true
;
}
static
MidiDevice
getConnectedDevice
(
Sequencer
sequencer
)
{
List
<
Transmitter
>
trans
=
sequencer
.
getTransmitters
();
log
(
" sequencer has "
+
trans
.
size
()
+
" opened transmitters:"
);
for
(
Transmitter
tr:
trans
)
{
Receiver
r
=
tr
.
getReceiver
();
log
(
" "
+
getClassStr
(
tr
)
+
" connected to "
+
getClassStr
(
r
));
if
(
r
instanceof
MidiDeviceReceiver
)
{
MidiDeviceReceiver
recv
=
(
MidiDeviceReceiver
)
r
;
MidiDevice
dev
=
recv
.
getMidiDevice
();
log
(
" - receiver of "
+
getClassStr
(
dev
));
return
dev
;
}
else
{
log
(
" - does NOT implement MidiDeviceReceiver"
);
}
}
return
null
;
}
static
String
getClassStr
(
Object
o
)
{
if
(
o
==
null
)
{
return
"<null>"
;
}
return
o
.
getClass
().
getName
();
}
static
String
getDeviceStr
(
MidiDevice
dev
)
{
if
(
dev
==
null
)
{
return
"NULL"
;
}
return
getClassStr
(
dev
)
+
", "
+
(
dev
.
isOpen
()
?
"OPENED"
:
"CLOSED"
);
}
static
void
log
(
String
s
)
{
System
.
out
.
println
(
s
);
}
}
test/javax/sound/sampled/Clip/ClipSetPos.java
0 → 100644
浏览文件 @
b5293c84
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6801206
* @summary Tests that Clip sets frame position
* @author Alex Menkov
*/
import
javax.sound.sampled.AudioFormat
;
import
javax.sound.sampled.AudioSystem
;
import
javax.sound.sampled.Clip
;
import
javax.sound.sampled.LineUnavailableException
;
public
class
ClipSetPos
{
final
static
AudioFormat
audioFormat
=
new
AudioFormat
(
44100
f
,
16
,
2
,
true
,
true
);
final
static
int
frameLength
=
44100
*
2
;
// 2 seconds
final
static
byte
[]
dataBuffer
=
new
byte
[
frameLength
*
(
audioFormat
.
getSampleSizeInBits
()/
8
)
*
audioFormat
.
getChannels
()];
final
static
int
MAX_FRAME_DELTA
=
20
;
public
static
void
main
(
String
[]
args
)
{
boolean
testPassed
=
true
;
Clip
clip
=
null
;
try
{
clip
=
AudioSystem
.
getClip
();
clip
.
open
(
audioFormat
,
dataBuffer
,
0
,
dataBuffer
.
length
);
}
catch
(
LineUnavailableException
ex
)
{
log
(
ex
);
log
(
"Cannot test (this is not failure)"
);
return
;
}
log
(
"clip: "
+
clip
.
getClass
().
getName
());
int
len
=
clip
.
getFrameLength
();
for
(
int
pos
=
0
;
pos
<
len
;
pos
+=
(
len
/
100
))
{
clip
.
setFramePosition
(
pos
);
int
curPos
=
clip
.
getFramePosition
();
if
(
Math
.
abs
(
pos
-
curPos
)
>
MAX_FRAME_DELTA
)
{
log
(
"Tried to set pos to "
+
pos
+
", but got back "
+
curPos
);
testPassed
=
false
;
}
else
{
log
(
"Sucessfully set pos to "
+
pos
);
}
}
clip
.
close
();
if
(
testPassed
)
{
log
(
"Test PASSED."
);
}
else
{
log
(
"Test FAILED."
);
throw
new
RuntimeException
(
"Test FAILED (see log)"
);
}
}
static
void
log
(
String
s
)
{
System
.
out
.
println
(
s
);
}
static
void
log
(
Exception
ex
)
{
ex
.
printStackTrace
(
System
.
out
);
}
}
test/javax/sound/sampled/FileWriter/AlawEncoderSync.java
0 → 100644
浏览文件 @
b5293c84
/**
* @test
* @bug 6938426
* @summary Tests that Alaw encoder works properly in multithreaded environment
* @author Alex Menkov
*/
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
javax.sound.sampled.AudioFormat
;
import
javax.sound.sampled.AudioInputStream
;
import
javax.sound.sampled.AudioSystem
;
public
class
AlawEncoderSync
{
static
final
int
THREAD_COUNT
=
20
;
static
final
AudioFormat
pcmFormat
=
new
AudioFormat
(
8000
f
,
16
,
2
,
true
,
false
);
static
final
int
STREAM_LENGTH
=
10
;
// in seconds
static
byte
[]
pcmBuffer
;
static
final
AudioFormat
alawFormat
=
new
AudioFormat
(
AudioFormat
.
Encoding
.
ALAW
,
8000
f
,
8
,
2
,
2
,
8000
f
,
false
);
static
final
ConversionThread
[]
threads
=
new
ConversionThread
[
THREAD_COUNT
];
public
static
void
main
(
String
[]
args
)
{
preparePCMBuffer
();
log
(
"pcmStream size: "
+
pcmBuffer
.
length
);
for
(
int
i
=
0
;
i
<
THREAD_COUNT
;
i
++)
{
threads
[
i
]
=
new
ConversionThread
(
i
);
threads
[
i
].
start
();
}
for
(
int
i
=
1
;
i
<
THREAD_COUNT
;
i
++)
{
try
{
threads
[
i
].
join
();
}
catch
(
InterruptedException
ex
)
{
log
(
"Main thread was interrupted, exiting."
);
return
;
}
}
int
failed
=
0
;
log
(
"comparing result arrays..."
);
for
(
int
i
=
1
;
i
<
THREAD_COUNT
;
i
++)
{
if
(!
Arrays
.
equals
(
threads
[
0
].
resultArray
,
threads
[
i
].
resultArray
))
{
failed
++;
log
(
"NOT equals: 0 and "
+
i
);
}
}
if
(
failed
>
0
)
{
throw
new
RuntimeException
(
"test FAILED"
);
}
log
(
"test PASSED."
);
}
static
void
preparePCMBuffer
()
{
pcmBuffer
=
new
byte
[
STREAM_LENGTH
*
(
int
)
pcmFormat
.
getSampleRate
()
*
(
pcmFormat
.
getSampleSizeInBits
()
/
8
)
*
pcmFormat
.
getChannels
()];
for
(
int
i
=
0
;
i
<
pcmBuffer
.
length
;
i
++)
{
pcmBuffer
[
i
]
=
(
byte
)(
Math
.
random
()
*
256.0
-
128.0
);
}
}
static
AudioInputStream
createPCMStream
()
{
InputStream
byteStream
=
new
ByteArrayInputStream
(
pcmBuffer
);
return
new
AudioInputStream
(
byteStream
,
pcmFormat
,
AudioSystem
.
NOT_SPECIFIED
);
}
static
class
ConversionThread
extends
Thread
{
public
final
int
num
;
public
byte
[]
resultArray
=
null
;
public
ConversionThread
(
int
num
)
{
this
.
num
=
num
;
}
@Override
public
void
run
()
{
log
(
"ConversionThread["
+
num
+
"] started."
);
try
{
InputStream
inStream
=
new
ByteArrayInputStream
(
pcmBuffer
);
AudioInputStream
pcmStream
=
new
AudioInputStream
(
inStream
,
pcmFormat
,
AudioSystem
.
NOT_SPECIFIED
);
AudioInputStream
alawStream
=
AudioSystem
.
getAudioInputStream
(
alawFormat
,
pcmStream
);
ByteArrayOutputStream
outStream
=
new
ByteArrayOutputStream
();
int
read
=
0
;
byte
[]
data
=
new
byte
[
4096
];
while
((
read
=
alawStream
.
read
(
data
))
!=
-
1
)
{
outStream
.
write
(
data
,
0
,
read
);
}
alawStream
.
close
();
resultArray
=
outStream
.
toByteArray
();
}
catch
(
Exception
ex
)
{
log
(
"ConversionThread["
+
num
+
"] exception:"
);
log
(
ex
);
}
log
(
"ConversionThread["
+
num
+
"] completed."
);
}
}
static
void
log
(
String
s
)
{
System
.
out
.
println
(
s
);
}
static
void
log
(
Exception
ex
)
{
ex
.
printStackTrace
(
System
.
out
);
}
}
test/javax/sound/sampled/FileWriter/WriterCloseInput.java
0 → 100644
浏览文件 @
b5293c84
/**
* @test
* @bug 7013521
* @summary AIFF/AU/WAVE writers close input audio stream
* @author Alex Menkov
*/
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
javax.sound.sampled.AudioFileFormat
;
import
javax.sound.sampled.AudioFormat
;
import
javax.sound.sampled.AudioInputStream
;
import
javax.sound.sampled.AudioSystem
;
public
class
WriterCloseInput
{
final
static
AudioFormat
audioFormat
=
new
AudioFormat
(
44100
f
,
16
,
2
,
true
,
true
);
//final static AudioFormat audioFormat = new AudioFormat(AudioFormat.Encoding.ULAW, 44100f, 8, 2, 2, 44100f, true);
final
static
int
frameLength
=
44100
*
2
;
// 2 seconds
final
static
byte
[]
dataBuffer
=
new
byte
[
frameLength
*
(
audioFormat
.
getSampleSizeInBits
()/
8
)
*
audioFormat
.
getChannels
()];
static
int
testTotal
=
0
;
static
int
testFailed
=
0
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
test
(
AudioFileFormat
.
Type
.
AIFF
);
test
(
AudioFileFormat
.
Type
.
AU
);
test
(
AudioFileFormat
.
Type
.
WAVE
);
if
(
testFailed
==
0
)
{
out
(
"All tests passed."
);
}
else
{
out
(
""
+
testFailed
+
" of "
+
testTotal
+
" tests FAILED."
);
System
.
out
.
flush
();
throw
new
RuntimeException
(
"Test FAILED."
);
}
}
static
void
test
(
AudioFileFormat
.
Type
fileType
)
{
test
(
fileType
,
frameLength
);
test
(
fileType
,
AudioSystem
.
NOT_SPECIFIED
);
}
static
void
test
(
AudioFileFormat
.
Type
fileType
,
int
length
)
{
test
(
fileType
,
length
,
false
);
test
(
fileType
,
length
,
true
);
}
static
void
test
(
AudioFileFormat
.
Type
fileType
,
int
length
,
boolean
isFile
)
{
testTotal
++;
out
(
"Testing fileType: "
+
fileType
+
", frameLength: "
+
(
length
>=
0
?
length
:
"unspecified"
)
+
", output: "
+
(
isFile
?
"File"
:
"OutputStream"
));
AudioInputStream
inStream
=
new
ThrowAfterCloseStream
(
new
ByteArrayInputStream
(
dataBuffer
),
audioFormat
,
length
);
AudioSystem
.
isFileTypeSupported
(
fileType
,
inStream
);
try
{
if
(
isFile
)
{
File
f
=
File
.
createTempFile
(
"WriterCloseInput"
+
testTotal
,
"tmp"
);
AudioSystem
.
write
(
inStream
,
fileType
,
f
);
f
.
delete
();
}
else
{
OutputStream
outStream
=
new
NullOutputStream
();
AudioSystem
.
write
(
inStream
,
fileType
,
outStream
);
}
}
catch
(
Exception
ex
)
{
// this is not failure
out
(
"SKIPPED (AudioSystem.write exception): "
+
ex
.
getMessage
());
//out(ex);
inStream
=
null
;
}
if
(
inStream
!=
null
)
{
try
{
// test if the stream is closed
inStream
.
available
();
out
(
"PASSED"
);
}
catch
(
IOException
ex
)
{
testFailed
++;
out
(
"FAILED: "
+
ex
.
getMessage
());
//out(ex);
}
}
out
(
""
);
}
static
class
ThrowAfterCloseStream
extends
AudioInputStream
{
private
boolean
closed
=
false
;
public
ThrowAfterCloseStream
(
InputStream
in
,
AudioFormat
format
,
long
length
)
{
super
(
in
,
format
,
length
);
}
@Override
public
void
close
()
{
closed
=
true
;
}
@Override
public
int
available
()
throws
IOException
{
if
(
closed
)
{
throw
new
IOException
(
"The stream has been closed"
);
}
return
1
;
}
}
static
class
NullOutputStream
extends
OutputStream
{
@Override
public
void
write
(
int
b
)
throws
IOException
{
// nop
}
}
static
void
out
(
String
s
)
{
System
.
out
.
println
(
s
);
}
static
void
out
(
Exception
ex
)
{
ex
.
printStackTrace
(
System
.
out
);
}
}
test/javax/swing/regtesthelpers/Util.java
0 → 100644
浏览文件 @
b5293c84
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
/**
* <p>This class contains utilities useful for regression testing.
* <p>When using jtreg you would include this class via something like:
* <pre>
*
* @library ../../regtesthelpers
* @build Util
* </pre>
*/
public
class
Util
{
/**
* Convert a rectangle from coordinate system of Component c to
* screen coordinate system.
*
* @param r a non-null Rectangle
* @param c a Component whose coordinate system is used for conversion
*/
public
static
void
convertRectToScreen
(
Rectangle
r
,
Component
c
)
{
Point
p
=
new
Point
(
r
.
x
,
r
.
y
);
SwingUtilities
.
convertPointToScreen
(
p
,
c
);
r
.
x
=
p
.
x
;
r
.
y
=
p
.
y
;
}
/**
* Compares two bufferedImages pixel-by-pixel.
* return true if all pixels in the two areas are identical
*/
public
static
boolean
compareBufferedImages
(
BufferedImage
bufferedImage0
,
BufferedImage
bufferedImage1
)
{
int
width
=
bufferedImage0
.
getWidth
();
int
height
=
bufferedImage0
.
getHeight
();
if
(
width
!=
bufferedImage1
.
getWidth
()
||
height
!=
bufferedImage1
.
getHeight
())
{
return
false
;
}
for
(
int
y
=
0
;
y
<
height
;
y
++)
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
if
(
bufferedImage0
.
getRGB
(
x
,
y
)
!=
bufferedImage1
.
getRGB
(
x
,
y
))
{
return
false
;
}
}
}
return
true
;
}
}
test/javax/swing/text/CSSBorder/6796710/bug6796710.java
0 → 100644
浏览文件 @
b5293c84
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6796710
* @summary Html content in JEditorPane is overlapping on swing components while resizing the application.
* @library ../../../regtesthelpers
* @build Util
* @author Pavel Porvatov
@run main bug6796710
*/
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
public
class
bug6796710
{
// The page is inlined because we want to be sure that the JEditorPane filled synchronously
public
static
final
String
TEXT
=
"<html>"
+
"<body>"
+
"<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\">"
+
" <tbody>"
+
" <tr>"
+
" <td>Col1</td>"
+
" <td>Col2</td>"
+
" <td>Col3</td>"
+
" </tr>"
+
" <tr>"
+
" <td>1. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>"
+
" <td>2. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>"
+
" <td>3. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>"
+
" </tr>"
+
" </tbody>"
+
"</table>"
+
"</body>"
+
"</html>"
;
private
static
Robot
robot
;
private
static
JFrame
frame
;
private
static
JPanel
pnBottom
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
robot
=
new
Robot
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
frame
=
new
JFrame
();
pnBottom
=
new
JPanel
();
pnBottom
.
add
(
new
JLabel
(
"Some label"
));
pnBottom
.
add
(
new
JButton
(
"A button"
));
JEditorPane
editorPane
=
new
JEditorPane
();
editorPane
.
setContentType
(
"text/html"
);
editorPane
.
setText
(
TEXT
);
editorPane
.
setEditable
(
false
);
JPanel
pnContent
=
new
JPanel
(
new
BorderLayout
());
pnContent
.
add
(
new
JScrollPane
(
editorPane
),
BorderLayout
.
CENTER
);
pnContent
.
add
(
pnBottom
,
BorderLayout
.
SOUTH
);
frame
.
setContentPane
(
pnContent
);
frame
.
setSize
(
400
,
600
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
setVisible
(
true
);
}
});
robot
.
waitForIdle
();
BufferedImage
bufferedImage
=
getPnBottomImage
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
frame
.
setSize
(
400
,
150
);
}
});
robot
.
waitForIdle
();
if
(!
Util
.
compareBufferedImages
(
bufferedImage
,
getPnBottomImage
()))
{
throw
new
RuntimeException
(
"The test failed"
);
}
System
.
out
.
println
(
"The test bug6796710 passed."
);
}
private
static
BufferedImage
getPnBottomImage
()
{
Rectangle
rect
=
pnBottom
.
getBounds
();
Util
.
convertRectToScreen
(
rect
,
pnBottom
.
getParent
());
return
robot
.
createScreenCapture
(
rect
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录