changeset 876:cad51b6eb7a6

6961571: Update visitors to support ARM's ElementKind.RESOURCE_VARIABLE Reviewed-by: jjg
author darcy
date Tue, 01 Feb 2011 10:11:05 -0800
parents 2ab47c4cd618
children 899f7c3d9426
files src/share/classes/javax/lang/model/type/DisjunctiveType.java src/share/classes/javax/lang/model/type/TypeKind.java src/share/classes/javax/lang/model/type/TypeVisitor.java src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java src/share/classes/javax/lang/model/util/ElementKindVisitor6.java src/share/classes/javax/lang/model/util/ElementKindVisitor7.java src/share/classes/javax/lang/model/util/ElementScanner6.java src/share/classes/javax/lang/model/util/ElementScanner7.java src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java src/share/classes/javax/lang/model/util/TypeKindVisitor7.java src/share/classes/javax/lang/model/util/Types.java test/tools/javac/processing/model/element/TestResourceVariable.java
diffstat 17 files changed, 276 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/javax/lang/model/type/DisjunctiveType.java	Tue Feb 01 10:11:05 2011 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package javax.lang.model.type;
+
+import java.util.List;
+
+/**
+ * Represents a disjunctive type.
+ *
+ * As of the {@link javax.lang.model.SourceVersion#RELEASE_7
+ * RELEASE_7} source version, disjunctive types can appear as the type
+ * of a multi-catch exception parameter.
+ *
+ * @since 1.7
+ */
+public interface DisjunctiveType extends TypeMirror {
+
+    /**
+     * Return the alternatives comprising this disjunctive type.
+     *
+     * The alternatives are formally referred to as <i>disjuncts</i>.
+     *
+     * @return the alternatives comprising this disjunctive type.
+     */
+    List<? extends TypeMirror> getAlternatives();
+}
--- a/src/share/classes/javax/lang/model/type/TypeKind.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/type/TypeKind.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -137,7 +137,14 @@
      * An implementation-reserved type.
      * This is not the type you are looking for.
      */
-    OTHER;
+    OTHER,
+
+    /**
+      * A disjunctive type.
+      *
+      * @since 1.7
+      */
+    DISJUNCTIVE;
 
     /**
      * Returns {@code true} if this kind corresponds to a primitive
--- a/src/share/classes/javax/lang/model/type/TypeVisitor.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/type/TypeVisitor.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -162,4 +162,14 @@
      *  a visitor implementation may optionally throw this exception
      */
     R visitUnknown(TypeMirror t, P p);
+
+    /**
+     * Visits a disjunctive type.
+     *
+     * @param t the type to visit
+     * @param p a visitor-specified parameter
+     * @return  a visitor-specified result
+     * @since 1.7
+     */
+    R visitDisjunctive(DisjunctiveType t, P p);
 }
--- a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,8 @@
 
 /**
  * A skeletal visitor of types with default behavior appropriate for
- * the version 6 language level.
+ * the {@link javax.lang.model.SourceVersion#RELEASE_6 RELEASE_6}
+ * source version.
  *
  * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
  * by this class may have methods added to it in the future to
@@ -95,6 +96,20 @@
     }
 
     /**
+     * Visits a {@code DisjunctiveType} element by calling {@code
+     * visitUnknown}.
+
+     * @param t  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of {@code visitUnknown}
+     *
+     * @since 1.7
+     */
+    public R visitDisjunctive(DisjunctiveType t, P p) {
+        return visitUnknown(t, p);
+    }
+
+    /**
      * {@inheritDoc}
      *
      * <p> The default implementation of this method in {@code
--- a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,8 @@
 
 /**
  * A skeletal visitor of types with default behavior appropriate for
- * the version 7 language level.
+ * the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7}
+ * source version.
  *
  * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
  * by this class may have methods added to it in the future to
@@ -64,4 +65,13 @@
     protected AbstractTypeVisitor7() {
         super();
     }
+
+    /**
+     * Visits a {@code DisjunctiveType} in a manner defined by a subclass.
+     *
+     * @param t  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of the visit as defined by a subclass
+     */
+    public abstract R visitDisjunctive(DisjunctiveType t, P p);
 }
