Skip to content

Commit

Permalink
8321114: Rename "Unnamed Classes" to "Implicitly Declared Classes" be…
Browse files Browse the repository at this point in the history
…tter

Reviewed-by: jlaskey
  • Loading branch information
pavelrappo committed Dec 1, 2023
1 parent ecd335d commit 8f1d40b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,21 @@
* a class or interface is hidden has no bearing on the characteristics
* exposed by the methods of class {@code Class}.
*
* <h2><a id=implicitClasses>Implicit Classes</a></h2>
* <h2><a id=implicitClasses>Implicitly Declared Classes</a></h2>
*
* Conventionally, a Java compiler, starting from a source file for an
* implicit class, say {@code HelloWorld.java}, creates a
* implicitly declared class, say {@code HelloWorld.java}, creates a
* similarly-named {@code class} file, {@code HelloWorld.class}, where
* the class stored in that {@code class} file is named {@code
* "HelloWorld"}, matching the base names of the source and {@code
* class} files.
*
* For the {@code Class} object of an implicit class {@code
* For the {@code Class} object of an implicitly declared class {@code
* HelloWorld}, the methods to get the {@linkplain #getName name} and
* {@linkplain #getTypeName type name} return results
* equal to {@code "HelloWorld"}. The {@linkplain #getSimpleName
* simple name} of such an implicit class is {@code "HelloWorld"} and the
* {@linkplain #getCanonicalName canonical name} is {@code "HelloWorld"}.
* simple name} of such an implicitly declared class is {@code "HelloWorld"} and
* the {@linkplain #getCanonicalName canonical name} is {@code "HelloWorld"}.
*
* @param <T> the type of the class modeled by this {@code Class}
* object. For example, the type of {@code String.class} is {@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public enum Feature {
STRING_TEMPLATES,
@JEP(number=445, title="Unnamed Classes and Instance Main Methods", status="Deprecated")
UNNAMED_CLASSES,
@JEP(number=463, title="Implicit Classes and Instance Main Methods", status="Preview")
@JEP(number=463, title="Implicitly Declared Classes and Instance Main Methods", status="Preview")
IMPLICIT_CLASSES,
@JEP(number=446, title="Scoped Values", status="Preview")
SCOPED_VALUES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public interface Filer {
* 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.
* implicitly declared classes must be in an unnamed package.
*
* @apiNote To use a particular {@linkplain
* java.nio.charset.Charset charset} to encode the contents of the
Expand Down Expand Up @@ -266,7 +266,7 @@ JavaFileObject createSourceFile(CharSequence name,
* 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.
* implicitly declared classes must be in an unnamed package.
*
* @apiNote To avoid subsequent errors, the contents of the class
* file should be compatible with the {@linkplain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static EnumSet<Flag> asFlagSet(long flags) {
*/
public static final int HASINIT = 1<<18;

/** Class is a implicit top level class.
/** Class is an implicitly declared top level class.
*/
public static final int IMPLICIT_CLASS = 1<<19;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ public void setRecordComponents(List<RecordComponent> recordComponents) {
@DefinedBy(Api.LANGUAGE_MODEL)
public NestingKind getNestingKind() {
apiComplete();
if (owner.kind == PCK) // Handles implicit classes as well
if (owner.kind == PCK) // Handles implicitly declared classes as well
return NestingKind.TOP_LEVEL;
else if (name.isEmpty())
return NestingKind.ANONYMOUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3982,11 +3982,11 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
defs.appendList(semiList.toList());
boolean isTopLevelMethodOrField = false;

// Do to a significant number of existing negative tests
// Due to a significant number of existing negative tests
// this code speculatively tests to see if a top level method
// or field can parse. If the method or field can parse then
// it is parsed. Otherwise, parsing continues as though
// implicit classes did not exist and error reporting
// implicitly declared classes did not exist and error reporting
// is the same as in the past.
if (Feature.IMPLICIT_CLASSES.allowedInSource(source) && !isDeclaration()) {
final JCModifiers finalMods = mods;
Expand Down Expand Up @@ -4014,7 +4014,7 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
firstTypeDecl = false;
}
}
List<JCTree> topLevelDefs = isImplicitClass ? constructImplictClass(defs.toList()) : defs.toList();
List<JCTree> topLevelDefs = isImplicitClass ? constructImplicitClass(defs.toList()) : defs.toList();
JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(topLevelDefs);
if (!consumedToplevelDoc)
attach(toplevel, firstToken.docComment());
Expand All @@ -4029,8 +4029,8 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
return toplevel;
}

// Restructure top level to be an implicit class.
private List<JCTree> constructImplictClass(List<JCTree> origDefs) {
// Restructure top level to be an implicitly declared class.
private List<JCTree> constructImplicitClass(List<JCTree> origDefs) {
ListBuffer<JCTree> topDefs = new ListBuffer<>();
ListBuffer<JCTree> defs = new ListBuffer<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ compiler.err.bad.file.name=\
bad file name: {0}

compiler.err.implicit.class.should.not.have.package.declaration=\
implicit class should not have package declaration
implicitly declared class should not have package declaration

compiler.err.implicit.class.does.not.have.main.method=\
implicit class does not have main method in the form of void main() or void main(String[] args)
implicitly declared class does not have main method in the form of void main() or void main(String[] args)

# 0: name, 1: name
compiler.err.same.binary.name=\
Expand Down Expand Up @@ -3219,7 +3219,7 @@ compiler.misc.feature.unconditional.patterns.in.instanceof=\
unconditional patterns in instanceof

compiler.misc.feature.implicit.classes=\
implicit classes
implicitly declared classes

compiler.misc.feature.super.init=\
statements before super()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import javax.tools.JavaFileObject;

/**
* Test annotation processing representation of implicitly classes
* Test annotation processing representation of implicitly declared classes
* constructed from either a source file or a class file.
*/
@SuppressWarnings("preview")
Expand Down

1 comment on commit 8f1d40b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.