< prev index next >

src/java.compiler/share/classes/javax/lang/model/util/Elements.java

Print this page

        

@@ -57,16 +57,21 @@
     PackageElement getPackageElement(CharSequence name);
 
     /**
      * Returns a package given its fully qualified name, as seen from the given module.
      *
+     * @implSpec The default implementation of this method returns
+     * {@code 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.
      * If running with modules, all modules in the modules graph are searched for matching
      * type elements.

@@ -77,31 +82,41 @@
     TypeElement getTypeElement(CharSequence name);
 
     /**
      * Returns a type element given its canonical name, as seen from the given module.
      *
+     * @implSpec The default implementation of this method returns
+     * {@code 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.
      * If the named module cannot be found, null is returned. One situation where a module
      * cannot be found 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.
      *
+     * @implSpec The default implementation of this method returns
+     * {@code 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.
      *
      * @see AnnotationMirror#getElementValues()

@@ -335,15 +350,20 @@
      * an annotation processing environment configured for
      * a {@linkplain
      * javax.annotation.processing.ProcessingEnvironment#getSourceVersion
      * source version} without modules.
      *
+     * @implSpec The default implementation of this method returns
+     * {@code 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
      * declared directly.  For a class the result also includes its
      * constructors, but not local or anonymous classes.
< prev index next >