langtools/test/tools/javac/processing/messager/MessagerDiags.java
changeset 25445 603f0c93d5c9
parent 12714 73f1f7097c5e
child 30730 d3ce7619db2c
equal deleted inserted replaced
25444:27045478cf23 25445:603f0c93d5c9
     1 /*
     1 /*
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 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.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    52 import javax.tools.ToolProvider;
    52 import javax.tools.ToolProvider;
    53 
    53 
    54 import static javax.tools.Diagnostic.Kind.*;
    54 import static javax.tools.Diagnostic.Kind.*;
    55 import static javax.tools.JavaFileObject.Kind.*;
    55 import static javax.tools.JavaFileObject.Kind.*;
    56 
    56 
    57 @SupportedSourceVersion(SourceVersion.RELEASE_6)
    57 @SupportedSourceVersion(SourceVersion.RELEASE_8)
    58 @SupportedAnnotationTypes("*")
    58 @SupportedAnnotationTypes("*")
    59 public class MessagerDiags extends AbstractProcessor {
    59 public class MessagerDiags extends AbstractProcessor {
    60     static final String CNAME = "Test";
    60     static final String CNAME = "Test";
    61     static final String TEST_JAVA = CNAME + ".java";
    61     static final String TEST_JAVA = CNAME + ".java";
    62     static final String TEST_JAVA_URI_NAME = "myfo:/" + TEST_JAVA;
    62     static final String TEST_JAVA_URI_NAME = "myfo:/" + TEST_JAVA;
    63     static final String WRN_NO_SOURCE   = "warning without source";
    63     static final String WRN_NO_SOURCE   = "warning without source";
    64     static final String WRN_WITH_SOURCE = "warning with source";
    64     static final String WRN_WITH_SOURCE = "warning with source";
    65     static final String NONE = "<none>";
    65     static final String NONE = "<none>";
    66     static final String[] EXPECTED = { NONE + ":-1--1:" + WRN_NO_SOURCE,
    66     static final String[] EXPECTED = { NONE + ":-1--1:" + WRN_NO_SOURCE,
    67                                        TEST_JAVA + ":0-13:" + WRN_WITH_SOURCE,
    67                                 TEST_JAVA + ":0-13:" + WRN_WITH_SOURCE,
    68                                        NONE + ":-1--1:" + WRN_NO_SOURCE
    68                                 NONE + ":-1--1:" + WRN_NO_SOURCE
    69     };
    69     };
    70 
    70 
    71     @Override
    71     @Override
    72     public boolean process(Set<? extends TypeElement> annotations,
    72     public boolean process(Set<? extends TypeElement> annotations,
    73                            RoundEnvironment roundEnv) {
    73                            RoundEnvironment roundEnv) {
    86         assert tool != null;
    86         assert tool != null;
    87 
    87 
    88         DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<>();
    88         DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<>();
    89         List<String> options = new LinkedList<>();
    89         List<String> options = new LinkedList<>();
    90         options.addAll(Arrays.asList("-bootclasspath",  bootPath,
    90         options.addAll(Arrays.asList("-bootclasspath",  bootPath,
    91                         "-source", "1.6", "-classpath",
    91                         "-source", "1.8", "-classpath",
    92                         System.getProperty("java.class.path")));
    92                         System.getProperty("java.class.path")));
    93         options.addAll(Arrays.asList("-processor",
    93         options.addAll(Arrays.asList("-processor",
    94                        MessagerDiags.class.getName()));
    94                        MessagerDiags.class.getName()));
    95         JavacTask ct = (JavacTask)tool.getTask(null, null, dc, options, null,
    95         JavacTask ct = (JavacTask)tool.getTask(null, null, dc, options, null,
    96                         Arrays.asList(new MyFileObject("class " + CNAME + " {}")));
    96                         Arrays.asList(new MyFileObject("class " + CNAME + " {}")));