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

John Wagenleitner commented on GROOVY-8199:
-------------------------------------------

After some more thought and reading \[1\], I think in order to effectively use 
{{java.lang.ClassValue}} it needs to be determined which {{ClassLoader}} loaded 
the {{Class}} in question (in relation to the {{ClassInfo}} class loader):

# *Parent* - computed value (a {{ClassInfo}} instance) must be a 
{{WeakReference}} because otherwise a strong reference will be created from 
system classes like {{java.lang.String}} to 
{{org.codehaus.groovy.reflection.ClassInfo}} and  prevent the Groovy run-time 
from being unloaded.  This then requires strongly referencing the computed 
value from the same class loader as {{ClassInfo}} so that it is not prematurely 
GC'd.  The {{Class}} could be stored on the computed value as a strong 
reference.
# *Same* - both computed value and {{Class}} on the computed value could be 
referenced strongly
# *Child* - computed value could be strongly referenced but the {{Class}} on 
the computed value would need to be weakly referenced

Before making {{ClassValue}} the default I think some of the above should be 
taken into consideration.

\[1\] 
http://openjdk.5641.n7.nabble.com/8169425-Values-computed-by-a-ClassValue-should-not-strongly-reference-the-ClassValue-tp291395p305616.html

> Re-enable use of ClassValue for all JDKs
> ----------------------------------------
>
>                 Key: GROOVY-8199
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8199
>             Project: Groovy
>          Issue Type: Task
>    Affects Versions: 3.x, 2.5.0-alpha-1, 2.4.11
>            Reporter: Jochen Kemnade
>              Labels: patch
>         Attachments: 
> 2.4.x-0001-GROOVY-8199-GROOVY-7591-GROOVY-7683-remove-groovy.us.patch, 
> master-0001-GROOVY-8199-GROOVY-7591-GROOVY-7683-remove-groovy.us.patch
>
>
> For GROOVY-7591, the {{groovy.use.classvalue}} system property was 
> introduced. Since the underlying issue (GROOVY-7683) is fixed, the property 
> should be removed again.



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

Reply via email to