Conversation
0905d71 to
aee86cd
Compare
aee86cd to
bff7df1
Compare
| } | ||
|
|
||
| // sbt/zinc#389: Ignore nulls coming from generic parameter types of lambdas | ||
| private[this] def ignoreNulls[T: scala.reflect.ClassTag](genericTypes: Array[T]): Array[T] = |
ad6638d to
b05a5c9
Compare
|
Things that I need to do before merge:
|
| private[this] def parameterTypes(m: Method): Array[Type] = | ||
| ignoreNulls(m.getGenericParameterTypes) | ||
| private[this] def parameterTypes(c: Constructor[_]): Array[Type] = | ||
| ignoreNulls(c.getGenericParameterTypes) |
There was a problem hiding this comment.
Did the previous iteration of this patch that only applied the filter on getActualTypeArguments fail the test in CI?
There was a problem hiding this comment.
Yes, the issue is that I forgot to push the latest local changes last night, which included this.
|
This slipped through the rocks. Handling tomorrow. |
|
It looks like I cannot sign in into JDK's issue tracker, so I won't be filing a ticket. I'm updating the commit message with the reason behind this problem. |
`Method.getGenericParameterType` may sometimes return `null` for the return types when the method's return type is indeed generic. It's not clear yet where this "sometimes" happens, but it looks like the JDK is not able to tell the return type of a lambda returning the generic class. This can be seen in the `java-lambda-typeparams` scripted test. In this context, lambda metafactory synthesizes a lambda class that returns a class that is parameterized in its return type. In that context, when `ClassToAPI` inspects the synthesized lambda and tries to figure out the full return type of it, the `null` is returned. It looks like the Java reflection API sparingly returns `null`s. We can see that in `ClassToAPI` where we guard against `null`s in lots of other places. So the guard added by this commit is not a novelty, but rather the norm. Fixes sbt#389.
|
This PR has been updated with a better commit message. |
|
So this should target 1.0.x branch, right? |
|
Closing this in favor of #446. |
|
Thanks for the rebase. I missed this notification. |
This is a WIP and needs to be double-checked before merge.
Related but not exact reasons why this happens can be found in JDK's
issue tracker: https://bugs.openjdk.java.net/browse/JDK-8178523?jql=text%20%7E%20%22lambda%20generic%20type%22
We ignore nulls that are returned by
getActualTypeArguments.It would be good to file a ticket in JIRA before merge.
Fixes #389.