groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <>
Subject [jira] [Commented] (GROOVY-8806) Immutable classes break in groovy 2.5.2
Date Wed, 03 Oct 2018 07:11:00 GMT


Paul King commented on GROOVY-8806:

I have sent an email to the dev list but to re-iterate:

I have a potential fix for this issue. I'd appreciate if anyone who has had issues could apply
the PR and see if it fixes their problems:

For anyone who has dived into the current implementation, they will know that currently a
collector annotation definition is converted into a helper class of sorts containing the serialized
annotation data so that pre-compiled meta-annotations can be processed.
Basically the fix allows the original annotation to be left in the codebase and instead creates
an inner helper class with the serialized data and a reference to the class in an annotation
attribute called serializeClass on AnnotationCollector.
I don't face the issue described in GROOVY-8806 when using Groovy 2.5.2 normally with asmResolving
in place, I only see it when using classloader resolution. The proposed fix works for either
and is backwards compatible with 2.4.x and 2.5.2 and earlier.
My cross version testcase which isn't covered by existing tests is to create an immutable
class in 2.5.3-SNAPSHOT that references a property with a 2.4.15 compiled @Immutable type
and another with a 2.5.2 compiled @Immutable type and compile it up with asmResolving set
to false.

Normally, serializeClass is set automatically for you as part of AnnotationCollector processing
but there is also a fallback to the existing behavior by explicitly setting the serializeClass
to the collector annotation. So in the following example, Foo will use the new approach and
Bar the current one as per 2.5.2.

@interface Foo { }

@interface Bar { }

Currently, the proposal makes the new approach the default. Any feedback welcome.

> Immutable classes break in groovy 2.5.2
> ---------------------------------------
>                 Key: GROOVY-8806
>                 URL:
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.2
>            Reporter: Roberto Perez Alcolea
>            Priority: Major
> We've being running tests of gradle plugins with latest gradle nightly release which
upgraded to groovy 2.5.2
> Since then, we've seen multiple plugins breaking with errors around immutability:
> {code:java}
> > Unsupported type (org.ajoberstar.grgit.Branch) found for field 'trackingBranch'
while constructing immutable class org.ajoberstar.grgit.Branch.
> Immutable classes only support properties with effectively immutable types including:
> - Strings, primitive types, wrapper types, Class, BigInteger and BigDecimal, enums
> - classes annotated with @KnownImmutable and known immutables (java.awt.Color,
> - Cloneable classes, collections, maps and arrays, and other classes with special handling
> (java.util.Date and various java.time.* classes and interfaces)
> Other restrictions apply, please see the groovydoc for ImmutableOptions for further details{code}
> I was wondering if this change is related to [] 
> And also,  looks like gradle plugins that use the gradleApi and are compiled with groovy
2.4 could break with groovy 2.5 with usages like this one

This message was sent by Atlassian JIRA

View raw message