On Tue, 14 Mar 2023 14:30:32 GMT, Chen Liang <li...@openjdk.org> wrote:

> Add String constants INIT_NAME, CLASS_INIT_NAME, MTD_void for the names and 
> method type of instance and class initializers; add String constant MAIN_NAME 
> and MTD_void_StringArray for the name and method type of main method.
> 
> Update occurrences of <init> and <clinit> in core libraries API specification 
> to refer to these constants. The occurrences in code elsewhere will be 
> converted separately for there are too many.
> 
> See 
> https://mail.openjdk.org/pipermail/classfile-api-dev/2023-March/000233.html

src/java.base/share/classes/java/lang/constant/ConstantDescs.java line 288:

> 286:     /**
> 287:      * The special name of instance initialization methods, {@value}. 
> They
> 288:      * typically correspond to constructors.

What about this to describe the signature:

Suggestion:

     * The special name of instance initialization methods, {@value}.   An 
instance
     *  initialization method has this special name and is {@code void}.

src/java.base/share/classes/java/lang/constant/ConstantDescs.java line 297:

> 295:     /**
> 296:      * The special name of class initialization methods, {@value}. They
> 297:      * typically correspond to static initializers.

Suggestion:

     * The special name of class initialization methods, {@value}.  A class 
     * initialization method has this special name, {@link AccessFlag#STATIC 
     * ACC_STATIC} flag set and is {@link #MTD_void void} taking no arguments.

src/java.base/share/classes/java/lang/constant/ConstantDescs.java line 315:

> 313:      * @since 21
> 314:      */
> 315:     public static final MethodTypeDesc MTD_void = 
> MethodTypeDesc.of(CD_void);

This is a generic method type descriptor and not restrict to initialization 
methods.   So I think no need to mention that "This is the method type of 
initialization methods ..." and  `@jvms, @see and @jls" references.

Maybe it can be as simple as:



Nominal descriptor representing the method descriptor {@code ()V},
taking no argument and returning {@code void}.

src/java.base/share/classes/java/lang/constant/ConstantDescs.java line 326:

> 324:      * @since 21
> 325:      */
> 326:     public static final String MAIN_NAME = "main";

I'm not sure if predefined constants for "main" and its method type descriptor 
are highly needed.

-------------

PR: https://git.openjdk.org/jdk/pull/13020

Reply via email to