--- old/src/java.compiler/share/classes/javax/lang/model/element/Element.java 2017-02-01 12:13:24.828591070 -0800
+++ new/src/java.compiler/share/classes/javax/lang/model/element/Element.java 2017-02-01 12:13:24.728591066 -0800
@@ -139,7 +139,7 @@
*
*
If this is a {@linkplain
* PackageElement#getEnclosingElement package}, its module is
- * returned.
+ * returned if such a module exists. Otherwise, {@code null} is returned.
*
* If this is a {@linkplain
* TypeParameterElement#getEnclosingElement type parameter},
--- old/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java 2017-02-01 12:13:25.148591081 -0800
+++ new/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java 2017-02-01 12:13:25.044591078 -0800
@@ -83,9 +83,16 @@
boolean isUnnamed();
/**
- * Returns the enclosing module.
+ * Returns the enclosing module if such a module exists; otherwise
+ * returns {@code null}.
*
- * @return the enclosing module
+ * One situation where a module does not exist for a package is if
+ * the environment does not include modules, such as an annotation
+ * processing environment configured for a {@linkplain
+ * javax.annotation.processing.ProcessingEnvironment#getSourceVersion
+ * source version} without modules.
+ *
+ * @return the enclosing module or {@code null} if no such module exists
*/
@Override
Element getEnclosingElement();
--- old/src/java.compiler/share/classes/javax/lang/model/type/NoType.java 2017-02-01 12:13:25.480591093 -0800
+++ new/src/java.compiler/share/classes/javax/lang/model/type/NoType.java 2017-02-01 12:13:25.380591090 -0800
@@ -34,6 +34,7 @@
*
* - {@link TypeKind#VOID VOID} - corresponds to the keyword {@code void}.
*
- {@link TypeKind#PACKAGE PACKAGE} - the pseudo-type of a package element.
+ *
- {@link TypeKind#MODULE MODULE} - the pseudo-type of a module element.
*
- {@link TypeKind#NONE NONE} - used in other cases
* where no actual type is appropriate; for example, the superclass
* of {@code java.lang.Object}.
--- old/src/java.compiler/share/classes/javax/lang/model/util/Elements.java 2017-02-01 12:13:25.784591104 -0800
+++ new/src/java.compiler/share/classes/javax/lang/model/util/Elements.java 2017-02-01 12:13:25.680591100 -0800
@@ -59,12 +59,17 @@
/**
* Returns a package given its fully qualified name, as seen from the given module.
*
+ * @implSpec The default implementation of this method returns
+ * null.
+ *
* @param name fully qualified package name, or an empty string for an unnamed package
* @param module module relative to which the lookup should happen
* @return the specified package, or {@code null} if it cannot be found
* @since 9
*/
- PackageElement getPackageElement(ModuleElement module, CharSequence name);
+ default PackageElement getPackageElement(ModuleElement module, CharSequence name) {
+ return null;
+ }
/**
* Returns a type element given its canonical name if the type element is unique in the environment.
@@ -79,12 +84,17 @@
/**
* Returns a type element given its canonical name, as seen from the given module.
*
+ * @implSpec The default implementation of this method returns
+ * null.
+ *
* @param name the canonical name
* @param module module relative to which the lookup should happen
* @return the named type element, or {@code null} if it cannot be found
* @since 9
*/
- TypeElement getTypeElement(ModuleElement module, CharSequence name);
+ default TypeElement getTypeElement(ModuleElement module, CharSequence name) {
+ return null;
+ }
/**
* Returns a module element given its fully qualified name.
@@ -95,11 +105,16 @@
* javax.annotation.processing.ProcessingEnvironment#getSourceVersion
* source version} without modules.
*
+ * @implSpec The default implementation of this method returns
+ * null.
+ *
* @param name the name
* @return the named module element, or {@code null} if it cannot be found
* @since 9
*/
- ModuleElement getModuleElement(CharSequence name);
+ default ModuleElement getModuleElement(CharSequence name) {
+ return null;
+ }
/**
* Returns the values of an annotation's elements, including defaults.
@@ -337,11 +352,16 @@
* javax.annotation.processing.ProcessingEnvironment#getSourceVersion
* source version} without modules.
*
+ * @implSpec The default implementation of this method returns
+ * null.
+ *
* @param type the element being examined
* @return the module of an element
* @since 9
*/
- ModuleElement getModuleOf(Element type);
+ default ModuleElement getModuleOf(Element type) {
+ return null;
+ }
/**
* Returns all members of a type element, whether inherited or