--- old/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java 2010-04-29 22:39:03.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java 2010-04-29 22:39:03.000000000 -0700 @@ -745,7 +745,7 @@ * Leave class public for external testing purposes. */ public static class ComputeAnnotationSet extends - ElementScanner6, Set> { + ElementScanner7, Set> { final Elements elements; public ComputeAnnotationSet(Elements elements) { --- old/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java 2010-04-29 22:39:03.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java 2010-04-29 22:39:03.000000000 -0700 @@ -125,7 +125,7 @@ else throw new AssertionError("Bad implementation type for " + tm); - ElementScanner6, DeclaredType> scanner = + ElementScanner7, DeclaredType> scanner = new AnnotationSetScanner(result, typeUtil); for (Element element : rootElements) @@ -136,7 +136,7 @@ // Could be written as a local class inside getElementsAnnotatedWith private class AnnotationSetScanner extends - ElementScanner6, DeclaredType> { + ElementScanner7, DeclaredType> { // Insertion-order preserving set Set annotatedElements = new LinkedHashSet(); Types typeUtil; --- old/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java 2010-04-29 22:39:04.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java 2010-04-29 22:39:04.000000000 -0700 @@ -83,7 +83,7 @@ * Used for the -Xprint option and called by Elements.printElements */ public static class PrintingElementVisitor - extends SimpleElementVisitor6 { + extends SimpleElementVisitor7 { int indentation; // Indentation level; final PrintWriter writer; final Elements elementUtils; @@ -117,7 +117,7 @@ enclosing != null && NestingKind.ANONYMOUS == // Use an anonymous class to determine anonymity! - (new SimpleElementVisitor6() { + (new SimpleElementVisitor7() { @Override public NestingKind visitType(TypeElement e, Void p) { return e.getNestingKind(); --- old/src/share/classes/com/sun/tools/javah/JavahTask.java 2010-04-29 22:39:04.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javah/JavahTask.java 2010-04-29 22:39:04.000000000 -0700 @@ -59,7 +59,7 @@ import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVisitor; import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.SimpleTypeVisitor6; +import javax.lang.model.util.SimpleTypeVisitor7; import javax.lang.model.util.Types; import javax.tools.Diagnostic; @@ -710,7 +710,7 @@ } private TypeVisitor checkMethodParametersVisitor = - new SimpleTypeVisitor6() { + new SimpleTypeVisitor7() { @Override public Void visitArray(ArrayType t, Types types) { visit(t.getComponentType(), types); --- old/src/share/classes/com/sun/tools/javah/LLNI.java 2010-04-29 22:39:05.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javah/LLNI.java 2010-04-29 22:39:05.000000000 -0700 @@ -45,7 +45,7 @@ import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVisitor; import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.SimpleTypeVisitor6; +import javax.lang.model.util.SimpleTypeVisitor7; /* *

This is NOT part of any API supported by Sun Microsystems. @@ -620,7 +620,7 @@ } protected final boolean isLongOrDouble(TypeMirror t) { - TypeVisitor v = new SimpleTypeVisitor6() { + TypeVisitor v = new SimpleTypeVisitor7() { public Boolean defaultAction(TypeMirror t, Void p){ return false; } --- old/src/share/classes/com/sun/tools/javah/TypeSignature.java 2010-04-29 22:39:06.000000000 -0700 +++ new/src/share/classes/com/sun/tools/javah/TypeSignature.java 2010-04-29 22:39:05.000000000 -0700 @@ -38,7 +38,7 @@ import javax.lang.model.type.TypeVariable; import javax.lang.model.type.TypeVisitor; import javax.lang.model.util.Elements; -import javax.lang.model.util.SimpleTypeVisitor6; +import javax.lang.model.util.SimpleTypeVisitor7; /** * Returns internal type signature. @@ -239,7 +239,7 @@ String qualifiedTypeName(TypeMirror type) { - TypeVisitor v = new SimpleTypeVisitor6() { + TypeVisitor v = new SimpleTypeVisitor7() { @Override public Name visitArray(ArrayType t, Void p) { return t.getComponentType().accept(this, p); --- old/src/share/classes/javax/lang/model/element/ElementVisitor.java 2010-04-29 22:39:06.000000000 -0700 +++ new/src/share/classes/javax/lang/model/element/ElementVisitor.java 2010-04-29 22:39:06.000000000 -0700 @@ -62,6 +62,7 @@ * @author Scott Seligman * @author Peter von der Ahé * @see AbstractElementVisitor6 + * @see AbstractElementVisitor7 * @since 1.6 */ public interface ElementVisitor { --- old/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java 2010-04-29 22:39:06.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java 2010-04-29 22:39:06.000000000 -0700 @@ -62,6 +62,8 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see AbstractAnnotationValueVisitor7 * @since 1.6 */ @SupportedSourceVersion(RELEASE_6) --- old/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java 2010-04-29 22:39:07.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java 2010-04-29 22:39:07.000000000 -0700 @@ -65,6 +65,8 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see AbstractElementVisitor7 * @since 1.6 */ @SupportedSourceVersion(RELEASE_6) --- old/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java 2010-04-29 22:39:07.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java 2010-04-29 22:39:07.000000000 -0700 @@ -57,6 +57,8 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see AbstractTypeVisitor7 * @since 1.6 */ public abstract class AbstractTypeVisitor6 implements TypeVisitor { --- old/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java 2010-04-29 22:39:08.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java 2010-04-29 22:39:08.000000000 -0700 @@ -76,11 +76,13 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see ElementKindVisitor7 * @since 1.6 */ @SupportedSourceVersion(RELEASE_6) public class ElementKindVisitor6 - extends SimpleElementVisitor6 { + extends SharedElementKindVisitor { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. @@ -98,287 +100,4 @@ protected ElementKindVisitor6(R defaultValue) { super(defaultValue); } - - /** - * {@inheritDoc} - * - * The element argument has kind {@code PACKAGE}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return {@inheritDoc} - */ - @Override - public R visitPackage(PackageElement e, P p) { - assert e.getKind() == PACKAGE: "Bad kind on PackageElement"; - return defaultAction(e, p); - } - - /** - * Visits a type element, dispatching to the visit method for the - * specific {@linkplain ElementKind kind} of type, {@code - * ANNOTATION_TYPE}, {@code CLASS}, {@code ENUM}, or {@code - * INTERFACE}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of the kind-specific visit method - */ - @Override - public R visitType(TypeElement e, P p) { - ElementKind k = e.getKind(); - switch(k) { - case ANNOTATION_TYPE: - return visitTypeAsAnnotationType(e, p); - - case CLASS: - return visitTypeAsClass(e, p); - - case ENUM: - return visitTypeAsEnum(e, p); - - case INTERFACE: - return visitTypeAsInterface(e, p); - - default: - throw new AssertionError("Bad kind " + k + " for TypeElement" + e); - } - } - - /** - * Visits an {@code ANNOTATION_TYPE} type element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitTypeAsAnnotationType(TypeElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits a {@code CLASS} type element by calling {@code - * defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitTypeAsClass(TypeElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits an {@code ENUM} type element by calling {@code - * defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitTypeAsEnum(TypeElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits an {@code INTERFACE} type element by calling {@code - * defaultAction}. - *. - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitTypeAsInterface(TypeElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits a variable element, dispatching to the visit method for - * the specific {@linkplain ElementKind kind} of variable, {@code - * ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD}, - * {@code LOCAL_VARIABLE}, or {@code PARAMETER}. - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of the kind-specific visit method - */ - @Override - public R visitVariable(VariableElement e, P p) { - ElementKind k = e.getKind(); - switch(k) { - case ENUM_CONSTANT: - return visitVariableAsEnumConstant(e, p); - - case EXCEPTION_PARAMETER: - return visitVariableAsExceptionParameter(e, p); - - case FIELD: - return visitVariableAsField(e, p); - - case LOCAL_VARIABLE: - return visitVariableAsLocalVariable(e, p); - - case PARAMETER: - return visitVariableAsParameter(e, p); - - default: - throw new AssertionError("Bad kind " + k + " for VariableElement" + e); - } - - } - - /** - * Visits an {@code ENUM_CONSTANT} variable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitVariableAsEnumConstant(VariableElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits an {@code EXCEPTION_PARAMETER} variable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitVariableAsExceptionParameter(VariableElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits a {@code FIELD} variable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitVariableAsField(VariableElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits a {@code LOCAL_VARIABLE} variable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitVariableAsLocalVariable(VariableElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits a {@code PARAMETER} variable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitVariableAsParameter(VariableElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits an executable element, dispatching to the visit method - * for the specific {@linkplain ElementKind kind} of executable, - * {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or - * {@code STATIC_INIT}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of the kind-specific visit method - */ - @Override - public R visitExecutable(ExecutableElement e, P p) { - ElementKind k = e.getKind(); - switch(k) { - case CONSTRUCTOR: - return visitExecutableAsConstructor(e, p); - - case INSTANCE_INIT: - return visitExecutableAsInstanceInit(e, p); - - case METHOD: - return visitExecutableAsMethod(e, p); - - case STATIC_INIT: - return visitExecutableAsStaticInit(e, p); - - default: - throw new AssertionError("Bad kind " + k + " for ExecutableElement" + e); - } - } - - /** - * Visits a {@code CONSTRUCTOR} executable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitExecutableAsConstructor(ExecutableElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits an {@code INSTANCE_INIT} executable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitExecutableAsInstanceInit(ExecutableElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits a {@code METHOD} executable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitExecutableAsMethod(ExecutableElement e, P p) { - return defaultAction(e, p); - } - - /** - * Visits a {@code STATIC_INIT} executable element by calling - * {@code defaultAction}. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitExecutableAsStaticInit(ExecutableElement e, P p) { - return defaultAction(e, p); - } - - - /** - * {@inheritDoc} - * - * The element argument has kind {@code TYPE_PARAMETER}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return {@inheritDoc} - */ - @Override - public R visitTypeParameter(TypeParameterElement e, P p) { - assert e.getKind() == TYPE_PARAMETER: "Bad kind on TypeParameterElement"; - return defaultAction(e, p); - } } --- old/src/share/classes/javax/lang/model/util/ElementScanner6.java 2010-04-29 22:39:08.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/ElementScanner6.java 2010-04-29 22:39:08.000000000 -0700 @@ -88,21 +88,18 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see ElementScanner7 * @since 1.6 */ @SupportedSourceVersion(RELEASE_6) -public class ElementScanner6 extends AbstractElementVisitor6 { - /** - * The specified default value. - */ - protected final R DEFAULT_VALUE; - +public class ElementScanner6 extends SharedElementScanner { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. */ protected ElementScanner6(){ - DEFAULT_VALUE = null; + super(); } /** @@ -110,95 +107,6 @@ * default value. */ protected ElementScanner6(R defaultValue){ - DEFAULT_VALUE = defaultValue; - } - - /** - * Iterates over the given elements and calls {@link - * #scan(Element, Object) scan(Element, P)} on each one. Returns - * the result of the last call to {@code scan} or {@code - * DEFAULT_VALUE} for an empty iterable. - * - * @param iterable the elements to scan - * @param p additional parameter - * @return the scan of the last element or {@code DEFAULT_VALUE} if no elements - */ - public final R scan(Iterable iterable, P p) { - R result = DEFAULT_VALUE; - for(Element e : iterable) - result = scan(e, p); - return result; - } - - /** - * Processes an element by calling {@code e.accept(this, p)}; - * this method may be overridden by subclasses. - * @return the result of visiting {@code e}. - */ - public R scan(Element e, P p) { - return e.accept(this, p); - } - - /** - * Convenience method equivalent to {@code v.scan(e, null)}. - * @return the result of scanning {@code e}. - */ - public final R scan(Element e) { - return scan(e, null); - } - - /** - * {@inheritDoc} This implementation scans the enclosed elements. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of scanning - */ - public R visitPackage(PackageElement e, P p) { - return scan(e.getEnclosedElements(), p); - } - - /** - * {@inheritDoc} This implementation scans the enclosed elements. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of scanning - */ - public R visitType(TypeElement e, P p) { - return scan(e.getEnclosedElements(), p); - } - - /** - * {@inheritDoc} This implementation scans the enclosed elements. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of scanning - */ - public R visitVariable(VariableElement e, P p) { - return scan(e.getEnclosedElements(), p); - } - - /** - * {@inheritDoc} This implementation scans the parameters. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of scanning - */ - public R visitExecutable(ExecutableElement e, P p) { - return scan(e.getParameters(), p); - } - - /** - * {@inheritDoc} This implementation scans the enclosed elements. - * - * @param e the element to visit - * @param p a visitor-specified parameter - * @return the result of scanning - */ - public R visitTypeParameter(TypeParameterElement e, P p) { - return scan(e.getEnclosedElements(), p); + super(defaultValue); } } --- old/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java 2010-04-29 22:39:08.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java 2010-04-29 22:39:08.000000000 -0700 @@ -25,7 +25,6 @@ package javax.lang.model.util; - import java.util.List; import javax.lang.model.element.*; @@ -69,18 +68,13 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see SimpleAnnotationValueVisitor7 * @since 1.6 */ @SupportedSourceVersion(RELEASE_6) public class SimpleAnnotationValueVisitor6 - extends AbstractAnnotationValueVisitor6 { - - /** - * Default value to be returned; {@link #defaultAction - * defaultAction} returns this value unless the method is - * overridden. - */ - protected final R DEFAULT_VALUE; + extends SharedSimpleAnnotationValueVisitor { /** * Constructor for concrete subclasses; uses {@code null} for the @@ -88,7 +82,6 @@ */ protected SimpleAnnotationValueVisitor6() { super(); - DEFAULT_VALUE = null; } /** @@ -98,163 +91,6 @@ * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} */ protected SimpleAnnotationValueVisitor6(R defaultValue) { - super(); - DEFAULT_VALUE = defaultValue; - } - - /** - * The default action for visit methods. The implementation in - * this class just returns {@link #DEFAULT_VALUE}; subclasses will - * commonly override this method. - * - * @param o the value of the annotation - * @param p a visitor-specified parameter - * @return {@code DEFAULT_VALUE} unless overridden - */ - protected R defaultAction(Object o, P p) { - return DEFAULT_VALUE; - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param b {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitBoolean(boolean b, P p) { - return defaultAction(b, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param b {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitByte(byte b, P p) { - return defaultAction(b, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param c {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitChar(char c, P p) { - return defaultAction(c, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param d {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitDouble(double d, P p) { - return defaultAction(d, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param f {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitFloat(float f, P p) { - return defaultAction(f, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param i {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitInt(int i, P p) { - return defaultAction(i, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param i {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitLong(long i, P p) { - return defaultAction(i, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param s {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitShort(short s, P p) { - return defaultAction(s, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param s {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitString(String s, P p) { - return defaultAction(s, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitType(TypeMirror t, P p) { - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param c {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitEnumConstant(VariableElement c, P p) { - return defaultAction(c, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param a {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitAnnotation(AnnotationMirror a, P p) { - return defaultAction(a, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param vals {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitArray(List vals, P p) { - return defaultAction(vals, p); + super(defaultValue); } } --- old/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java 2010-04-29 22:39:09.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java 2010-04-29 22:39:09.000000000 -0700 @@ -31,7 +31,6 @@ import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; - /** * A simple visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6} @@ -71,23 +70,18 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see SimpleElementVisitor7 * @since 1.6 */ @SupportedSourceVersion(RELEASE_6) -public class SimpleElementVisitor6 extends AbstractElementVisitor6 { - /** - * Default value to be returned; {@link #defaultAction - * defaultAction} returns this value unless the method is - * overridden. - */ - protected final R DEFAULT_VALUE; - +public class SimpleElementVisitor6 extends SharedSimpleElementVisitor { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. */ protected SimpleElementVisitor6(){ - DEFAULT_VALUE = null; + super(); } /** @@ -97,73 +91,6 @@ * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} */ protected SimpleElementVisitor6(R defaultValue){ - DEFAULT_VALUE = defaultValue; - } - /** - * The default action for visit methods. The implementation in - * this class just returns {@link #DEFAULT_VALUE}; subclasses will - * commonly override this method. - * - * @param e the element to process - * @param p a visitor-specified parameter - * @return {@code DEFAULT_VALUE} unless overridden - */ - protected R defaultAction(Element e, P p) { - return DEFAULT_VALUE; - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitPackage(PackageElement e, P p) { - return defaultAction(e, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitType(TypeElement e, P p) { - return defaultAction(e, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitVariable(VariableElement e, P p) { - return defaultAction(e, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitExecutable(ExecutableElement e, P p) { - return defaultAction(e, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param e {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitTypeParameter(TypeParameterElement e, P p) { - return defaultAction(e, p); + super(defaultValue); } } --- old/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java 2010-04-29 22:39:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java 2010-04-29 22:39:09.000000000 -0700 @@ -30,7 +30,6 @@ import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; - /** * A simple visitor of types with default behavior appropriate for the * {@link SourceVersion#RELEASE_6 RELEASE_6} source version. @@ -70,23 +69,18 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see SimpleTypeVisitor7 * @since 1.6 */ @SupportedSourceVersion(RELEASE_6) -public class SimpleTypeVisitor6 extends AbstractTypeVisitor6 { - /** - * Default value to be returned; {@link #defaultAction - * defaultAction} returns this value unless the method is - * overridden. - */ - protected final R DEFAULT_VALUE; - +public class SimpleTypeVisitor6 extends SharedSimpleTypeVisitor { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. */ protected SimpleTypeVisitor6(){ - DEFAULT_VALUE = null; + super(); } /** @@ -96,114 +90,6 @@ * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} */ protected SimpleTypeVisitor6(R defaultValue){ - DEFAULT_VALUE = defaultValue; - } - - /** - * The default action for visit methods. The implementation in - * this class just returns {@link #DEFAULT_VALUE}; subclasses will - * commonly override this method. - */ - protected R defaultAction(TypeMirror e, P p) { - return DEFAULT_VALUE; - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitPrimitive(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitNull(NullType t, P p){ - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitArray(ArrayType t, P p){ - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitDeclared(DeclaredType t, P p){ - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitError(ErrorType t, P p){ - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitTypeVariable(TypeVariable t, P p){ - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitWildcard(WildcardType t, P p){ - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitExecutable(ExecutableType t, P p) { - return defaultAction(t, p); - } - - /** - * {@inheritDoc} This implementation calls {@code defaultAction}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of {@code defaultAction} - */ - public R visitNoType(NoType t, P p){ - return defaultAction(t, p); + super(defaultValue); } } --- old/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java 2010-04-29 22:39:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java 2010-04-29 22:39:10.000000000 -0700 @@ -25,7 +25,6 @@ package javax.lang.model.util; - import javax.lang.model.type.*; import javax.annotation.processing.SupportedSourceVersion; import static javax.lang.model.element.ElementKind.*; @@ -74,10 +73,12 @@ * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé + * + * @see TypeKindVisitor7 * @since 1.6 */ @SupportedSourceVersion(RELEASE_6) -public class TypeKindVisitor6 extends SimpleTypeVisitor6 { +public class TypeKindVisitor6 extends SharedTypeKindVisitor { /** * Constructor for concrete subclasses to call; uses {@code null} * for the default value. @@ -86,7 +87,6 @@ super(null); } - /** * Constructor for concrete subclasses to call; uses the argument * for the default value. @@ -96,205 +96,4 @@ protected TypeKindVisitor6(R defaultValue) { super(defaultValue); } - - /** - * Visits a primitive type, dispatching to the visit method for - * the specific {@linkplain TypeKind kind} of primitive type: - * {@code BOOLEAN}, {@code BYTE}, etc. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of the kind-specific visit method - */ - @Override - public R visitPrimitive(PrimitiveType t, P p) { - TypeKind k = t.getKind(); - switch (k) { - case BOOLEAN: - return visitPrimitiveAsBoolean(t, p); - - case BYTE: - return visitPrimitiveAsByte(t, p); - - case SHORT: - return visitPrimitiveAsShort(t, p); - - case INT: - return visitPrimitiveAsInt(t, p); - - case LONG: - return visitPrimitiveAsLong(t, p); - - case CHAR: - return visitPrimitiveAsChar(t, p); - - case FLOAT: - return visitPrimitiveAsFloat(t, p); - - case DOUBLE: - return visitPrimitiveAsDouble(t, p); - - default: - throw new AssertionError("Bad kind " + k + " for PrimitiveType" + t); - } - } - - /** - * Visits a {@code BOOLEAN} primitive type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitPrimitiveAsBoolean(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@code BYTE} primitive type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitPrimitiveAsByte(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@code SHORT} primitive type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitPrimitiveAsShort(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits an {@code INT} primitive type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitPrimitiveAsInt(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@code LONG} primitive type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitPrimitiveAsLong(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@code CHAR} primitive type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitPrimitiveAsChar(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@code FLOAT} primitive type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitPrimitiveAsFloat(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@code DOUBLE} primitive type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitPrimitiveAsDouble(PrimitiveType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@link NoType} instance, dispatching to the visit method for - * the specific {@linkplain TypeKind kind} of pseudo-type: - * {@code VOID}, {@code PACKAGE}, or {@code NONE}. - * - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of the kind-specific visit method - */ - @Override - public R visitNoType(NoType t, P p) { - TypeKind k = t.getKind(); - switch (k) { - case VOID: - return visitNoTypeAsVoid(t, p); - - case PACKAGE: - return visitNoTypeAsPackage(t, p); - - case NONE: - return visitNoTypeAsNone(t, p); - - default: - throw new AssertionError("Bad kind " + k + " for NoType" + t); - } - } - - /** - * Visits a {@link TypeKind#VOID VOID} pseudo-type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitNoTypeAsVoid(NoType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@link TypeKind#PACKAGE PACKAGE} pseudo-type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitNoTypeAsPackage(NoType t, P p) { - return defaultAction(t, p); - } - - /** - * Visits a {@link TypeKind#NONE NONE} pseudo-type by calling - * {@code defaultAction}. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return the result of {@code defaultAction} - */ - public R visitNoTypeAsNone(NoType t, P p) { - return defaultAction(t, p); - } } --- old/src/share/sample/javac/processing/src/CheckNamesProcessor.java 2010-04-29 22:39:11.000000000 -0700 +++ new/src/share/sample/javac/processing/src/CheckNamesProcessor.java 2010-04-29 22:39:11.000000000 -0700 @@ -138,7 +138,7 @@ public SourceVersion getSupportedSourceVersion() { /* * Return latest source version instead of a fixed version - * like RELEASE_6. To return a fixed version, this class + * like RELEASE_7. To return a fixed version, this class * could be annotated with a SupportedSourceVersion * annotation. * @@ -190,7 +190,7 @@ /** * Visitor to implement name checks. */ - private class NameCheckScanner extends ElementScanner6 { + private class NameCheckScanner extends ElementScanner7 { // The visitor could be enhanced to return true/false if // there were warnings reported or a count of the number // of warnings. This could be facilitated by using @@ -312,7 +312,7 @@ @Override public Void visitUnknown(Element e, Void p) { // This method will be called if a kind of element - // added after JDK 6 is visited. Since as of this + // added after JDK 7 is visited. Since as of this // writing the conventions for such constructs aren't // known, issue a warning. messager.printMessage(WARNING, --- old/test/tools/javac/6402516/CheckLocalElements.java 2010-04-29 22:39:11.000000000 -0700 +++ new/test/tools/javac/6402516/CheckLocalElements.java 2010-04-29 22:39:11.000000000 -0700 @@ -95,7 +95,7 @@ return encl == null ? "" : encl.accept(qualNameVisitor, null); } - private ElementVisitor qualNameVisitor = new SimpleElementVisitor6() { + private ElementVisitor qualNameVisitor = new SimpleElementVisitor7() { protected String defaultAction(Element e, Void ignore) { return ""; } --- old/test/tools/javac/api/TestOperators.java 2010-04-29 22:39:12.000000000 -0700 +++ new/test/tools/javac/api/TestOperators.java 2010-04-29 22:39:12.000000000 -0700 @@ -299,7 +299,7 @@ final Trees trees = Trees.instance(processingEnv); final Messager log = processingEnv.getMessager(); final Elements elements = processingEnv.getElementUtils(); - class Scan extends ElementScanner6 { + class Scan extends ElementScanner7 { @Override public Void visitExecutable(ExecutableElement e, Void p) { Object debug = e; // info for exception handler --- old/test/tools/javac/enum/6424358/T6424358.java 2010-04-29 22:39:12.000000000 -0700 +++ new/test/tools/javac/enum/6424358/T6424358.java 2010-04-29 22:39:12.000000000 -0700 @@ -48,7 +48,7 @@ final Messager log = processingEnv.getMessager(); final Elements elements = processingEnv.getElementUtils(); final TypeElement testMe = elements.getTypeElement("TestMe"); - class Scan extends ElementScanner6 { + class Scan extends ElementScanner7 { @Override public Void visitExecutable(ExecutableElement e, Void p) { System.err.println("Looking at " + e); --- old/test/tools/javac/processing/model/6194785/T6194785.java 2010-04-29 22:39:13.000000000 -0700 +++ new/test/tools/javac/processing/model/6194785/T6194785.java 2010-04-29 22:39:13.000000000 -0700 @@ -43,7 +43,7 @@ { final Messager log = processingEnv.getMessager(); final Elements elements = processingEnv.getElementUtils(); - class Scan extends ElementScanner6 { + class Scan extends ElementScanner7 { @Override public Void visitExecutable(ExecutableElement e, Void ignored) { for (VariableElement p : e.getParameters()) --- old/test/tools/javac/processing/model/type/NoTypes.java 2010-04-29 22:39:13.000000000 -0700 +++ new/test/tools/javac/processing/model/type/NoTypes.java 2010-04-29 22:39:13.000000000 -0700 @@ -89,7 +89,7 @@ verifyKind(NONE, types.getNoType(NONE)); // The return type of a constructor or void method is VOID. - class Scanner extends ElementScanner6 { + class Scanner extends ElementScanner7 { @Override public Void visitExecutable(ExecutableElement e, Void p) { verifyKind(VOID, e.getReturnType()); @@ -104,10 +104,10 @@ /** * Verify that a NoType instance is of a particular kind, - * and that TypeKindVisitor6 properly dispatches on it. + * and that TypeKindVisitor7 properly dispatches on it. */ private void verifyKind(TypeKind kind, TypeMirror type) { - class Vis extends TypeKindVisitor6 { + class Vis extends TypeKindVisitor7 { @Override public TypeKind visitNoTypeAsVoid(NoType t, Void p) { return VOID; --- old/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java 2010-04-29 22:39:14.000000000 -0700 +++ new/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java 2010-04-29 22:39:14.000000000 -0700 @@ -67,7 +67,7 @@ return true; } - private class DeprecationChecker extends ElementScanner6 { + private class DeprecationChecker extends ElementScanner7 { private Elements elementUtils; private boolean failure; DeprecationChecker() { --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java 2010-04-29 22:39:14.000000000 -0700 @@ -0,0 +1,110 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import java.util.List; +import javax.lang.model.element.*; + +import javax.lang.model.type.TypeMirror; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; +import javax.annotation.processing.SupportedSourceVersion; + +/** + * A skeletal visitor for annotation values with default behavior + * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} + * source version. + * + *

WARNING: The {@code AnnotationValueVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new abstract annotation + * value visitor class will also be introduced to correspond to the + * new language level; this visitor will have different default + * behavior for the visit method in question. When the new visitor is + * introduced, all or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods + * @param

the type of the additional parameter to this visitor's methods. + * + * @see AbstractAnnotationValueVisitor6 + * @since 1.7 + */ +@SupportedSourceVersion(RELEASE_7) +public abstract class AbstractAnnotationValueVisitor7 + implements AnnotationValueVisitor { + + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractAnnotationValueVisitor7() {} + + /** + * Visits an annotation value as if by passing itself to that + * value's {@link AnnotationValue#accept accept}. The invocation + * {@code v.visit(av)} is equivalent to {@code av.accept(v, p)}. + * @param av {@inheritDoc} + * @param p {@inheritDoc} + */ + public final R visit(AnnotationValue av, P p) { + return av.accept(this, p); + } + + /** + * Visits an annotation value as if by passing itself to that + * value's {@link AnnotationValue#accept accept} method passing + * {@code null} for the additional parameter. The invocation + * {@code v.visit(av)} is equivalent to {@code av.accept(v, + * null)}. + * @param av {@inheritDoc} + */ + public final R visit(AnnotationValue av) { + return av.accept(this, null); + } + + /** + * {@inheritDoc} + * + *

The default implementation of this method in {@code + * AbstractAnnotationValueVisitor7} will always throw {@code + * UnknownAnnotationValueException}. This behavior is not + * required of a subclass. + * + * @param av {@inheritDoc} + * @param p {@inheritDoc} + */ + public R visitUnknown(AnnotationValue av, P p) { + throw new UnknownAnnotationValueException(av, p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java 2010-04-29 22:39:15.000000000 -0700 @@ -0,0 +1,119 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.element.*; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.element.*; +import static javax.lang.model.element.ElementKind.*; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; + + +/** + * A skeletal visitor of program elements with default behavior + * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} + * source version. + * + *

WARNING: The {@code ElementVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new abstract element visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see AbstractElementVisitor6 + * @since 1.7 + */ +@SupportedSourceVersion(RELEASE_7) +public abstract class AbstractElementVisitor7 implements ElementVisitor { + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractElementVisitor7(){} + + /** + * Visits any program element as if by passing itself to that + * element's {@link Element#accept accept} method. The invocation + * {@code v.visit(elem)} is equivalent to {@code elem.accept(v, + * p)}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return a visitor-specified result + */ + public final R visit(Element e, P p) { + return e.accept(this, p); + } + + /** + * Visits any program element as if by passing itself to that + * element's {@link Element#accept accept} method and passing + * {@code null} for the additional parameter. The invocation + * {@code v.visit(elem)} is equivalent to {@code elem.accept(v, + * null)}. + * + * @param e the element to visit + * @return a visitor-specified result + */ + public final R visit(Element e) { + return e.accept(this, null); + } + + /** + * {@inheritDoc} + * + *

The default implementation of this method in + * {@code AbstractElementVisitor7} will always throw + * {@code UnknownElementException}. + * This behavior is not required of a subclass. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return a visitor-specified result + * @throws UnknownElementException + * a visitor implementation may optionally throw this exception + */ + public R visitUnknown(Element e, P p) { + throw new UnknownElementException(e, p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java 2010-04-29 22:39:15.000000000 -0700 @@ -0,0 +1,109 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.type.*; + +/** + * A skeletal visitor of types with default behavior appropriate for + * the version 7 language level. + * + *

WARNING: The {@code TypeVisitor} interface implemented + * by this class may have methods added to it in the future to + * accommodate new, currently unknown, language structures added to + * future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new abstract type visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see AbstractTypeVisitor6 + * @since 1.7 + */ +public abstract class AbstractTypeVisitor7 implements TypeVisitor { + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractTypeVisitor7() {} + + /** + * Visits any type mirror as if by passing itself to that type + * mirror's {@link TypeMirror#accept accept} method. The + * invocation {@code v.visit(t, p)} is equivalent to {@code + * t.accept(v, p)}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return a visitor-specified result + */ + public final R visit(TypeMirror t, P p) { + return t.accept(this, p); + } + + /** + * Visits any type mirror as if by passing itself to that type + * mirror's {@link TypeMirror#accept accept} method and passing + * {@code null} for the additional parameter. The invocation + * {@code v.visit(t)} is equivalent to {@code t.accept(v, null)}. + * + * @param t the type to visit + * @return a visitor-specified result + */ + public final R visit(TypeMirror t) { + return t.accept(this, null); + } + + /** + * {@inheritDoc} + * + *

The default implementation of this method in {@code + * AbstractTypeVisitor7} will always throw {@code + * UnknownTypeException}. This behavior is not required of a + * subclass. + * + * @param t the type to visit + * @return a visitor-specified result + * @throws UnknownTypeException + * a visitor implementation may optionally throw this exception + */ + public R visitUnknown(TypeMirror t, P p) { + throw new UnknownTypeException(t, p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java 2010-04-29 22:39:15.000000000 -0700 @@ -0,0 +1,98 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.element.*; +import static javax.lang.model.element.ElementKind.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; + +/** + * A visitor of program elements based on their {@linkplain + * ElementKind kind} with default behavior appropriate for the {@link + * SourceVersion#RELEASE_6 RELEASE_6} source version. For {@linkplain + * Element elements} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods + * call {@link #defaultAction defaultAction}, passing their arguments + * to {@code defaultAction}'s corresponding parameters. + * + *

Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

WARNING: The {@code ElementVisitor} interface + * implemented by this class may have methods added to it or the + * {@code ElementKind} {@code enum} used in this case may have + * constants added to it in the future to accommodate new, currently + * unknown, language structures added to future versions of the + * Java™ programming language. Therefore, methods whose names + * begin with {@code "visit"} may be added to this class in the + * future; to avoid incompatibilities, classes which extend this class + * should not declare any instance methods with names beginning with + * {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new abstract element kind + * visitor class will also be introduced to correspond to the new + * language level; this visitor will have different default behavior + * for the visit method in question. When the new visitor is + * introduced, all or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see ElementKindVisitor6 + * @since 1.7 + */ +@SupportedSourceVersion(RELEASE_7) +public class ElementKindVisitor7 + extends SharedElementKindVisitor { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected ElementKindVisitor7() { + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected ElementKindVisitor7(R defaultValue) { + super(defaultValue); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/ElementScanner7.java 2010-04-29 22:39:16.000000000 -0700 @@ -0,0 +1,108 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.element.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.element.ElementKind.*; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + + +/** + * A scanning visitor of program elements with default behavior + * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} + * source version. The visitXYZ methods in this + * class scan their component elements by calling {@code scan} on + * their {@linkplain Element#getEnclosedElements enclosed elements}, + * {@linkplain ExecutableElement#getParameters parameters}, etc., as + * indicated in the individual method specifications. A subclass can + * control the order elements are visited by overriding the + * visitXYZ methods. Note that clients of a scanner + * may get the desired behavior be invoking {@code v.scan(e, p)} rather + * than {@code v.visit(e, p)} on the root objects of interest. + * + *

When a subclass overrides a visitXYZ method, the + * new method can cause the enclosed elements to be scanned in the + * default way by calling super.visitXYZ. In this + * fashion, the concrete visitor can control the ordering of traversal + * over the component elements with respect to the additional + * processing; for example, consistently calling + * super.visitXYZ at the start of the overridden + * methods will yield a preorder traversal, etc. If the component + * elements should be traversed in some other order, instead of + * calling super.visitXYZ, an overriding visit method + * should call {@code scan} with the elements in the desired order. + * + *

Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

WARNING: The {@code ElementVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new element scanner visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see ElementScanner6 + * @since 1.7 + */ +@SupportedSourceVersion(RELEASE_7) +public class ElementScanner7 extends SharedElementScanner { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected ElementScanner7(){ + super(); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + */ + protected ElementScanner7(R defaultValue){ + super(defaultValue); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SharedElementKindVisitor.java 2010-04-29 22:39:16.000000000 -0700 @@ -0,0 +1,347 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.element.*; +import static javax.lang.model.element.ElementKind.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; + + +/** + * Shared package private superclass to reduce code bloat. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @since 1.7 + */ +class SharedElementKindVisitor extends SimpleElementVisitor6 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SharedElementKindVisitor() { + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SharedElementKindVisitor(R defaultValue) { + super(defaultValue); + } + + /** + * {@inheritDoc} + * + * The element argument has kind {@code PACKAGE}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return {@inheritDoc} + */ + @Override + public R visitPackage(PackageElement e, P p) { + assert e.getKind() == PACKAGE: "Bad kind on PackageElement"; + return defaultAction(e, p); + } + + /** + * Visits a type element, dispatching to the visit method for the + * specific {@linkplain ElementKind kind} of type, {@code + * ANNOTATION_TYPE}, {@code CLASS}, {@code ENUM}, or {@code + * INTERFACE}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of the kind-specific visit method + */ + @Override + public R visitType(TypeElement e, P p) { + ElementKind k = e.getKind(); + switch(k) { + case ANNOTATION_TYPE: + return visitTypeAsAnnotationType(e, p); + + case CLASS: + return visitTypeAsClass(e, p); + + case ENUM: + return visitTypeAsEnum(e, p); + + case INTERFACE: + return visitTypeAsInterface(e, p); + + default: + throw new AssertionError("Bad kind " + k + " for TypeElement" + e); + } + } + + /** + * Visits an {@code ANNOTATION_TYPE} type element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitTypeAsAnnotationType(TypeElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits a {@code CLASS} type element by calling {@code + * defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitTypeAsClass(TypeElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits an {@code ENUM} type element by calling {@code + * defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitTypeAsEnum(TypeElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits an {@code INTERFACE} type element by calling {@code + * defaultAction}. + *. + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitTypeAsInterface(TypeElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits a variable element, dispatching to the visit method for + * the specific {@linkplain ElementKind kind} of variable, {@code + * ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD}, + * {@code LOCAL_VARIABLE}, or {@code PARAMETER}. + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of the kind-specific visit method + */ + @Override + public R visitVariable(VariableElement e, P p) { + ElementKind k = e.getKind(); + switch(k) { + case ENUM_CONSTANT: + return visitVariableAsEnumConstant(e, p); + + case EXCEPTION_PARAMETER: + return visitVariableAsExceptionParameter(e, p); + + case FIELD: + return visitVariableAsField(e, p); + + case LOCAL_VARIABLE: + return visitVariableAsLocalVariable(e, p); + + case PARAMETER: + return visitVariableAsParameter(e, p); + + default: + throw new AssertionError("Bad kind " + k + " for VariableElement" + e); + } + + } + + /** + * Visits an {@code ENUM_CONSTANT} variable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitVariableAsEnumConstant(VariableElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits an {@code EXCEPTION_PARAMETER} variable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitVariableAsExceptionParameter(VariableElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits a {@code FIELD} variable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitVariableAsField(VariableElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits a {@code LOCAL_VARIABLE} variable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitVariableAsLocalVariable(VariableElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits a {@code PARAMETER} variable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitVariableAsParameter(VariableElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits an executable element, dispatching to the visit method + * for the specific {@linkplain ElementKind kind} of executable, + * {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or + * {@code STATIC_INIT}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of the kind-specific visit method + */ + @Override + public R visitExecutable(ExecutableElement e, P p) { + ElementKind k = e.getKind(); + switch(k) { + case CONSTRUCTOR: + return visitExecutableAsConstructor(e, p); + + case INSTANCE_INIT: + return visitExecutableAsInstanceInit(e, p); + + case METHOD: + return visitExecutableAsMethod(e, p); + + case STATIC_INIT: + return visitExecutableAsStaticInit(e, p); + + default: + throw new AssertionError("Bad kind " + k + " for ExecutableElement" + e); + } + } + + /** + * Visits a {@code CONSTRUCTOR} executable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitExecutableAsConstructor(ExecutableElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits an {@code INSTANCE_INIT} executable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitExecutableAsInstanceInit(ExecutableElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits a {@code METHOD} executable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitExecutableAsMethod(ExecutableElement e, P p) { + return defaultAction(e, p); + } + + /** + * Visits a {@code STATIC_INIT} executable element by calling + * {@code defaultAction}. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitExecutableAsStaticInit(ExecutableElement e, P p) { + return defaultAction(e, p); + } + + + /** + * {@inheritDoc} + * + * The element argument has kind {@code TYPE_PARAMETER}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return {@inheritDoc} + */ + @Override + public R visitTypeParameter(TypeParameterElement e, P p) { + assert e.getKind() == TYPE_PARAMETER: "Bad kind on TypeParameterElement"; + return defaultAction(e, p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SharedElementScanner.java 2010-04-29 22:39:17.000000000 -0700 @@ -0,0 +1,156 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.element.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.element.ElementKind.*; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + + +/** + * Shared package private superclass to avoid code bloat. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @since 1.7 + */ +class SharedElementScanner extends AbstractElementVisitor6 { + /** + * The specified default value. + */ + protected final R DEFAULT_VALUE; + + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SharedElementScanner(){ + DEFAULT_VALUE = null; + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + */ + protected SharedElementScanner(R defaultValue){ + DEFAULT_VALUE = defaultValue; + } + + /** + * Iterates over the given elements and calls {@link + * #scan(Element, Object) scan(Element, P)} on each one. Returns + * the result of the last call to {@code scan} or {@code + * DEFAULT_VALUE} for an empty iterable. + * + * @param iterable the elements to scan + * @param p additional parameter + * @return the scan of the last element or {@code DEFAULT_VALUE} if no elements + */ + public final R scan(Iterable iterable, P p) { + R result = DEFAULT_VALUE; + for(Element e : iterable) + result = scan(e, p); + return result; + } + + /** + * Processes an element by calling {@code e.accept(this, p)}; + * this method may be overridden by subclasses. + * @return the result of visiting {@code e}. + */ + public R scan(Element e, P p) { + return e.accept(this, p); + } + + /** + * Convenience method equivalent to {@code v.scan(e, null)}. + * @return the result of scanning {@code e}. + */ + public final R scan(Element e) { + return scan(e, null); + } + + /** + * {@inheritDoc} This implementation scans the enclosed elements. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of scanning + */ + public R visitPackage(PackageElement e, P p) { + return scan(e.getEnclosedElements(), p); + } + + /** + * {@inheritDoc} This implementation scans the enclosed elements. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of scanning + */ + public R visitType(TypeElement e, P p) { + return scan(e.getEnclosedElements(), p); + } + + /** + * {@inheritDoc} This implementation scans the enclosed elements. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of scanning + */ + public R visitVariable(VariableElement e, P p) { + return scan(e.getEnclosedElements(), p); + } + + /** + * {@inheritDoc} This implementation scans the parameters. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of scanning + */ + public R visitExecutable(ExecutableElement e, P p) { + return scan(e.getParameters(), p); + } + + /** + * {@inheritDoc} This implementation scans the enclosed elements. + * + * @param e the element to visit + * @param p a visitor-specified parameter + * @return the result of scanning + */ + public R visitTypeParameter(TypeParameterElement e, P p) { + return scan(e.getEnclosedElements(), p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SharedSimpleAnnotationValueVisitor.java 2010-04-29 22:39:17.000000000 -0700 @@ -0,0 +1,231 @@ +/* + * Copyright 2005-2006 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + + +import java.util.List; +import javax.lang.model.element.*; + +import javax.lang.model.type.TypeMirror; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; +import javax.annotation.processing.SupportedSourceVersion; + +/** + * Shared package private superclass to reduce code bloat. + * + * @param the return type of this visitor's methods + * @param

the type of the additional parameter to this visitor's methods. + * + * @see SimpleAnnotationValueVisitor7 + * @since 1.6 + */ +class SharedSimpleAnnotationValueVisitor + extends AbstractAnnotationValueVisitor6 { + + /** + * Default value to be returned; {@link #defaultAction + * defaultAction} returns this value unless the method is + * overridden. + */ + protected final R DEFAULT_VALUE; + + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SharedSimpleAnnotationValueVisitor() { + super(); + DEFAULT_VALUE = null; + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SharedSimpleAnnotationValueVisitor(R defaultValue) { + super(); + DEFAULT_VALUE = defaultValue; + } + + /** + * The default action for visit methods. The implementation in + * this class just returns {@link #DEFAULT_VALUE}; subclasses will + * commonly override this method. + * + * @param o the value of the annotation + * @param p a visitor-specified parameter + * @return {@code DEFAULT_VALUE} unless overridden + */ + protected R defaultAction(Object o, P p) { + return DEFAULT_VALUE; + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param b {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitBoolean(boolean b, P p) { + return defaultAction(b, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param b {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitByte(byte b, P p) { + return defaultAction(b, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param c {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitChar(char c, P p) { + return defaultAction(c, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param d {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitDouble(double d, P p) { + return defaultAction(d, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param f {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitFloat(float f, P p) { + return defaultAction(f, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param i {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitInt(int i, P p) { + return defaultAction(i, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param i {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitLong(long i, P p) { + return defaultAction(i, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param s {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitShort(short s, P p) { + return defaultAction(s, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param s {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitString(String s, P p) { + return defaultAction(s, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitType(TypeMirror t, P p) { + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param c {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitEnumConstant(VariableElement c, P p) { + return defaultAction(c, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param a {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitAnnotation(AnnotationMirror a, P p) { + return defaultAction(a, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param vals {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitArray(List vals, P p) { + return defaultAction(vals, p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SharedSimpleElementVisitor.java 2010-04-29 22:39:17.000000000 -0700 @@ -0,0 +1,136 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.element.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.element.ElementKind.*; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + +/** + * Shared package private superclass to avoid code bloat. + * + * @param the return type of this visitor's methods. Use {@code Void} + * for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's methods. Use {@code Void} + * for visitors that do not need an additional parameter. + * + * @since 1.7 + */ +class SharedSimpleElementVisitor extends AbstractElementVisitor6 { + /** + * Default value to be returned; {@link #defaultAction + * defaultAction} returns this value unless the method is + * overridden. + */ + protected final R DEFAULT_VALUE; + + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SharedSimpleElementVisitor(){ + DEFAULT_VALUE = null; + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SharedSimpleElementVisitor(R defaultValue){ + DEFAULT_VALUE = defaultValue; + } + /** + * The default action for visit methods. The implementation in + * this class just returns {@link #DEFAULT_VALUE}; subclasses will + * commonly override this method. + * + * @param e the element to process + * @param p a visitor-specified parameter + * @return {@code DEFAULT_VALUE} unless overridden + */ + protected R defaultAction(Element e, P p) { + return DEFAULT_VALUE; + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitPackage(PackageElement e, P p) { + return defaultAction(e, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitType(TypeElement e, P p) { + return defaultAction(e, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitVariable(VariableElement e, P p) { + return defaultAction(e, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitExecutable(ExecutableElement e, P p) { + return defaultAction(e, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param e {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitTypeParameter(TypeParameterElement e, P p) { + return defaultAction(e, p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SharedSimpleTypeVisitor.java 2010-04-29 22:39:18.000000000 -0700 @@ -0,0 +1,181 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.type.*; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + +/** + * Shared package private class to avoid code bloat. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @author Joseph D. Darcy + * @author Scott Seligman + * @author Peter von der Ahé + * + * @since 1.7 + */ +class SharedSimpleTypeVisitor extends AbstractTypeVisitor6 { + /** + * Default value to be returned; {@link #defaultAction + * defaultAction} returns this value unless the method is + * overridden. + */ + protected final R DEFAULT_VALUE; + + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SharedSimpleTypeVisitor() { + DEFAULT_VALUE = null; + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SharedSimpleTypeVisitor(R defaultValue) { + DEFAULT_VALUE = defaultValue; + } + + /** + * The default action for visit methods. The implementation in + * this class just returns {@link #DEFAULT_VALUE}; subclasses will + * commonly override this method. + */ + protected R defaultAction(TypeMirror e, P p) { + return DEFAULT_VALUE; + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitPrimitive(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitNull(NullType t, P p){ + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitArray(ArrayType t, P p){ + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitDeclared(DeclaredType t, P p){ + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitError(ErrorType t, P p){ + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitTypeVariable(TypeVariable t, P p){ + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitWildcard(WildcardType t, P p){ + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitExecutable(ExecutableType t, P p) { + return defaultAction(t, p); + } + + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + public R visitNoType(NoType t, P p){ + return defaultAction(t, p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SharedTypeKindVisitor.java 2010-04-29 22:39:18.000000000 -0700 @@ -0,0 +1,264 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.type.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.element.ElementKind.*; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; + +/** + * Shared package private class to reduce code bloat. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @since 1.7 + */ +class SharedTypeKindVisitor extends SimpleTypeVisitor6 { + /** + * Constructor for concrete subclasses to call; uses {@code null} + * for the default value. + */ + protected SharedTypeKindVisitor() { + super(null); + } + + /** + * Constructor for concrete subclasses to call; uses the argument + * for the default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SharedTypeKindVisitor(R defaultValue) { + super(defaultValue); + } + + /** + * Visits a primitive type, dispatching to the visit method for + * the specific {@linkplain TypeKind kind} of primitive type: + * {@code BOOLEAN}, {@code BYTE}, etc. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of the kind-specific visit method + */ + @Override + public R visitPrimitive(PrimitiveType t, P p) { + TypeKind k = t.getKind(); + switch (k) { + case BOOLEAN: + return visitPrimitiveAsBoolean(t, p); + + case BYTE: + return visitPrimitiveAsByte(t, p); + + case SHORT: + return visitPrimitiveAsShort(t, p); + + case INT: + return visitPrimitiveAsInt(t, p); + + case LONG: + return visitPrimitiveAsLong(t, p); + + case CHAR: + return visitPrimitiveAsChar(t, p); + + case FLOAT: + return visitPrimitiveAsFloat(t, p); + + case DOUBLE: + return visitPrimitiveAsDouble(t, p); + + default: + throw new AssertionError("Bad kind " + k + " for PrimitiveType" + t); + } + } + + /** + * Visits a {@code BOOLEAN} primitive type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitPrimitiveAsBoolean(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@code BYTE} primitive type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitPrimitiveAsByte(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@code SHORT} primitive type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitPrimitiveAsShort(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits an {@code INT} primitive type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitPrimitiveAsInt(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@code LONG} primitive type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitPrimitiveAsLong(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@code CHAR} primitive type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitPrimitiveAsChar(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@code FLOAT} primitive type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitPrimitiveAsFloat(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@code DOUBLE} primitive type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitPrimitiveAsDouble(PrimitiveType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@link NoType} instance, dispatching to the visit method for + * the specific {@linkplain TypeKind kind} of pseudo-type: + * {@code VOID}, {@code PACKAGE}, or {@code NONE}. + * + * @param t {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of the kind-specific visit method + */ + @Override + public R visitNoType(NoType t, P p) { + TypeKind k = t.getKind(); + switch (k) { + case VOID: + return visitNoTypeAsVoid(t, p); + + case PACKAGE: + return visitNoTypeAsPackage(t, p); + + case NONE: + return visitNoTypeAsNone(t, p); + + default: + throw new AssertionError("Bad kind " + k + " for NoType" + t); + } + } + + /** + * Visits a {@link TypeKind#VOID VOID} pseudo-type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitNoTypeAsVoid(NoType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@link TypeKind#PACKAGE PACKAGE} pseudo-type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitNoTypeAsPackage(NoType t, P p) { + return defaultAction(t, p); + } + + /** + * Visits a {@link TypeKind#NONE NONE} pseudo-type by calling + * {@code defaultAction}. + * + * @param t the type to visit + * @param p a visitor-specified parameter + * @return the result of {@code defaultAction} + */ + public R visitNoTypeAsNone(NoType t, P p) { + return defaultAction(t, p); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java 2010-04-29 22:39:19.000000000 -0700 @@ -0,0 +1,92 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import java.util.List; +import javax.lang.model.element.*; + +import javax.lang.model.type.TypeMirror; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; +import javax.annotation.processing.SupportedSourceVersion; + +/** + * A simple visitor for annotation values with default behavior + * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} + * source version. Visit methods call {@link + * #defaultAction} passing their arguments to {@code defaultAction}'s + * corresponding parameters. + * + *

Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

WARNING: The {@code AnnotationValueVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new simple annotation + * value visitor class will also be introduced to correspond to the + * new language level; this visitor will have different default + * behavior for the visit method in question. When the new visitor is + * introduced, all or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods + * @param

the type of the additional parameter to this visitor's methods. + * + * @see SimpleAnnotationValueVisitor6 + * @since 1.7 + */ +@SupportedSourceVersion(RELEASE_7) +public class SimpleAnnotationValueVisitor7 + extends SharedSimpleAnnotationValueVisitor { + + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleAnnotationValueVisitor7() { + super(); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleAnnotationValueVisitor7(R defaultValue) { + super(defaultValue); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java 2010-04-29 22:39:19.000000000 -0700 @@ -0,0 +1,92 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.element.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.element.ElementKind.*; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + +/** + * A simple visitor of program elements with default behavior + * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} + * source version. + * + * Visit methods corresponding to {@code RELEASE_7} language + * constructs call {@link #defaultAction}, passing their arguments to + * {@code defaultAction}'s corresponding parameters. + * + *

Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

WARNING: The {@code ElementVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new simple element visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@code Void} + * for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's methods. Use {@code Void} + * for visitors that do not need an additional parameter. + * + * @see SimpleElementVisitor6 + * @since 1.7 + */ +@SupportedSourceVersion(RELEASE_7) +public class SimpleElementVisitor7 extends SharedSimpleElementVisitor { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleElementVisitor7(){ + super(); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleElementVisitor7(R defaultValue){ + super(defaultValue); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java 2010-04-29 22:39:19.000000000 -0700 @@ -0,0 +1,91 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.type.*; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + +/** + * A simple visitor of types with default behavior appropriate for the + * {@link SourceVersion#RELEASE_7 RELEASE_7} source version. + * + * Visit methods corresponding to {@code RELEASE_7} language + * constructs call {@link #defaultAction}, passing their arguments to + * {@code defaultAction}'s corresponding parameters. + * + *

Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

WARNING: The {@code TypeVisitor} interface implemented + * by this class may have methods added to it in the future to + * accommodate new, currently unknown, language structures added to + * future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new simple type visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see SimpleTypeVisitor6 + * @since 1.7 + */ +@SupportedSourceVersion(RELEASE_7) +public class SimpleTypeVisitor7 extends SharedSimpleTypeVisitor { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleTypeVisitor7(){ + super(); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleTypeVisitor7(R defaultValue){ + super(defaultValue); + } +} --- /dev/null 2009-07-06 20:02:10.000000000 -0700 +++ new/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java 2010-04-29 22:39:20.000000000 -0700 @@ -0,0 +1,95 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.lang.model.util; + +import javax.lang.model.type.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.element.ElementKind.*; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; + +/** + * A visitor of types based on their {@linkplain TypeKind kind} with + * default behavior appropriate for the {@link SourceVersion#RELEASE_7 + * RELEASE_7} source version. For {@linkplain + * TypeMirror types} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods + * call {@link #defaultAction defaultAction}, passing their arguments + * to {@code defaultAction}'s corresponding parameters. + * + *

Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

WARNING: The {@code TypeVisitor} interface implemented + * by this class may have methods added to it in the future to + * accommodate new, currently unknown, language structures added to + * future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new type kind visitor class + * will also be introduced to correspond to the new language level; + * this visitor will have different default behavior for the visit + * method in question. When the new visitor is introduced, all or + * portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see TypeKindVisitor6 + * @since 1.7 + */ +@SupportedSourceVersion(RELEASE_7) +public class TypeKindVisitor7 extends SharedTypeKindVisitor { + /** + * Constructor for concrete subclasses to call; uses {@code null} + * for the default value. + */ + protected TypeKindVisitor7() { + super(null); + } + + /** + * Constructor for concrete subclasses to call; uses the argument + * for the default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected TypeKindVisitor7(R defaultValue) { + super(defaultValue); + } +}