Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8284

getMetaClass should be annotated as (JavaBeans) transient

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.12
    • 4.0.0-alpha-1, 3.0.6
    • Compiler
    • None

    Description

      All groovy classes have the "getMetaClass()" method. This breaks the (e.g. XML) serialization of groovy classes that are supposed to represent JavaBeans.

      While the serialization provided with Serializable or Externalizable examines the attributes of a class, the special JavaBeans serialization provided by serializers based on [Encoders](https://docs.oracle.com/javase/8/docs/api/java/beans/Encoder.html) relies on the information provided by the [Introspector](https://docs.oracle.com/javase/8/docs/api/java/beans/Introspector.html).

      With respect to persistence, the PropertyDescriptor for "getMetaClass" should have the attribute value "transient" set. The Introspector generates this value if the method has been annotated as [Transient](https://docs.oracle.com/javase/8/docs/api/java/beans/Transient.html)). Because this value is currently missing, the Encoder tries to serialize the MetaClass information, which fails.

      The groovy compiler should therefore annotate the "getMetaClass" method with the runtime annotation "java.beans.Transient".

      Attachments

        Activity

          People

            paulk Paul King
            drmlipp Michael Lipp
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m