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

Optimized the compilation speed of the memory compiler #2736

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

hhy50
Copy link
Contributor

@hhy50 hhy50 commented Nov 21, 2023

Optimized the compilation speed of the memory compiler


public class PackageInternalsFinder {
private final ClassLoader classLoader;
private static final String CLASS_FILE_EXTENSION = ".class";

private static final Map<String, JarFileIndex> INDEXS = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里会有线程安全问题不?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里会出现线程安全问题, 我把它换成线程安全的map


private List<JavaFileObject> processJar(String packageName, URL packageFolderURL) {
try {
String jarUri = packageFolderURL.toExternalForm().substring(0, packageFolderURL.toExternalForm().lastIndexOf("!/"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里好像有问题,因为完整的 spring boot fat jar 里的 url 是 两层结构的。但这里只取了一层的 url 为 map 的key。

比如应用打包有一个 aaa.jar ,然后另外也有一个同名的 aaa.jar 是另外的 classloader 加载的,这里就会冲突了。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

如果是两层jar的话, 他应该会有两个!/, 会从第二个jar结尾开始截取,类似于 aaa.jar!/Boot-Lib/aaa.jar!/

@hengyunabc hengyunabc added this to the 4.0.0 milestone Nov 22, 2023
@hengyunabc hengyunabc merged commit 6a43273 into alibaba:master Nov 23, 2023
12 checks passed
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