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

Avoid using string concatenation to forge impl name #1211

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

gsmet
Copy link
Contributor

@gsmet gsmet commented Aug 25, 2024

Also avoid using hashCode(). My understanding is that it was used to make sure the name wouldn't clash but I think it's better to use an approach to what we did for other technical classes.

This is related to the discussion in quarkusio/quarkus#42506 .

And in particular to this:

Screenshot from 2024-08-24 16-46-44

Also avoid using hashCode(). My understanding is that it was used to
make sure the name wouldn't clash but I think it's better to use an
approach to what CDI did.
Comment on lines +130 to +131
Class<?> implementationClass = type.getClassLoader()
.loadClass(ConfigMappingInterface.getImplementationClassName(type));
Copy link
Contributor Author

@gsmet gsmet Aug 26, 2024

Choose a reason for hiding this comment

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

BTW to clarify, the point was to fix the issue here. But... I broke the tests by doing so because ConfigMappingInterface had the same code. So I made sure they would share the code now.

@radcortez
Copy link
Member

If I remember correctly, we had the hascode because, at some point we were generating the implementation classes in the FQN of the Loader, plus the interface simple name, due to the security restrictions of Unsafe and the ClassLoader in JDK 8, so we needed a way to avoid the clashes.

We later rewrote that piece to use MethodHandles, but the implementation name generation remained.

@radcortez radcortez merged commit cb62346 into smallrye:main Aug 26, 2024
8 checks passed
@github-actions github-actions bot added this to the 3.10.0 milestone Aug 26, 2024
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