Fri, 29 Apr 2011 16:06:28 +0100
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
Summary: Accessing a non-existing enum constant from an annotation whose class is available results in an internal error
Reviewed-by: jjg
1 /*
2 * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 /*
25 * @test
26 * @bug 6634138
27 * @author Joseph D. Darcy
28 * @summary Verify source files output after processing is over are compiled
29 * @library ../../lib
30 * @build JavacTestingAbstractProcessor
31 * @compile T6634138.java
32 * @compile -processor T6634138 Dummy.java
33 * @run main ExerciseDependency
34 */
36 import java.lang.annotation.Annotation;
37 import java.io.*;
38 import java.util.Collections;
39 import java.util.Set;
40 import java.util.HashSet;
41 import java.util.List;
42 import java.util.ArrayList;
43 import java.util.Arrays;
44 import javax.annotation.processing.*;
45 import javax.lang.model.SourceVersion;
46 import javax.lang.model.element.*;
47 import javax.lang.model.util.*;
49 public class T6634138 extends JavacTestingAbstractProcessor {
50 public boolean process(Set<? extends TypeElement> annotations,
51 RoundEnvironment roundEnvironment) {
52 // Write out files *after* processing is over.
53 if (roundEnvironment.processingOver()) {
54 System.out.println("Writing out source files.");
55 try {
56 PrintWriter pw = new PrintWriter(filer.createSourceFile("foo.WrittenAfterProcessing").openWriter());
57 try {
58 pw.println("package foo;");
59 pw.println("public class WrittenAfterProcessing {");
60 pw.println(" public WrittenAfterProcessing() {super();}");
61 pw.println("}");
62 } finally {
63 pw.close();
64 }
66 pw = new PrintWriter(filer.createSourceFile("foo.package-info").openWriter());
67 try {
68 pw.println("@Deprecated");
69 pw.println("package foo;");
70 } finally {
71 pw.close();
72 }
73 } catch(IOException io) {
74 throw new RuntimeException(io);
75 }
76 }
77 return true;
78 }
79 }