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

Problem with ArrayTypeDetailsImpl#getName #103

Closed
cigaly opened this issue Oct 6, 2024 · 4 comments
Closed

Problem with ArrayTypeDetailsImpl#getName #103

cigaly opened this issue Oct 6, 2024 · 4 comments

Comments

@cigaly
Copy link

cigaly commented Oct 6, 2024

Attached is test case that is failing
MultiDimensionalIntegerArrayTypeTest.txt

I've noticed it while testing something on Hibernate ORM, but the problem seems to be in org.hibernate.models.internal.ArrayTypeDetailsImpl#getName. When run, test is failing with message

org.opentest4j.AssertionFailedError: Returned class ==> expected: <int[][][][]> but was: <int[][][][][][][][][][]>

Source of the problem is inside the loop:

		while ( type.getTypeKind() == Kind.ARRAY ) {
			int dimensions = type.asArrayType().getDimensions();
			while ( dimensions-- > 0 ) {
				builder.append( '[' );
			}
			type = type.asArrayType().getConstituentType();
		}

This way, number of dimensions in returned class will be d*(d+1)/2 instead of just d since every constituent type has dimension one less that its 'parent'

Correct code should be imply:

		while ( type.getTypeKind() == Kind.ARRAY ) {
			builder.append( '[' );
			type = type.asArrayType().getConstituentType();
		}
@sebersole
Copy link
Member

Thanks @cigaly !

Do you agree to let me use that test in this project (different licenses)?

@cigaly
Copy link
Author

cigaly commented Oct 22, 2024

Yes, of course

@sebersole
Copy link
Member

Thanks! Sorry to ask, but its important to have explicit approval :)

@sebersole
Copy link
Member

Fixed

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

No branches or pull requests

2 participants