Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e4b8584e
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e4b8584e
编写于
4月 02, 2013
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8004979: java.lang.reflect.Modifier.toString should include "default"
Reviewed-by: mduigou
上级
5eaeff5d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
68 addition
and
11 deletion
+68
-11
src/share/classes/java/lang/reflect/Constructor.java
src/share/classes/java/lang/reflect/Constructor.java
+6
-1
src/share/classes/java/lang/reflect/Executable.java
src/share/classes/java/lang/reflect/Executable.java
+16
-5
src/share/classes/java/lang/reflect/Field.java
src/share/classes/java/lang/reflect/Field.java
+4
-0
src/share/classes/java/lang/reflect/Method.java
src/share/classes/java/lang/reflect/Method.java
+12
-3
src/share/classes/java/lang/reflect/Modifier.java
src/share/classes/java/lang/reflect/Modifier.java
+6
-0
test/java/lang/reflect/Method/GenericStringTest.java
test/java/lang/reflect/Method/GenericStringTest.java
+24
-2
未找到文件。
src/share/classes/java/lang/reflect/Constructor.java
浏览文件 @
e4b8584e
...
...
@@ -284,9 +284,13 @@ public final class Constructor<T> extends Executable {
* modifiers {@code public}, {@code protected} or
* {@code private}. Only one of these may appear, or none if the
* constructor has default (package) access.
*
* @return a string describing this {@code Constructor}
* @jls 8.8.3. Constructor Modifiers
*/
public
String
toString
()
{
return
sharedToString
(
Modifier
.
constructorModifiers
(),
false
,
parameterTypes
,
exceptionTypes
);
}
...
...
@@ -328,10 +332,11 @@ public final class Constructor<T> extends Executable {
* include type parameters
*
* @since 1.5
* @jls 8.8.3. Constructor Modifiers
*/
@Override
public
String
toGenericString
()
{
return
sharedToGenericString
(
Modifier
.
constructorModifiers
());
return
sharedToGenericString
(
Modifier
.
constructorModifiers
()
,
false
);
}
@Override
...
...
src/share/classes/java/lang/reflect/Executable.java
浏览文件 @
e4b8584e
...
...
@@ -89,20 +89,31 @@ public abstract class Executable extends AccessibleObject
}
void
printModifiersIfNonzero
(
StringBuilder
sb
,
int
mask
)
{
void
printModifiersIfNonzero
(
StringBuilder
sb
,
int
mask
,
boolean
isDefault
)
{
int
mod
=
getModifiers
()
&
mask
;
if
(
mod
!=
0
)
{
if
(
mod
!=
0
&&
!
isDefault
)
{
sb
.
append
(
Modifier
.
toString
(
mod
)).
append
(
' '
);
}
else
{
int
access_mod
=
mod
&
Modifier
.
ACCESS_MODIFIERS
;
if
(
access_mod
!=
0
)
sb
.
append
(
Modifier
.
toString
(
access_mod
)).
append
(
' '
);
if
(
isDefault
)
sb
.
append
(
"default "
);
mod
=
(
mod
&
~
Modifier
.
ACCESS_MODIFIERS
);
if
(
mod
!=
0
)
sb
.
append
(
Modifier
.
toString
(
mod
)).
append
(
' '
);
}
}
String
sharedToString
(
int
modifierMask
,
boolean
isDefault
,
Class
<?>[]
parameterTypes
,
Class
<?>[]
exceptionTypes
)
{
try
{
StringBuilder
sb
=
new
StringBuilder
();
printModifiersIfNonzero
(
sb
,
modifierMask
);
printModifiersIfNonzero
(
sb
,
modifierMask
,
isDefault
);
specificToStringHeader
(
sb
);
sb
.
append
(
'('
);
...
...
@@ -124,11 +135,11 @@ public abstract class Executable extends AccessibleObject
*/
abstract
void
specificToStringHeader
(
StringBuilder
sb
);
String
sharedToGenericString
(
int
modifierMask
)
{
String
sharedToGenericString
(
int
modifierMask
,
boolean
isDefault
)
{
try
{
StringBuilder
sb
=
new
StringBuilder
();
printModifiersIfNonzero
(
sb
,
modifierMask
);
printModifiersIfNonzero
(
sb
,
modifierMask
,
isDefault
);
TypeVariable
<?>[]
typeparms
=
getTypeParameters
();
if
(
typeparms
.
length
>
0
)
{
...
...
src/share/classes/java/lang/reflect/Field.java
浏览文件 @
e4b8584e
...
...
@@ -288,6 +288,9 @@ class Field extends AccessibleObject implements Member {
* {@code protected} or {@code private} first, and then other
* modifiers in the following order: {@code static}, {@code final},
* {@code transient}, {@code volatile}.
*
* @return a string describing this {@code Field}
* @jls 8.3.1 Field Modifiers
*/
public
String
toString
()
{
int
mod
=
getModifiers
();
...
...
@@ -315,6 +318,7 @@ class Field extends AccessibleObject implements Member {
* its generic type
*
* @since 1.5
* @jls 8.3.1 Field Modifiers
*/
public
String
toGenericString
()
{
int
mod
=
getModifiers
();
...
...
src/share/classes/java/lang/reflect/Method.java
浏览文件 @
e4b8584e
...
...
@@ -343,10 +343,16 @@ public final class Method extends Executable {
* {@code public}, {@code protected} or {@code private} first,
* and then other modifiers in the following order:
* {@code abstract}, {@code static}, {@code final},
* {@code synchronized}, {@code native}, {@code strictfp}.
* {@code synchronized}, {@code native}, {@code strictfp},
* {@code default}.
*
* @return a string describing this {@code Method}
*
* @jls 8.4.3 Method Modifiers
*/
public
String
toString
()
{
return
sharedToString
(
Modifier
.
methodModifiers
(),
isDefault
(),
parameterTypes
,
exceptionTypes
);
}
...
...
@@ -389,16 +395,19 @@ public final class Method extends Executable {
* {@code public}, {@code protected} or {@code private} first,
* and then other modifiers in the following order:
* {@code abstract}, {@code static}, {@code final},
* {@code synchronized}, {@code native}, {@code strictfp}.
* {@code synchronized}, {@code native}, {@code strictfp},
* {@code default}.
*
* @return a string describing this {@code Method},
* include type parameters
*
* @since 1.5
*
* @jls 8.4.3 Method Modifiers
*/
@Override
public
String
toGenericString
()
{
return
sharedToGenericString
(
Modifier
.
methodModifiers
());
return
sharedToGenericString
(
Modifier
.
methodModifiers
()
,
isDefault
()
);
}
@Override
...
...
src/share/classes/java/lang/reflect/Modifier.java
浏览文件 @
e4b8584e
...
...
@@ -389,6 +389,12 @@ class Modifier {
Modifier
.
STATIC
|
Modifier
.
FINAL
|
Modifier
.
TRANSIENT
|
Modifier
.
VOLATILE
;
/**
*
*/
static
final
int
ACCESS_MODIFIERS
=
Modifier
.
PUBLIC
|
Modifier
.
PROTECTED
|
Modifier
.
PRIVATE
;
/**
* Return an {@code int} value OR-ing together the source language
* modifiers that can be applied to a class.
...
...
test/java/lang/reflect/Method/GenericStringTest.java
浏览文件 @
e4b8584e
/*
* Copyright (c) 2004, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 20
13
, 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
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 5033583 6316717 6470106
* @bug 5033583 6316717 6470106
8004979
* @summary Check toGenericString() and toString() methods
* @author Joseph D. Darcy
*/
...
...
@@ -39,6 +39,7 @@ public class GenericStringTest {
classList
.
add
(
TestClass1
.
class
);
classList
.
add
(
TestClass2
.
class
);
classList
.
add
(
Roebling
.
class
);
classList
.
add
(
TestInterface1
.
class
);
for
(
Class
<?>
clazz:
classList
)
...
...
@@ -129,6 +130,27 @@ class Roebling implements Comparable<Roebling> {
void
varArg
(
Object
...
arg
)
{}
}
interface
TestInterface1
{
@ExpectedGenericString
(
"public default void TestInterface1.foo()"
)
@ExpectedString
(
"public default void TestInterface1.foo()"
)
public
default
void
foo
(){;}
@ExpectedString
(
"public default java.lang.Object TestInterface1.bar()"
)
@ExpectedGenericString
(
"public default <A> A TestInterface1.bar()"
)
default
<
A
>
A
bar
(){
return
null
;}
@ExpectedString
(
"public default strictfp double TestInterface1.quux()"
)
@ExpectedGenericString
(
"public default strictfp double TestInterface1.quux()"
)
strictfp
default
double
quux
(){
return
1.0
;}
}
@Retention
(
RetentionPolicy
.
RUNTIME
)
@interface
ExpectedGenericString
{
String
value
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录