From robert.field at oracle.com Wed Aug 5 18:48:33 2020 From: robert.field at oracle.com (Robert Field) Date: Wed, 5 Aug 2020 11:48:33 -0700 Subject: RFR 8247456: JShell: Handling of top-level final, abstract, and static modifiers Message-ID: <4e7344e5-751f-ae25-426f-fd831a04461f@oracle.com> Please review -- Issue: https://bugs.openjdk.java.net/browse/JDK-8247456 Webrev: http://cr.openjdk.java.net/~rfield/8247456v0.webrev/ Allows the pasting of abstract methods, by pre-corralling them. This allows reference before defined. Better handling of abstract on var errors. Ignores "static" modifier, without annoying warning. Final portion handled by sealed types fix. -Robert From plugins at lingocoder.com Fri Aug 7 23:14:57 2020 From: plugins at lingocoder.com (Lingo Coder) Date: Fri, 07 Aug 2020 16:14:57 -0700 Subject: Having to delete a sealed interface and start from scratch to add additional implementers, feels unintuitive Message-ID: <20200807161457.b6ff8ab09a6c540215cae158a90d7e03.aa59b503c4.wbe@email17.godaddy.com> I apologize if this is the wrong place to discuss a Sealed Interface/Records issue in JShell. The issue is: The only way to update a previously-created sealed interface in JShell, to add new/forgotten records to its permits list, is to first /drop the original interface, then declare the additional permitted record(s), then recreate the sealed interface from scratch; including the additional implementing record(s) in the permits clause of the recreated sealed interface. Steps to Reproduce 1. Launch jshell --enable-preview 2. Create a sealed interface jshell> sealed interface Animal permits Cat, Dog { String breed(); } | created interface Animal, however, it cannot be referenced until class Cat, and class Dog are declared 3. Create the two records that you just declared to implement the sealed interface: jshell> record Cat(String breed, String name) implements Animal{} jshell> record Dog(String breed, String name, boolean bites) implements Animal{} The interface and two records now exist: jshell> /types | interface Animal | record Cat | record Dog 5. Now /edit the interface to permit a third record: /edit Animal sealed interface Animal permits Cat, Dog, Fish { String breed(); } | Error: | cannot find symbol | symbol: class Fish | sealed interface Animal permits Cat, Dog, Fish { String breed();} | ^--^ | Error: | invalid permits clause | (illegal reference to supertype Fish) | sealed interface Animal permits Cat, Dog, Fish { String breed();} | ^-^ 4. No luck adding the third record either: jshell> record Fish(String breed, String color) implements Animal{} | Error: | class is not allowed to extend sealed class: Animal | record Fish(String breed, String color) implements Animal{} | ^---------------------------------------------------------^ It seems like I should be able to update the interface by simply /editing its declaration. It feels awkward and unintuitive to be unable to add additional implementations by /editing the permits in the interface's declaration. Are there plans to add that capability to JShell at any point in the future? Also, after several attempts at /editing the interface kept erroring, I observed that JShell got in such a state that even after deleting the interface to start over, adding the new record or recreating the interface crashed JShell. Until I can pin down a more reproducible pattern though, I'll assume that's more likely down to me having done something wrong. TIA. From plugins at lingocoder.com Sat Aug 8 09:07:05 2020 From: plugins at lingocoder.com (Lingo Coder) Date: Sat, 08 Aug 2020 02:07:05 -0700 Subject: Having to delete a sealed interface and start from scratch to add additional implementers, feels unintuitive Message-ID: <20200808020705.b6ff8ab09a6c540215cae158a90d7e03.57d60079db.wbe@email17.godaddy.com> My Environment: ------------------------------------------------------------ uname -a Linux lingocoder 4.15.0-76-generic #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux java -version openjdk version "15" 2020-09-15 OpenJDK Runtime Environment (build 15+35-1559) OpenJDK 64-Bit Server VM (build 15+35-1559, mixed mode, sharing) ------------------------------------------------------------ But the same thing happens on Windows amd64 with OpenJDK Runtime Environment (build 15-ea+31-1502) -------- Original Message -------- Subject: Having to delete a sealed interface and start from scratch to add additional implementers, feels unintuitive From: "Lingo Coder" Date: Fri, August 07, 2020 4:14 pm To: "kulla-dev at openjdk.java.net" I apologize if this is the wrong place to discuss a Sealed Interface/Records issue in JShell. The issue is: The only way to update a previously-created sealed interface in JShell, to add new/forgotten records to its permits list, is to first /drop the original interface, then declare the additional permitted record(s), then recreate the sealed interface from scratch; including the additional implementing record(s) in the permits clause of the recreated sealed interface. Steps to Reproduce 1. Launch jshell --enable-preview 2. Create a sealed interface jshell> sealed interface Animal permits Cat, Dog { String breed(); } | created interface Animal, however, it cannot be referenced until class Cat, and class Dog are declared 3. Create the two records that you just declared to implement the sealed interface: jshell> record Cat(String breed, String name) implements Animal{} jshell> record Dog(String breed, String name, boolean bites) implements Animal{} The interface and two records now exist: jshell> /types | interface Animal | record Cat | record Dog 5. Now /edit the interface to permit a third record: /edit Animal sealed interface Animal permits Cat, Dog, Fish { String breed(); } | Error: | cannot find symbol | symbol: class Fish | sealed interface Animal permits Cat, Dog, Fish { String breed();} | ^--^ | Error: | invalid permits clause | (illegal reference to supertype Fish) | sealed interface Animal permits Cat, Dog, Fish { String breed();} | ^-^ 4. No luck adding the third record either: jshell> record Fish(String breed, String color) implements Animal{} | Error: | class is not allowed to extend sealed class: Animal | record Fish(String breed, String color) implements Animal{} | ^---------------------------------------------------------^ It seems like I should be able to update the interface by simply /editing its declaration. It feels awkward and unintuitive to be unable to add additional implementations by /editing the permits in the interface's declaration. Are there plans to add that capability to JShell at any point in the future? Also, after several attempts at /editing the interface kept erroring, I observed that JShell got in such a state that even after deleting the interface to start over, adding the new record or recreating the interface crashed JShell. Until I can pin down a more reproducible pattern though, I'll assume that's more likely down to me having done something wrong. TIA.