Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7b3dae29
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看板
提交
7b3dae29
编写于
2月 19, 2013
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
a9c98dbd
6f248283
变更
40
隐藏空白更改
内联
并排
Showing
40 changed file
with
1147 addition
and
168 deletion
+1147
-168
.hgtags
.hgtags
+1
-0
src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
+29
-7
src/macosx/lib/flavormap.properties
src/macosx/lib/flavormap.properties
+4
-2
src/macosx/native/jobjc/src/core/native/SEL.m
src/macosx/native/jobjc/src/core/native/SEL.m
+1
-1
src/macosx/native/sun/awt/CPrinterJob.m
src/macosx/native/sun/awt/CPrinterJob.m
+0
-25
src/share/classes/java/awt/EventDispatchThread.java
src/share/classes/java/awt/EventDispatchThread.java
+0
-28
src/share/classes/javax/swing/JMenuBar.java
src/share/classes/javax/swing/JMenuBar.java
+8
-1
src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
...share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
+45
-18
src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
...hare/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
+2
-1
src/share/classes/sun/awt/im/CompositionAreaHandler.java
src/share/classes/sun/awt/im/CompositionAreaHandler.java
+9
-6
src/share/native/sun/awt/image/jpeg/imageioJPEG.c
src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+5
-0
src/share/native/sun/awt/medialib/mlib_ImageConv.h
src/share/native/sun/awt/medialib/mlib_ImageConv.h
+10
-0
src/share/native/sun/awt/medialib/mlib_ImageConvMxN_ext.c
src/share/native/sun/awt/medialib/mlib_ImageConvMxN_ext.c
+3
-1
src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c
src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c
+11
-5
src/share/native/sun/awt/medialib/mlib_ImageConv_16nw.c
src/share/native/sun/awt/medialib/mlib_ImageConv_16nw.c
+11
-5
src/share/native/sun/awt/medialib/mlib_ImageConv_32nw.c
src/share/native/sun/awt/medialib/mlib_ImageConv_32nw.c
+11
-5
src/share/native/sun/awt/medialib/mlib_ImageConv_8ext.c
src/share/native/sun/awt/medialib/mlib_ImageConv_8ext.c
+11
-5
src/share/native/sun/awt/medialib/mlib_ImageConv_8nw.c
src/share/native/sun/awt/medialib/mlib_ImageConv_8nw.c
+11
-5
src/share/native/sun/awt/medialib/mlib_ImageConv_u16ext.c
src/share/native/sun/awt/medialib/mlib_ImageConv_u16ext.c
+11
-5
src/share/native/sun/awt/medialib/mlib_ImageConv_u16nw.c
src/share/native/sun/awt/medialib/mlib_ImageConv_u16nw.c
+11
-5
src/share/native/sun/awt/medialib/mlib_ImageCreate.c
src/share/native/sun/awt/medialib/mlib_ImageCreate.c
+2
-2
src/share/native/sun/awt/medialib/mlib_c_ImageConv.h
src/share/native/sun/awt/medialib/mlib_c_ImageConv.h
+10
-0
src/solaris/classes/sun/awt/X11/XIconWindow.java
src/solaris/classes/sun/awt/X11/XIconWindow.java
+1
-1
src/solaris/classes/sun/awt/X11InputMethod.java
src/solaris/classes/sun/awt/X11InputMethod.java
+7
-6
src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
+8
-7
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/AbsoluteComponentCenterCalculator.java
...issedHtmlAndRtfBug/AbsoluteComponentCenterCalculator.java
+14
-16
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/DataFlavorSearcher.java
...wt/DataFlavor/MissedHtmlAndRtfBug/DataFlavorSearcher.java
+47
-0
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/InterprocessMessages.java
.../DataFlavor/MissedHtmlAndRtfBug/InterprocessMessages.java
+28
-0
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html
...t/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html
+27
-0
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java
...t/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java
+205
-0
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MyTransferable.java
...va/awt/DataFlavor/MissedHtmlAndRtfBug/MyTransferable.java
+62
-0
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/NextFramePositionCalculator.java
...avor/MissedHtmlAndRtfBug/NextFramePositionCalculator.java
+20
-0
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/SourcePanel.java
.../java/awt/DataFlavor/MissedHtmlAndRtfBug/SourcePanel.java
+26
-0
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/TargetPanel.java
.../java/awt/DataFlavor/MissedHtmlAndRtfBug/TargetPanel.java
+83
-0
test/java/awt/Frame/WindowDragTest/WindowDragTest.java
test/java/awt/Frame/WindowDragTest/WindowDragTest.java
+3
-2
test/java/awt/im/memoryleak/InputContextMemoryLeakTest.java
test/java/awt/im/memoryleak/InputContextMemoryLeakTest.java
+112
-0
test/java/awt/regtesthelpers/Util.java
test/java/awt/regtesthelpers/Util.java
+7
-0
test/javax/swing/JComboBox/4199622/bug4199622.java
test/javax/swing/JComboBox/4199622/bug4199622.java
+243
-0
test/javax/swing/JLabel/6596966/bug6596966.java
test/javax/swing/JLabel/6596966/bug6596966.java
+16
-8
test/javax/swing/regtesthelpers/Util.java
test/javax/swing/regtesthelpers/Util.java
+32
-1
未找到文件。
.hgtags
浏览文件 @
7b3dae29
...
...
@@ -198,3 +198,4 @@ a996b57e554198f4592a5f3c30f2f9f4075e545d jdk8-b70
57d5d954462831ac353a1f40d3bb05ddb4620952 jdk8-b74
4a67fdb752b7d6329d9be9c28d3f9d6cf7eb9a3c jdk8-b75
3a263052866137b645ab86498a43693ff5c19e69 jdk8-b76
b2fc8e31cecc35b76188e821d4c5dc0e0b74ac24 jdk8-b77
src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
浏览文件 @
7b3dae29
...
...
@@ -30,6 +30,8 @@ import java.awt.*;
import
java.awt.geom.Rectangle2D
;
import
java.awt.image.BufferedImage
;
import
java.awt.print.*
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
javax.print.*
;
import
javax.print.attribute.PrintRequestAttributeSet
;
...
...
@@ -47,6 +49,8 @@ public class CPrinterJob extends RasterPrinterJob {
private
static
String
sShouldNotReachHere
=
"Should not reach here."
;
private
volatile
SecondaryLoop
printingLoop
;
private
boolean
noDefaultPrinter
=
false
;
private
static
Font
defaultFont
;
...
...
@@ -160,11 +164,22 @@ public class CPrinterJob extends RasterPrinterJob {
volatile
boolean
onEventThread
;
@Override
protected
void
cancelDoc
()
throws
PrinterAbortException
{
super
.
cancelDoc
();
if
(
printingLoop
!=
null
)
{
printingLoop
.
exit
();
}
}
private
void
completePrintLoop
()
{
Runnable
r
=
new
Runnable
()
{
public
void
run
()
{
synchronized
(
this
)
{
performingPrinting
=
false
;
}
if
(
printingLoop
!=
null
)
{
printingLoop
.
exit
();
}
}};
if
(
onEventThread
)
{
...
...
@@ -219,17 +234,21 @@ public class CPrinterJob extends RasterPrinterJob {
onEventThread
=
true
;
printingLoop
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
SecondaryLoop
>()
{
@Override
public
SecondaryLoop
run
()
{
return
Toolkit
.
getDefaultToolkit
()
.
getSystemEventQueue
()
.
createSecondaryLoop
();
}
});
try
{
// Fire off the print rendering loop on the AppKit thread, and don't have
// it wait and block this thread.
if
(
printLoop
(
false
,
firstPage
,
lastPage
))
{
// Fire off the EventConditional that will what until the condition is met,
// but will still process AWTEvent's as they occur.
new
EventDispatchAccess
()
{
public
boolean
evaluate
()
{
return
performingPrinting
;
}
}.
pumpEventsAndWait
();
// Start a secondary loop on EDT until printing operation is finished or cancelled
printingLoop
.
enter
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -253,6 +272,9 @@ public class CPrinterJob extends RasterPrinterJob {
performingPrinting
=
false
;
notify
();
}
if
(
printingLoop
!=
null
)
{
printingLoop
.
exit
();
}
}
// Normalize the collated, # copies, numPages, first/last pages. Need to
...
...
src/macosx/lib/flavormap.properties
浏览文件 @
7b3dae29
#
# This properties file is used to initialize the default
# java.awt.datatransfer.SystemFlavorMap. It contains the
X11
platform-specific,
# default mappings between common
X11
selection atoms and platform-independent
# java.awt.datatransfer.SystemFlavorMap. It contains the
Mac OS X
platform-specific,
# default mappings between common
Mac OS X
selection atoms and platform-independent
# MIME type strings, which will be converted into
# java.awt.datatransfer.DataFlavors.
#
...
...
@@ -76,3 +76,5 @@ FILE_NAME=application/x-java-file-list;class=java.util.List
text/uri-list=application/x-java-file-list;class=java.util.List
PNG=image/x-java-image;class=java.awt.Image
JFIF=image/x-java-image;class=java.awt.Image
RICH_TEXT=text/rtf
HTML=text/html;charset=utf-8;eoln="
\r\n
";terminators=1
src/macosx/native/jobjc/src/core/native/SEL.m
浏览文件 @
7b3dae29
...
...
@@ -34,7 +34,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_jobjc_SEL_getSelectorPtr
const
char
*
selNameAsChars
=
(*env)->GetStringUTFChars(env, selName, JNI_FALSE);
const SEL sel = sel_registerName(selNameAsChars);
(*env)->ReleaseStringUTFChars(env, selName, selNameAsChars);
return ptr_to_jlong(sel);
return ptr_to_jlong(
(void*)
sel);
}
JNIEXPORT jstring JNICALL Java_com_apple_jobjc_SEL_getSelectorName
...
...
src/macosx/native/sun/awt/CPrinterJob.m
浏览文件 @
7b3dae29
...
...
@@ -383,31 +383,6 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
}
}
/*
* Class: sun_lwawt_macosx_EventDispatchAccess
* Method: pumpEventsAndWait
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_EventDispatchAccess_pumpEventsAndWait
(JNIEnv *env, jobject eda)
{
static JNF_CLASS_CACHE(jc_Thread, "java/lang/Thread");
static JNF_STATIC_MEMBER_CACHE(jm_currentThread, jc_Thread, "currentThread", "()Ljava/lang/Thread;");
static JNF_CLASS_CACHE(jc_EventDispatchThread, "java/awt/EventDispatchThread");
static JNF_MEMBER_CACHE(jm_macosxGetConditional, jc_EventDispatchThread, "_macosxGetConditional", "(Ljava/lang/Object;)Ljava/awt/Conditional;");
static JNF_MEMBER_CACHE(jm_pumpEvents, jc_EventDispatchThread, "pumpEvents", "(Ljava/awt/Conditional;)V");
JNF_COCOA_DURING(env);
jobject thread = JNFCallStaticObjectMethod(env, jm_currentThread);
jobject conditional = JNFCallObjectMethod(env, thread, jm_macosxGetConditional, eda);
if (conditional != NULL) {
JNFCallVoidMethod(env, thread, jm_pumpEvents, conditional);
}
JNF_COCOA_HANDLE(env);
}
/*
* Class: sun_lwawt_macosx_CPrinterJob
* Method: abortDoc
...
...
src/share/classes/java/awt/EventDispatchThread.java
浏览文件 @
7b3dae29
...
...
@@ -107,34 +107,6 @@ class EventDispatchThread extends Thread {
}
}
// MacOSX change:
// This was added because this class (and java.awt.Conditional) are package private.
// There are certain instances where classes in other packages need to block the
// AWTEventQueue while still allowing it to process events. This uses reflection
// to call back into the caller in order to remove dependencies.
//
// NOTE: This uses reflection in its implementation, so it is not for performance critical code.
//
// cond is an instance of sun.lwawt.macosx.EventDispatchAccess
//
private
Conditional
_macosxGetConditional
(
final
Object
cond
)
{
try
{
return
new
Conditional
()
{
final
Method
evaluateMethod
=
Class
.
forName
(
"sun.lwawt.macosx.EventDispatchAccess"
).
getMethod
(
"evaluate"
,
null
);
public
boolean
evaluate
()
{
try
{
return
((
Boolean
)
evaluateMethod
.
invoke
(
cond
,
null
)).
booleanValue
();
}
catch
(
Exception
e
)
{
return
false
;
}
}
};
}
catch
(
Exception
e
)
{
return
new
Conditional
()
{
public
boolean
evaluate
()
{
return
false
;
}
};
}
}
void
pumpEvents
(
Conditional
cond
)
{
pumpEvents
(
ANY_EVENT
,
cond
);
}
...
...
src/share/classes/javax/swing/JMenuBar.java
浏览文件 @
7b3dae29
...
...
@@ -70,7 +70,14 @@ import javax.accessibility.*;
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* <p>
* <strong>Warning:</strong>
* By default, pressing the Tab key does not transfer focus from a <code>
* JMenuBar</code> which is added to a container together with other Swing
* components, because the <code>focusTraversalKeysEnabled</code> property
* of <code>JMenuBar</code> is set to <code>false</code>. To resolve this,
* you should call the <code>JMenuBar.setFocusTraversalKeysEnabled(true)</code>
* method.
* @beaninfo
* attribute: isContainer true
* description: A container for holding and displaying menus.
...
...
src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
浏览文件 @
7b3dae29
/*
* Copyright (c) 1997, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -1120,7 +1120,9 @@ public class BasicComboBoxUI extends ComboBoxUI {
listBox
.
setSelectedIndex
(
si
+
1
);
listBox
.
ensureIndexIsVisible
(
si
+
1
);
if
(
!
isTableCellEditor
)
{
comboBox
.
setSelectedIndex
(
si
+
1
);
if
(!(
UIManager
.
getBoolean
(
"ComboBox.noActionOnKeyNavigation"
)
&&
comboBox
.
isPopupVisible
()))
{
comboBox
.
setSelectedIndex
(
si
+
1
);
}
}
comboBox
.
repaint
();
}
...
...
@@ -1144,7 +1146,9 @@ public class BasicComboBoxUI extends ComboBoxUI {
listBox
.
setSelectedIndex
(
si
-
1
);
listBox
.
ensureIndexIsVisible
(
si
-
1
);
if
(
!
isTableCellEditor
)
{
comboBox
.
setSelectedIndex
(
si
-
1
);
if
(!(
UIManager
.
getBoolean
(
"ComboBox.noActionOnKeyNavigation"
)
&&
comboBox
.
isPopupVisible
()))
{
comboBox
.
setSelectedIndex
(
si
-
1
);
}
}
comboBox
.
repaint
();
}
...
...
@@ -1490,7 +1494,13 @@ public class BasicComboBoxUI extends ComboBoxUI {
key
==
HOME
||
key
==
END
)
{
int
index
=
getNextIndex
(
comboBox
,
key
);
if
(
index
>=
0
&&
index
<
comboBox
.
getItemCount
())
{
comboBox
.
setSelectedIndex
(
index
);
if
(
UIManager
.
getBoolean
(
"ComboBox.noActionOnKeyNavigation"
)
&&
comboBox
.
isPopupVisible
())
{
ui
.
listBox
.
setSelectedIndex
(
index
);
ui
.
listBox
.
ensureIndexIsVisible
(
index
);
comboBox
.
repaint
();
}
else
{
comboBox
.
setSelectedIndex
(
index
);
}
}
}
else
if
(
key
==
DOWN
)
{
...
...
@@ -1558,22 +1568,33 @@ public class BasicComboBoxUI extends ComboBoxUI {
else
if
(
key
==
ENTER
)
{
if
(
comboBox
.
isPopupVisible
())
{
// Forces the selection of the list item
boolean
isEnterSelectablePopup
=
UIManager
.
getBoolean
(
"ComboBox.isEnterSelectablePopup"
);
if
(!
comboBox
.
isEditable
()
||
isEnterSelectablePopup
||
ui
.
isTableCellEditor
)
{
// If ComboBox.noActionOnKeyNavigation is set,
// forse selection of list item
if
(
UIManager
.
getBoolean
(
"ComboBox.noActionOnKeyNavigation"
))
{
Object
listItem
=
ui
.
popup
.
getList
().
getSelectedValue
();
if
(
listItem
!=
null
)
{
// Use the selected value from popup
// to set the selected item in combo box,
// but ensure before that JComboBox.actionPerformed()
// won't use editor's value to set the selected item
comboBox
.
getEditor
().
setItem
(
listItem
);
comboBox
.
setSelectedItem
(
listItem
);
}
comboBox
.
setPopupVisible
(
false
);
}
else
{
// Forces the selection of the list item
boolean
isEnterSelectablePopup
=
UIManager
.
getBoolean
(
"ComboBox.isEnterSelectablePopup"
);
if
(!
comboBox
.
isEditable
()
||
isEnterSelectablePopup
||
ui
.
isTableCellEditor
)
{
Object
listItem
=
ui
.
popup
.
getList
().
getSelectedValue
();
if
(
listItem
!=
null
)
{
// Use the selected value from popup
// to set the selected item in combo box,
// but ensure before that JComboBox.actionPerformed()
// won't use editor's value to set the selected item
comboBox
.
getEditor
().
setItem
(
listItem
);
comboBox
.
setSelectedItem
(
listItem
);
}
}
comboBox
.
setPopupVisible
(
false
);
}
comboBox
.
setPopupVisible
(
false
);
}
else
{
// Hide combo box if it is a table cell editor
...
...
@@ -1604,14 +1625,20 @@ public class BasicComboBoxUI extends ComboBoxUI {
}
private
int
getNextIndex
(
JComboBox
comboBox
,
String
key
)
{
int
listHeight
=
comboBox
.
getMaximumRowCount
();
int
selectedIndex
=
comboBox
.
getSelectedIndex
();
if
(
UIManager
.
getBoolean
(
"ComboBox.noActionOnKeyNavigation"
)
&&
(
comboBox
.
getUI
()
instanceof
BasicComboBoxUI
))
{
selectedIndex
=
((
BasicComboBoxUI
)
comboBox
.
getUI
()).
listBox
.
getSelectedIndex
();
}
if
(
key
==
PAGE_UP
)
{
int
listHeight
=
comboBox
.
getMaximumRowCount
();
int
index
=
comboBox
.
getSelectedIndex
()
-
listHeight
;
int
index
=
selectedIndex
-
listHeight
;
return
(
index
<
0
?
0
:
index
);
}
else
if
(
key
==
PAGE_DOWN
)
{
int
listHeight
=
comboBox
.
getMaximumRowCount
();
int
index
=
comboBox
.
getSelectedIndex
()
+
listHeight
;
int
index
=
selectedIndex
+
listHeight
;
int
max
=
comboBox
.
getItemCount
();
return
(
index
<
max
?
index:
max
-
1
);
}
...
...
src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
浏览文件 @
7b3dae29
/*
* Copyright (c) 1997, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -861,6 +861,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab
"END"
,
"endPassThrough"
,
"ENTER"
,
"enterPressed"
}),
"ComboBox.noActionOnKeyNavigation"
,
Boolean
.
FALSE
,
// *** FileChooser
...
...
src/share/classes/sun/awt/im/CompositionAreaHandler.java
浏览文件 @
7b3dae29
...
...
@@ -33,6 +33,7 @@ import java.awt.event.InputMethodListener;
import
java.awt.font.TextAttribute
;
import
java.awt.font.TextHitInfo
;
import
java.awt.im.InputMethodRequests
;
import
java.lang.ref.WeakReference
;
import
java.text.AttributedCharacterIterator
;
import
java.text.AttributedCharacterIterator.Attribute
;
import
java.text.AttributedString
;
...
...
@@ -55,7 +56,7 @@ class CompositionAreaHandler implements InputMethodListener,
private
AttributedCharacterIterator
composedText
;
private
TextHitInfo
caret
=
null
;
private
Component
clientComponent
=
null
;
private
WeakReference
<
Component
>
clientComponent
=
new
WeakReference
<>(
null
)
;
private
InputMethodContext
inputMethodContext
;
/**
...
...
@@ -76,8 +77,9 @@ class CompositionAreaHandler implements InputMethodListener,
}
// If the client component is an active client using below-the-spot style, then
// make the composition window undecorated without a title bar.
if
(
clientComponent
!=
null
){
InputMethodRequests
req
=
clientComponent
.
getInputMethodRequests
();
Component
client
=
clientComponent
.
get
();
if
(
client
!=
null
){
InputMethodRequests
req
=
client
.
getInputMethodRequests
();
if
(
req
!=
null
&&
inputMethodContext
.
useBelowTheSpotInput
())
{
setCompositionAreaUndecorated
(
true
);
}
...
...
@@ -86,7 +88,7 @@ class CompositionAreaHandler implements InputMethodListener,
}
void
setClientComponent
(
Component
clientComponent
)
{
this
.
clientComponent
=
clientComponent
;
this
.
clientComponent
=
new
WeakReference
<>(
clientComponent
)
;
}
/**
...
...
@@ -256,8 +258,9 @@ class CompositionAreaHandler implements InputMethodListener,
* the composed text are forwarded to the client component.
*/
InputMethodRequests
getClientInputMethodRequests
()
{
if
(
clientComponent
!=
null
)
{
return
clientComponent
.
getInputMethodRequests
();
Component
client
=
clientComponent
.
get
();
if
(
client
!=
null
)
{
return
client
.
getInputMethodRequests
();
}
return
null
;
...
...
src/share/native/sun/awt/image/jpeg/imageioJPEG.c
浏览文件 @
7b3dae29
...
...
@@ -2694,6 +2694,11 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage
scale
[
i
]
=
(
UINT8
*
)
malloc
((
maxBandValue
+
1
)
*
sizeof
(
UINT8
));
if
(
scale
[
i
]
==
NULL
)
{
// Cleanup before throwing an out of memory exception
for
(
j
=
0
;
j
<
i
;
j
++
)
{
free
(
scale
[
j
]);
}
free
(
scale
);
JNU_ThrowByName
(
env
,
"java/lang/OutOfMemoryError"
,
"Writing JPEG Stream"
);
return
JNI_FALSE
;
...
...
src/share/native/sun/awt/medialib/mlib_ImageConv.h
浏览文件 @
7b3dae29
...
...
@@ -31,6 +31,16 @@
extern
"C"
{
#endif
/* __cplusplus */
// Shared macro defined for cleanup of allocated memory.
#ifndef FREE_AND_RETURN_STATUS
#define FREE_AND_RETURN_STATUS \
{ \
if (pbuff != buff) mlib_free(pbuff); \
if (k != akernel) mlib_free(k); \
return status; \
}
#endif
/* FREE_AND_RETURN_STATUS */
void
mlib_ImageXor80_aa
(
mlib_u8
*
dl
,
mlib_s32
wid
,
mlib_s32
hgt
,
...
...
src/share/native/sun/awt/medialib/mlib_ImageConvMxN_ext.c
浏览文件 @
7b3dae29
...
...
@@ -253,8 +253,10 @@ mlib_status mlib_convMxNext_s32(mlib_image *dst,
if
(
mn
>
256
)
{
dkernel
=
mlib_malloc
(
mn
*
sizeof
(
mlib_d64
));
if
(
dkernel
==
NULL
)
if
(
dkernel
==
NULL
)
{
if
(
dsa
!=
dspace
)
mlib_free
(
dsa
);
return
MLIB_FAILURE
;
}
}
while
(
scale
>
30
)
{
...
...
src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c
浏览文件 @
7b3dae29
...
...
@@ -1884,6 +1884,8 @@ mlib_status CONV_FUNC_MxN
mlib_s32
nchannel
,
chan1
,
chan2
;
mlib_s32
i
,
j
,
c
,
swid
;
d64_2x32
dd
;
mlib_status
status
=
MLIB_SUCCESS
;
GET_SRC_DST_PARAMETERS
(
DTYPE
);
if
(
scale
>
30
)
{
...
...
@@ -1905,7 +1907,10 @@ mlib_status CONV_FUNC_MxN
k
[
i
]
=
kernel
[
i
]
*
fscale
;
}
if
(
m
==
1
)
return
mlib_ImageConv1xN_ext
(
dst
,
src
,
k
,
n
,
dy_t
,
dy_b
,
cmask
);
if
(
m
==
1
)
{
status
=
mlib_ImageConv1xN_ext
(
dst
,
src
,
k
,
n
,
dy_t
,
dy_b
,
cmask
);
FREE_AND_RETURN_STATUS
;
}
swid
=
wid
+
(
m
-
1
);
...
...
@@ -1914,7 +1919,10 @@ mlib_status CONV_FUNC_MxN
if
((
bsize
>
BUFF_SIZE
)
||
(
n
>
MAX_N
))
{
pbuff
=
mlib_malloc
(
sizeof
(
FTYPE
)
*
bsize
+
sizeof
(
FTYPE
*
)
*
2
*
(
n
+
1
));
if
(
pbuff
==
NULL
)
return
MLIB_FAILURE
;
if
(
pbuff
==
NULL
)
{
status
=
MLIB_FAILURE
;
FREE_AND_RETURN_STATUS
;
}
buffs
=
(
FTYPE
**
)(
pbuff
+
bsize
);
}
...
...
@@ -2318,9 +2326,7 @@ mlib_status CONV_FUNC_MxN
}
}
if
(
pbuff
!=
buff
)
mlib_free
(
pbuff
);
return
MLIB_SUCCESS
;
FREE_AND_RETURN_STATUS
;
}
/***************************************************************/
...
...
src/share/native/sun/awt/medialib/mlib_ImageConv_16nw.c
浏览文件 @
7b3dae29
...
...
@@ -1651,6 +1651,8 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
DEF_VARS
(
DTYPE
);
mlib_s32
chan2
;
mlib_s32
*
buffo
,
*
buffi
;
mlib_status
status
=
MLIB_SUCCESS
;
GET_SRC_DST_PARAMETERS
(
DTYPE
);
if
(
scale
>
30
)
{
...
...
@@ -1672,14 +1674,20 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
k
[
i
]
=
kernel
[
i
]
*
fscale
;
}
if
(
m
==
1
)
return
mlib_ImageConv1xN
(
dst
,
src
,
k
,
n
,
dn
,
cmask
);
if
(
m
==
1
)
{
status
=
mlib_ImageConv1xN
(
dst
,
src
,
k
,
n
,
dn
,
cmask
);
FREE_AND_RETURN_STATUS
;
}
bsize
=
(
n
+
3
)
*
wid
;
if
((
bsize
>
BUFF_SIZE
)
||
(
n
>
MAX_N
))
{
pbuff
=
mlib_malloc
(
sizeof
(
FTYPE
)
*
bsize
+
sizeof
(
FTYPE
*
)
*
2
*
(
n
+
1
));
if
(
pbuff
==
NULL
)
return
MLIB_FAILURE
;
if
(
pbuff
==
NULL
)
{
status
=
MLIB_FAILURE
;
FREE_AND_RETURN_STATUS
;
}
buffs
=
(
FTYPE
**
)(
pbuff
+
bsize
);
}
...
...
@@ -2033,9 +2041,7 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
}
}
if
(
pbuff
!=
buff
)
mlib_free
(
pbuff
);
return
MLIB_SUCCESS
;
FREE_AND_RETURN_STATUS
;
}
/***************************************************************/
...
...
src/share/native/sun/awt/medialib/mlib_ImageConv_32nw.c
浏览文件 @
7b3dae29
...
...
@@ -1160,6 +1160,8 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
DEF_VARS_MxN
(
mlib_s32
);
mlib_s32
chan2
=
chan1
+
chan1
;
mlib_status
status
=
MLIB_SUCCESS
;
if
(
scale
>
30
)
{
fscale
*=
1
.
0
/
(
1
<<
30
);
scale
-=
30
;
...
...
@@ -1179,14 +1181,20 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
k
[
i
]
=
kernel
[
i
]
*
fscale
;
}
if
(
m
==
1
)
return
mlib_ImageConv1xN
(
dst
,
src
,
k
,
n
,
dn
,
cmask
);
if
(
m
==
1
)
{
status
=
mlib_ImageConv1xN
(
dst
,
src
,
k
,
n
,
dn
,
cmask
);
FREE_AND_RETURN_STATUS
;
}
bsize
=
(
n
+
2
)
*
wid
;
if
((
bsize
>
BUFF_SIZE
)
||
(
n
>
MAX_N
))
{
pbuff
=
mlib_malloc
(
sizeof
(
mlib_d64
)
*
bsize
+
sizeof
(
mlib_d64
*
)
*
2
*
(
n
+
1
));
if
(
pbuff
==
NULL
)
return
MLIB_FAILURE
;
if
(
pbuff
==
NULL
)
{
status
=
MLIB_FAILURE
;
FREE_AND_RETURN_STATUS
;
}
buffs
=
(
mlib_d64
**
)(
pbuff
+
bsize
);
}
...
...
@@ -1531,9 +1539,7 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
}
}
if
(
pbuff
!=
buff
)
mlib_free
(
pbuff
);
return
MLIB_SUCCESS
;
FREE_AND_RETURN_STATUS
;
}
/***************************************************************/
src/share/native/sun/awt/medialib/mlib_ImageConv_8ext.c
浏览文件 @
7b3dae29
...
...
@@ -1884,6 +1884,8 @@ mlib_status CONV_FUNC_MxN
mlib_s32
nchannel
,
chan1
,
chan2
;
mlib_s32
i
,
j
,
c
,
swid
;
d64_2x32
dd
;
mlib_status
status
=
MLIB_SUCCESS
;
GET_SRC_DST_PARAMETERS
(
DTYPE
);
if
(
scale
>
30
)
{
...
...
@@ -1905,7 +1907,10 @@ mlib_status CONV_FUNC_MxN
k
[
i
]
=
kernel
[
i
]
*
fscale
;
}
if
(
m
==
1
)
return
mlib_ImageConv1xN_ext
(
dst
,
src
,
k
,
n
,
dy_t
,
dy_b
,
cmask
);
if
(
m
==
1
)
{
status
=
mlib_ImageConv1xN_ext
(
dst
,
src
,
k
,
n
,
dy_t
,
dy_b
,
cmask
);
FREE_AND_RETURN_STATUS
;
}
swid
=
wid
+
(
m
-
1
);
...
...
@@ -1914,7 +1919,10 @@ mlib_status CONV_FUNC_MxN
if
((
bsize
>
BUFF_SIZE
)
||
(
n
>
MAX_N
))
{
pbuff
=
mlib_malloc
(
sizeof
(
FTYPE
)
*
bsize
+
sizeof
(
FTYPE
*
)
*
2
*
(
n
+
1
));
if
(
pbuff
==
NULL
)
return
MLIB_FAILURE
;
if
(
pbuff
==
NULL
)
{
status
=
MLIB_FAILURE
;
FREE_AND_RETURN_STATUS
;
}
buffs
=
(
FTYPE
**
)(
pbuff
+
bsize
);
}
...
...
@@ -2318,9 +2326,7 @@ mlib_status CONV_FUNC_MxN
}
}
if
(
pbuff
!=
buff
)
mlib_free
(
pbuff
);
return
MLIB_SUCCESS
;
FREE_AND_RETURN_STATUS
;
}
/***************************************************************/
...
...
src/share/native/sun/awt/medialib/mlib_ImageConv_8nw.c
浏览文件 @
7b3dae29
...
...
@@ -1652,6 +1652,8 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
DEF_VARS
(
DTYPE
);
mlib_s32
chan2
;
mlib_s32
*
buffo
,
*
buffi
;
mlib_status
status
=
MLIB_SUCCESS
;
GET_SRC_DST_PARAMETERS
(
DTYPE
);
if
(
scale
>
30
)
{
...
...
@@ -1673,14 +1675,20 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
k
[
i
]
=
kernel
[
i
]
*
fscale
;
}
if
(
m
==
1
)
return
mlib_ImageConv1xN
(
dst
,
src
,
k
,
n
,
dn
,
cmask
);
if
(
m
==
1
)
{
status
=
mlib_ImageConv1xN
(
dst
,
src
,
k
,
n
,
dn
,
cmask
);
FREE_AND_RETURN_STATUS
;
}
bsize
=
(
n
+
3
)
*
wid
;
if
((
bsize
>
BUFF_SIZE
)
||
(
n
>
MAX_N
))
{
pbuff
=
mlib_malloc
(
sizeof
(
FTYPE
)
*
bsize
+
sizeof
(
FTYPE
*
)
*
2
*
(
n
+
1
));
if
(
pbuff
==
NULL
)
return
MLIB_FAILURE
;
if
(
pbuff
==
NULL
)
{
status
=
MLIB_FAILURE
;
FREE_AND_RETURN_STATUS
;
}
buffs
=
(
FTYPE
**
)(
pbuff
+
bsize
);
}
...
...
@@ -2034,9 +2042,7 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
}
}
if
(
pbuff
!=
buff
)
mlib_free
(
pbuff
);
return
MLIB_SUCCESS
;
FREE_AND_RETURN_STATUS
;
}
/***************************************************************/
...
...
src/share/native/sun/awt/medialib/mlib_ImageConv_u16ext.c
浏览文件 @
7b3dae29
...
...
@@ -1884,6 +1884,8 @@ mlib_status CONV_FUNC_MxN
mlib_s32
nchannel
,
chan1
,
chan2
;
mlib_s32
i
,
j
,
c
,
swid
;
d64_2x32
dd
;
mlib_status
status
=
MLIB_SUCCESS
;
GET_SRC_DST_PARAMETERS
(
DTYPE
);
if
(
scale
>
30
)
{
...
...
@@ -1905,7 +1907,10 @@ mlib_status CONV_FUNC_MxN
k
[
i
]
=
kernel
[
i
]
*
fscale
;
}
if
(
m
==
1
)
return
mlib_ImageConv1xN_ext
(
dst
,
src
,
k
,
n
,
dy_t
,
dy_b
,
cmask
);
if
(
m
==
1
)
{
status
=
mlib_ImageConv1xN_ext
(
dst
,
src
,
k
,
n
,
dy_t
,
dy_b
,
cmask
);
FREE_AND_RETURN_STATUS
;
}
swid
=
wid
+
(
m
-
1
);
...
...
@@ -1914,7 +1919,10 @@ mlib_status CONV_FUNC_MxN
if
((
bsize
>
BUFF_SIZE
)
||
(
n
>
MAX_N
))
{
pbuff
=
mlib_malloc
(
sizeof
(
FTYPE
)
*
bsize
+
sizeof
(
FTYPE
*
)
*
2
*
(
n
+
1
));
if
(
pbuff
==
NULL
)
return
MLIB_FAILURE
;
if
(
pbuff
==
NULL
)
{
status
=
MLIB_FAILURE
;
FREE_AND_RETURN_STATUS
;
}
buffs
=
(
FTYPE
**
)(
pbuff
+
bsize
);
}
...
...
@@ -2318,9 +2326,7 @@ mlib_status CONV_FUNC_MxN
}
}
if
(
pbuff
!=
buff
)
mlib_free
(
pbuff
);
return
MLIB_SUCCESS
;
FREE_AND_RETURN_STATUS
;
}
/***************************************************************/
...
...
src/share/native/sun/awt/medialib/mlib_ImageConv_u16nw.c
浏览文件 @
7b3dae29
...
...
@@ -1651,6 +1651,8 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
DEF_VARS
(
DTYPE
);
mlib_s32
chan2
;
mlib_s32
*
buffo
,
*
buffi
;
mlib_status
status
=
MLIB_SUCCESS
;
GET_SRC_DST_PARAMETERS
(
DTYPE
);
if
(
scale
>
30
)
{
...
...
@@ -1672,14 +1674,20 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
k
[
i
]
=
kernel
[
i
]
*
fscale
;
}
if
(
m
==
1
)
return
mlib_ImageConv1xN
(
dst
,
src
,
k
,
n
,
dn
,
cmask
);
if
(
m
==
1
)
{
status
=
mlib_ImageConv1xN
(
dst
,
src
,
k
,
n
,
dn
,
cmask
);
FREE_AND_RETURN_STATUS
;
}
bsize
=
(
n
+
3
)
*
wid
;
if
((
bsize
>
BUFF_SIZE
)
||
(
n
>
MAX_N
))
{
pbuff
=
mlib_malloc
(
sizeof
(
FTYPE
)
*
bsize
+
sizeof
(
FTYPE
*
)
*
2
*
(
n
+
1
));
if
(
pbuff
==
NULL
)
return
MLIB_FAILURE
;
if
(
pbuff
==
NULL
)
{
status
=
MLIB_FAILURE
;
FREE_AND_RETURN_STATUS
;
}
buffs
=
(
FTYPE
**
)(
pbuff
+
bsize
);
}
...
...
@@ -2033,9 +2041,7 @@ mlib_status CONV_FUNC(MxN)(mlib_image *dst,
}
}
if
(
pbuff
!=
buff
)
mlib_free
(
pbuff
);
return
MLIB_SUCCESS
;
FREE_AND_RETURN_STATUS
;
}
/***************************************************************/
...
...
src/share/native/sun/awt/medialib/mlib_ImageCreate.c
浏览文件 @
7b3dae29
...
...
@@ -477,9 +477,9 @@ void *mlib_ImageCreateRowTable(mlib_image *img)
im_height
=
mlib_ImageGetHeight
(
img
);
im_stride
=
mlib_ImageGetStride
(
img
);
tline
=
mlib_ImageGetData
(
img
);
if
(
tline
==
NULL
)
return
NULL
;
rtable
=
mlib_malloc
((
3
+
im_height
)
*
sizeof
(
mlib_u8
*
));
if
(
rtable
==
NULL
||
tline
==
NULL
)
return
NULL
;
if
(
rtable
==
NULL
)
return
NULL
;
rtable
[
0
]
=
0
;
rtable
[
1
]
=
(
mlib_u8
*
)((
void
**
)
rtable
+
1
);
...
...
src/share/native/sun/awt/medialib/mlib_c_ImageConv.h
浏览文件 @
7b3dae29
...
...
@@ -31,6 +31,16 @@
extern
"C"
{
#endif
/* __cplusplus */
// Shared macro defined for cleanup of allocated memory.
#ifndef FREE_AND_RETURN_STATUS
#define FREE_AND_RETURN_STATUS \
{ \
if (pbuff != buff) mlib_free(pbuff); \
if (k != akernel) mlib_free(k); \
return status; \
}
#endif
/* FREE_AND_RETURN_STATUS */
mlib_status
mlib_c_conv2x2ext_s16
(
mlib_image
*
dst
,
const
mlib_image
*
src
,
mlib_s32
dx_l
,
...
...
src/solaris/classes/sun/awt/X11/XIconWindow.java
浏览文件 @
7b3dae29
...
...
@@ -92,7 +92,7 @@ public class XIconWindow extends XBaseWindow {
}
XIconSize
[]
sizeList
=
getIconSizes
();
log
.
finest
(
"Icon sizes: {0}"
,
sizeList
);
log
.
finest
(
"Icon sizes: {0}"
,
(
Object
[])
sizeList
);
if
(
sizeList
==
null
)
{
// No icon sizes so we simply fall back to 16x16
return
new
Dimension
(
16
,
16
);
...
...
src/solaris/classes/sun/awt/X11InputMethod.java
浏览文件 @
7b3dae29
...
...
@@ -57,6 +57,7 @@ import java.io.File;
import
java.io.FileReader
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.lang.ref.WeakReference
;
import
sun.util.logging.PlatformLogger
;
import
java.util.StringTokenizer
;
import
java.util.regex.Pattern
;
...
...
@@ -104,7 +105,7 @@ public abstract class X11InputMethod extends InputMethodAdapter {
//reset the XIC if necessary
private
boolean
needResetXIC
=
false
;
private
Component
needResetXICClient
=
null
;
private
WeakReference
<
Component
>
needResetXICClient
=
new
WeakReference
<>(
null
)
;
// The use of compositionEnableSupported is to reduce unnecessary
// native calls if set/isCompositionEnabled
...
...
@@ -272,14 +273,14 @@ public abstract class X11InputMethod extends InputMethodAdapter {
called on the passive client when endComposition is called.
*/
if
(
needResetXIC
&&
haveActiveClient
()
&&
getClientComponent
()
!=
needResetXICClient
){
getClientComponent
()
!=
needResetXICClient
.
get
()
){
resetXIC
();
// needs to reset the last xic focussed component.
lastXICFocussedComponent
=
null
;
isLastXICActive
=
false
;
needResetXICClient
=
null
;
needResetXICClient
.
clear
()
;
needResetXIC
=
false
;
}
}
...
...
@@ -417,7 +418,7 @@ public abstract class X11InputMethod extends InputMethodAdapter {
isLastXICActive
=
false
;
resetXIC
();
needResetXICClient
=
null
;
needResetXICClient
.
clear
()
;
needResetXIC
=
false
;
}
}
...
...
@@ -478,7 +479,7 @@ public abstract class X11InputMethod extends InputMethodAdapter {
disableInputMethod
();
if
(
needResetXIC
)
{
resetXIC
();
needResetXICClient
=
null
;
needResetXICClient
.
clear
()
;
needResetXIC
=
false
;
}
}
...
...
@@ -877,7 +878,7 @@ public abstract class X11InputMethod extends InputMethodAdapter {
boolean
active
=
haveActiveClient
();
if
(
active
&&
composedText
==
null
&&
committedText
==
null
){
needResetXIC
=
true
;
needResetXICClient
=
getClientComponent
(
);
needResetXICClient
=
new
WeakReference
<>(
getClientComponent
()
);
return
;
}
...
...
src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
浏览文件 @
7b3dae29
...
...
@@ -57,21 +57,22 @@ Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
jobject
peer
,
jlong
aData
)
{
#ifndef HEADLESS
OGLSDOps
*
oglsdo
=
(
OGLSDOps
*
)
SurfaceData_InitOps
(
env
,
glxsd
,
sizeof
(
OGLSDOps
));
GLXSDOps
*
glxsdo
=
(
GLXSDOps
*
)
malloc
(
sizeof
(
GLXSDOps
));
J2dTraceLn
(
J2D_TRACE_INFO
,
"GLXSurfaceData_initOps"
);
if
(
glxsdo
==
NULL
)
{
JNU_ThrowOutOfMemoryError
(
env
,
"creating native GLX ops"
);
return
;
}
OGLSDOps
*
oglsdo
=
(
OGLSDOps
*
)
SurfaceData_InitOps
(
env
,
glxsd
,
sizeof
(
OGLSDOps
));
if
(
oglsdo
==
NULL
)
{
free
(
glxsdo
);
JNU_ThrowOutOfMemoryError
(
env
,
"Initialization of SurfaceData failed."
);
return
;
}
if
(
glxsdo
==
NULL
)
{
JNU_ThrowOutOfMemoryError
(
env
,
"creating native GLX ops"
);
return
;
}
J2dTraceLn
(
J2D_TRACE_INFO
,
"GLXSurfaceData_initOps"
);
oglsdo
->
privOps
=
glxsdo
;
...
...
src/macosx/classes/sun/lwawt/macosx/EventDispatchAccess
.java
→
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/AbsoluteComponentCenterCalculator
.java
浏览文件 @
7b3dae29
/*
* Copyright (c) 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute 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.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -23,17 +21,17 @@
* questions.
*/
package
sun.lwawt.macosx
;
import
java.awt.*
;
// This exists strictly to work around the fact that java.awt.Conditional isn't a public class.
// It uses java reflection to get the EventDispatchThread class and call a MacOSX only
// method on it.
//
// NOTE: This uses reflection in its implementation, so it is not for performance critical code.
//
// See java.awt.EventDispatchThread and apple.awt.CPrintJob for more.
//
public
abstract
class
EventDispatchAccess
{
public
native
void
pumpEventsAndWait
(
);
public
abstract
boolean
evaluate
();
class
AbsoluteComponentCenterCalculator
{
private
AbsoluteComponentCenterCalculator
()
{
}
public
static
int
calculateXCenterCoordinate
(
Component
component
)
{
return
(
int
)
component
.
getLocationOnScreen
().
getX
()
+
(
component
.
getWidth
()
/
2
);
}
public
static
int
calculateYCenterCoordinate
(
Component
component
)
{
return
(
int
)
component
.
getLocationOnScreen
().
getY
()
+
(
component
.
getHeight
()
/
2
);
}
}
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/DataFlavorSearcher.java
0 → 100644
浏览文件 @
7b3dae29
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.datatransfer.DataFlavor
;
import
java.awt.datatransfer.FlavorTable
;
import
java.awt.datatransfer.SystemFlavorMap
;
import
java.util.Arrays
;
public
class
DataFlavorSearcher
{
static
public
String
[]
HTML_NAMES
=
new
String
[]{
"HTML"
,
"HTML Format"
};
static
public
String
[]
RICH_TEXT_NAMES
=
new
String
[]{
"RICH_TEXT"
,
"Rich Text Format"
};
static
public
DataFlavor
getByteDataFlavorForNative
(
String
[]
nats
)
{
FlavorTable
flavorTable
=
(
FlavorTable
)
SystemFlavorMap
.
getDefaultFlavorMap
();
for
(
String
nat
:
nats
)
{
java
.
util
.
List
<
DataFlavor
>
flavors
=
flavorTable
.
getFlavorsForNative
(
nat
);
for
(
DataFlavor
flavor
:
flavors
)
{
if
(
flavor
!=
null
&&
flavor
.
getRepresentationClass
().
equals
(
byte
[].
class
))
{
return
flavor
;
}
}
}
throw
new
RuntimeException
(
"No data flavor was found for natives: "
+
Arrays
.
toString
(
nats
));
}
}
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/InterprocessMessages.java
0 → 100644
浏览文件 @
7b3dae29
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along 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.
*/
interface
InterprocessMessages
{
final
static
int
EXECUTION_IS_SUCCESSFULL
=
0
;
final
static
int
DATA_IS_CORRUPTED
=
212
;
}
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html
0 → 100644
浏览文件 @
7b3dae29
<html>
<!--
@test
@bug 8005932
@summary Java 7 on mac os x only provides text clipboard formats
@author mikhail.cherkasov@oracle.com
@library ../../regtesthelpers
@library ../../regtesthelpers/process
@build Util
@build ProcessResults ProcessCommunicator
@run applet/othervm MissedHtmlAndRtfBug.html
*/>
<head>
<title>Java 7 on mac os x only provides text clipboard formats</title>
</head>
<body>
<h1> MissedHtmlAndRtfBug <br>Bug ID: 8005932 </h1>
<p> This is an AUTOMATIC test, simply wait for completion </p>
<APPLET CODE="MissedHtmlAndRtfBug.class" WIDTH=200 HEIGHT=200></APPLET>
</body>
</html>
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java
0 → 100644
浏览文件 @
7b3dae29
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along 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 8005932
@summary Java 7 on mac os x only provides text clipboard formats
@author mikhail.cherkasov@oracle.com
@library ../../regtesthelpers
@library ../../regtesthelpers/process
@build Util
@build ProcessResults ProcessCommunicator
@run applet/othervm MissedHtmlAndRtfBug.html
*/
import
java.awt.*
;
import
java.awt.datatransfer.DataFlavor
;
import
java.awt.event.*
;
import
java.applet.Applet
;
import
java.io.File
;
import
java.util.ArrayList
;
import
test.java.awt.regtesthelpers.process.ProcessCommunicator
;
import
test.java.awt.regtesthelpers.process.ProcessResults
;
import
test.java.awt.regtesthelpers.Util
;
import
sun.awt.OSInfo
;
import
static
java
.
lang
.
Thread
.
sleep
;
public
class
MissedHtmlAndRtfBug
extends
Applet
{
public
void
init
()
{
setLayout
(
new
BorderLayout
());
}
//End init()
public
void
start
()
{
if
(
OSInfo
.
getOSType
()
!=
OSInfo
.
OSType
.
MACOSX
&&
OSInfo
.
getOSType
()
!=
OSInfo
.
OSType
.
WINDOWS
)
{
System
.
out
.
println
(
"This test is for Windows and Mac only. Passed."
);
return
;
}
final
Frame
sourceFrame
=
new
Frame
(
"Source frame"
);
final
SourcePanel
sourcePanel
=
new
SourcePanel
();
sourceFrame
.
add
(
sourcePanel
);
sourceFrame
.
pack
();
sourceFrame
.
addWindowListener
(
new
WindowAdapter
()
{
@Override
public
void
windowClosing
(
WindowEvent
e
)
{
sourceFrame
.
dispose
();
}
});
sourceFrame
.
setVisible
(
true
);
Util
.
waitForIdle
(
null
);
NextFramePositionCalculator
positionCalculator
=
new
NextFramePositionCalculator
(
sourceFrame
);
ArrayList
<
String
>
args
=
new
ArrayList
<
String
>(
5
);
args
.
add
(
String
.
valueOf
(
positionCalculator
.
getNextLocationX
()));
args
.
add
(
String
.
valueOf
(
positionCalculator
.
getNextLocationY
()));
args
.
add
(
String
.
valueOf
(
AbsoluteComponentCenterCalculator
.
calculateXCenterCoordinate
(
sourcePanel
)));
args
.
add
(
String
.
valueOf
(
AbsoluteComponentCenterCalculator
.
calculateYCenterCoordinate
(
sourcePanel
)));
args
.
add
(
concatStrings
(
DataFlavorSearcher
.
RICH_TEXT_NAMES
));
ProcessResults
processResults
=
// ProcessCommunicator.executeChildProcess(this.getClass(), "/Users/mcherkasov/ws/clipboard/DataFlover/out/production/DataFlover" +
// " -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 ",
// args.toArray(new String[0]));
ProcessCommunicator
.
executeChildProcess
(
this
.
getClass
(),
"."
+
File
.
separator
+
System
.
getProperty
(
"java.class.path"
),
args
.
toArray
(
new
String
[]{}));
verifyTestResults
(
processResults
);
args
.
set
(
args
.
size
()
-
1
,
concatStrings
(
DataFlavorSearcher
.
HTML_NAMES
));
ProcessCommunicator
.
executeChildProcess
(
this
.
getClass
(),
"."
+
File
.
separator
+
System
.
getProperty
(
"java.class.path"
),
args
.
toArray
(
new
String
[]{}));
verifyTestResults
(
processResults
);
}
// start()
private
String
concatStrings
(
String
[]
strings
)
{
StringBuffer
result
=
new
StringBuffer
(
"\""
);
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
result
.
append
(
strings
[
i
]);
result
.
append
(
","
);
}
result
.
append
(
"\""
);
return
result
.
toString
();
}
private
static
void
verifyTestResults
(
ProcessResults
processResults
)
{
if
(
InterprocessMessages
.
DATA_IS_CORRUPTED
==
processResults
.
getExitValue
())
{
processResults
.
printProcessErrorOutput
(
System
.
err
);
throw
new
RuntimeException
(
"TEST IS FAILED: Target has received"
+
" corrupted data."
);
}
processResults
.
verifyStdErr
(
System
.
err
);
processResults
.
verifyProcessExitValue
(
System
.
err
);
processResults
.
printProcessStandartOutput
(
System
.
out
);
}
//We cannot make an instance of the applet without the default constructor
public
MissedHtmlAndRtfBug
()
{
super
();
}
//We need in this constructor to pass frame position between JVMs
public
MissedHtmlAndRtfBug
(
Point
targetFrameLocation
,
Point
dragSourcePoint
,
DataFlavor
df
)
throws
InterruptedException
{
final
Frame
targetFrame
=
new
Frame
(
"Target frame"
);
final
TargetPanel
targetPanel
=
new
TargetPanel
(
targetFrame
,
df
);
targetFrame
.
add
(
targetPanel
);
targetFrame
.
addWindowListener
(
new
WindowAdapter
()
{
@Override
public
void
windowClosing
(
WindowEvent
e
)
{
targetFrame
.
dispose
();
}
});
targetFrame
.
setLocation
(
targetFrameLocation
);
targetFrame
.
pack
();
targetFrame
.
setVisible
(
true
);
doTest
(
dragSourcePoint
,
targetPanel
);
}
private
void
doTest
(
Point
dragSourcePoint
,
TargetPanel
targetPanel
)
{
Util
.
waitForIdle
(
null
);
final
Robot
robot
=
Util
.
createRobot
();
robot
.
mouseMove
((
int
)
dragSourcePoint
.
getX
(),
(
int
)
dragSourcePoint
.
getY
());
try
{
sleep
(
100
);
robot
.
mousePress
(
InputEvent
.
BUTTON1_MASK
);
sleep
(
100
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_MASK
);
sleep
(
100
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
Util
.
drag
(
robot
,
dragSourcePoint
,
new
Point
(
AbsoluteComponentCenterCalculator
.
calculateXCenterCoordinate
(
targetPanel
),
AbsoluteComponentCenterCalculator
.
calculateYCenterCoordinate
(
targetPanel
)),
InputEvent
.
BUTTON1_MASK
);
}
enum
InterprocessArguments
{
TARGET_FRAME_X_POSITION_ARGUMENT
,
TARGET_FRAME_Y_POSITION_ARGUMENT
,
DRAG_SOURCE_POINT_X_ARGUMENT
,
DRAG_SOURCE_POINT_Y_ARGUMENT
,
DATA_FLAVOR_NAMES
;
int
extractInt
(
String
[]
args
)
{
return
Integer
.
parseInt
(
args
[
this
.
ordinal
()]);
}
String
[]
extractStringArray
(
String
[]
args
)
{
return
args
[
this
.
ordinal
()].
replaceAll
(
"\""
,
""
).
split
(
","
);
}
}
public
static
void
main
(
String
[]
args
)
{
Point
dragSourcePoint
=
new
Point
(
InterprocessArguments
.
DRAG_SOURCE_POINT_X_ARGUMENT
.
extractInt
(
args
),
InterprocessArguments
.
DRAG_SOURCE_POINT_Y_ARGUMENT
.
extractInt
(
args
));
Point
targetFrameLocation
=
new
Point
(
InterprocessArguments
.
TARGET_FRAME_X_POSITION_ARGUMENT
.
extractInt
(
args
),
InterprocessArguments
.
TARGET_FRAME_Y_POSITION_ARGUMENT
.
extractInt
(
args
));
String
[]
names
=
InterprocessArguments
.
DATA_FLAVOR_NAMES
.
extractStringArray
(
args
);
DataFlavor
df
=
DataFlavorSearcher
.
getByteDataFlavorForNative
(
names
);
try
{
new
MissedHtmlAndRtfBug
(
targetFrameLocation
,
dragSourcePoint
,
df
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MyTransferable.java
0 → 100644
浏览文件 @
7b3dae29
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.datatransfer.*
;
import
java.io.IOException
;
class
MyTransferable
implements
Transferable
{
public
static
final
String
TEST_DATA
=
"<b>Test</b>"
;
private
DataFlavor
[]
dataFlavors
;
public
MyTransferable
()
{
dataFlavors
=
new
DataFlavor
[]{
DataFlavorSearcher
.
getByteDataFlavorForNative
(
DataFlavorSearcher
.
HTML_NAMES
),
DataFlavorSearcher
.
getByteDataFlavorForNative
(
DataFlavorSearcher
.
RICH_TEXT_NAMES
)};
}
@Override
public
DataFlavor
[]
getTransferDataFlavors
()
{
return
dataFlavors
;
}
@Override
public
boolean
isDataFlavorSupported
(
DataFlavor
flavor
)
{
for
(
DataFlavor
f
:
dataFlavors
)
{
if
(
f
.
equals
(
flavor
))
{
return
true
;
}
}
return
false
;
}
@Override
public
Object
getTransferData
(
DataFlavor
flavor
)
throws
UnsupportedFlavorException
,
IOException
{
if
(
isDataFlavorSupported
(
flavor
))
{
return
TEST_DATA
.
getBytes
(
"UTF-16"
);
}
else
{
throw
new
UnsupportedFlavorException
(
flavor
);
}
}
}
\ No newline at end of file
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/NextFramePositionCalculator.java
0 → 100644
浏览文件 @
7b3dae29
import
java.awt.*
;
class
NextFramePositionCalculator
{
private
final
Frame
currentFrame
;
public
NextFramePositionCalculator
(
Frame
currentFrame
)
{
this
.
currentFrame
=
currentFrame
;
}
public
int
getNextLocationX
()
{
return
currentFrame
.
getX
()
+
currentFrame
.
getWidth
();
}
public
int
getNextLocationY
()
{
return
currentFrame
.
getY
();
}
}
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/SourcePanel.java
0 → 100644
浏览文件 @
7b3dae29
import
java.awt.dnd.DragSource
;
import
java.awt.dnd.DnDConstants
;
import
java.awt.dnd.DragGestureEvent
;
import
java.awt.dnd.DragGestureListener
;
import
java.awt.*
;
public
class
SourcePanel
extends
Panel
{
private
final
MyDragGestureListener
dragGestureListener
=
new
MyDragGestureListener
();
public
SourcePanel
()
{
setPreferredSize
(
new
Dimension
(
200
,
200
));
DragSource
defaultDragSource
=
DragSource
.
getDefaultDragSource
();
defaultDragSource
.
createDefaultDragGestureRecognizer
(
this
,
DnDConstants
.
ACTION_COPY_OR_MOVE
,
dragGestureListener
);
setBackground
(
Color
.
RED
);
}
private
class
MyDragGestureListener
implements
DragGestureListener
{
public
void
dragGestureRecognized
(
DragGestureEvent
dge
)
{
dge
.
startDrag
(
null
,
new
MyTransferable
());
}
}
}
test/java/awt/DataFlavor/MissedHtmlAndRtfBug/TargetPanel.java
0 → 100644
浏览文件 @
7b3dae29
import
java.awt.datatransfer.Transferable
;
import
java.awt.dnd.*
;
import
java.awt.*
;
import
java.awt.datatransfer.DataFlavor
;
import
java.awt.datatransfer.UnsupportedFlavorException
;
import
java.io.IOException
;
import
java.util.Timer
;
import
java.util.TimerTask
;
public
class
TargetPanel
extends
Panel
implements
DropTargetListener
{
//private final CustomDropTargetListener dropTargetListener = new CustomDropTargetListener();
private
Frame
frame
;
DataFlavor
dataFlavor
;
public
TargetPanel
(
Frame
frame
,
DataFlavor
dataFlavor
)
{
this
.
dataFlavor
=
dataFlavor
;
this
.
frame
=
frame
;
setBackground
(
Color
.
DARK_GRAY
);
setPreferredSize
(
new
Dimension
(
200
,
200
));
setDropTarget
(
new
DropTarget
(
this
,
this
));
}
public
void
dragEnter
(
DropTargetDragEvent
dtde
)
{
if
(
dtde
.
isDataFlavorSupported
(
dataFlavor
))
{
dtde
.
acceptDrag
(
DnDConstants
.
ACTION_COPY_OR_MOVE
);
}
}
public
void
dragOver
(
DropTargetDragEvent
dtde
)
{
if
(
dtde
.
isDataFlavorSupported
(
dataFlavor
))
{
dtde
.
acceptDrag
(
DnDConstants
.
ACTION_COPY_OR_MOVE
);
}
}
public
void
dropActionChanged
(
DropTargetDragEvent
dtde
)
{
if
(
dtde
.
isDataFlavorSupported
(
dataFlavor
))
{
dtde
.
acceptDrag
(
DnDConstants
.
ACTION_COPY_OR_MOVE
);
}
}
public
void
dragExit
(
DropTargetEvent
dte
)
{
}
public
void
drop
(
DropTargetDropEvent
dtde
)
{
dtde
.
acceptDrop
(
DnDConstants
.
ACTION_COPY_OR_MOVE
);
if
(
dtde
.
isDataFlavorSupported
(
dataFlavor
))
{
String
result
=
null
;
try
{
Transferable
t
=
dtde
.
getTransferable
();
byte
[]
data
=
(
byte
[])
dtde
.
getTransferable
().
getTransferData
(
dataFlavor
);
result
=
new
String
(
data
,
"UTF-16"
);
repaint
();
}
catch
(
UnsupportedFlavorException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
dtde
.
dropComplete
(
true
);
if
(
result
!=
null
&&
result
.
contains
(
MyTransferable
.
TEST_DATA
))
{
System
.
err
.
println
(
InterprocessMessages
.
EXECUTION_IS_SUCCESSFULL
);
Timer
t
=
new
Timer
();
t
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
System
.
exit
(
0
);
}
},
2000
);
return
;
}
}
dtde
.
rejectDrop
();
System
.
err
.
println
(
InterprocessMessages
.
DATA_IS_CORRUPTED
);
System
.
exit
(
InterprocessMessages
.
DATA_IS_CORRUPTED
);
}
}
test/java/awt/Frame/WindowDragTest/WindowDragTest.java
浏览文件 @
7b3dae29
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -23,10 +23,11 @@
/*
@test
@bug 7128738
@bug 7128738
7161759
@summary dragged dialog freezes system on dispose
@author Oleg Pekhovskiy: area=awt.toplevel
@library ../../regtesthelpers
@build Util
@run main WindowDragTest
*/
...
...
test/java/awt/im/memoryleak/InputContextMemoryLeakTest.java
0 → 100644
浏览文件 @
7b3dae29
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.FlowLayout
;
import
java.awt.Robot
;
import
java.lang.ref.Reference
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JPanel
;
import
javax.swing.JTextField
;
import
javax.swing.SwingUtilities
;
import
test.java.awt.regtesthelpers.Util
;
/*
@test
@bug 7079260
@summary XInputContext leaks memory by needRecetXXIClient field
@author Petr Pchelko
@library ../../regtesthelpers
@build Util
@compile InputContextMemoryLeakTest.java
@run main/othervm -Xmx20M InputContextMemoryLeakTest
*/
public
class
InputContextMemoryLeakTest
{
private
static
JFrame
frame
;
private
static
WeakReference
<
JTextField
>
text
;
private
static
WeakReference
<
JPanel
>
p
;
private
static
JButton
button
;
public
static
void
init
()
throws
Throwable
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
frame
=
new
JFrame
();
frame
.
setLayout
(
new
FlowLayout
());
JPanel
p1
=
new
JPanel
();
button
=
new
JButton
(
"Test"
);
p1
.
add
(
button
);
frame
.
add
(
p1
);
text
=
new
WeakReference
<
JTextField
>(
new
JTextField
(
"Text"
));
p
=
new
WeakReference
<
JPanel
>(
new
JPanel
(
new
FlowLayout
()));
p
.
get
().
add
(
text
.
get
());
frame
.
add
(
p
.
get
());
frame
.
setBounds
(
500
,
400
,
200
,
200
);
frame
.
setVisible
(
true
);
}
});
Util
.
focusComponent
(
text
.
get
(),
500
);
Util
.
clickOnComp
(
button
,
new
Robot
());
//References to objects testes for memory leak are stored in Util.
//Need to clean them
Util
.
cleanUp
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
frame
.
remove
(
p
.
get
());
}
});
Util
.
waitForIdle
(
null
);
//After the next caret blink it automatically TextField references
Thread
.
sleep
(
text
.
get
().
getCaret
().
getBlinkRate
()
*
2
);
Util
.
waitForIdle
(
null
);
assertGC
();
}
public
static
void
assertGC
()
throws
Throwable
{
List
<
byte
[]>
alloc
=
new
ArrayList
<
byte
[]>();
int
size
=
1024
*
10
;
while
(
true
)
{
try
{
alloc
.
add
(
new
byte
[
size
]);
}
catch
(
OutOfMemoryError
err
)
{
break
;
}
}
alloc
=
null
;
if
(
text
.
get
()
!=
null
)
{
throw
new
Exception
(
"Test failed: JTextField was not collected"
);
}
}
public
static
void
main
(
String
args
[])
throws
Throwable
{
init
();
}
}
test/java/awt/regtesthelpers/Util.java
浏览文件 @
7b3dae29
...
...
@@ -463,6 +463,13 @@ public final class Util {
return
-
1
;
}
//Cleans all the references
public
static
void
cleanUp
()
{
apListener
=
null
;
fgListener
=
null
;
wgfListener
=
null
;
}
////////////////////////////
// Some stuff to test focus.
...
...
test/javax/swing/JComboBox/4199622/bug4199622.java
0 → 100644
浏览文件 @
7b3dae29
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along 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 4199622
@summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation
@author Vladislav Karnaukhov
@run main bug4199622
*/
import
com.sun.java.swing.plaf.windows.WindowsLookAndFeel
;
import
sun.awt.OSInfo
;
import
sun.awt.SunToolkit
;
import
javax.swing.*
;
import
javax.swing.plaf.metal.MetalLookAndFeel
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.KeyEvent
;
import
java.lang.reflect.InvocationTargetException
;
public
class
bug4199622
extends
JFrame
implements
ActionListener
{
static
final
int
nElems
=
20
;
static
JComboBox
<
String
>
cb
=
null
;
bug4199622
(
LookAndFeel
laf
)
{
super
();
try
{
UIManager
.
setLookAndFeel
(
laf
);
}
catch
(
UnsupportedLookAndFeelException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
setDefaultCloseOperation
(
DISPOSE_ON_CLOSE
);
cb
=
new
JComboBox
<>();
for
(
int
i
=
0
;
i
<
nElems
;
i
++)
{
cb
.
addItem
(
String
.
valueOf
(
i
+
1
));
}
cb
.
addActionListener
(
this
);
add
(
cb
);
setSize
(
300
,
300
);
pack
();
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
UIManager
.
getBoolean
(
"ComboBox.noActionOnKeyNavigation"
)
&&
cb
.
isPopupVisible
())
{
throw
new
RuntimeException
(
"Test failed. actionPerformed generated"
);
}
}
static
Robot
robot
=
null
;
static
SunToolkit
toolkit
=
null
;
static
void
doTest
()
{
if
(
robot
==
null
)
{
try
{
robot
=
new
Robot
();
robot
.
setAutoDelay
(
20
);
}
catch
(
AWTException
e
)
{
throw
new
RuntimeException
(
"Can't create robot. Test failed"
,
e
);
}
}
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
if
(
toolkit
==
null
)
{
throw
new
RuntimeException
(
"Can't get the toolkit. Test failed"
);
}
toolkit
.
realSync
();
doActualTest
();
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
cb
.
hidePopup
();
cb
.
setEditable
(
true
);
cb
.
updateUI
();
}
});
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
catch
(
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
toolkit
.
realSync
();
doActualTest
();
}
static
void
doActualTest
()
{
UIManager
.
put
(
"ComboBox.noActionOnKeyNavigation"
,
true
);
doTestUpDown
();
UIManager
.
put
(
"ComboBox.noActionOnKeyNavigation"
,
false
);
doTestUpDown
();
UIManager
.
put
(
"ComboBox.noActionOnKeyNavigation"
,
true
);
doTestPgUpDown
();
UIManager
.
put
(
"ComboBox.noActionOnKeyNavigation"
,
false
);
doTestPgUpDown
();
UIManager
.
put
(
"ComboBox.noActionOnKeyNavigation"
,
true
);
doTestHomeEnd
();
UIManager
.
put
(
"ComboBox.noActionOnKeyNavigation"
,
false
);
doTestHomeEnd
();
}
static
void
doTestHomeEnd
()
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
cb
.
hidePopup
();
cb
.
setSelectedIndex
(
0
);
}
});
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
catch
(
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
toolkit
.
realSync
();
robot
.
keyPress
(
KeyEvent
.
VK_END
);
toolkit
.
realSync
();
robot
.
keyPress
(
KeyEvent
.
VK_HOME
);
toolkit
.
realSync
();
}
static
void
doTestUpDown
()
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
cb
.
hidePopup
();
cb
.
setSelectedIndex
(
0
);
}
});
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
catch
(
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
toolkit
.
realSync
();
for
(
int
i
=
0
;
i
<
nElems
;
i
++)
{
robot
.
keyPress
(
KeyEvent
.
VK_DOWN
);
toolkit
.
realSync
();
}
for
(
int
i
=
0
;
i
<
nElems
;
i
++)
{
robot
.
keyPress
(
KeyEvent
.
VK_UP
);
toolkit
.
realSync
();
}
}
static
void
doTestPgUpDown
()
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
cb
.
hidePopup
();
cb
.
setSelectedIndex
(
0
);
}
});
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
catch
(
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
toolkit
.
realSync
();
int
listHeight
=
cb
.
getMaximumRowCount
();
for
(
int
i
=
0
;
i
<
nElems
;
i
+=
listHeight
)
{
robot
.
keyPress
(
KeyEvent
.
VK_PAGE_DOWN
);
toolkit
.
realSync
();
}
for
(
int
i
=
0
;
i
<
nElems
;
i
+=
listHeight
)
{
robot
.
keyPress
(
KeyEvent
.
VK_PAGE_UP
);
toolkit
.
realSync
();
}
}
public
static
void
main
(
String
[]
args
)
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
bug4199622
test
=
new
bug4199622
(
new
MetalLookAndFeel
());
test
.
setVisible
(
true
);
}
});
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
catch
(
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
doTest
();
if
(
OSInfo
.
getOSType
()
==
OSInfo
.
OSType
.
WINDOWS
)
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
bug4199622
test
=
new
bug4199622
(
new
WindowsLookAndFeel
());
test
.
setVisible
(
true
);
}
});
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
catch
(
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
doTest
();
}
}
}
test/javax/swing/JLabel/6596966/bug6596966.java
浏览文件 @
7b3dae29
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -24,16 +24,17 @@
/* @test
@bug 6596966
@summary Some JFileChooser mnemonics do not work with sticky keys
@library ../../regtesthelpers
@build Util
@run main bug6596966
@author Pavel Porvatov
*/
import
sun.awt.SunToolkit
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.KeyEvent
;
import
java.util.ArrayList
;
import
javax.swing.*
;
import
sun.awt.SunToolkit
;
public
class
bug6596966
{
private
static
JFrame
frame
;
...
...
@@ -71,11 +72,14 @@ public class bug6596966 {
toolkit
.
realSync
();
robot
.
keyPress
(
KeyEvent
.
VK_ALT
);
ArrayList
<
Integer
>
keys
=
Util
.
getSystemMnemonicKeyCodes
();
for
(
int
i
=
0
;
i
<
keys
.
size
();
++
i
)
{
robot
.
keyPress
(
keys
.
get
(
i
));
}
robot
.
keyPress
(
KeyEvent
.
VK_L
);
toolkit
.
realSync
();
toolkit
.
getSystemEventQueue
().
postEvent
(
new
KeyEvent
(
label
,
KeyEvent
.
KEY_RELEASED
,
EventQueue
.
getMostRecentEventTime
(),
0
,
KeyEvent
.
VK_L
,
'L'
));
...
...
@@ -90,7 +94,11 @@ public class bug6596966 {
}
});
}
finally
{
robot
.
keyRelease
(
KeyEvent
.
VK_ALT
);
robot
.
keyRelease
(
KeyEvent
.
VK_L
);
for
(
int
i
=
0
;
i
<
keys
.
size
();
++
i
)
{
robot
.
keyRelease
(
keys
.
get
(
i
));
}
toolkit
.
realSync
();
}
}
}
test/javax/swing/regtesthelpers/Util.java
浏览文件 @
7b3dae29
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -23,11 +23,13 @@
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.image.BufferedImage
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
sun.swing.*
;
/**
* <p>This class contains utilities useful for regression testing.
...
...
@@ -212,4 +214,33 @@ public class Util {
return
result
.
get
(
0
);
}
/**
* Gets key codes from system mnemonic key mask
* @return key codes list
*/
public
static
ArrayList
<
Integer
>
getSystemMnemonicKeyCodes
()
{
return
Util
.
getKeyCodesFromKeyMask
(
SwingUtilities2
.
getSystemMnemonicKeyMask
());
}
/**
* Gets the key codes list from modifiers
* @param modifiers an integer combination of the modifier constants
* @return key codes list
*/
public
static
ArrayList
<
Integer
>
getKeyCodesFromKeyMask
(
int
modifiers
)
{
ArrayList
<
Integer
>
result
=
new
ArrayList
<>();
if
((
modifiers
&
InputEvent
.
CTRL_MASK
)
!=
0
)
{
result
.
add
(
KeyEvent
.
VK_CONTROL
);
}
if
((
modifiers
&
InputEvent
.
ALT_MASK
)
!=
0
)
{
result
.
add
(
KeyEvent
.
VK_ALT
);
}
if
((
modifiers
&
InputEvent
.
SHIFT_MASK
)
!=
0
)
{
result
.
add
(
KeyEvent
.
VK_SHIFT
);
}
if
((
modifiers
&
InputEvent
.
META_MASK
)
!=
0
)
{
result
.
add
(
KeyEvent
.
VK_META
);
}
return
result
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录