Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4e6f3462
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,发现更多精彩内容 >>
提交
4e6f3462
编写于
1月 13, 2011
作者:
M
michaelm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6896088: URLClassLoader.close() apparently not working for JAR URLs on Windows
Reviewed-by: chegar
上级
a0fc2f27
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
147 addition
and
1 deletion
+147
-1
src/share/classes/sun/misc/URLClassPath.java
src/share/classes/sun/misc/URLClassPath.java
+17
-1
test/java/net/URLClassLoader/B6896088.java
test/java/net/URLClassLoader/B6896088.java
+130
-0
未找到文件。
src/share/classes/sun/misc/URLClassPath.java
浏览文件 @
4e6f3462
...
...
@@ -466,6 +466,7 @@ public class URLClassPath {
*/
private
static
class
Loader
implements
Closeable
{
private
final
URL
base
;
private
JarFile
jarfile
;
// if this points to a jar file
/*
* Creates a new Loader for the specified URL.
...
...
@@ -530,6 +531,17 @@ public class URLClassPath {
}
uc
=
url
.
openConnection
();
InputStream
in
=
uc
.
getInputStream
();
if
(
uc
instanceof
JarURLConnection
)
{
/* JarURLConnection.getInputStream() returns a separate
* instance on each call. So we have to close this here.
* The jar file cache will keep the file open.
* Also, need to remember the jar file so it can be closed
* in a hurry.
*/
JarURLConnection
juc
=
(
JarURLConnection
)
uc
;
jarfile
=
juc
.
getJarFile
();
in
.
close
();
}
}
catch
(
Exception
e
)
{
return
null
;
}
...
...
@@ -559,7 +571,11 @@ public class URLClassPath {
* close this loader and release all resources
* method overridden in sub-classes
*/
public
void
close
()
throws
IOException
{}
public
void
close
()
throws
IOException
{
if
(
jarfile
!=
null
)
{
jarfile
.
close
();
}
}
/*
* Returns the local class path for this loader, or null if none.
...
...
test/java/net/URLClassLoader/B6896088.java
0 → 100644
浏览文件 @
4e6f3462
/*
* 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 6896088
* @run main/othervm B6896088
* @summary URLClassLoader.close() apparently not working for JAR URLs on Windows
*/
import
java.net.*
;
import
java.io.*
;
import
java.nio.file.Path
;
public
class
B6896088
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
dir
=
System
.
getProperty
(
"test.classes"
);
File
jarf
=
new
File
(
dir
,
"foo.jar"
);
FileOutputStream
fos
=
new
FileOutputStream
(
jarf
);
fos
.
write
(
bytes
(
nums
));
fos
.
close
();
// Create URL using JAR protocol
String
jarName
=
(
jarf
.
toURI
()).
toString
();
URL
url
=
new
URL
(
"jar"
,
""
,
jarName
+
"!/"
);
// Create URLClassLoader from the URL
URLClassLoader
loader
=
new
URLClassLoader
(
new
URL
[]{
url
});
Class
c
=
loader
.
loadClass
(
"Foo"
);
// Close the URLClassLoader so we can delete/update the jar file
loader
.
close
();
// Now try to delete the jar file
if
(
jarf
.
delete
()
&&
!
jarf
.
exists
())
{
System
.
out
.
println
(
jarf
.
getName
()+
" File Deleted"
);
}
else
{
System
.
out
.
println
(
jarf
.
getName
()+
" File Not Deleted"
);
throw
new
RuntimeException
(
"File not deleted"
);
}
}
static
byte
[]
bytes
(
int
[]
i
)
{
byte
[]
buf
=
new
byte
[
i
.
length
];
for
(
int
j
=
0
;
j
<
i
.
length
;
j
++)
{
buf
[
j
]
=
(
byte
)
i
[
j
];
}
return
buf
;
}
/* contents of foo.jar */
static
final
int
nums
[]
=
{
0x50
,
0x4b
,
0x03
,
0x04
,
0x14
,
0x00
,
0x08
,
0x08
,
0x08
,
0x00
,
0xc8
,
0x61
,
0x90
,
0x3d
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x09
,
0x00
,
0x04
,
0x00
,
0x4d
,
0x45
,
0x54
,
0x41
,
0x2d
,
0x49
,
0x4e
,
0x46
,
0x2f
,
0xfe
,
0xca
,
0x00
,
0x00
,
0x03
,
0x00
,
0x50
,
0x4b
,
0x07
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x50
,
0x4b
,
0x03
,
0x04
,
0x14
,
0x00
,
0x08
,
0x08
,
0x08
,
0x00
,
0xc8
,
0x61
,
0x90
,
0x3d
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x14
,
0x00
,
0x00
,
0x00
,
0x4d
,
0x45
,
0x54
,
0x41
,
0x2d
,
0x49
,
0x4e
,
0x46
,
0x2f
,
0x4d
,
0x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,
0x90
,
0x3d
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x09
,
0x00
,
0x04
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x4d
,
0x45
,
0x54
,
0x41
,
0x2d
,
0x49
,
0x4e
,
0x46
,
0x2f
,
0xfe
,
0xca
,
0x00
,
0x00
,
0x50
,
0x4b
,
0x01
,
0x02
,
0x14
,
0x00
,
0x14
,
0x00
,
0x08
,
0x08
,
0x08
,
0x00
,
0xc8
,
0x61
,
0x90
,
0x3d
,
0x4c
,
0xd8
,
0x5e
,
0x68
,
0x49
,
0x00
,
0x00
,
0x00
,
0x4a
,
0x00
,
0x00
,
0x00
,
0x14
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x3d
,
0x00
,
0x00
,
0x00
,
0x4d
,
0x45
,
0x54
,
0x41
,
0x2d
,
0x49
,
0x4e
,
0x46
,
0x2f
,
0x4d
,
0x41
,
0x4e
,
0x49
,
0x46
,
0x45
,
0x53
,
0x54
,
0x2e
,
0x4d
,
0x46
,
0x50
,
0x4b
,
0x01
,
0x02
,
0x14
,
0x00
,
0x14
,
0x00
,
0x08
,
0x08
,
0x08
,
0x00
,
0xbd
,
0x61
,
0x90
,
0x3d
,
0x3e
,
0x0a
,
0xdc
,
0x88
,
0x98
,
0x00
,
0x00
,
0x00
,
0xb4
,
0x00
,
0x00
,
0x00
,
0x09
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xc8
,
0x00
,
0x00
,
0x00
,
0x46
,
0x6f
,
0x6f
,
0x2e
,
0x63
,
0x6c
,
0x61
,
0x73
,
0x73
,
0x50
,
0x4b
,
0x05
,
0x06
,
0x00
,
0x00
,
0x00
,
0x00
,
0x03
,
0x00
,
0x03
,
0x00
,
0xb4
,
0x00
,
0x00
,
0x00
,
0x97
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录