langtools/test/tools/javac/T6595666.java
author never
Fri, 25 Mar 2011 18:50:10 -0700
changeset 8867 6febcc945802
parent 5520 86e4b9a9da40
child 30730 d3ce7619db2c
permissions -rw-r--r--
7022204: LogFile wildcarding should use %p instead of star Reviewed-by: coleenp, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1996
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1996
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1996
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
     4
 *
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
     8
 *
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    13
 * accompanied this code).
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    14
 *
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1996
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1996
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1996
diff changeset
    21
 * questions.
1996
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    22
 */
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    23
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    24
/*
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    25
 * @test
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    26
 * @bug 6595666
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    27
 * @summary fix -Werror
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    28
 */
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    29
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    30
import java.io.*;
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    31
import java.util.*;
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    32
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    33
public class T6595666 {
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    34
    void m() {
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    35
        // the following line must create warnings with -Xlint, because of unchecked conversion
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    36
        List<Integer> list = new ArrayList();
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    37
    }
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    38
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    39
    public static void main(String... args) throws Exception {
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    40
        File testSrc = new File(System.getProperty("test.src", "."));
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    41
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    42
        String basename = T6595666.class.getName();
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    43
        File srcFile = new File(testSrc, basename+".java");
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    44
        File classFile = new File(basename+".class");
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    45
        classFile.delete();
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    46
        if (classFile.exists())
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    47
            throw new Exception("setup error, can't delete " + classFile);
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    48
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    49
        compile(1, "-d", ".", "-Xlint", "-Werror", srcFile.getPath());
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    50
        if (classFile.exists())
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    51
            throw new Exception("failed: found " + classFile);
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    52
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    53
        compile(0, "-d", ".", "-Xlint", srcFile.getPath());
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    54
        if (!classFile.exists())
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    55
            throw new Exception("failed: " + classFile + " not found");
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    56
    }
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    57
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    58
    private static void compile(int rc, String... args) throws Exception {
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    59
        System.err.println("compile: " + Arrays.asList(args));
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    60
        StringWriter sw = new StringWriter();
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    61
        PrintWriter pw = new PrintWriter(sw);
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    62
        int rc2 = com.sun.tools.javac.Main.compile(args, pw);
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    63
        pw.close();
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    64
        System.err.println(sw);
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    65
        if (rc != rc2)
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    66
            throw new Exception("bad exit code; expected " + rc + ", found " + rc2);
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    67
    }
c855318a4b03 6595666: fix -Werror
jjg
parents:
diff changeset
    68
}