test/tools/javac/processing/6378728/T6378728.java

Fri, 27 May 2011 15:02:39 -0700

author
jeff
date
Fri, 27 May 2011 15:02:39 -0700
changeset 1016
6211df69f7e0
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

7045697: JDK7 THIRD PARTY README update
Reviewed-by: lana

     1 /*
     2  * Copyright (c) 2006, 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 /* @test
    25  * @bug     6378728
    26  * @summary Verify -proc:only doesn't produce class files
    27  * @author  Joseph D. Darcy
    28  * @compile T6378728.java
    29  * @run main T6378728
    30  */
    32 import java.io.File;
    33 import java.io.IOException;
    34 import java.io.OutputStreamWriter;
    35 import java.net.URI;
    36 import java.util.Arrays;
    37 import javax.tools.JavaCompiler.CompilationTask;
    39 import javax.tools.*;
    42 public class T6378728 {
    43     private static class ExceptionalFileManager extends ForwardingJavaFileManager {
    44         public ExceptionalFileManager(JavaFileManager wrapped) {
    45             super(wrapped);
    46         }
    48         @Override
    49         public FileObject getFileForOutput(Location location,
    50                                            String packageName,
    51                                            String relativeName,
    52                                            FileObject sibling)
    53         {
    54             throw new IllegalArgumentException("No files for you!");
    55         }
    57         @Override
    58         public JavaFileObject getJavaFileForOutput(Location location,
    59                                                    String className,
    60                                                    JavaFileObject.Kind kind,
    61                                                    FileObject sibling)
    62         {
    63             throw new IllegalArgumentException("No files for you!");
    64         }
    65     }
    67     public static void main(String[] args) {
    68         // Get a compiler tool
    69         JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    70         String srcdir = System.getProperty("test.src");
    71         File source = new File(srcdir, "T6378728.java");
    72         StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
    74         CompilationTask task =
    75             compiler.getTask(null,
    76                              new ExceptionalFileManager(fm),
    77                              null,
    78                              Arrays.asList("-proc:only"),
    79                              null,
    80                              fm.getJavaFileObjectsFromFiles(Arrays.asList(source)));
    81         if (!task.call())
    82             throw new RuntimeException("Unexpected compilation failure");
    83     }
    84 }

mercurial