Skip to content

Treat leading and trailing $ in a class name as part of a top-level class name in ClassPath - #8740

Open
LubabaKhalid wants to merge 1 commit into
google:masterfrom
LubabaKhalid:classpath-dollar-top-level
Open

LubabaKhalid wants to merge 1 commit into
google:masterfrom
LubabaKhalid:classpath-dollar-top-level

Conversation

@LubabaKhalid

Copy link
Copy Markdown
Contributor

ClassInfo.isTopLevel() (and so ClassPath.getTopLevelClasses()) assumed that any $ in a class name marks a nested class, so generated top-level classes like $AutoValue_Foo were silently dropped. getSimpleName() had the same problem, returning AutoValue_Foo.

This ignores $ characters at the start and end of the part of the name after the package when looking for the nested-class separator, as suggested in the issue discussion. It's still a heuristic, but it handles the common case of generated class names.

Added tests for isTopLevel() and getSimpleName().

Fixes #3349

… class name in `ClassPath`.

`ClassInfo.isTopLevel()` (and so `ClassPath.getTopLevelClasses()`) assumed that any `$` in a
class name marks a nested class, so generated top-level classes like `$AutoValue_Foo` were
silently dropped. `getSimpleName()` had the same problem, returning `AutoValue_Foo`.

Ignore `$` characters at the start and end of the part of the name after the package when
looking for the nested-class separator, as suggested in the issue discussion. This is still a
heuristic, but it handles the common case of generated class names.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@LubabaKhalid

Copy link
Copy Markdown
Contributor Author

@eamonnmcmanus @cpovirk could you take a look when you have a chance? This implements the leading/trailing-$ heuristic suggested in the issue discussion.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClassPath.getTopLevelClasses() does not return a top-level class with $ character

1 participant