667N/A/*
667N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
667N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
667N/A *
667N/A * This code is free software; you can redistribute it and/or modify it
667N/A * under the terms of the GNU General Public License version 2 only, as
667N/A * published by the Free Software Foundation.
667N/A *
667N/A * This code is distributed in the hope that it will be useful, but WITHOUT
667N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
667N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
667N/A * version 2 for more details (a copy is included in the LICENSE file that
667N/A * accompanied this code).
667N/A *
667N/A * You should have received a copy of the GNU General Public License version
667N/A * 2 along with this work; if not, write to the Free Software Foundation,
667N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
667N/A *
667N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
667N/A * or visit www.oracle.com if you need additional information or have any
667N/A * questions.
667N/A */
667N/A
667N/A/*
667N/A * @test
667N/A * @bug 6458823
667N/A * @summary Messager messages on TypeParamterElements to not include position information.
667N/A *
667N/A * @compile MyProcessor.java T6458823.java
667N/A * @run main T6458823
667N/A */
667N/A
667N/Aimport java.io.File;
667N/Aimport java.io.IOException;
667N/Aimport java.io.Writer;
667N/Aimport java.net.URISyntaxException;
667N/Aimport java.util.ArrayList;
667N/Aimport java.util.HashMap;
667N/Aimport java.util.List;
667N/Aimport java.util.Map;
667N/Aimport java.util.Set;
667N/Aimport javax.tools.Diagnostic;
667N/Aimport javax.tools.DiagnosticCollector;
667N/Aimport javax.tools.JavaCompiler;
667N/Aimport javax.tools.JavaCompiler.CompilationTask;
667N/Aimport javax.tools.JavaFileObject;
667N/Aimport javax.tools.StandardJavaFileManager;
667N/Aimport javax.tools.ToolProvider;
667N/A
667N/Apublic class T6458823 {
667N/A public static void main(String[] args) throws Exception {
667N/A JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
667N/A if (compiler == null) {
667N/A throw new RuntimeException("can't get javax.tools.JavaCompiler!");
667N/A }
667N/A DiagnosticCollector<JavaFileObject> diagColl =
667N/A new DiagnosticCollector<JavaFileObject>();
667N/A StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
667N/A List<String> options = new ArrayList<String>();
667N/A options.add("-processor");
667N/A options.add("MyProcessor");
667N/A options.add("-proc:only");
667N/A List<File> files = new ArrayList<File>();
667N/A files.add(new File(T6458823.class.getResource("TestClass.java").toURI()));
667N/A final CompilationTask task = compiler.getTask(null, fm, diagColl,
667N/A options, null, fm.getJavaFileObjectsFromFiles(files));
667N/A task.call();
667N/A int diagCount = 0;
667N/A for (Diagnostic<? extends JavaFileObject> diag : diagColl.getDiagnostics()) {
667N/A if (diag.getKind() != Diagnostic.Kind.WARNING) {
667N/A throw new AssertionError("Only warnings expected");
667N/A }
667N/A System.out.println(diag);
667N/A if (diag.getPosition() == Diagnostic.NOPOS) {
667N/A throw new AssertionError("No position info in message");
667N/A }
667N/A if (diag.getSource() == null) {
667N/A throw new AssertionError("No source info in message");
667N/A }
667N/A diagCount++;
667N/A }
667N/A if (diagCount != 2) {
667N/A throw new AssertionError("unexpected number of warnings: " +
667N/A diagCount + ", expected: 2");
667N/A }
667N/A }
667N/A}