6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE

Tue, 01 Feb 2011 10:11:05 -0800

author
darcy
date
Tue, 01 Feb 2011 10:11:05 -0800
changeset 851
cad51b6eb7a6
parent 850
2ab47c4cd618
child 852
899f7c3d9426

6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE
Reviewed-by: jjg

src/share/classes/javax/lang/model/type/DisjunctiveType.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/type/TypeKind.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/type/TypeVisitor.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/ElementKindVisitor6.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/ElementKindVisitor7.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/ElementScanner6.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/ElementScanner7.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/TypeKindVisitor7.java file | annotate | diff | comparison | revisions
src/share/classes/javax/lang/model/util/Types.java file | annotate | diff | comparison | revisions
test/tools/javac/processing/model/element/TestResourceVariable.java file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/javax/lang/model/type/DisjunctiveType.java	Tue Feb 01 10:11:05 2011 -0800
     1.3 @@ -0,0 +1,49 @@
     1.4 +/*
     1.5 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package javax.lang.model.type;
    1.30 +
    1.31 +import java.util.List;
    1.32 +
    1.33 +/**
    1.34 + * Represents a disjunctive type.
    1.35 + *
    1.36 + * As of the {@link javax.lang.model.SourceVersion#RELEASE_7
    1.37 + * RELEASE_7} source version, disjunctive types can appear as the type
    1.38 + * of a multi-catch exception parameter.
    1.39 + *
    1.40 + * @since 1.7
    1.41 + */
    1.42 +public interface DisjunctiveType extends TypeMirror {
    1.43 +
    1.44 +    /**
    1.45 +     * Return the alternatives comprising this disjunctive type.
    1.46 +     *
    1.47 +     * The alternatives are formally referred to as <i>disjuncts</i>.
    1.48 +     *
    1.49 +     * @return the alternatives comprising this disjunctive type.
    1.50 +     */
    1.51 +    List<? extends TypeMirror> getAlternatives();
    1.52 +}
     2.1 --- a/src/share/classes/javax/lang/model/type/TypeKind.java	Mon Jan 31 19:06:32 2011 -0800
     2.2 +++ b/src/share/classes/javax/lang/model/type/TypeKind.java	Tue Feb 01 10:11:05 2011 -0800
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -137,7 +137,14 @@
    2.11       * An implementation-reserved type.
    2.12       * This is not the type you are looking for.
    2.13       */
    2.14 -    OTHER;
    2.15 +    OTHER,
    2.16 +
    2.17 +    /**
    2.18 +      * A disjunctive type.
    2.19 +      *
    2.20 +      * @since 1.7
    2.21 +      */
    2.22 +    DISJUNCTIVE;
    2.23  
    2.24      /**
    2.25       * Returns {@code true} if this kind corresponds to a primitive
     3.1 --- a/src/share/classes/javax/lang/model/type/TypeVisitor.java	Mon Jan 31 19:06:32 2011 -0800
     3.2 +++ b/src/share/classes/javax/lang/model/type/TypeVisitor.java	Tue Feb 01 10:11:05 2011 -0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -162,4 +162,14 @@
    3.11       *  a visitor implementation may optionally throw this exception
    3.12       */
    3.13      R visitUnknown(TypeMirror t, P p);
    3.14 +
    3.15 +    /**
    3.16 +     * Visits a disjunctive type.
    3.17 +     *
    3.18 +     * @param t the type to visit
    3.19 +     * @param p a visitor-specified parameter
    3.20 +     * @return  a visitor-specified result
    3.21 +     * @since 1.7
    3.22 +     */
    3.23 +    R visitDisjunctive(DisjunctiveType t, P p);
    3.24  }
     4.1 --- a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java	Mon Jan 31 19:06:32 2011 -0800
     4.2 +++ b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java	Tue Feb 01 10:11:05 2011 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -29,7 +29,8 @@
    4.11  
    4.12  /**
    4.13   * A skeletal visitor of types with default behavior appropriate for
    4.14 - * the version 6 language level.
    4.15 + * the {@link javax.lang.model.SourceVersion#RELEASE_6 RELEASE_6}
    4.16 + * source version.
    4.17   *
    4.18   * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
    4.19   * by this class may have methods added to it in the future to
    4.20 @@ -95,6 +96,20 @@
    4.21      }
    4.22  
    4.23      /**
    4.24 +     * Visits a {@code DisjunctiveType} element by calling {@code
    4.25 +     * visitUnknown}.
    4.26 +
    4.27 +     * @param t  {@inheritDoc}
    4.28 +     * @param p  {@inheritDoc}
    4.29 +     * @return the result of {@code visitUnknown}
    4.30 +     *
    4.31 +     * @since 1.7
    4.32 +     */
    4.33 +    public R visitDisjunctive(DisjunctiveType t, P p) {
    4.34 +        return visitUnknown(t, p);
    4.35 +    }
    4.36 +
    4.37 +    /**
    4.38       * {@inheritDoc}
    4.39       *
    4.40       * <p> The default implementation of this method in {@code
     5.1 --- a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
     5.2 +++ b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -29,7 +29,8 @@
    5.11  
    5.12  /**
    5.13   * A skeletal visitor of types with default behavior appropriate for
    5.14 - * the version 7 language level.
    5.15 + * the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7}
    5.16 + * source version.
    5.17   *
    5.18   * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
    5.19   * by this class may have methods added to it in the future to
    5.20 @@ -64,4 +65,13 @@
    5.21      protected AbstractTypeVisitor7() {
    5.22          super();
    5.23      }
    5.24 +
    5.25 +    /**
    5.26 +     * Visits a {@code DisjunctiveType} in a manner defined by a subclass.
    5.27 +     *
    5.28 +     * @param t  {@inheritDoc}
    5.29 +     * @param p  {@inheritDoc}
    5.30 +     * @return the result of the visit as defined by a subclass
    5.31 +     */
    5.32 +    public abstract R visitDisjunctive(DisjunctiveType t, P p);
    5.33  }
     6.1 --- a/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java	Mon Jan 31 19:06:32 2011 -0800
     6.2 +++ b/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java	Tue Feb 01 10:11:05 2011 -0800
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -199,7 +199,8 @@
    6.11       * Visits a variable element, dispatching to the visit method for
    6.12       * the specific {@linkplain ElementKind kind} of variable, {@code
    6.13       * ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
    6.14 -     * {@code LOCAL_VARIABLE}, or {@code PARAMETER}.
    6.15 +     * {@code LOCAL_VARIABLE}, {@code PARAMETER}, or {@code RESOURCE_VARIABLE}.
    6.16 +     *
    6.17       * @param e {@inheritDoc}
    6.18       * @param p {@inheritDoc}
    6.19       * @return  the result of the kind-specific visit method
    6.20 @@ -223,10 +224,12 @@
    6.21          case PARAMETER:
    6.22              return visitVariableAsParameter(e, p);
    6.23  
    6.24 +        case RESOURCE_VARIABLE:
    6.25 +            return visitVariableAsResourceVariable(e, p);
    6.26 +
    6.27          default:
    6.28              throw new AssertionError("Bad kind " + k + " for VariableElement" + e);
    6.29          }
    6.30 -
    6.31      }
    6.32  
    6.33      /**
    6.34 @@ -290,6 +293,20 @@
    6.35      }
    6.36  
    6.37      /**
    6.38 +     * Visits a {@code RESOURCE_VARIABLE} variable element by calling
    6.39 +     * {@code visitUnknown}.
    6.40 +     *
    6.41 +     * @param e the element to visit
    6.42 +     * @param p a visitor-specified parameter
    6.43 +     * @return  the result of {@code visitUnknown}
    6.44 +     *
    6.45 +     * @since 1.7
    6.46 +     */
    6.47 +    public R visitVariableAsResourceVariable(VariableElement e, P p) {
    6.48 +        return visitUnknown(e, p);
    6.49 +    }
    6.50 +
    6.51 +    /**
    6.52       * Visits an executable element, dispatching to the visit method
    6.53       * for the specific {@linkplain ElementKind kind} of executable,
    6.54       * {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or
     7.1 --- a/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
     7.2 +++ b/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -34,7 +34,7 @@
    7.11  /**
    7.12   * A visitor of program elements based on their {@linkplain
    7.13   * ElementKind kind} with default behavior appropriate for the {@link
    7.14 - * SourceVersion#RELEASE_6 RELEASE_6} source version.  For {@linkplain
    7.15 + * SourceVersion#RELEASE_7 RELEASE_7} source version.  For {@linkplain
    7.16   * Element elements} <tt><i>XYZ</i></tt> that may have more than one
    7.17   * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
    7.18   * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
    7.19 @@ -94,4 +94,17 @@
    7.20      protected ElementKindVisitor7(R defaultValue) {
    7.21          super(defaultValue);
    7.22      }
    7.23 +
    7.24 +    /**
    7.25 +     * Visits a {@code RESOURCE_VARIABLE} variable element by calling
    7.26 +     * {@code defaultAction}.
    7.27 +     *
    7.28 +     * @param e {@inheritDoc}
    7.29 +     * @param p {@inheritDoc}
    7.30 +     * @return  the result of {@code defaultAction}
    7.31 +     */
    7.32 +    @Override
    7.33 +    public R visitVariableAsResourceVariable(VariableElement e, P p) {
    7.34 +        return defaultAction(e, p);
    7.35 +    }
    7.36  }
     8.1 --- a/src/share/classes/javax/lang/model/util/ElementScanner6.java	Mon Jan 31 19:06:32 2011 -0800
     8.2 +++ b/src/share/classes/javax/lang/model/util/ElementScanner6.java	Tue Feb 01 10:11:05 2011 -0800
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -152,8 +152,8 @@
    8.11      /**
    8.12       * {@inheritDoc} This implementation scans the enclosed elements.
    8.13       *
    8.14 -     * @param e  the element to visit
    8.15 -     * @param p  a visitor-specified parameter
    8.16 +     * @param e  {@inheritDoc}
    8.17 +     * @param p  {@inheritDoc}
    8.18       * @return the result of scanning
    8.19       */
    8.20      public R visitPackage(PackageElement e, P p) {
    8.21 @@ -163,8 +163,8 @@
    8.22      /**
    8.23       * {@inheritDoc} This implementation scans the enclosed elements.
    8.24       *
    8.25 -     * @param e  the element to visit
    8.26 -     * @param p  a visitor-specified parameter
    8.27 +     * @param e  {@inheritDoc}
    8.28 +     * @param p  {@inheritDoc}
    8.29       * @return the result of scanning
    8.30       */
    8.31      public R visitType(TypeElement e, P p) {
    8.32 @@ -172,21 +172,28 @@
    8.33      }
    8.34  
    8.35      /**
    8.36 -     * {@inheritDoc} This implementation scans the enclosed elements.
    8.37 +     * {@inheritDoc}
    8.38       *
    8.39 -     * @param e  the element to visit
    8.40 -     * @param p  a visitor-specified parameter
    8.41 +     * This implementation scans the enclosed elements, unless the
    8.42 +     * element is a {@code RESOURCE_VARIABLE} in which case {@code
    8.43 +     * visitUnknown} is called.
    8.44 +     *
    8.45 +     * @param e  {@inheritDoc}
    8.46 +     * @param p  {@inheritDoc}
    8.47       * @return the result of scanning
    8.48       */
    8.49      public R visitVariable(VariableElement e, P p) {
    8.50 -        return scan(e.getEnclosedElements(), p);
    8.51 +        if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
    8.52 +            return scan(e.getEnclosedElements(), p);
    8.53 +        else
    8.54 +            return visitUnknown(e, p);
    8.55      }
    8.56  
    8.57      /**
    8.58       * {@inheritDoc} This implementation scans the parameters.
    8.59       *
    8.60 -     * @param e  the element to visit
    8.61 -     * @param p  a visitor-specified parameter
    8.62 +     * @param e  {@inheritDoc}
    8.63 +     * @param p  {@inheritDoc}
    8.64       * @return the result of scanning
    8.65       */
    8.66      public R visitExecutable(ExecutableElement e, P p) {
    8.67 @@ -196,8 +203,8 @@
    8.68      /**
    8.69       * {@inheritDoc} This implementation scans the enclosed elements.
    8.70       *
    8.71 -     * @param e  the element to visit
    8.72 -     * @param p  a visitor-specified parameter
    8.73 +     * @param e  {@inheritDoc}
    8.74 +     * @param p  {@inheritDoc}
    8.75       * @return the result of scanning
    8.76       */
    8.77      public R visitTypeParameter(TypeParameterElement e, P p) {
     9.1 --- a/src/share/classes/javax/lang/model/util/ElementScanner7.java	Mon Jan 31 19:06:32 2011 -0800
     9.2 +++ b/src/share/classes/javax/lang/model/util/ElementScanner7.java	Tue Feb 01 10:11:05 2011 -0800
     9.3 @@ -1,5 +1,5 @@
     9.4  /*
     9.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
     9.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
     9.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8   *
     9.9   * This code is free software; you can redistribute it and/or modify it
    9.10 @@ -105,4 +105,16 @@
    9.11      protected ElementScanner7(R defaultValue){
    9.12          super(defaultValue);
    9.13      }
    9.14 +
    9.15 +    /**
    9.16 +     * This implementation scans the enclosed elements.
    9.17 +     *
    9.18 +     * @param e  {@inheritDoc}
    9.19 +     * @param p  {@inheritDoc}
    9.20 +     * @return the result of scanning
    9.21 +     */
    9.22 +    @Override
    9.23 +    public R visitVariable(VariableElement e, P p) {
    9.24 +        return scan(e.getEnclosedElements(), p);
    9.25 +    }
    9.26  }
    10.1 --- a/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
    10.2 +++ b/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
    10.3 @@ -1,5 +1,5 @@
    10.4  /*
    10.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    10.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    10.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.8   *
    10.9   * This code is free software; you can redistribute it and/or modify it
   10.10 @@ -36,8 +36,8 @@
   10.11  /**
   10.12   * A simple visitor for annotation values with default behavior
   10.13   * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
   10.14 - * source version.  Visit methods call {@link
   10.15 - * #defaultAction} passing their arguments to {@code defaultAction}'s
   10.16 + * source version.  Visit methods call {@link #defaultAction
   10.17 + * defaultAction} passing their arguments to {@code defaultAction}'s
   10.18   * corresponding parameters.
   10.19   *
   10.20   * <p> Methods in this class may be overridden subject to their
    11.1 --- a/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java	Mon Jan 31 19:06:32 2011 -0800
    11.2 +++ b/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java	Tue Feb 01 10:11:05 2011 -0800
    11.3 @@ -1,5 +1,5 @@
    11.4  /*
    11.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    11.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    11.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.8   *
    11.9   * This code is free software; you can redistribute it and/or modify it
   11.10 @@ -38,8 +38,11 @@
   11.11   * source version.
   11.12   *
   11.13   * Visit methods corresponding to {@code RELEASE_6} language
   11.14 - * constructs call {@link #defaultAction}, passing their arguments to
   11.15 - * {@code defaultAction}'s corresponding parameters.
   11.16 + * constructs call {@link #defaultAction defaultAction}, passing their
   11.17 + * arguments to {@code defaultAction}'s corresponding parameters.
   11.18 + *
   11.19 + * For constructs introduced in {@code RELEASE_7} and later, {@code
   11.20 + * visitUnknown} is called instead.
   11.21   *
   11.22   * <p> Methods in this class may be overridden subject to their
   11.23   * general contract.  Note that annotating methods in concrete
   11.24 @@ -137,14 +140,21 @@
   11.25      }
   11.26  
   11.27      /**
   11.28 -     * {@inheritDoc} This implementation calls {@code defaultAction}.
   11.29 +     * {@inheritDoc}
   11.30 +     *
   11.31 +     * This implementation calls {@code defaultAction}, unless the
   11.32 +     * element is a {@code RESOURCE_VARIABLE} in which case {@code
   11.33 +     * visitUnknown} is called.
   11.34       *
   11.35       * @param e {@inheritDoc}
   11.36       * @param p {@inheritDoc}
   11.37 -     * @return  the result of {@code defaultAction}
   11.38 +     * @return  the result of {@code defaultAction} or {@code visitUnknown}
   11.39       */
   11.40      public R visitVariable(VariableElement e, P p) {
   11.41 -        return defaultAction(e, p);
   11.42 +        if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
   11.43 +            return defaultAction(e, p);
   11.44 +        else
   11.45 +            return visitUnknown(e, p);
   11.46      }
   11.47  
   11.48      /**
    12.1 --- a/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
    12.2 +++ b/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
    12.3 @@ -1,5 +1,5 @@
    12.4  /*
    12.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    12.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    12.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.8   *
    12.9   * This code is free software; you can redistribute it and/or modify it
   12.10 @@ -36,9 +36,10 @@
   12.11   * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
   12.12   * source version.
   12.13   *
   12.14 - * Visit methods corresponding to {@code RELEASE_7} language
   12.15 - * constructs call {@link #defaultAction}, passing their arguments to
   12.16 - * {@code defaultAction}'s corresponding parameters.
   12.17 + * Visit methods corresponding to {@code RELEASE_7} and earlier
   12.18 + * language constructs call {@link #defaultAction defaultAction},
   12.19 + * passing their arguments to {@code defaultAction}'s corresponding
   12.20 + * parameters.
   12.21   *
   12.22   * <p> Methods in this class may be overridden subject to their
   12.23   * general contract.  Note that annotating methods in concrete
   12.24 @@ -89,4 +90,16 @@
   12.25      protected SimpleElementVisitor7(R defaultValue){
   12.26          super(defaultValue);
   12.27      }
   12.28 +
   12.29 +    /**
   12.30 +     * This implementation calls {@code defaultAction}.
   12.31 +     *
   12.32 +     * @param e {@inheritDoc}
   12.33 +     * @param p {@inheritDoc}
   12.34 +     * @return  the result of {@code defaultAction}
   12.35 +     */
   12.36 +    @Override
   12.37 +    public R visitVariable(VariableElement e, P p) {
   12.38 +        return defaultAction(e, p);
   12.39 +    }
   12.40  }
    13.1 --- a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java	Mon Jan 31 19:06:32 2011 -0800
    13.2 +++ b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java	Tue Feb 01 10:11:05 2011 -0800
    13.3 @@ -1,5 +1,5 @@
    13.4  /*
    13.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    13.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    13.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.8   *
    13.9   * This code is free software; you can redistribute it and/or modify it
   13.10 @@ -36,8 +36,11 @@
   13.11   * {@link SourceVersion#RELEASE_6 RELEASE_6} source version.
   13.12   *
   13.13   * Visit methods corresponding to {@code RELEASE_6} language
   13.14 - * constructs call {@link #defaultAction}, passing their arguments to
   13.15 - * {@code defaultAction}'s corresponding parameters.
   13.16 + * constructs call {@link #defaultAction defaultAction}, passing their
   13.17 + * arguments to {@code defaultAction}'s corresponding parameters.
   13.18 + *
   13.19 + * For constructs introduced in {@code RELEASE_7} and later, {@code
   13.20 + * visitUnknown} is called instead.
   13.21   *
   13.22   * <p> Methods in this class may be overridden subject to their
   13.23   * general contract.  Note that annotating methods in concrete
    14.1 --- a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
    14.2 +++ b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
    14.3 @@ -1,5 +1,5 @@
    14.4  /*
    14.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    14.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    14.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.8   *
    14.9   * This code is free software; you can redistribute it and/or modify it
   14.10 @@ -34,9 +34,10 @@
   14.11   * A simple visitor of types with default behavior appropriate for the
   14.12   * {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
   14.13   *
   14.14 - * Visit methods corresponding to {@code RELEASE_7} language
   14.15 - * constructs call {@link #defaultAction}, passing their arguments to
   14.16 - * {@code defaultAction}'s corresponding parameters.
   14.17 + * Visit methods corresponding to {@code RELEASE_7} and earlier
   14.18 + * language constructs call {@link #defaultAction defaultAction},
   14.19 + * passing their arguments to {@code defaultAction}'s corresponding
   14.20 + * parameters.
   14.21   *
   14.22   * <p> Methods in this class may be overridden subject to their
   14.23   * general contract.  Note that annotating methods in concrete
   14.24 @@ -88,4 +89,17 @@
   14.25      protected SimpleTypeVisitor7(R defaultValue){
   14.26          super(defaultValue);
   14.27      }
   14.28 +
   14.29 +    /**
   14.30 +     * This implementation visits a {@code DisjunctiveType} by calling
   14.31 +     * {@code defaultAction}.
   14.32 +     *
   14.33 +     * @param t  {@inheritDoc}
   14.34 +     * @param p  {@inheritDoc}
   14.35 +     * @return the result of {@code defaultAction}
   14.36 +     */
   14.37 +    @Override
   14.38 +    public R visitDisjunctive(DisjunctiveType t, P p) {
   14.39 +        return defaultAction(t, p);
   14.40 +    }
   14.41  }
    15.1 --- a/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
    15.2 +++ b/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
    15.3 @@ -1,5 +1,5 @@
    15.4  /*
    15.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    15.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    15.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.8   *
    15.9   * This code is free software; you can redistribute it and/or modify it
   15.10 @@ -92,4 +92,17 @@
   15.11      protected TypeKindVisitor7(R defaultValue) {
   15.12          super(defaultValue);
   15.13      }
   15.14 +
   15.15 +    /**
   15.16 +     * This implementation visits a {@code DisjunctiveType} by calling
   15.17 +     * {@code defaultAction}.
   15.18 +     *
   15.19 +     * @param t  {@inheritDoc}
   15.20 +     * @param p  {@inheritDoc}
   15.21 +     * @return the result of {@code defaultAction}
   15.22 +     */
   15.23 +    @Override
   15.24 +    public R visitDisjunctive(DisjunctiveType t, P p) {
   15.25 +        return defaultAction(t, p);
   15.26 +    }
   15.27  }
    16.1 --- a/src/share/classes/javax/lang/model/util/Types.java	Mon Jan 31 19:06:32 2011 -0800
    16.2 +++ b/src/share/classes/javax/lang/model/util/Types.java	Tue Feb 01 10:11:05 2011 -0800
    16.3 @@ -1,5 +1,5 @@
    16.4  /*
    16.5 - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
    16.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    16.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.8   *
    16.9   * This code is free software; you can redistribute it and/or modify it
    17.1 --- a/test/tools/javac/processing/model/element/TestResourceVariable.java	Mon Jan 31 19:06:32 2011 -0800
    17.2 +++ b/test/tools/javac/processing/model/element/TestResourceVariable.java	Tue Feb 01 10:11:05 2011 -0800
    17.3 @@ -1,5 +1,5 @@
    17.4  /*
    17.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    17.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
    17.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.8   *
    17.9   * This code is free software; you can redistribute it and/or modify it
   17.10 @@ -23,7 +23,7 @@
   17.11  
   17.12  /*
   17.13   * @test
   17.14 - * @bug  6911256 6964740 6967842
   17.15 + * @bug  6911256 6964740 6967842 6961571
   17.16   * @summary Test that the resource variable kind is appropriately set
   17.17   * @author  Joseph D. Darcy
   17.18   * @library ../../../lib
   17.19 @@ -31,8 +31,6 @@
   17.20   * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
   17.21   */
   17.22  
   17.23 -// Bug should be filed for this misbehavior
   17.24 -
   17.25  import java.io.*;
   17.26  import javax.annotation.processing.*;
   17.27  import javax.lang.model.*;
   17.28 @@ -82,6 +80,33 @@
   17.29          try(TestResourceVariable trv1 = this; TestResourceVariable trv2 = trv1) {}
   17.30      }
   17.31  
   17.32 +    /**
   17.33 +     * Verify that a resource variable modeled as an element behaves
   17.34 +     * as expected under 6 and 7 specific visitors.
   17.35 +     */
   17.36 +    private static void testResourceVariable(Element element) {
   17.37 +        ElementVisitor visitor6 = new ElementKindVisitor6<Void, Void>() {};
   17.38 +
   17.39 +        try {
   17.40 +            visitor6.visit(element);
   17.41 +            throw new RuntimeException("Expected UnknownElementException not thrown.");
   17.42 +        } catch (UnknownElementException uee) {
   17.43 +            ; // Expected.
   17.44 +        }
   17.45 +
   17.46 +        ElementKindVisitor7 visitor7 = new ElementKindVisitor7<Object, Void>() {
   17.47 +            @Override
   17.48 +            public Object visitVariableAsResourceVariable(VariableElement e,
   17.49 +                                                          Void p) {
   17.50 +                return e; // a non-null value
   17.51 +            }
   17.52 +        };
   17.53 +
   17.54 +        if (visitor7.visit(element) == null) {
   17.55 +            throw new RuntimeException("Null result of resource variable visitation.");
   17.56 +        }
   17.57 +    }
   17.58 +
   17.59      class ResourceVariableScanner extends TreeScanner<Void, CompilationUnitTree> {
   17.60         private Trees trees;
   17.61  
   17.62 @@ -92,17 +117,14 @@
   17.63         @Override
   17.64         public Void visitVariable(VariableTree node, CompilationUnitTree cu) {
   17.65             Element element = trees.getElement(trees.getPath(cu, node));
   17.66 -           if (element == null) {
   17.67 -               System.out.println("Null variable element: " + node);
   17.68 -           } else {
   17.69 -               System.out.println("Name: " + element.getSimpleName() +
   17.70 -                                  "\tKind: " + element.getKind());
   17.71 -           }
   17.72 -           if (element != null &&
   17.73 -               element.getKind() == ElementKind.RESOURCE_VARIABLE) {
   17.74 +
   17.75 +           System.out.println("Name: " + element.getSimpleName() +
   17.76 +                              "\tKind: " + element.getKind());
   17.77 +           if (element.getKind() == ElementKind.RESOURCE_VARIABLE) {
   17.78 +               testResourceVariable(element);
   17.79                 resourceVariableCount++;
   17.80             }
   17.81             return super.visitVariable(node, cu);
   17.82         }
   17.83 -   }
   17.84 +    }
   17.85  }

mercurial