This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 6d5b83b additional record test (fix for different JDK versions)
6d5b83b is described below
commit 6d5b83be04f64ed0a0a5d14f2fc7c2a92a84fb56
Author: Paul King <[email protected]>
AuthorDate: Thu Nov 4 18:47:17 2021 +1000
additional record test (fix for different JDK versions)
---
src/main/groovy/groovy/transform/RecordType.groovy | 2 +-
.../groovy/transform/RecordTypeASTTransformation.java | 1 -
src/spec/doc/_records.adoc | 11 ++++++++++-
.../groovy/org/codehaus/groovy/classgen/RecordTest.groovy | 6 +++++-
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/main/groovy/groovy/transform/RecordType.groovy
b/src/main/groovy/groovy/transform/RecordType.groovy
index 3e50833..d476d64 100644
--- a/src/main/groovy/groovy/transform/RecordType.groovy
+++ b/src/main/groovy/groovy/transform/RecordType.groovy
@@ -77,7 +77,7 @@ import java.lang.annotation.Target
*/
@RecordBase
@RecordOptions
-@TupleConstructor(namedVariant = true, force = true)
+@TupleConstructor(namedVariant = true, force = true/*, callSuper = true*/)
@PropertyOptions
@KnownImmutable
@POJO
diff --git
a/src/main/java/org/codehaus/groovy/transform/RecordTypeASTTransformation.java
b/src/main/java/org/codehaus/groovy/transform/RecordTypeASTTransformation.java
index 958bda4..0ed10df 100644
---
a/src/main/java/org/codehaus/groovy/transform/RecordTypeASTTransformation.java
+++
b/src/main/java/org/codehaus/groovy/transform/RecordTypeASTTransformation.java
@@ -228,7 +228,6 @@ public class RecordTypeASTTransformation extends
AbstractASTTransformation imple
if (unsupportedTupleAttribute(tupleCons, "includes")) return;
if (unsupportedTupleAttribute(tupleCons, "includeProperties"))
return;
if (unsupportedTupleAttribute(tupleCons, "includeSuperFields"))
return;
- if (unsupportedTupleAttribute(tupleCons, "callSuper")) return;
}
if ((options == null || !memberHasValue(options, COPY_WITH,
Boolean.FALSE)) && !hasDeclaredMethod(cNode, COPY_WITH, 1)) {
diff --git a/src/spec/doc/_records.adoc b/src/spec/doc/_records.adoc
index c7873e1..f5def5c 100644
--- a/src/spec/doc/_records.adoc
+++ b/src/spec/doc/_records.adoc
@@ -83,7 +83,9 @@ It can be used as follows:
include::../test/RecordSpecificationTest.groovy[tags=record_generics_usage,indent=0]
----
-== Compact constructor
+== Special record features
+
+=== Compact constructor
Records have an implicit constructor. This can be overridden in the normal way
by providing your own constructor - you need to make sure you set all of the
fields
@@ -98,6 +100,13 @@ but is augmented by the supplied statements in the compact
constructor definitio
include::../test/RecordSpecificationTest.groovy[tags=record_compact_constructor,indent=0]
----
+=== Serializability
+
+Groovy _native_ records follow the
+https://docs.oracle.com/en/java/javase/16/docs/specs/records-serialization.html[special
conventions]
+for serializability which apply to Java records.
+Groovy _record-like_ classes (discussed below) follow normal Java class
serializability conventions.
+
== Groovy enhancements
Groovy supports default values for constructor arguments.
diff --git a/src/test/groovy/org/codehaus/groovy/classgen/RecordTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/RecordTest.groovy
index ddab9dc..33c047f 100644
--- a/src/test/groovy/org/codehaus/groovy/classgen/RecordTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/classgen/RecordTest.groovy
@@ -386,7 +386,7 @@ class RecordTest {
}
@Test
- void testSerialization() {
+ void testClassSerialization() {
// inspired by:
// https://inside.java/2020/07/20/record-serialization/
@@ -415,7 +415,11 @@ class RecordTest {
assert in.readObject().toString() == 'RangeClass(lo:10, hi:5)'
}
'''
+ }
+ @Test
+ void testNativeRecordSerialization() {
+ assumeTrue(isAtLeastJdk('16.0'))
assertScript '''
import static groovy.test.GroovyAssert.shouldFail