test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java

Tue, 14 May 2013 15:04:06 -0700

author
jjg
date
Tue, 14 May 2013 15:04:06 -0700
changeset 1755
ddb4a2bfcd82
parent 1721
abd153854f16
child 2103
b1b4a6dcc282
permissions
-rw-r--r--

8013852: update reference impl for type-annotations
Reviewed-by: jjg
Contributed-by: wdietl@gmail.com, steve.sides@oracle.com, joel.franck@oracle.com, alex.buckley@oracle.com

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
    26 /*
    27  * @test
    28  * @bug 8006732 8006775
    29  * @summary Test population of reference info for multicatch exception parameters
    30  * @author Werner Dietl
    31  * @compile -g Driver.java ReferenceInfoUtil.java MultiCatch.java
    32  * @run main Driver MultiCatch
    33  */
    34 public class MultiCatch {
    36     @TADescriptions({
    37         @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
    38         @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
    39     })
    40     public String multiCatch1() {
    41         return "void multiCatch1() { " +
    42             "try { new Object(); } catch (@TA NullPointerException | @TB IndexOutOfBoundsException e) { e.toString(); } }";
    43     }
    45     @TADescriptions({
    46         @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
    47         @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
    48         @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2),
    49     })
    50     public String multiCatch2() {
    51         return "void multiCatch2() { " +
    52             "try { new Object(); } catch (@TA NullPointerException | @TB IndexOutOfBoundsException | @TC IllegalArgumentException e) { e.toString(); } }";
    53     }
    55     @TADescriptions({
    56         @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
    57         @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1),
    58         @TADescription(annotation = "TC", type = EXCEPTION_PARAMETER, exceptionIndex = 2),
    59         @TADescription(annotation = "TD", type = EXCEPTION_PARAMETER, exceptionIndex = 2),
    60         @TADescription(annotation = "TE", type = EXCEPTION_PARAMETER, exceptionIndex = 3),
    61     })
    62     public String multiCatch3() {
    63         return "void multiCatch3() { " +
    64             "try { new Object(); } catch (NullPointerException e1) {}" +
    65             "try { new Object(); } catch (@TA @TB NullPointerException | @TC @TD IndexOutOfBoundsException | @TE IllegalArgumentException e2) { e2.toString(); } }";
    66     }
    67 }

mercurial