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

Unable to find generic type of class... for an interface #183

Closed
yukchan opened this issue Sep 26, 2018 · 7 comments
Closed

Unable to find generic type of class... for an interface #183

yukchan opened this issue Sep 26, 2018 · 7 comments
Labels
Milestone

Comments

@yukchan
Copy link

yukchan commented Sep 26, 2018

Hi,

SchemaParserBuilder throws IllegalStateException "Unable to find generic type of class ..." when it is trying to load an interface method from parent. I guess the function relativeToPotentialParent should be revised to handle the case for interface:

fun relativeToPotentialParent(declaringType: JavaType): RelativeTo {
    if(declaringType !is Class<*> || declaringType.isInterface) {
        return relativeToType(declaringType)
    }

    val type = getGenericSuperType(mostSpecificType, declaringType)
    if(type == null) {
        error("Unable to find generic type of class ${TypeUtils.toString(declaringType)} relative to ${TypeUtils.toString(mostSpecificType)}")
    } else {
        return relativeToType(type)
    }
}

Regards,
Alex

@yukchan
Copy link
Author

yukchan commented Sep 26, 2018

https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getGenericSuperclass()

... If this Class represents either the Object class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the Class object representing the Object class is returned.

@oliemansm oliemansm added the bug label Sep 26, 2018
@oliemansm oliemansm modified the milestone: 5.3.1 Sep 30, 2018
@liangjacky
Copy link

@yukchan @oliemansm is there any workarounds for this issue? I'm running into it as well.

@oliemansm
Copy link
Member

@liangjacky Can you share an example what you're running into exactly? Ideally a small unit test to reproduce the issue? The fix suggested in the issue is already implemented for a while, but apparently that doesn't have the desired result.

@yukchan
Copy link
Author

yukchan commented Nov 19, 2018

I branched out locally with the change mentioned and that fixed my issues. I will try to get the latest version later though as this is already incorporated

@yukchan
Copy link
Author

yukchan commented Nov 19, 2018

oh, sad that the other one is not yet fixed in 5.4.0
#188

@oliemansm
Copy link
Member

@yukchan Do you already have a fix for that one available you could submit a PR for?

@oliemansm oliemansm added this to the 5.4.1 milestone Nov 22, 2018
oliemansm added a commit that referenced this issue Nov 24, 2018
@oliemansm
Copy link
Member

Fix will be available in 5.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants