Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
ae466267
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看板
提交
ae466267
编写于
5月 07, 2015
作者:
A
aeriksso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
Reviewed-by: coleenp, dsimms
上级
fb8902d7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
142 addition
and
21 deletion
+142
-21
src/share/vm/interpreter/linkResolver.cpp
src/share/vm/interpreter/linkResolver.cpp
+27
-21
test/runtime/invokedynamic/BootstrapMethodErrorTest.java
test/runtime/invokedynamic/BootstrapMethodErrorTest.java
+115
-0
未找到文件。
src/share/vm/interpreter/linkResolver.cpp
浏览文件 @
ae466267
...
...
@@ -1592,6 +1592,26 @@ void LinkResolver::resolve_handle_call(CallInfo& result, KlassHandle resolved_kl
result
.
set_handle
(
resolved_method
,
resolved_appendix
,
resolved_method_type
,
CHECK
);
}
static
void
wrap_invokedynamic_exception
(
TRAPS
)
{
if
(
HAS_PENDING_EXCEPTION
)
{
if
(
TraceMethodHandles
)
{
tty
->
print_cr
(
"invokedynamic throws BSME for "
INTPTR_FORMAT
,
p2i
((
void
*
)
PENDING_EXCEPTION
));
PENDING_EXCEPTION
->
print
();
}
if
(
PENDING_EXCEPTION
->
is_a
(
SystemDictionary
::
BootstrapMethodError_klass
()))
{
// throw these guys, since they are already wrapped
return
;
}
if
(
!
PENDING_EXCEPTION
->
is_a
(
SystemDictionary
::
LinkageError_klass
()))
{
// intercept only LinkageErrors which might have failed to wrap
return
;
}
// See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS.
Handle
nested_exception
(
THREAD
,
PENDING_EXCEPTION
);
CLEAR_PENDING_EXCEPTION
;
THROW_CAUSE
(
vmSymbols
::
java_lang_BootstrapMethodError
(),
nested_exception
)
}
}
void
LinkResolver
::
resolve_invokedynamic
(
CallInfo
&
result
,
constantPoolHandle
pool
,
int
index
,
TRAPS
)
{
assert
(
EnableInvokeDynamic
,
""
);
...
...
@@ -1607,7 +1627,8 @@ void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle po
ConstantPoolCacheEntry
*
cpce
=
pool
->
invokedynamic_cp_cache_entry_at
(
index
);
if
(
cpce
->
is_f1_null
())
{
int
pool_index
=
cpce
->
constant_pool_index
();
oop
bsm_info
=
pool
->
resolve_bootstrap_specifier_at
(
pool_index
,
CHECK
);
oop
bsm_info
=
pool
->
resolve_bootstrap_specifier_at
(
pool_index
,
THREAD
);
wrap_invokedynamic_exception
(
CHECK
);
assert
(
bsm_info
!=
NULL
,
""
);
// FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic.
bootstrap_specifier
=
Handle
(
THREAD
,
bsm_info
);
...
...
@@ -1616,7 +1637,8 @@ void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle po
methodHandle
method
(
THREAD
,
cpce
->
f1_as_method
());
Handle
appendix
(
THREAD
,
cpce
->
appendix_if_resolved
(
pool
));
Handle
method_type
(
THREAD
,
cpce
->
method_type_if_resolved
(
pool
));
result
.
set_handle
(
method
,
appendix
,
method_type
,
CHECK
);
result
.
set_handle
(
method
,
appendix
,
method_type
,
THREAD
);
wrap_invokedynamic_exception
(
CHECK
);
return
;
}
...
...
@@ -1647,25 +1669,9 @@ void LinkResolver::resolve_dynamic_call(CallInfo& result,
&
resolved_appendix
,
&
resolved_method_type
,
THREAD
);
if
(
HAS_PENDING_EXCEPTION
)
{
if
(
TraceMethodHandles
)
{
tty
->
print_cr
(
"invokedynamic throws BSME for "
INTPTR_FORMAT
,
p2i
((
void
*
)
PENDING_EXCEPTION
));
PENDING_EXCEPTION
->
print
();
}
if
(
PENDING_EXCEPTION
->
is_a
(
SystemDictionary
::
BootstrapMethodError_klass
()))
{
// throw these guys, since they are already wrapped
return
;
}
if
(
!
PENDING_EXCEPTION
->
is_a
(
SystemDictionary
::
LinkageError_klass
()))
{
// intercept only LinkageErrors which might have failed to wrap
return
;
}
// See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS.
Handle
nested_exception
(
THREAD
,
PENDING_EXCEPTION
);
CLEAR_PENDING_EXCEPTION
;
THROW_CAUSE
(
vmSymbols
::
java_lang_BootstrapMethodError
(),
nested_exception
)
}
result
.
set_handle
(
resolved_method
,
resolved_appendix
,
resolved_method_type
,
CHECK
);
wrap_invokedynamic_exception
(
CHECK
);
result
.
set_handle
(
resolved_method
,
resolved_appendix
,
resolved_method_type
,
THREAD
);
wrap_invokedynamic_exception
(
CHECK
);
}
//------------------------------------------------------------------------------------------------------------------------
...
...
test/runtime/invokedynamic/BootstrapMethodErrorTest.java
0 → 100644
浏览文件 @
ae466267
/*
* Copyright (c) 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 8051045
* @summary Test that exceptions from invokedynamic are wrapped in BootstrapMethodError
* @modules java.base/jdk.internal.org.objectweb.asm
* @run main BootstrapMethodErrorTest
*/
import
java.lang.reflect.Method
;
import
java.lang.invoke.MethodHandle
;
import
java.lang.invoke.MethodHandles
;
import
static
java
.
lang
.
invoke
.
MethodHandles
.*;
import
static
java
.
lang
.
invoke
.
MethodType
.*;
import
jdk.internal.org.objectweb.asm.ClassWriter
;
import
jdk.internal.org.objectweb.asm.Handle
;
import
jdk.internal.org.objectweb.asm.MethodVisitor
;
import
jdk.internal.org.objectweb.asm.Opcodes
;
public
class
BootstrapMethodErrorTest
extends
ClassLoader
implements
Opcodes
{
@Override
public
Class
findClass
(
String
name
)
throws
ClassNotFoundException
{
byte
[]
b
;
try
{
b
=
loadClassData
(
name
);
}
catch
(
Throwable
th
)
{
throw
new
ClassNotFoundException
(
"Loading error"
,
th
);
}
return
defineClass
(
name
,
b
,
0
,
b
.
length
);
}
private
byte
[]
loadClassData
(
String
name
)
throws
Exception
{
ClassWriter
cw
=
new
ClassWriter
(
0
);
MethodVisitor
mv
;
if
(
name
.
equals
(
"C"
))
{
cw
.
visit
(
52
,
ACC_SUPER
|
ACC_PUBLIC
,
"C"
,
null
,
"java/lang/Object"
,
null
);
{
mv
=
cw
.
visitMethod
(
ACC_PRIVATE
|
ACC_STATIC
,
"m"
,
"()V"
,
null
,
null
);
mv
.
visitCode
();
mv
.
visitInsn
(
RETURN
);
mv
.
visitMaxs
(
0
,
1
);
mv
.
visitEnd
();
}
cw
.
visitEnd
();
return
cw
.
toByteArray
();
}
else
if
(
name
.
equals
(
"Exec"
))
{
cw
.
visit
(
52
,
ACC_SUPER
|
ACC_PUBLIC
,
"Exec"
,
null
,
"java/lang/Object"
,
null
);
{
mv
=
cw
.
visitMethod
(
ACC_PUBLIC
|
ACC_STATIC
,
"invokeRef"
,
"()V"
,
null
,
null
);
mv
.
visitCode
();
Handle
h
=
new
Handle
(
H_INVOKESTATIC
,
"C"
,
"m"
,
"()V"
);
mv
.
visitInvokeDynamicInsn
(
"C"
,
"()V"
,
h
);
mv
.
visitInsn
(
RETURN
);
mv
.
visitMaxs
(
0
,
0
);
mv
.
visitEnd
();
}
cw
.
visitEnd
();
return
cw
.
toByteArray
();
}
return
null
;
}
public
static
void
main
(
String
[]
args
)
throws
ClassNotFoundException
,
IllegalAccessException
,
NoSuchMethodException
{
new
BootstrapMethodErrorTest
().
test
();
}
public
void
test
()
throws
ClassNotFoundException
,
IllegalAccessException
,
NoSuchMethodException
{
Class
.
forName
(
"C"
,
true
,
this
);
Class
<?>
exec
=
Class
.
forName
(
"Exec"
,
true
,
this
);
try
{
exec
.
getMethod
(
"invokeRef"
).
invoke
(
null
);
}
catch
(
Throwable
e
)
{
Throwable
c
=
e
.
getCause
();
if
(
c
==
null
)
{
throw
new
RuntimeException
(
"Expected BootstrapMethodError wrapped in an InvocationTargetException but it wasn't wrapped"
,
e
);
}
else
if
(
c
instanceof
BootstrapMethodError
)
{
// Only way to pass test, all else should throw
return
;
}
else
{
throw
new
RuntimeException
(
"Expected BootstrapMethodError but got another Error: "
+
c
.
getClass
().
getName
(),
c
);
}
}
throw
new
RuntimeException
(
"Expected BootstrapMethodError but no Error at all was thrown"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录