7199925: Separate compilation breaks check that elements have a default for the containing annotation
Reviewed-by: jjg, mcimadamore
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Sep 28 18:50:40 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Sep 28 11:39:29 2012 -0700
@@ -514,22 +514,6 @@
expectedType);
fatalError = true;
}
-
- // validate that all other elements of containing type has defaults
- scope = targetContainerType.tsym.members();
- error = false;
- for(Symbol elm : scope.getElements()) {
- if (elm.name != names.value &&
- elm.kind == Kinds.MTH &&
- ((MethodSymbol)elm).defaultValue == null) {
- log.error(pos,
- "invalid.containedby.annotation.elem.nondefault",
- targetContainerType,
- elm);
- containerValueSymbol = null;
- error = true;
- }
- }
if (error) {
fatalError = true;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Sep 28 18:50:40 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Sep 28 11:39:29 2012 -0700
@@ -2491,6 +2491,7 @@
validateDocumented(t.tsym, s, pos);
validateInherited(t.tsym, s, pos);
validateTarget(t.tsym, s, pos);
+ validateDefault(t.tsym, s, pos);
}
/**
@@ -2671,6 +2672,21 @@
return true;
}
+ private void validateDefault(Symbol container, Symbol contained, DiagnosticPosition pos) {
+ // validate that all other elements of containing type has defaults
+ Scope scope = container.members();
+ for(Symbol elm : scope.getElements()) {
+ if (elm.name != names.value &&
+ elm.kind == Kinds.MTH &&
+ ((MethodSymbol)elm).defaultValue == null) {
+ log.error(pos,
+ "invalid.containedby.annotation.elem.nondefault",
+ container,
+ elm);
+ }
+ }
+ }
+
/** Is s a method symbol that overrides a method in a superclass? */
boolean isOverrider(Symbol s) {
if (s.kind != MTH || s.isStatic())
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Sep 28 18:50:40 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Sep 28 11:39:29 2012 -0700
@@ -292,7 +292,7 @@
# 0: type, 1: symbol
compiler.err.invalid.containedby.annotation.elem.nondefault=\
- duplicate annotation, element {1} in containing annotation {0} does not have a default value
+ containing annotation {0} does not have a default value for element {1}
# 0: symbol, 1: type, 2: symbol, 3: type
compiler.err.invalid.containedby.annotation.retention=\