提交 f0b26d3f 编写于 作者: R rbackman

8014709: Constructor.getAnnotatedReturnType() returns empty AnnotatedType

Reviewed-by: stefank, rbackman
Contributed-by: NJoel Borggren-Franck <joel.franck@oracle.com>
上级 52f3b854
...@@ -817,6 +817,10 @@ oop Reflection::new_constructor(methodHandle method, TRAPS) { ...@@ -817,6 +817,10 @@ oop Reflection::new_constructor(methodHandle method, TRAPS) {
typeArrayOop an_oop = Annotations::make_java_array(method->parameter_annotations(), CHECK_NULL); typeArrayOop an_oop = Annotations::make_java_array(method->parameter_annotations(), CHECK_NULL);
java_lang_reflect_Constructor::set_parameter_annotations(ch(), an_oop); java_lang_reflect_Constructor::set_parameter_annotations(ch(), an_oop);
} }
if (java_lang_reflect_Constructor::has_type_annotations_field()) {
typeArrayOop an_oop = Annotations::make_java_array(method->type_annotations(), CHECK_NULL);
java_lang_reflect_Constructor::set_type_annotations(ch(), an_oop);
}
return ch(); return ch();
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8007320 * @bug 8007320 8014709
* @summary Test all optional fields in ConstMethod * @summary Test all optional fields in ConstMethod
* @compile -g -parameters ConstMethodTest.java * @compile -g -parameters ConstMethodTest.java
* @run main ConstMethodTest * @run main ConstMethodTest
...@@ -74,6 +74,11 @@ class OkException extends RuntimeException {}; ...@@ -74,6 +74,11 @@ class OkException extends RuntimeException {};
@MyAnnotation(name="someName", value = "Hello World") @MyAnnotation(name="someName", value = "Hello World")
public class ConstMethodTest { public class ConstMethodTest {
public @TypeAnno("constructor") ConstMethodTest() { }
public ConstMethodTest(int i) {
// needs a second unannotated constructor
}
private static void check(boolean b) { private static void check(boolean b) {
if (!b) if (!b)
...@@ -139,10 +144,26 @@ public class ConstMethodTest { ...@@ -139,10 +144,26 @@ public class ConstMethodTest {
} }
} }
private static void testConstructor() throws Exception {
for (Constructor c : ConstMethodTest.class.getDeclaredConstructors()) {
Annotation[] aa = c.getAnnotatedReturnType().getAnnotations();
if (c.getParameterTypes().length == 1) { // should be un-annotated
check(aa.length == 0);
} else if (c.getParameterTypes().length == 0) { //should be annotated
check(aa.length == 1);
check(((TypeAnno)aa[0]).value().equals("constructor"));
} else {
//should not happen
check(false);
}
}
}
public static void main(java.lang.String[] unused) throws Throwable { public static void main(java.lang.String[] unused) throws Throwable {
// pass 5 so kitchenSinkFunc is instantiated with an int // pass 5 so kitchenSinkFunc is instantiated with an int
kitchenSinkFunc("parameter", "param2", 5); kitchenSinkFunc("parameter", "param2", 5);
test1(); test1();
testConstructor();
} }
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册