langtools/test/tools/javac/classfiles/attributes/Signature/ExceptionTest.java
changeset 29637 c03745b71c70
child 30730 d3ce7619db2c
equal deleted inserted replaced
29559:47544495db2d 29637:c03745b71c70
       
     1 /*
       
     2  * Copyright (c) 2015, 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  */
       
    23 
       
    24 /*
       
    25  * @test
       
    26  * @bug 8049238
       
    27  * @summary Checks Signature attribute for methods which throw exceptions.
       
    28  * @library /tools/lib /tools/javac/lib ../lib
       
    29  * @build TestBase TestResult InMemoryFileManager ToolBox
       
    30  * @build ExceptionTest Driver ExpectedSignature ExpectedSignatureContainer
       
    31  * @run main Driver ExceptionTest
       
    32  */
       
    33 
       
    34 import java.io.IOError;
       
    35 import java.io.IOException;
       
    36 
       
    37 @ExpectedSignature(descriptor = "ExceptionTest",
       
    38         signature = "<Exc:Ljava/lang/RuntimeException;:Ljava/lang/Runnable;>Ljava/lang/Object;")
       
    39 public class ExceptionTest<Exc extends RuntimeException & Runnable> {
       
    40 
       
    41     @ExpectedSignature(descriptor = "<init>()", signature = "<E:Ljava/lang/Exception;>()V^TE;")
       
    42     <E extends Exception> ExceptionTest() throws E {
       
    43     }
       
    44 
       
    45     @ExpectedSignature(descriptor = "<init>(int)",
       
    46             signature = "<E:Ljava/lang/Exception;>(I)V^Ljava/io/IOException;^TE;^Ljava/io/IOError;")
       
    47     <E extends Exception> ExceptionTest(int a) throws IOException, E, IOError {
       
    48     }
       
    49 
       
    50     @ExpectedSignature(descriptor = "<init>(long)", signature = "(J)V^TExc;")
       
    51     ExceptionTest(long a) throws Exc {
       
    52     }
       
    53 
       
    54     @ExpectedSignature(descriptor = "<init>(byte)", signature = "(B)V^Ljava/io/IOError;^TExc;^Ljava/io/IOException;")
       
    55     ExceptionTest(byte a) throws IOError, Exc, IOException {
       
    56     }
       
    57 
       
    58     @ExpectedSignature(descriptor = "<init>(java.lang.RuntimeException)", signature = "(TExc;)V")
       
    59     ExceptionTest(Exc a) throws IOException {
       
    60     }
       
    61 
       
    62     // no Signature attribute
       
    63     ExceptionTest(String a) throws IOError {
       
    64     }
       
    65 
       
    66     void noSignatureAttributeMethod() throws IOException {
       
    67     }
       
    68 
       
    69     @ExpectedSignature(descriptor = "genericMethod(int)", signature = "(I)V^TExc;")
       
    70     void genericMethod(int a) throws Exc {
       
    71     }
       
    72 
       
    73     @ExpectedSignature(descriptor = "genericMethod(long)", signature = "(J)V^TExc;^Ljava/io/IOException;")
       
    74     void genericMethod(long a) throws Exc, IOException {
       
    75     }
       
    76 
       
    77     @ExpectedSignature(descriptor = "genericMethod(java.lang.RuntimeException)", signature = "(TExc;)V")
       
    78     void genericMethod(Exc a) throws IOError {
       
    79     }
       
    80 
       
    81     static void staticNoSignatureAttributeMethod() throws IOException {
       
    82     }
       
    83 
       
    84     @ExpectedSignature(descriptor = "staticGenericMethod(int)",
       
    85             signature = "<E:Ljava/lang/Exception;:Ljava/lang/Runnable;>(I)V^TE;")
       
    86     static <E extends Exception & Runnable> void staticGenericMethod(int a) throws E {
       
    87     }
       
    88 
       
    89     @ExpectedSignature(descriptor = "staticGenericMethod(long)",
       
    90             signature = "<E:Ljava/lang/Exception;>(J)V^Ljava/io/IOError;^TE;^Ljava/io/IOException;")
       
    91     static <E extends Exception> void staticGenericMethod(long a) throws IOError, E, IOException {
       
    92     }
       
    93 
       
    94     @ExpectedSignature(descriptor = "staticGenericMethod(java.lang.Exception)",
       
    95             signature = "<E:Ljava/lang/Exception;>(TE;)V")
       
    96     static <E extends Exception> void staticGenericMethod(E a) throws IOError {
       
    97     }
       
    98 }