Re: Records are called „methods“ in JShell

Robert Field robert.field at oracle.com
Thu Jul 16 04:04:21 UTC 2020


Thanks for persisting with this!

I have filed a bug:

https://bugs.openjdk.java.net/browse/JDK-8249566

I am able to reproduce it (see bug).

You should be able to see it working correctly by doing:

    jshell> /set feedback normal

    jshell> public record ConstExpr(Expr e) implements Expr{}

See work-around suggestions in bug.

I will be looking into fixes.

Thanks,
Robert


On 2020-07-15 13:47, Lingo Coder wrote:
> Thank you so much, Robert!
>
>> Hopefully,
>>
>> /set format mymode typeKind "record" record
>>
>> Will fix your issue.
>
> I had high hopes for that [1] but...
>
> jshell> /set format mymode typeKind
> |  /set format mymode typeKind "class" class
> |  /set format mymode typeKind "interface" interface
> |  /set format mymode typeKind "enum" enum
> |  /set format mymode typeKind "annotation interface" annotation
>
> jshell> public record ConstExpr(Expr e) implements Expr{}
> |  created method ConstExpr(), however, it cannot be referenced until
> class Expr is declared
>
> jshell> /set format mymode typeKind "record" record
>
> jshell> /set format mymode typeKind
> |  /set format mymode typeKind "class" class
> |  /set format mymode typeKind "interface" interface
> |  /set format mymode typeKind "enum" enum
> |  /set format mymode typeKind "annotation interface" annotation
> |  /set format mymode typeKind "record" record
>
> jshell> public record ConstExpr(Expr e) implements Expr{}
> |  modified method ConstExpr(), however, it cannot be referenced until
> class Expr is declared
>
> ----
>
> [1] https://imgur.com/GaIgkOb
>
>
>
> -------- Original Message --------
> Subject: Re:_Records_are_called_„methods“_in_JSh ell
> From: Robert Field <robert.field at oracle.com>
> Date: Wed, July 15, 2020 11:09 am
> To: Lingo Coder <plugins at lingocoder.com>,
> "kulla-dev at openjdk.java.net" <kulla-dev at openjdk.java.net>,
> "jorn.vernee at oracle.com" <jorn.vernee at oracle.com>
>
> OK! There is the root of your issue.  You have your own mode, but it
> probably hasn't been updated for records.  You aren't using normal mode
> so, instead, show the output of:
>
>   /set format mymode typeKind
>
> Hopefully,
>
> /set format mymode typeKind "record" record
>
> Will fix your issue.
>
> -Robert
>
> On 7/15/20 7:33 AM, Lingo Coder wrote:
>> Thank you Robert,
>>
>>> „...And send us what it prints...“
>> You'll see below that right after I did `/set format normal typeKind`
>> it still said, „created *method*...“. I also recorded it. [1]
>>
>> But then right after `/set feedback verbose`, it said „created
>> *record*“.
>>
>> However, after an `/exit` and a relaunch of `jshell --enable-preview`,
>> it
>> reverted back to „created *method*...“/„dropped *method*... “.
>>
>> I _vaguely_ recall creating `mymode` and doing `/set feedback -retain
>> mymode`
>> way back in 2017 when JShell first came out. I think. I'm not 100% sure
>> tho.
>> So I'm guessing I need to do `/set feedback -retain verbose` to
>> permanently
>> get „created *record*...“ Correct?
>>
>> TIA.
>>
>> ----
>> ...
>>
>> jshell> /set feedback
>> | /set feedback -retain mymode
>> |
>> | Retained feedback modes:
>> | mymode
>> | Available feedback modes:
>> | concise
>> | mymode
>> | normal
>> | silent
>> | verbose
>>
>> jshell> /set format normal typeKind
>> | /set format normal typeKind "class" class
>> | /set format normal typeKind "interface" interface
>> | /set format normal typeKind "enum" enum
>> | /set format normal typeKind "annotation interface" annotation
>> | /set format normal typeKind "record" record
>>
>> jshell> public record ConstExpr(Expr e) implements Expr{}
>> | created method ConstExpr(), however, it cannot be referenced until
>> class Expr is declared
>>
>> jshell> /type
>> | record ConstExpr
>> | which cannot be referenced until class Expr is declared
>>
>> jshell> /types
>> | record ConstExpr
>> | which cannot be referenced until class Expr is declared
>>
>> jshell> /method
>> | void print(boolean)
>> | void print(char)
>> | void print(int)
>> | void print(long)
>> | void print(float)
>> | void print(double)
>> | void print(char s[])
>> | void print(String)
>> | void print(Object)
>> | void println()
>> | void println(boolean)
>> | void println(char)
>> | void println(int)
>> | void println(long)
>> | void println(float)
>> | void println(double)
>> | void println(char s[])
>> | void println(String)
>> | void println(Object)
>> | void printf(java.util.Locale,String,Object...)
>> | void printf(String,Object...)
>>
>> jshell> /drop ConstExpr
>> | dropped method ConstExpr()
>>
>> jshell> /set feedback verbose
>> | Feedback mode: verbose
>>
>> jshell> public record ConstExpr(Expr e) implements Expr{}
>> | created record ConstExpr, however, it cannot be referenced until
>> class Expr is declared
>>
>> jshell> /type
>> | record ConstExpr
>> | which cannot be referenced until class Expr is declared
>>
>> jshell> class Expr{}
>> | created class Expr
>>
>> jshell> /types
>> | record ConstExpr
>> | which cannot be referenced until this error is corrected:
>> | interface expected here
>> | public record ConstExpr(Expr e) implements Expr{}
>> | ^--^
>> | class Expr
>>
>> jshell> /drop Expr
>> | dropped class Expr
>>
>> jshell> interface Expr{}
>> | created interface Expr
>> | update replaced record ConstExpr
>>
>> jshell> /types
>> | record ConstExpr
>> | interface Expr
>>
>> jshell> /drop ConstExpr
>> | dropped record ConstExpr
>>
>> ...
>>
>> ----
>> [1] https://imgur.com/ePyilYo
>>
>>
>>
>> -------- Original Message --------
>> Subject: Re:_Records_are_called_„methods“_in_JSh ell
>> From: Robert Field <robert.field at oracle.com>
>> Date: Tue, July 14, 2020 8:07 pm
>> To: Lingo Coder <plugins at lingocoder.com>,
>> "kulla-dev at openjdk.java.net" <kulla-dev at openjdk.java.net>,
>> "jorn.vernee at oracle.com" <jorn.vernee at oracle.com>
>>
>> I have a theory, maybe the following can illuminate...
>>
>> Couple more things to try:
>>
>> /set feedback
>>
>> /set format normal typeKind
>>
>> And send us what it prints.
>>
>> Also, after you have entered:
>>
>> public record ConstExpr(Expr e) implements Expr{}
>>
>> Type:
>>
>> /type
>>
>> and
>>
>> /method
>>
>> Separately, what do they print?
>>
>> Oh, and if you want to try one more thing:
>>
>> /set feedback verbose
>>
>> public record ConstExpr(Expr e) implements Expr{}
>>
>> Sorry, I don't have Windows, but I believe Jan has access.
>>
>> -Robert
>>
>>
>> On 2020-07-14 18:35, Lingo Coder wrote:
>>> Thanks Robert,
>>>
>>>> „...Can you do:
>>>> jshell --full-version...“
>>> I did that. It says jshell 15-ea+31-1502 [1]
>>>
>>> What version of Windows are you other guys trying this in? I'm on
>>> Windows 7.
>>>
>>>> „...I'm guessing you may be using an older JDK...“
>>> As I show in [1] and in earlier screen recordings, I completely
>>> clear my $PATH to confirm that there is no other jshell.exe on
>>> the $PATH.
>>>
>>> I have not installed any JDKs with an installer or anything
>>> like that. For that reason, I rule out anything registry-related.
>>>
>>> I do have an early access release of 14-Valhalla
>>> build 14-valhalla+4-55 on my workstation. But, that was
>>> installed by simply unzipping the archive into a
>>> jdk-14.L.world.Build.14-valhalla+4-55 folder. More importantly,
>>> that build doesn't even have the records nor the sealed types
>>> features.
>>>
>>> I also have GA releases of OpenJDK 12 & 13 in their own folders.
>>> But again, not only are they isolated well out of the way of
>>> the $PATH I run jshell 15 in, they don't even have records and
>>> sealed types functionality.
>>>
>>> If _any_ other JDK were somehow in the $PATH, it would be
>>> surprising if records and sealed types even worked _at all_;
>>> let alone the misnaming as „methods“ issue Right? Please
>>> correct me if I'm wrong?
>>>
>>>
>>> [1] https://imgur.com/cMsAl5f
>>>
>>> -------- Original Message --------
>>> Subject: Re:_Records_are_called_„methods“_in_JSh ell
>>> From: Robert Field <robert.field at oracle.com>
>>> Date: Tue, July 14, 2020 3:57 pm
>>> To: kulla-dev at openjdk.java.net, jorn.vernee at oracle.com,
>>> plugins at lingocoder.com
>>>
>>> I'm guessing you may be using an older JDK. I get:
>>> jshell> public record ConstExpr(Expr e) implements Expr{}
>>> | created record ConstExpr
>>>
>>> jshell> /drop ConstExpr
>>> | dropped record ConstExpr
>>>
>>>
>>> Can you do:
>>> jshell --full-version
>>>
>>> Thanks,
>>> Robert
>>>
>>>
>>>


More information about the kulla-dev mailing list