hotspot/test/runtime/duplAttributes/DuplAttributesTest.java
author lana
Thu, 04 Feb 2016 11:28:20 -0800
changeset 35720 e66a02d55e71
parent 30604 b8d532cb6420
child 36851 03e2f4d0a421
permissions -rw-r--r--
Added tag jdk-9+104 for changeset a8ace34fedbc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24432
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 24432
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
24432
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
     4
 *
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
     7
 * published by the Free Software Foundation.
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
     8
 *
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    13
 * accompanied this code).
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    14
 *
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    18
 *
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    21
 * questions.
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    22
 */
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    23
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    24
/*
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    25
 * @test
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    26
 * @bug 8040292
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    27
 * @library /testlibrary
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    28
 * @summary Throw exceptions when duplicate attributes are detected.
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 24432
diff changeset
    29
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 24432
diff changeset
    30
 *          java.management
24432
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    31
 * @run main DuplAttributesTest
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    32
 */
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    33
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    34
import java.io.File;
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    35
import jdk.test.lib.*;
24432
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    36
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    37
public class DuplAttributesTest {
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    38
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    39
    static final String testsrc = System.getProperty("test.src");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    40
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    41
    public static void runTest(String test, String result) throws Throwable {
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    42
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    43
            "-cp", testsrc + File.separator + "test.jar", test);
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    44
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    45
        output.shouldContain("java.lang.ClassFormatError: Multiple " + result);
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    46
    }
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    47
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    48
    public static void main(String args[]) throws Throwable {
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    49
        System.out.println("Regression test for bug 8040292");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    50
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    51
        runTest("ClassInvisAnnotsDup", "RuntimeInvisibleAnnotations");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    52
        runTest("ClassVisAnnotsDup", "RuntimeVisibleAnnotations");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    53
        runTest("SrcDbgExtDup", "SourceDebugExtension");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    54
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    55
        runTest("FieldInvisAnnotsDup", "RuntimeInvisibleAnnotations");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    56
        runTest("FieldVisAnnotsDup", "RuntimeVisibleAnnotations");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    57
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    58
        runTest("AnnotationDefaultDup", "AnnotationDefault");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    59
        runTest("MethInvisAnnotsDup", "RuntimeInvisibleAnnotations");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    60
        runTest("MethVisAnnotsDup", "RuntimeVisibleAnnotations");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    61
        runTest("MethInvisParamAnnotsDup", "RuntimeInvisibleParameterAnnotations");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    62
        runTest("MethVisParamAnnotsDup", "RuntimeVisibleParameterAnnotations");
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    63
    }
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    64
}
482afb00f089 8040292: Annotation attributes must not appear more than once
hseigel
parents:
diff changeset
    65