You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Roman Leuprecht (JIRA)" <ji...@apache.org> on 2016/07/05 16:26:11 UTC
[jira] [Updated] (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 ]
Roman Leuprecht updated GROOVY-7880:
------------------------------------
Description:
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 if 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}
was:
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 if 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 does work"(){
CompilerKiller<BugTest> sample = new CompilerKiller<BugTest>(this)
}
public void "This works as well"(){
CompilerKiller<BugTest> sample = new CompilerKiller(this)
}
}
{code}
> 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
> Priority: Minor
>
> 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 if 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.4#6332)