You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/03/29 16:40:00 UTC
groovy git commit: changes to address japicmp serializable version
issue warnings
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_5_X 6bde499d7 -> 95945fd83
changes to address japicmp serializable version issue warnings
even after these changes, japicmp is still complaining, e.g.
for ObservableList/Map/Set it complains that the serialVersionUID is incompatible
but I have tested using round-tripping between 2.4.14 and 2.5.0-SNAPSHOT and all
classes serializable in 2.4.14 are successfully deserialized in 2.5.0-SNAPSHOT.
And when I change the uid to what japicmp wants it doesn't deserialize and japicmp
still complains. I suspect it's calculation is missing some aspect - perhaps that
the above are static nested classes.
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/95945fd8
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/95945fd8
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/95945fd8
Branch: refs/heads/GROOVY_2_5_X
Commit: 95945fd83b2b157ba5bfb6a2b316e14623f243c2
Parents: 6bde499
Author: Paul King <pa...@asert.com.au>
Authored: Fri Mar 30 02:39:44 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Fri Mar 30 02:39:44 2018 +1000
----------------------------------------------------------------------
.../groovy/groovy/lang/NonEmptySequence.java | 11 +++---
src/main/groovy/groovy/lang/Sequence.java | 41 ++++++++------------
src/main/groovy/groovy/util/ObservableList.java | 17 +++++---
src/main/groovy/groovy/util/ObservableMap.java | 15 +++++--
src/main/groovy/groovy/util/ObservableSet.java | 14 +++++--
.../org/codehaus/groovy/antlr/LexerFrame.java | 1 +
.../groovy/runtime/ComposedClosure.java | 3 +-
.../codehaus/groovy/runtime/GStringImpl.java | 2 +-
.../codehaus/groovy/runtime/MethodClosure.java | 4 +-
.../groovy/runtime/ScriptReference.java | 3 +-
.../metaclass/MissingMethodExecutionFailed.java | 1 +
.../codehaus/groovy/syntax/SyntaxException.java | 6 +--
12 files changed, 64 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/groovy/groovy/lang/NonEmptySequence.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/lang/NonEmptySequence.java b/src/main/groovy/groovy/lang/NonEmptySequence.java
index f069b7a..4a6dbd8 100644
--- a/src/main/groovy/groovy/lang/NonEmptySequence.java
+++ b/src/main/groovy/groovy/lang/NonEmptySequence.java
@@ -21,14 +21,13 @@ package groovy.lang;
import java.util.List;
/**
- * Represents a sequence of objects which represents one or many instances of
- * of objects of a given type. The type can be omitted in which case any type of
- * object can be added.
- *
- * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
+ * Represents a sequence of one or more objects of a given type.
+ * The type can be omitted in which case any type of object can be added.
*/
public class NonEmptySequence extends Sequence {
+ private static final long serialVersionUID = 1614604919062836998L;
+
public NonEmptySequence() {
super(null);
}
@@ -44,4 +43,4 @@ public class NonEmptySequence extends Sequence {
public int minimumSize() {
return 1;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/groovy/groovy/lang/Sequence.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/lang/Sequence.java b/src/main/groovy/groovy/lang/Sequence.java
index 2b4316c..57e6152 100644
--- a/src/main/groovy/groovy/lang/Sequence.java
+++ b/src/main/groovy/groovy/lang/Sequence.java
@@ -23,19 +23,16 @@ import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
/**
- * Represents a sequence of objects which represents zero or many instances of
- * of objects of a given type. The type can be omitted in which case any type of
- * object can be added.
- *
- * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
+ * Represents a sequence of zero or more objects of a given type.
+ * The type can be omitted in which case any type of object can be added.
*/
public class Sequence extends ArrayList implements GroovyObject {
- private MetaClass metaClass = InvokerHelper.getMetaClass(getClass());
+ private static final long serialVersionUID = 7324025453767284764L;
+ private transient MetaClass metaClass = InvokerHelper.getMetaClass(getClass());
private final Class type;
private int hashCode;
@@ -62,7 +59,7 @@ public class Sequence extends ArrayList implements GroovyObject {
clear();
addAll(collection);
}
-
+
public boolean equals(Object that) {
if (that instanceof Sequence) {
return equals((Sequence) that);
@@ -107,7 +104,7 @@ public class Sequence extends ArrayList implements GroovyObject {
public Class type() {
return type;
}
-
+
public void add(int index, Object element) {
checkType(element);
hashCode = 0;
@@ -156,13 +153,11 @@ public class Sequence extends ArrayList implements GroovyObject {
//-------------------------------------------------------------------------
public Object invokeMethod(String name, Object args) {
try {
- return getMetaClass().invokeMethod(this, name, args);
- }
- catch (MissingMethodException e) {
- // lets apply the method to each item in the collection
+ return getMetaClass().invokeMethod(this, name, args);
+ } catch (MissingMethodException e) {
+ // let's apply the method to each item in the collection
List answer = new ArrayList(size());
- for (Iterator iter = iterator(); iter.hasNext(); ) {
- Object element = iter.next();
+ for (Object element : this) {
Object value = InvokerHelper.invokeMethod(element, name, args);
answer.add(value);
}
@@ -188,22 +183,20 @@ public class Sequence extends ArrayList implements GroovyObject {
// Implementation methods
//-------------------------------------------------------------------------
-
+
/**
* Checks that each member of the given collection are of the correct
* type
*/
protected void checkCollectionType(Collection c) {
if (type != null) {
- for (Iterator iter = c.iterator(); iter.hasNext(); ) {
- Object element = iter.next();
+ for (Object element : c) {
checkType(element);
}
}
}
-
- /**
+ /**
* Checks that the given object instance is of the correct type
* otherwise a runtime exception is thrown
*/
@@ -214,10 +207,10 @@ public class Sequence extends ArrayList implements GroovyObject {
if (type != null) {
if (!type.isInstance(object)) {
throw new IllegalArgumentException(
- "Invalid type of argument for sequence of type: "
- + type.getName()
- + " cannot add object: "
- + object);
+ "Invalid type of argument for sequence of type: "
+ + type.getName()
+ + " cannot add object: "
+ + object);
}
}
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/groovy/groovy/util/ObservableList.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/util/ObservableList.java b/src/main/groovy/groovy/util/ObservableList.java
index 31b5745..01c2e2f 100644
--- a/src/main/groovy/groovy/util/ObservableList.java
+++ b/src/main/groovy/groovy/util/ObservableList.java
@@ -63,8 +63,6 @@ import java.util.Set;
* <li><tt>content</tt> - read-only.</li>
* <li><tt>size</tt> - read-only.</li>
* </ul>
- *
- * @author <a href="mailto:aalmiray@users.sourceforge.net">Andres Almiray</a>
*/
public class ObservableList implements List {
private final List delegate;
@@ -453,8 +451,8 @@ public class ObservableList implements List {
public enum ChangeType {
ADDED, UPDATED, REMOVED, CLEARED, MULTI_ADD, MULTI_REMOVE, NONE;
- public static final Object oldValue = new Object();
- public static final Object newValue = new Object();
+ public static final Object oldValue = new Object[0];
+ public static final Object newValue = new Object[0];
public static ChangeType resolve(int ordinal) {
switch (ordinal) {
@@ -478,7 +476,7 @@ public class ObservableList implements List {
}
public abstract static class ElementEvent extends PropertyChangeEvent {
-
+ private static final long serialVersionUID = 4985518099021958098L;
private final ChangeType type;
private final int index;
@@ -506,24 +504,31 @@ public class ObservableList implements List {
}
public static class ElementAddedEvent extends ElementEvent {
+ private static final long serialVersionUID = 6472450701680783544L;
+
public ElementAddedEvent(Object source, Object newValue, int index) {
super(source, null, newValue, index, ChangeType.ADDED);
}
}
public static class ElementUpdatedEvent extends ElementEvent {
+ private static final long serialVersionUID = 1116018076124047485L;
+
public ElementUpdatedEvent(Object source, Object oldValue, Object newValue, int index) {
super(source, oldValue, newValue, index, ChangeType.UPDATED);
}
}
public static class ElementRemovedEvent extends ElementEvent {
+ private static final long serialVersionUID = 8480367764843668809L;
+
public ElementRemovedEvent(Object source, Object value, int index) {
super(source, value, null, index, ChangeType.REMOVED);
}
}
public static class ElementClearedEvent extends ElementEvent {
+ private static final long serialVersionUID = -6586012825386453052L;
private final List values = new ArrayList();
public ElementClearedEvent(Object source, List values) {
@@ -539,6 +544,7 @@ public class ObservableList implements List {
}
public static class MultiElementAddedEvent extends ElementEvent {
+ private static final long serialVersionUID = 5142936559765501723L;
private final List values = new ArrayList();
public MultiElementAddedEvent(Object source, int index, List values) {
@@ -554,6 +560,7 @@ public class ObservableList implements List {
}
public static class MultiElementRemovedEvent extends ElementEvent {
+ private static final long serialVersionUID = 2453305767752911341L;
private final List values = new ArrayList();
public MultiElementRemovedEvent(Object source, List values) {
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/groovy/groovy/util/ObservableMap.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/util/ObservableMap.java b/src/main/groovy/groovy/util/ObservableMap.java
index a71165f..c55d3b1 100644
--- a/src/main/groovy/groovy/util/ObservableMap.java
+++ b/src/main/groovy/groovy/util/ObservableMap.java
@@ -60,8 +60,6 @@ import java.util.Set;
* <li><tt>content</tt> - read-only.</li>
* <li><tt>size</tt> - read-only.</li>
* </ul>
- *
- * @author <a href="mailto:aalmiray@users.sourceforge.net">Andres Almiray</a>
*/
public class ObservableMap implements Map {
private final Map delegate;
@@ -309,8 +307,8 @@ public class ObservableMap implements Map {
public enum ChangeType {
ADDED, UPDATED, REMOVED, CLEARED, MULTI, NONE;
- public static final Object oldValue = new Object();
- public static final Object newValue = new Object();
+ public static final Object oldValue = new Object[0];
+ public static final Object newValue = new Object[0];
public static ChangeType resolve(int ordinal) {
switch (ordinal) {
@@ -332,6 +330,7 @@ public class ObservableMap implements Map {
}
public abstract static class PropertyEvent extends PropertyChangeEvent {
+ private static final long serialVersionUID = -3439518280585144435L;
private final ChangeType type;
public PropertyEvent(Object source, String propertyName, Object oldValue, Object newValue, ChangeType type) {
@@ -353,24 +352,31 @@ public class ObservableMap implements Map {
}
public static class PropertyAddedEvent extends PropertyEvent {
+ private static final long serialVersionUID = -7237626384063194253L;
+
public PropertyAddedEvent(Object source, String propertyName, Object newValue) {
super(source, propertyName, null, newValue, ChangeType.ADDED);
}
}
public static class PropertyUpdatedEvent extends PropertyEvent {
+ private static final long serialVersionUID = 1322327094566373342L;
+
public PropertyUpdatedEvent(Object source, String propertyName, Object oldValue, Object newValue) {
super(source, propertyName, oldValue, newValue, ChangeType.UPDATED);
}
}
public static class PropertyRemovedEvent extends PropertyEvent {
+ private static final long serialVersionUID = 6646851287602912969L;
+
public PropertyRemovedEvent(Object source, String propertyName, Object oldValue) {
super(source, propertyName, oldValue, null, ChangeType.REMOVED);
}
}
public static class PropertyClearedEvent extends PropertyEvent {
+ private static final long serialVersionUID = -5066784441907086768L;
private final Map values = new HashMap();
public PropertyClearedEvent(Object source, Map values) {
@@ -388,6 +394,7 @@ public class ObservableMap implements Map {
public static class MultiPropertyEvent extends PropertyEvent {
public static final String MULTI_PROPERTY = "groovy_util_ObservableMap_MultiPropertyEvent_MULTI";
private static final PropertyEvent[] EMPTY_PROPERTY_EVENTS = new PropertyEvent[0];
+ private static final long serialVersionUID = 2185997629991653251L;
private final PropertyEvent[] events;
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/groovy/groovy/util/ObservableSet.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/util/ObservableSet.java b/src/main/groovy/groovy/util/ObservableSet.java
index b794436..2a50d2d 100644
--- a/src/main/groovy/groovy/util/ObservableSet.java
+++ b/src/main/groovy/groovy/util/ObservableSet.java
@@ -64,8 +64,6 @@ import java.util.Stack;
* <li><tt>content</tt> - read-only.</li>
* <li><tt>size</tt> - read-only.</li>
* </ul>
- *
- * @author <a href="mailto:aalmiray@users.sourceforge.net">Andres Almiray</a>
*/
public class ObservableSet<E> implements Set<E> {
private final Set<E> delegate;
@@ -343,11 +341,12 @@ public class ObservableSet<E> implements Set<E> {
public enum ChangeType {
ADDED, REMOVED, CLEARED, MULTI_ADD, MULTI_REMOVE, NONE;
- public static final Object oldValue = new Object();
- public static final Object newValue = new Object();
+ public static final Object oldValue = new Object[0];
+ public static final Object newValue = new Object[0];
}
public abstract static class ElementEvent extends PropertyChangeEvent {
+ private static final long serialVersionUID = 1636915619671510488L;
private final ChangeType type;
public ElementEvent(Object source, Object oldValue, Object newValue, ChangeType type) {
@@ -369,18 +368,23 @@ public class ObservableSet<E> implements Set<E> {
}
public static class ElementAddedEvent extends ElementEvent {
+ private static final long serialVersionUID = 8487116924204612932L;
+
public ElementAddedEvent(Object source, Object newValue) {
super(source, null, newValue, ChangeType.ADDED);
}
}
public static class ElementRemovedEvent extends ElementEvent {
+ private static final long serialVersionUID = 661289692849269910L;
+
public ElementRemovedEvent(Object source, Object value) {
super(source, value, null, ChangeType.REMOVED);
}
}
public static class ElementClearedEvent extends ElementEvent {
+ private static final long serialVersionUID = -4285830355690031818L;
private final List values = new ArrayList();
public ElementClearedEvent(Object source, List values) {
@@ -396,6 +400,7 @@ public class ObservableSet<E> implements Set<E> {
}
public static class MultiElementAddedEvent extends ElementEvent {
+ private static final long serialVersionUID = -4307534536004566487L;
private final List values = new ArrayList();
public MultiElementAddedEvent(Object source, List values) {
@@ -411,6 +416,7 @@ public class ObservableSet<E> implements Set<E> {
}
public static class MultiElementRemovedEvent extends ElementEvent {
+ private static final long serialVersionUID = -2068802236380651658L;
private final List values = new ArrayList();
public MultiElementRemovedEvent(Object source, List values) {
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/java/org/codehaus/groovy/antlr/LexerFrame.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/antlr/LexerFrame.java b/src/main/java/org/codehaus/groovy/antlr/LexerFrame.java
index 046fd17..ecc8098 100644
--- a/src/main/java/org/codehaus/groovy/antlr/LexerFrame.java
+++ b/src/main/java/org/codehaus/groovy/antlr/LexerFrame.java
@@ -47,6 +47,7 @@ import java.util.Hashtable;
* Swing application to graphically display the tokens produced by the lexer.
*/
public class LexerFrame extends JFrame implements ActionListener {
+ private static final long serialVersionUID = 4753761422597441243L;
private final JSplitPane jSplitPane1 = new JSplitPane();
private final JScrollPane jScrollPane1 = new JScrollPane();
private final JScrollPane jScrollPane2 = new JScrollPane();
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java b/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java
index 63e0406..f39ae85 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java
@@ -54,11 +54,10 @@ import java.util.List;
* def twiceBothPlus10 = twiceBoth >> add2plus10
* assert twiceBothPlus10(5, 10) == 40
* </pre>
- *
- * @author Paul King
*/
public final class ComposedClosure<V> extends Closure<V> {
+ private static final long serialVersionUID = -6410722393739184061L;
private final Closure first;
private final Closure<V> second;
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java b/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java
index d4cd857..278c6a6 100644
--- a/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java
+++ b/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java
@@ -26,10 +26,10 @@ import groovy.lang.GString;
* consist of a list of values and strings which can be combined to
* create a new String.
*
- * @author Jochen Theodorou
* @see groovy.lang.GString
*/
public class GStringImpl extends GString {
+ private static final long serialVersionUID = 3856688359714409314L;
private final String[] strings;
/**
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/java/org/codehaus/groovy/runtime/MethodClosure.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/MethodClosure.java b/src/main/java/org/codehaus/groovy/runtime/MethodClosure.java
index 7ead0c7..de61257 100644
--- a/src/main/java/org/codehaus/groovy/runtime/MethodClosure.java
+++ b/src/main/java/org/codehaus/groovy/runtime/MethodClosure.java
@@ -24,15 +24,13 @@ import groovy.lang.MetaMethod;
import java.io.IOException;
import java.util.List;
-
/**
* Represents a method on an object using a closure which can be invoked
* at any time
- *
- * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
*/
public class MethodClosure extends Closure {
+ private static final long serialVersionUID = -7600155510871887910L;
public static boolean ALLOW_RESOLVE = false;
private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/java/org/codehaus/groovy/runtime/ScriptReference.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/ScriptReference.java b/src/main/java/org/codehaus/groovy/runtime/ScriptReference.java
index 6877f51..7d27603 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ScriptReference.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ScriptReference.java
@@ -23,11 +23,10 @@ import groovy.lang.Script;
/**
* Represents a reference to a variable in a script
- *
- * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
*/
public class ScriptReference extends Reference {
+ private static final long serialVersionUID = 9011836991962996884L;
private final Script script;
private final String variable;
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/java/org/codehaus/groovy/runtime/metaclass/MissingMethodExecutionFailed.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/MissingMethodExecutionFailed.java b/src/main/java/org/codehaus/groovy/runtime/metaclass/MissingMethodExecutionFailed.java
index 9a3a0ba..f7f6b5e 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/MissingMethodExecutionFailed.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/MissingMethodExecutionFailed.java
@@ -24,6 +24,7 @@ package org.codehaus.groovy.runtime.metaclass;
* invokeMethod for GroovyObject implementing classes.
*/
public class MissingMethodExecutionFailed extends MissingMethodExceptionNoStack {
+ private static final long serialVersionUID = -6384783636894179156L;
private final Throwable cause;
public MissingMethodExecutionFailed(String method, Class type, Object[] arguments, boolean isStatic, Throwable cause) {
super(method, type, arguments, isStatic);
http://git-wip-us.apache.org/repos/asf/groovy/blob/95945fd8/src/main/java/org/codehaus/groovy/syntax/SyntaxException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/syntax/SyntaxException.java b/src/main/java/org/codehaus/groovy/syntax/SyntaxException.java
index eb5b69f..91df343 100644
--- a/src/main/java/org/codehaus/groovy/syntax/SyntaxException.java
+++ b/src/main/java/org/codehaus/groovy/syntax/SyntaxException.java
@@ -21,12 +21,12 @@ package org.codehaus.groovy.syntax;
import org.codehaus.groovy.GroovyException;
import org.codehaus.groovy.ast.ASTNode;
-/** Base exception indicating a syntax error.
- *
- * @author <a href="bob@werken.com">bob mcwhirter</a>
+/**
+ * Base exception indicating a syntax error.
*/
public class SyntaxException extends GroovyException {
+ private static final long serialVersionUID = -6086822614839477581L;
/** Line upon which the error occurred. */
private final int startLine;
private final int endLine;