Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
9161eb5e
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9161eb5e
编写于
6月 16, 2015
作者:
A
aeriksso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8076110: VM crash when class is redefined with Instrumentation.redefineClasses
Reviewed-by: coleenp, sspitsyn
上级
a3753ee9
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
146 addition
and
3 deletion
+146
-3
src/share/vm/oops/instanceKlass.cpp
src/share/vm/oops/instanceKlass.cpp
+3
-0
src/share/vm/prims/jvmtiRedefineClasses.cpp
src/share/vm/prims/jvmtiRedefineClasses.cpp
+0
-3
test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java
...fineTests/RedefineRunningMethodsWithResolutionErrors.java
+143
-0
未找到文件。
src/share/vm/oops/instanceKlass.cpp
浏览文件 @
9161eb5e
...
...
@@ -439,6 +439,9 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
if
(
!
constants
()
->
is_shared
())
{
MetadataFactory
::
free_metadata
(
loader_data
,
constants
());
}
// Delete any cached resolution errors for the constant pool
SystemDictionary
::
delete_resolution_error
(
constants
());
set_constants
(
NULL
);
}
...
...
src/share/vm/prims/jvmtiRedefineClasses.cpp
浏览文件 @
9161eb5e
...
...
@@ -4071,9 +4071,6 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass,
mnt
->
adjust_method_entries
(
the_class
(),
&
trace_name_printed
);
}
// Fix Resolution Error table also to remove old constant pools
SystemDictionary
::
delete_resolution_error
(
old_constants
);
if
(
the_class
->
oop_map_cache
()
!=
NULL
)
{
// Flush references to any obsolete methods from the oop map cache
// so that obsolete methods are not pinned.
...
...
test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java
0 → 100644
浏览文件 @
9161eb5e
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8076110
* @summary Redefine running methods that have cached resolution errors
* @library /testlibrary
* @modules java.instrument
* java.base/jdk.internal.org.objectweb.asm
* @build RedefineClassHelper
* @run main RedefineClassHelper
* @run main/othervm -javaagent:redefineagent.jar -XX:TraceRedefineClasses=0x600 RedefineRunningMethodsWithResolutionErrors
*/
import
jdk.internal.org.objectweb.asm.ClassWriter
;
import
jdk.internal.org.objectweb.asm.Label
;
import
jdk.internal.org.objectweb.asm.MethodVisitor
;
import
jdk.internal.org.objectweb.asm.Opcodes
;
import
java.lang.reflect.InvocationTargetException
;
public
class
RedefineRunningMethodsWithResolutionErrors
extends
ClassLoader
implements
Opcodes
{
@Override
protected
Class
<?>
findClass
(
String
name
)
throws
ClassNotFoundException
{
if
(
name
.
equals
(
"C"
))
{
byte
[]
b
=
loadC
(
false
);
return
defineClass
(
name
,
b
,
0
,
b
.
length
);
}
else
{
return
super
.
findClass
(
name
);
}
}
private
static
byte
[]
loadC
(
boolean
redefine
)
{
ClassWriter
cw
=
new
ClassWriter
(
0
);
cw
.
visit
(
52
,
ACC_SUPER
|
ACC_PUBLIC
,
"C"
,
null
,
"java/lang/Object"
,
null
);
{
MethodVisitor
mv
;
mv
=
cw
.
visitMethod
(
ACC_PUBLIC
|
ACC_STATIC
,
"m"
,
"()V"
,
null
,
null
);
mv
.
visitCode
();
// First time we run we will:
// 1) Cache resolution errors
// 2) Redefine the class / method
// 3) Try to read the resolution errors that were cached
//
// The redefined method will never run, throw error to be sure
if
(
redefine
)
{
createThrowRuntimeExceptionCode
(
mv
,
"The redefined method was called"
);
}
else
{
createMethodBody
(
mv
);
}
mv
.
visitMaxs
(
3
,
0
);
mv
.
visitEnd
();
}
cw
.
visitEnd
();
return
cw
.
toByteArray
();
}
private
static
void
createMethodBody
(
MethodVisitor
mv
)
{
Label
classExists
=
new
Label
();
// Cache resolution errors
createLoadNonExistentClassCode
(
mv
,
classExists
);
// Redefine our own class and method
mv
.
visitMethodInsn
(
INVOKESTATIC
,
"RedefineRunningMethodsWithResolutionErrors"
,
"redefine"
,
"()V"
);
// Provoke the same error again to make sure the resolution error cache works
createLoadNonExistentClassCode
(
mv
,
classExists
);
// Test passed
mv
.
visitInsn
(
RETURN
);
mv
.
visitFrame
(
F_SAME
,
0
,
new
Object
[
0
],
0
,
new
Object
[
0
]);
mv
.
visitLabel
(
classExists
);
createThrowRuntimeExceptionCode
(
mv
,
"Loaded class that shouldn't exist (\"NonExistentClass\")"
);
}
private
static
void
createLoadNonExistentClassCode
(
MethodVisitor
mv
,
Label
classExists
)
{
Label
tryLoadBegin
=
new
Label
();
Label
tryLoadEnd
=
new
Label
();
Label
catchLoadBlock
=
new
Label
();
mv
.
visitTryCatchBlock
(
tryLoadBegin
,
tryLoadEnd
,
catchLoadBlock
,
"java/lang/NoClassDefFoundError"
);
// Try to load a class that does not exist to provoke resolution errors
mv
.
visitLabel
(
tryLoadBegin
);
mv
.
visitMethodInsn
(
INVOKESTATIC
,
"NonExistentClass"
,
"nonExistentMethod"
,
"()V"
);
mv
.
visitLabel
(
tryLoadEnd
);
// No NoClassDefFoundError means NonExistentClass existed, which shouldn't happen
mv
.
visitJumpInsn
(
GOTO
,
classExists
);
mv
.
visitFrame
(
F_SAME1
,
0
,
new
Object
[
0
],
1
,
new
Object
[]
{
"java/lang/NoClassDefFoundError"
});
mv
.
visitLabel
(
catchLoadBlock
);
// Ignore the expected NoClassDefFoundError
mv
.
visitInsn
(
POP
);
}
private
static
void
createThrowRuntimeExceptionCode
(
MethodVisitor
mv
,
String
msg
)
{
mv
.
visitTypeInsn
(
NEW
,
"java/lang/RuntimeException"
);
mv
.
visitInsn
(
DUP
);
mv
.
visitLdcInsn
(
msg
);
mv
.
visitMethodInsn
(
INVOKESPECIAL
,
"java/lang/RuntimeException"
,
"<init>"
,
"(Ljava/lang/String;)V"
);
mv
.
visitInsn
(
ATHROW
);
}
private
static
Class
<?>
c
;
public
static
void
redefine
()
throws
Exception
{
RedefineClassHelper
.
redefineClass
(
c
,
loadC
(
true
));
}
public
static
void
main
(
String
[]
args
)
throws
ClassNotFoundException
,
NoSuchMethodException
,
IllegalAccessException
,
InvocationTargetException
{
c
=
Class
.
forName
(
"C"
,
true
,
new
RedefineRunningMethodsWithResolutionErrors
());
c
.
getMethod
(
"m"
).
invoke
(
null
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录