Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HHH-19626 Hibernate processor may fail to process entities with generics#10584

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
cigaly wants to merge2 commits intohibernate:main
base:main
Choose a base branch
Loading
fromcigaly:HHH-19626-Hibernate-processor-may-fail-to-process-entities-with-generics

Conversation

cigaly
Copy link
Contributor

@cigalycigaly commentedJul 18, 2025
edited by jirabot
Loading

Jira issueHHH-19626

Test case from PR#10574

Created helper classorg.hibernate.processor.util.GenericTypeParameterResolver used for generic type parameters resolution


By submitting this pull request, I confirm that my contribution is made under the terms of theApache 2.0 license
and can be relicensed under the terms of theLGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please checkhere.


Copy link
Member

@gavinkinggavinking left a comment

Choose a reason for hiding this comment

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

Thanks,@cigaly, appreciated. Please see my comments.

First, the fix works, so that's great.

But I think it's generally a bad idea to keep this sort of state in the processor, and so I would lean toward making these just functions.

Comment on lines +97 to +98
private static final Map<Element, GenericTypeParameterResolver> typeResolversMap = new HashMap<>();

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we can cache stuff like this in astatic. As I understand it, we have no control over the lifecycle of these classes, and they could in principle fill up with all kinds of stuff over many calls to the processor.

Comment on lines +43 to +46
if ( !( typeArguments.isEmpty() || generic.size() == typeArguments.size() ) ) {
throw new IndexOutOfBoundsException(
"Type %s : %d vs %d".formatted( type, generic.size(), typeArguments.size() ) );
}
Copy link
Member

Choose a reason for hiding this comment

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

I guess I think it's wrong for any of this code to ever throw exceptions. We either produce an error message, or we ignore the condition and trust that the Java compiler itself will pick up on the error. In this case I believe "ignore" is the right option, if I'm understanding correctly.


public class GenericTypeParameterResolver {

private final Map<Element, Map<String, TypeMirror>> typeParameterMap;
Copy link
Member

Choose a reason for hiding this comment

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

Given that I don't think we can hold onto these in astatic (see other comment), I guess I would prefer to not even build up this map here. This search can be stateless, I believe (unless we're concerned we might encounter circularities, but I guess I doubt we would).

@@ -94,6 +94,8 @@
PRIMITIVES.put( TypeKind.DOUBLE, "double" );
}

private static final Map<Element, GenericTypeParameterResolver> typeResolversMap = new HashMap<>();

Check failure

Code scanning / CodeQL

Container contents are never initialized Error

The contents of this container are never initialized.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gavinkinggavinkinggavinking requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@cigaly@gavinking@marko-bekhta

[8]ページ先頭

©2009-2025 Movatter.jp