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

move method reflection from ExtensionFactoryDelegate to ExtensionMetadata #2414

Merged
merged 2 commits into from Jun 30, 2023

Conversation

stevenschlansker
Copy link
Member

fixes #2413

@stevenschlansker stevenschlansker requested review from hgschmie and a team June 29, 2023 02:25
@hgschmie
Copy link
Contributor

Turns out that there is actually a lot of stupidity in the original code. An interface can not override any method from Object (because ... rules). So all of the tests can go away, because we only create the metadata for interfaces.

@hgschmie hgschmie force-pushed the extension-method-metadata branch 4 times, most recently from df368f3 to d7817e0 Compare June 30, 2023 05:27
@hgschmie hgschmie force-pushed the extension-method-metadata branch 2 times, most recently from 4083ce4 to d93920a Compare June 30, 2023 16:04
@@ -44,6 +45,15 @@ public interface ExtensionHandler {
/** Handler that only returns null independent of any input parameters. */
ExtensionHandler NULL_HANDLER = (handleSupplier, target, args) -> null;

/** Constant for {@link Object#equals(Object)}. */
Method EQUALS_METHOD = JdbiClassUtils.methodLookup(Object.class, "equals", Object.class);
Copy link
Member Author

Choose a reason for hiding this comment

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

I originally had these in JdbiClassUtils in order to have them not be part of the public API. Do we really want to ship this as part of public API?

* Returns a reference to a method that overrides {@link Object#finalize()} if it exists.
* @return An {@link Optional} containing a {@link Method} if a finalizer exists.
*/
public Optional<Method> getFinalizer() {
Copy link
Member Author

Choose a reason for hiding this comment

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

I originally had this as package-private so it is not part of the public API.
Do we really think this should be a fully supported part of the public API?

Interfaces can not override any method from Object and the extension
metadata is only created for interfaces. So there is no need to do any
checking.

Rip out all of the check logic, add constant methods (except for
toString).

Cache the finalizer if present in extension metadata.
@sonarcloud
Copy link

sonarcloud bot commented Jun 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@hgschmie hgschmie merged commit 8dfffc7 into master Jun 30, 2023
36 checks passed
@hgschmie hgschmie deleted the extension-method-metadata branch June 30, 2023 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

ExtensionFactoryDelegate uses reflection checks for every time you attach a dao
2 participants