jshell has trouble to register some records in the environment

forax at univ-mlv.fr forax at univ-mlv.fr
Thu Dec 26 17:45:48 UTC 2019


> De: "Ali Ebrahimi" <ali.ebrahimi1781 at gmail.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Jeudi 26 Décembre 2019 17:48:35
> Objet: Re: jshell has trouble to register some records in the environment

> hi Remi,
> Is there typo in
> ...> return Math.hypot( with , height); // width

Thanks Ali ! 
Anyway, jshell should report this as an error. Is there an empty catch block somewhere ?? 

Rémi 

> On Thu, Dec 26, 2019 at 3:54 PM Remi Forax < [ mailto:forax at univ-mlv.fr |
> forax at univ-mlv.fr ] > wrote:

>> Hi all,
>> converting some materials for undergraduates, i have uncover a weird bug.

>> This snippet of code doesn't work in jshell
>> (jshell --enable-preview).

>> I get

>> jshell> record Rectangle(int width, int height) {
>> ...> double diagonal() {
>> ...> return Math.hypot(with, height);
>> ...> }
>> ...> }
>> ...> var rectangle2 = new Rectangle(4, 3);
>> ...> System.out.println(rectangle2.diagonal());
>> | Error:
>> | cannot find symbol
>> | symbol: class Rectangle
>> | var rectangle2 = new Rectangle(4, 3);
>> | ^-------^

>> So the class/record Rectangle doesn't seem to be registered ?
>> Changing it to

>> record Rectangle(int width, int height) {
>> double diagonal() {
>> return 5;
>> }
>> }
>> var rectangle2 = new Rectangle(4, 3);
>> System.out.println(rectangle2.diagonal());

>> do work ??

>> Rémi

> --

> Best Regards,
> Ali Ebrahimi


More information about the amber-dev mailing list