RFR: 8325936: jshell - crash on 'new Object().""'

Hannes Greule hgreule at openjdk.org
Thu Feb 15 17:05:21 UTC 2024


On Thu, 15 Feb 2024 16:55:31 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

> This fixes a crash in jshell when the target of a StringTemplate is not a processor. We only look up the `process` method if the type is actually a processor. The added test case fails without that fix.
> 
> Please let me know what you think of this fix, and if there are things that should be changed.

test/langtools/tools/javac/diags/examples/StringTemplateNotProcessor.java line 26:

> 24:  // key: compiler.note.preview.filename
> 25:  // key: compiler.err.cant.resolve.location.args
> 26:  // key: compiler.misc.location

I think this error was rather confusing, e.g.

Simple2.java:3: error: cannot find symbol
        System.out.println(e."{e}");
                             ^
  symbol:   method process(StringTemplate)
  location: class String

It mentions the `process` method while it's not visible in the code. It also always came directly after e.g.

Simple2.java:3: error: not a processor type: String
        System.out.println(e."{e}");

so it basically just caused 2 errors when there actually only is 1.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17876#discussion_r1491337338


More information about the compiler-dev mailing list