Integrated: 8327512: JShell does not work correctly when a class named Object or Throwable is defined
Jan Lahoda
jlahoda at openjdk.org
Fri Apr 26 07:26:40 UTC 2024
On Thu, 14 Mar 2024 10:22:04 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> When JShell wraps the user's snippets with additional code to make the standalone compilable units, it uses simple names to refer to `Object`, `Throwable` or `SuppressWarnings` in some cases. These may interact with user-defined class of the same names, leading to error while running the next snippet. E.g.:
>
> jshell> class Object{}
> | created class Object
>
> jshell> 1
> | Error:
> | incompatible types: int cannot be converted to Object
> | 1
> | ^
>
>
> The proposal here is to use qualified names when creating the snippet wrappers, and to more carefully produce simple names when analyzing expressions (fully qualified names should be used when a class with the same simple name has been introduced in a snippet).
This pull request has now been integrated.
Changeset: a407dc9c
Author: Jan Lahoda <jlahoda at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/a407dc9cbb48c4f66af51433067925605d3bc39d
Stats: 82 lines in 6 files changed: 74 ins; 0 del; 8 mod
8327512: JShell does not work correctly when a class named Object or Throwable is defined
Reviewed-by: asotona
-------------
PR: https://git.openjdk.org/jdk/pull/18295
More information about the kulla-dev
mailing list