RFR: 8327512: JShell does not work correctly when a class named Object or Throwable is defined

Adam Sotona asotona at openjdk.org
Tue Apr 23 11:09:32 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).

Looks good to me

-------------

Marked as reviewed by asotona (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/18295#pullrequestreview-2016928472


More information about the kulla-dev mailing list