You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/09/26 03:53:00 UTC

[jira] [Commented] (GROOVY-9760) NPE when trait with type parameter is implemented as raw type

    [ https://issues.apache.org/jira/browse/GROOVY-9760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17202509#comment-17202509 ] 

Paul King commented on GROOVY-9760:
-----------------------------------

A little strange. I went through Groovy versions back to 3.0.1 and 2.5.4 (and master) and all exhibit the NPE unless it is JDK version related?

> NPE when trait with type parameter is implemented as raw type
> -------------------------------------------------------------
>
>                 Key: GROOVY-9760
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9760
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> class C implements T {
>   static main(args) {
>     new C().one
>   }
> }
> trait T<X> {
>   X getOne() {}
> }
> {code}
> No type argument is supplied to T when C implements it.  Therefore, the method {{getOne()}} is written out with an unresolved type param in its signature.
> {noformat}
> Exception in thread "main" java.lang.NullPointerException
> 	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:203)
> 	at com.sun.beans.TypeResolver.resolveInClass(TypeResolver.java:81)
> 	at java.beans.FeatureDescriptor.getReturnType(FeatureDescriptor.java:370)
> 	at java.beans.Introspector.getTargetEventInfo(Introspector.java:1052)
> 	at java.beans.Introspector.getBeanInfo(Introspector.java:427)
> 	at java.beans.Introspector.getBeanInfo(Introspector.java:173)
> 	at groovy.lang.MetaClassImpl.lambda$addProperties$4(MetaClassImpl.java:3416)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3416)
> 	at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3397)
> 	at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:273)
> 	at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:315)
> 	at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:258)
> 	at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:987)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:82)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:268)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)