Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -157,7 +157,7 @@ public SourceVersion getSupportedSourceVersion() {
*
* @implSpec
* Initializes the processor with the processing environment by
* setting the {@code processingEnv} field to the value of the
* setting the {@link #processingEnv} field to the value of the
* {@code processingEnv} argument. An {@code
* IllegalStateException} will be thrown if this method is called
* more than once on the same object.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -146,7 +146,7 @@ default Set<? extends Element> getElementsAnnotatedWithAny(TypeElement... annota
* processing. The set of annotation interfaces present in the runtime
* context may differ from the set of annotation interfaces present in
* the context of annotation processing in a particular
* environmental configuration. If an runtime annotation interface is
* environmental configuration. If a runtime annotation interface is
* not present in the annotation processing context, the situation
* is not treated as an error and no elements are found for that
* annotation interface.
Expand All @@ -173,7 +173,7 @@ default Set<? extends Element> getElementsAnnotatedWithAny(TypeElement... annota
* processing. The set of annotation interfaces present in the runtime
* context may differ from the set of annotation interfaces present in
* the context of annotation processing in a particular
* environmental configuration. If an runtime annotation interface is
* environmental configuration. If a runtime annotation interface is
* not present in the annotation processing context, the situation
* is not treated as an error and no elements are found for that
* annotation interface.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, 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
Expand Down Expand Up @@ -45,14 +45,14 @@
* <em>type annotation</em>.
*
* The terms <em>directly present</em>, <em>present</em>,
* <em>indirectly present</em>, and <em>associated </em> are used
* <em>indirectly present</em>, and <em>associated</em> are used
* throughout this interface to describe precisely which annotations,
* either declaration annotations or type annotations, are returned by
* the methods in this interface.
*
* <p>In the definitions below, an annotation <i>A</i> has an
* annotation interface <i>AI</i>. If <i>AI</i> is a repeatable annotation
* interface, the type of the containing annotation is <i>AIC</i>.
* interface, the type of the container annotation is <i>AIC</i>.
Copy link
Member

Choose a reason for hiding this comment

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

"the annotation interface of the container annotation is AIC"
or
"the containing annotation interface is AIC"

To align with the JLS.

Copy link
Member Author

Choose a reason for hiding this comment

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

"Type" is appropriate here and in some other locations in the AnnotatedConstruct javadoc. I paid attention to the difference between "contain-ing annotation interface" and "contain-er annotation".

@dansmithcode, please correct me if I'm wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

The "type" terminology is outdated and is already migrated to "class or interface" or the applicable subtype elsewhere: https://bugs.openjdk.org/browse/JDK-8257636 and commit 952dc70

Copy link
Member Author

Choose a reason for hiding this comment

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

The "type" terminology is outdated and is already migrated to "class or interface" or the applicable subtype elsewhere: https://bugs.openjdk.org/browse/JDK-8257636 and commit 952dc70

@liach, I respect you as a fellow JLS reader. Not only am I aware of that JBS issue, but I also remember the respective PR being reviewed.

Unsurprisingly, I had a similar knee-jerk reaction to the word "type". So, before publishing this PR, I asked a JLS expert on its use in this context. He replied that although in general "type" should not to be conflated with "interface"/"class", in this context it is reasonable to use "type".

However, if we do decide to abandon "type", we need to inspect every use of it in this class very carefully. The closest terminology that I could find is JLS 9.7.1

The TypeName specifies the annotation interface corresponding to the annotation. The annotation is said to be "of" that interface.

and JLS 9.6.3

An annotation interface A is repeatable if its declaration is (meta-)annotated with an @Repeatable annotation (§9.6.4.8) whose value element indicates a containing annotation interface of A.

Note how slightly dizzying the terminology is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Separately, maybe JLS hasn't done its homework in full? See 9.6.4.1. @Target:

It is a compile-time error if the same enum constant appears more than once in the value element of an annotation of type java.lang.annotation.Target.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that use of "type" in 9.6.4.1. feels like an overlook.

Copy link
Member Author

Choose a reason for hiding this comment

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

Chen, I suggest we integrate this PR as is but ask JLS experts/authors on the issue. In fact, I've already asked. I suspect that JLS 9.6.4.1 is germane to this discussion. If JLS changes "type" to "interface" in JLS 9.6.4.1, we could change these occurrences of "type" to "interface" in AnnotatedConstruct too.

Choose a reason for hiding this comment

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

There's really nothing wrong with talking about the type of an annotation, just like you can talk about the type of a variable. If it's the most intuitive way to express what you're trying to say, go for it!

*
* <p>Annotation <i>A</i> is <em>directly present</em> on a construct
* <i>C</i> if either:
Expand All @@ -78,7 +78,7 @@
* Specification</cite> (JLS {@jls 8.10.1}).
*
* If there are multiple annotations of type <i>AI</i> present on
* <i>C</i>, then if <i>AI</i> is repeatable annotation interface, an
* <i>C</i>, then if <i>AI</i> is a repeatable annotation interface, an
* annotation of type <i>AIC</i> is {@linkplain javax.lang.model.util.Elements#getOrigin(AnnotatedConstruct, AnnotationMirror) implicitly declared} on <i>C</i>.
* <li> A representation of <i>A</i> appears in the executable output
* for <i>C</i>, such as the {@code RuntimeVisibleAnnotations} (JVMS {@jvms 4.7.16}) or
Expand Down Expand Up @@ -189,10 +189,11 @@ public interface AnnotatedConstruct {
<A extends Annotation> A getAnnotation(Class<A> annotationType);

/**
* Returns annotations that are <em>associated</em> with this construct.
* Returns annotations of the specified type that are <em>associated</em>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Returns annotations of the specified type that are <em>associated</em>
* Returns annotations of the specified interface that are <em>associated</em>

Copy link
Member Author

Choose a reason for hiding this comment

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

Please see the entire javadoc, not just the parts ended up in this diff. There's one more method that uses this term. In general, "type" should not always be changed to "interface" in the context of annotations.

* with this construct.
*
* If there are no annotations associated with this construct, the
* return value is an array of length 0.
* If there are no annotations of the specified type associated with this
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* If there are no annotations of the specified type associated with this
* If there is no annotation of the specified interface associated with this

Copy link
Member Author

Choose a reason for hiding this comment

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

See the above comment on "type".

* construct, the return value is an array of length 0.
*
* The order of annotations which are directly or indirectly
* present on a construct <i>C</i> is computed as if indirectly present
Expand Down
23 changes: 11 additions & 12 deletions src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public enum SourceVersion {
* @see <a href="https://openjdk.org/jeps/213">
* JEP 213: Milling Project Coin</a>
*/
RELEASE_9,
RELEASE_9,

/**
* The version introduced by the Java Platform, Standard Edition
Expand Down Expand Up @@ -470,7 +470,7 @@ private static SourceVersion getLatestSupported() {
*
* @apiNote This method is included alongside {@link latest} to
* allow identification of situations where the language model API
* is running on a platform version different than the latest
* is running on a platform version different from the latest
* version modeled by the API. One way that sort of situation can
* occur is if an IDE or similar tool is using the API to model
* source version <i>N</i> while running on platform version
Expand All @@ -496,8 +496,7 @@ public static SourceVersion latestSupported() {
* followed only by characters for which {@link
* Character#isJavaIdentifierPart(int)} returns {@code true}.
* This pattern matches regular identifiers, keywords, contextual
* keywords, and the literals {@code "true"},
* {@code "false"}, {@code "null"}.
* keywords, boolean literals, and the null literal.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it is necessarily more clear remove the explicit listing of the strings in question.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps. I just thought that it's strange to spell them out only here, but refer to them through "x literal(s)" everywhere else in that file.

*
* The method returns {@code false} for all other strings.
*
Expand Down Expand Up @@ -590,14 +589,14 @@ public static boolean isName(CharSequence name, SourceVersion version) {
}

/**
* Returns whether or not {@code s} is a keyword, boolean literal,
* or null literal in the latest source version.
* Returns whether or not {@code s} is a keyword, a boolean literal,
* or the null literal in the latest source version.
* This method returns {@code false} for <i>contextual
* keywords</i>.
*
* @param s the string to check
* @return {@code true} if {@code s} is a keyword, or boolean
* literal, or null literal, {@code false} otherwise.
* @return {@code true} if {@code s} is a keyword, boolean
* literal, or the null literal, {@code false} otherwise.
* @jls 3.9 Keywords
* @jls 3.10.3 Boolean Literals
* @jls 3.10.8 The Null Literal
Expand All @@ -607,15 +606,15 @@ public static boolean isKeyword(CharSequence s) {
}

/**
* Returns whether or not {@code s} is a keyword, boolean literal,
* or null literal in the given source version.
* Returns whether or not {@code s} is a keyword, a boolean literal,
* or the null literal in the given source version.
* This method returns {@code false} for <i>contextual
* keywords</i>.
*
* @param s the string to check
* @param version the version to use
* @return {@code true} if {@code s} is a keyword, or boolean
* literal, or null literal, {@code false} otherwise.
* @return {@code true} if {@code s} is a keyword, boolean
* literal, or the null literal, {@code false} otherwise.
* @jls 3.9 Keywords
* @jls 3.10.3 Boolean Literals
* @jls 3.10.8 The Null Literal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -47,7 +47,7 @@ public interface AnnotationMirror {

/**
* Returns the values of this annotation's elements.
* This is returned in the form of a map that associates elements
* These are returned in the form of a map that associates elements
* with their corresponding values.
* Only those elements with values explicitly present in the
* annotation are included, not those that are implicitly assuming
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -34,7 +34,7 @@
* elements.
* Annotation interface elements are methods restricted to have no
* formal parameters, no type parameters, and no {@code throws}
* clause, among other restrictions; see JLS {@jls 9.6.1} for details
* clause, among other restrictions; see JLS {@jls 9.6.1} for details.
*
* @see ExecutableType
* @since 1.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
* javax.lang.model.util.Elements#getFileObjectOf(Element) reference
* representation} (either source code or executable output). Multiple
* classes and interfaces can share the same reference representation
* backing construct. For example, multiple classes and interface can
* be declared in the same source file, including, but are not limited
* backing construct. For example, multiple classes and interfaces can
* be declared in the same source file, including, but not limited
* to:
* <ul>
* <li> a {@linkplain NestingKind#TOP_LEVEL top-level} class or
* interface and auxiliary classes and interfaces
* <li>a top-level class or interface and {@linkplain
* NestingKind#isNested() nested class and interfaces} within it
* NestingKind#isNested() nested classes and interfaces} within it
* </ul>
* <p>In the context of annotation processing, a type element can
* be:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* elements, the declared entities that make up a program. Elements
* include classes, interfaces, methods, constructors, and fields.
* The interfaces in this package do not model the structure of a
* program inside a method body; for example there is no
* program inside a method body; for example, there is no
* representation of a {@code for} loop or {@code try}-{@code finally}
* block. Concretely, there is no model of any abstract syntax tree
* (AST) structure of a Java program. However, the interfaces can
Expand Down Expand Up @@ -84,7 +84,7 @@
* javax.lang.model.util.Elements#isBridge(ExecutableElement)
* bridge methods} used in implementing covariant returns, are
* translation artifacts strictly outside of this model. However, when
* operating on class files, it is helpful be able to operate on such
* operating on class files, it is helpful to be able to operate on such
* elements, screening them out when appropriate.
*
* <p>During annotation processing, operating on incomplete or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public interface Elements {
* <ul>
* <li>find non-empty packages with the given name returned by
* {@link #getPackageElement(ModuleElement, CharSequence)},
* where the provided ModuleSymbol is any
* where the provided ModuleElement is any
* {@linkplain java.lang.module##root-modules root module},
* </li>
* <li>if the above yields an empty list, search
* {@link #getAllModuleElements() all modules} for observable
* {@linkplain #getAllModuleElements() all modules} for observable
* packages with the given name
* </li>
* </ul>
Expand Down Expand Up @@ -143,11 +143,11 @@ default Set<? extends PackageElement> getAllPackageElements(CharSequence name) {
* <ul>
* <li>find type elements with the given name returned by
* {@link #getTypeElement(ModuleElement, CharSequence)},
* where the provided ModuleSymbol is any
* where the provided ModuleElement is any
* {@linkplain java.lang.module##root-modules root module},
* </li>
* <li>if the above yields an empty list, search
* {@link #getAllModuleElements() all modules} for observable
* {@linkplain #getAllModuleElements() all modules} for observable
* type elements with the given name
* </li>
* </ul>
Expand Down Expand Up @@ -617,7 +617,7 @@ default ModuleElement getModuleOf(Element e) {

/**
* Returns all members of a type element, whether inherited or
* declared directly. For a class the result also includes its
* declared directly. For a class, the result also includes its
* constructors, but not local or anonymous classes.
*
* @apiNote Elements of certain kinds can be isolated using
Expand Down Expand Up @@ -878,10 +878,10 @@ default TypeElement getEnumConstantBody(VariableElement enumConstant) {
* accessor.
*
* @implSpec The default implementation of this method checks if the element
* enclosing the accessor has kind {@link ElementKind#RECORD RECORD} if that is
* the case, then all the record components on the accessor's enclosing element
* are retrieved by invoking {@link ElementFilter#recordComponentsIn(Iterable)}.
* If the accessor of at least one of the record components retrieved happen to
* enclosing the accessor has kind {@link ElementKind#RECORD RECORD}, if that is
* the case, then all the record components of the accessor's enclosing element
* are isolated by invoking {@link ElementFilter#recordComponentsIn(Iterable)}.
* If the accessor of at least one of the record components retrieved happens to
* be equal to the accessor passed as a parameter to this method, then that
* record component is returned, in any other case {@code null} is returned.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* ExecutableType Executable types} and the pseudo-types for
* {@linkplain TypeKind#PACKAGE packages} and {@linkplain
* TypeKind#MODULE modules} are generally out of scope for these
* methods. One or more out of scope arguments will typically result
* methods. One or more out-of-scope arguments will typically result
* in a method throwing an {@link IllegalArgumentException}.
*
* <p>Where a method returns a type mirror or a collection of type
Expand Down Expand Up @@ -165,7 +165,7 @@ public interface Types {
* the direct supertypes of a type mirror representing {@code
* java.lang.Object}.
*
* Annotations on the direct super types are preserved.
* Annotations on the direct supertypes are preserved.
*
* @param t the type being examined
* @return the direct supertypes, or an empty list if none
Expand Down Expand Up @@ -318,7 +318,7 @@ WildcardType getWildcardType(TypeMirror extendsBound,
* Annotations on the type arguments are preserved.
*
* <p> If the containing type is a parameterized type,
* the number of type arguments must equal the
* the number of type arguments must be equal to the
* number of {@code typeElem}'s formal type parameters.
* If it is not parameterized or if it is {@code null}, this method is
* equivalent to {@code getDeclaredType(typeElem, typeArgs)}.
Expand Down Expand Up @@ -354,7 +354,7 @@ DeclaredType getDeclaredType(DeclaredType containing,
/**
* {@return a type mirror equivalent to the argument, but with no annotations}
* If the type mirror is a composite type, such as an array type
* or a wildcard type, any constitute types, such as the
* or a wildcard type, any constituent types, such as the
* component type of an array and the type of the bounds of a
* wildcard type, also have no annotations, recursively.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2024, 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
Expand Down Expand Up @@ -39,7 +39,7 @@
* additional fields and methods.
*
* <p>Unless stated otherwise, references in this class to "<em>this file object</em>"
* should be interpreted as referring indirectly to the {@link #fileObject delegate file object}.
* should be interpreted as referring indirectly to the {@linkplain #fileObject delegate file object}.
*
* @param <F> the kind of file object forwarded to by this object
* @since 1.6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -39,7 +39,7 @@
* additional fields and methods.
*
* <p>Unless stated otherwise, references in this class to "<em>this file manager</em>"
* should be interpreted as referring indirectly to the {@link #fileManager delegate file manager}.
* should be interpreted as referring indirectly to the {@linkplain #fileManager delegate file manager}.
*
* @param <M> the kind of file manager forwarded to by this object
* @since 1.6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -34,7 +34,7 @@
* additional fields and methods.
*
* <p>Unless stated otherwise, references in this class to "<em>this file object</em>"
* should be interpreted as referring indirectly to the {@link #fileObject delegate file object}.
* should be interpreted as referring indirectly to the {@linkplain #fileObject delegate file object}.
*
* @param <F> the kind of file object forwarded to by this object
* @since 1.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*
* <p>Some methods in this interface use class names. Such class
* names must be given in the Java Virtual Machine internal form of
* fully qualified class and interface names. For convenience '.'
* fully qualified class and interface names. For convenience, '.'
* and '/' are interchangeable. The internal form is defined in
* chapter four of
* <cite>The Java Virtual Machine Specification</cite>.
Expand Down Expand Up @@ -239,7 +239,7 @@ Iterable<JavaFileObject> list(Location location,
String inferBinaryName(Location location, JavaFileObject file);

/**
* Compares two file objects and return true if they represent the
* Compares two file objects and returns true if they represent the
* same underlying object.
*
* @param a a file object
Expand All @@ -255,7 +255,7 @@ Iterable<JavaFileObject> list(Location location,

/**
* Handles one option. If {@code current} is an option to this
* file manager it will consume any arguments to that option from
* file manager, it will consume any arguments to that option from
* {@code remaining} and return true, otherwise return false.
*
* @param current current option
Expand Down
Loading