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

ClassCastException in TypeResolver (ResolvedRecursiveType cannot be cast to ResolvedObjectType) #16

Closed
deki opened this issue Nov 28, 2013 · 8 comments
Milestone

Comments

@deki
Copy link

deki commented Nov 28, 2013

I'm using hibernate validator for bean validation. During the ddl generation a ClassCastException is thrown:

java.lang.ClassCastException: com.fasterxml.classmate.types.ResolvedRecursiveType cannot be cast to com.fasterxml.classmate.types.ResolvedObjectType
at com.fasterxml.classmate.TypeResolver._resolveSuperClass(TypeResolver.java:422)
at com.fasterxml.classmate.TypeResolver._constructType(TypeResolver.java:395)
at com.fasterxml.classmate.TypeResolver._fromClass(TypeResolver.java:351)
at com.fasterxml.classmate.TypeResolver._fromAny(TypeResolver.java:299)
at com.fasterxml.classmate.TypeResolver._fromParamType(TypeResolver.java:437)
at com.fasterxml.classmate.TypeResolver._fromAny(TypeResolver.java:305)
at com.fasterxml.classmate.TypeResolver._resolveSuperInterfaces(TypeResolver.java:409)
at com.fasterxml.classmate.TypeResolver._constructType(TypeResolver.java:395)
at com.fasterxml.classmate.TypeResolver._fromClass(TypeResolver.java:351)
at com.fasterxml.classmate.TypeResolver.resolve(TypeResolver.java:111)
at org.hibernate.validator.internal.util.ReflectionHelper.parametersResolveToSameTypes(ReflectionHelper.java:755)

@cowtowncoder
Copy link
Member

Ok this seems possible theoretically (and given that you hit it, now in practice...). But while fix may be simple to do (cast may not be necessary) I would need a test case to verify that the problem would be completely resolved.

Would it be possible to get a code snippet or test to reproduce this problem?

@deki
Copy link
Author

deki commented Dec 11, 2013

I'm not using the classmate library directly, so it's difficult for me to create a testcase. I tried to create a simple Maven project with hibernate-maven-plugin that reproduces the issue but didn't succeed yet.

@cowtowncoder
Copy link
Member

Ok. I hope we can eventually reproduce it, so that it will be possible to come up with fix & verification.

@cheister
Copy link

We're also seeing this error when trying to update from Hibernate Validator 4.3.1 to 5.1.2. The following test will reproduce the error:

public static void main(String[] args) {
    TypeResolver resolver = new TypeResolver();
    resolver.resolve(Bar.class);
}

private static class Foo extends Bar { }

private static class Bar extends Zen<Bar, Foo> { }

private static class Zen<A, B extends A>  { }

@cowtowncoder
Copy link
Member

@cheister thank you. That certainly is simple enough to reproduce.

@cowtowncoder cowtowncoder added this to the 1.1.0 milestone Aug 20, 2014
@cowtowncoder
Copy link
Member

Fixed, will be in 1.1.0 release which is being released at this point.

@cheister
Copy link

Thanks for the quick turnaround on the fix!

@cowtowncoder
Copy link
Member

No problem, thank you for providing the test. For a while I worried it might be complicated thing to fix, but in the end things worked out reasonably well I think.

1.1.0 should be available from Maven Central now.

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

3 participants