Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
66fa671c
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看板
提交
66fa671c
编写于
1月 06, 2011
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
d432c9f5
72f86c0d
变更
130
展开全部
隐藏空白更改
内联
并排
Showing
130 changed file
with
2074 addition
and
1849 deletion
+2074
-1849
make/common/shared/Defs-java.gmk
make/common/shared/Defs-java.gmk
+1
-1
src/share/bin/java.c
src/share/bin/java.c
+15
-6
src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java
...re/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java
+3
-3
src/share/classes/com/sun/java/util/jar/pack/Attribute.java
src/share/classes/com/sun/java/util/jar/pack/Attribute.java
+35
-29
src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
...are/classes/com/sun/java/util/jar/pack/BandStructure.java
+54
-51
src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
...share/classes/com/sun/java/util/jar/pack/ClassReader.java
+23
-25
src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java
...share/classes/com/sun/java/util/jar/pack/ClassWriter.java
+6
-8
src/share/classes/com/sun/java/util/jar/pack/Code.java
src/share/classes/com/sun/java/util/jar/pack/Code.java
+9
-17
src/share/classes/com/sun/java/util/jar/pack/Coding.java
src/share/classes/com/sun/java/util/jar/pack/Coding.java
+22
-18
src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java
...are/classes/com/sun/java/util/jar/pack/CodingChooser.java
+55
-53
src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java
...hare/classes/com/sun/java/util/jar/pack/ConstantPool.java
+27
-24
src/share/classes/com/sun/java/util/jar/pack/Constants.java
src/share/classes/com/sun/java/util/jar/pack/Constants.java
+4
-1
src/share/classes/com/sun/java/util/jar/pack/Driver.java
src/share/classes/com/sun/java/util/jar/pack/Driver.java
+28
-18
src/share/classes/com/sun/java/util/jar/pack/FixedList.java
src/share/classes/com/sun/java/util/jar/pack/FixedList.java
+174
-0
src/share/classes/com/sun/java/util/jar/pack/Fixups.java
src/share/classes/com/sun/java/util/jar/pack/Fixups.java
+6
-4
src/share/classes/com/sun/java/util/jar/pack/Histogram.java
src/share/classes/com/sun/java/util/jar/pack/Histogram.java
+10
-10
src/share/classes/com/sun/java/util/jar/pack/Instruction.java
...share/classes/com/sun/java/util/jar/pack/Instruction.java
+19
-5
src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java
...hare/classes/com/sun/java/util/jar/pack/NativeUnpack.java
+3
-3
src/share/classes/com/sun/java/util/jar/pack/Package.java
src/share/classes/com/sun/java/util/jar/pack/Package.java
+80
-82
src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
...are/classes/com/sun/java/util/jar/pack/PackageReader.java
+63
-53
src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
...are/classes/com/sun/java/util/jar/pack/PackageWriter.java
+73
-92
src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java
src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java
+20
-24
src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java
.../classes/com/sun/java/util/jar/pack/PopulationCoding.java
+29
-26
src/share/classes/com/sun/java/util/jar/pack/PropMap.java
src/share/classes/com/sun/java/util/jar/pack/PropMap.java
+118
-27
src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
...hare/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
+5
-5
src/share/classes/com/sun/java/util/jar/pack/Utils.java
src/share/classes/com/sun/java/util/jar/pack/Utils.java
+1
-1
src/share/classes/com/sun/media/sound/DirectAudioDevice.java
src/share/classes/com/sun/media/sound/DirectAudioDevice.java
+5
-2
src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java
.../classes/com/sun/script/javascript/RhinoScriptEngine.java
+28
-9
src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java
...s/com/sun/script/javascript/RhinoScriptEngineFactory.java
+4
-2
src/share/classes/com/sun/script/javascript/RhinoTopLevel.java
...hare/classes/com/sun/script/javascript/RhinoTopLevel.java
+0
-12
src/share/classes/com/sun/tools/script/shell/init.js
src/share/classes/com/sun/tools/script/shell/init.js
+2
-2
src/share/classes/java/io/DeleteOnExitHook.java
src/share/classes/java/io/DeleteOnExitHook.java
+2
-2
src/share/classes/java/io/File.java
src/share/classes/java/io/File.java
+3
-3
src/share/classes/java/io/FileInputStream.java
src/share/classes/java/io/FileInputStream.java
+1
-1
src/share/classes/java/io/FileOutputStream.java
src/share/classes/java/io/FileOutputStream.java
+1
-1
src/share/classes/java/io/FilePermission.java
src/share/classes/java/io/FilePermission.java
+3
-3
src/share/classes/java/io/ObjectInputStream.java
src/share/classes/java/io/ObjectInputStream.java
+3
-3
src/share/classes/java/io/ObjectOutputStream.java
src/share/classes/java/io/ObjectOutputStream.java
+3
-3
src/share/classes/java/io/ObjectStreamClass.java
src/share/classes/java/io/ObjectStreamClass.java
+13
-13
src/share/classes/java/lang/ApplicationShutdownHooks.java
src/share/classes/java/lang/ApplicationShutdownHooks.java
+1
-1
src/share/classes/java/lang/Character.java
src/share/classes/java/lang/Character.java
+2
-3
src/share/classes/java/lang/CharacterName.java
src/share/classes/java/lang/CharacterName.java
+1
-1
src/share/classes/java/lang/Class.java
src/share/classes/java/lang/Class.java
+13
-13
src/share/classes/java/lang/ClassLoader.java
src/share/classes/java/lang/ClassLoader.java
+16
-20
src/share/classes/java/lang/Package.java
src/share/classes/java/lang/Package.java
+3
-6
src/share/classes/java/lang/ProcessBuilder.java
src/share/classes/java/lang/ProcessBuilder.java
+2
-2
src/share/classes/java/lang/String.java
src/share/classes/java/lang/String.java
+1
-1
src/share/classes/java/lang/StringCoding.java
src/share/classes/java/lang/StringCoding.java
+3
-3
src/share/classes/java/lang/Thread.java
src/share/classes/java/lang/Thread.java
+3
-4
src/share/classes/java/lang/Throwable.java
src/share/classes/java/lang/Throwable.java
+2
-2
src/share/classes/java/lang/management/ManagementFactory.java
...share/classes/java/lang/management/ManagementFactory.java
+1
-1
src/share/classes/java/lang/management/PlatformComponent.java
...share/classes/java/lang/management/PlatformComponent.java
+3
-3
src/share/classes/java/lang/reflect/Constructor.java
src/share/classes/java/lang/reflect/Constructor.java
+1
-1
src/share/classes/java/lang/reflect/Proxy.java
src/share/classes/java/lang/reflect/Proxy.java
+3
-3
src/share/classes/java/lang/reflect/ReflectAccess.java
src/share/classes/java/lang/reflect/ReflectAccess.java
+1
-1
src/share/classes/java/sql/DriverManager.java
src/share/classes/java/sql/DriverManager.java
+1
-1
src/share/classes/java/sql/Statement.java
src/share/classes/java/sql/Statement.java
+1
-1
src/share/classes/java/util/AbstractList.java
src/share/classes/java/util/AbstractList.java
+4
-4
src/share/classes/java/util/Arrays.java
src/share/classes/java/util/Arrays.java
+1
-1
src/share/classes/java/util/Collections.java
src/share/classes/java/util/Collections.java
+77
-78
src/share/classes/java/util/EnumMap.java
src/share/classes/java/util/EnumMap.java
+1
-1
src/share/classes/java/util/EnumSet.java
src/share/classes/java/util/EnumSet.java
+3
-3
src/share/classes/java/util/Formatter.java
src/share/classes/java/util/Formatter.java
+1
-1
src/share/classes/java/util/HashMap.java
src/share/classes/java/util/HashMap.java
+2
-2
src/share/classes/java/util/HashSet.java
src/share/classes/java/util/HashSet.java
+5
-5
src/share/classes/java/util/Hashtable.java
src/share/classes/java/util/Hashtable.java
+5
-5
src/share/classes/java/util/IdentityHashMap.java
src/share/classes/java/util/IdentityHashMap.java
+2
-2
src/share/classes/java/util/JumboEnumSet.java
src/share/classes/java/util/JumboEnumSet.java
+1
-1
src/share/classes/java/util/LinkedHashMap.java
src/share/classes/java/util/LinkedHashMap.java
+2
-2
src/share/classes/java/util/LinkedList.java
src/share/classes/java/util/LinkedList.java
+4
-4
src/share/classes/java/util/ListResourceBundle.java
src/share/classes/java/util/ListResourceBundle.java
+1
-1
src/share/classes/java/util/PriorityQueue.java
src/share/classes/java/util/PriorityQueue.java
+1
-1
src/share/classes/java/util/Properties.java
src/share/classes/java/util/Properties.java
+1
-1
src/share/classes/java/util/RegularEnumSet.java
src/share/classes/java/util/RegularEnumSet.java
+1
-1
src/share/classes/java/util/ServiceLoader.java
src/share/classes/java/util/ServiceLoader.java
+3
-3
src/share/classes/java/util/TimSort.java
src/share/classes/java/util/TimSort.java
+1
-1
src/share/classes/java/util/TreeMap.java
src/share/classes/java/util/TreeMap.java
+7
-7
src/share/classes/java/util/TreeSet.java
src/share/classes/java/util/TreeSet.java
+8
-8
src/share/classes/java/util/WeakHashMap.java
src/share/classes/java/util/WeakHashMap.java
+4
-5
src/share/classes/java/util/jar/Pack200.java
src/share/classes/java/util/jar/Pack200.java
+2
-2
src/share/classes/java/util/logging/FileHandler.java
src/share/classes/java/util/logging/FileHandler.java
+1
-1
src/share/classes/java/util/logging/Level.java
src/share/classes/java/util/logging/Level.java
+1
-1
src/share/classes/java/util/logging/LogManager.java
src/share/classes/java/util/logging/LogManager.java
+4
-5
src/share/classes/java/util/logging/LogRecord.java
src/share/classes/java/util/logging/LogRecord.java
+1
-2
src/share/classes/java/util/logging/Logger.java
src/share/classes/java/util/logging/Logger.java
+3
-3
src/share/classes/java/util/logging/Logging.java
src/share/classes/java/util/logging/Logging.java
+1
-1
src/share/classes/java/util/prefs/AbstractPreferences.java
src/share/classes/java/util/prefs/AbstractPreferences.java
+3
-5
src/share/classes/java/util/regex/Pattern.java
src/share/classes/java/util/regex/Pattern.java
+3
-3
src/share/classes/java/util/zip/Inflater.java
src/share/classes/java/util/zip/Inflater.java
+6
-0
src/share/classes/java/util/zip/ZipFile.java
src/share/classes/java/util/zip/ZipFile.java
+3
-1
src/share/classes/java/util/zip/ZipOutputStream.java
src/share/classes/java/util/zip/ZipOutputStream.java
+2
-2
src/share/classes/javax/net/ssl/X509ExtendedTrustManager.java
...share/classes/javax/net/ssl/X509ExtendedTrustManager.java
+12
-12
src/share/classes/sun/io/Converters.java
src/share/classes/sun/io/Converters.java
+1
-1
src/share/classes/sun/launcher/LauncherHelper.java
src/share/classes/sun/launcher/LauncherHelper.java
+94
-54
src/share/classes/sun/security/jgss/krb5/CipherHelper.java
src/share/classes/sun/security/jgss/krb5/CipherHelper.java
+13
-21
src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java
...share/classes/sun/security/jgss/krb5/MessageToken_v2.java
+159
-194
src/share/classes/sun/security/jgss/krb5/MicToken_v2.java
src/share/classes/sun/security/jgss/krb5/MicToken_v2.java
+18
-22
src/share/classes/sun/security/jgss/krb5/WrapToken.java
src/share/classes/sun/security/jgss/krb5/WrapToken.java
+23
-21
src/share/classes/sun/security/jgss/krb5/WrapToken_v2.java
src/share/classes/sun/security/jgss/krb5/WrapToken_v2.java
+42
-301
src/share/classes/sun/security/pkcs11/Config.java
src/share/classes/sun/security/pkcs11/Config.java
+1
-0
src/share/classes/sun/security/pkcs11/P11Cipher.java
src/share/classes/sun/security/pkcs11/P11Cipher.java
+28
-13
src/share/classes/sun/security/ssl/CipherSuite.java
src/share/classes/sun/security/ssl/CipherSuite.java
+138
-111
src/share/classes/sun/security/ssl/ClientHandshaker.java
src/share/classes/sun/security/ssl/ClientHandshaker.java
+2
-3
src/share/classes/sun/security/ssl/HandshakeHash.java
src/share/classes/sun/security/ssl/HandshakeHash.java
+13
-97
src/share/classes/sun/security/ssl/ServerHandshaker.java
src/share/classes/sun/security/ssl/ServerHandshaker.java
+1
-2
src/share/classes/sun/tools/jstat/resources/jstat_options
src/share/classes/sun/tools/jstat/resources/jstat_options
+2
-2
src/share/classes/sun/util/logging/PlatformLogger.java
src/share/classes/sun/util/logging/PlatformLogger.java
+3
-3
src/share/demo/jvmti/heapTracker/heapTracker.c
src/share/demo/jvmti/heapTracker/heapTracker.c
+2
-2
src/solaris/classes/java/lang/ProcessEnvironment.java
src/solaris/classes/java/lang/ProcessEnvironment.java
+1
-1
src/solaris/classes/java/util/prefs/FileSystemPreferences.java
...olaris/classes/java/util/prefs/FileSystemPreferences.java
+7
-7
src/windows/classes/java/lang/ProcessEnvironment.java
src/windows/classes/java/lang/ProcessEnvironment.java
+2
-4
src/windows/native/java/net/Inet4AddressImpl.c
src/windows/native/java/net/Inet4AddressImpl.c
+2
-2
src/windows/native/java/net/Inet6AddressImpl.c
src/windows/native/java/net/Inet6AddressImpl.c
+2
-2
test/java/awt/xembed/server/TestXEmbedServer.java
test/java/awt/xembed/server/TestXEmbedServer.java
+5
-2
test/java/io/Serializable/NPEProvoker/NPEProvoker.java
test/java/io/Serializable/NPEProvoker/NPEProvoker.java
+1
-1
test/java/lang/instrument/ilib/Inject.java
test/java/lang/instrument/ilib/Inject.java
+1
-1
test/java/lang/instrument/ilib/InjectBytecodes.java
test/java/lang/instrument/ilib/InjectBytecodes.java
+1
-1
test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java
.../java/lang/reflect/Generics/TestPlainArrayNotGeneric.java
+1
-1
test/java/util/Random/DistinctSeeds.java
test/java/util/Random/DistinctSeeds.java
+1
-1
test/java/util/logging/ClassLoaderLeakTest.java
test/java/util/logging/ClassLoaderLeakTest.java
+1
-1
test/java/util/zip/ZipFile/FinalizeZipFile.java
test/java/util/zip/ZipFile/FinalizeZipFile.java
+100
-0
test/javax/script/VersionTest.java
test/javax/script/VersionTest.java
+2
-2
test/sun/security/krb5/auto/BasicKrb5Test.java
test/sun/security/krb5/auto/BasicKrb5Test.java
+38
-4
test/sun/security/krb5/auto/Context.java
test/sun/security/krb5/auto/Context.java
+53
-10
test/sun/security/krb5/auto/basic.sh
test/sun/security/krb5/auto/basic.sh
+0
-75
test/sun/security/pkcs11/Provider/ConfigShortPath.java
test/sun/security/pkcs11/Provider/ConfigShortPath.java
+49
-0
test/sun/security/pkcs11/Provider/csp.cfg
test/sun/security/pkcs11/Provider/csp.cfg
+4
-0
test/sun/tools/jstat/gcNewCapacityOutput1.awk
test/sun/tools/jstat/gcNewCapacityOutput1.awk
+1
-1
test/tools/launcher/Settings.java
test/tools/launcher/Settings.java
+9
-2
test/tools/pack200/T7007157.java
test/tools/pack200/T7007157.java
+67
-0
未找到文件。
make/common/shared/Defs-java.gmk
浏览文件 @
66fa671c
...
...
@@ -155,7 +155,7 @@ ifdef LANGTOOLS_DIST
"-Xbootclasspath/p:$(JAVAC_JAR)" \
-jar $(JAVAC_JAR) $(JAVACFLAGS)
JAVAH_CMD = $(BOOT_JAVA_CMD) \
"-Xbootclasspath/p:$(JAVAH_JAR)$(CLASSPATH_SEPARATOR)$(JAVA
DOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVA
C_JAR)" \
"-Xbootclasspath/p:$(JAVAH_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)" \
-jar $(JAVAH_JAR) $(JAVAHFLAGS)
JAVADOC_CMD = $(BOOT_JAVA_CMD) \
"-Xbootclasspath/p:$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)$(CLASSPATH_SEPARATOR)$(DOCLETS_JAR)" \
...
...
src/share/bin/java.c
浏览文件 @
66fa671c
...
...
@@ -158,8 +158,9 @@ static jboolean IsWildCardEnabled();
* Running Java code in primordial thread caused many problems. We will
* create a new thread to invoke JVM. See 6316197 for more information.
*/
static
jlong
threadStackSize
=
0
;
/* stack size of the new thread */
static
jlong
heapSize
=
0
;
/* heap size */
static
jlong
threadStackSize
=
0
;
/* stack size of the new thread */
static
jlong
maxHeapSize
=
0
;
/* max heap size */
static
jlong
initialHeapSize
=
0
;
/* inital heap size */
int
JNICALL
JavaMain
(
void
*
args
);
/* entry point */
...
...
@@ -381,7 +382,7 @@ JavaMain(void * _args)
if
(
showSettings
!=
NULL
)
{
ShowSettings
(
env
,
showSettings
);
CHECK_EXCEPTION_LEAVE
(
0
);
CHECK_EXCEPTION_LEAVE
(
1
);
}
/* If the user specified neither a class name nor a JAR file */
if
(
printXUsage
||
printUsage
||
(
jarfile
==
0
&&
classname
==
0
))
{
...
...
@@ -689,7 +690,14 @@ AddOption(char *str, void *info)
if
(
JLI_StrCCmp
(
str
,
"-Xmx"
)
==
0
)
{
jlong
tmp
;
if
(
parse_size
(
str
+
4
,
&
tmp
))
{
heapSize
=
tmp
;
maxHeapSize
=
tmp
;
}
}
if
(
JLI_StrCCmp
(
str
,
"-Xms"
)
==
0
)
{
jlong
tmp
;
if
(
parse_size
(
str
+
4
,
&
tmp
))
{
initialHeapSize
=
tmp
;
}
}
}
...
...
@@ -1506,12 +1514,13 @@ ShowSettings(JNIEnv *env, char *optString)
jstring
joptString
;
NULL_CHECK
(
cls
=
FindBootStrapClass
(
env
,
"sun/launcher/LauncherHelper"
));
NULL_CHECK
(
showSettingsID
=
(
*
env
)
->
GetStaticMethodID
(
env
,
cls
,
"showSettings"
,
"(ZLjava/lang/String;JJZ)V"
));
"showSettings"
,
"(ZLjava/lang/String;JJ
J
Z)V"
));
joptString
=
(
*
env
)
->
NewStringUTF
(
env
,
optString
);
(
*
env
)
->
CallStaticVoidMethod
(
env
,
cls
,
showSettingsID
,
JNI_TRUE
,
joptString
,
(
jlong
)
heapSize
,
(
jlong
)
initialHeapSize
,
(
jlong
)
maxHeapSize
,
(
jlong
)
threadStackSize
,
ServerClassMachine
());
}
...
...
src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java
浏览文件 @
66fa671c
...
...
@@ -29,13 +29,14 @@ import java.io.ByteArrayOutputStream;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Adaptive coding.
* See the section "Adaptive Encodings" in the Pack200 spec.
* @author John Rose
*/
class
AdaptiveCoding
implements
Co
nstants
,
Co
dingMethod
{
class
AdaptiveCoding
implements
CodingMethod
{
CodingMethod
headCoding
;
int
headLength
;
CodingMethod
tailCoding
;
...
...
@@ -147,7 +148,6 @@ class AdaptiveCoding implements Constants, CodingMethod {
}
if
(
KX
==
KX_MAX
)
return
Integer
.
MAX_VALUE
;
KX
+=
1
;
int
unit2
=
1
<<
(
KX
*
KX_LG2BASE
);
int
mask2
=
KB_MAX
<<
(
KX
*
KX_LG2BASE
);
K1
|=
(
mask
&
~
mask2
);
K1
+=
unit
;
...
...
@@ -250,7 +250,7 @@ class AdaptiveCoding implements Constants, CodingMethod {
return
m
.
toString
();
}
public
String
toString
()
{
StringBu
ffer
res
=
new
StringBuff
er
(
20
);
StringBu
ilder
res
=
new
StringBuild
er
(
20
);
AdaptiveCoding
run
=
this
;
res
.
append
(
"run("
);
for
(;;)
{
...
...
src/share/classes/com/sun/java/util/jar/pack/Attribute.java
浏览文件 @
66fa671c
...
...
@@ -36,6 +36,7 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Represents an attribute in a class-file.
...
...
@@ -44,7 +45,7 @@ import java.util.Map;
* attribute layouts.
* @author John Rose
*/
class
Attribute
implements
Comparable
,
Constants
{
class
Attribute
implements
Comparable
{
// Attribute instance fields.
Layout
def
;
// the name and format of this attr
...
...
@@ -103,7 +104,6 @@ class Attribute implements Comparable, Constants {
return
this
.
def
.
compareTo
(
that
.
def
);
}
private
static
final
byte
[]
noBytes
=
{};
private
static
final
Map
<
List
<
Attribute
>,
List
<
Attribute
>>
canonLists
=
new
HashMap
<>();
private
static
final
Map
<
Layout
,
Attribute
>
attributes
=
new
HashMap
<>();
private
static
final
Map
<
Layout
,
Attribute
>
standardDefs
=
new
HashMap
<>();
...
...
@@ -112,7 +112,7 @@ class Attribute implements Comparable, Constants {
// are used by trimToSize, in order to reduce footprint
// of some common cases. (Note that Code attributes are
// always zero size.)
public
static
List
getCanonList
(
List
<
Attribute
>
al
)
{
public
static
List
<
Attribute
>
getCanonList
(
List
<
Attribute
>
al
)
{
synchronized
(
canonLists
)
{
List
<
Attribute
>
cl
=
canonLists
.
get
(
al
);
if
(
cl
==
null
)
{
...
...
@@ -465,7 +465,9 @@ class Attribute implements Comparable, Constants {
return
ConstantPool
.
getUtf8Entry
(
name
());
}
public
boolean
isEmpty
()
{
return
layout
==
""
;
}
public
boolean
isEmpty
()
{
return
layout
.
isEmpty
();
}
public
Layout
(
int
ctype
,
String
name
,
String
layout
)
{
this
.
ctype
=
ctype
;
...
...
@@ -479,19 +481,19 @@ class Attribute implements Comparable, Constants {
}
else
{
String
[]
bodies
=
splitBodies
(
layout
);
// Make the callables now, so they can be linked immediately.
Element
[]
elems
=
new
Element
[
bodies
.
length
];
this
.
elems
=
elems
;
for
(
int
i
=
0
;
i
<
elems
.
length
;
i
++)
{
Element
[]
l
elems
=
new
Element
[
bodies
.
length
];
this
.
elems
=
l
elems
;
for
(
int
i
=
0
;
i
<
l
elems
.
length
;
i
++)
{
Element
ce
=
this
.
new
Element
();
ce
.
kind
=
EK_CBLE
;
ce
.
removeBand
();
ce
.
bandIndex
=
NO_BAND_INDEX
;
ce
.
layout
=
bodies
[
i
];
elems
[
i
]
=
ce
;
l
elems
[
i
]
=
ce
;
}
// Next fill them in.
for
(
int
i
=
0
;
i
<
elems
.
length
;
i
++)
{
Element
ce
=
elems
[
i
];
for
(
int
i
=
0
;
i
<
l
elems
.
length
;
i
++)
{
Element
ce
=
l
elems
[
i
];
ce
.
body
=
tokenizeLayout
(
this
,
i
,
bodies
[
i
]);
}
//System.out.println(Arrays.asList(elems));
...
...
@@ -525,11 +527,12 @@ class Attribute implements Comparable, Constants {
}
public
boolean
equals
(
Object
x
)
{
return
x
instanceof
Layout
&&
equals
((
Layout
)
x
);
return
(
x
!=
null
)
&&
(
x
.
getClass
()
==
Layout
.
class
)
&&
equals
((
Layout
)
x
);
}
public
boolean
equals
(
Layout
that
)
{
return
this
.
name
==
that
.
name
&&
this
.
layout
==
that
.
layout
return
this
.
name
.
equals
(
that
.
name
)
&&
this
.
layout
.
equals
(
that
.
layout
)
&&
this
.
ctype
==
that
.
ctype
;
}
public
int
hashCode
()
{
...
...
@@ -589,14 +592,14 @@ class Attribute implements Comparable, Constants {
return
str
;
}
private
String
stringForDebug
()
{
Element
[]
body
=
this
.
body
;
Element
[]
l
body
=
this
.
body
;
switch
(
kind
)
{
case
EK_CALL:
body
=
null
;
l
body
=
null
;
break
;
case
EK_CASE:
if
(
flagTest
(
EF_BACK
))
body
=
null
;
l
body
=
null
;
break
;
}
return
layout
...
...
@@ -604,7 +607,7 @@ class Attribute implements Comparable, Constants {
+
"<"
+
(
flags
==
0
?
""
:
""
+
flags
)+
kind
+
len
+
(
refKind
==
0
?
""
:
""
+
refKind
)
+
">"
+
(
value
==
0
?
""
:
"("
+
value
+
")"
)
+
(
body
==
null
?
""
:
""
+
Arrays
.
asList
(
body
));
+
(
lbody
==
null
?
""
:
""
+
Arrays
.
asList
(
l
body
));
}
}
...
...
@@ -613,16 +616,19 @@ class Attribute implements Comparable, Constants {
}
static
private
final
Element
[]
noElems
=
{};
public
Element
[]
getCallables
()
{
if
(
hasCallables
())
return
elems
;
else
if
(
hasCallables
())
{
Element
[]
nelems
=
Arrays
.
copyOf
(
elems
,
elems
.
length
);
return
nelems
;
}
else
return
noElems
;
// no callables at all
}
public
Element
[]
getEntryPoint
()
{
if
(
hasCallables
())
return
elems
[
0
].
body
;
// body of first callable
else
return
elems
;
// no callables; whole body
else
{
Element
[]
nelems
=
Arrays
.
copyOf
(
elems
,
elems
.
length
);
return
nelems
;
// no callables; whole body
}
}
/** Return a sequence of tokens from the given attribute bytes.
...
...
@@ -674,7 +680,7 @@ class Attribute implements Comparable, Constants {
}
}
void
visitRefs
(
Holder
holder
,
int
mode
,
final
Collection
refs
)
{
void
visitRefs
(
Holder
holder
,
int
mode
,
final
Collection
<
Entry
>
refs
)
{
if
(
mode
==
VRM_CLASSIC
)
{
refs
.
add
(
getNameRef
());
}
...
...
@@ -720,7 +726,7 @@ class Attribute implements Comparable, Constants {
*/
static
public
String
normalizeLayoutString
(
String
layout
)
{
StringBu
ffer
buf
=
new
StringBuff
er
();
StringBu
ilder
buf
=
new
StringBuild
er
();
for
(
int
i
=
0
,
len
=
layout
.
length
();
i
<
len
;
)
{
char
ch
=
layout
.
charAt
(
i
++);
if
(
ch
<=
' '
)
{
...
...
@@ -832,14 +838,14 @@ class Attribute implements Comparable, Constants {
*/
static
//private
Layout
.
Element
[]
tokenizeLayout
(
Layout
self
,
int
curCble
,
String
layout
)
{
Array
List
<
Layout
.
Element
>
col
=
new
ArrayList
<>(
layout
.
length
());
List
<
Layout
.
Element
>
col
=
new
ArrayList
<>(
layout
.
length
());
tokenizeLayout
(
self
,
curCble
,
layout
,
col
);
Layout
.
Element
[]
res
=
new
Layout
.
Element
[
col
.
size
()];
col
.
toArray
(
res
);
return
res
;
}
static
//private
void
tokenizeLayout
(
Layout
self
,
int
curCble
,
String
layout
,
Array
List
<
Layout
.
Element
>
col
)
{
void
tokenizeLayout
(
Layout
self
,
int
curCble
,
String
layout
,
List
<
Layout
.
Element
>
col
)
{
boolean
prevBCI
=
false
;
for
(
int
len
=
layout
.
length
(),
i
=
0
;
i
<
len
;
)
{
int
start
=
i
;
...
...
@@ -897,7 +903,7 @@ class Attribute implements Comparable, Constants {
case
'T'
:
// union: 'T' any_int union_case* '(' ')' '[' body ']'
kind
=
EK_UN
;
i
=
tokenizeSInt
(
e
,
layout
,
i
);
Array
List
<
Layout
.
Element
>
cases
=
new
ArrayList
<>();
List
<
Layout
.
Element
>
cases
=
new
ArrayList
<>();
for
(;;)
{
// Keep parsing cases until we hit the default case.
if
(
layout
.
charAt
(
i
++)
!=
'('
)
...
...
@@ -1051,7 +1057,7 @@ class Attribute implements Comparable, Constants {
}
static
//private
String
[]
splitBodies
(
String
layout
)
{
Array
List
<
String
>
bodies
=
new
ArrayList
<>();
List
<
String
>
bodies
=
new
ArrayList
<>();
// Parse several independent layout bodies: "[foo][bar]...[baz]"
for
(
int
i
=
0
;
i
<
layout
.
length
();
i
++)
{
if
(
layout
.
charAt
(
i
++)
!=
'['
)
...
...
@@ -1156,7 +1162,7 @@ class Attribute implements Comparable, Constants {
String
expandCaseDashNotation
(
String
layout
)
{
int
dash
=
findCaseDash
(
layout
,
0
);
if
(
dash
<
0
)
return
layout
;
// no dashes (the common case)
StringBu
ffer
result
=
new
StringBuff
er
(
layout
.
length
()
*
3
);
StringBu
ilder
result
=
new
StringBuild
er
(
layout
.
length
()
*
3
);
int
sofar
=
0
;
// how far have we processed the layout?
for
(;;)
{
// for each dash, collect everything up to the dash
...
...
src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
浏览文件 @
66fa671c
...
...
@@ -44,16 +44,17 @@ import java.util.ArrayList;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.jar.Pack200
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Define the structure and ordering of "bands" in a packed file.
* @author John Rose
*/
abstract
class
BandStructure
implements
Constants
{
class
BandStructure
{
static
final
int
MAX_EFFORT
=
9
;
static
final
int
MIN_EFFORT
=
1
;
static
final
int
DEFAULT_EFFORT
=
5
;
...
...
@@ -251,18 +252,18 @@ class BandStructure implements Constants {
null
};
final
private
static
HashMap
basicCodingIndexes
;
final
private
static
Map
<
Coding
,
Integer
>
basicCodingIndexes
;
static
{
assert
(
basicCodings
[
_meta_default
]
==
null
);
assert
(
basicCodings
[
_meta_canon_min
]
!=
null
);
assert
(
basicCodings
[
_meta_canon_max
]
!=
null
);
HashMap
map
=
new
HashMap
();
Map
<
Coding
,
Integer
>
map
=
new
HashMap
<>
();
for
(
int
i
=
0
;
i
<
basicCodings
.
length
;
i
++)
{
Coding
c
=
basicCodings
[
i
];
if
(
c
==
null
)
continue
;
assert
(
i
>=
_meta_canon_min
);
assert
(
i
<=
_meta_canon_max
);
map
.
put
(
c
,
new
Integer
(
i
)
);
map
.
put
(
c
,
i
);
}
basicCodingIndexes
=
map
;
}
...
...
@@ -270,12 +271,12 @@ class BandStructure implements Constants {
return
i
<
basicCodings
.
length
?
basicCodings
[
i
]
:
null
;
}
public
static
int
indexOf
(
Coding
c
)
{
Integer
i
=
(
Integer
)
basicCodingIndexes
.
get
(
c
);
Integer
i
=
basicCodingIndexes
.
get
(
c
);
if
(
i
==
null
)
return
0
;
return
i
.
intValue
();
}
public
static
Coding
[]
getBasicCodings
()
{
return
(
Coding
[])
basicCodings
.
clone
();
return
basicCodings
.
clone
();
}
protected
byte
[]
bandHeaderBytes
;
// used for input only
...
...
@@ -687,7 +688,6 @@ class BandStructure implements Constants {
}
bandCoding
.
writeArrayTo
(
out
,
values
,
0
,
length
);
if
(
out
==
outputCounter
)
{
long
len1
=
outputCounter
.
getCount
();
assert
(
outputSize
==
outputCounter
.
getCount
()
-
len0
)
:
(
outputSize
+
" != "
+
outputCounter
.
getCount
()+
"-"
+
len0
);
}
...
...
@@ -1050,8 +1050,8 @@ class BandStructure implements Constants {
// Bootstrap support for CPRefBands. These are needed to record
// intended CP indexes, before the CP has been created.
private
ArrayList
allKQBands
=
new
ArrayList
();
private
ArrayList
needPredefIndex
=
new
ArrayList
();
private
final
List
<
CPRefBand
>
allKQBands
=
new
ArrayList
<>
();
private
List
<
Object
[]>
needPredefIndex
=
new
ArrayList
<>
();
int
encodeRef
(
Entry
e
,
Index
ix
)
{
...
...
@@ -1078,9 +1078,9 @@ class BandStructure implements Constants {
&&
this
instanceof
PackageWriter
)
{
// Twist the random state based on my first file.
// This sends each segment off in a different direction.
List
classes
=
((
PackageWriter
)
this
).
pkg
.
classes
;
List
<
Package
.
Class
>
classes
=
((
PackageWriter
)
this
).
pkg
.
classes
;
if
(!
classes
.
isEmpty
())
{
Package
.
Class
cls
=
(
Package
.
Class
)
classes
.
get
(
0
);
Package
.
Class
cls
=
classes
.
get
(
0
);
codingChooser
.
addStressSeed
(
cls
.
getName
().
hashCode
());
}
}
...
...
@@ -1619,8 +1619,7 @@ class BandStructure implements Constants {
/** Given CP indexes, distribute tag-specific indexes to bands. */
protected
void
setBandIndexes
()
{
// Handle prior calls to setBandIndex:
for
(
Iterator
i
=
needPredefIndex
.
iterator
();
i
.
hasNext
();
)
{
Object
[]
need
=
(
Object
[])
i
.
next
();
for
(
Object
[]
need
:
needPredefIndex
)
{
CPRefBand
b
=
(
CPRefBand
)
need
[
0
];
Byte
which
=
(
Byte
)
need
[
1
];
b
.
setIndex
(
getCPIndex
(
which
.
byteValue
()));
...
...
@@ -1633,7 +1632,7 @@ class BandStructure implements Constants {
}
protected
void
setBandIndex
(
CPRefBand
b
,
byte
which
)
{
Object
[]
need
=
{
b
,
new
Byte
(
which
)
};
Object
[]
need
=
{
b
,
Byte
.
valueOf
(
which
)
};
if
(
which
==
CONSTANT_Literal
)
{
// I.e., attribute layouts KQ (no null) or KQN (null ok).
allKQBands
.
add
(
b
);
...
...
@@ -1645,7 +1644,7 @@ class BandStructure implements Constants {
}
}
protected
void
setConstantValueIndex
(
com
.
sun
.
java
.
util
.
jar
.
pack
.
Package
.
Class
.
Field
f
)
{
protected
void
setConstantValueIndex
(
Field
f
)
{
Index
ix
=
null
;
if
(
f
!=
null
)
{
byte
tag
=
f
.
getLiteralTag
();
...
...
@@ -1655,8 +1654,7 @@ class BandStructure implements Constants {
assert
(
ix
!=
null
);
}
// Typically, allKQBands is the singleton of field_ConstantValue_KQ.
for
(
Iterator
i
=
allKQBands
.
iterator
();
i
.
hasNext
();
)
{
CPRefBand
xxx_KQ
=
(
CPRefBand
)
i
.
next
();
for
(
CPRefBand
xxx_KQ
:
allKQBands
)
{
xxx_KQ
.
setIndex
(
ix
);
}
}
...
...
@@ -1688,7 +1686,7 @@ class BandStructure implements Constants {
protected
int
attrClassFileVersionMask
;
// Mapping from Attribute.Layout to Band[] (layout element bands).
protected
HashMap
attrBandTable
=
new
HashMap
();
protected
Map
<
Attribute
.
Layout
,
Band
[]>
attrBandTable
=
new
HashMap
<>
();
// Well-known attributes:
protected
final
Attribute
.
Layout
attrCodeEmpty
;
...
...
@@ -1697,15 +1695,18 @@ class BandStructure implements Constants {
protected
final
Attribute
.
Layout
attrConstantValue
;
// Mapping from Attribute.Layout to Integer (inverse of attrDefs)
HashMap
attrIndexTable
=
new
HashMap
();
Map
<
Attribute
.
Layout
,
Integer
>
attrIndexTable
=
new
HashMap
<>
();
// Mapping from attribute index (<32 are flag bits) to attributes.
protected
ArrayList
[]
attrDefs
=
new
ArrayList
[
ATTR_CONTEXT_LIMIT
];
protected
List
<
List
<
Attribute
.
Layout
>>
attrDefs
=
new
FixedList
<>(
ATTR_CONTEXT_LIMIT
);
{
for
(
int
i
=
0
;
i
<
ATTR_CONTEXT_LIMIT
;
i
++)
{
assert
(
attrIndexLimit
[
i
]
==
0
);
attrIndexLimit
[
i
]
=
32
;
// just for the sake of predefs.
attrDefs
[
i
]
=
new
ArrayList
(
Collections
.
nCopies
(
attrIndexLimit
[
i
],
null
));
attrDefs
.
set
(
i
,
new
ArrayList
<>(
Collections
.
nCopies
(
attrIndexLimit
[
i
],
(
Attribute
.
Layout
)
null
)));
}
// Add predefined attribute definitions:
...
...
@@ -1867,9 +1868,10 @@ class BandStructure implements Constants {
for
(
int
i
=
0
;
i
<
ATTR_CONTEXT_LIMIT
;
i
++)
{
assert
(
attrIndexLimit
[
i
]
==
0
);
// decide on it now!
attrIndexLimit
[
i
]
=
(
haveFlagsHi
(
i
)?
63
:
32
);
assert
(
attrDefs
[
i
].
size
()
==
32
);
// all predef indexes are <32
int
addMore
=
attrIndexLimit
[
i
]
-
attrDefs
[
i
].
size
();
attrDefs
[
i
].
addAll
(
Collections
.
nCopies
(
addMore
,
null
));
List
<
Attribute
.
Layout
>
defList
=
attrDefs
.
get
(
i
);
assert
(
defList
.
size
()
==
32
);
// all predef indexes are <32
int
addMore
=
attrIndexLimit
[
i
]
-
defList
.
size
();
defList
.
addAll
(
Collections
.
nCopies
(
addMore
,
(
Attribute
.
Layout
)
null
));
}
}
...
...
@@ -1890,13 +1892,13 @@ class BandStructure implements Constants {
return
testBit
(
archiveOptions
,
mask
);
}
protected
Array
List
getPredefinedAttrs
(
int
ctype
)
{
protected
List
getPredefinedAttrs
(
int
ctype
)
{
assert
(
attrIndexLimit
[
ctype
]
!=
0
);
ArrayList
res
=
new
ArrayList
(
attrIndexLimit
[
ctype
]);
List
<
Attribute
.
Layout
>
res
=
new
ArrayList
<>
(
attrIndexLimit
[
ctype
]);
// Remove nulls and non-predefs.
for
(
int
ai
=
0
;
ai
<
attrIndexLimit
[
ctype
];
ai
++)
{
if
(
testBit
(
attrDefSeen
[
ctype
],
1L
<<
ai
))
continue
;
Attribute
.
Layout
def
=
(
Attribute
.
Layout
)
attrDefs
[
ctype
]
.
get
(
ai
);
Attribute
.
Layout
def
=
attrDefs
.
get
(
ctype
)
.
get
(
ai
);
if
(
def
==
null
)
continue
;
// unused flag bit
assert
(
isPredefinedAttr
(
ctype
,
ai
));
res
.
add
(
def
);
...
...
@@ -1910,7 +1912,7 @@ class BandStructure implements Constants {
if
(
ai
>=
attrIndexLimit
[
ctype
])
return
false
;
// If the bit is set, it was explicitly def'd.
if
(
testBit
(
attrDefSeen
[
ctype
],
1L
<<
ai
))
return
false
;
return
(
attrDefs
[
ctype
]
.
get
(
ai
)
!=
null
);
return
(
attrDefs
.
get
(
ctype
)
.
get
(
ai
)
!=
null
);
}
protected
void
adjustSpecialAttrMasks
()
{
...
...
@@ -2050,8 +2052,8 @@ class BandStructure implements Constants {
System
.
out
.
println
(
"Removing predefined "
+
ATTR_CONTEXT_NAME
[
ctype
]+
" attribute on bit "
+
index
);
}
List
defList
=
attrDefs
[
ctype
]
;
Attribute
.
Layout
def
=
(
Attribute
.
Layout
)
defList
.
get
(
index
);
List
<
Attribute
.
Layout
>
defList
=
attrDefs
.
get
(
ctype
)
;
Attribute
.
Layout
def
=
defList
.
get
(
index
);
assert
(
def
!=
null
);
defList
.
set
(
index
,
null
);
attrIndexTable
.
put
(
def
,
null
);
...
...
@@ -2059,7 +2061,7 @@ class BandStructure implements Constants {
assert
(
index
<
64
);
attrDefSeen
[
ctype
]
&=
~(
1L
<<
index
);
attrFlagMask
[
ctype
]
&=
~(
1L
<<
index
);
Band
[]
ab
=
(
Band
[])
attrBandTable
.
get
(
def
);
Band
[]
ab
=
attrBandTable
.
get
(
def
);
for
(
int
j
=
0
;
j
<
ab
.
length
;
j
++)
{
ab
[
j
].
doneWithUnusedBand
();
}
...
...
@@ -2085,9 +2087,8 @@ class BandStructure implements Constants {
long
defSeen
=
attrDefSeen
[
ctype
];
// Note: attrDefSeen is always a subset of attrFlagMask.
assert
((
defSeen
&
~
attrFlagMask
[
ctype
])
==
0
);
for
(
int
i
=
0
;
i
<
attrDefs
[
ctype
].
size
();
i
++)
{
Attribute
.
Layout
def
=
(
Attribute
.
Layout
)
attrDefs
[
ctype
].
get
(
i
);
for
(
int
i
=
0
;
i
<
attrDefs
.
get
(
ctype
).
size
();
i
++)
{
Attribute
.
Layout
def
=
attrDefs
.
get
(
ctype
).
get
(
i
);
if
(
def
==
null
)
continue
;
// unused flag bit
if
(
def
.
bandCount
==
0
)
continue
;
// empty attr
if
(
i
<
attrIndexLimit
[
ctype
]
&&
!
testBit
(
defSeen
,
1L
<<
i
))
{
...
...
@@ -2102,7 +2103,7 @@ class BandStructure implements Constants {
Band
[]
newAB
=
makeNewAttributeBands
(
pfx
,
def
,
xxx_attr_bands
);
assert
(
newAB
.
length
==
def
.
bandCount
);
Band
[]
prevAB
=
(
Band
[])
attrBandTable
.
put
(
def
,
newAB
);
Band
[]
prevAB
=
attrBandTable
.
put
(
def
,
newAB
);
if
(
prevAB
!=
null
)
{
// We won't be using these predefined bands.
for
(
int
j
=
0
;
j
<
prevAB
.
length
;
j
++)
{
...
...
@@ -2212,14 +2213,14 @@ class BandStructure implements Constants {
protected
int
setAttributeLayoutIndex
(
Attribute
.
Layout
def
,
int
index
)
{
int
ctype
=
def
.
ctype
;
assert
(
ATTR_INDEX_OVERFLOW
<=
index
&&
index
<
attrIndexLimit
[
ctype
]);
List
defList
=
attrDefs
[
ctype
]
;
List
<
Attribute
.
Layout
>
defList
=
attrDefs
.
get
(
ctype
)
;
if
(
index
==
ATTR_INDEX_OVERFLOW
)
{
// Overflow attribute.
index
=
defList
.
size
();
defList
.
add
(
def
);
if
(
verbose
>
0
)
Utils
.
log
.
info
(
"Adding new attribute at "
+
def
+
": "
+
index
);
attrIndexTable
.
put
(
def
,
new
Integer
(
index
)
);
attrIndexTable
.
put
(
def
,
index
);
return
index
;
}
...
...
@@ -2240,7 +2241,7 @@ class BandStructure implements Constants {
// Remove index binding of any previous fixed attr.
attrIndexTable
.
put
(
defList
.
get
(
index
),
null
);
defList
.
set
(
index
,
def
);
attrIndexTable
.
put
(
def
,
new
Integer
(
index
)
);
attrIndexTable
.
put
(
def
,
index
);
return
index
;
}
...
...
@@ -2361,7 +2362,7 @@ class BandStructure implements Constants {
////////////////////////////////////////////////////////////////////
static
int
nextSeqForDebug
;
static
File
dumpDir
;
static
File
dumpDir
=
null
;
static
OutputStream
getDumpStream
(
Band
b
,
String
ext
)
throws
IOException
{
return
getDumpStream
(
b
.
name
,
b
.
seqForDebug
,
ext
,
b
);
}
...
...
@@ -2512,19 +2513,19 @@ class BandStructure implements Constants {
+
", "
+
cstr
+
", "
+
ixS
+
"),"
);
}
private
HashMap
prevForAssertMap
;
private
Map
<
Band
,
Band
>
prevForAssertMap
;
// DEBUG ONLY: Record something about the band order.
boolean
notePrevForAssert
(
Band
b
,
Band
p
)
{
if
(
prevForAssertMap
==
null
)
prevForAssertMap
=
new
HashMap
();
prevForAssertMap
=
new
HashMap
<>
();
prevForAssertMap
.
put
(
b
,
p
);
return
true
;
}
// DEBUG ONLY: Validate next input band.
private
boolean
assertReadyToReadFrom
(
Band
b
,
InputStream
in
)
throws
IOException
{
Band
p
=
(
Band
)
prevForAssertMap
.
get
(
b
);
Band
p
=
prevForAssertMap
.
get
(
b
);
// Any previous band must be done reading before this one starts.
if
(
p
!=
null
&&
phaseCmp
(
p
.
phase
(),
DISBURSE_PHASE
)
<
0
)
{
Utils
.
log
.
warning
(
"Previous band not done reading."
);
...
...
@@ -2536,19 +2537,21 @@ class BandStructure implements Constants {
String
name
=
b
.
name
;
if
(
optDebugBands
&&
!
name
.
startsWith
(
"("
))
{
// Verify synchronization between reader & writer:
StringBu
ffer
buf
=
new
StringBuff
er
();
StringBu
ilder
buf
=
new
StringBuild
er
();
int
ch
;
while
((
ch
=
in
.
read
())
>
0
)
buf
.
append
((
char
)
ch
);
String
inName
=
buf
.
toString
();
if
(!
inName
.
equals
(
name
))
{
StringBu
ffer
sb
=
new
StringBuff
er
();
StringBu
ilder
sb
=
new
StringBuild
er
();
sb
.
append
(
"Expected "
+
name
+
" but read: "
);
inName
+=
(
char
)
ch
;
while
(
inName
.
length
()
<
10
)
inName
+=
(
char
)
in
.
read
();
for
(
int
i
=
0
;
i
<
inName
.
length
();
i
++)
while
(
inName
.
length
()
<
10
)
{
inName
+=
(
char
)
in
.
read
();
}
for
(
int
i
=
0
;
i
<
inName
.
length
();
i
++)
{
sb
.
append
(
inName
.
charAt
(
i
));
}
Utils
.
log
.
warning
(
sb
.
toString
());
return
false
;
}
...
...
@@ -2573,7 +2576,7 @@ class BandStructure implements Constants {
// DEBUG ONLY: Maybe write a debugging cookie to next output band.
private
boolean
assertReadyToWriteTo
(
Band
b
,
OutputStream
out
)
throws
IOException
{
Band
p
=
(
Band
)
prevForAssertMap
.
get
(
b
);
Band
p
=
prevForAssertMap
.
get
(
b
);
// Any previous band must be done writing before this one starts.
if
(
p
!=
null
&&
phaseCmp
(
p
.
phase
(),
DONE_PHASE
)
<
0
)
{
Utils
.
log
.
warning
(
"Previous band not done writing."
);
...
...
@@ -2654,7 +2657,7 @@ class BandStructure implements Constants {
protected
static
Object
[]
realloc
(
Object
[]
a
)
{
return
realloc
(
a
,
Math
.
max
(
10
,
a
.
length
*
2
));
}
static
private
int
[]
noInts
=
{};
protected
static
int
[]
realloc
(
int
[]
a
,
int
len
)
{
if
(
len
==
0
)
return
noInts
;
if
(
a
==
null
)
return
new
int
[
len
];
...
...
@@ -2665,7 +2668,7 @@ class BandStructure implements Constants {
protected
static
int
[]
realloc
(
int
[]
a
)
{
return
realloc
(
a
,
Math
.
max
(
10
,
a
.
length
*
2
));
}
static
private
byte
[]
noBytes
=
{};
protected
static
byte
[]
realloc
(
byte
[]
a
,
int
len
)
{
if
(
len
==
0
)
return
noBytes
;
if
(
a
==
null
)
return
new
byte
[
len
];
...
...
src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
浏览文件 @
66fa671c
...
...
@@ -38,19 +38,20 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Reader for a class file that is being incorporated into a package.
* @author John Rose
*/
class
ClassReader
implements
Constants
{
class
ClassReader
{
int
verbose
;
Package
pkg
;
Class
cls
;
long
inPos
;
DataInputStream
in
;
Map
attrDefs
;
Map
<
Attribute
.
Layout
,
Attribute
>
attrDefs
;
Map
attrCommands
;
String
unknownAttrCommand
=
"error"
;;
...
...
@@ -77,7 +78,7 @@ class ClassReader implements Constants {
});
}
public
void
setAttrDefs
(
Map
attrDefs
)
{
public
void
setAttrDefs
(
Map
<
Attribute
.
Layout
,
Attribute
>
attrDefs
)
{
this
.
attrDefs
=
attrDefs
;
}
...
...
@@ -211,27 +212,23 @@ class ClassReader implements Constants {
break
;
case
CONSTANT_Integer:
{
Comparable
val
=
new
Integer
(
in
.
readInt
());
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
val
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
in
.
readInt
());
}
break
;
case
CONSTANT_Float:
{
Comparable
val
=
new
Float
(
in
.
readFloat
());
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
val
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
in
.
readFloat
());
}
break
;
case
CONSTANT_Long:
{
Comparable
val
=
new
Long
(
in
.
readLong
());
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
val
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
in
.
readLong
());
cpMap
[++
i
]
=
null
;
}
break
;
case
CONSTANT_Double:
{
Comparable
val
=
new
Double
(
in
.
readDouble
());
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
val
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
in
.
readDouble
());
cpMap
[++
i
]
=
null
;
}
break
;
...
...
@@ -353,17 +350,18 @@ class ClassReader implements Constants {
if
(
attrCommands
!=
null
)
{
Object
lkey
=
Attribute
.
keyForLookup
(
ctype
,
name
);
String
cmd
=
(
String
)
attrCommands
.
get
(
lkey
);
if
(
cmd
==
"pass"
)
{
String
message
=
"passing attribute bitwise in "
+
h
;
throw
new
Attribute
.
FormatException
(
message
,
ctype
,
name
,
cmd
);
}
else
if
(
cmd
==
"error"
)
{
String
message
=
"attribute not allowed in "
+
h
;
throw
new
Attribute
.
FormatException
(
message
,
ctype
,
name
,
cmd
);
}
else
if
(
cmd
==
"strip"
)
{
skip
(
length
,
name
+
" attribute in "
+
h
);
continue
;
if
(
cmd
!=
null
)
{
switch
(
cmd
)
{
case
"pass"
:
String
message1
=
"passing attribute bitwise in "
+
h
;
throw
new
Attribute
.
FormatException
(
message1
,
ctype
,
name
,
cmd
);
case
"error"
:
String
message2
=
"attribute not allowed in "
+
h
;
throw
new
Attribute
.
FormatException
(
message2
,
ctype
,
name
,
cmd
);
case
"strip"
:
skip
(
length
,
name
+
" attribute in "
+
h
);
continue
;
}
}
}
// Find canonical instance of the requested attribute.
...
...
@@ -408,7 +406,7 @@ class ClassReader implements Constants {
String
message
=
"unsupported StackMap variant in "
+
h
;
throw
new
Attribute
.
FormatException
(
message
,
ctype
,
name
,
"pass"
);
}
else
if
(
unknownAttrCommand
==
"strip"
)
{
}
else
if
(
"strip"
.
equals
(
unknownAttrCommand
)
)
{
// Skip the unknown attribute.
skip
(
length
,
"unknown "
+
name
+
" attribute in "
+
h
);
continue
;
...
...
@@ -422,7 +420,7 @@ class ClassReader implements Constants {
a
.
layout
()
==
Package
.
attrInnerClassesEmpty
)
{
// These are hardwired.
long
pos0
=
inPos
;
if
(
a
.
name
()
==
"Code"
)
{
if
(
"Code"
.
equals
(
a
.
name
())
)
{
Class
.
Method
m
=
(
Class
.
Method
)
h
;
m
.
code
=
new
Code
(
m
);
try
{
...
...
@@ -471,7 +469,7 @@ class ClassReader implements Constants {
void
readInnerClasses
(
Class
cls
)
throws
IOException
{
int
nc
=
readUnsignedShort
();
ArrayList
ics
=
new
ArrayList
(
nc
);
ArrayList
<
InnerClass
>
ics
=
new
ArrayList
<>
(
nc
);
for
(
int
i
=
0
;
i
<
nc
;
i
++)
{
InnerClass
ic
=
new
InnerClass
(
readClassRef
(),
...
...
src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java
浏览文件 @
66fa671c
...
...
@@ -38,12 +38,12 @@ import java.io.IOException;
import
java.io.OutputStream
;
import
java.util.Iterator
;
import
java.util.List
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Writer for a class file that is incorporated into a package.
* @author John Rose
*/
class
ClassWriter
implements
Constants
{
class
ClassWriter
{
int
verbose
;
Package
pkg
;
...
...
@@ -196,8 +196,7 @@ class ClassWriter implements Constants {
return
;
}
writeShort
(
h
.
attributes
.
size
());
for
(
Iterator
i
=
h
.
attributes
.
iterator
();
i
.
hasNext
();
)
{
Attribute
a
=
(
Attribute
)
i
.
next
();
for
(
Attribute
a
:
h
.
attributes
)
{
a
.
finishRefs
(
cpIndex
);
writeRef
(
a
.
getNameRef
());
if
(
a
.
layout
()
==
Package
.
attrCodeEmpty
||
...
...
@@ -207,7 +206,7 @@ class ClassWriter implements Constants {
assert
(
out
!=
bufOut
);
buf
.
reset
();
out
=
bufOut
;
if
(
a
.
name
()
==
"Code"
)
{
if
(
"Code"
.
equals
(
a
.
name
())
)
{
Class
.
Method
m
=
(
Class
.
Method
)
h
;
writeCode
(
m
.
code
);
}
else
{
...
...
@@ -246,10 +245,9 @@ class ClassWriter implements Constants {
}
void
writeInnerClasses
(
Class
cls
)
throws
IOException
{
List
ics
=
cls
.
getInnerClasses
();
List
<
InnerClass
>
ics
=
cls
.
getInnerClasses
();
writeShort
(
ics
.
size
());
for
(
Iterator
i
=
ics
.
iterator
();
i
.
hasNext
();
)
{
InnerClass
ic
=
(
InnerClass
)
i
.
next
();
for
(
InnerClass
ic
:
ics
)
{
writeRef
(
ic
.
thisClass
);
writeRef
(
ic
.
outerClass
);
writeRef
(
ic
.
name
);
...
...
src/share/classes/com/sun/java/util/jar/pack/Code.java
浏览文件 @
66fa671c
...
...
@@ -29,12 +29,13 @@ import com.sun.java.util.jar.pack.Package.Class;
import
java.lang.reflect.Modifier
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Represents a chunk of bytecodes.
* @author John Rose
*/
class
Code
extends
Attribute
.
Holder
implements
Constants
{
class
Code
extends
Attribute
.
Holder
{
Class
.
Method
m
;
public
Code
(
Class
.
Method
m
)
{
...
...
@@ -141,15 +142,12 @@ class Code extends Attribute.Holder implements Constants {
super
.
trimToSize
();
}
protected
void
visitRefs
(
int
mode
,
Collection
refs
)
{
protected
void
visitRefs
(
int
mode
,
Collection
<
ConstantPool
.
Entry
>
refs
)
{
int
verbose
=
getPackage
().
verbose
;
if
(
verbose
>
2
)
System
.
out
.
println
(
"Reference scan "
+
this
);
Class
cls
=
thisClass
();
Package
pkg
=
cls
.
getPackage
();
for
(
int
i
=
0
;
i
<
handler_class
.
length
;
i
++)
{
refs
.
add
(
handler_class
[
i
]);
}
refs
.
addAll
(
Arrays
.
asList
(
handler_class
));
if
(
fixups
!=
null
)
{
fixups
.
visitRefs
(
refs
);
}
else
{
...
...
@@ -196,11 +194,8 @@ class Code extends Attribute.Holder implements Constants {
map
[
mapLen
]
=
(
short
)(
PClimit
+
Short
.
MIN_VALUE
);
return
map
;
}
else
{
int
[]
map
=
new
int
[
mapLen
+
1
];
for
(
int
i
=
0
;
i
<
mapLen
;
i
++)
{
map
[
i
]
=
(
int
)
insnMap
[
i
];
}
map
[
mapLen
]
=
(
int
)
PClimit
;
int
[]
map
=
Arrays
.
copyOf
(
insnMap
,
mapLen
+
1
);
map
[
mapLen
]
=
PClimit
;
return
map
;
}
}
...
...
@@ -220,10 +215,7 @@ class Code extends Attribute.Holder implements Constants {
}
}
else
{
int
[]
map
=
(
int
[])
map0
;
imap
=
new
int
[
map
.
length
-
1
];
for
(
int
i
=
0
;
i
<
imap
.
length
;
i
++)
{
imap
[
i
]
=
map
[
i
];
}
imap
=
Arrays
.
copyOfRange
(
map
,
0
,
map
.
length
-
1
);
}
return
imap
;
}
...
...
@@ -266,7 +258,7 @@ class Code extends Attribute.Holder implements Constants {
}
else
{
int
[]
map
=
(
int
[])
map0
;
len
=
map
.
length
;
i
=
Arrays
.
binarySearch
(
map
,
(
int
)
bci
);
i
=
Arrays
.
binarySearch
(
map
,
bci
);
}
assert
(
i
!=
-
1
);
assert
(
i
!=
0
);
...
...
@@ -322,7 +314,7 @@ class Code extends Attribute.Holder implements Constants {
len
=
map
.
length
;
if
(
bciCode
<
len
)
return
map
[
bciCode
];
i
=
Arrays
.
binarySearch
(
map
,
(
int
)
bciCode
);
i
=
Arrays
.
binarySearch
(
map
,
bciCode
);
if
(
i
<
0
)
i
=
-
i
-
1
;
int
key
=
bciCode
-
len
;
for
(;;
i
--)
{
...
...
src/share/classes/com/sun/java/util/jar/pack/Coding.java
浏览文件 @
66fa671c
...
...
@@ -29,14 +29,15 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Define the conversions between sequences of small integers and raw bytes.
* This is a schema of encodings which incorporates varying lengths,
* varying degrees of length variability, and varying amounts of signed-ness.
* @author John Rose
*/
class
Coding
implements
Co
nstants
,
Co
mparable
,
CodingMethod
,
Histogram
.
BitMetric
{
class
Coding
implements
Comparable
,
CodingMethod
,
Histogram
.
BitMetric
{
/*
Coding schema for single integers, parameterized by (B,H,S):
...
...
@@ -191,7 +192,9 @@ class Coding implements Constants, Comparable, CodingMethod, Histogram.BitMetric
if
(
S
==
0
||
range
>=
(
long
)
1
<<
32
)
return
saturate32
(
range
-
1
);
long
maxPos
=
range
-
1
;
while
(
isNegativeCode
(
maxPos
,
S
))
--
maxPos
;
while
(
isNegativeCode
(
maxPos
,
S
))
{
--
maxPos
;
}
if
(
maxPos
<
0
)
return
-
1
;
// No positive codings at all.
int
smax
=
decodeSign32
(
maxPos
,
S
);
// check for 32-bit wraparound:
...
...
@@ -213,9 +216,10 @@ class Coding implements Constants, Comparable, CodingMethod, Histogram.BitMetric
if
(
S
==
0
)
{
return
0
;
}
int
Smask
=
(
1
<<
S
)-
1
;
long
maxNeg
=
range
-
1
;
while
(!
isNegativeCode
(
maxNeg
,
S
))
--
maxNeg
;
while
(!
isNegativeCode
(
maxNeg
,
S
))
--
maxNeg
;
if
(
maxNeg
<
0
)
return
0
;
// No negative codings at all.
return
decodeSign32
(
maxNeg
,
S
);
}
...
...
@@ -395,12 +399,12 @@ class Coding implements Constants, Comparable, CodingMethod, Histogram.BitMetric
return
(
del
<<
14
)+(
S
<<
11
)+(
B
<<
8
)+(
H
<<
0
);
}
private
static
HashMap
codeMap
;
private
static
Map
<
Coding
,
Coding
>
codeMap
;
private
static
synchronized
Coding
of
(
int
B
,
int
H
,
int
S
,
int
del
)
{
if
(
codeMap
==
null
)
codeMap
=
new
HashMap
();
if
(
codeMap
==
null
)
codeMap
=
new
HashMap
<>
();
Coding
x0
=
new
Coding
(
B
,
H
,
S
,
del
);
Coding
x1
=
(
Coding
)
codeMap
.
get
(
x0
);
Coding
x1
=
codeMap
.
get
(
x0
);
if
(
x1
==
null
)
codeMap
.
put
(
x0
,
x1
=
x0
);
return
x1
;
}
...
...
@@ -462,6 +466,7 @@ class Coding implements Constants, Comparable, CodingMethod, Histogram.BitMetric
// %%% use byte[] buffer
for
(
int
i
=
start
;
i
<
end
;
i
++)
a
[
i
]
=
readFrom
(
in
);
for
(
int
dstep
=
0
;
dstep
<
del
;
dstep
++)
{
long
state
=
0
;
for
(
int
i
=
start
;
i
<
end
;
i
++)
{
...
...
@@ -750,14 +755,14 @@ class Coding implements Constants, Comparable, CodingMethod, Histogram.BitMetric
if
(
len
==
0
)
return
true
;
if
(
isFullRange
())
return
true
;
// Calculate max, min:
int
max
=
values
[
start
];
int
min
=
max
;
int
l
max
=
values
[
start
];
int
lmin
=
l
max
;
for
(
int
i
=
1
;
i
<
len
;
i
++)
{
int
value
=
values
[
start
+
i
];
if
(
max
<
value
)
max
=
value
;
if
(
min
>
value
)
min
=
value
;
if
(
lmax
<
value
)
l
max
=
value
;
if
(
lmin
>
value
)
l
min
=
value
;
}
return
canRepresent
(
min
,
max
);
return
canRepresent
(
lmin
,
l
max
);
}
public
double
getBitLength
(
int
value
)
{
// implements BitMetric
...
...
@@ -800,21 +805,20 @@ class Coding implements Constants, Comparable, CodingMethod, Histogram.BitMetric
//return Coding.of(B, H, S).getLength(deltas, 0, len);
values
=
deltas
;
start
=
0
;
end
=
values
.
length
;
}
int
sum
=
len
;
// at least 1 byte per
// add extra bytes for extra-long values
for
(
int
n
=
1
;
n
<=
B
;
n
++)
{
// what is the coding interval [min..max] for n bytes?
int
max
=
byteMax
[
n
-
1
];
int
min
=
byteMin
[
n
-
1
];
int
l
max
=
byteMax
[
n
-
1
];
int
l
min
=
byteMin
[
n
-
1
];
int
longer
=
0
;
// count of guys longer than n bytes
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
value
=
values
[
start
+
i
];
if
(
value
>=
0
)
{
if
(
value
>
max
)
longer
++;
if
(
value
>
l
max
)
longer
++;
}
else
{
if
(
value
<
min
)
longer
++;
if
(
value
<
l
min
)
longer
++;
}
}
if
(
longer
==
0
)
break
;
// no more passes needed
...
...
src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java
浏览文件 @
66fa671c
...
...
@@ -34,15 +34,16 @@ import java.util.HashSet;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.Set
;
import
java.util.zip.Deflater
;
import
java.util.zip.DeflaterOutputStream
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Heuristic chooser of basic encodings.
* Runs "zip" to measure the apparent information content after coding.
* @author John Rose
*/
class
CodingChooser
implements
Constants
{
class
CodingChooser
{
int
verbose
;
int
effort
;
boolean
optUseHistogram
=
true
;
...
...
@@ -124,10 +125,10 @@ class CodingChooser implements Constants {
=
!
p200
.
getBoolean
(
Utils
.
COM_PREFIX
+
"no.population.coding"
);
this
.
optUseAdaptiveCoding
=
!
p200
.
getBoolean
(
Utils
.
COM_PREFIX
+
"no.adaptive.coding"
);
int
stress
int
l
stress
=
p200
.
getInteger
(
Utils
.
COM_PREFIX
+
"stress.coding"
);
if
(
stress
!=
0
)
this
.
stress
=
new
Random
(
stress
);
if
(
l
stress
!=
0
)
this
.
stress
=
new
Random
(
l
stress
);
}
this
.
effort
=
effort
;
...
...
@@ -376,9 +377,9 @@ class CodingChooser implements Constants {
" fewer bytes than regular "
+
regular
+
"; win="
+
pct
(
zipSize1
-
bestZipSize
,
zipSize1
));
}
CodingMethod
bestMethod
=
this
.
bestMethod
;
CodingMethod
l
bestMethod
=
this
.
bestMethod
;
reset
(
null
,
0
,
0
);
// for GC
return
bestMethod
;
return
l
bestMethod
;
}
CodingMethod
choose
(
int
[]
values
,
int
start
,
int
end
,
Coding
regular
)
{
return
choose
(
values
,
start
,
end
,
regular
,
null
);
...
...
@@ -742,9 +743,9 @@ class CodingChooser implements Constants {
// Steps 1/2/3 are interdependent, and may be iterated.
// Steps 4 and 5 may be decided independently afterward.
int
[]
LValuesCoded
=
PopulationCoding
.
LValuesCoded
;
ArrayList
bestFits
=
new
ArrayList
();
ArrayList
fullFits
=
new
ArrayList
();
ArrayList
longFits
=
new
ArrayList
();
List
<
Coding
>
bestFits
=
new
ArrayList
<>
();
List
<
Coding
>
fullFits
=
new
ArrayList
<>
();
List
<
Coding
>
longFits
=
new
ArrayList
<>
();
final
int
PACK_TO_MAX_S
=
1
;
if
(
bestPopFVC
<=
255
)
{
bestFits
.
add
(
BandStructure
.
BYTE1
);
...
...
@@ -776,16 +777,16 @@ class CodingChooser implements Constants {
}
}
// interleave all B greater than bestB with best and full fits
for
(
Iterator
i
=
bestFits
.
iterator
();
i
.
hasNext
();
)
{
Coding
c
=
(
Coding
)
i
.
next
();
for
(
Iterator
<
Coding
>
i
=
bestFits
.
iterator
();
i
.
hasNext
();
)
{
Coding
c
=
i
.
next
();
if
(
c
.
B
()
>
bestB
)
{
i
.
remove
();
longFits
.
add
(
0
,
c
);
}
}
}
ArrayList
allFits
=
new
ArrayList
();
for
(
Iterator
i
=
bestFits
.
iterator
(),
List
<
Coding
>
allFits
=
new
ArrayList
<>
();
for
(
Iterator
<
Coding
>
i
=
bestFits
.
iterator
(),
j
=
fullFits
.
iterator
(),
k
=
longFits
.
iterator
();
i
.
hasNext
()
||
j
.
hasNext
()
||
k
.
hasNext
();
)
{
...
...
@@ -812,8 +813,7 @@ class CodingChooser implements Constants {
}
if
(
verbose
>
3
)
Utils
.
log
.
info
(
"allFits: "
+
allFits
);
for
(
Iterator
i
=
allFits
.
iterator
();
i
.
hasNext
();
)
{
Coding
tc
=
(
Coding
)
i
.
next
();
for
(
Coding
tc
:
allFits
)
{
boolean
packToMax
=
false
;
if
(
tc
.
S
()
==
PACK_TO_MAX_S
)
{
// Kludge: setS(PACK_TO_MAX_S) means packToMax here.
...
...
@@ -910,7 +910,7 @@ class CodingChooser implements Constants {
" tc="
+
pop
.
tokenCoding
+
" uc="
+
pop
.
unfavoredCoding
);
//pop.hist.print("pop-hist", null, System.out);
StringBu
ffer
sb
=
new
StringBuff
er
();
StringBu
ilder
sb
=
new
StringBuild
er
();
sb
.
append
(
"fv = {"
);
for
(
int
i
=
1
;
i
<=
fVlen
;
i
++)
{
if
((
i
%
10
)
==
0
)
...
...
@@ -949,20 +949,20 @@ class CodingChooser implements Constants {
// run occupies too much space. ("Too much" means, say 5% more
// than the average integer size of the band as a whole.)
// Try to find a better coding for those segments.
int
start
=
this
.
start
;
int
end
=
this
.
end
;
int
[]
values
=
this
.
values
;
int
len
=
end
-
start
;
int
l
start
=
this
.
start
;
int
l
end
=
this
.
end
;
int
[]
l
values
=
this
.
values
;
int
len
=
lend
-
l
start
;
if
(
plainCoding
.
isDelta
())
{
values
=
getDeltas
(
0
,
0
);
//%%% not quite right!
start
=
0
;
end
=
values
.
length
;
l
values
=
getDeltas
(
0
,
0
);
//%%% not quite right!
l
start
=
0
;
lend
=
l
values
.
length
;
}
int
[]
sizes
=
new
int
[
len
+
1
];
int
fillp
=
0
;
int
totalSize
=
0
;
for
(
int
i
=
start
;
i
<
end
;
i
++)
{
int
val
=
values
[
i
];
for
(
int
i
=
lstart
;
i
<
l
end
;
i
++)
{
int
val
=
l
values
[
i
];
sizes
[
fillp
++]
=
totalSize
;
int
size
=
plainCoding
.
getLength
(
val
);
assert
(
size
<
Integer
.
MAX_VALUE
);
...
...
@@ -1013,22 +1013,23 @@ class CodingChooser implements Constants {
double
[]
fuzzes
=
new
double
[
meshes
.
length
];
for
(
int
i
=
0
;
i
<
meshes
.
length
;
i
++)
{
int
mesh
=
meshes
[
i
];
double
fuzz
;
double
l
fuzz
;
if
(
mesh
<
10
)
fuzz
=
sizeFuzz3
;
l
fuzz
=
sizeFuzz3
;
else
if
(
mesh
<
100
)
fuzz
=
sizeFuzz2
;
l
fuzz
=
sizeFuzz2
;
else
fuzz
=
sizeFuzz
;
fuzzes
[
i
]
=
fuzz
;
threshes
[
i
]
=
BAND_HEADER
+
(
int
)
Math
.
ceil
(
mesh
*
avgSize
*
fuzz
);
l
fuzz
=
sizeFuzz
;
fuzzes
[
i
]
=
l
fuzz
;
threshes
[
i
]
=
BAND_HEADER
+
(
int
)
Math
.
ceil
(
mesh
*
avgSize
*
l
fuzz
);
}
if
(
verbose
>
1
)
{
System
.
out
.
print
(
"tryAdaptiveCoding ["
+
len
+
"]"
+
" avgS="
+
avgSize
+
" fuzz="
+
sizeFuzz
+
" meshes: {"
);
for
(
int
i
=
0
;
i
<
meshes
.
length
;
i
++)
System
.
out
.
print
(
" "
+
meshes
[
i
]+
"("
+
threshes
[
i
]+
")"
);
for
(
int
i
=
0
;
i
<
meshes
.
length
;
i
++)
{
System
.
out
.
print
(
" "
+
meshes
[
i
]
+
"("
+
threshes
[
i
]
+
")"
);
}
Utils
.
log
.
info
(
" }"
);
}
if
(
runHelper
==
null
)
{
...
...
@@ -1229,20 +1230,19 @@ class CodingChooser implements Constants {
Histogram
hist
=
getValueHistogram
();
int
fVlen
=
stressLen
(
hist
.
getTotalLength
());
if
(
fVlen
==
0
)
return
coding
;
List
popvals
=
new
ArrayList
();
List
<
Integer
>
popvals
=
new
ArrayList
<>
();
if
(
stress
.
nextBoolean
())
{
// Build the population from the value list.
HashSet
popset
=
new
HashSet
();
Set
<
Integer
>
popset
=
new
HashSet
<>
();
for
(
int
i
=
start
;
i
<
end
;
i
++)
{
Integer
val
=
new
Integer
(
values
[
i
]);
if
(
popset
.
add
(
val
))
popvals
.
add
(
val
);
if
(
popset
.
add
(
values
[
i
]))
popvals
.
add
(
values
[
i
]);
}
}
else
{
int
[][]
matrix
=
hist
.
getMatrix
();
for
(
int
mrow
=
0
;
mrow
<
matrix
.
length
;
mrow
++)
{
int
[]
row
=
matrix
[
mrow
];
for
(
int
mcol
=
1
;
mcol
<
row
.
length
;
mcol
++)
{
popvals
.
add
(
new
Integer
(
row
[
mcol
])
);
popvals
.
add
(
row
[
mcol
]
);
}
}
}
...
...
@@ -1269,7 +1269,7 @@ class CodingChooser implements Constants {
fVlen
=
popvals
.
size
();
int
[]
fvals
=
new
int
[
1
+
fVlen
];
for
(
int
i
=
0
;
i
<
fVlen
;
i
++)
{
fvals
[
1
+
i
]
=
(
(
Integer
)
popvals
.
get
(
i
)).
intValue
();
fvals
[
1
+
i
]
=
(
popvals
.
get
(
i
)).
intValue
();
}
PopulationCoding
pop
=
new
PopulationCoding
();
pop
.
setFavoredValues
(
fvals
,
fVlen
);
...
...
@@ -1283,13 +1283,13 @@ class CodingChooser implements Constants {
}
}
if
(
pop
.
tokenCoding
==
null
)
{
int
min
=
fvals
[
1
],
max
=
min
;
int
lmin
=
fvals
[
1
],
lmax
=
l
min
;
for
(
int
i
=
2
;
i
<=
fVlen
;
i
++)
{
int
val
=
fvals
[
i
];
if
(
min
>
val
)
min
=
val
;
if
(
max
<
val
)
max
=
val
;
if
(
lmin
>
val
)
l
min
=
val
;
if
(
lmax
<
val
)
l
max
=
val
;
}
pop
.
tokenCoding
=
stressCoding
(
min
,
max
);
pop
.
tokenCoding
=
stressCoding
(
lmin
,
l
max
);
}
computePopSizePrivate
(
pop
,
valueCoding
,
valueCoding
);
...
...
@@ -1310,13 +1310,13 @@ class CodingChooser implements Constants {
try
{
assert
(!
disableRunCoding
);
disableRunCoding
=
true
;
// temporary, while I decide spans
int
[]
allValues
=
(
int
[])
values
.
clone
();
int
[]
allValues
=
values
.
clone
();
CodingMethod
result
=
null
;
int
scan
=
this
.
end
;
int
start
=
this
.
start
;
for
(
int
split
;
scan
>
start
;
scan
=
split
)
{
int
l
start
=
this
.
start
;
for
(
int
split
;
scan
>
l
start
;
scan
=
split
)
{
int
thisspan
;
int
rand
=
(
scan
-
start
<
100
)?
-
1
:
stress
.
nextInt
();
int
rand
=
(
scan
-
l
start
<
100
)?
-
1
:
stress
.
nextInt
();
if
((
rand
&
7
)
!=
0
)
{
thisspan
=
(
spanlen
==
1
?
spanlen:
stressLen
(
spanlen
-
1
)+
1
);
}
else
{
...
...
@@ -1325,7 +1325,7 @@ class CodingChooser implements Constants {
int
KB
=
(
rand
>>>=
3
)
&
AdaptiveCoding
.
KB_MAX
;
for
(;;)
{
thisspan
=
AdaptiveCoding
.
decodeK
(
KX
,
KB
);
if
(
thisspan
<=
scan
-
start
)
break
;
if
(
thisspan
<=
scan
-
l
start
)
break
;
// Try smaller and smaller codings:
if
(
KB
!=
AdaptiveCoding
.
KB_DEFAULT
)
KB
=
AdaptiveCoding
.
KB_DEFAULT
;
...
...
@@ -1335,11 +1335,13 @@ class CodingChooser implements Constants {
//System.out.println("KX="+KX+" KB="+KB+" K="+thisspan);
assert
(
AdaptiveCoding
.
isCodableLength
(
thisspan
));
}
if
(
thisspan
>
scan
-
start
)
thisspan
=
scan
-
start
;
while
(!
AdaptiveCoding
.
isCodableLength
(
thisspan
))
--
thisspan
;
if
(
thisspan
>
scan
-
lstart
)
thisspan
=
scan
-
lstart
;
while
(!
AdaptiveCoding
.
isCodableLength
(
thisspan
))
{
--
thisspan
;
}
split
=
scan
-
thisspan
;
assert
(
split
<
scan
);
assert
(
split
>=
start
);
assert
(
split
>=
l
start
);
// Choose a coding for the span [split..scan).
CodingMethod
sc
=
choose
(
allValues
,
split
,
scan
,
plainCoding
);
if
(
result
==
null
)
{
...
...
@@ -1420,7 +1422,7 @@ class CodingChooser implements Constants {
case StreamTokenizer.TT_EOF:
throw new NoSuchElementException();
case StreamTokenizer.TT_NUMBER:
return
new Integer
((int) in.nval);
return
Integer.valueOf
((int) in.nval);
default:
assert(false);
return null;
...
...
src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java
浏览文件 @
66fa671c
...
...
@@ -33,13 +33,14 @@ import java.util.List;
import
java.util.ListIterator
;
import
java.util.Map
;
import
java.util.Set
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Representation of constant pool entries and indexes.
* @author John Rose
*/
abstract
class
ConstantPool
implements
Constants
{
class
ConstantPool
{
private
ConstantPool
()
{}
// do not instantiate
static
int
verbose
()
{
...
...
@@ -155,9 +156,6 @@ class ConstantPool implements Constants {
return
null
;
}
public
boolean
sameTagAs
(
Object
o
)
{
return
(
o
instanceof
Entry
)
&&
((
Entry
)
o
).
tag
==
tag
;
}
public
boolean
eq
(
Entry
that
)
{
// same reference
assert
(
that
!=
null
);
return
this
==
that
||
this
.
equals
(
that
);
...
...
@@ -219,9 +217,9 @@ class ConstantPool implements Constants {
return
value
.
hashCode
();
}
public
boolean
equals
(
Object
o
)
{
if
(!
sameTagAs
(
o
))
return
false
;
// Use reference equality of interned strings:
return
((
Utf8Entry
)
o
).
value
==
value
;
return
(
o
!=
null
&&
o
.
getClass
()
==
Utf8Entry
.
class
&&
((
Utf8Entry
)
o
).
value
.
equals
(
value
));
}
public
int
compareTo
(
Object
o
)
{
int
x
=
superCompareTo
(
o
);
...
...
@@ -275,8 +273,9 @@ class ConstantPool implements Constants {
}
public
boolean
equals
(
Object
o
)
{
if
(!
sameTagAs
(
o
))
return
false
;
return
(((
NumberEntry
)
o
).
value
).
equals
(
value
);
return
(
o
!=
null
&&
o
.
getClass
()
==
NumberEntry
.
class
&&
((
NumberEntry
)
o
).
value
.
equals
(
value
));
}
public
int
compareTo
(
Object
o
)
{
int
x
=
superCompareTo
(
o
);
...
...
@@ -310,8 +309,8 @@ class ConstantPool implements Constants {
return
ref
.
hashCode
()
+
tag
;
}
public
boolean
equals
(
Object
o
)
{
if
(!
sameTagAs
(
o
))
return
false
;
return
((
StringEntry
)
o
).
ref
.
eq
(
ref
);
return
(
o
!=
null
&&
o
.
getClass
()
==
StringEntry
.
class
&&
((
StringEntry
)
o
).
ref
.
eq
(
ref
)
);
}
public
int
compareTo
(
Object
o
)
{
int
x
=
superCompareTo
(
o
);
...
...
@@ -342,8 +341,8 @@ class ConstantPool implements Constants {
hashCode
();
// force computation of valueHash
}
public
boolean
equals
(
Object
o
)
{
if
(!
sameTagAs
(
o
))
return
false
;
return
((
ClassEntry
)
o
).
ref
.
eq
(
ref
);
return
(
o
!=
null
&&
o
.
getClass
()
==
ClassEntry
.
class
&&
((
ClassEntry
)
o
).
ref
.
eq
(
ref
)
);
}
public
int
compareTo
(
Object
o
)
{
int
x
=
superCompareTo
(
o
);
...
...
@@ -380,7 +379,9 @@ class ConstantPool implements Constants {
return
(
nameRef
.
hashCode
()
+
(
hc2
<<
8
))
^
hc2
;
}
public
boolean
equals
(
Object
o
)
{
if
(!
sameTagAs
(
o
))
return
false
;
if
(
o
==
null
||
o
.
getClass
()
!=
DescriptorEntry
.
class
)
{
return
false
;
}
DescriptorEntry
that
=
(
DescriptorEntry
)
o
;
return
this
.
nameRef
.
eq
(
that
.
nameRef
)
&&
this
.
typeRef
.
eq
(
that
.
typeRef
);
...
...
@@ -439,7 +440,9 @@ class ConstantPool implements Constants {
hashCode
();
// force computation of valueHash
}
public
boolean
equals
(
Object
o
)
{
if
(!
sameTagAs
(
o
))
return
false
;
if
(
o
==
null
||
o
.
getClass
()
!=
MemberEntry
.
class
)
{
return
false
;
}
MemberEntry
that
=
(
MemberEntry
)
o
;
return
this
.
classRef
.
eq
(
that
.
classRef
)
&&
this
.
descRef
.
eq
(
that
.
descRef
);
...
...
@@ -511,8 +514,8 @@ class ConstantPool implements Constants {
}
public
boolean
equals
(
Object
o
)
{
if
(!
sameTagAs
(
o
))
return
false
;
return
((
SignatureEntry
)
o
).
value
==
value
;
return
(
o
!=
null
&&
o
.
getClass
()
==
SignatureEntry
.
class
&&
((
SignatureEntry
)
o
).
value
.
equals
(
value
))
;
}
public
int
compareTo
(
Object
o
)
{
int
x
=
superCompareTo
(
o
);
...
...
@@ -724,7 +727,7 @@ class ConstantPool implements Constants {
protected
static
final
ClassEntry
[]
noClassRefs
=
{};
/** An Index is a mapping between CP entries and small integers. */
public
static
public
static
final
class
Index
extends
AbstractList
{
protected
String
debugName
;
protected
Entry
[]
cpMap
;
...
...
@@ -894,7 +897,7 @@ class ConstantPool implements Constants {
}
public
static
Index
makeIndex
(
String
debugName
,
Collection
cpMapList
)
{
Index
makeIndex
(
String
debugName
,
Collection
<
Entry
>
cpMapList
)
{
return
new
Index
(
debugName
,
cpMapList
);
}
...
...
@@ -916,7 +919,7 @@ class ConstantPool implements Constants {
public
static
Index
[]
partition
(
Index
ix
,
int
[]
keys
)
{
// %%% Should move this into class Index.
Array
List
<
List
<
Entry
>>
parts
=
new
ArrayList
<>();
List
<
List
<
Entry
>>
parts
=
new
ArrayList
<>();
Entry
[]
cpMap
=
ix
.
cpMap
;
assert
(
keys
.
length
==
cpMap
.
length
);
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
...
...
@@ -1094,12 +1097,12 @@ class ConstantPool implements Constants {
// Inverse of getOverloadingIndex
public
MemberEntry
getOverloadingForIndex
(
byte
tag
,
ClassEntry
classRef
,
String
name
,
int
which
)
{
assert
(
name
==
name
.
intern
(
));
assert
(
name
.
equals
(
name
.
intern
()
));
Index
ix
=
getMemberIndex
(
tag
,
classRef
);
int
ord
=
0
;
for
(
int
i
=
0
;
i
<
ix
.
cpMap
.
length
;
i
++)
{
MemberEntry
e
=
(
MemberEntry
)
ix
.
cpMap
[
i
];
if
(
e
.
descRef
.
nameRef
.
stringValue
()
==
name
)
{
if
(
e
.
descRef
.
nameRef
.
stringValue
()
.
equals
(
name
)
)
{
if
(
ord
==
which
)
return
e
;
ord
++;
}
...
...
@@ -1133,10 +1136,10 @@ class ConstantPool implements Constants {
public
static
void
completeReferencesIn
(
Set
<
Entry
>
cpRefs
,
boolean
flattenSigs
)
{
cpRefs
.
remove
(
null
);
for
(
ListIterator
work
=
new
ArrayList
(
cpRefs
).
listIterator
(
cpRefs
.
size
());
for
(
ListIterator
<
Entry
>
work
=
new
ArrayList
<>
(
cpRefs
).
listIterator
(
cpRefs
.
size
());
work
.
hasPrevious
();
)
{
Entry
e
=
(
Entry
)
work
.
previous
();
Entry
e
=
work
.
previous
();
work
.
remove
();
// pop stack
assert
(
e
!=
null
);
if
(
flattenSigs
&&
e
.
tag
==
CONSTANT_Signature
)
{
...
...
src/share/classes/com/sun/java/util/jar/pack/Constants.java
浏览文件 @
66fa671c
...
...
@@ -32,7 +32,10 @@ import java.util.List;
* Shared constants
* @author John Rose
*/
interface
Constants
{
class
Constants
{
private
Constants
(){}
public
final
static
int
JAVA_MAGIC
=
0xCAFEBABE
;
/*
...
...
src/share/classes/com/sun/java/util/jar/pack/Driver.java
浏览文件 @
66fa671c
...
...
@@ -59,12 +59,11 @@ class Driver {
ResourceBundle
.
getBundle
(
"com.sun.java.util.jar.pack.DriverResource"
);
public
static
void
main
(
String
[]
ava
)
throws
IOException
{
Array
List
<
String
>
av
=
new
ArrayList
<>(
Arrays
.
asList
(
ava
));
List
<
String
>
av
=
new
ArrayList
<>(
Arrays
.
asList
(
ava
));
boolean
doPack
=
true
;
boolean
doUnpack
=
false
;
boolean
doRepack
=
false
;
boolean
doForceRepack
=
false
;
boolean
doZip
=
true
;
String
logFile
=
null
;
String
verboseProp
=
Utils
.
DEBUG_VERBOSE
;
...
...
@@ -72,17 +71,20 @@ class Driver {
{
// Non-standard, undocumented "--unpack" switch enables unpack mode.
String
arg0
=
av
.
isEmpty
()
?
""
:
av
.
get
(
0
);
if
(
arg0
.
equals
(
"--pack"
))
{
switch
(
arg0
)
{
case
"--pack"
:
av
.
remove
(
0
);
}
else
if
(
arg0
.
equals
(
"--unpack"
))
{
break
;
case
"--unpack"
:
av
.
remove
(
0
);
doPack
=
false
;
doUnpack
=
true
;
break
;
}
}
// Collect engine properties here:
Hash
Map
<
String
,
String
>
engProps
=
new
HashMap
<>();
Map
<
String
,
String
>
engProps
=
new
HashMap
<>();
engProps
.
put
(
verboseProp
,
System
.
getProperty
(
verboseProp
));
String
optionMap
;
...
...
@@ -96,7 +98,7 @@ class Driver {
}
// Collect argument properties here:
Hash
Map
<
String
,
String
>
avProps
=
new
HashMap
<>();
Map
<
String
,
String
>
avProps
=
new
HashMap
<>();
try
{
for
(;;)
{
String
state
=
parseCommandOptions
(
av
,
optionMap
,
avProps
);
...
...
@@ -146,7 +148,7 @@ class Driver {
}
// See if there is any other action to take.
if
(
state
==
"--config-file="
)
{
if
(
"--config-file="
.
equals
(
state
)
)
{
String
propFile
=
av
.
remove
(
0
);
InputStream
propIn
=
new
FileInputStream
(
propFile
);
Properties
fileProps
=
new
Properties
();
...
...
@@ -157,10 +159,10 @@ class Driver {
for
(
Map
.
Entry
<
Object
,
Object
>
me
:
fileProps
.
entrySet
())
{
engProps
.
put
((
String
)
me
.
getKey
(),
(
String
)
me
.
getValue
());
}
}
else
if
(
state
==
"--version"
)
{
}
else
if
(
"--version"
.
equals
(
state
)
)
{
System
.
out
.
println
(
MessageFormat
.
format
(
RESOURCE
.
getString
(
DriverResource
.
VERSION
),
Driver
.
class
.
getName
(),
"1.31, 07/05/05"
));
return
;
}
else
if
(
state
==
"--help"
)
{
}
else
if
(
"--help"
.
equals
(
state
)
)
{
printUsage
(
doPack
,
true
,
System
.
out
);
System
.
exit
(
1
);
return
;
...
...
@@ -178,14 +180,20 @@ class Driver {
// Deal with remaining non-engine properties:
for
(
String
opt
:
avProps
.
keySet
())
{
String
val
=
avProps
.
get
(
opt
);
if
(
opt
==
"--repack"
)
{
doRepack
=
true
;
}
else
if
(
opt
==
"--no-gzip"
)
{
doZip
=
(
val
==
null
);
}
else
if
(
opt
==
"--log-file="
)
{
logFile
=
val
;
}
else
{
throw
new
InternalError
(
MessageFormat
.
format
(
RESOURCE
.
getString
(
DriverResource
.
BAD_OPTION
),
opt
,
avProps
.
get
(
opt
)));
switch
(
opt
)
{
case
"--repack"
:
doRepack
=
true
;
break
;
case
"--no-gzip"
:
doZip
=
(
val
==
null
);
break
;
case
"--log-file="
:
logFile
=
val
;
break
;
default
:
throw
new
InternalError
(
MessageFormat
.
format
(
RESOURCE
.
getString
(
DriverResource
.
BAD_OPTION
),
opt
,
avProps
.
get
(
opt
)));
}
}
...
...
@@ -219,7 +227,9 @@ class Driver {
if
(
packfile
.
toLowerCase
().
endsWith
(
".pack"
)
||
packfile
.
toLowerCase
().
endsWith
(
".pac"
)
||
packfile
.
toLowerCase
().
endsWith
(
".gz"
))
{
System
.
err
.
println
(
MessageFormat
.
format
(
RESOURCE
.
getString
(
DriverResource
.
BAD_REPACK_OUTPUT
),
packfile
));
System
.
err
.
println
(
MessageFormat
.
format
(
RESOURCE
.
getString
(
DriverResource
.
BAD_REPACK_OUTPUT
),
packfile
));
printUsage
(
doPack
,
false
,
System
.
err
);
System
.
exit
(
2
);
}
...
...
src/share/classes/com/sun/java/util/jar/pack/FixedList.java
0 → 100644
浏览文件 @
66fa671c
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
com.sun.java.util.jar.pack
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.ListIterator
;
/*
* @author ksrini
*/
/*
* This class provides an ArrayList implementation which has a fixed size,
* thus all the operations which modifies the size have been rendered
* inoperative. This essentially allows us to use generified array
* lists in lieu of arrays.
*/
final
class
FixedList
<
E
>
implements
List
<
E
>
{
private
final
ArrayList
<
E
>
flist
;
protected
FixedList
(
int
capacity
)
{
flist
=
new
ArrayList
<>(
capacity
);
// initialize the list to null
for
(
int
i
=
0
;
i
<
capacity
;
i
++)
{
flist
.
add
(
null
);
}
}
@Override
public
int
size
()
{
return
flist
.
size
();
}
@Override
public
boolean
isEmpty
()
{
return
flist
.
isEmpty
();
}
@Override
public
boolean
contains
(
Object
o
)
{
return
flist
.
contains
(
o
);
}
@Override
public
Iterator
<
E
>
iterator
()
{
return
flist
.
iterator
();
}
@Override
public
Object
[]
toArray
()
{
return
flist
.
toArray
();
}
@Override
public
<
T
>
T
[]
toArray
(
T
[]
a
)
{
return
flist
.
toArray
(
a
);
}
@Override
public
boolean
add
(
E
e
)
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
boolean
remove
(
Object
o
)
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
boolean
containsAll
(
Collection
<?>
c
)
{
return
flist
.
containsAll
(
c
);
}
@Override
public
boolean
addAll
(
Collection
<?
extends
E
>
c
)
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
boolean
addAll
(
int
index
,
Collection
<?
extends
E
>
c
)
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
boolean
removeAll
(
Collection
<?>
c
)
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
boolean
retainAll
(
Collection
<?>
c
)
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
void
clear
()
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
E
get
(
int
index
)
{
return
flist
.
get
(
index
);
}
@Override
public
E
set
(
int
index
,
E
element
)
{
return
flist
.
set
(
index
,
element
);
}
@Override
public
void
add
(
int
index
,
E
element
)
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
E
remove
(
int
index
)
throws
UnsupportedOperationException
{
throw
new
UnsupportedOperationException
(
"operation not permitted"
);
}
@Override
public
int
indexOf
(
Object
o
)
{
return
flist
.
indexOf
(
o
);
}
@Override
public
int
lastIndexOf
(
Object
o
)
{
return
flist
.
lastIndexOf
(
o
);
}
@Override
public
ListIterator
<
E
>
listIterator
()
{
return
flist
.
listIterator
();
}
@Override
public
ListIterator
<
E
>
listIterator
(
int
index
)
{
return
flist
.
listIterator
(
index
);
}
@Override
public
List
<
E
>
subList
(
int
fromIndex
,
int
toIndex
)
{
return
flist
.
subList
(
fromIndex
,
toIndex
);
}
@Override
public
String
toString
()
{
return
"FixedList{"
+
"plist="
+
flist
+
'}'
;
}
}
src/share/classes/com/sun/java/util/jar/pack/Fixups.java
浏览文件 @
66fa671c
...
...
@@ -42,7 +42,7 @@ import java.util.Iterator;
*
* @author John Rose
*/
class
Fixups
extends
AbstractCollection
implements
Constants
{
final
class
Fixups
extends
AbstractCollection
{
byte
[]
bytes
;
// the subject of the relocations
int
head
;
// desc locating first reloc
int
tail
;
// desc locating last reloc
...
...
@@ -99,7 +99,7 @@ class Fixups extends AbstractCollection implements Constants {
}
}
public
void
visitRefs
(
Collection
refs
)
{
public
void
visitRefs
(
Collection
<
Entry
>
refs
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
refs
.
add
(
entries
[
i
]);
}
...
...
@@ -124,6 +124,7 @@ class Fixups extends AbstractCollection implements Constants {
return
bytes
;
}
@SuppressWarnings
(
"unchecked"
)
public
void
setBytes
(
byte
[]
newBytes
)
{
if
(
bytes
==
newBytes
)
return
;
ArrayList
old
=
null
;
...
...
@@ -278,7 +279,7 @@ class Fixups extends AbstractCollection implements Constants {
return
new
Fixup
(
nextDesc
(),
entries
[
thisIndex
]);
}
int
nextDesc
()
{
in
t
thisIndex
=
in
dex
++;
index
++;
int
thisDesc
=
next
;
if
(
index
<
size
)
{
// Fetch next desc eagerly, in case this fixup gets finalized.
...
...
@@ -310,6 +311,7 @@ class Fixups extends AbstractCollection implements Constants {
public
boolean
add
(
Object
fixup
)
{
return
add
((
Fixup
)
fixup
);
}
@SuppressWarnings
(
"unchecked"
)
public
boolean
addAll
(
Collection
c
)
{
if
(
c
instanceof
Fixups
)
{
// Use knowledge of Itr structure to avoid building little structs.
...
...
@@ -420,7 +422,7 @@ class Fixups extends AbstractCollection implements Constants {
// Iterate over all the references in this set of fixups.
public
static
void
visitRefs
(
Object
fixups
,
Collection
refs
)
{
void
visitRefs
(
Object
fixups
,
Collection
<
Entry
>
refs
)
{
if
(
fixups
==
null
)
{
}
else
if
(!(
fixups
instanceof
Fixups
))
{
// Special convention; see above.
...
...
src/share/classes/com/sun/java/util/jar/pack/Histogram.java
浏览文件 @
66fa671c
...
...
@@ -34,7 +34,7 @@ import java.util.Arrays;
* Histogram derived from an integer array of events (int[]).
* @author John Rose
*/
class
Histogram
{
final
class
Histogram
{
// Compact histogram representation: 4 bytes per distinct value,
// plus 5 words per distinct count.
protected
final
int
[][]
matrix
;
// multi-row matrix {{counti,valueij...}}
...
...
@@ -304,7 +304,7 @@ class Histogram {
public
String
[]
getRowTitles
(
String
name
)
{
int
totalUnique
=
getTotalLength
();
int
totalWeight
=
getTotalWeight
();
int
l
totalWeight
=
getTotalWeight
();
String
[]
histTitles
=
new
String
[
matrix
.
length
];
int
cumWeight
=
0
;
int
cumUnique
=
0
;
...
...
@@ -314,7 +314,7 @@ class Histogram {
int
weight
=
getRowWeight
(
i
);
cumWeight
+=
weight
;
cumUnique
+=
unique
;
long
wpct
=
((
long
)
cumWeight
*
100
+
totalWeight
/
2
)
/
totalWeight
;
long
wpct
=
((
long
)
cumWeight
*
100
+
ltotalWeight
/
2
)
/
l
totalWeight
;
long
upct
=
((
long
)
cumUnique
*
100
+
totalUnique
/
2
)
/
totalUnique
;
double
len
=
getRowBitLength
(
i
);
assert
(
0.1
>
Math
.
abs
(
len
-
getBitLength
(
matrix
[
i
][
1
])));
...
...
@@ -346,14 +346,14 @@ class Histogram {
public
void
print
(
String
name
,
String
[]
histTitles
,
PrintStream
out
)
{
int
totalUnique
=
getTotalLength
();
int
totalWeight
=
getTotalWeight
();
int
l
totalWeight
=
getTotalWeight
();
double
tlen
=
getBitLength
();
double
avgLen
=
tlen
/
totalWeight
;
double
avg
=
(
double
)
totalWeight
/
totalUnique
;
double
avgLen
=
tlen
/
l
totalWeight
;
double
avg
=
(
double
)
l
totalWeight
/
totalUnique
;
String
title
=
(
name
+
" len="
+
round
(
tlen
,
10
)
+
" avgLen="
+
round
(
avgLen
,
10
)
+
" weight("
+
totalWeight
+
")"
+
" weight("
+
l
totalWeight
+
")"
+
" unique["
+
totalUnique
+
"]"
+
" avgWeight("
+
round
(
avg
,
100
)+
")"
);
if
(
histTitles
==
null
)
{
...
...
@@ -363,9 +363,9 @@ class Histogram {
StringBuffer
buf
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
matrix
.
length
;
i
++)
{
buf
.
setLength
(
0
);
buf
.
append
(
" "
+
histTitles
[
i
]+
" {"
);
buf
.
append
(
" "
).
append
(
histTitles
[
i
]).
append
(
" {"
);
for
(
int
j
=
1
;
j
<
matrix
[
i
].
length
;
j
++)
{
buf
.
append
(
" "
+
matrix
[
i
][
j
]);
buf
.
append
(
" "
).
append
(
matrix
[
i
][
j
]);
}
buf
.
append
(
" }"
);
out
.
println
(
buf
);
...
...
@@ -603,7 +603,7 @@ class Histogram {
private
static
int
[]
maybeSort
(
int
[]
values
)
{
if
(!
isSorted
(
values
,
0
,
false
))
{
values
=
(
int
[])
values
.
clone
();
values
=
values
.
clone
();
Arrays
.
sort
(
values
);
}
return
values
;
...
...
src/share/classes/com/sun/java/util/jar/pack/Instruction.java
浏览文件 @
66fa671c
...
...
@@ -26,13 +26,15 @@
package
com.sun.java.util.jar.pack
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* A parsed bytecode instruction.
* Provides accessors to various relevant bits.
* @author John Rose
*/
class
Instruction
implements
Constants
{
class
Instruction
{
protected
byte
[]
bytes
;
// bytecodes
protected
int
pc
;
// location of this instruction
protected
int
bc
;
// opcode of this instruction
...
...
@@ -91,8 +93,8 @@ class Instruction implements Constants {
/** A fake instruction at this pc whose next() will be at nextpc. */
public
Instruction
forceNextPC
(
int
nextpc
)
{
int
length
=
nextpc
-
pc
;
return
new
Instruction
(
bytes
,
pc
,
-
1
,
-
1
,
length
);
int
l
l
ength
=
nextpc
-
pc
;
return
new
Instruction
(
bytes
,
pc
,
-
1
,
-
1
,
l
l
ength
);
}
public
static
Instruction
at
(
byte
[]
bytes
,
int
pc
)
{
...
...
@@ -315,12 +317,24 @@ class Instruction implements Constants {
}
}
/** Two insns are equal if they have the same bytes. */
/** Two ins
tructio
ns are equal if they have the same bytes. */
public
boolean
equals
(
Object
o
)
{
return
(
o
instanceof
Instruction
)
&&
equals
((
Instruction
)
o
);
return
(
o
!=
null
)
&&
(
o
.
getClass
()
==
Instruction
.
class
)
&&
equals
((
Instruction
)
o
);
}
public
int
hashCode
()
{
int
hash
=
3
;
hash
=
11
*
hash
+
Arrays
.
hashCode
(
this
.
bytes
);
hash
=
11
*
hash
+
this
.
pc
;
hash
=
11
*
hash
+
this
.
bc
;
hash
=
11
*
hash
+
this
.
w
;
hash
=
11
*
hash
+
this
.
length
;
return
hash
;
}
public
boolean
equals
(
Instruction
that
)
{
if
(
this
.
pc
!=
that
.
pc
)
return
false
;
if
(
this
.
bc
!=
that
.
bc
)
return
false
;
if
(
this
.
w
!=
that
.
w
)
return
false
;
if
(
this
.
length
!=
that
.
length
)
return
false
;
...
...
src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java
浏览文件 @
66fa671c
...
...
@@ -170,8 +170,8 @@ class NativeUnpack {
void
run
(
InputStream
inRaw
,
JarOutputStream
jstream
,
ByteBuffer
presetInput
)
throws
IOException
{
BufferedInputStream
in
=
new
BufferedInputStream
(
inRaw
);
this
.
in
=
in
;
// for readInputFn to see
BufferedInputStream
in
0
=
new
BufferedInputStream
(
inRaw
);
this
.
in
=
in
0
;
// for readInputFn to see
_verbose
=
_props
.
getInteger
(
Utils
.
DEBUG_VERBOSE
);
// Fix for BugId: 4902477, -unpack.modification.time = 1059010598000
// TODO eliminate and fix in unpack.cpp
...
...
@@ -224,7 +224,7 @@ class NativeUnpack {
if
(
_verbose
>
0
)
Utils
.
log
.
info
(
"bytes consumed = "
+
consumed
);
if
(
presetInput
==
null
&&
!
Utils
.
isPackMagic
(
Utils
.
readMagic
(
in
)))
{
!
Utils
.
isPackMagic
(
Utils
.
readMagic
(
in
0
)))
{
break
;
}
if
(
_verbose
>
0
)
{
...
...
src/share/classes/com/sun/java/util/jar/pack/Package.java
浏览文件 @
66fa671c
...
...
@@ -52,12 +52,13 @@ import java.util.ListIterator;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.jar.JarFile
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Define the main data structure transmitted by pack/unpack.
* @author John Rose
*/
class
Package
implements
Constants
{
class
Package
{
int
verbose
;
{
PropMap
pmap
=
Utils
.
currentPropMap
();
...
...
@@ -109,9 +110,9 @@ class Package implements Constants {
public
static
final
Attribute
.
Layout
attrCodeEmpty
;
public
static
final
Attribute
.
Layout
attrInnerClassesEmpty
;
public
static
final
Attribute
.
Layout
attrSourceFileSpecial
;
public
static
final
Map
attrDefs
;
public
static
final
Map
<
Attribute
.
Layout
,
Attribute
>
attrDefs
;
static
{
Hash
Map
<
Layout
,
Attribute
>
ad
=
new
HashMap
<>(
3
);
Map
<
Layout
,
Attribute
>
ad
=
new
HashMap
<>(
3
);
attrCodeEmpty
=
Attribute
.
define
(
ad
,
ATTR_CONTEXT_METHOD
,
"Code"
,
""
).
layout
();
attrInnerClassesEmpty
=
Attribute
.
define
(
ad
,
ATTR_CONTEXT_CLASS
,
...
...
@@ -130,8 +131,7 @@ class Package implements Constants {
*/
int
getHighestClassVersion
()
{
int
res
=
0
;
// initial low value
for
(
Iterator
i
=
classes
.
iterator
();
i
.
hasNext
();
)
{
Class
cls
=
(
Class
)
i
.
next
();
for
(
Class
cls
:
classes
)
{
int
ver
=
cls
.
getVersion
();
if
(
res
<
ver
)
res
=
ver
;
}
...
...
@@ -187,7 +187,7 @@ class Package implements Constants {
return
classes
;
}
public
public
final
class
Class
extends
Attribute
.
Holder
implements
Comparable
{
public
Package
getPackage
()
{
return
Package
.
this
;
}
...
...
@@ -232,8 +232,8 @@ class Package implements Constants {
initFile
(
newStub
(
classFile
));
}
List
getFields
()
{
return
fields
==
null
?
noFields
:
fields
;
}
List
getMethods
()
{
return
methods
==
null
?
noMethods
:
methods
;
}
List
<
Field
>
getFields
()
{
return
fields
==
null
?
noFields
:
fields
;
}
List
<
Method
>
getMethods
()
{
return
methods
==
null
?
noMethods
:
methods
;
}
public
String
getName
()
{
return
thisClass
.
stringValue
();
...
...
@@ -264,7 +264,7 @@ class Package implements Constants {
if
(
olda
==
null
)
return
;
// no SourceFile attr.
String
obvious
=
getObviousSourceFile
();
ArrayList
ref
=
new
ArrayList
(
1
);
List
<
Entry
>
ref
=
new
ArrayList
<>
(
1
);
olda
.
visitRefs
(
this
,
VRM_PACKAGE
,
ref
);
Utf8Entry
sfName
=
(
Utf8Entry
)
ref
.
get
(
0
);
Attribute
a
=
olda
;
...
...
@@ -322,7 +322,7 @@ class Package implements Constants {
}
public
void
setInnerClasses
(
Collection
<
InnerClass
>
ics
)
{
innerClasses
=
(
ics
==
null
)
?
null
:
new
ArrayList
<
InnerClass
>(
ics
);
innerClasses
=
(
ics
==
null
)
?
null
:
new
ArrayList
<>(
ics
);
// Edit the attribute list, if necessary.
Attribute
a
=
getAttribute
(
attrInnerClassesEmpty
);
if
(
innerClasses
!=
null
&&
a
==
null
)
...
...
@@ -341,7 +341,7 @@ class Package implements Constants {
* with that of Package.this.allInnerClasses.
*/
public
List
<
InnerClass
>
computeGloballyImpliedICs
()
{
Hash
Set
<
Entry
>
cpRefs
=
new
HashSet
<>();
Set
<
Entry
>
cpRefs
=
new
HashSet
<>();
{
// This block temporarily displaces this.innerClasses.
ArrayList
<
InnerClass
>
innerClassesSaved
=
innerClasses
;
innerClasses
=
null
;
// ignore for the moment
...
...
@@ -350,7 +350,7 @@ class Package implements Constants {
}
ConstantPool
.
completeReferencesIn
(
cpRefs
,
true
);
Hash
Set
<
Entry
>
icRefs
=
new
HashSet
<>();
Set
<
Entry
>
icRefs
=
new
HashSet
<>();
for
(
Entry
e
:
cpRefs
)
{
// Restrict cpRefs to InnerClasses entries only.
if
(!(
e
instanceof
ClassEntry
))
continue
;
...
...
@@ -390,7 +390,7 @@ class Package implements Constants {
List
<
InnerClass
>
impliedICs
=
computeGloballyImpliedICs
();
List
<
InnerClass
>
actualICs
=
getInnerClasses
();
if
(
actualICs
==
null
)
actualICs
=
Collections
.
EMPTY_LIST
;
actualICs
=
Collections
.
emptyList
()
;
// Symmetric difference is calculated from I, A like this:
// diff = (I+A) - (I*A)
...
...
@@ -409,7 +409,7 @@ class Package implements Constants {
// Diff is A since I is empty.
}
// (I*A) is non-trivial
Hash
Set
<
InnerClass
>
center
=
new
HashSet
<>(
actualICs
);
Set
<
InnerClass
>
center
=
new
HashSet
<>(
actualICs
);
center
.
retainAll
(
new
HashSet
<>(
impliedICs
));
impliedICs
.
addAll
(
actualICs
);
impliedICs
.
removeAll
(
center
);
...
...
@@ -443,7 +443,7 @@ class Package implements Constants {
}
else
if
(
actualICs
==
null
)
{
// No local IC attribute, even though some are implied.
// Signal with trivial attribute.
localICs
=
Collections
.
EMPTY_LIST
;
localICs
=
Collections
.
emptyList
()
;
}
else
{
// Transmit a non-empty diff, which will create
// a local ICs attribute.
...
...
@@ -588,7 +588,7 @@ class Package implements Constants {
}
public
void
strip
(
String
attrName
)
{
if
(
attrName
==
"Code"
)
if
(
"Code"
.
equals
(
attrName
)
)
code
=
null
;
if
(
code
!=
null
)
code
.
strip
(
attrName
);
...
...
@@ -622,7 +622,7 @@ class Package implements Constants {
}
public
void
strip
(
String
attrName
)
{
if
(
attrName
==
"InnerClass"
)
if
(
"InnerClass"
.
equals
(
attrName
)
)
innerClasses
=
null
;
for
(
int
isM
=
0
;
isM
<=
1
;
isM
++)
{
ArrayList
members
=
(
isM
==
0
)
?
fields
:
methods
;
...
...
@@ -639,9 +639,7 @@ class Package implements Constants {
if
(
verbose
>
2
)
Utils
.
log
.
fine
(
"visitRefs "
+
this
);
refs
.
add
(
thisClass
);
refs
.
add
(
superClass
);
for
(
int
i
=
0
;
i
<
interfaces
.
length
;
i
++)
{
refs
.
add
(
interfaces
[
i
]);
}
refs
.
addAll
(
Arrays
.
asList
(
interfaces
));
for
(
int
isM
=
0
;
isM
<=
1
;
isM
++)
{
ArrayList
members
=
(
isM
==
0
)
?
fields
:
methods
;
if
(
members
==
null
)
continue
;
...
...
@@ -741,7 +739,7 @@ class Package implements Constants {
}
public
List
<
File
>
getClassStubs
()
{
Array
List
<
File
>
classStubs
=
new
ArrayList
<>(
classes
.
size
());
List
<
File
>
classStubs
=
new
ArrayList
<>(
classes
.
size
());
for
(
Class
cls
:
classes
)
{
assert
(
cls
.
file
.
isClassStub
());
classStubs
.
add
(
cls
.
file
);
...
...
@@ -749,8 +747,7 @@ class Package implements Constants {
return
classStubs
;
}
public
class
File
implements
Comparable
{
public
final
class
File
implements
Comparable
{
String
nameString
;
// true name of this file
Utf8Entry
name
;
int
modtime
=
NO_MODTIME
;
...
...
@@ -792,8 +789,10 @@ class Package implements Constants {
// The nameString is the key. Ignore other things.
// (Note: The name might be "", in the case of a trivial class stub.)
public
boolean
equals
(
Object
o
)
{
if
(
o
==
null
||
(
o
.
getClass
()
!=
File
.
class
))
return
false
;
File
that
=
(
File
)
o
;
return
that
.
nameString
==
this
.
nameString
;
return
that
.
nameString
.
equals
(
this
.
nameString
)
;
}
public
int
hashCode
()
{
return
nameString
.
hashCode
();
...
...
@@ -816,9 +815,9 @@ class Package implements Constants {
return
getFileName
(
null
);
}
public
java
.
io
.
File
getFileName
(
java
.
io
.
File
parent
)
{
String
name
=
this
.
nameString
;
String
l
name
=
this
.
nameString
;
//if (name.startsWith("./")) name = name.substring(2);
String
fname
=
name
.
replace
(
'/'
,
java
.
io
.
File
.
separatorChar
);
String
fname
=
l
name
.
replace
(
'/'
,
java
.
io
.
File
.
separatorChar
);
return
new
java
.
io
.
File
(
parent
,
fname
);
}
...
...
@@ -834,7 +833,7 @@ class Package implements Constants {
}
public
long
getFileLength
()
{
long
len
=
0
;
if
(
prepend
==
null
&&
append
==
null
)
return
0
;
if
(
prepend
==
null
||
append
==
null
)
return
0
;
for
(
Iterator
i
=
prepend
.
iterator
();
i
.
hasNext
();
)
{
byte
[]
block
=
(
byte
[])
i
.
next
();
len
+=
block
.
length
;
...
...
@@ -843,7 +842,7 @@ class Package implements Constants {
return
len
;
}
public
void
writeTo
(
OutputStream
out
)
throws
IOException
{
if
(
prepend
==
null
&&
append
==
null
)
return
;
if
(
prepend
==
null
||
append
==
null
)
return
;
for
(
Iterator
i
=
prepend
.
iterator
();
i
.
hasNext
();
)
{
byte
[]
block
=
(
byte
[])
i
.
next
();
out
.
write
(
block
);
...
...
@@ -859,8 +858,8 @@ class Package implements Constants {
}
public
InputStream
getInputStream
()
{
InputStream
in
=
new
ByteArrayInputStream
(
append
.
toByteArray
());
if
(
prepend
.
size
()
==
0
)
return
in
;
Array
List
<
InputStream
>
isa
=
new
ArrayList
<>(
prepend
.
size
()+
1
);
if
(
prepend
.
isEmpty
()
)
return
in
;
List
<
InputStream
>
isa
=
new
ArrayList
<>(
prepend
.
size
()+
1
);
for
(
Iterator
i
=
prepend
.
iterator
();
i
.
hasNext
();
)
{
byte
[]
bytes
=
(
byte
[])
i
.
next
();
isa
.
add
(
new
ByteArrayInputStream
(
bytes
));
...
...
@@ -897,11 +896,11 @@ class Package implements Constants {
}
// Is there a globally declared table of inner classes?
Array
List
<
InnerClass
>
allInnerClasses
=
new
ArrayList
<>();
Hash
Map
<
ClassEntry
,
InnerClass
>
allInnerClassesByThis
;
List
<
InnerClass
>
allInnerClasses
=
new
ArrayList
<>();
Map
<
ClassEntry
,
InnerClass
>
allInnerClassesByThis
;
public
List
getAllInnerClasses
()
{
List
<
InnerClass
>
getAllInnerClasses
()
{
return
allInnerClasses
;
}
...
...
@@ -955,16 +954,17 @@ class Package implements Constants {
if
(
parse
==
null
)
return
false
;
String
pkgOuter
=
parse
[
0
];
//String number = parse[1];
String
name
=
parse
[
2
];
String
l
name
=
parse
[
2
];
String
haveName
=
(
this
.
name
==
null
)
?
null
:
this
.
name
.
stringValue
();
String
haveOuter
=
(
outerClass
==
null
)
?
null
:
outerClass
.
stringValue
();
boolean
predictable
=
(
name
==
haveName
&&
pkgOuter
==
haveOuter
);
boolean
lpredictable
=
(
l
name
==
haveName
&&
pkgOuter
==
haveOuter
);
//System.out.println("computePredictable => "+predictable);
return
predictable
;
return
l
predictable
;
}
public
boolean
equals
(
Object
o
)
{
if
(
o
==
null
)
return
false
;
if
(
o
==
null
||
o
.
getClass
()
!=
InnerClass
.
class
)
return
false
;
InnerClass
that
=
(
InnerClass
)
o
;
return
eq
(
this
.
thisClass
,
that
.
thisClass
)
&&
eq
(
this
.
outerClass
,
that
.
outerClass
)
...
...
@@ -999,7 +999,7 @@ class Package implements Constants {
// Helper for building InnerClasses attributes.
static
private
void
visitInnerClassRefs
(
Collection
innerClasses
,
int
mode
,
Collection
<
Entry
>
refs
)
{
void
visitInnerClassRefs
(
Collection
<
InnerClass
>
innerClasses
,
int
mode
,
Collection
<
Entry
>
refs
)
{
if
(
innerClasses
==
null
)
{
return
;
// no attribute; nothing to do
}
...
...
@@ -1008,8 +1008,7 @@ class Package implements Constants {
}
if
(
innerClasses
.
size
()
>
0
)
{
// Count the entries themselves:
for
(
Iterator
i
=
innerClasses
.
iterator
();
i
.
hasNext
();
)
{
InnerClass
c
=
(
InnerClass
)
i
.
next
();
for
(
InnerClass
c
:
innerClasses
)
{
c
.
visitRefs
(
mode
,
refs
);
}
}
...
...
@@ -1117,43 +1116,43 @@ class Package implements Constants {
// what is one of { Debug, Compile, Constant, Exceptions, InnerClasses }
if
(
verbose
>
0
)
Utils
.
log
.
info
(
"Stripping "
+
what
.
toLowerCase
()+
" data and attributes..."
);
if
(
what
==
"Debug"
)
{
strip
(
"SourceFile"
);
strip
(
"LineNumberTable"
);
strip
(
"LocalVariableTable"
);
strip
(
"LocalVariableTypeTable"
);
}
if
(
what
==
"Compile"
)
{
// Keep the inner classes normally.
// Although they have no effect on execution,
// the Reflection API exposes them, and JCK checks them.
// NO: // strip("InnerClasses");
strip
(
"Deprecated"
);
strip
(
"Synthetic"
);
}
if
(
what
==
"Exceptions"
)
{
// Keep the exceptions normally.
// Although they have no effect on execution,
// the Reflection API exposes them, and JCK checks them.
strip
(
"Exceptions"
);
}
if
(
what
==
"Constant"
)
{
stripConstantFields
();
switch
(
what
)
{
case
"Debug"
:
strip
(
"SourceFile"
);
strip
(
"LineNumberTable"
);
strip
(
"LocalVariableTable"
);
strip
(
"LocalVariableTypeTable"
);
break
;
case
"Compile"
:
// Keep the inner classes normally.
// Although they have no effect on execution,
// the Reflection API exposes them, and JCK checks them.
// NO: // strip("InnerClasses");
strip
(
"Deprecated"
);
strip
(
"Synthetic"
);
break
;
case
"Exceptions"
:
// Keep the exceptions normally.
// Although they have no effect on execution,
// the Reflection API exposes them, and JCK checks them.
strip
(
"Exceptions"
);
break
;
case
"Constant"
:
stripConstantFields
();
break
;
}
}
public
void
trimToSize
()
{
classes
.
trimToSize
();
for
(
Iterator
i
=
classes
.
iterator
();
i
.
hasNext
();
)
{
Class
c
=
(
Class
)
i
.
next
();
for
(
Class
c
:
classes
)
{
c
.
trimToSize
();
}
files
.
trimToSize
();
}
public
void
strip
(
String
attrName
)
{
for
(
Iterator
i
=
classes
.
iterator
();
i
.
hasNext
();
)
{
Class
c
=
(
Class
)
i
.
next
();
for
(
Class
c
:
classes
)
{
c
.
strip
(
attrName
);
}
}
...
...
@@ -1166,10 +1165,9 @@ class Package implements Constants {
}
public
void
stripConstantFields
()
{
for
(
Iterator
i
=
classes
.
iterator
();
i
.
hasNext
();
)
{
Class
c
=
(
Class
)
i
.
next
();
for
(
Iterator
j
=
c
.
fields
.
iterator
();
j
.
hasNext
();
)
{
Class
.
Field
f
=
(
Class
.
Field
)
j
.
next
();
for
(
Class
c
:
classes
)
{
for
(
Iterator
<
Class
.
Field
>
j
=
c
.
fields
.
iterator
();
j
.
hasNext
();
)
{
Class
.
Field
f
=
j
.
next
();
if
(
Modifier
.
isFinal
(
f
.
flags
)
// do not strip non-static finals:
&&
Modifier
.
isStatic
(
f
.
flags
)
...
...
@@ -1189,8 +1187,7 @@ class Package implements Constants {
c
.
visitRefs
(
mode
,
refs
);
}
if
(
mode
!=
VRM_CLASSIC
)
{
for
(
Iterator
i
=
files
.
iterator
();
i
.
hasNext
();
)
{
File
f
=
(
File
)
i
.
next
();
for
(
File
f
:
files
)
{
f
.
visitRefs
(
mode
,
refs
);
}
visitInnerClassRefs
(
allInnerClasses
,
mode
,
refs
);
...
...
@@ -1202,6 +1199,7 @@ class Package implements Constants {
// compress better. It also moves classes to the end of the
// file order. It also removes JAR directory entries, which
// are useless.
@SuppressWarnings
(
"unchecked"
)
void
reorderFiles
(
boolean
keepClassOrder
,
boolean
stripDirectories
)
{
// First reorder the classes, if that is allowed.
if
(!
keepClassOrder
)
{
...
...
@@ -1214,9 +1212,9 @@ class Package implements Constants {
// modtimes and options are not transmitted, and the stub files
// for class files do not need to be transmitted at all.
// Also
List
stubs
=
getClassStubs
();
for
(
Iterator
i
=
files
.
iterator
();
i
.
hasNext
();
)
{
File
file
=
(
File
)
i
.
next
();
List
<
File
>
stubs
=
getClassStubs
();
for
(
Iterator
<
File
>
i
=
files
.
iterator
();
i
.
hasNext
();
)
{
File
file
=
i
.
next
();
if
(
file
.
isClassStub
()
||
(
stripDirectories
&&
file
.
isDirectory
()))
{
i
.
remove
();
...
...
@@ -1259,8 +1257,8 @@ class Package implements Constants {
void
trimStubs
()
{
// Restore enough non-trivial stubs to carry the needed class modtimes.
for
(
ListIterator
i
=
files
.
listIterator
(
files
.
size
());
i
.
hasPrevious
();
)
{
File
file
=
(
File
)
i
.
previous
();
for
(
ListIterator
<
File
>
i
=
files
.
listIterator
(
files
.
size
());
i
.
hasPrevious
();
)
{
File
file
=
i
.
previous
();
if
(!
file
.
isTrivialClassStub
())
{
if
(
verbose
>
1
)
Utils
.
log
.
fine
(
"Keeping last non-trivial "
+
file
);
...
...
@@ -1309,7 +1307,7 @@ class Package implements Constants {
// Use this before writing the class files.
void
ensureAllClassFiles
()
{
Hash
Set
<
File
>
fileSet
=
new
HashSet
<>(
files
);
Set
<
File
>
fileSet
=
new
HashSet
<>(
files
);
for
(
Class
cls
:
classes
)
{
// Add to the end of ths list:
if
(!
fileSet
.
contains
(
cls
.
file
))
...
...
@@ -1317,8 +1315,8 @@ class Package implements Constants {
}
}
static
final
List
noObjects
=
Arrays
.
asList
(
new
Object
[
0
]);
static
final
List
noFields
=
Arrays
.
asList
(
new
Class
.
Field
[
0
]);
static
final
List
noMethods
=
Arrays
.
asList
(
new
Class
.
Method
[
0
]);
static
final
List
noInnerClasses
=
Arrays
.
asList
(
new
InnerClass
[
0
]);
static
final
List
<
Object
>
noObjects
=
Arrays
.
asList
(
new
Object
[
0
]);
static
final
List
<
Class
.
Field
>
noFields
=
Arrays
.
asList
(
new
Class
.
Field
[
0
]);
static
final
List
<
Class
.
Method
>
noMethods
=
Arrays
.
asList
(
new
Class
.
Method
[
0
]);
static
final
List
<
InnerClass
>
noInnerClasses
=
Arrays
.
asList
(
new
InnerClass
[
0
]);
}
src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
浏览文件 @
66fa671c
...
...
@@ -32,11 +32,28 @@ import com.sun.java.util.jar.pack.ConstantPool.Index;
import
com.sun.java.util.jar.pack.ConstantPool.MemberEntry
;
import
com.sun.java.util.jar.pack.ConstantPool.SignatureEntry
;
import
com.sun.java.util.jar.pack.ConstantPool.Utf8Entry
;
import
java.io.*
;
import
java.util.*
;
import
com.sun.java.util.jar.pack.Package.Class
;
import
com.sun.java.util.jar.pack.Package.File
;
import
com.sun.java.util.jar.pack.Package.InnerClass
;
import
java.io.ByteArrayOutputStream
;
import
java.io.EOFException
;
import
java.io.PrintStream
;
import
java.io.FilterInputStream
;
import
java.io.BufferedInputStream
;
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.ListIterator
;
import
java.util.Set
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Reader for a package file.
...
...
@@ -418,7 +435,7 @@ class PackageReader extends BandStructure {
cp_Int
.
readFrom
(
in
);
for
(
int
i
=
0
;
i
<
cpMap
.
length
;
i
++)
{
int
x
=
cp_Int
.
getInt
();
// coding handles signs OK
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
new
Integer
(
x
)
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
x
);
}
cp_Int
.
doneDisbursing
();
break
;
...
...
@@ -428,7 +445,7 @@ class PackageReader extends BandStructure {
for
(
int
i
=
0
;
i
<
cpMap
.
length
;
i
++)
{
int
x
=
cp_Float
.
getInt
();
float
fx
=
Float
.
intBitsToFloat
(
x
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
new
Float
(
fx
)
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
fx
);
}
cp_Float
.
doneDisbursing
();
break
;
...
...
@@ -444,7 +461,7 @@ class PackageReader extends BandStructure {
long
hi
=
cp_Long_hi
.
getInt
();
long
lo
=
cp_Long_lo
.
getInt
();
long
x
=
(
hi
<<
32
)
+
((
lo
<<
32
)
>>>
32
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
new
Long
(
x
)
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
x
);
}
cp_Long_hi
.
doneDisbursing
();
cp_Long_lo
.
doneDisbursing
();
...
...
@@ -462,7 +479,7 @@ class PackageReader extends BandStructure {
long
lo
=
cp_Double_lo
.
getInt
();
long
x
=
(
hi
<<
32
)
+
((
lo
<<
32
)
>>>
32
);
double
dx
=
Double
.
longBitsToDouble
(
x
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
new
Double
(
dx
)
);
cpMap
[
i
]
=
ConstantPool
.
getLiteralEntry
(
dx
);
}
cp_Double_hi
.
doneDisbursing
();
cp_Double_lo
.
doneDisbursing
();
...
...
@@ -645,7 +662,7 @@ class PackageReader extends BandStructure {
cp_Utf8_big_suffix
.
doneDisbursing
();
}
HashMap
utf8Signatures
;
// Utf8Entry->SignatureEntry
Map
<
Utf8Entry
,
SignatureEntry
>
utf8Signatures
;
void
readSignatureBands
(
Entry
[]
cpMap
)
throws
IOException
{
// cp_Signature:
...
...
@@ -663,7 +680,7 @@ class PackageReader extends BandStructure {
cp_Signature_classes
.
expectLength
(
getIntTotal
(
numSigClasses
));
cp_Signature_classes
.
readFrom
(
in
);
cp_Signature_classes
.
setIndex
(
getCPIndex
(
CONSTANT_Class
));
utf8Signatures
=
new
HashMap
();
utf8Signatures
=
new
HashMap
<>
();
for
(
int
i
=
0
;
i
<
cpMap
.
length
;
i
++)
{
Utf8Entry
formRef
=
(
Utf8Entry
)
cp_Signature_form
.
getRef
();
ClassEntry
[]
classRefs
=
new
ClassEntry
[
numSigClasses
[
i
]];
...
...
@@ -863,7 +880,7 @@ class PackageReader extends BandStructure {
ic_name
.
expectLength
(
longICCount
);
ic_name
.
readFrom
(
in
);
ic_flags
.
resetForSecondPass
();
ArrayList
icList
=
new
ArrayList
(
numInnerClasses
);
List
<
InnerClass
>
icList
=
new
ArrayList
<>
(
numInnerClasses
);
for
(
int
i
=
0
;
i
<
numInnerClasses
;
i
++)
{
int
flags
=
ic_flags
.
getInt
();
boolean
longForm
=
(
flags
&
ACC_IC_LONG_FORM
)
!=
0
;
...
...
@@ -876,7 +893,7 @@ class PackageReader extends BandStructure {
thisName
=
(
Utf8Entry
)
ic_name
.
getRef
();
}
else
{
String
n
=
thisClass
.
stringValue
();
String
[]
parse
=
pkg
.
parseInnerClassName
(
n
);
String
[]
parse
=
Package
.
parseInnerClassName
(
n
);
assert
(
parse
!=
null
);
String
pkgOuter
=
parse
[
0
];
//String number = parse[1];
...
...
@@ -905,7 +922,7 @@ class PackageReader extends BandStructure {
void
readLocalInnerClasses
(
Class
cls
)
throws
IOException
{
int
nc
=
class_InnerClasses_N
.
getInt
();
ArrayList
localICs
=
new
ArrayList
(
nc
);
List
<
InnerClass
>
localICs
=
new
ArrayList
<>
(
nc
);
for
(
int
i
=
0
;
i
<
nc
;
i
++)
{
ClassEntry
thisClass
=
(
ClassEntry
)
class_InnerClasses_RC
.
getRef
();
int
flags
=
class_InnerClasses_F
.
getInt
();
...
...
@@ -994,10 +1011,8 @@ class PackageReader extends BandStructure {
return
-
1
;
}
Comparator
entryOutputOrder
=
new
Comparator
()
{
public
int
compare
(
Object
o0
,
Object
o1
)
{
Entry
e0
=
(
Entry
)
o0
;
Entry
e1
=
(
Entry
)
o1
;
Comparator
<
Entry
>
entryOutputOrder
=
new
Comparator
<>()
{
public
int
compare
(
Entry
e0
,
Entry
e1
)
{
int
k0
=
getOutputIndex
(
e0
);
int
k1
=
getOutputIndex
(
e1
);
if
(
k0
>=
0
&&
k1
>=
0
)
...
...
@@ -1034,9 +1049,8 @@ class PackageReader extends BandStructure {
}
Entry
[]
reconstructLocalCPMap
(
Class
cls
)
{
HashSet
ldcRefs
=
(
HashSet
)
ldcRefMap
.
get
(
cls
);
HashSet
cpRefs
=
new
HashSet
();
HashSet
sigSet
=
new
HashSet
();
Set
<
Entry
>
ldcRefs
=
ldcRefMap
.
get
(
cls
);
Set
<
Entry
>
cpRefs
=
new
HashSet
<>();
// look for constant pool entries:
cls
.
visitRefs
(
VRM_CLASSIC
,
cpRefs
);
...
...
@@ -1064,8 +1078,7 @@ class PackageReader extends BandStructure {
// construct a local constant pool
int
numDoubles
=
0
;
for
(
Iterator
i
=
cpRefs
.
iterator
();
i
.
hasNext
();
)
{
Entry
e
=
(
Entry
)
i
.
next
();
for
(
Entry
e
:
cpRefs
)
{
if
(
e
.
isDoubleWord
())
numDoubles
++;
assert
(
e
.
tag
!=
CONSTANT_Signature
)
:
(
e
);
}
...
...
@@ -1075,8 +1088,7 @@ class PackageReader extends BandStructure {
// Add all ldc operands first.
if
(
ldcRefs
!=
null
)
{
assert
(
cpRefs
.
containsAll
(
ldcRefs
));
for
(
Iterator
i
=
ldcRefs
.
iterator
();
i
.
hasNext
();
)
{
Entry
e
=
(
Entry
)
i
.
next
();
for
(
Entry
e
:
ldcRefs
)
{
cpMap
[
fillp
++]
=
e
;
}
assert
(
fillp
==
1
+
ldcRefs
.
size
());
...
...
@@ -1085,11 +1097,10 @@ class PackageReader extends BandStructure {
}
// Next add all the two-byte references.
HashSet
wideRefs
=
cpRefs
;
Set
<
Entry
>
wideRefs
=
cpRefs
;
cpRefs
=
null
;
// do not use!
int
narrowLimit
=
fillp
;
for
(
Iterator
i
=
wideRefs
.
iterator
();
i
.
hasNext
();
)
{
Entry
e
=
(
Entry
)
i
.
next
();
for
(
Entry
e
:
wideRefs
)
{
cpMap
[
fillp
++]
=
e
;
}
assert
(
fillp
==
narrowLimit
+
wideRefs
.
size
());
...
...
@@ -1144,7 +1155,7 @@ class PackageReader extends BandStructure {
method_descr
.
expectLength
(
totalNM
);
if
(
verbose
>
1
)
Utils
.
log
.
fine
(
"expecting #fields="
+
totalNF
+
" and #methods="
+
totalNM
+
" in #classes="
+
numClasses
);
ArrayList
fields
=
new
ArrayList
(
totalNF
);
List
<
Class
.
Field
>
fields
=
new
ArrayList
<>
(
totalNF
);
field_descr
.
readFrom
(
in
);
for
(
int
i
=
0
;
i
<
classes
.
length
;
i
++)
{
Class
c
=
classes
[
i
];
...
...
@@ -1160,7 +1171,7 @@ class PackageReader extends BandStructure {
countAndReadAttrs
(
ATTR_CONTEXT_FIELD
,
fields
);
fields
=
null
;
// release to GC
ArrayList
methods
=
new
ArrayList
(
totalNM
);
List
<
Class
.
Method
>
methods
=
new
ArrayList
<>
(
totalNM
);
method_descr
.
readFrom
(
in
);
for
(
int
i
=
0
;
i
<
classes
.
length
;
i
++)
{
Class
c
=
classes
[
i
];
...
...
@@ -1182,13 +1193,12 @@ class PackageReader extends BandStructure {
}
Code
[]
allCodes
;
List
codesWithFlags
;
HashMap
ldcRefMap
=
new
HashMap
();
// HashMap<Class, HashSet<Entry>>
List
<
Code
>
codesWithFlags
;
Map
<
Class
,
Set
<
Entry
>>
ldcRefMap
=
new
HashMap
<>();
Code
[]
buildCodeAttrs
(
List
methods
)
{
ArrayList
codes
=
new
ArrayList
(
methods
.
size
());
for
(
Iterator
i
=
methods
.
iterator
();
i
.
hasNext
();
)
{
Class
.
Method
m
=
(
Class
.
Method
)
i
.
next
();
Code
[]
buildCodeAttrs
(
List
<
Class
.
Method
>
methods
)
{
List
<
Code
>
codes
=
new
ArrayList
<>(
methods
.
size
());
for
(
Class
.
Method
m
:
methods
)
{
if
(
m
.
getAttribute
(
attrCodeEmpty
)
!=
null
)
{
m
.
code
=
new
Code
(
m
);
codes
.
add
(
m
.
code
);
...
...
@@ -1211,7 +1221,7 @@ class PackageReader extends BandStructure {
boolean
attrsOK
=
testBit
(
archiveOptions
,
AO_HAVE_ALL_CODE_FLAGS
);
code_headers
.
expectLength
(
allCodes
.
length
);
code_headers
.
readFrom
(
in
);
ArrayList
longCodes
=
new
ArrayList
(
allCodes
.
length
/
10
);
List
<
Code
>
longCodes
=
new
ArrayList
<>
(
allCodes
.
length
/
10
);
for
(
int
i
=
0
;
i
<
allCodes
.
length
;
i
++)
{
Code
c
=
allCodes
[
i
];
int
sc
=
code_headers
.
getByte
();
...
...
@@ -1238,8 +1248,7 @@ class PackageReader extends BandStructure {
code_max_stack
.
readFrom
(
in
);
code_max_na_locals
.
readFrom
(
in
);
code_handler_count
.
readFrom
(
in
);
for
(
Iterator
i
=
longCodes
.
iterator
();
i
.
hasNext
();
)
{
Code
c
=
(
Code
)
i
.
next
();
for
(
Code
c
:
longCodes
)
{
c
.
setMaxStack
(
code_max_stack
.
getInt
()
);
c
.
setMaxNALocals
(
code_max_na_locals
.
getInt
()
);
c
.
setHandlerCount
(
code_handler_count
.
getInt
()
);
...
...
@@ -1386,8 +1395,9 @@ class PackageReader extends BandStructure {
// Fetch the attribute layout definitions which govern the bands
// we are about to read.
Attribute
.
Layout
[]
defs
=
new
Attribute
.
Layout
[
attrDefs
[
ctype
].
size
()];
attrDefs
[
ctype
].
toArray
(
defs
);
List
<
Attribute
.
Layout
>
defList
=
attrDefs
.
get
(
ctype
);
Attribute
.
Layout
[]
defs
=
new
Attribute
.
Layout
[
defList
.
size
()];
defList
.
toArray
(
defs
);
IntBand
xxx_flags_hi
=
getAttrBand
(
xxx_attr_bands
,
AB_FLAGS_HI
);
IntBand
xxx_flags_lo
=
getAttrBand
(
xxx_attr_bands
,
AB_FLAGS_LO
);
IntBand
xxx_attr_count
=
getAttrBand
(
xxx_attr_bands
,
AB_ATTR_COUNT
);
...
...
@@ -1450,7 +1460,7 @@ class PackageReader extends BandStructure {
bits
-=
(
1L
<<
ai
);
nfa
+=
1
;
}
ArrayList
ha
=
new
ArrayList
(
nfa
+
noa
);
List
<
Attribute
>
ha
=
new
ArrayList
<>
(
nfa
+
noa
);
h
.
attributes
=
ha
;
bits
=
attrBits
;
// iterate again
for
(
int
ai
=
0
;
bits
!=
0
;
ai
++)
{
...
...
@@ -1516,7 +1526,7 @@ class PackageReader extends BandStructure {
if
(
predef
!=
isPredefinedAttr
(
ctype
,
ai
))
continue
;
// wrong pass
int
totalCount
=
totalCounts
[
ai
];
Band
[]
ab
=
(
Band
[])
attrBandTable
.
get
(
def
);
Band
[]
ab
=
attrBandTable
.
get
(
def
);
if
(
def
==
attrInnerClassesEmpty
)
{
// Special case.
// Size the bands as if using the following layout:
...
...
@@ -1571,15 +1581,16 @@ class PackageReader extends BandStructure {
ATTR_CONTEXT_NAME
[
ctype
]+
" attribute"
);
}
@SuppressWarnings
(
"unchecked"
)
void
readAttrs
(
int
ctype
,
Collection
holders
)
throws
IOException
{
// Decode band values into attributes.
HashSet
sawDefs
=
new
HashSet
();
Set
<
Attribute
.
Layout
>
sawDefs
=
new
HashSet
<>
();
ByteArrayOutputStream
buf
=
new
ByteArrayOutputStream
();
for
(
Iterator
i
=
holders
.
iterator
();
i
.
hasNext
();
)
{
final
Attribute
.
Holder
h
=
(
Attribute
.
Holder
)
i
.
next
();
if
(
h
.
attributes
==
null
)
continue
;
for
(
ListIterator
j
=
h
.
attributes
.
listIterator
();
j
.
hasNext
();
)
{
Attribute
a
=
(
Attribute
)
j
.
next
();
for
(
ListIterator
<
Attribute
>
j
=
h
.
attributes
.
listIterator
();
j
.
hasNext
();
)
{
Attribute
a
=
j
.
next
();
Attribute
.
Layout
def
=
a
.
layout
();
if
(
def
.
bandCount
==
0
)
{
if
(
def
==
attrInnerClassesEmpty
)
{
...
...
@@ -1595,7 +1606,7 @@ class PackageReader extends BandStructure {
if
(
isCV
)
setConstantValueIndex
((
Class
.
Field
)
h
);
if
(
verbose
>
2
)
Utils
.
log
.
fine
(
"read "
+
a
+
" in "
+
h
);
final
Band
[]
ab
=
(
Band
[])
attrBandTable
.
get
(
def
);
final
Band
[]
ab
=
attrBandTable
.
get
(
def
);
// Read one attribute of type def from ab into a byte array.
buf
.
reset
();
Object
fixups
=
a
.
unparse
(
new
Attribute
.
ValueStream
()
{
...
...
@@ -1617,10 +1628,9 @@ class PackageReader extends BandStructure {
}
// Mark the bands we just used as done disbursing.
for
(
Iterator
i
=
sawDefs
.
iterator
();
i
.
hasNext
();
)
{
Attribute
.
Layout
def
=
(
Attribute
.
Layout
)
i
.
next
();
for
(
Attribute
.
Layout
def
:
sawDefs
)
{
if
(
def
==
null
)
continue
;
// unused index
Band
[]
ab
=
(
Band
[])
attrBandTable
.
get
(
def
);
Band
[]
ab
=
attrBandTable
.
get
(
def
);
for
(
int
j
=
0
;
j
<
ab
.
length
;
j
++)
{
ab
[
j
].
doneDisbursing
();
}
...
...
@@ -1778,7 +1788,7 @@ class PackageReader extends BandStructure {
// scratch buffer for collecting code::
byte
[]
buf
=
new
byte
[
1
<<
12
];
// record of all switch opcodes (these are variable-length)
ArrayList
allSwitchOps
=
new
ArrayList
();
List
<
Integer
>
allSwitchOps
=
new
ArrayList
<>
();
for
(
int
k
=
0
;
k
<
allCodes
.
length
;
k
++)
{
Code
c
=
allCodes
[
k
];
scanOneMethod:
...
...
@@ -1798,7 +1808,7 @@ class PackageReader extends BandStructure {
case
_tableswitch:
case
_lookupswitch:
bc_case_count
.
expectMoreLength
(
1
);
allSwitchOps
.
add
(
new
Integer
(
bc
)
);
allSwitchOps
.
add
(
bc
);
break
;
case
_iinc:
bc_local
.
expectMoreLength
(
1
);
...
...
@@ -1866,8 +1876,8 @@ class PackageReader extends BandStructure {
// To size instruction bands correctly, we need info on switches:
bc_case_count
.
readFrom
(
in
);
for
(
I
terator
i
=
allSwitchOps
.
iterator
();
i
.
hasNext
();
)
{
int
bc
=
((
Integer
)
i
.
next
())
.
intValue
();
for
(
I
nteger
i
:
allSwitchOps
)
{
int
bc
=
i
.
intValue
();
int
caseCount
=
bc_case_count
.
getInt
();
bc_label
.
expectMoreLength
(
1
+
caseCount
);
// default label + cases
bc_case_value
.
expectMoreLength
(
bc
==
_tableswitch
?
1
:
caseCount
);
...
...
@@ -1892,9 +1902,9 @@ class PackageReader extends BandStructure {
Class
curClass
=
code
.
thisClass
();
HashSet
ldcRefSet
=
(
HashSet
)
ldcRefMap
.
get
(
curClass
);
Set
<
Entry
>
ldcRefSet
=
ldcRefMap
.
get
(
curClass
);
if
(
ldcRefSet
==
null
)
ldcRefMap
.
put
(
curClass
,
ldcRefSet
=
new
HashSet
());
ldcRefMap
.
put
(
curClass
,
ldcRefSet
=
new
HashSet
<>
());
ClassEntry
thisClass
=
curClass
.
thisClass
;
ClassEntry
superClass
=
curClass
.
superClass
;
...
...
src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java
浏览文件 @
66fa671c
...
...
@@ -69,7 +69,8 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
* Get the set of options for the pack and unpack engines.
* @return A sorted association of option key strings to option values.
*/
public
SortedMap
<
String
,
String
>
properties
()
{
@SuppressWarnings
(
"unchecked"
)
public
SortedMap
properties
()
{
return
props
;
}
...
...
@@ -155,8 +156,8 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
// All the worker bees.....
// The packer worker.
@SuppressWarnings
(
"unchecked"
)
private
class
DoPack
{
final
int
verbose
=
props
.
getInteger
(
Utils
.
DEBUG_VERBOSE
);
...
...
@@ -179,11 +180,11 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
unknownAttrCommand
=
uaMode
.
intern
();
}
final
HashMap
attrDefs
;
final
HashMap
attrCommands
;
final
Map
<
Attribute
.
Layout
,
Attribute
>
attrDefs
;
final
Map
<
Attribute
.
Layout
,
String
>
attrCommands
;
{
HashMap
attrDefs
=
new
HashMap
();
HashMap
attrCommands
=
new
HashMap
();
Map
<
Attribute
.
Layout
,
Attribute
>
lattrDefs
=
new
HashMap
<>
();
Map
<
Attribute
.
Layout
,
String
>
lattrCommands
=
new
HashMap
<>
();
String
[]
keys
=
{
Pack200
.
Packer
.
CLASS_ATTRIBUTE_PFX
,
Pack200
.
Packer
.
FIELD_ATTRIBUTE_PFX
,
...
...
@@ -198,8 +199,9 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
};
for
(
int
i
=
0
;
i
<
ctypes
.
length
;
i
++)
{
String
pfx
=
keys
[
i
];
Map
<
String
,
String
>
map
=
props
.
prefixMap
(
pfx
);
for
(
String
key
:
map
.
keySet
())
{
Map
<
Object
,
Object
>
map
=
props
.
prefixMap
(
pfx
);
for
(
Object
k
:
map
.
keySet
())
{
String
key
=
(
String
)
k
;
assert
(
key
.
startsWith
(
pfx
));
String
name
=
key
.
substring
(
pfx
.
length
());
String
layout
=
props
.
getProperty
(
key
);
...
...
@@ -207,24 +209,18 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
if
(
Pack200
.
Packer
.
STRIP
.
equals
(
layout
)
||
Pack200
.
Packer
.
PASS
.
equals
(
layout
)
||
Pack200
.
Packer
.
ERROR
.
equals
(
layout
))
{
attrCommands
.
put
(
lkey
,
layout
.
intern
());
l
attrCommands
.
put
(
lkey
,
layout
.
intern
());
}
else
{
Attribute
.
define
(
attrDefs
,
ctypes
[
i
],
name
,
layout
);
Attribute
.
define
(
l
attrDefs
,
ctypes
[
i
],
name
,
layout
);
if
(
verbose
>
1
)
{
Utils
.
log
.
fine
(
"Added layout for "
+
Constants
.
ATTR_CONTEXT_NAME
[
i
]+
" attribute "
+
name
+
" = "
+
layout
);
}
assert
(
attrDefs
.
containsKey
(
lkey
));
assert
(
l
attrDefs
.
containsKey
(
lkey
));
}
}
}
if
(
attrDefs
.
size
()
>
0
)
this
.
attrDefs
=
attrDefs
;
else
this
.
attrDefs
=
null
;
if
(
attrCommands
.
size
()
>
0
)
this
.
attrCommands
=
attrCommands
;
else
this
.
attrCommands
=
null
;
this
.
attrDefs
=
(
lattrDefs
.
isEmpty
())
?
null
:
lattrDefs
;
this
.
attrCommands
=
(
lattrCommands
.
isEmpty
())
?
null
:
lattrCommands
;
}
final
boolean
keepFileOrder
...
...
@@ -275,8 +271,8 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
{
// Which class files will be passed through?
passFiles
=
props
.
getProperties
(
Pack200
.
Packer
.
PASS_FILE_PFX
);
for
(
ListIterator
i
=
passFiles
.
listIterator
();
i
.
hasNext
();
)
{
String
file
=
(
String
)
i
.
next
();
for
(
ListIterator
<
String
>
i
=
passFiles
.
listIterator
();
i
.
hasNext
();
)
{
String
file
=
i
.
next
();
if
(
file
==
null
)
{
i
.
remove
();
continue
;
}
file
=
Utils
.
getJarEntryName
(
file
);
// normalize '\\' to '/'
if
(
file
.
endsWith
(
"/"
))
...
...
@@ -333,7 +329,7 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
pkg
.
reset
();
}
class
InFile
{
final
class
InFile
{
final
String
name
;
final
JarFile
jf
;
final
JarEntry
je
;
...
...
@@ -596,8 +592,8 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
// Package builder must have created a stub for each class.
assert
(
pkg
.
files
.
containsAll
(
pkg
.
getClassStubs
()));
// Order of stubs in file list must agree with classes.
List
res
=
pkg
.
files
;
assert
((
res
=
new
ArrayList
(
pkg
.
files
))
List
<
Package
.
File
>
res
=
pkg
.
files
;
assert
((
res
=
new
ArrayList
<>
(
pkg
.
files
))
.
retainAll
(
pkg
.
getClassStubs
())
||
true
);
assert
(
res
.
equals
(
pkg
.
getClassStubs
()));
}
...
...
src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java
浏览文件 @
66fa671c
...
...
@@ -31,6 +31,8 @@ import java.io.InputStream;
import
java.io.OutputStream
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Set
;
import
static
com
.
sun
.
java
.
util
.
jar
.
pack
.
Constants
.*;
/**
* Population-based coding.
...
...
@@ -38,7 +40,7 @@ import java.util.HashSet;
* @author John Rose
*/
// This tactic alone reduces the final zipped rt.jar by about a percent.
class
PopulationCoding
implements
Co
nstants
,
Co
dingMethod
{
class
PopulationCoding
implements
CodingMethod
{
Histogram
vHist
;
// histogram of all values
int
[]
fValues
;
// list of favored values
int
fVlen
;
// inclusive max index
...
...
@@ -62,8 +64,8 @@ class PopulationCoding implements Constants, CodingMethod {
}
}
public
void
setFavoredValues
(
int
[]
fValues
)
{
int
fVlen
=
fValues
.
length
-
1
;
setFavoredValues
(
fValues
,
fVlen
);
int
l
fVlen
=
fValues
.
length
-
1
;
setFavoredValues
(
fValues
,
l
fVlen
);
}
public
void
setHistogram
(
Histogram
vHist
)
{
this
.
vHist
=
vHist
;
...
...
@@ -103,7 +105,7 @@ class PopulationCoding implements Constants, CodingMethod {
if
(
tokenCoding
instanceof
Coding
&&
fValues
!=
null
)
{
Coding
tc
=
(
Coding
)
tokenCoding
;
if
(
tc
==
fitTokenCoding
(
fVlen
,
tc
.
L
()))
this
.
L
=
tc
.
L
();
;
this
.
L
=
tc
.
L
();
// Otherwise, it's a non-default coding.
}
}
...
...
@@ -217,13 +219,13 @@ class PopulationCoding implements Constants, CodingMethod {
}
private
long
[]
makeSymtab
()
{
long
[]
symtab
=
new
long
[
fVlen
];
long
[]
l
symtab
=
new
long
[
fVlen
];
for
(
int
token
=
1
;
token
<=
fVlen
;
token
++)
{
symtab
[
token
-
1
]
=
((
long
)
fValues
[
token
]
<<
32
)
|
token
;
l
symtab
[
token
-
1
]
=
((
long
)
fValues
[
token
]
<<
32
)
|
token
;
}
// Index by value:
Arrays
.
sort
(
symtab
);
return
symtab
;
Arrays
.
sort
(
l
symtab
);
return
l
symtab
;
}
private
Coding
getTailCoding
(
CodingMethod
c
)
{
...
...
@@ -302,12 +304,12 @@ class PopulationCoding implements Constants, CodingMethod {
}
int
[]
readFavoredValuesFrom
(
InputStream
in
,
int
maxForDebug
)
throws
IOException
{
int
[]
fValues
=
new
int
[
1000
];
// realloc as needed
int
[]
l
fValues
=
new
int
[
1000
];
// realloc as needed
// The set uniqueValuesForDebug records all favored values.
// As each new value is added, we assert that the value
// was not already in the set.
HashSet
uniqueValuesForDebug
=
null
;
assert
((
uniqueValuesForDebug
=
new
HashSet
())
!=
null
);
Set
<
Integer
>
uniqueValuesForDebug
=
null
;
assert
((
uniqueValuesForDebug
=
new
HashSet
<>
())
!=
null
);
int
fillp
=
1
;
maxForDebug
+=
fillp
;
int
min
=
Integer
.
MIN_VALUE
;
// farthest from the center
...
...
@@ -317,13 +319,14 @@ class PopulationCoding implements Constants, CodingMethod {
while
(
fcm
instanceof
AdaptiveCoding
)
{
AdaptiveCoding
ac
=
(
AdaptiveCoding
)
fcm
;
int
len
=
ac
.
headLength
;
while
(
fillp
+
len
>
fValues
.
length
)
fValues
=
BandStructure
.
realloc
(
fValues
);
while
(
fillp
+
len
>
lfValues
.
length
)
{
lfValues
=
BandStructure
.
realloc
(
lfValues
);
}
int
newFillp
=
fillp
+
len
;
ac
.
headCoding
.
readArrayFrom
(
in
,
fValues
,
fillp
,
newFillp
);
ac
.
headCoding
.
readArrayFrom
(
in
,
l
fValues
,
fillp
,
newFillp
);
while
(
fillp
<
newFillp
)
{
int
val
=
fValues
[
fillp
++];
assert
(
uniqueValuesForDebug
.
add
(
new
Integer
(
val
)
));
int
val
=
l
fValues
[
fillp
++];
assert
(
uniqueValuesForDebug
.
add
(
val
));
assert
(
fillp
<=
maxForDebug
);
last
=
val
;
min
=
moreCentral
(
min
,
val
);
...
...
@@ -344,10 +347,10 @@ class PopulationCoding implements Constants, CodingMethod {
state
=
val
;
if
(
fillp
>
1
&&
(
val
==
last
||
val
==
min
))
//|| val == min2
break
;
if
(
fillp
==
fValues
.
length
)
fValues
=
BandStructure
.
realloc
(
fValues
);
fValues
[
fillp
++]
=
val
;
assert
(
uniqueValuesForDebug
.
add
(
new
Integer
(
val
)
));
if
(
fillp
==
l
fValues
.
length
)
lfValues
=
BandStructure
.
realloc
(
l
fValues
);
l
fValues
[
fillp
++]
=
val
;
assert
(
uniqueValuesForDebug
.
add
(
val
));
assert
(
fillp
<=
maxForDebug
);
last
=
val
;
min
=
moreCentral
(
min
,
val
);
...
...
@@ -358,17 +361,17 @@ class PopulationCoding implements Constants, CodingMethod {
int
val
=
fc
.
readFrom
(
in
);
if
(
fillp
>
1
&&
(
val
==
last
||
val
==
min
))
//|| val == min2
break
;
if
(
fillp
==
fValues
.
length
)
fValues
=
BandStructure
.
realloc
(
fValues
);
fValues
[
fillp
++]
=
val
;
assert
(
uniqueValuesForDebug
.
add
(
new
Integer
(
val
)
));
if
(
fillp
==
l
fValues
.
length
)
lfValues
=
BandStructure
.
realloc
(
l
fValues
);
l
fValues
[
fillp
++]
=
val
;
assert
(
uniqueValuesForDebug
.
add
(
val
));
assert
(
fillp
<=
maxForDebug
);
last
=
val
;
min
=
moreCentral
(
min
,
val
);
//min2 = moreCentral2(min2, val, min);
}
}
return
BandStructure
.
realloc
(
fValues
,
fillp
);
return
BandStructure
.
realloc
(
l
fValues
,
fillp
);
}
private
static
int
moreCentral
(
int
x
,
int
y
)
{
...
...
@@ -478,7 +481,7 @@ class PopulationCoding implements Constants, CodingMethod {
boolean
verbose
=
(
p200
!=
null
&&
p200
.
getBoolean
(
Utils
.
COM_PREFIX
+
"verbose.pop"
));
StringBu
ffer
res
=
new
StringBuff
er
(
100
);
StringBu
ilder
res
=
new
StringBuild
er
(
100
);
res
.
append
(
"pop("
).
append
(
"fVlen="
).
append
(
fVlen
);
if
(
verbose
&&
fValues
!=
null
)
{
res
.
append
(
" fV=["
);
...
...
src/share/classes/com/sun/java/util/jar/pack/PropMap.java
浏览文件 @
66fa671c
/*
* Copyright (c) 2003,
2010
Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003,
2010,
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
...
...
@@ -34,8 +34,8 @@ import java.io.PrintStream;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
...
...
@@ -46,36 +46,36 @@ import java.util.jar.Pack200;
/**
* Control block for publishing Pack200 options to the other classes.
*/
class
PropMap
extends
TreeMap
{
ArrayList
_listeners
=
new
ArrayList
(
1
);
final
class
PropMap
implements
SortedMap
<
Object
,
Object
>
{
private
final
TreeMap
<
Object
,
Object
>
theMap
=
new
TreeMap
<>();;
private
final
List
<
PropertyChangeListener
>
listenerList
=
new
ArrayList
<>(
1
);
void
addListener
(
PropertyChangeListener
listener
)
{
_listeners
.
add
(
listener
);
listenerList
.
add
(
listener
);
}
void
removeListener
(
PropertyChangeListener
listener
)
{
_listeners
.
remove
(
listener
);
listenerList
.
remove
(
listener
);
}
void
addListeners
(
ArrayList
listeners
)
{
_listeners
.
addAll
(
listeners
);
void
addListeners
(
ArrayList
<
PropertyChangeListener
>
listeners
)
{
listenerList
.
addAll
(
listeners
);
}
void
removeListeners
(
ArrayList
listeners
)
{
_listeners
.
removeAll
(
listeners
);
void
removeListeners
(
ArrayList
<
PropertyChangeListener
>
listeners
)
{
listenerList
.
removeAll
(
listeners
);
}
// Override:
public
Object
put
(
Object
key
,
Object
value
)
{
Object
oldValue
=
super
.
put
(
key
,
value
);
if
(
value
!=
oldValue
&&
_listeners
.
size
()
>
0
)
{
Object
oldValue
=
theMap
.
put
(
key
,
value
);
if
(
value
!=
oldValue
&&
!
listenerList
.
isEmpty
()
)
{
// Post the property change event.
PropertyChangeEvent
event
=
new
PropertyChangeEvent
(
this
,
(
String
)
key
,
oldValue
,
value
);
for
(
Iterator
i
=
_listeners
.
iterator
();
i
.
hasNext
();
)
{
PropertyChangeListener
listener
=
(
PropertyChangeListener
)
i
.
next
();
for
(
PropertyChangeListener
listener
:
listenerList
)
{
listener
.
propertyChange
(
event
);
}
}
...
...
@@ -85,7 +85,7 @@ class PropMap extends TreeMap {
// All this other stuff is private to the current package.
// Outide clients of Pack200 do not need to use it; they can
// get by with generic SortedMap functionality.
private
static
Map
defaultProps
;
private
static
Map
<
Object
,
Object
>
defaultProps
;
static
{
Properties
props
=
new
Properties
();
...
...
@@ -122,13 +122,12 @@ class PropMap extends TreeMap {
// Define certain attribute layouts by default.
// Do this after the previous props are put in place,
// to allow override if necessary.
InputStream
propStr
=
null
;
try
{
String
propFile
=
"intrinsic.properties"
;
InputStream
propStr
=
PackerImpl
.
class
.
getResourceAsStream
(
propFile
);
propStr
=
PackerImpl
.
class
.
getResourceAsStream
(
propFile
);
props
.
load
(
new
BufferedInputStream
(
propStr
));
propStr
.
close
();
for
(
Iterator
i
=
props
.
entrySet
().
iterator
();
i
.
hasNext
();
)
{
Map
.
Entry
e
=
(
Map
.
Entry
)
i
.
next
();
for
(
Map
.
Entry
<
Object
,
Object
>
e
:
props
.
entrySet
())
{
String
key
=
(
String
)
e
.
getKey
();
String
val
=
(
String
)
e
.
getValue
();
if
(
key
.
startsWith
(
"attribute."
))
{
...
...
@@ -137,19 +136,25 @@ class PropMap extends TreeMap {
}
}
catch
(
IOException
ee
)
{
throw
new
RuntimeException
(
ee
);
}
finally
{
try
{
if
(
propStr
!=
null
)
{
propStr
.
close
();
}
}
catch
(
IOException
ignore
)
{}
}
defaultProps
=
(
new
HashMap
(
props
));
// shrink to fit
defaultProps
=
(
new
HashMap
<>
(
props
));
// shrink to fit
}
PropMap
()
{
putAll
(
defaultProps
);
theMap
.
putAll
(
defaultProps
);
}
// Return a view of this map which includes only properties
// that begin with the given prefix. This is easy because
// the map is sorted, and has a subMap accessor.
SortedMap
prefixMap
(
String
prefix
)
{
SortedMap
<
Object
,
Object
>
prefixMap
(
String
prefix
)
{
int
len
=
prefix
.
length
();
if
(
len
==
0
)
return
this
;
...
...
@@ -174,8 +179,8 @@ class PropMap extends TreeMap {
// Get sequence of props for "prefix", and "prefix.*".
List
getProperties
(
String
prefix
)
{
Collection
values
=
prefixMap
(
prefix
).
values
();
ArrayList
res
=
new
ArrayList
(
values
.
size
());
Collection
<
Object
>
values
=
prefixMap
(
prefix
).
values
();
List
<
Object
>
res
=
new
ArrayList
<>
(
values
.
size
());
res
.
addAll
(
values
);
while
(
res
.
remove
(
null
));
return
res
;
...
...
@@ -240,11 +245,97 @@ class PropMap extends TreeMap {
void
list
(
PrintWriter
out
)
{
out
.
println
(
"#"
+
Utils
.
PACK_ZIP_ARCHIVE_MARKER_COMMENT
+
"["
);
Set
defaults
=
defaultProps
.
entrySet
();
for
(
Iterator
i
=
entrySet
().
iterator
();
i
.
hasNext
();
)
{
Map
.
Entry
e
=
(
Map
.
Entry
)
i
.
next
();
for
(
Map
.
Entry
e
:
theMap
.
entrySet
())
{
if
(
defaults
.
contains
(
e
))
continue
;
out
.
println
(
" "
+
e
.
getKey
()
+
" = "
+
e
.
getValue
());
}
out
.
println
(
"#]"
);
}
@Override
public
int
size
()
{
return
theMap
.
size
();
}
@Override
public
boolean
isEmpty
()
{
return
theMap
.
isEmpty
();
}
@Override
public
boolean
containsKey
(
Object
key
)
{
return
theMap
.
containsKey
(
key
);
}
@Override
public
boolean
containsValue
(
Object
value
)
{
return
theMap
.
containsValue
(
value
);
}
@Override
public
Object
get
(
Object
key
)
{
return
theMap
.
get
(
key
);
}
@Override
public
Object
remove
(
Object
key
)
{
return
theMap
.
remove
(
key
);
}
@Override
@SuppressWarnings
(
"unchecked"
)
public
void
putAll
(
Map
m
)
{
theMap
.
putAll
(
m
);
}
@Override
public
void
clear
()
{
theMap
.
clear
();
}
@Override
public
Set
<
Object
>
keySet
()
{
return
theMap
.
keySet
();
}
@Override
public
Collection
<
Object
>
values
()
{
return
theMap
.
values
();
}
@Override
public
Set
<
Map
.
Entry
<
Object
,
Object
>>
entrySet
()
{
return
theMap
.
entrySet
();
}
@Override
@SuppressWarnings
(
"unchecked"
)
public
Comparator
<
Object
>
comparator
()
{
return
(
Comparator
<
Object
>)
theMap
.
comparator
();
}
@Override
public
SortedMap
<
Object
,
Object
>
subMap
(
Object
fromKey
,
Object
toKey
)
{
return
theMap
.
subMap
(
fromKey
,
toKey
);
}
@Override
public
SortedMap
<
Object
,
Object
>
headMap
(
Object
toKey
)
{
return
theMap
.
headMap
(
toKey
);
}
@Override
public
SortedMap
<
Object
,
Object
>
tailMap
(
Object
fromKey
)
{
return
theMap
.
tailMap
(
fromKey
);
}
@Override
public
Object
firstKey
()
{
return
theMap
.
firstKey
();
}
@Override
public
Object
lastKey
()
{
return
theMap
.
lastKey
();
}
}
src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
浏览文件 @
66fa671c
...
...
@@ -34,7 +34,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.HashSet
;
import
java.util.
Iterator
;
import
java.util.
Set
;
import
java.util.SortedMap
;
import
java.util.TimeZone
;
import
java.util.jar.JarEntry
;
...
...
@@ -81,7 +81,8 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
* Get the set of options for the pack and unpack engines.
* @return A sorted association of option key strings to option values.
*/
public
SortedMap
<
String
,
String
>
properties
()
{
@SuppressWarnings
(
"unchecked"
)
public
SortedMap
properties
()
{
return
props
;
}
...
...
@@ -225,9 +226,8 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
props
.
setProperty
(
java
.
util
.
jar
.
Pack200
.
Unpacker
.
PROGRESS
,
"50"
);
pkg
.
ensureAllClassFiles
();
// Now write out the files.
HashSet
<
Package
.
Class
>
classesToWrite
=
new
HashSet
<>(
pkg
.
getClasses
());
for
(
Iterator
i
=
pkg
.
getFiles
().
iterator
();
i
.
hasNext
();
)
{
Package
.
File
file
=
(
Package
.
File
)
i
.
next
();
Set
<
Package
.
Class
>
classesToWrite
=
new
HashSet
<>(
pkg
.
getClasses
());
for
(
Package
.
File
file
:
pkg
.
getFiles
())
{
String
name
=
file
.
nameString
;
JarEntry
je
=
new
JarEntry
(
Utils
.
getJarEntryName
(
name
));
boolean
deflate
;
...
...
src/share/classes/com/sun/java/util/jar/pack/Utils.java
浏览文件 @
66fa671c
...
...
@@ -297,7 +297,7 @@ class Utils {
(
int
)(
(
1.0
-
((
double
)
ze
.
getCompressedSize
()/(
double
)
ze
.
getSize
()))*
100
)
:
0
;
// Follow unzip -lv output
return
(
long
)
ze
.
getSize
()
+
"\t"
+
ze
.
getMethod
()
return
ze
.
getSize
()
+
"\t"
+
ze
.
getMethod
()
+
"\t"
+
ze
.
getCompressedSize
()
+
"\t"
+
store
+
"%\t"
+
new
Date
(
ze
.
getTime
())
+
"\t"
...
...
src/share/classes/com/sun/media/sound/DirectAudioDevice.java
浏览文件 @
66fa671c
...
...
@@ -1393,8 +1393,11 @@ class DirectAudioDevice extends AbstractMixer {
public
void
run
()
{
if
(
Printer
.
trace
)
Printer
.
trace
(
">>> DirectClip: run() threadID="
+
Thread
.
currentThread
().
getId
());
while
(
thread
!=
null
)
{
if
(!
doIO
)
{
synchronized
(
lock
)
{
// doIO is volatile, but we could check it, then get
// pre-empted while another thread changes doIO and notifies,
// before we wait (so we sleep in wait forever).
synchronized
(
lock
)
{
if
(!
doIO
)
{
try
{
lock
.
wait
();
}
catch
(
InterruptedException
ie
)
{}
...
...
src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java
浏览文件 @
66fa671c
...
...
@@ -61,26 +61,43 @@ public final class RhinoScriptEngine extends AbstractScriptEngine
private
ScriptEngineFactory
factory
;
private
InterfaceImplementor
implementor
;
private
static
final
int
languageVersion
=
getLanguageVersion
();
private
static
final
int
optimizationLevel
=
getOptimizationLevel
();
static
{
ContextFactory
.
initGlobal
(
new
ContextFactory
()
{
protected
Context
makeContext
()
{
Context
cx
=
super
.
makeContext
();
cx
.
setLanguageVersion
(
languageVersion
);
cx
.
setOptimizationLevel
(
optimizationLevel
);
cx
.
setClassShutter
(
RhinoClassShutter
.
getInstance
());
cx
.
setWrapFactory
(
RhinoWrapFactory
.
getInstance
());
return
cx
;
}
public
boolean
hasFeature
(
Context
cx
,
int
feature
)
{
// we do not support E4X (ECMAScript for XML)!
if
(
feature
==
Context
.
FEATURE_E4X
)
{
return
false
;
}
else
{
return
super
.
hasFeature
(
cx
,
feature
);
}
}
});
}
private
static
final
String
RHINO_JS_VERSION
=
"rhino.js.version"
;
private
static
int
getLanguageVersion
()
{
int
version
;
String
tmp
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
RHINO_JS_VERSION
));
if
(
tmp
!=
null
)
{
version
=
Integer
.
parseInt
((
String
)
tmp
);
}
else
{
version
=
Context
.
VERSION_1_8
;
}
return
version
;
}
private
static
final
String
RHINO_OPT_LEVEL
=
"rhino.opt.level"
;
private
static
int
getOptimizationLevel
()
{
int
optLevel
=
-
1
;
// disable optimizer under security manager, for now.
if
(
System
.
getSecurityManager
()
==
null
)
{
optLevel
=
Integer
.
getInteger
(
RHINO_OPT_LEVEL
,
-
1
);
}
return
optLevel
;
}
/**
* Creates a new instance of RhinoScriptEngine
...
...
@@ -333,6 +350,7 @@ public final class RhinoScriptEngine extends AbstractScriptEngine
return
result
instanceof
Undefined
?
null
:
result
;
}
/*
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.out.println("No file specified");
...
...
@@ -347,4 +365,5 @@ public final class RhinoScriptEngine extends AbstractScriptEngine
engine.eval(r);
System.out.println(engine.get("x"));
}
*/
}
src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java
浏览文件 @
66fa671c
...
...
@@ -58,11 +58,11 @@ public class RhinoScriptEngineFactory extends ScriptEngineFactoryBase {
}
else
if
(
key
.
equals
(
ScriptEngine
.
ENGINE
))
{
return
"Mozilla Rhino"
;
}
else
if
(
key
.
equals
(
ScriptEngine
.
ENGINE_VERSION
))
{
return
"1.
6 release 2
"
;
return
"1.
7 release 3 PRERELEASE
"
;
}
else
if
(
key
.
equals
(
ScriptEngine
.
LANGUAGE
))
{
return
"ECMAScript"
;
}
else
if
(
key
.
equals
(
ScriptEngine
.
LANGUAGE_VERSION
))
{
return
"1.
6
"
;
return
"1.
8
"
;
}
else
if
(
key
.
equals
(
"THREADING"
))
{
return
"MULTITHREADED"
;
}
else
{
...
...
@@ -128,10 +128,12 @@ public class RhinoScriptEngineFactory extends ScriptEngineFactoryBase {
return
ret
;
}
/*
public static void main(String[] args) {
RhinoScriptEngineFactory fact = new RhinoScriptEngineFactory();
System.out.println(fact.getParameter(ScriptEngine.ENGINE_VERSION));
}
*/
private
static
List
<
String
>
names
;
private
static
List
<
String
>
mimeTypes
;
...
...
src/share/classes/com/sun/script/javascript/RhinoTopLevel.java
浏览文件 @
66fa671c
...
...
@@ -37,15 +37,6 @@ import javax.script.*;
* @since 1.6
*/
public
final
class
RhinoTopLevel
extends
ImporterTopLevel
{
// variables defined always to help Java access from JavaScript
private
static
final
String
builtinVariables
=
"var com = Packages.com; \n"
+
"var edu = Packages.edu; \n"
+
"var javax = Packages.javax; \n"
+
"var net = Packages.net; \n"
+
"var org = Packages.org; \n"
;
RhinoTopLevel
(
Context
cx
,
RhinoScriptEngine
engine
)
{
super
(
cx
);
this
.
engine
=
engine
;
...
...
@@ -67,9 +58,6 @@ public final class RhinoTopLevel extends ImporterTopLevel {
String
names
[]
=
{
"bindings"
,
"scope"
,
"sync"
};
defineFunctionProperties
(
names
,
RhinoTopLevel
.
class
,
ScriptableObject
.
DONTENUM
);
// define built-in variables
cx
.
evaluateString
(
this
,
builtinVariables
,
"<builtin>"
,
1
,
null
);
}
/**
...
...
src/share/classes/com/sun/tools/script/shell/init.js
浏览文件 @
66fa671c
...
...
@@ -311,9 +311,9 @@ function load(str) {
try
{
engine
.
eval
(
reader
);
}
finally
{
engine
.
put
(
engine
.
FILENAME
,
oldFilename
);
engine
.
put
(
engine
.
FILENAME
,
oldFilename
);
streamClose
(
stream
);
}
streamClose
(
stream
);
}
// file system utilities
...
...
src/share/classes/java/io/DeleteOnExitHook.java
浏览文件 @
66fa671c
...
...
@@ -34,7 +34,7 @@ import java.io.File;
*/
class
DeleteOnExitHook
{
private
static
LinkedHashSet
<
String
>
files
=
new
LinkedHashSet
<
String
>();
private
static
LinkedHashSet
<
String
>
files
=
new
LinkedHashSet
<>();
static
{
// DeleteOnExitHook must be the last shutdown hook to be invoked.
// Application shutdown hooks may add the first file to the
...
...
@@ -71,7 +71,7 @@ class DeleteOnExitHook {
files
=
null
;
}
ArrayList
<
String
>
toBeDeleted
=
new
ArrayList
<
String
>(
theFiles
);
ArrayList
<
String
>
toBeDeleted
=
new
ArrayList
<>(
theFiles
);
// reverse the list to maintain previous jdk deletion order.
// Last in first deleted.
...
...
src/share/classes/java/io/File.java
浏览文件 @
66fa671c
...
...
@@ -1067,7 +1067,7 @@ public class File
if
((
names
==
null
)
||
(
filter
==
null
))
{
return
names
;
}
List
<
String
>
v
=
new
ArrayList
<
String
>();
List
<
String
>
v
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
if
(
filter
.
accept
(
this
,
names
[
i
]))
{
v
.
add
(
names
[
i
]);
...
...
@@ -1158,7 +1158,7 @@ public class File
public
File
[]
listFiles
(
FilenameFilter
filter
)
{
String
ss
[]
=
list
();
if
(
ss
==
null
)
return
null
;
ArrayList
<
File
>
files
=
new
ArrayList
<
File
>();
ArrayList
<
File
>
files
=
new
ArrayList
<>();
for
(
String
s
:
ss
)
if
((
filter
==
null
)
||
filter
.
accept
(
this
,
s
))
files
.
add
(
new
File
(
s
,
this
));
...
...
@@ -1195,7 +1195,7 @@ public class File
public
File
[]
listFiles
(
FileFilter
filter
)
{
String
ss
[]
=
list
();
if
(
ss
==
null
)
return
null
;
ArrayList
<
File
>
files
=
new
ArrayList
<
File
>();
ArrayList
<
File
>
files
=
new
ArrayList
<>();
for
(
String
s
:
ss
)
{
File
f
=
new
File
(
s
,
this
);
if
((
filter
==
null
)
||
filter
.
accept
(
f
))
...
...
src/share/classes/java/io/FileInputStream.java
浏览文件 @
66fa671c
...
...
@@ -56,7 +56,7 @@ class FileInputStream extends InputStream
private
volatile
boolean
closed
=
false
;
private
static
final
ThreadLocal
<
Boolean
>
runningFinalize
=
new
ThreadLocal
<
Boolean
>();
new
ThreadLocal
<>();
private
static
boolean
isRunningFinalize
()
{
Boolean
val
;
...
...
src/share/classes/java/io/FileOutputStream.java
浏览文件 @
66fa671c
...
...
@@ -69,7 +69,7 @@ class FileOutputStream extends OutputStream
private
final
Object
closeLock
=
new
Object
();
private
volatile
boolean
closed
=
false
;
private
static
final
ThreadLocal
<
Boolean
>
runningFinalize
=
new
ThreadLocal
<
Boolean
>();
new
ThreadLocal
<>();
private
static
boolean
isRunningFinalize
()
{
Boolean
val
;
...
...
src/share/classes/java/io/FilePermission.java
浏览文件 @
66fa671c
...
...
@@ -725,7 +725,7 @@ implements Serializable {
*/
public
FilePermissionCollection
()
{
perms
=
new
ArrayList
<
Permission
>();
perms
=
new
ArrayList
<>();
}
/**
...
...
@@ -830,7 +830,7 @@ implements Serializable {
// Don't call out.defaultWriteObject()
// Write out Vector
Vector
<
Permission
>
permissions
=
new
Vector
<
Permission
>(
perms
.
size
());
Vector
<
Permission
>
permissions
=
new
Vector
<>(
perms
.
size
());
synchronized
(
this
)
{
permissions
.
addAll
(
perms
);
}
...
...
@@ -853,7 +853,7 @@ implements Serializable {
// Get the one we want
Vector
<
Permission
>
permissions
=
(
Vector
<
Permission
>)
gfields
.
get
(
"permissions"
,
null
);
perms
=
new
ArrayList
<
Permission
>(
permissions
.
size
());
perms
=
new
ArrayList
<>(
permissions
.
size
());
perms
.
addAll
(
permissions
);
}
}
src/share/classes/java/io/ObjectInputStream.java
浏览文件 @
66fa671c
...
...
@@ -213,7 +213,7 @@ public class ObjectInputStream
/** table mapping primitive type names to corresponding class objects */
private
static
final
HashMap
<
String
,
Class
<?>>
primClasses
=
new
HashMap
<
String
,
Class
<?>
>(
8
,
1.0
F
);
=
new
HashMap
<>(
8
,
1.0
F
);
static
{
primClasses
.
put
(
"boolean"
,
boolean
.
class
);
primClasses
.
put
(
"byte"
,
byte
.
class
);
...
...
@@ -229,11 +229,11 @@ public class ObjectInputStream
private
static
class
Caches
{
/** cache of subclass security audit results */
static
final
ConcurrentMap
<
WeakClassKey
,
Boolean
>
subclassAudits
=
new
ConcurrentHashMap
<
WeakClassKey
,
Boolean
>();
new
ConcurrentHashMap
<>();
/** queue for WeakReferences to audited subclasses */
static
final
ReferenceQueue
<
Class
<?>>
subclassAuditsQueue
=
new
ReferenceQueue
<
Class
<?>
>();
new
ReferenceQueue
<>();
}
/** filter stream for handling block data conversion */
...
...
src/share/classes/java/io/ObjectOutputStream.java
浏览文件 @
66fa671c
...
...
@@ -165,11 +165,11 @@ public class ObjectOutputStream
private
static
class
Caches
{
/** cache of subclass security audit results */
static
final
ConcurrentMap
<
WeakClassKey
,
Boolean
>
subclassAudits
=
new
ConcurrentHashMap
<
WeakClassKey
,
Boolean
>();
new
ConcurrentHashMap
<>();
/** queue for WeakReferences to audited subclasses */
static
final
ReferenceQueue
<
Class
<?>>
subclassAuditsQueue
=
new
ReferenceQueue
<
Class
<?>
>();
new
ReferenceQueue
<>();
}
/** filter stream for handling block data conversion */
...
...
@@ -2413,7 +2413,7 @@ public class ObjectOutputStream
private
final
List
<
String
>
stack
;
DebugTraceInfoStack
()
{
stack
=
new
ArrayList
<
String
>();
stack
=
new
ArrayList
<>();
}
/**
...
...
src/share/classes/java/io/ObjectStreamClass.java
浏览文件 @
66fa671c
...
...
@@ -84,18 +84,18 @@ public class ObjectStreamClass implements Serializable {
private
static
class
Caches
{
/** cache mapping local classes -> descriptors */
static
final
ConcurrentMap
<
WeakClassKey
,
Reference
<?>>
localDescs
=
new
ConcurrentHashMap
<
WeakClassKey
,
Reference
<?>
>();
new
ConcurrentHashMap
<>();
/** cache mapping field group/local desc pairs -> field reflectors */
static
final
ConcurrentMap
<
FieldReflectorKey
,
Reference
<?>>
reflectors
=
new
ConcurrentHashMap
<
FieldReflectorKey
,
Reference
<?>
>();
new
ConcurrentHashMap
<>();
/** queue for WeakReferences to local classes */
private
static
final
ReferenceQueue
<
Class
<?>>
localDescsQueue
=
new
ReferenceQueue
<
Class
<?>
>();
new
ReferenceQueue
<>();
/** queue for WeakReferences to field reflectors keys */
private
static
final
ReferenceQueue
<
Class
<?>>
reflectorsQueue
=
new
ReferenceQueue
<
Class
<?>
>();
new
ReferenceQueue
<>();
}
/** class associated with this descriptor (if any) */
...
...
@@ -290,7 +290,7 @@ public class ObjectStreamClass implements Serializable {
EntryFuture
future
=
null
;
if
(
entry
==
null
)
{
EntryFuture
newEntry
=
new
EntryFuture
();
Reference
<?>
newRef
=
new
SoftReference
<
EntryFuture
>(
newEntry
);
Reference
<?>
newRef
=
new
SoftReference
<>(
newEntry
);
do
{
if
(
ref
!=
null
)
{
Caches
.
localDescs
.
remove
(
key
,
ref
);
...
...
@@ -329,7 +329,7 @@ public class ObjectStreamClass implements Serializable {
entry
=
th
;
}
if
(
future
.
set
(
entry
))
{
Caches
.
localDescs
.
put
(
key
,
new
SoftReference
<
Object
>(
entry
));
Caches
.
localDescs
.
put
(
key
,
new
SoftReference
<>(
entry
));
}
else
{
// nested lookup call already set future
entry
=
future
.
get
();
...
...
@@ -1130,7 +1130,7 @@ public class ObjectStreamClass implements Serializable {
private
ClassDataSlot
[]
getClassDataLayout0
()
throws
InvalidClassException
{
ArrayList
<
ClassDataSlot
>
slots
=
new
ArrayList
<
ClassDataSlot
>();
ArrayList
<
ClassDataSlot
>
slots
=
new
ArrayList
<>();
Class
<?>
start
=
cl
,
end
=
cl
;
// locate closest non-serializable superclass
...
...
@@ -1566,7 +1566,7 @@ public class ObjectStreamClass implements Serializable {
ObjectStreamField
[]
boundFields
=
new
ObjectStreamField
[
serialPersistentFields
.
length
];
Set
<
String
>
fieldNames
=
new
HashSet
<
String
>(
serialPersistentFields
.
length
);
Set
<
String
>
fieldNames
=
new
HashSet
<>(
serialPersistentFields
.
length
);
for
(
int
i
=
0
;
i
<
serialPersistentFields
.
length
;
i
++)
{
ObjectStreamField
spf
=
serialPersistentFields
[
i
];
...
...
@@ -1604,7 +1604,7 @@ public class ObjectStreamClass implements Serializable {
*/
private
static
ObjectStreamField
[]
getDefaultSerialFields
(
Class
<?>
cl
)
{
Field
[]
clFields
=
cl
.
getDeclaredFields
();
ArrayList
<
ObjectStreamField
>
list
=
new
ArrayList
<
ObjectStreamField
>();
ArrayList
<
ObjectStreamField
>
list
=
new
ArrayList
<>();
int
mask
=
Modifier
.
STATIC
|
Modifier
.
TRANSIENT
;
for
(
int
i
=
0
;
i
<
clFields
.
length
;
i
++)
{
...
...
@@ -1855,8 +1855,8 @@ public class ObjectStreamClass implements Serializable {
writeKeys
=
new
long
[
nfields
];
offsets
=
new
int
[
nfields
];
typeCodes
=
new
char
[
nfields
];
ArrayList
<
Class
<?>>
typeList
=
new
ArrayList
<
Class
<?>
>();
Set
<
Long
>
usedKeys
=
new
HashSet
<
Long
>();
ArrayList
<
Class
<?>>
typeList
=
new
ArrayList
<>();
Set
<
Long
>
usedKeys
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
nfields
;
i
++)
{
...
...
@@ -2092,7 +2092,7 @@ public class ObjectStreamClass implements Serializable {
EntryFuture
future
=
null
;
if
(
entry
==
null
)
{
EntryFuture
newEntry
=
new
EntryFuture
();
Reference
<?>
newRef
=
new
SoftReference
<
EntryFuture
>(
newEntry
);
Reference
<?>
newRef
=
new
SoftReference
<>(
newEntry
);
do
{
if
(
ref
!=
null
)
{
Caches
.
reflectors
.
remove
(
key
,
ref
);
...
...
@@ -2118,7 +2118,7 @@ public class ObjectStreamClass implements Serializable {
entry
=
th
;
}
future
.
set
(
entry
);
Caches
.
reflectors
.
put
(
key
,
new
SoftReference
<
Object
>(
entry
));
Caches
.
reflectors
.
put
(
key
,
new
SoftReference
<>(
entry
));
}
if
(
entry
instanceof
FieldReflector
)
{
...
...
src/share/classes/java/lang/ApplicationShutdownHooks.java
浏览文件 @
66fa671c
...
...
@@ -47,7 +47,7 @@ class ApplicationShutdownHooks {
}
}
);
hooks
=
new
IdentityHashMap
<
Thread
,
Thread
>();
hooks
=
new
IdentityHashMap
<>();
}
catch
(
IllegalStateException
e
)
{
// application shutdown hooks cannot be added if
// shutdown is in progress.
...
...
src/share/classes/java/lang/Character.java
浏览文件 @
66fa671c
...
...
@@ -648,8 +648,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
*/
public
static
final
class
UnicodeBlock
extends
Subset
{
private
static
Map
<
String
,
UnicodeBlock
>
map
=
new
HashMap
<
String
,
UnicodeBlock
>(
256
);
private
static
Map
<
String
,
UnicodeBlock
>
map
=
new
HashMap
<>(
256
);
/**
* Creates a UnicodeBlock with the given identifier name.
...
...
@@ -4178,7 +4177,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
private
static
HashMap
<
String
,
Character
.
UnicodeScript
>
aliases
;
static
{
aliases
=
new
HashMap
<
String
,
UnicodeScript
>(
128
);
aliases
=
new
HashMap
<>(
128
);
aliases
.
put
(
"ARAB"
,
ARABIC
);
aliases
.
put
(
"ARMI"
,
IMPERIAL_ARAMAIC
);
aliases
.
put
(
"ARMN"
,
ARMENIAN
);
...
...
src/share/classes/java/lang/CharacterName.java
浏览文件 @
66fa671c
...
...
@@ -81,7 +81,7 @@ class CharacterName {
}
while
(
cpOff
<
cpEnd
);
strPool
=
new
byte
[
total
-
cpEnd
];
dis
.
readFully
(
strPool
);
refStrPool
=
new
SoftReference
<
byte
[]
>(
strPool
);
refStrPool
=
new
SoftReference
<>(
strPool
);
}
catch
(
Exception
x
)
{
throw
new
InternalError
(
x
.
getMessage
());
}
finally
{
...
...
src/share/classes/java/lang/Class.java
浏览文件 @
66fa671c
...
...
@@ -1306,7 +1306,7 @@ public final
return
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
<
Class
<?>[]>()
{
public
Class
[]
run
()
{
List
<
Class
<?>>
list
=
new
ArrayList
<
Class
<?>
>();
List
<
Class
<?>>
list
=
new
ArrayList
<>();
Class
<?>
currentClass
=
Class
.
this
;
while
(
currentClass
!=
null
)
{
Class
<?>[]
members
=
currentClass
.
getDeclaredClasses
();
...
...
@@ -2306,9 +2306,9 @@ public final
res
=
Reflection
.
filterFields
(
this
,
getDeclaredFields0
(
publicOnly
));
if
(
useCaches
)
{
if
(
publicOnly
)
{
declaredPublicFields
=
new
SoftReference
<
Field
[]
>(
res
);
declaredPublicFields
=
new
SoftReference
<>(
res
);
}
else
{
declaredFields
=
new
SoftReference
<
Field
[]
>(
res
);
declaredFields
=
new
SoftReference
<>(
res
);
}
}
return
res
;
...
...
@@ -2330,9 +2330,9 @@ public final
// No cached value available; compute value recursively.
// Traverse in correct order for getField().
List
<
Field
>
fields
=
new
ArrayList
<
Field
>();
List
<
Field
>
fields
=
new
ArrayList
<>();
if
(
traversedInterfaces
==
null
)
{
traversedInterfaces
=
new
HashSet
<
Class
<?>
>();
traversedInterfaces
=
new
HashSet
<>();
}
// Local fields
...
...
@@ -2358,7 +2358,7 @@ public final
res
=
new
Field
[
fields
.
size
()];
fields
.
toArray
(
res
);
if
(
useCaches
)
{
publicFields
=
new
SoftReference
<
Field
[]
>(
res
);
publicFields
=
new
SoftReference
<>(
res
);
}
return
res
;
}
...
...
@@ -2403,9 +2403,9 @@ public final
}
if
(
useCaches
)
{
if
(
publicOnly
)
{
publicConstructors
=
new
SoftReference
<
Constructor
<
T
>[]
>(
res
);
publicConstructors
=
new
SoftReference
<>(
res
);
}
else
{
declaredConstructors
=
new
SoftReference
<
Constructor
<
T
>[]
>(
res
);
declaredConstructors
=
new
SoftReference
<>(
res
);
}
}
return
res
;
...
...
@@ -2440,9 +2440,9 @@ public final
res
=
Reflection
.
filterMethods
(
this
,
getDeclaredMethods0
(
publicOnly
));
if
(
useCaches
)
{
if
(
publicOnly
)
{
declaredPublicMethods
=
new
SoftReference
<
Method
[]
>(
res
);
declaredPublicMethods
=
new
SoftReference
<>(
res
);
}
else
{
declaredMethods
=
new
SoftReference
<
Method
[]
>(
res
);
declaredMethods
=
new
SoftReference
<>(
res
);
}
}
return
res
;
...
...
@@ -2598,7 +2598,7 @@ public final
methods
.
compactAndTrim
();
res
=
methods
.
getArray
();
if
(
useCaches
)
{
publicMethods
=
new
SoftReference
<
Method
[]
>(
res
);
publicMethods
=
new
SoftReference
<>(
res
);
}
return
res
;
}
...
...
@@ -2977,7 +2977,7 @@ public final
if
(
universe
==
null
)
throw
new
IllegalArgumentException
(
getName
()
+
" is not an enum type"
);
Map
<
String
,
T
>
m
=
new
HashMap
<
String
,
T
>(
2
*
universe
.
length
);
Map
<
String
,
T
>
m
=
new
HashMap
<>(
2
*
universe
.
length
);
for
(
T
constant
:
universe
)
m
.
put
(((
Enum
<?>)
constant
).
name
(),
constant
);
enumConstantDirectory
=
m
;
...
...
@@ -3090,7 +3090,7 @@ public final
if
(
superClass
==
null
)
{
annotations
=
declaredAnnotations
;
}
else
{
annotations
=
new
HashMap
<
Class
<?
extends
Annotation
>,
Annotation
>();
annotations
=
new
HashMap
<>();
superClass
.
initAnnotationsIfNecessary
();
for
(
Map
.
Entry
<
Class
<?
extends
Annotation
>,
Annotation
>
e
:
superClass
.
annotations
.
entrySet
())
{
Class
<?
extends
Annotation
>
annotationClass
=
e
.
getKey
();
...
...
src/share/classes/java/lang/ClassLoader.java
浏览文件 @
66fa671c
...
...
@@ -247,7 +247,7 @@ public abstract class ClassLoader {
// The classes loaded by this class loader. The only purpose of this table
// is to keep the classes from being GC'ed until the loader is GC'ed.
private
final
Vector
<
Class
<?>>
classes
=
new
Vector
<
Class
<?>
>();
private
final
Vector
<
Class
<?>>
classes
=
new
Vector
<>();
// The "default" domain. Set as the default ProtectionDomain on newly
// created classes.
...
...
@@ -266,8 +266,7 @@ public abstract class ClassLoader {
// The packages defined in this class loader. Each package name is mapped
// to its corresponding Package object.
// @GuardedBy("itself")
private
final
HashMap
<
String
,
Package
>
packages
=
new
HashMap
<
String
,
Package
>();
private
final
HashMap
<
String
,
Package
>
packages
=
new
HashMap
<>();
private
static
Void
checkCreateClassLoader
()
{
SecurityManager
security
=
System
.
getSecurityManager
();
...
...
@@ -280,16 +279,16 @@ public abstract class ClassLoader {
private
ClassLoader
(
Void
unused
,
ClassLoader
parent
)
{
this
.
parent
=
parent
;
if
(
ParallelLoaders
.
isRegistered
(
this
.
getClass
()))
{
parallelLockMap
=
new
ConcurrentHashMap
<
String
,
Object
>();
package2certs
=
new
ConcurrentHashMap
<
String
,
Certificate
[]
>();
parallelLockMap
=
new
ConcurrentHashMap
<>();
package2certs
=
new
ConcurrentHashMap
<>();
domains
=
Collections
.
synchronizedSet
(
new
HashSet
<
ProtectionDomain
>());
assertionLock
=
new
Object
();
}
else
{
// no finer-grained lock; lock on the classloader instance
parallelLockMap
=
null
;
package2certs
=
new
Hashtable
<
String
,
Certificate
[]
>();
domains
=
new
HashSet
<
ProtectionDomain
>();
package2certs
=
new
Hashtable
<>();
domains
=
new
HashSet
<>();
assertionLock
=
this
;
}
}
...
...
@@ -1182,7 +1181,7 @@ public abstract class ClassLoader {
}
tmp
[
1
]
=
findResources
(
name
);
return
new
CompoundEnumeration
<
URL
>(
tmp
);
return
new
CompoundEnumeration
<>(
tmp
);
}
/**
...
...
@@ -1657,7 +1656,7 @@ public abstract class ClassLoader {
protected
Package
[]
getPackages
()
{
Map
<
String
,
Package
>
map
;
synchronized
(
packages
)
{
map
=
new
HashMap
<
String
,
Package
>(
packages
);
map
=
new
HashMap
<>(
packages
);
}
Package
[]
pkgs
;
if
(
parent
!=
null
)
{
...
...
@@ -1764,20 +1763,17 @@ public abstract class ClassLoader {
}
// All native library names we've loaded.
private
static
Vector
<
String
>
loadedLibraryNames
=
new
Vector
<
String
>();
private
static
Vector
<
String
>
loadedLibraryNames
=
new
Vector
<>();
// Native libraries belonging to system classes.
private
static
Vector
<
NativeLibrary
>
systemNativeLibraries
=
new
Vector
<
NativeLibrary
>();
=
new
Vector
<>();
// Native libraries associated with the class loader.
private
Vector
<
NativeLibrary
>
nativeLibraries
=
new
Vector
<
NativeLibrary
>();
private
Vector
<
NativeLibrary
>
nativeLibraries
=
new
Vector
<>();
// native libraries being loaded/unloaded.
private
static
Stack
<
NativeLibrary
>
nativeLibraryContext
=
new
Stack
<
NativeLibrary
>();
private
static
Stack
<
NativeLibrary
>
nativeLibraryContext
=
new
Stack
<>();
// The paths searched for libraries
private
static
String
usr_paths
[];
...
...
@@ -2101,8 +2097,8 @@ public abstract class ClassLoader {
* them to empty maps, effectively ignoring any present settings.
*/
synchronized
(
assertionLock
)
{
classAssertionStatus
=
new
HashMap
<
String
,
Boolean
>();
packageAssertionStatus
=
new
HashMap
<
String
,
Boolean
>();
classAssertionStatus
=
new
HashMap
<>();
packageAssertionStatus
=
new
HashMap
<>();
defaultAssertionStatus
=
false
;
}
}
...
...
@@ -2164,8 +2160,8 @@ public abstract class ClassLoader {
private
void
initializeJavaAssertionMaps
()
{
// assert Thread.holdsLock(assertionLock);
classAssertionStatus
=
new
HashMap
<
String
,
Boolean
>();
packageAssertionStatus
=
new
HashMap
<
String
,
Boolean
>();
classAssertionStatus
=
new
HashMap
<>();
packageAssertionStatus
=
new
HashMap
<>();
AssertionStatusDirectives
directives
=
retrieveDirectives
();
for
(
int
i
=
0
;
i
<
directives
.
classes
.
length
;
i
++)
...
...
src/share/classes/java/lang/Package.java
浏览文件 @
66fa671c
...
...
@@ -588,16 +588,13 @@ public class Package implements java.lang.reflect.AnnotatedElement {
}
// The map of loaded system packages
private
static
Map
<
String
,
Package
>
pkgs
=
new
HashMap
<
String
,
Package
>(
31
);
private
static
Map
<
String
,
Package
>
pkgs
=
new
HashMap
<>(
31
);
// Maps each directory or zip file name to its corresponding url
private
static
Map
<
String
,
URL
>
urls
=
new
HashMap
<
String
,
URL
>(
10
);
private
static
Map
<
String
,
URL
>
urls
=
new
HashMap
<>(
10
);
// Maps each code source url for a jar file to its manifest
private
static
Map
<
String
,
Manifest
>
mans
=
new
HashMap
<
String
,
Manifest
>(
10
);
private
static
Map
<
String
,
Manifest
>
mans
=
new
HashMap
<>(
10
);
private
static
native
String
getSystemPackage0
(
String
name
);
private
static
native
String
[]
getSystemPackages0
();
...
...
src/share/classes/java/lang/ProcessBuilder.java
浏览文件 @
66fa671c
...
...
@@ -214,7 +214,7 @@ public final class ProcessBuilder
* @param command a string array containing the program and its arguments
*/
public
ProcessBuilder
(
String
...
command
)
{
this
.
command
=
new
ArrayList
<
String
>(
command
.
length
);
this
.
command
=
new
ArrayList
<>(
command
.
length
);
for
(
String
arg
:
command
)
this
.
command
.
add
(
arg
);
}
...
...
@@ -251,7 +251,7 @@ public final class ProcessBuilder
* @return this process builder
*/
public
ProcessBuilder
command
(
String
...
command
)
{
this
.
command
=
new
ArrayList
<
String
>(
command
.
length
);
this
.
command
=
new
ArrayList
<>(
command
.
length
);
for
(
String
arg
:
command
)
this
.
command
.
add
(
arg
);
return
this
;
...
...
src/share/classes/java/lang/String.java
浏览文件 @
66fa671c
...
...
@@ -2330,7 +2330,7 @@ public final class String
int
off
=
0
;
int
next
=
0
;
boolean
limited
=
limit
>
0
;
ArrayList
<
String
>
list
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
list
=
new
ArrayList
<>();
while
((
next
=
indexOf
(
ch
,
off
))
!=
-
1
)
{
if
(!
limited
||
list
.
size
()
<
limit
-
1
)
{
list
.
add
(
substring
(
off
,
next
));
...
...
src/share/classes/java/lang/StringCoding.java
浏览文件 @
66fa671c
...
...
@@ -53,9 +53,9 @@ class StringCoding {
/** The cached coders for each thread */
private
final
static
ThreadLocal
<
SoftReference
<
StringDecoder
>>
decoder
=
new
ThreadLocal
<
SoftReference
<
StringDecoder
>
>();
new
ThreadLocal
<>();
private
final
static
ThreadLocal
<
SoftReference
<
StringEncoder
>>
encoder
=
new
ThreadLocal
<
SoftReference
<
StringEncoder
>
>();
new
ThreadLocal
<>();
private
static
boolean
warnUnsupportedCharset
=
true
;
...
...
@@ -67,7 +67,7 @@ class StringCoding {
}
private
static
<
T
>
void
set
(
ThreadLocal
<
SoftReference
<
T
>>
tl
,
T
ob
)
{
tl
.
set
(
new
SoftReference
<
T
>(
ob
));
tl
.
set
(
new
SoftReference
<>(
ob
));
}
// Trim the given byte array to the given length
...
...
src/share/classes/java/lang/Thread.java
浏览文件 @
66fa671c
...
...
@@ -1642,8 +1642,7 @@ class Thread implements Runnable {
// Get a snapshot of the list of all threads
Thread
[]
threads
=
getThreads
();
StackTraceElement
[][]
traces
=
dumpThreads
(
threads
);
Map
<
Thread
,
StackTraceElement
[]>
m
=
new
HashMap
<
Thread
,
StackTraceElement
[]>(
threads
.
length
);
Map
<
Thread
,
StackTraceElement
[]>
m
=
new
HashMap
<>(
threads
.
length
);
for
(
int
i
=
0
;
i
<
threads
.
length
;
i
++)
{
StackTraceElement
[]
stackTrace
=
traces
[
i
];
if
(
stackTrace
!=
null
)
{
...
...
@@ -1664,11 +1663,11 @@ class Thread implements Runnable {
private
static
class
Caches
{
/** cache of subclass security audit results */
static
final
ConcurrentMap
<
WeakClassKey
,
Boolean
>
subclassAudits
=
new
ConcurrentHashMap
<
WeakClassKey
,
Boolean
>();
new
ConcurrentHashMap
<>();
/** queue for WeakReferences to audited subclasses */
static
final
ReferenceQueue
<
Class
<?>>
subclassAuditsQueue
=
new
ReferenceQueue
<
Class
<?>
>();
new
ReferenceQueue
<>();
}
/**
...
...
src/share/classes/java/lang/Throwable.java
浏览文件 @
66fa671c
...
...
@@ -828,7 +828,7 @@ public class Throwable implements Serializable {
// Use the sentinel for a zero-length list
suppressed
=
SUPPRESSED_SENTINEL
;
}
else
{
// Copy Throwables to new list
suppressed
=
new
ArrayList
<
Throwable
>(
1
);
suppressed
=
new
ArrayList
<>(
1
);
for
(
Throwable
t
:
suppressedExceptions
)
{
// Enforce constraints on suppressed exceptions in
// case of corrupt or malicious stream.
...
...
@@ -911,7 +911,7 @@ public class Throwable implements Serializable {
return
;
if
(
suppressedExceptions
==
SUPPRESSED_SENTINEL
)
suppressedExceptions
=
new
ArrayList
<
Throwable
>(
1
);
suppressedExceptions
=
new
ArrayList
<>(
1
);
assert
suppressedExceptions
!=
SUPPRESSED_SENTINEL
;
...
...
src/share/classes/java/lang/management/ManagementFactory.java
浏览文件 @
66fa671c
...
...
@@ -794,7 +794,7 @@ public class ManagementFactory {
*/
public
static
List
<
Class
<?
extends
PlatformManagedObject
>>
getAllPlatformMXBeanInterfaces
()
{
List
<
Class
<?
extends
PlatformManagedObject
>>
result
=
new
ArrayList
<
Class
<?
extends
PlatformManagedObject
>
>();
new
ArrayList
<>();
for
(
PlatformComponent
component:
PlatformComponent
.
values
())
{
result
.
add
(
component
.
getMXBeanInterface
());
}
...
...
src/share/classes/java/lang/management/PlatformComponent.java
浏览文件 @
66fa671c
...
...
@@ -267,7 +267,7 @@ enum PlatformComponent {
List
<
T
>
getGcMXBeanList
(
Class
<
T
>
gcMXBeanIntf
)
{
List
<
GarbageCollectorMXBean
>
list
=
ManagementFactoryHelper
.
getGarbageCollectorMXBeans
();
List
<
T
>
result
=
new
ArrayList
<
T
>(
list
.
size
());
List
<
T
>
result
=
new
ArrayList
<>(
list
.
size
());
for
(
GarbageCollectorMXBean
m
:
list
)
{
if
(
gcMXBeanIntf
.
isInstance
(
m
))
{
result
.
add
(
gcMXBeanIntf
.
cast
(
m
));
...
...
@@ -330,7 +330,7 @@ enum PlatformComponent {
}
private
static
Set
<
String
>
keyProperties
(
String
...
keyNames
)
{
Set
<
String
>
set
=
new
HashSet
<
String
>();
Set
<
String
>
set
=
new
HashSet
<>();
set
.
add
(
"type"
);
for
(
String
s
:
keyNames
)
{
set
.
add
(
s
);
...
...
@@ -364,7 +364,7 @@ enum PlatformComponent {
List
<
T
>
getMXBeans
(
MBeanServerConnection
mbs
,
Class
<
T
>
mxbeanInterface
)
throws
java
.
io
.
IOException
{
List
<
T
>
result
=
new
ArrayList
<
T
>();
List
<
T
>
result
=
new
ArrayList
<>();
for
(
ObjectName
on
:
getObjectNames
(
mbs
))
{
result
.
add
(
ManagementFactory
.
newPlatformMXBeanProxy
(
mbs
,
...
...
src/share/classes/java/lang/reflect/Constructor.java
浏览文件 @
66fa671c
...
...
@@ -144,7 +144,7 @@ public final
// which implicitly requires that new java.lang.reflect
// objects be fabricated for each reflective call on Class
// objects.)
Constructor
<
T
>
res
=
new
Constructor
<
T
>(
clazz
,
Constructor
<
T
>
res
=
new
Constructor
<>(
clazz
,
parameterTypes
,
exceptionTypes
,
modifiers
,
slot
,
signature
,
...
...
src/share/classes/java/lang/reflect/Proxy.java
浏览文件 @
66fa671c
...
...
@@ -232,7 +232,7 @@ public class Proxy implements java.io.Serializable {
/** maps a class loader to the proxy class cache for that loader */
private
static
Map
<
ClassLoader
,
Map
<
List
<
String
>,
Object
>>
loaderToCache
=
new
WeakHashMap
<
ClassLoader
,
Map
<
List
<
String
>,
Object
>
>();
=
new
WeakHashMap
<>();
/** marks that a particular proxy class is currently being generated */
private
static
Object
pendingGenerationMarker
=
new
Object
();
...
...
@@ -356,7 +356,7 @@ public class Proxy implements java.io.Serializable {
String
[]
interfaceNames
=
new
String
[
interfaces
.
length
];
// for detecting duplicates
Set
<
Class
<?>>
interfaceSet
=
new
HashSet
<
Class
<?>
>();
Set
<
Class
<?>>
interfaceSet
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
interfaces
.
length
;
i
++)
{
/*
...
...
@@ -413,7 +413,7 @@ public class Proxy implements java.io.Serializable {
synchronized
(
loaderToCache
)
{
cache
=
loaderToCache
.
get
(
loader
);
if
(
cache
==
null
)
{
cache
=
new
HashMap
<
List
<
String
>,
Object
>();
cache
=
new
HashMap
<>();
loaderToCache
.
put
(
loader
,
cache
);
}
/*
...
...
src/share/classes/java/lang/reflect/ReflectAccess.java
浏览文件 @
66fa671c
...
...
@@ -84,7 +84,7 @@ class ReflectAccess implements sun.reflect.LangReflectAccess {
byte
[]
annotations
,
byte
[]
parameterAnnotations
)
{
return
new
Constructor
<
T
>(
declaringClass
,
return
new
Constructor
<>(
declaringClass
,
parameterTypes
,
checkedExceptions
,
modifiers
,
...
...
src/share/classes/java/sql/DriverManager.java
浏览文件 @
66fa671c
...
...
@@ -364,7 +364,7 @@ public class DriverManager {
* @return the list of JDBC Drivers loaded by the caller's class loader
*/
public
static
java
.
util
.
Enumeration
<
Driver
>
getDrivers
()
{
java
.
util
.
Vector
<
Driver
>
result
=
new
java
.
util
.
Vector
<
Driver
>();
java
.
util
.
Vector
<
Driver
>
result
=
new
java
.
util
.
Vector
<>();
java
.
util
.
Vector
drivers
=
null
;
if
(!
initialized
)
{
...
...
src/share/classes/java/sql/Statement.java
浏览文件 @
66fa671c
...
...
@@ -577,7 +577,7 @@ public interface Statement extends Wrapper, AutoCloseable {
*
* @see #addBatch
* @see DatabaseMetaData#supportsBatchUpdates
* @since 1.
3
* @since 1.
2
*/
int
[]
executeBatch
()
throws
SQLException
;
...
...
src/share/classes/java/util/AbstractList.java
浏览文件 @
66fa671c
...
...
@@ -482,8 +482,8 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
*/
public
List
<
E
>
subList
(
int
fromIndex
,
int
toIndex
)
{
return
(
this
instanceof
RandomAccess
?
new
RandomAccessSubList
<
E
>(
this
,
fromIndex
,
toIndex
)
:
new
SubList
<
E
>(
this
,
fromIndex
,
toIndex
));
new
RandomAccessSubList
<>(
this
,
fromIndex
,
toIndex
)
:
new
SubList
<>(
this
,
fromIndex
,
toIndex
));
}
// Comparison and hashing
...
...
@@ -747,7 +747,7 @@ class SubList<E> extends AbstractList<E> {
}
public
List
<
E
>
subList
(
int
fromIndex
,
int
toIndex
)
{
return
new
SubList
<
E
>(
this
,
fromIndex
,
toIndex
);
return
new
SubList
<>(
this
,
fromIndex
,
toIndex
);
}
private
void
rangeCheck
(
int
index
)
{
...
...
@@ -776,6 +776,6 @@ class RandomAccessSubList<E> extends SubList<E> implements RandomAccess {
}
public
List
<
E
>
subList
(
int
fromIndex
,
int
toIndex
)
{
return
new
RandomAccessSubList
<
E
>(
this
,
fromIndex
,
toIndex
);
return
new
RandomAccessSubList
<>(
this
,
fromIndex
,
toIndex
);
}
}
src/share/classes/java/util/Arrays.java
浏览文件 @
66fa671c
...
...
@@ -2824,7 +2824,7 @@ public class Arrays {
* @return a list view of the specified array
*/
public
static
<
T
>
List
<
T
>
asList
(
T
...
a
)
{
return
new
ArrayList
<
T
>(
a
);
return
new
ArrayList
<>(
a
);
}
/**
...
...
src/share/classes/java/util/Collections.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/EnumMap.java
浏览文件 @
66fa671c
...
...
@@ -499,7 +499,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
int
j
=
0
;
for
(
int
i
=
0
;
i
<
vals
.
length
;
i
++)
if
(
vals
[
i
]
!=
null
)
a
[
j
++]
=
new
AbstractMap
.
SimpleEntry
<
K
,
V
>(
a
[
j
++]
=
new
AbstractMap
.
SimpleEntry
<>(
keyUniverse
[
i
],
unmaskNull
(
vals
[
i
]));
return
a
;
}
...
...
src/share/classes/java/util/EnumSet.java
浏览文件 @
66fa671c
...
...
@@ -110,9 +110,9 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
throw
new
ClassCastException
(
elementType
+
" not an enum"
);
if
(
universe
.
length
<=
64
)
return
new
RegularEnumSet
<
E
>(
elementType
,
universe
);
return
new
RegularEnumSet
<>(
elementType
,
universe
);
else
return
new
JumboEnumSet
<
E
>(
elementType
,
universe
);
return
new
JumboEnumSet
<>(
elementType
,
universe
);
}
/**
...
...
@@ -430,7 +430,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
}
Object
writeReplace
()
{
return
new
SerializationProxy
<
E
>(
this
);
return
new
SerializationProxy
<>(
this
);
}
// readObject method for the serialization proxy pattern
...
...
src/share/classes/java/util/Formatter.java
浏览文件 @
66fa671c
...
...
@@ -2490,7 +2490,7 @@ public final class Formatter implements Closeable, Flushable {
* Finds format specifiers in the format string.
*/
private
FormatString
[]
parse
(
String
s
)
{
ArrayList
<
FormatString
>
al
=
new
ArrayList
<
FormatString
>();
ArrayList
<
FormatString
>
al
=
new
ArrayList
<>();
Matcher
m
=
fsPattern
.
matcher
(
s
);
for
(
int
i
=
0
,
len
=
s
.
length
();
i
<
len
;
)
{
if
(
m
.
find
(
i
))
{
...
...
src/share/classes/java/util/HashMap.java
浏览文件 @
66fa671c
...
...
@@ -763,7 +763,7 @@ public class HashMap<K,V>
*/
void
addEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
Entry
<
K
,
V
>
e
=
table
[
bucketIndex
];
table
[
bucketIndex
]
=
new
Entry
<
K
,
V
>(
hash
,
key
,
value
,
e
);
table
[
bucketIndex
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
if
(
size
++
>=
threshold
)
resize
(
2
*
table
.
length
);
}
...
...
@@ -778,7 +778,7 @@ public class HashMap<K,V>
*/
void
createEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
Entry
<
K
,
V
>
e
=
table
[
bucketIndex
];
table
[
bucketIndex
]
=
new
Entry
<
K
,
V
>(
hash
,
key
,
value
,
e
);
table
[
bucketIndex
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
size
++;
}
...
...
src/share/classes/java/util/HashSet.java
浏览文件 @
66fa671c
...
...
@@ -100,7 +100,7 @@ public class HashSet<E>
* default initial capacity (16) and load factor (0.75).
*/
public
HashSet
()
{
map
=
new
HashMap
<
E
,
Object
>();
map
=
new
HashMap
<>();
}
/**
...
...
@@ -113,7 +113,7 @@ public class HashSet<E>
* @throws NullPointerException if the specified collection is null
*/
public
HashSet
(
Collection
<?
extends
E
>
c
)
{
map
=
new
HashMap
<
E
,
Object
>(
Math
.
max
((
int
)
(
c
.
size
()/.
75
f
)
+
1
,
16
));
map
=
new
HashMap
<>(
Math
.
max
((
int
)
(
c
.
size
()/.
75
f
)
+
1
,
16
));
addAll
(
c
);
}
...
...
@@ -127,7 +127,7 @@ public class HashSet<E>
* than zero, or if the load factor is nonpositive
*/
public
HashSet
(
int
initialCapacity
,
float
loadFactor
)
{
map
=
new
HashMap
<
E
,
Object
>(
initialCapacity
,
loadFactor
);
map
=
new
HashMap
<>(
initialCapacity
,
loadFactor
);
}
/**
...
...
@@ -139,7 +139,7 @@ public class HashSet<E>
* than zero
*/
public
HashSet
(
int
initialCapacity
)
{
map
=
new
HashMap
<
E
,
Object
>(
initialCapacity
);
map
=
new
HashMap
<>(
initialCapacity
);
}
/**
...
...
@@ -156,7 +156,7 @@ public class HashSet<E>
* than zero, or if the load factor is nonpositive
*/
HashSet
(
int
initialCapacity
,
float
loadFactor
,
boolean
dummy
)
{
map
=
new
LinkedHashMap
<
E
,
Object
>(
initialCapacity
,
loadFactor
);
map
=
new
LinkedHashMap
<>(
initialCapacity
,
loadFactor
);
}
/**
...
...
src/share/classes/java/util/Hashtable.java
浏览文件 @
66fa671c
...
...
@@ -455,7 +455,7 @@ public class Hashtable<K,V>
// Creates the new entry.
Entry
<
K
,
V
>
e
=
tab
[
index
];
tab
[
index
]
=
new
Entry
<
K
,
V
>(
hash
,
key
,
value
,
e
);
tab
[
index
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
count
++;
return
null
;
}
...
...
@@ -579,7 +579,7 @@ public class Hashtable<K,V>
if
(
count
==
0
)
{
return
Collections
.
emptyEnumeration
();
}
else
{
return
new
Enumerator
<
T
>(
type
,
false
);
return
new
Enumerator
<>(
type
,
false
);
}
}
...
...
@@ -587,7 +587,7 @@ public class Hashtable<K,V>
if
(
count
==
0
)
{
return
Collections
.
emptyIterator
();
}
else
{
return
new
Enumerator
<
T
>(
type
,
true
);
return
new
Enumerator
<>(
type
,
true
);
}
}
...
...
@@ -929,7 +929,7 @@ public class Hashtable<K,V>
}
// Creates the new entry.
Entry
<
K
,
V
>
e
=
tab
[
index
];
tab
[
index
]
=
new
Entry
<
K
,
V
>(
hash
,
key
,
value
,
e
);
tab
[
index
]
=
new
Entry
<>(
hash
,
key
,
value
,
e
);
count
++;
}
...
...
@@ -950,7 +950,7 @@ public class Hashtable<K,V>
}
protected
Object
clone
()
{
return
new
Entry
<
K
,
V
>(
hash
,
key
,
value
,
return
new
Entry
<>(
hash
,
key
,
value
,
(
next
==
null
?
null
:
(
Entry
<
K
,
V
>)
next
.
clone
()));
}
...
...
src/share/classes/java/util/IdentityHashMap.java
浏览文件 @
66fa671c
...
...
@@ -1134,7 +1134,7 @@ public class IdentityHashMap<K,V>
Object
[]
result
=
new
Object
[
size
];
Iterator
<
Map
.
Entry
<
K
,
V
>>
it
=
iterator
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
result
[
i
]
=
new
AbstractMap
.
SimpleEntry
<
K
,
V
>(
it
.
next
());
result
[
i
]
=
new
AbstractMap
.
SimpleEntry
<>(
it
.
next
());
return
result
;
}
...
...
@@ -1146,7 +1146,7 @@ public class IdentityHashMap<K,V>
.
newInstance
(
a
.
getClass
().
getComponentType
(),
size
);
Iterator
<
Map
.
Entry
<
K
,
V
>>
it
=
iterator
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
a
[
i
]
=
(
T
)
new
AbstractMap
.
SimpleEntry
<
K
,
V
>(
it
.
next
());
a
[
i
]
=
(
T
)
new
AbstractMap
.
SimpleEntry
<>(
it
.
next
());
if
(
a
.
length
>
size
)
a
[
size
]
=
null
;
return
a
;
...
...
src/share/classes/java/util/JumboEnumSet.java
浏览文件 @
66fa671c
...
...
@@ -89,7 +89,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
* @return an iterator over the elements contained in this set
*/
public
Iterator
<
E
>
iterator
()
{
return
new
EnumSetIterator
<
E
>();
return
new
EnumSetIterator
<>();
}
private
class
EnumSetIterator
<
E
extends
Enum
<
E
>>
implements
Iterator
<
E
>
{
...
...
src/share/classes/java/util/LinkedHashMap.java
浏览文件 @
66fa671c
...
...
@@ -237,7 +237,7 @@ public class LinkedHashMap<K,V>
* the chain.
*/
void
init
()
{
header
=
new
Entry
<
K
,
V
>(-
1
,
null
,
null
,
null
);
header
=
new
Entry
<>(-
1
,
null
,
null
,
null
);
header
.
before
=
header
.
after
=
header
;
}
...
...
@@ -438,7 +438,7 @@ public class LinkedHashMap<K,V>
*/
void
createEntry
(
int
hash
,
K
key
,
V
value
,
int
bucketIndex
)
{
HashMap
.
Entry
<
K
,
V
>
old
=
table
[
bucketIndex
];
Entry
<
K
,
V
>
e
=
new
Entry
<
K
,
V
>(
hash
,
key
,
value
,
old
);
Entry
<
K
,
V
>
e
=
new
Entry
<>(
hash
,
key
,
value
,
old
);
table
[
bucketIndex
]
=
e
;
e
.
addBefore
(
header
);
size
++;
...
...
src/share/classes/java/util/LinkedList.java
浏览文件 @
66fa671c
...
...
@@ -122,7 +122,7 @@ public class LinkedList<E>
*/
private
void
linkFirst
(
E
e
)
{
final
Node
<
E
>
f
=
first
;
final
Node
<
E
>
newNode
=
new
Node
<
E
>(
null
,
e
,
f
);
final
Node
<
E
>
newNode
=
new
Node
<>(
null
,
e
,
f
);
first
=
newNode
;
if
(
f
==
null
)
last
=
newNode
;
...
...
@@ -137,7 +137,7 @@ public class LinkedList<E>
*/
void
linkLast
(
E
e
)
{
final
Node
<
E
>
l
=
last
;
final
Node
<
E
>
newNode
=
new
Node
<
E
>(
l
,
e
,
null
);
final
Node
<
E
>
newNode
=
new
Node
<>(
l
,
e
,
null
);
last
=
newNode
;
if
(
l
==
null
)
first
=
newNode
;
...
...
@@ -153,7 +153,7 @@ public class LinkedList<E>
void
linkBefore
(
E
e
,
Node
<
E
>
succ
)
{
// assert succ != null;
final
Node
<
E
>
pred
=
succ
.
prev
;
final
Node
<
E
>
newNode
=
new
Node
<
E
>(
pred
,
e
,
succ
);
final
Node
<
E
>
newNode
=
new
Node
<>(
pred
,
e
,
succ
);
succ
.
prev
=
newNode
;
if
(
pred
==
null
)
first
=
newNode
;
...
...
@@ -419,7 +419,7 @@ public class LinkedList<E>
for
(
Object
o
:
a
)
{
@SuppressWarnings
(
"unchecked"
)
E
e
=
(
E
)
o
;
Node
<
E
>
newNode
=
new
Node
<
E
>(
pred
,
e
,
null
);
Node
<
E
>
newNode
=
new
Node
<>(
pred
,
e
,
null
);
if
(
pred
==
null
)
first
=
newNode
;
else
...
...
src/share/classes/java/util/ListResourceBundle.java
浏览文件 @
66fa671c
...
...
@@ -187,7 +187,7 @@ public abstract class ListResourceBundle extends ResourceBundle {
return
;
Object
[][]
contents
=
getContents
();
HashMap
<
String
,
Object
>
temp
=
new
HashMap
<
String
,
Object
>(
contents
.
length
);
HashMap
<
String
,
Object
>
temp
=
new
HashMap
<>(
contents
.
length
);
for
(
int
i
=
0
;
i
<
contents
.
length
;
++
i
)
{
// key must be non-null String, value must be non-null
String
key
=
(
String
)
contents
[
i
][
0
];
...
...
src/share/classes/java/util/PriorityQueue.java
浏览文件 @
66fa671c
...
...
@@ -538,7 +538,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
cursor
--;
else
{
if
(
forgetMeNot
==
null
)
forgetMeNot
=
new
ArrayDeque
<
E
>();
forgetMeNot
=
new
ArrayDeque
<>();
forgetMeNot
.
add
(
moved
);
}
}
else
if
(
lastRetElt
!=
null
)
{
...
...
src/share/classes/java/util/Properties.java
浏览文件 @
66fa671c
...
...
@@ -1011,7 +1011,7 @@ class Properties extends Hashtable<Object,Object> {
* @since 1.6
*/
public
Set
<
String
>
stringPropertyNames
()
{
Hashtable
<
String
,
String
>
h
=
new
Hashtable
<
String
,
String
>();
Hashtable
<
String
,
String
>
h
=
new
Hashtable
<>();
enumerateStringProperties
(
h
);
return
h
.
keySet
();
}
...
...
src/share/classes/java/util/RegularEnumSet.java
浏览文件 @
66fa671c
...
...
@@ -71,7 +71,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
* @return an iterator over the elements contained in this set
*/
public
Iterator
<
E
>
iterator
()
{
return
new
EnumSetIterator
<
E
>();
return
new
EnumSetIterator
<>();
}
private
class
EnumSetIterator
<
E
extends
Enum
<
E
>>
implements
Iterator
<
E
>
{
...
...
src/share/classes/java/util/ServiceLoader.java
浏览文件 @
66fa671c
...
...
@@ -191,7 +191,7 @@ public final class ServiceLoader<S>
private
ClassLoader
loader
;
// Cached providers, in instantiation order
private
LinkedHashMap
<
String
,
S
>
providers
=
new
LinkedHashMap
<
String
,
S
>();
private
LinkedHashMap
<
String
,
S
>
providers
=
new
LinkedHashMap
<>();
// The current lazy-lookup iterator
private
LazyIterator
lookupIterator
;
...
...
@@ -291,7 +291,7 @@ public final class ServiceLoader<S>
{
InputStream
in
=
null
;
BufferedReader
r
=
null
;
ArrayList
<
String
>
names
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
names
=
new
ArrayList
<>();
try
{
in
=
u
.
openStream
();
r
=
new
BufferedReader
(
new
InputStreamReader
(
in
,
"utf-8"
));
...
...
@@ -463,7 +463,7 @@ public final class ServiceLoader<S>
public
static
<
S
>
ServiceLoader
<
S
>
load
(
Class
<
S
>
service
,
ClassLoader
loader
)
{
return
new
ServiceLoader
<
S
>(
service
,
loader
);
return
new
ServiceLoader
<>(
service
,
loader
);
}
/**
...
...
src/share/classes/java/util/TimSort.java
浏览文件 @
66fa671c
...
...
@@ -196,7 +196,7 @@ class TimSort<T> {
* extending short natural runs to minRun elements, and merging runs
* to maintain stack invariant.
*/
TimSort
<
T
>
ts
=
new
TimSort
<
T
>(
a
,
c
);
TimSort
<
T
>
ts
=
new
TimSort
<>(
a
,
c
);
int
minRun
=
minRunLength
(
nRemaining
);
do
{
// Identify next run
...
...
src/share/classes/java/util/TreeMap.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/TreeSet.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/WeakHashMap.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/jar/Pack200.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/logging/FileHandler.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/logging/Level.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/logging/LogManager.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/logging/LogRecord.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/logging/Logger.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/logging/Logging.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/prefs/AbstractPreferences.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/regex/Pattern.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/zip/Inflater.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/zip/ZipFile.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/java/util/zip/ZipOutputStream.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/javax/net/ssl/X509ExtendedTrustManager.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/io/Converters.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/launcher/LauncherHelper.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/jgss/krb5/CipherHelper.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/jgss/krb5/MicToken_v2.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/jgss/krb5/WrapToken.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/jgss/krb5/WrapToken_v2.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/pkcs11/Config.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/pkcs11/P11Cipher.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/ssl/CipherSuite.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/ssl/ClientHandshaker.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/ssl/HandshakeHash.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/security/ssl/ServerHandshaker.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/tools/jstat/resources/jstat_options
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/classes/sun/util/logging/PlatformLogger.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/share/demo/jvmti/heapTracker/heapTracker.c
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/solaris/classes/java/lang/ProcessEnvironment.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/solaris/classes/java/util/prefs/FileSystemPreferences.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/windows/classes/java/lang/ProcessEnvironment.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/windows/native/java/net/Inet4AddressImpl.c
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
src/windows/native/java/net/Inet6AddressImpl.c
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/java/awt/xembed/server/TestXEmbedServer.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/java/io/Serializable/NPEProvoker/NPEProvoker.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/java/lang/instrument/ilib/Inject.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/java/lang/instrument/ilib/InjectBytecodes.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/java/util/Random/DistinctSeeds.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/java/util/logging/ClassLoaderLeakTest.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/java/util/zip/ZipFile/FinalizeZipFile.java
0 → 100644
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/javax/script/VersionTest.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/sun/security/krb5/auto/BasicKrb5Test.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/sun/security/krb5/auto/Context.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/sun/security/krb5/auto/basic.sh
已删除
100644 → 0
浏览文件 @
d432c9f5
此差异已折叠。
点击以展开。
test/
javax/script/E4XErrorTest
.java
→
test/
sun/security/pkcs11/Provider/ConfigShortPath
.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/sun/security/pkcs11/Provider/csp.cfg
0 → 100644
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/sun/tools/jstat/gcNewCapacityOutput1.awk
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/tools/launcher/Settings.java
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
test/tools/pack200/T7007157.java
0 → 100644
浏览文件 @
66fa671c
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录