Re: Records are called „methods“ in JShell

Robert Field robert.field at oracle.com
Tue Jul 14 22:57:15 UTC 2020


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


On 2020-07-14 11:47, Lingo Coder wrote:
> Thanks Jan,
>
>> „...the problem can be seen by running a few commands in JShell.“
> While I was awaiting your reply, I went ahead and did a script that
> contains exactly what I typed in the most recent screen recording [1].
>
> TIL — but you will already know — that running .jsh scripts don't
> produce the output typically seen in the REPL's interactive mode.
>
> So to repeat what I did in the recordings, you'll need to manually
> copy & paste the code into JShell interactively.
>
> Please correct me if I'm wrong, Jan. But am I correct in assuming
> that the JDK shouldn't behave differently on Windows 7 vs 10?
>
> TIA.
>
> ----
> [1] https://bit.ly/jshRecMeth
>
> -------- Original Message --------
> Subject: Re:_Records_are_called_„methods“_in_JSh ell
> From: Jan Lahoda <jan.lahoda at oracle.com>
> Date: Tue, July 14, 2020 11:11 am
> To: Lingo Coder <plugins at lingocoder.com>, kulla-dev
> <kulla-dev at openjdk.java.net>
> Cc: Jorn Vernee <jorn.vernee at oracle.com>
>
> On 14. 07. 20 18:58, Lingo Coder wrote:
>> Hi,
>>
>> Thanks for looking into this, Jan.
>>
>>> „...Would you have a small reproducible test case?...“
>> Sure. In what form would you prefer that? A .jsh or something?
> I am hoping the problem can be seen by running a few commands in JShell
> - if you could just write them here, that'd be enough. (I tried several
> commands based on the animations, but didn't succeed, so I am probably
> missing some detail somewhere.)
>
> Thanks,
>   Jan
>
>> For what it's worth, I'm on Windows 7 Professional 64 bit. I
>> mention that for completeness. It would be surprising to learn
>> that the JDK behaved differently on 7 than it does on 10.
>> Would you agree?
>>
>> TIA.
>>
>> -------- Original Message --------
>> Subject: Re:_Records_are_called_„methods“_in_JSh ell
>> From: Jan Lahoda <jan.lahoda at oracle.com>
>> Date: Tue, July 14, 2020 9:36 am
>> To: Lingo Coder <plugins at lingocoder.com>, kulla-dev
>> <kulla-dev at openjdk.java.net>
>> Cc: Jorn Vernee <jorn.vernee at oracle.com>
>>
>> Hi,
>>
>> Would you have a small reproducible test case? I don't seem to be able
>> to reproduce either.
>>
>> Thanks,
>> Jan
>>
>> On 14. 07. 20 18:15, Lingo Coder wrote:
>>> Hi,
>>>
>>> Thanks for looking into this, Jorn.
>>>
>>>> „...Are you sure that you are using the right jshell executable, and
>>> it's not picking up another one that's on the PATH as well?..“
>>>
>>> I'm sure :)
>>>
>>> I checked, rechecked and then, finally, rechecked that I rechecked.
>>>
>>> How I (re)checked:
>>>
>>> 1. I cleared the value of $PATH in the terminal where I run JShell
>>> 2. I then set the value of $PATH to be the file system location of the
>>> one and only installation of OpenJDK 15-ea (build 15-ea+31-1502)
>>> 3. I checked that the value of $PATH had only the one single entry
>>> 4. Does java -version report build 15-ea+31-1502? Confirmed!
>>> 5. I launched JShell
>>> 6. Created a record named „JShellChecker“;
>>> 7. Observed JShell reports: „created *method* JShellChecker“
>>> 8. Edited the record to implement a JShell .exe location check
>>> 9. JShell reports: „replaced *method* JShellChecker“
>>>
>>> Observe [1] to check that it is really happening as I describe.
>>>
>>> TIA.
>>>
>>> ----
>>> [1] https://imgur.com/NYBdYhn
>>>
>>>
>>>
>>>
>>> -------- Original Message --------
>>> Subject: Re:_Records_are_called_„methods“_in_JSh ell
>>> From: Jorn Vernee <jorn.vernee at oracle.com>
>>> Date: Tue, July 14, 2020 3:01 am
>>> To: Lingo Coder <plugins at lingocoder.com>
>>> Cc: kulla-dev <kulla-dev at openjdk.java.net>
>>>
>>> Hi,
>>>
>>> I was not able to reproduce this with JDK 15 build 31 (the same version
>>> that you are using).
>>>
>>> PS C:\Program Files\Java\jdk-15-b31\bin> ./jshell.exe --enable-preview
>>> | Welcome to JShell -- Version 15-ea
>>> | For an introduction type: /help intro
>>>
>>> jshell> public record Point(int x, int y) {}
>>> | created record Point
>>>
>>> jshell> /drop Point
>>> | dropped record Point
>>>
>>> Are you sure that you are using the right jshell executable, and it's
>>> not picking up another one that's on the PATH as well?
>>>
>>> Jorn
>>>
>>> On 14/07/2020 00:04, Michel Trudeau wrote:
>>>> [Moving this to kulla-dev]
>>>>
>>>> On Jul 12, 2020, at 4:35 PM, Lingo Coder <plugins at lingocoder.com> wrote:
>>>>
>>>> java -version
>>>> openjdk version "15-ea" 2020-09-15
>>>> OpenJDK Runtime Environment (build 15-ea+31-1502)
>>>> OpenJDK 64-Bit Server VM (build 15-ea+31-1502, mixed mode, sharing)
>>>>
>>>> OS: Windows amd64
>>>>
>>>> Steps to reproduce
>>>>
>>>> 1. Create some records...
>>>>
>>>> jshell>public record ConstExpr(Expr e) implements Expr{}
>>>>
>>>> jshell>public record PlusExpr(Expr a, Expr b) implements Expr{}
>>>>
>>>> jshell>public record TimesExpr(Expr x, Expr y) implements Expr{}
>>>>
>>>> jshell>public record NegExpr(Expr n) implements Expr{}
>>>>
>>>>
>>>> 2. Observe that JShell calls the records you just created,
>>>> „methods“...
>>>>
>>>> jshell> ...
>>>> | created method ConstExpr() ...
>>>> | created method PlusExpr() ...
>>>> | created method TimesExpr() ...
>>>> | created method NegExpr() ...
>>>>
>>>> 3. Delete those records. JShell says they're „methods“...
>>>>
>>>> jshell> /drop ConstExpr
>>>> | dropped method ConstExpr()
>>>>
>>>> jshell> /drop PlusExpr
>>>> | dropped method PlusExpr()
>>>>
>>>> jshell> /drop TimesExpr
>>>> | dropped method TimesExpr()
>>>>
>>>> jshell> /drop NegExpr
>>>> | dropped method NegExpr()
>>>>
>>>> Same deal with /edit. I did a screen recording if it's any help. [1]
>>>>
>>>> I couldn't reproduce this in Linux with the same JDK release/build. It
>>>> only happens on Windows.
>>>>
>>>> ----
>>>>
>>>> [1] https://i.imgur.com/ee8sJMf.gif
>>>>
>>>>


More information about the kulla-dev mailing list