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 2017/02/01 23:19:02 UTC

[jira] [Closed] (GROOVY-7880) Diamond Operator for own class causes NullPointerException if Static Compilation is enabled

     [ https://issues.apache.org/jira/browse/GROOVY-7880?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-7880.
-----------------------------

> Diamond Operator for own class causes NullPointerException if Static Compilation is enabled
> -------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7880
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7880
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler, Static compilation, Static Type Checker
>    Affects Versions: 2.4.3, 2.4.7
>         Environment: Test Machine 1: ArchLinux x64,
> openjdk version "1.8.0_92"
> OpenJDK Runtime Environment (build 1.8.0_92-b14)
> OpenJDK 64-Bit Server VM (build 25.92-b14, mixed mode)
> Test Machine 2: MacOSX 10.11.3
> Oracle Java Version: 1.8.0_05
>            Reporter: Roman Leuprecht
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 2.4.8
>
>
> When the diamond operator is used to instantiate a generic and the generic is specialized on the class the method is in, static compilation fails with a Nullpointer Exception. Dynamic compilation works, also replacing the diamond operator with the exact type or using "raw" typing.
> The following code reproduces the bug on both machines(listed in Environment):
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic
> class BugTest {
>     private class CompilerKiller<T> {
>         private T t
>         public CompilerKiller(T t){
>             this.t = t
>         }
>     }
>     public void "This causes a NPE"(){
>         CompilerKiller<BugTest> sample = new CompilerKiller<>(this)
>     }
>     public void "This causes a NPE as well"(){
>         CompilerKiller<BugTest> sample = new CompilerKiller<>(new BugTest())
>     }
>     public void "This does work"(){
>         CompilerKiller<BugTest> sample = new CompilerKiller<BugTest>(this)
>     }
>     public void "This works as well"(){
>         CompilerKiller<BugTest> sample = new CompilerKiller(this)
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)