-
CSR
-
Resolution: Approved
-
P3
-
None
-
source
-
minimal
-
Preview APIs are generally subject to change.
-
Java API
-
SE
Summary
Remove annotation processing APIs for unnamed classes, remove documentation related to unnamed classes from javadoc.
Problem
In the second preview of this feature, support for unnamed classes has been dropped and replaced with implicit classes. The distinction between unnamed classes and implicit classes is that the implicit class syntax is purely syntactic sugar and the classes generated by the compiler are exactly like regular classes with no indication of their origin.
Solution
Remove annotation processing APIs that rely on the detectability of unnamed classes and remove documentation related to unnamed classes.
Specification
javax.lang.model.element.TypeElement::isUnnamed
is removed. This was the method was also used to detect an unnamed class. javax.lang.model.element.TypeElement::getSimpleName
and javax.lang.model.element.TypeElement::getQualifiedName()
have documentation removed related to unnamed classes.
javax.annotation.processing::Filer::createSourceFile
and javax.annotation.processing::Filer::createClassFile
have documentation removed related to unnamed classes.
diff --git a/src/java.compiler/share/classes/javax/annotation/processing/Filer.java b/src/java.compiler/share/classes/javax/annotation/processing/Filer.java
index 9ebcf2c5908..7487c1fb236 100644
--- a/src/java.compiler/share/classes/javax/annotation/processing/Filer.java
+++ b/src/java.compiler/share/classes/javax/annotation/processing/Filer.java
@@ -177,12 +177,11 @@ public interface Filer {
* <p>Creating a source file in or for an <em>unnamed</em> package in a <em>named</em>
* module is <em>not</em> supported.
*
- * <p>If the environment is configured to support {@linkplain
- * TypeElement#isUnnamed unnamed classes}, the name argument is
- * used to provide the leading component of the name used for the
- * output file. For example {@code filer.createSourceFile("Foo")}
- * to create an unnamed class hosted in {@code Foo.java}. All
- * unnamed classes must be in an unnamed package.
+ * <p>If the environment is configured to support implicitly declared
+ * classes, the name argument is used to provide the leading component of the
+ * name used for the output file. For example {@code filer.createSourceFile("Foo")}
+ * to create an implicitly declared class hosted in {@code Foo.java}. All
+ * implicit classes must be in an unnamed package.
*
* @apiNote To use a particular {@linkplain
* java.nio.charset.Charset charset} to encode the contents of the
@@ -263,12 +262,11 @@ JavaFileObject createSourceFile(CharSequence name,
* <p>Creating a class file in or for an <em>unnamed</em> package in a <em>named</em>
* module is <em>not</em> supported.
*
- * <p>If the environment is configured to support {@linkplain
- * TypeElement#isUnnamed unnamed classes}, the name argument is
- * used to provide the leading component of the name used for the
- * output file. For example {@code filer.createClassFile("Foo")} to
- * create an unnamed class hosted in {@code Foo.class}. All unnamed
- * classes must be in an unnamed package.
+ * <p>If the environment is configured to support implicitly declared
+ * classes, the name argument is used to provide the leading component of the
+ * name used for the output file. For example {@code filer.createSourceFile("Foo")}
+ * to create an implicitly declared class hosted in {@code Foo.java}. All
+ * implicit classes must be in an unnamed package.
*
* @apiNote To avoid subsequent errors, the contents of the class
* file should be compatible with the {@linkplain
diff --git a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
index d430e33e591..a8c3b91f8b5 100644
--- a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
+++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
@@ -155,7 +155,7 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
/**
* Returns the fully qualified name of this class or interface
* element. More precisely, it returns the <i>canonical</i> name.
- * For local, anonymous, and {@linkplain #isUnnamed() unnamed} classes, which do not have canonical
+ * For local, and anonymous classes, which do not have canonical
* names, an {@linkplain Name##empty_name empty name} is
* returned.
*
@@ -171,7 +171,6 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
*
* @see Elements#getBinaryName
* @jls 6.7 Fully Qualified Names and Canonical Names
- * @jls 7.3 Compilation Units
*/
Name getQualifiedName();
@@ -181,10 +180,6 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
* For an anonymous class, an {@linkplain Name##empty_name empty
* name} is returned.
*
- * For an {@linkplain #isUnnamed() unnamed} class, a name matching
- * the base name of the hosting file, minus any extension, is
- * returned.
- *
* @return the simple name of this class or interface,
* an empty name for an anonymous class
*
@@ -192,22 +187,6 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
@Override
Name getSimpleName();
- /**
- * {@return {@code true} if this is an unnamed class and {@code
- * false} otherwise}
- *
- * @implSpec
- * The default implementation of this method returns {@code false}.
- *
- * @jls 7.3 Compilation Units
- * @since 21
- */
- @PreviewFeature(feature=PreviewFeature.Feature.UNNAMED_CLASSES,
- reflective=true)
- default boolean isUnnamed() {
- return false;
- }
-
/**
* Returns the direct superclass of this class or interface element.
* If this class or interface element represents an interface or the class
PDFs of changed API javadocs enclosed.
- csr of
-
JDK-8319133 Implement JEP 463: Changes to annotation processing related to dropping unnamed classes
- Resolved
- relates to
-
JDK-8308831 javax.lang.model updates for JEP 445 (preview)
- Closed