# HG changeset patch # User rbackman # Date 1369998144 -7200 # Node ID a589c78a88116024b0dda28d4dd73a0a2ec44f19 # Parent fe00365c8f31c428d5bea2b5c89b8e8601c87a58 8014709: Constructor.getAnnotatedReturnType() returns empty AnnotatedType Reviewed-by: stefank, rbackman Contributed-by: Joel Borggren-Franck diff -r fe00365c8f31 -r a589c78a8811 src/share/vm/runtime/reflection.cpp --- a/src/share/vm/runtime/reflection.cpp Thu May 30 11:46:39 2013 -0700 +++ b/src/share/vm/runtime/reflection.cpp Fri May 31 13:02:24 2013 +0200 @@ -817,6 +817,10 @@ 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(); } diff -r fe00365c8f31 -r a589c78a8811 test/runtime/8007320/ConstMethodTest.java --- a/test/runtime/8007320/ConstMethodTest.java Thu May 30 11:46:39 2013 -0700 +++ b/test/runtime/8007320/ConstMethodTest.java Fri May 31 13:02:24 2013 +0200 @@ -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 @@ @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 @@ } } + 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(); } };