Re: Records are called „methods“ in JShell
Robert Field
robert.field at oracle.com
Thu Jul 16 14:47:41 UTC 2020
Retained JShell tool settings are stored globally. They persist across
version/installation ...
To revert to normal just do this once:
/set feedback normal -retain
-Robert
On July 16, 2020 2:48:06 AM Lingo Coder <plugins at lingocoder.com> wrote:
> Thank you Robert, Jorn, and Jan,
>
> A couple last things. Please?
>
> 1. How is that `mymode` has persisted so long and
> is configured for every one of my JDKs since JDK9?
> Even though they are all in their own folders?
>
> I set `mymode` way back in 2017 in a JDK 9 install;
> that was so long ago that I'd forgotten it. Since
> then, I've used JDKs 10-15. They're all in their
> own folders.
>
> 2. Please, can anybody on the list recommend a thorough
> resource on advanced use of JShell? I've learned
> a lot about JShell from Java 9 Revealed — For Early
> Adoption and Migration by Kishor Sharan
>
> By „advanced“ I mean things like: How to configure the
> built-in default snippet editor on Windows, to open
> centered in the screen; instead of opening at an X * Y
> position that has most of the editor off screen at the
> bottom-right of the window.
>
> TIA.
>
> -------- Original Message --------
> Subject: Re:_Records_are_called_„methods“_in_JSh ell
> From: Robert Field <robert.field at oracle.com>
> Date: Wed, July 15, 2020 9:04 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>
>
> 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" recordWill 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" annotationjshell> public record ConstExpr(Expr e)
> implements Expr{}| created method ConstExpr(), however, it cannot be
> referenced untilclass Expr is declaredjshell> /set format mymode
> typeKind "record" recordjshell> /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" recordjshell> public record ConstExpr(Expr e) implements
> Expr{}| modified method ConstExpr(), however, it cannot be referenced
> untilclass Expr is declared----[1] https://imgur.com/GaIgkOb--------
> Original Message --------Subject:
> Re:_Records_are_called_„methods“_in_JSh ellFrom: Robert Field
> <robert.field at oracle.com>Date: Wed, July 15, 2020 11:09 amTo: 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 typeKindHopefully,/set format mymode typeKind "record" recordWill
> fix your issue.-RobertOn 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`,itreverted back to
> „created *method*...“/„dropped *method*... “.I _vaguely_ recall
> creating `mymode` and doing `/set feedback -retainmymode`way back in
> 2017 when JShell first came out. I think. I'm not 100% suretho.So I'm
> guessing I need to do `/set feedback -retain verbose` topermanentlyget
> „created *record*...“ Correct?TIA.----...jshell> /set feedback| /set
> feedback -retain mymode|| Retained feedback modes:| mymode| Available
> feedback modes:| concise| mymode| normal| silent| verbosejshell> /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" recordjshell> public
> record ConstExpr(Expr e) implements Expr{}| created method ConstExpr(),
> however, it cannot be referenced untilclass Expr is declaredjshell>
> /type| record ConstExpr| which cannot be referenced until class Expr is
> declaredjshell> /types| record ConstExpr| which cannot be referenced
> until class Expr is declaredjshell> /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: verbosejshell>
> public record ConstExpr(Expr e) implements Expr{}| created record
> ConstExpr, however, it cannot be referenced untilclass Expr is
> declaredjshell> /type| record ConstExpr| which cannot be referenced
> until class Expr is declaredjshell> class Expr{}| created class
> Exprjshell> /types| record ConstExpr| which cannot be referenced until
> this error is corrected:| interface expected here| public record
> ConstExpr(Expr e) implements Expr{}| ^--^| class Exprjshell> /drop Expr|
> dropped class Exprjshell> interface Expr{}| created interface Expr|
> update replaced record ConstExprjshell> /types| record ConstExpr|
> interface Exprjshell> /drop ConstExpr| dropped record
> ConstExpr...----[1] https://imgur.com/ePyilYo-------- Original Message
> --------Subject: Re:_Records_are_called_„methods“_in_JSh ellFrom:
> Robert Field <robert.field at oracle.com>Date: Tue, July 14, 2020 8:07
> pmTo: 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
> typeKindAnd send us what it prints.Also, after you have entered:public
> record ConstExpr(Expr e) implements
> Expr{}Type:/typeand/methodSeparately, what do they print?Oh, and if you
> want to try one more thing:/set feedback verbosepublic record
> ConstExpr(Expr e) implements Expr{}Sorry, I don't have Windows, but I
> believe Jan has access.-RobertOn 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 onWindows 7. „...I'm guessing you may
> be using an older JDK...“ As I show in [1] and in earlier screen
> recordings, I completelyclear my $PATH to confirm that there is no other
> jshell.exe onthe $PATH.I have not installed any JDKs with an installer
> or anythinglike that. For that reason, I rule out anything
> registry-related.I do have an early access release of 14-Valhallabuild
> 14-valhalla+4-55 on my workstation. But, that wasinstalled by simply
> unzipping the archive into ajdk-14.L.world.Build.14-valhalla+4-55
> folder. More importantly,that build doesn't even have the records nor
> the sealed typesfeatures.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 ofthe $PATH I run jshell 15 in, they don't even have records
> andsealed types functionality.If _any_ other JDK were somehow in the
> $PATH, it would besurprising if records and sealed types even worked _at
> all_;let alone the misnaming as „methods“ issue Right? Pleasecorrect
> me if I'm wrong?[1] https://imgur.com/cMsAl5f-------- Original Message
> --------Subject: Re:_Records_are_called_„methods“_in_JSh ellFrom:
> Robert Field <robert.field at oracle.com>Date: Tue, July 14, 2020 3:57
> pmTo: kulla-dev at openjdk.java.net,
> jorn.vernee at oracle.com,plugins at lingocoder.comI'm guessing you may be
> using an older JDK. I get:jshell> public record ConstExpr(Expr e)
> implements Expr{}| created record ConstExprjshell> /drop ConstExpr|
> dropped record ConstExprCan you do:jshell --full-versionThanks,Robert
More information about the kulla-dev
mailing list