You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Kemnade (JIRA)" <ji...@apache.org> on 2017/05/18 10:43:04 UTC
[jira] [Commented] (GROOVY-5769) NullObject leak
[ https://issues.apache.org/jira/browse/GROOVY-5769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16015558#comment-16015558 ]
Jochen Kemnade commented on GROOVY-5769:
----------------------------------------
The script runs fine with 2.4.11.
> NullObject leak
> ---------------
>
> Key: GROOVY-5769
> URL: https://issues.apache.org/jira/browse/GROOVY-5769
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Reporter: Jochen Theodorou
>
> {code:Java}
> def b = null
> assert b == null
> def a = null.getClass().newInstance()
> println a.getClass()
> assert a == null
> {code}
> The program shows a leak of NullObject. newInstance will give an instance. This is problematic in multiple ways. NullObject is supposed to be almost an invisible object, as well as a singleton.
> To make the program above pass we could either fix the compareEquals or we fix newInstance() to return null for NullObject. I prefer the later one.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)