8014709: Constructor.getAnnotatedReturnType() returns empty AnnotatedType

Reviewed-by: stefank, rbackman
This commit is contained in:
Joel Borggren-Franck 2013-05-31 13:02:24 +02:00 committed by Rickard Bäckman
parent a246da16d1
commit 6d51346158
2 changed files with 26 additions and 1 deletions

View File

@ -817,6 +817,10 @@ oop Reflection::new_constructor(methodHandle method, TRAPS) {
typeArrayOop an_oop = Annotations::make_java_array(method->parameter_annotations(), CHECK_NULL);
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();
}

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8007320
* @bug 8007320 8014709
* @summary Test all optional fields in ConstMethod
* @compile -g -parameters ConstMethodTest.java
* @run main ConstMethodTest
@ -74,6 +74,11 @@ class OkException extends RuntimeException {};
@MyAnnotation(name="someName", value = "Hello World")
public class ConstMethodTest {
public @TypeAnno("constructor") ConstMethodTest() { }
public ConstMethodTest(int i) {
// needs a second unannotated constructor
}
private static void check(boolean b) {
if (!b)
@ -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 {
// pass 5 so kitchenSinkFunc is instantiated with an int
kitchenSinkFunc("parameter", "param2", 5);
test1();
testConstructor();
}
};