duke@1: /* ohair@554: * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as duke@1: * published by the Free Software Foundation. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: /* duke@1: * @test duke@1: * @bug 6361619 6392118 duke@1: * @summary AssertionError from ClassReader; mismatch between JavacTaskImpl.context and JSR 269 duke@1: */ duke@1: duke@1: import java.io.*; duke@1: import java.net.*; duke@1: import java.util.*; duke@1: import javax.annotation.processing.*; duke@1: import javax.lang.model.element.*; duke@1: import javax.tools.*; duke@1: import com.sun.source.util.*; duke@1: import com.sun.tools.javac.api.*; duke@1: import com.sun.source.util.Trees; duke@1: duke@1: @SupportedAnnotationTypes("*") duke@1: public class T6361619 extends AbstractProcessor { duke@1: public static void main(String... args) throws Throwable { duke@1: String testSrcDir = System.getProperty("test.src"); duke@1: String testClassDir = System.getProperty("test.classes"); duke@1: String self = T6361619.class.getName(); duke@1: duke@1: JavacTool tool = JavacTool.create(); duke@1: duke@1: final PrintWriter out = new PrintWriter(System.err, true); duke@1: duke@1: Iterable flags = Arrays.asList("-processorpath", testClassDir, duke@1: "-processor", self, duke@1: "-d", "."); duke@1: DiagnosticListener dl = new DiagnosticListener() { duke@1: public void report(Diagnostic m) { duke@1: out.println(m); duke@1: } duke@1: }; duke@1: duke@1: StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); duke@1: Iterable f = duke@1: fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, duke@1: self + ".java"))); duke@1: duke@1: JavacTask task = tool.getTask(out, fm, dl, flags, null, f); duke@1: MyTaskListener tl = new MyTaskListener(task); duke@1: task.setTaskListener(tl); duke@1: duke@1: // should complete, without exceptions duke@1: task.call(); duke@1: } duke@1: duke@1: public boolean process(Set elems, RoundEnvironment renv) { duke@1: return true; duke@1: } duke@1: duke@1: duke@1: static class MyTaskListener implements TaskListener { duke@1: public MyTaskListener(JavacTask task) { duke@1: this.task = task; duke@1: } duke@1: duke@1: public void started(TaskEvent e) { duke@1: System.err.println("Started: " + e); duke@1: Trees t = Trees.instance(task); duke@1: } duke@1: public void finished(TaskEvent e) { duke@1: System.err.println("Finished: " + e); duke@1: Trees t = Trees.instance(task); duke@1: } duke@1: duke@1: JavacTask task; duke@1: } duke@1: }