Skip to content

Use symbol-processing-aa-embeddable in Gradle#2006

Merged
ting-yuan merged 1 commit into
google:mainfrom
ting-yuan:rename
Jul 19, 2024
Merged

Use symbol-processing-aa-embeddable in Gradle#2006
ting-yuan merged 1 commit into
google:mainfrom
ting-yuan:rename

Conversation

@ting-yuan

Copy link
Copy Markdown
Contributor

isolatedClassloader only isolates KSP from Gradle classpath. Bundled classes in the KSP jar can still be seen by processors and pollute their classpath. Replacing symbol-processing-aa with
symbol-processing-aa-embeddable solves both issues.

Note that classloaders are still required for:

  1. loading KSP2 when needed, so that KSP1 don't download the fat jar.
  2. processors need to be re-loaded everytime, in case of improper uses of static variables and/or memory leak.

if (kspClassLoaderCache[key] == null) {
kspClassLoaderCache[key] = URLClassLoader(
kspClasspath.files.map { it.toURI().toURL() }.toTypedArray(),
this.javaClass.classLoader

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This means we are no longer isolating from Gradle's classpath is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it should be better to leave it isolated from Gradle's. The PR is updated.

isolatedClassloader only isolates KSP from Gradle classpath. Bundled
classes in the KSP jar can still be seen by processors and pollute their
classpath. Replacing symbol-processing-aa with
symbol-processing-aa-embeddable solves both issues.

Note that classloaders are still required for:
1. loading KSP2 when needed, so that KSP1 doesn't download the fat jar.
2. processors need to be re-loaded everytime, in case of improper uses
   of static variables and/or memory leak.
3. isolating processors from Gradle's classpath.
@ting-yuan ting-yuan merged commit 2b74d4d into google:main Jul 19, 2024
@ting-yuan ting-yuan deleted the rename branch October 11, 2024 02:44
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