langtools/test/tools/javac/T7159016.java
changeset 27319 030080f03e4f
parent 12917 0c381f0ac967
child 30730 d3ce7619db2c
equal deleted inserted replaced
27318:4660a5da7d90 27319:030080f03e4f
     1 /*
     1 /*
     2  * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    43 import javax.annotation.processing.SupportedSourceVersion;
    43 import javax.annotation.processing.SupportedSourceVersion;
    44 import javax.lang.model.SourceVersion;
    44 import javax.lang.model.SourceVersion;
    45 import javax.lang.model.element.TypeElement;
    45 import javax.lang.model.element.TypeElement;
    46 import javax.tools.Diagnostic;
    46 import javax.tools.Diagnostic;
    47 import javax.tools.JavaCompiler;
    47 import javax.tools.JavaCompiler;
       
    48 import javax.tools.StandardJavaFileManager;
    48 import javax.tools.ToolProvider;
    49 import javax.tools.ToolProvider;
    49 
    50 
    50 public class T7159016 {
    51 public class T7159016 {
    51     public static void main(String[] args) throws Exception {
    52     public static void main(String[] args) throws Exception {
    52         File src = new File("C.java");
    53         File src = new File("C.java");
    56             w.flush();
    57             w.flush();
    57         } finally {
    58         } finally {
    58             w.close();
    59             w.close();
    59         }
    60         }
    60         JavaCompiler jc = ToolProvider.getSystemJavaCompiler();
    61         JavaCompiler jc = ToolProvider.getSystemJavaCompiler();
    61         JavaCompiler.CompilationTask task = jc.getTask(null, null, null, null, null,
    62         try (StandardJavaFileManager fm = jc.getStandardFileManager(null, null, null)) {
    62                                                        jc.getStandardFileManager(null, null, null).getJavaFileObjects(src));
    63             JavaCompiler.CompilationTask task = jc.getTask(null, fm, null, null, null,
    63         task.setProcessors(Collections.singleton(new Proc()));
    64                                                            fm.getJavaFileObjects(src));
    64         if (!task.call()) {
    65             task.setProcessors(Collections.singleton(new Proc()));
    65             throw new Error("Test failed");
    66             if (!task.call()) {
       
    67                 throw new Error("Test failed");
       
    68             }
    66         }
    69         }
    67     }
    70     }
    68 
    71 
    69     private static class Proc extends JavacTestingAbstractProcessor {
    72     private static class Proc extends JavacTestingAbstractProcessor {
    70         int written;
    73         int written;