jdk/test/java/lang/reflect/Generics/TestBadSignatures.java
author mchung
Thu, 28 May 2015 10:54:48 -0700
changeset 30820 0d4717a011d3
parent 10356 5c00183df0c8
permissions -rw-r--r--
8081347: Add @modules to jdk_core tests Reviewed-by: alanb, joehw, lancea Contributed-by: alexander.kulyakhtin@oracle.com, alan.bateman@oracle.com, mandy.chung@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10356
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     1
/*
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     4
 *
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     8
 *
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    13
 * accompanied this code).
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    14
 *
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    18
 *
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    21
 * questions.
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    22
 */
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    23
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    24
/*
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    25
 * @test
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    26
 * @bug 6832374 7052898
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    27
 * @summary Test bad signatures get a GenericSignatureFormatError thrown.
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    28
 * @author Joseph D. Darcy
30820
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 10356
diff changeset
    29
 * @modules java.base/sun.reflect.generics.parser
10356
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    30
 */
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    31
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    32
import java.lang.reflect.*;
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    33
import sun.reflect.generics.parser.SignatureParser;
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    34
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    35
public class TestBadSignatures {
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    36
    public static void main(String[] args) {
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    37
        String[] badSignatures = {
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    38
            // Missing ":" after first type bound
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    39
            "<T:Lfoo/tools/nsc/symtab/Names;Lfoo/tools/nsc/symtab/Symbols;",
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    40
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    41
            // Arrays improperly indicated for exception information
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    42
            "<E:Ljava/lang/Exception;>(TE;[Ljava/lang/RuntimeException;)V^[TE;",
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    43
        };
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    44
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    45
        for(String badSig : badSignatures) {
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    46
            try {
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    47
                SignatureParser.make().parseMethodSig(badSig);
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    48
                throw new RuntimeException("Expected GenericSignatureFormatError for " +
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    49
                                           badSig);
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    50
            } catch(GenericSignatureFormatError gsfe) {
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    51
                System.out.println(gsfe.toString()); // Expected
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    52
            }
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    53
        }
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    54
    }
5c00183df0c8 6476261: (reflect) GenericSignatureFormatError When signature includes nested inner classes
darcy
parents:
diff changeset
    55
}