Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
19b2b253
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
19b2b253
编写于
3月 03, 2009
作者:
P
prr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2163516: Font.createFont can be persuaded to leak temporary files
Reviewed-by: igor
上级
c7f2054c
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
70 addition
and
9 deletion
+70
-9
src/share/classes/sun/font/FontManager.java
src/share/classes/sun/font/FontManager.java
+1
-1
src/share/classes/sun/font/TrueTypeFont.java
src/share/classes/sun/font/TrueTypeFont.java
+11
-2
src/share/classes/sun/font/Type1Font.java
src/share/classes/sun/font/Type1Font.java
+48
-2
test/java/awt/FontClass/CreateFont/DeleteFont.java
test/java/awt/FontClass/CreateFont/DeleteFont.java
+10
-4
未找到文件。
src/share/classes/sun/font/FontManager.java
浏览文件 @
19b2b253
...
...
@@ -2361,7 +2361,7 @@ public final class FontManager {
font2D
=
new
TrueTypeFont
(
fontFilePath
,
null
,
0
,
true
);
break
;
case
Font
.
TYPE1_FONT
:
font2D
=
new
Type1Font
(
fontFilePath
,
null
);
font2D
=
new
Type1Font
(
fontFilePath
,
null
,
isCopy
);
break
;
default
:
throw
new
FontFormatException
(
"Unrecognised Font Format"
);
...
...
src/share/classes/sun/font/TrueTypeFont.java
浏览文件 @
19b2b253
...
...
@@ -174,8 +174,17 @@ public class TrueTypeFont extends FileFont {
super
(
platname
,
nativeNames
);
useJavaRasterizer
=
javaRasterizer
;
fontRank
=
Font2D
.
TTF_RANK
;
try
{
verify
();
init
(
fIndex
);
}
catch
(
Throwable
t
)
{
close
();
if
(
t
instanceof
FontFormatException
)
{
throw
(
FontFormatException
)
t
;
}
else
{
throw
new
FontFormatException
(
"Unexpected runtime exception."
);
}
}
Disposer
.
addObjectRecord
(
this
,
disposerRecord
);
}
...
...
src/share/classes/sun/font/Type1Font.java
浏览文件 @
19b2b253
...
...
@@ -39,6 +39,7 @@ import java.nio.BufferUnderflowException;
import
java.nio.channels.ClosedChannelException
;
import
java.nio.channels.FileChannel
;
import
sun.java2d.Disposer
;
import
sun.java2d.DisposerRecord
;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
java.awt.Font
;
...
...
@@ -76,6 +77,27 @@ import java.awt.Font;
*/
public
class
Type1Font
extends
FileFont
{
private
static
class
T1DisposerRecord
implements
DisposerRecord
{
String
fileName
=
null
;
T1DisposerRecord
(
String
name
)
{
fileName
=
name
;
}
public
synchronized
void
dispose
()
{
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
()
{
public
Object
run
()
{
if
(
fileName
!=
null
)
{
(
new
java
.
io
.
File
(
fileName
)).
delete
();
}
return
null
;
}
});
}
}
WeakReference
bufferRef
=
new
WeakReference
(
null
);
private
String
psName
=
null
;
...
...
@@ -124,6 +146,17 @@ public class Type1Font extends FileFont {
}
/**
* Constructs a Type1 Font.
* @param platname - Platform identifier of the font. Typically file name.
* @param nativeNames - Native names - typically XLFDs on Unix.
*/
public
Type1Font
(
String
platname
,
Object
nativeNames
)
throws
FontFormatException
{
this
(
platname
,
nativeNames
,
false
);
}
/**
* - does basic verification of the file
* - reads the names (full, family).
...
...
@@ -131,12 +164,25 @@ public class Type1Font extends FileFont {
* @throws FontFormatException - if the font can't be opened
* or fails verification, or there's no usable cmap
*/
public
Type1Font
(
String
platname
,
Object
nativeNames
)
public
Type1Font
(
String
platname
,
Object
nativeNames
,
boolean
createdCopy
)
throws
FontFormatException
{
super
(
platname
,
nativeNames
);
fontRank
=
Font2D
.
TYPE1_RANK
;
checkedNatives
=
true
;
try
{
verify
();
}
catch
(
Throwable
t
)
{
if
(
createdCopy
)
{
T1DisposerRecord
ref
=
new
T1DisposerRecord
(
platname
);
Disposer
.
addObjectRecord
(
bufferRef
,
ref
);
bufferRef
=
null
;
}
if
(
t
instanceof
FontFormatException
)
{
throw
(
FontFormatException
)
t
;
}
else
{
throw
new
FontFormatException
(
"Unexpected runtime exception."
);
}
}
}
private
synchronized
ByteBuffer
getBuffer
()
throws
FontFormatException
{
...
...
test/java/awt/FontClass/CreateFont/DeleteFont.java
浏览文件 @
19b2b253
...
...
@@ -55,17 +55,23 @@ public class DeleteFont {
if
(!
gotException
)
{
throw
new
RuntimeException
(
"No expected IOException"
);
}
badRead
(-
2
);
badRead
(
8193
);
badRead
(-
2
,
Font
.
TRUETYPE_FONT
);
badRead
(
8193
,
Font
.
TRUETYPE_FONT
);
badRead
(-
2
,
Font
.
TYPE1_FONT
);
badRead
(
8193
,
Font
.
TYPE1_FONT
);
// Make sure GC has a chance to clean up before we exit.
System
.
gc
();
System
.
gc
();
}
static
void
badRead
(
final
int
retval
)
{
static
void
badRead
(
final
int
retval
,
int
fontType
)
{
int
num
=
2
;
byte
[]
buff
=
new
byte
[
16
*
8192
];
// Multiple of 8192 is important.
for
(
int
ct
=
0
;
ct
<
num
;
++
ct
)
{
try
{
Font
.
createFont
(
Font
.
TRUETYPE_FONT
,
fontType
,
new
ByteArrayInputStream
(
buff
)
{
@Override
public
int
read
(
byte
[]
buff
,
int
off
,
int
len
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录