--- a/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -199,7 +199,8 @@
      * 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}.
+     * {@code LOCAL_VARIABLE}, {@code PARAMETER}, or {@code RESOURCE_VARIABLE}.
+     *
      * @param e {@inheritDoc}
      * @param p {@inheritDoc}
      * @return  the result of the kind-specific visit method
@@ -223,10 +224,12 @@
         case PARAMETER:
             return visitVariableAsParameter(e, p);
 
+        case RESOURCE_VARIABLE:
+            return visitVariableAsResourceVariable(e, p);
+
         default:
             throw new AssertionError("Bad kind " + k + " for VariableElement" + e);
         }
-
     }
 
     /**
@@ -290,6 +293,20 @@
     }
 
     /**
+     * Visits a {@code RESOURCE_VARIABLE} variable element by calling
+     * {@code visitUnknown}.
+     *
+     * @param e the element to visit
+     * @param p a visitor-specified parameter
+     * @return  the result of {@code visitUnknown}
+     *
+     * @since 1.7
+     */
+    public R visitVariableAsResourceVariable(VariableElement e, P p) {
+        return visitUnknown(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
--- a/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
 /**
  * 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
+ * SourceVersion#RELEASE_7 RELEASE_7} source version.  For {@linkplain
  * Element elements} <tt><i>XYZ</i></tt> that may have more than one
  * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
  * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
@@ -94,4 +94,17 @@
     protected ElementKindVisitor7(R defaultValue) {
         super(defaultValue);
     }
+
+    /**
+     * Visits a {@code RESOURCE_VARIABLE} variable element by calling
+     * {@code defaultAction}.
+     *
+     * @param e {@inheritDoc}
+     * @param p {@inheritDoc}
+     * @return  the result of {@code defaultAction}
+     */
+    @Override
+    public R visitVariableAsResourceVariable(VariableElement e, P p) {
+        return defaultAction(e, p);
+    }
 }
--- a/src/share/classes/javax/lang/model/util/ElementScanner6.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/ElementScanner6.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -152,8 +152,8 @@
     /**
      * {@inheritDoc} This implementation scans the enclosed elements.
      *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
+     * @param e  {@inheritDoc}
+     * @param p  {@inheritDoc}
      * @return the result of scanning
      */
     public R visitPackage(PackageElement e, P p) {
@@ -163,8 +163,8 @@
     /**
      * {@inheritDoc} This implementation scans the enclosed elements.
      *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
+     * @param e  {@inheritDoc}
+     * @param p  {@inheritDoc}
      * @return the result of scanning
      */
     public R visitType(TypeElement e, P p) {
@@ -172,21 +172,28 @@
     }
 
     /**
-     * {@inheritDoc} This implementation scans the enclosed elements.
+     * {@inheritDoc}
      *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
+     * This implementation scans the enclosed elements, unless the
+     * element is a {@code RESOURCE_VARIABLE} in which case {@code
+     * visitUnknown} is called.
+     *
+     * @param e  {@inheritDoc}
+     * @param p  {@inheritDoc}
      * @return the result of scanning
      */
     public R visitVariable(VariableElement e, P p) {
-        return scan(e.getEnclosedElements(), p);
+        if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
+            return scan(e.getEnclosedElements(), p);
+        else
+            return visitUnknown(e, p);
     }
 
     /**
      * {@inheritDoc} This implementation scans the parameters.
      *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
+     * @param e  {@inheritDoc}
+     * @param p  {@inheritDoc}
      * @return the result of scanning
      */
     public R visitExecutable(ExecutableElement e, P p) {
@@ -196,8 +203,8 @@
     /**
      * {@inheritDoc} This implementation scans the enclosed elements.
      *
-     * @param e  the element to visit
-     * @param p  a visitor-specified parameter
+     * @param e  {@inheritDoc}
+     * @param p  {@inheritDoc}
      * @return the result of scanning
      */
     public R visitTypeParameter(TypeParameterElement e, P p) {
--- a/src/share/classes/javax/lang/model/util/ElementScanner7.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/ElementScanner7.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -105,4 +105,16 @@
     protected ElementScanner7(R defaultValue){
         super(defaultValue);
     }
+
+    /**
+     * This implementation scans the enclosed elements.
+     *
+     * @param e  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of scanning
+     */
+    @Override
+    public R visitVariable(VariableElement e, P p) {
+        return scan(e.getEnclosedElements(), p);
+    }
 }
--- a/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,8 @@
 /**
  * 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
+ * source version.  Visit methods call {@link #defaultAction
+ * defaultAction} passing their arguments to {@code defaultAction}'s
  * corresponding parameters.
  *
  * <p> Methods in this class may be overridden subject to their
--- a/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,8 +38,11 @@
  * source version.
  *
  * Visit methods corresponding to {@code RELEASE_6} language
- * constructs call {@link #defaultAction}, passing their arguments to
- * {@code defaultAction}'s corresponding parameters.
+ * constructs call {@link #defaultAction defaultAction}, passing their
+ * arguments to {@code defaultAction}'s corresponding parameters.
+ *
+ * For constructs introduced in {@code RELEASE_7} and later, {@code
+ * visitUnknown} is called instead.
  *
  * <p> Methods in this class may be overridden subject to their
  * general contract.  Note that annotating methods in concrete
@@ -137,14 +140,21 @@
     }
 
     /**
-     * {@inheritDoc} This implementation calls {@code defaultAction}.
+     * {@inheritDoc}
+     *
+     * This implementation calls {@code defaultAction}, unless the
+     * element is a {@code RESOURCE_VARIABLE} in which case {@code
+     * visitUnknown} is called.
      *
      * @param e {@inheritDoc}
      * @param p {@inheritDoc}
-     * @return  the result of {@code defaultAction}
+     * @return  the result of {@code defaultAction} or {@code visitUnknown}
      */
     public R visitVariable(VariableElement e, P p) {
-        return defaultAction(e, p);
+        if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
+            return defaultAction(e, p);
+        else
+            return visitUnknown(e, p);
     }
 
     /**
--- a/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,9 +36,10 @@
  * 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.
+ * Visit methods corresponding to {@code RELEASE_7} and earlier
+ * language constructs call {@link #defaultAction defaultAction},
+ * passing their arguments to {@code defaultAction}'s corresponding
+ * parameters.
  *
  * <p> Methods in this class may be overridden subject to their
  * general contract.  Note that annotating methods in concrete
@@ -89,4 +90,16 @@
     protected SimpleElementVisitor7(R defaultValue){
         super(defaultValue);
     }
+
+    /**
+     * This implementation calls {@code defaultAction}.
+     *
+     * @param e {@inheritDoc}
+     * @param p {@inheritDoc}
+     * @return  the result of {@code defaultAction}
+     */
+    @Override
+    public R visitVariable(VariableElement e, P p) {
+        return defaultAction(e, p);
+    }
 }
--- a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,11 @@
  * {@link SourceVersion#RELEASE_6 RELEASE_6} source version.
  *
  * Visit methods corresponding to {@code RELEASE_6} language
- * constructs call {@link #defaultAction}, passing their arguments to
- * {@code defaultAction}'s corresponding parameters.
+ * constructs call {@link #defaultAction defaultAction}, passing their
+ * arguments to {@code defaultAction}'s corresponding parameters.
+ *
+ * For constructs introduced in {@code RELEASE_7} and later, {@code
+ * visitUnknown} is called instead.
  *
  * <p> Methods in this class may be overridden subject to their
  * general contract.  Note that annotating methods in concrete
--- a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,9 +34,10 @@
  * 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.
+ * Visit methods corresponding to {@code RELEASE_7} and earlier
+ * language constructs call {@link #defaultAction defaultAction},
+ * passing their arguments to {@code defaultAction}'s corresponding
+ * parameters.
  *
  * <p> Methods in this class may be overridden subject to their
  * general contract.  Note that annotating methods in concrete
@@ -88,4 +89,17 @@
     protected SimpleTypeVisitor7(R defaultValue){
         super(defaultValue);
     }
+
+    /**
+     * This implementation visits a {@code DisjunctiveType} by calling
+     * {@code defaultAction}.
+     *
+     * @param t  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of {@code defaultAction}
+     */
+    @Override
+    public R visitDisjunctive(DisjunctiveType t, P p) {
+        return defaultAction(t, p);
+    }
 }
--- a/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,4 +92,17 @@
     protected TypeKindVisitor7(R defaultValue) {
         super(defaultValue);
     }
+
+    /**
+     * This implementation visits a {@code DisjunctiveType} by calling
+     * {@code defaultAction}.
+     *
+     * @param t  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of {@code defaultAction}
+     */
+    @Override
+    public R visitDisjunctive(DisjunctiveType t, P p) {
+        return defaultAction(t, p);
+    }
 }
--- a/src/share/classes/javax/lang/model/util/Types.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/src/share/classes/javax/lang/model/util/Types.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/tools/javac/processing/model/element/TestResourceVariable.java	Mon Jan 31 19:06:32 2011 -0800
+++ b/test/tools/javac/processing/model/element/TestResourceVariable.java	Tue Feb 01 10:11:05 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug  6911256 6964740 6967842
+ * @bug  6911256 6964740 6967842 6961571
  * @summary Test that the resource variable kind is appropriately set
  * @author  Joseph D. Darcy
  * @library ../../../lib
@@ -31,8 +31,6 @@
  * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
  */
 
-// Bug should be filed for this misbehavior
-
 import java.io.*;
 import javax.annotation.processing.*;
 import javax.lang.model.*;
@@ -82,6 +80,33 @@
         try(TestResourceVariable trv1 = this; TestResourceVariable trv2 = trv1) {}
     }
 
+    /**
+     * Verify that a resource variable modeled as an element behaves
+     * as expected under 6 and 7 specific visitors.
+     */
+    private static void testResourceVariable(Element element) {
+        ElementVisitor visitor6 = new ElementKindVisitor6<Void, Void>() {};
+
+        try {
+            visitor6.visit(element);
+            throw new RuntimeException("Expected UnknownElementException not thrown.");
+        } catch (UnknownElementException uee) {
+            ; // Expected.
+        }
+
+        ElementKindVisitor7 visitor7 = new ElementKindVisitor7<Object, Void>() {
+            @Override
+            public Object visitVariableAsResourceVariable(VariableElement e,
+                                                          Void p) {
+                return e; // a non-null value
+            }
+        };
+
+        if (visitor7.visit(element) == null) {
+            throw new RuntimeException("Null result of resource variable visitation.");
+        }
+    }
+
     class ResourceVariableScanner extends TreeScanner<Void, CompilationUnitTree> {
        private Trees trees;
 
@@ -92,17 +117,14 @@
        @Override
        public Void visitVariable(VariableTree node, CompilationUnitTree cu) {
            Element element = trees.getElement(trees.getPath(cu, node));
-           if (element == null) {
-               System.out.println("Null variable element: " + node);
-           } else {
-               System.out.println("Name: " + element.getSimpleName() +
-                                  "\tKind: " + element.getKind());
-           }
-           if (element != null &&
-               element.getKind() == ElementKind.RESOURCE_VARIABLE) {
+
+           System.out.println("Name: " + element.getSimpleName() +
+                              "\tKind: " + element.getKind());
+           if (element.getKind() == ElementKind.RESOURCE_VARIABLE) {
+               testResourceVariable(element);
                resourceVariableCount++;
            }
            return super.visitVariable(node, cu);
        }
-   }
+    }
 }