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

Mon, 15 Dec 2008 16:55:33 -0800

author
xdono
date
Mon, 15 Dec 2008 16:55:33 -0800
changeset 174
fdfed22db054
parent 1
9a66ca7c79fa
child 554
9d9f26857129
permissions
-rw-r--r--

6785258: Update copyright year
Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008
Reviewed-by: katleman, ohair, tbell

     1 /*
     2  * Copyright 2006 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any 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