Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
带水的鱼儿
spring-framework
提交
d29d4d45
S
spring-framework
项目概览
带水的鱼儿
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d29d4d45
编写于
6月 07, 2021
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Upgrade to ASM master
Closes gh-27023
上级
432fdad7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
8 deletion
+30
-8
spring-core/src/main/java/org/springframework/asm/ClassReader.java
...re/src/main/java/org/springframework/asm/ClassReader.java
+29
-7
spring-core/src/main/java/org/springframework/asm/ClassWriter.java
...re/src/main/java/org/springframework/asm/ClassWriter.java
+1
-1
未找到文件。
spring-core/src/main/java/org/springframework/asm/ClassReader.java
浏览文件 @
d29d4d45
...
...
@@ -88,6 +88,9 @@ public class ClassReader {
*/
static
final
int
EXPAND_ASM_INSNS
=
256
;
/** The maximum size of array to allocate. */
private
static
final
int
MAX_BUFFER_SIZE
=
1024
*
1024
;
/** The size of the temporary byte array used to read class input streams chunk by chunk. */
private
static
final
int
INPUT_STREAM_DATA_CHUNK_SIZE
=
4096
;
...
...
@@ -310,13 +313,19 @@ public class ClassReader {
if
(
inputStream
==
null
)
{
throw
new
IOException
(
"Class not found"
);
}
int
bufferSize
=
calculateBufferSize
(
inputStream
);
try
(
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
())
{
byte
[]
data
=
new
byte
[
INPUT_STREAM_DATA_CHUNK_SIZE
];
byte
[]
data
=
new
byte
[
bufferSize
];
int
bytesRead
;
while
((
bytesRead
=
inputStream
.
read
(
data
,
0
,
data
.
length
))
!=
-
1
)
{
int
readCount
=
0
;
while
((
bytesRead
=
inputStream
.
read
(
data
,
0
,
bufferSize
))
!=
-
1
)
{
outputStream
.
write
(
data
,
0
,
bytesRead
);
readCount
++;
}
outputStream
.
flush
();
if
(
readCount
==
1
)
{
return
data
;
}
return
outputStream
.
toByteArray
();
}
finally
{
if
(
close
)
{
...
...
@@ -325,6 +334,20 @@ public class ClassReader {
}
}
private
static
int
calculateBufferSize
(
final
InputStream
inputStream
)
throws
IOException
{
int
expectedLength
=
inputStream
.
available
();
/*
* Some implementations can return 0 while holding available data
* (e.g. new FileInputStream("/proc/a_file"))
* Also in some pathological cases a very small number might be returned,
* and in this case we use default size
*/
if
(
expectedLength
<
256
)
{
return
INPUT_STREAM_DATA_CHUNK_SIZE
;
}
return
Math
.
min
(
expectedLength
,
MAX_BUFFER_SIZE
);
}
// -----------------------------------------------------------------------------------------------
// Accessors
// -----------------------------------------------------------------------------------------------
...
...
@@ -3456,7 +3479,6 @@ public class ClassReader {
private
int
[]
readBootstrapMethodsAttribute
(
final
int
maxStringLength
)
{
char
[]
charBuffer
=
new
char
[
maxStringLength
];
int
currentAttributeOffset
=
getFirstAttributeOffset
();
int
[]
currentBootstrapMethodOffsets
=
null
;
for
(
int
i
=
readUnsignedShort
(
currentAttributeOffset
-
2
);
i
>
0
;
--
i
)
{
// Read the attribute_info's attribute_name and attribute_length fields.
String
attributeName
=
readUTF8
(
currentAttributeOffset
,
charBuffer
);
...
...
@@ -3464,17 +3486,17 @@ public class ClassReader {
currentAttributeOffset
+=
6
;
if
(
Constants
.
BOOTSTRAP_METHODS
.
equals
(
attributeName
))
{
// Read the num_bootstrap_methods field and create an array of this size.
currentBootstrapMethodOffsets
=
new
int
[
readUnsignedShort
(
currentAttributeOffset
)];
int
[]
result
=
new
int
[
readUnsignedShort
(
currentAttributeOffset
)];
// Compute and store the offset of each 'bootstrap_methods' array field entry.
int
currentBootstrapMethodOffset
=
currentAttributeOffset
+
2
;
for
(
int
j
=
0
;
j
<
currentBootstrapMethodOffsets
.
length
;
++
j
)
{
currentBootstrapMethodOffsets
[
j
]
=
currentBootstrapMethodOffset
;
for
(
int
j
=
0
;
j
<
result
.
length
;
++
j
)
{
result
[
j
]
=
currentBootstrapMethodOffset
;
// Skip the bootstrap_method_ref and num_bootstrap_arguments fields (2 bytes each),
// as well as the bootstrap_arguments array field (of size num_bootstrap_arguments * 2).
currentBootstrapMethodOffset
+=
4
+
readUnsignedShort
(
currentBootstrapMethodOffset
+
2
)
*
2
;
}
return
currentBootstrapMethodOffsets
;
return
result
;
}
currentAttributeOffset
+=
attributeLength
;
}
...
...
spring-core/src/main/java/org/springframework/asm/ClassWriter.java
浏览文件 @
d29d4d45
...
...
@@ -79,7 +79,7 @@ public class ClassWriter extends ClassVisitor {
/**
* The access_flags field of the JVMS ClassFile structure. This field can contain ASM specific
* access flags, such as {@link Opcodes#ACC_DEPRECATED} or {
}
@link Opcodes#ACC_RECORD}, which are
* access flags, such as {@link Opcodes#ACC_DEPRECATED} or {@link Opcodes#ACC_RECORD}, which are
* removed when generating the ClassFile structure.
*/
private
int
accessFlags
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录