Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ce50fca0
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看板
提交
ce50fca0
编写于
8月 07, 2009
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
a8bb37d3
27f90c20
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
125 addition
and
36 deletion
+125
-36
make/sun/net/FILES_java.gmk
make/sun/net/FILES_java.gmk
+1
-0
src/share/classes/sun/misc/URLClassPath.java
src/share/classes/sun/misc/URLClassPath.java
+16
-12
src/share/classes/sun/net/util/URLUtil.java
src/share/classes/sun/net/util/URLUtil.java
+80
-0
src/solaris/classes/sun/net/www/protocol/jar/JarFileFactory.java
...aris/classes/sun/net/www/protocol/jar/JarFileFactory.java
+14
-12
src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java
...dows/classes/sun/net/www/protocol/jar/JarFileFactory.java
+14
-12
未找到文件。
make/sun/net/FILES_java.gmk
浏览文件 @
ce50fca0
...
@@ -41,6 +41,7 @@ FILES_java = \
...
@@ -41,6 +41,7 @@ FILES_java = \
sun/net/NetProperties.java \
sun/net/NetProperties.java \
sun/net/NetHooks.java \
sun/net/NetHooks.java \
sun/net/util/IPAddressUtil.java \
sun/net/util/IPAddressUtil.java \
sun/net/util/URLUtil.java \
sun/net/dns/ResolverConfiguration.java \
sun/net/dns/ResolverConfiguration.java \
sun/net/dns/ResolverConfigurationImpl.java \
sun/net/dns/ResolverConfigurationImpl.java \
sun/net/ftp/FtpClient.java \
sun/net/ftp/FtpClient.java \
...
...
src/share/classes/sun/misc/URLClassPath.java
浏览文件 @
ce50fca0
...
@@ -51,6 +51,7 @@ import java.security.PrivilegedAction;
...
@@ -51,6 +51,7 @@ import java.security.PrivilegedAction;
import
java.security.PrivilegedExceptionAction
;
import
java.security.PrivilegedExceptionAction
;
import
java.security.cert.Certificate
;
import
java.security.cert.Certificate
;
import
sun.misc.FileURLMapper
;
import
sun.misc.FileURLMapper
;
import
sun.net.util.URLUtil
;
/**
/**
* This class is used to maintain a search path of URLs for loading classes
* This class is used to maintain a search path of URLs for loading classes
...
@@ -80,7 +81,7 @@ public class URLClassPath {
...
@@ -80,7 +81,7 @@ public class URLClassPath {
ArrayList
<
Loader
>
loaders
=
new
ArrayList
<
Loader
>();
ArrayList
<
Loader
>
loaders
=
new
ArrayList
<
Loader
>();
/* Map of each URL opened to its corresponding Loader */
/* Map of each URL opened to its corresponding Loader */
HashMap
<
URL
,
Loader
>
lmap
=
new
HashMap
<
URL
,
Loader
>();
HashMap
<
String
,
Loader
>
lmap
=
new
HashMap
<
String
,
Loader
>();
/* The jar protocol handler to use when creating new URLs */
/* The jar protocol handler to use when creating new URLs */
private
URLStreamHandler
jarHandler
;
private
URLStreamHandler
jarHandler
;
...
@@ -317,7 +318,8 @@ public class URLClassPath {
...
@@ -317,7 +318,8 @@ public class URLClassPath {
// Skip this URL if it already has a Loader. (Loader
// Skip this URL if it already has a Loader. (Loader
// may be null in the case where URL has not been opened
// may be null in the case where URL has not been opened
// but is referenced by a JAR index.)
// but is referenced by a JAR index.)
if
(
lmap
.
containsKey
(
url
))
{
String
urlNoFragString
=
URLUtil
.
urlNoFragString
(
url
);
if
(
lmap
.
containsKey
(
urlNoFragString
))
{
continue
;
continue
;
}
}
// Otherwise, create a new Loader for the URL.
// Otherwise, create a new Loader for the URL.
...
@@ -336,7 +338,7 @@ public class URLClassPath {
...
@@ -336,7 +338,7 @@ public class URLClassPath {
}
}
// Finally, add the Loader to the search path.
// Finally, add the Loader to the search path.
loaders
.
add
(
loader
);
loaders
.
add
(
loader
);
lmap
.
put
(
url
,
loader
);
lmap
.
put
(
url
NoFragString
,
loader
);
}
}
return
loaders
.
get
(
index
);
return
loaders
.
get
(
index
);
}
}
...
@@ -576,7 +578,7 @@ public class URLClassPath {
...
@@ -576,7 +578,7 @@ public class URLClassPath {
private
JarIndex
index
;
private
JarIndex
index
;
private
MetaIndex
metaIndex
;
private
MetaIndex
metaIndex
;
private
URLStreamHandler
handler
;
private
URLStreamHandler
handler
;
private
HashMap
<
URL
,
Loader
>
lmap
;
private
HashMap
<
String
,
Loader
>
lmap
;
private
boolean
closed
=
false
;
private
boolean
closed
=
false
;
/*
/*
...
@@ -584,7 +586,7 @@ public class URLClassPath {
...
@@ -584,7 +586,7 @@ public class URLClassPath {
* a JAR file.
* a JAR file.
*/
*/
JarLoader
(
URL
url
,
URLStreamHandler
jarHandler
,
JarLoader
(
URL
url
,
URLStreamHandler
jarHandler
,
HashMap
<
URL
,
Loader
>
loaderMap
)
HashMap
<
String
,
Loader
>
loaderMap
)
throws
IOException
throws
IOException
{
{
super
(
new
URL
(
"jar"
,
""
,
-
1
,
url
+
"!/"
,
jarHandler
));
super
(
new
URL
(
"jar"
,
""
,
-
1
,
url
+
"!/"
,
jarHandler
));
...
@@ -663,8 +665,9 @@ public class URLClassPath {
...
@@ -663,8 +665,9 @@ public class URLClassPath {
try
{
try
{
URL
jarURL
=
new
URL
(
csu
,
jarfiles
[
i
]);
URL
jarURL
=
new
URL
(
csu
,
jarfiles
[
i
]);
// If a non-null loader already exists, leave it alone.
// If a non-null loader already exists, leave it alone.
if
(!
lmap
.
containsKey
(
jarURL
))
{
String
urlNoFragString
=
URLUtil
.
urlNoFragString
(
jarURL
);
lmap
.
put
(
jarURL
,
null
);
if
(!
lmap
.
containsKey
(
urlNoFragString
))
{
lmap
.
put
(
urlNoFragString
,
null
);
}
}
}
catch
(
MalformedURLException
e
)
{
}
catch
(
MalformedURLException
e
)
{
continue
;
continue
;
...
@@ -806,7 +809,7 @@ public class URLClassPath {
...
@@ -806,7 +809,7 @@ public class URLClassPath {
if
(
index
==
null
)
if
(
index
==
null
)
return
null
;
return
null
;
HashSet
<
URL
>
visited
=
new
HashSet
<
URL
>();
HashSet
<
String
>
visited
=
new
HashSet
<
String
>();
return
getResource
(
name
,
check
,
visited
);
return
getResource
(
name
,
check
,
visited
);
}
}
...
@@ -818,7 +821,7 @@ public class URLClassPath {
...
@@ -818,7 +821,7 @@ public class URLClassPath {
* non-existent resource
* non-existent resource
*/
*/
Resource
getResource
(
final
String
name
,
boolean
check
,
Resource
getResource
(
final
String
name
,
boolean
check
,
Set
<
URL
>
visited
)
{
Set
<
String
>
visited
)
{
Resource
res
;
Resource
res
;
Object
[]
jarFiles
;
Object
[]
jarFiles
;
...
@@ -843,7 +846,8 @@ public class URLClassPath {
...
@@ -843,7 +846,8 @@ public class URLClassPath {
try
{
try
{
url
=
new
URL
(
csu
,
jarName
);
url
=
new
URL
(
csu
,
jarName
);
if
((
newLoader
=
(
JarLoader
)
lmap
.
get
(
url
))
==
null
)
{
String
urlNoFragString
=
URLUtil
.
urlNoFragString
(
url
);
if
((
newLoader
=
(
JarLoader
)
lmap
.
get
(
urlNoFragString
))
==
null
)
{
/* no loader has been set up for this jar file
/* no loader has been set up for this jar file
* before
* before
*/
*/
...
@@ -867,7 +871,7 @@ public class URLClassPath {
...
@@ -867,7 +871,7 @@ public class URLClassPath {
}
}
/* put it in the global hashtable */
/* put it in the global hashtable */
lmap
.
put
(
url
,
newLoader
);
lmap
.
put
(
url
NoFragString
,
newLoader
);
}
}
}
catch
(
java
.
security
.
PrivilegedActionException
pae
)
{
}
catch
(
java
.
security
.
PrivilegedActionException
pae
)
{
continue
;
continue
;
...
@@ -879,7 +883,7 @@ public class URLClassPath {
...
@@ -879,7 +883,7 @@ public class URLClassPath {
/* Note that the addition of the url to the list of visited
/* Note that the addition of the url to the list of visited
* jars incorporates a check for presence in the hashmap
* jars incorporates a check for presence in the hashmap
*/
*/
boolean
visitedURL
=
!
visited
.
add
(
url
);
boolean
visitedURL
=
!
visited
.
add
(
URLUtil
.
urlNoFragString
(
url
)
);
if
(!
visitedURL
)
{
if
(!
visitedURL
)
{
try
{
try
{
newLoader
.
ensureOpen
();
newLoader
.
ensureOpen
();
...
...
src/share/classes/sun/net/util/URLUtil.java
0 → 100644
浏览文件 @
ce50fca0
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
sun.net.util
;
import
java.net.URL
;
/**
* URL Utility class.
*/
public
class
URLUtil
{
/**
* Returns a string form of the url suitable for use as a key in HashMap/Sets.
*
* The string form should be behave in the same manner as the URL when
* compared for equality in a HashMap/Set, except that no nameservice
* lookup is done on the hostname (only string comparison), and the fragment
* is not considered.
*
* @see java.net.URLStreamHandler.sameFile(java.net.URL)
*/
public
static
String
urlNoFragString
(
URL
url
)
{
StringBuilder
strForm
=
new
StringBuilder
();
String
protocol
=
url
.
getProtocol
();
if
(
protocol
!=
null
)
{
/* protocol is compared case-insensitive, so convert to lowercase */
protocol
=
protocol
.
toLowerCase
();
strForm
.
append
(
protocol
);
strForm
.
append
(
"://"
);
}
String
host
=
url
.
getHost
();
if
(
host
!=
null
)
{
/* host is compared case-insensitive, so convert to lowercase */
host
=
host
.
toLowerCase
();
strForm
.
append
(
host
);
int
port
=
url
.
getPort
();
if
(
port
==
-
1
)
{
/* if no port is specificed then use the protocols
* default, if there is one */
port
=
url
.
getDefaultPort
();
}
if
(
port
!=
-
1
)
{
strForm
.
append
(
":"
).
append
(
port
);
}
}
String
file
=
url
.
getFile
();
if
(
file
!=
null
)
{
strForm
.
append
(
file
);
}
return
strForm
.
toString
();
}
}
src/solaris/classes/sun/net/www/protocol/jar/JarFileFactory.java
浏览文件 @
ce50fca0
...
@@ -25,12 +25,14 @@
...
@@ -25,12 +25,14 @@
package
sun.net.www.protocol.jar
;
package
sun.net.www.protocol.jar
;
import
java.io.*
;
import
java.io.IOException
;
import
java.net.*
;
import
java.io.FileNotFoundException
;
import
java.util.*
;
import
java.net.URL
;
import
java.util.jar.*
;
import
java.net.URLConnection
;
import
java.util.zip.ZipFile
;
import
java.util.HashMap
;
import
java.util.jar.JarFile
;
import
java.security.Permission
;
import
java.security.Permission
;
import
sun.net.util.URLUtil
;
/* A factory for cached JAR file. This class is used to both retrieve
/* A factory for cached JAR file. This class is used to both retrieve
* and cache Jar files.
* and cache Jar files.
...
@@ -41,13 +43,13 @@ import java.security.Permission;
...
@@ -41,13 +43,13 @@ import java.security.Permission;
class
JarFileFactory
implements
URLJarFile
.
URLJarFileCloseController
{
class
JarFileFactory
implements
URLJarFile
.
URLJarFileCloseController
{
/* the url to file cache */
/* the url to file cache */
private
static
HashMap
fileCache
=
new
HashMap
();
private
static
HashMap
<
String
,
JarFile
>
fileCache
=
new
HashMap
<
String
,
JarFile
>
();
/* the file to url cache */
/* the file to url cache */
private
static
HashMap
urlCache
=
new
HashMap
();
private
static
HashMap
<
JarFile
,
URL
>
urlCache
=
new
HashMap
<
JarFile
,
URL
>
();
URLConnection
getConnection
(
JarFile
jarFile
)
throws
IOException
{
URLConnection
getConnection
(
JarFile
jarFile
)
throws
IOException
{
URL
u
=
(
URL
)
urlCache
.
get
(
jarFile
);
URL
u
=
urlCache
.
get
(
jarFile
);
if
(
u
!=
null
)
if
(
u
!=
null
)
return
u
.
openConnection
();
return
u
.
openConnection
();
...
@@ -72,7 +74,7 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
...
@@ -72,7 +74,7 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
synchronized
(
this
)
{
synchronized
(
this
)
{
result
=
getCachedJarFile
(
url
);
result
=
getCachedJarFile
(
url
);
if
(
result
==
null
)
{
if
(
result
==
null
)
{
fileCache
.
put
(
url
,
local_result
);
fileCache
.
put
(
URLUtil
.
urlNoFragString
(
url
)
,
local_result
);
urlCache
.
put
(
local_result
,
url
);
urlCache
.
put
(
local_result
,
url
);
result
=
local_result
;
result
=
local_result
;
}
else
{
}
else
{
...
@@ -97,15 +99,15 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
...
@@ -97,15 +99,15 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
* remove the JarFile from the cache
* remove the JarFile from the cache
*/
*/
public
void
close
(
JarFile
jarFile
)
{
public
void
close
(
JarFile
jarFile
)
{
URL
urlRemoved
=
(
URL
)
urlCache
.
remove
(
jarFile
);
URL
urlRemoved
=
urlCache
.
remove
(
jarFile
);
if
(
urlRemoved
!=
null
)
{
if
(
urlRemoved
!=
null
)
{
fileCache
.
remove
(
urlRemoved
);
fileCache
.
remove
(
URLUtil
.
urlNoFragString
(
urlRemoved
)
);
}
}
}
}
private
JarFile
getCachedJarFile
(
URL
url
)
{
private
JarFile
getCachedJarFile
(
URL
url
)
{
JarFile
result
=
(
JarFile
)
fileCache
.
get
(
url
);
JarFile
result
=
fileCache
.
get
(
URLUtil
.
urlNoFragString
(
url
)
);
/* if the JAR file is cached, the permission will always be there */
/* if the JAR file is cached, the permission will always be there */
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
...
...
src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java
浏览文件 @
ce50fca0
...
@@ -25,12 +25,14 @@
...
@@ -25,12 +25,14 @@
package
sun.net.www.protocol.jar
;
package
sun.net.www.protocol.jar
;
import
java.io.*
;
import
java.io.IOException
;
import
java.net.*
;
import
java.io.FileNotFoundException
;
import
java.util.*
;
import
java.net.URL
;
import
java.util.jar.*
;
import
java.net.URLConnection
;
import
java.util.zip.ZipFile
;
import
java.util.HashMap
;
import
java.util.jar.JarFile
;
import
java.security.Permission
;
import
java.security.Permission
;
import
sun.net.util.URLUtil
;
/* A factory for cached JAR file. This class is used to both retrieve
/* A factory for cached JAR file. This class is used to both retrieve
* and cache Jar files.
* and cache Jar files.
...
@@ -41,13 +43,13 @@ import java.security.Permission;
...
@@ -41,13 +43,13 @@ import java.security.Permission;
class
JarFileFactory
implements
URLJarFile
.
URLJarFileCloseController
{
class
JarFileFactory
implements
URLJarFile
.
URLJarFileCloseController
{
/* the url to file cache */
/* the url to file cache */
private
static
HashMap
fileCache
=
new
HashMap
();
private
static
HashMap
<
String
,
JarFile
>
fileCache
=
new
HashMap
<
String
,
JarFile
>
();
/* the file to url cache */
/* the file to url cache */
private
static
HashMap
urlCache
=
new
HashMap
();
private
static
HashMap
<
JarFile
,
URL
>
urlCache
=
new
HashMap
<
JarFile
,
URL
>
();
URLConnection
getConnection
(
JarFile
jarFile
)
throws
IOException
{
URLConnection
getConnection
(
JarFile
jarFile
)
throws
IOException
{
URL
u
=
(
URL
)
urlCache
.
get
(
jarFile
);
URL
u
=
urlCache
.
get
(
jarFile
);
if
(
u
!=
null
)
if
(
u
!=
null
)
return
u
.
openConnection
();
return
u
.
openConnection
();
...
@@ -82,7 +84,7 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
...
@@ -82,7 +84,7 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
synchronized
(
this
)
{
synchronized
(
this
)
{
result
=
getCachedJarFile
(
url
);
result
=
getCachedJarFile
(
url
);
if
(
result
==
null
)
{
if
(
result
==
null
)
{
fileCache
.
put
(
url
,
local_result
);
fileCache
.
put
(
URLUtil
.
urlNoFragString
(
url
)
,
local_result
);
urlCache
.
put
(
local_result
,
url
);
urlCache
.
put
(
local_result
,
url
);
result
=
local_result
;
result
=
local_result
;
}
else
{
}
else
{
...
@@ -107,14 +109,14 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
...
@@ -107,14 +109,14 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
* remove the JarFile from the cache
* remove the JarFile from the cache
*/
*/
public
void
close
(
JarFile
jarFile
)
{
public
void
close
(
JarFile
jarFile
)
{
URL
urlRemoved
=
(
URL
)
urlCache
.
remove
(
jarFile
);
URL
urlRemoved
=
urlCache
.
remove
(
jarFile
);
if
(
urlRemoved
!=
null
)
{
if
(
urlRemoved
!=
null
)
{
fileCache
.
remove
(
urlRemoved
);
fileCache
.
remove
(
URLUtil
.
urlNoFragString
(
urlRemoved
)
);
}
}
}
}
private
JarFile
getCachedJarFile
(
URL
url
)
{
private
JarFile
getCachedJarFile
(
URL
url
)
{
JarFile
result
=
(
JarFile
)
fileCache
.
get
(
url
);
JarFile
result
=
fileCache
.
get
(
URLUtil
.
urlNoFragString
(
url
)
);
/* if the JAR file is cached, the permission will always be there */
/* if the JAR file is cached, the permission will always be there */
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录