test/jdk/java/lang/annotation/AnnotationToStringTest.java
author darcy
Thu, 13 Jun 2019 11:50:45 -0700
changeset 55387 761b86d5563d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8164819: Make javac's toString() on annotation objects consistent with core reflection Reviewed-by: jjg, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
     1
/*
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
     4
 *
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
     8
 *
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    13
 * accompanied this code).
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    14
 *
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    18
 *
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    21
 * questions.
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    22
 */
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    23
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    24
/*
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    25
 * @test
41882
0549e50db4bf 8168921: Inconsistent Annotation.toString()
igerasim
parents: 40116
diff changeset
    26
 * @bug 8162817 8168921
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    27
 * @summary Test of toString on normal annotations
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    28
 */
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    29
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    30
// See also the sibling compile-time test
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    31
// test/langtools/tools/javac/processing/model/element/AnnotationToStringTest.java
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    32
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    33
import java.lang.annotation.*;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    34
import java.lang.reflect.*;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    35
import java.util.*;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    36
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    37
/**
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    38
 * The expected string values are stored in @ExpectedString
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    39
 * annotations. The essence of the test is comparing the toString()
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    40
 * result of annotations to the corresponding ExpectedString.value().
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    41
 */
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    42
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    43
public class AnnotationToStringTest {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    44
    public static void main(String... args) throws Exception {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    45
        int failures = 0;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    46
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    47
        failures += check(PrimHost.class.getAnnotation(ExpectedString.class).value(),
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    48
                          PrimHost.class.getAnnotation(MostlyPrimitive.class).toString());
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    49
        failures += classyTest();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    50
        failures += arrayAnnotationTest();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    51
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    52
        if (failures > 0)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    53
            throw new RuntimeException(failures + " failures");
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    54
    }
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    55
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    56
    private static int check(String expected, String actual) {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    57
        if (!expected.equals(actual)) {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    58
            System.err.printf("ERROR: Expected ''%s'';%ngot             ''%s''.\n",
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    59
                              expected, actual);
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    60
            return 1;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    61
        } else
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    62
            return 0;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    63
    }
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    64
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    65
    @ExpectedString(
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    66
        "@MostlyPrimitive(c0='a', "+
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    67
        "c1='\\'', " +
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    68
        "b0=(byte)0x01, " +
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    69
        "i0=1, " +
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    70
        "i1=2, " +
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    71
        "f0=1.0f, " +
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    72
        "f1=0.0f/0.0f, " +
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    73
        "d0=0.0, " +
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    74
        "d1=1.0/0.0, " +
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    75
        "l0=5L, " +
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    76
        "l1=9223372036854775807L, " +
41882
0549e50db4bf 8168921: Inconsistent Annotation.toString()
igerasim
parents: 40116
diff changeset
    77
        "l2=-9223372036854775808L, " +
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    78
        "l3=-2147483648L, " +
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    79
        "s0=\"Hello world.\", " +
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    80
        "s1=\"a\\\"b\", " +
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    81
        "class0=Obj[].class, " +
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    82
        "classArray={Obj[].class})")
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    83
    @MostlyPrimitive(
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    84
        c0='a',
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    85
        c1='\'',
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    86
        b0=1,
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    87
        i0=1,
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    88
        i1=2,
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    89
        f0=1.0f,
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    90
        f1=Float.NaN,
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    91
        d0=0.0,
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    92
        d1=2.0/0.0,
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    93
        l0=5,
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    94
        l1=Long.MAX_VALUE,
41882
0549e50db4bf 8168921: Inconsistent Annotation.toString()
igerasim
parents: 40116
diff changeset
    95
        l2=Long.MIN_VALUE,
0549e50db4bf 8168921: Inconsistent Annotation.toString()
igerasim
parents: 40116
diff changeset
    96
        l3=Integer.MIN_VALUE,
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    97
        s0="Hello world.",
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
    98
        s1="a\"b",
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
    99
        class0=Obj[].class,
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   100
        classArray={Obj[].class}
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   101
    )
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   102
    static class PrimHost{}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   103
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   104
    private static int classyTest() {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   105
        int failures = 0;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   106
        for (Field f : AnnotationHost.class.getFields()) {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   107
            Annotation a = f.getAnnotation(Classy.class);
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   108
            System.out.println(a);
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   109
            failures += check(f.getAnnotation(ExpectedString.class).value(),
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   110
                              a.toString());
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   111
        }
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   112
        return failures;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   113
    }
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   114
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   115
    static class AnnotationHost {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   116
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   117
       "@Classy(Obj.class)")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   118
        @Classy(Obj.class)
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   119
        public int f0;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   120
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   121
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   122
       "@Classy(Obj[].class)")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   123
        @Classy(Obj[].class)
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   124
        public int f1;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   125
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   126
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   127
       "@Classy(Obj[][].class)")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   128
        @Classy(Obj[][].class)
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   129
        public int f2;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   130
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   131
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   132
       "@Classy(Obj[][][].class)")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   133
        @Classy(Obj[][][].class)
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   134
        public int f3;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   135
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   136
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   137
       "@Classy(int.class)")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   138
        @Classy(int.class)
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   139
        public int f4;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   140
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   141
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   142
       "@Classy(int[][][].class)")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   143
        @Classy(int[][][].class)
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   144
        public int f5;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   145
    }
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   146
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   147
    /**
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   148
     * Each field should have two annotations, the first being
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   149
     * @ExpectedString and the second the annotation under test.
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   150
     */
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   151
    private static int arrayAnnotationTest() {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   152
        int failures = 0;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   153
        for (Field f : ArrayAnnotationHost.class.getFields()) {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   154
            Annotation[] annotations = f.getAnnotations();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   155
            System.out.println(annotations[1]);
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   156
            failures += check(((ExpectedString)annotations[0]).value(),
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   157
                              annotations[1].toString());
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   158
        }
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   159
        return failures;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   160
    }
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   161
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   162
    static class ArrayAnnotationHost {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   163
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   164
       "@BooleanArray({true, false, true})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   165
        @BooleanArray({true, false, true})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   166
        public boolean[]   f0;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   167
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   168
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   169
       "@FloatArray({3.0f, 4.0f, 0.0f/0.0f, -1.0f/0.0f, 1.0f/0.0f})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   170
        @FloatArray({3.0f, 4.0f, Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   171
        public float[]     f1;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   172
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   173
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   174
       "@DoubleArray({1.0, 2.0, 0.0/0.0, 1.0/0.0, -1.0/0.0})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   175
        @DoubleArray({1.0, 2.0, Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   176
        public double[]    f2;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   177
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   178
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   179
       "@ByteArray({(byte)0x0a, (byte)0x0b, (byte)0x0c})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   180
        @ByteArray({10, 11, 12})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   181
        public byte[]      f3;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   182
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   183
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   184
       "@ShortArray({0, 4, 5})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   185
        @ShortArray({0, 4, 5})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   186
        public short[]     f4;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   187
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   188
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   189
       "@CharArray({'a', 'b', 'c', '\\''})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   190
        @CharArray({'a', 'b', 'c', '\''})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   191
        public char[]      f5;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   192
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   193
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   194
       "@IntArray({1})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   195
        @IntArray({1})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   196
        public int[]       f6;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   197
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   198
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   199
       "@LongArray({-9223372036854775808L, -2147483649L, -2147483648L," +
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   200
                " -2147483647L, 2147483648L, 9223372036854775807L})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   201
        @LongArray({Long.MIN_VALUE, Integer.MIN_VALUE-1L, Integer.MIN_VALUE,
41882
0549e50db4bf 8168921: Inconsistent Annotation.toString()
igerasim
parents: 40116
diff changeset
   202
                -Integer.MAX_VALUE, Integer.MAX_VALUE+1L, Long.MAX_VALUE})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   203
        public long[]      f7;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   204
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   205
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   206
       "@StringArray({\"A\", \"B\", \"C\", \"\\\"Quote\\\"\"})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   207
        @StringArray({"A", "B", "C", "\"Quote\""})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   208
        public String[]    f8;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   209
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   210
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   211
       "@ClassArray({int.class, Obj[].class})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   212
        @ClassArray({int.class, Obj[].class})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   213
        public Class<?>[]  f9;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   214
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   215
        @ExpectedString(
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   216
       "@EnumArray({SOURCE})")
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   217
        @EnumArray({RetentionPolicy.SOURCE})
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   218
        public RetentionPolicy[]  f10;
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   219
    }
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   220
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   221
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   222
// ------------ Supporting types ------------
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   223
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   224
class Obj {}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   225
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   226
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   227
@interface ExpectedString {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   228
    String value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   229
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   230
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   231
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   232
@interface Classy {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   233
    Class<?> value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   234
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   235
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   236
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   237
@interface BooleanArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   238
    boolean[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   239
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   240
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   241
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   242
@interface FloatArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   243
    float[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   244
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   245
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   246
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   247
@interface DoubleArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   248
    double[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   249
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   250
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   251
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   252
@interface ByteArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   253
    byte[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   254
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   255
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   256
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   257
@interface ShortArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   258
    short[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   259
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   260
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   261
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   262
@interface CharArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   263
    char[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   264
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   265
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   266
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   267
@interface IntArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   268
    int[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   269
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   270
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   271
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   272
@interface LongArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   273
    long[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   274
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   275
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   276
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   277
@interface ClassArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   278
    Class<?>[] value() default {int.class, Obj[].class};
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   279
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   280
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   281
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   282
@interface StringArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   283
    String[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   284
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   285
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   286
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   287
@interface EnumArray {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   288
    RetentionPolicy[] value();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   289
}
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   290
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   291
@Retention(RetentionPolicy.RUNTIME)
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   292
@interface MostlyPrimitive {
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   293
    char   c0();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   294
    char   c1();
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   295
    byte   b0();
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   296
    int    i0();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   297
    int    i1();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   298
    float  f0();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   299
    float  f1();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   300
    double d0();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   301
    double d1();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   302
    long   l0();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   303
    long   l1();
41882
0549e50db4bf 8168921: Inconsistent Annotation.toString()
igerasim
parents: 40116
diff changeset
   304
    long   l2();
0549e50db4bf 8168921: Inconsistent Annotation.toString()
igerasim
parents: 40116
diff changeset
   305
    long   l3();
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   306
    String s0();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   307
    String s1();
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   308
    Class<?> class0();
55387
761b86d5563d 8164819: Make javac's toString() on annotation objects consistent with core reflection
darcy
parents: 47216
diff changeset
   309
    Class<?>[] classArray();
40116
9bde91c0d0ef 8162817: Annotation toString output not reusable for source input
darcy
parents:
diff changeset
   310
}