FromSpecification.java revision 2454:f434ca8aface
1139823Simp/*
211819Sjulian * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3165899Srwatson * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4157128Srwatson *
5165899Srwatson * This code is free software; you can redistribute it and/or modify it
611819Sjulian * under the terms of the GNU General Public License version 2 only, as
711819Sjulian * published by the Free Software Foundation.
811819Sjulian *
911819Sjulian * This code is distributed in the hope that it will be useful, but WITHOUT
1011819Sjulian * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1111819Sjulian * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1211819Sjulian * version 2 for more details (a copy is included in the LICENSE file that
1311819Sjulian * accompanied this code).
1411819Sjulian *
15165899Srwatson * You should have received a copy of the GNU General Public License version
16165899Srwatson * 2 along with this work; if not, write to the Free Software Foundation,
17165899Srwatson * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18165899Srwatson *
19165899Srwatson * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20165899Srwatson * or visit www.oracle.com if you need additional information or have any
21165899Srwatson * questions.
22165899Srwatson */
23165899Srwatson
24165899Srwatsonimport static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
25165899Srwatson
26165899Srwatson/*
27165899Srwatson * @test
28165899Srwatson * @bug 8042451
29165899Srwatson * @summary Test that the examples from the manual are stored as expected
30165899Srwatson * @compile -g Driver.java ReferenceInfoUtil.java FromSpecification.java
31165899Srwatson * @run main Driver FromSpecification
32165899Srwatson */
33165899Srwatsonpublic class FromSpecification {
34165899Srwatson
35165899Srwatson    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
36165899Srwatson    @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
37165899Srwatson                genericLocation = {3, 0}, paramIndex = 0)
38165899Srwatson    @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
39165899Srwatson                genericLocation = {3, 0, 2, 0}, paramIndex = 0)
40165899Srwatson    @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
41165899Srwatson                genericLocation = {3, 1}, paramIndex = 0)
4211819Sjulian    @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
4311819Sjulian                genericLocation = {3, 1, 3, 0}, paramIndex = 0)
4411819Sjulian    public String testSpec1() {
4511819Sjulian        return "void test(@TA Map<@TB ? extends @TC String, @TD List<@TE Object>> a) { }";
4611819Sjulian    }
4711819Sjulian
4811819Sjulian    @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
4911819Sjulian    @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
5011819Sjulian                genericLocation = {0, 0}, paramIndex = 0)
5111819Sjulian    @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
5211819Sjulian                genericLocation = {0, 0, 0, 0}, paramIndex = 0)
5311819Sjulian    @TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
5411819Sjulian                genericLocation = {0, 0, 0, 0, 0, 0}, paramIndex = 0)
5511819Sjulian    public String testSpec2() {
5611819Sjulian        return "void test(@TI String @TF [] @TG [] @TH [] a) { }";
5711819Sjulian    }
5811819Sjulian
5911819Sjulian    // Note first "1, 0" for top-level class Test.
6011819Sjulian    @TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
6111819Sjulian                genericLocation = {1, 0, 1, 0, 1, 0, 1, 0}, paramIndex = 0)
6212057Sjulian    @TADescription(annotation = "TK", type = METHOD_FORMAL_PARAMETER,
6312057Sjulian                genericLocation = {1, 0, 1, 0, 1, 0}, paramIndex = 0)
6450477Speter    @TADescription(annotation = "TL", type = METHOD_FORMAL_PARAMETER,
6511819Sjulian                genericLocation = {1, 0, 1, 0}, paramIndex = 0)
6611819Sjulian    @TADescription(annotation = "TM", type = METHOD_FORMAL_PARAMETER,
6711819Sjulian                genericLocation = {1, 0}, paramIndex = 0)
6812470Sbde    public String testSpec3() {
6911819Sjulian        return "class %TEST_CLASS_NAME% { class O1 { class O2 { class O3 { class NestedStatic {} } } }" +
7011819Sjulian                "void test(@TM O1.@TL O2.@TK O3.@TJ NestedStatic a) { } }";
7111819Sjulian    }
7211819Sjulian
7311819Sjulian    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
74139444Srwatson    @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
7511819Sjulian                genericLocation = {3, 0}, paramIndex = 0)
7611819Sjulian    @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
7711819Sjulian                genericLocation = {3, 0, 3, 0}, paramIndex = 0)
7811819Sjulian    @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
7911819Sjulian                genericLocation = {3, 0, 3, 0, 0, 0}, paramIndex = 0)
8011819Sjulian    @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
8111819Sjulian                genericLocation = {3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0)
8211819Sjulian    @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
8311819Sjulian                genericLocation = {3, 0, 3, 0, 0, 0, 0, 0, 0, 0}, paramIndex = 0)
84139925Srwatson    @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
8511819Sjulian                genericLocation = {3, 1}, paramIndex = 0)
8611819Sjulian    @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
87139444Srwatson                genericLocation = {3, 1, 3, 0}, paramIndex = 0)
88139444Srwatson    public String testSpec4() {
89139444Srwatson        return "void test(@TA Map<@TB Comparable<@TF Object @TC [] @TD [] @TE []>, @TG List<@TH String>> a) { }";
90139444Srwatson    }
91139444Srwatson
92139444Srwatson    // Note first "1, 0" for top-level class Test.
93139444Srwatson    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
94139925Srwatson                genericLocation = {1, 0, 1, 0, 1, 0, 1, 0}, paramIndex = 0)
95139925Srwatson    @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
96139925Srwatson                genericLocation = {1, 0, 1, 0, 1, 0, 1, 0, 3, 0}, paramIndex = 0)
97139925Srwatson    @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
98157128Srwatson                genericLocation = {1, 0, 1, 0, 1, 0, 1, 0, 3, 1}, paramIndex = 0)
99157128Srwatson    @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
100157128Srwatson                genericLocation = {1, 0, 1, 0, 1, 0}, paramIndex = 0)
101157128Srwatson    @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
102157128Srwatson                genericLocation = {1, 0, 1, 0}, paramIndex = 0)
103157128Srwatson    @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
104157128Srwatson                genericLocation = {1, 0, 1, 0, 3, 0}, paramIndex = 0)
105157128Srwatson    @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
106157128Srwatson                genericLocation = {1, 0, 1, 0, 3, 1}, paramIndex = 0)
107157145Srwatson    @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
10811819Sjulian                genericLocation = {1, 0}, paramIndex = 0)
10925652Sjhay    public String testSpec5() {
11011819Sjulian        return "class %TEST_CLASS_NAME% { class O1 { class O2<A, B> { class O3 { class Nested<X, Y> {} } } }" +
11111819Sjulian                "void test(@TH O1.@TE O2<@TF String, @TG String>.@TD O3.@TA Nested<@TB String, @TC String> a) { } }";
11211819Sjulian    }
11311819Sjulian}
11411819Sjulian