Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix KSTypeNotPresentException for an existing nesting class #2331

Merged
merged 4 commits into from
Feb 12, 2025

Conversation

RishatShamsutdinov
Copy link
Contributor

@RishatShamsutdinov RishatShamsutdinov commented Feb 11, 2025

Source

object Root {
    class Nested
}

annotation class MyAnnotation(val clazz: KClass<*>)

@MyAnnotation(Root.Nested::class)
fun main() = Unit

Processor

getAnnotationsByType(MyAnnotation::class).first().clazz

Why

Map.Entry.class.getName() prints java.util.Map$Entry
Map.Entry.class.getCanonicalName() prints java.util.Map.Entry

ksp's qualifiedName for Map.Entry is java.util.Map.Entry

ksp's qualifiedName is equivalent to Java's Class.getCanonicalName but Class.forName requires fully qualified name (Class.getName).

Copy link
Collaborator

@ting-yuan ting-yuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@ting-yuan ting-yuan merged commit 07747f6 into google:main Feb 12, 2025
3 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 13, 2025
* fix KSTypeNotPresentException for an existing nesting class

* add tests

* renaming

* fix tests

(cherry picked from commit 07747f6)
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.

2 participants