jshell has trouble to register some records in the environment

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Thu Dec 26 16:48:35 UTC 2019


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

On Thu, Dec 26, 2019 at 3:54 PM Remi Forax <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