openrewrite / openrewrite/rewrite

Problem with inner Class named '$' in JavaTemplate

Open
#3,623 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug java
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

What version of OpenRewrite are you using?

I am using current main (Commit: d53b36febdc9ba609ae64295bcaa54b9fe4169b8)
rewrite-java 8.5.0-SNAPSHOT

How are you running OpenRewrite?

Initially via tests in PR https://github.com/openrewrite/rewrite-migrate-java/pull/285
Reproduced with test in rewrite-java directly.

What is the smallest, simplest way to reproduce the problem?

Reference an inner class with name $ inside a JavaTemplate

What did you expect to see?

JavaTemplate has to deal with $ as name of inner classes.
They resutl into A$$as FQN when defined as A.$.

What did you see instead?

__P__.<error>

What is the full stack trace of any errors you encountered?

none

Are you interested in contributing a fix to OpenRewrite?

Yes, as it blocks my PR :D

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with JavaTemplate and the reproduction test in rewrite-java, using the smallest example that references an inner class named $. Trace how that reference is interpreted and compare the generated result with the expected A$$ FQN. Done means the template handles A.$ without producing __P__.<error> and the reproduction test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.