JEP 463: Implicitly Declared Classes (Second Preview) - Draft Spec Clarification

Leonid Arbuzov leonid.arbouzov at oracle.com
Tue Nov 28 18:08:52 UTC 2023


Hi Ron,

JLS 12.1 states that "The Java Virtual Machine starts execution by 
invoking the *method main* of some*specified class or interface*..."

You are right that Java SE doesn't say how exactly JVM is launched.
The JCK handles this by requesting an user to provide a command that 
start his tested JVM.
The command can be as script, a wrapper code, etc.
But it should be able to take a test main class name as an argument.
There are other ways to start JVM (for example, manually) but still the 
JCK should be able
to feed it with test main class name.

Also JCK compiler tests are run in two steps:
- a first step: to  run *tested *Java compiler that compile test sources 
and generate classes
- a second step: to run *reference *JVM to execute the generated classes 
- this is to verify that tested compiler generate proper classes.

To summarize: the JCK should be able to find out a test class name to be 
able to run it.

If the JCK doesn't know classes generated then it can skip the second step.
But obviously this would make JCK tests much weaker.

Thanks,
Leonid
JCK Team

On 11/28/2023 4:22 AM, Ron Pressler wrote:
>
>> On 27 Nov 2023, at 20:25, Leonid Arbuzov<leonid.arbouzov at oracle.com>  wrote:
>>
>>
>> How the JCK can launch a test class not knowing its name in an implementation-independent manner?
>>
> Is launching *any* Java program specified SE even if you do know the name of its main class?
>
> For example, JLS §12.1.4 specifies the `main` method but doesn’t specify how the main class is launched. Does it matter, then, that the chosen name for the main class is implementation-specific given that launching the main class is also implementation-specific?
>
> Perhaps the best way to test implicit classes, then, is from *within* the implicit class itself. Like any other main class, it is launched by some implementation-specific mechanism, but once you’re in it, everything is known. You can then get the chosen class name with `this.getClass()…`.
>
> — Ron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20231128/8f225e75/attachment-0001.htm>


More information about the amber-dev mailing list