8200166: Repeating annotations refering to to-be-generated classes don't work
Reviewed-by: jjg
This commit is contained in:
parent
45abb6791e
commit
8afe86a2fe
src/jdk.compiler/share/classes/com/sun/tools/javac/tree
test/langtools/tools/javac/annotations/repeatingAnnotations/generatedInRepeating
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,6 +30,7 @@ import java.util.Iterator;
|
||||
import com.sun.source.tree.ModuleTree.ModuleKind;
|
||||
import com.sun.source.tree.Tree.Kind;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Attribute.UnresolvedClass;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.code.Type.*;
|
||||
import com.sun.tools.javac.util.*;
|
||||
@ -872,7 +873,11 @@ public class TreeMaker implements JCTree.Factory {
|
||||
result = QualIdent(e.value);
|
||||
}
|
||||
public void visitError(Attribute.Error e) {
|
||||
result = Erroneous();
|
||||
if (e instanceof UnresolvedClass) {
|
||||
result = ClassLiteral(((UnresolvedClass) e).classType).setType(syms.classType);
|
||||
} else {
|
||||
result = Erroneous();
|
||||
}
|
||||
}
|
||||
public void visitCompound(Attribute.Compound compound) {
|
||||
if (compound instanceof Attribute.TypeCompound) {
|
||||
|
46
test/langtools/tools/javac/annotations/repeatingAnnotations/generatedInRepeating/GeneratedInRepeating.java
Normal file
46
test/langtools/tools/javac/annotations/repeatingAnnotations/generatedInRepeating/GeneratedInRepeating.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8200166
|
||||
* @summary Check that repeating annotations whose attributes are not-yet-generated classes work.
|
||||
* @compile Processor.java
|
||||
* @compile -processor Processor GeneratedInRepeating.java
|
||||
*/
|
||||
|
||||
import java.lang.annotation.Repeatable;
|
||||
|
||||
@Annot(Gen.class)
|
||||
@Annot(Gen.class)
|
||||
public class GeneratedInRepeating {
|
||||
}
|
||||
|
||||
@Repeatable(AnnotContainer.class)
|
||||
@interface Annot {
|
||||
public Class<?> value();
|
||||
}
|
||||
|
||||
@interface AnnotContainer {
|
||||
public Annot[] value();
|
||||
}
|
56
test/langtools/tools/javac/annotations/repeatingAnnotations/generatedInRepeating/Processor.java
Normal file
56
test/langtools/tools/javac/annotations/repeatingAnnotations/generatedInRepeating/Processor.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
public class Processor extends AbstractProcessor {
|
||||
|
||||
int round;
|
||||
|
||||
@Override
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
return SourceVersion.latestSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
if (round == 0) {
|
||||
try (Writer w = processingEnv.getFiler().createSourceFile("Gen").openWriter()) {
|
||||
w.write("class Gen {}");
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
round++;
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user