You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/03/03 17:19:50 UTC
[1/4] incubator-brooklyn git commit: Use the eclipse-groovy compiler
for .groovy files only.
Repository: incubator-brooklyn
Updated Branches:
refs/heads/master 34ce96ee7 -> 1f3bff401
Use the eclipse-groovy compiler for .groovy files only.
Compile non-groovy tests with the same compiler used for the non-test code so tests can excersize the same code path as used by client code.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/96a5ab12
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/96a5ab12
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/96a5ab12
Branch: refs/heads/master
Commit: 96a5ab1216f53de9b3e5a3f30972a3faf5482629
Parents: 1597906
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Thu Feb 19 14:23:19 2015 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Fri Feb 20 21:12:16 2015 +0200
----------------------------------------------------------------------
core/pom.xml | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/96a5ab12/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 3a9925b..27ba663 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -234,10 +234,25 @@
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<executions>
+ <!--
+ Compile only Groovy files with the eclipse-groovy compiler.
+ Java files compiled by default-testCompile execution inherited from parent.
+ -->
<execution>
- <id>default-testCompile</id>
+ <id>groovy-testCompile</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
+ <includes>
+ <include>**/*.groovy</include>
+ </includes>
+ <fork>true</fork>
+ <verbose>false</verbose>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
</configuration>
</execution>
</executions>
[3/4] incubator-brooklyn git commit: Add caching when searching for
outer class fields
Posted by al...@apache.org.
Add caching when searching for outer class fields
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/49c5be40
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/49c5be40
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/49c5be40
Branch: refs/heads/master
Commit: 49c5be404c5e1053bcc7c2be691bb5d7c99c4c8d
Parents: ba0e648
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Tue Feb 24 23:13:48 2015 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Tue Mar 3 17:42:10 2015 +0200
----------------------------------------------------------------------
...ompilerIndependentOuterClassFieldMapper.java | 22 +++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/49c5be40/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java b/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java
index 7faeb02..f9a1f00 100644
--- a/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java
+++ b/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java
@@ -21,12 +21,16 @@ package brooklyn.util.xstream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.thoughtworks.xstream.core.Caching;
import com.thoughtworks.xstream.mapper.Mapper;
import com.thoughtworks.xstream.mapper.MapperWrapper;
@@ -57,13 +61,16 @@ import com.thoughtworks.xstream.mapper.MapperWrapper;
* <p>Currently available at
* http://web.archive.org/web/20000830111107/http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html</p>
*/
-public class CompilerIndependentOuterClassFieldMapper extends MapperWrapper {
+public class CompilerIndependentOuterClassFieldMapper extends MapperWrapper implements Caching {
public static final Logger LOG = LoggerFactory.getLogger(CompilerIndependentOuterClassFieldMapper.class);
private static final String OUTER_CLASS_FIELD_PREFIX = "this$";
+ private final Map<String, Collection<String>> classOuterFields = new ConcurrentHashMap<String, Collection<String>>();
+
public CompilerIndependentOuterClassFieldMapper(Mapper wrapped) {
super(wrapped);
+ classOuterFields.put(Object.class.getName(), Collections.<String>emptyList());
}
@Override
@@ -131,8 +138,12 @@ public class CompilerIndependentOuterClassFieldMapper extends MapperWrapper {
}
private Collection<String> findOuterClassFieldNames(Class<?> type) {
- Collection<String> fields = new ArrayList<String>();
- addOuterClassFields(type, fields);
+ Collection<String> fields = classOuterFields.get(type.getName());
+ if (fields == null) {
+ fields = new ArrayList<String>();
+ addOuterClassFields(type, fields);
+ classOuterFields.put(type.getName(), fields);
+ }
return fields;
}
@@ -147,4 +158,9 @@ public class CompilerIndependentOuterClassFieldMapper extends MapperWrapper {
}
}
+ @Override
+ public void flushCache() {
+ classOuterFields.keySet().retainAll(Collections.singletonList(Object.class.getName()));
+ }
+
}
\ No newline at end of file
[2/4] incubator-brooklyn git commit: Compiler independent outer class
field deserialization
Posted by al...@apache.org.
Compiler independent outer class field deserialization
Different compilers generate different names for the outer class synthetic fields. The change tries to infer the new name where possible.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ba0e6480
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ba0e6480
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ba0e6480
Branch: refs/heads/master
Commit: ba0e648058bd861122c6ccf9d6dcfe0fdfbfd6f3
Parents: 96a5ab1
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Thu Feb 19 14:26:35 2015 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Tue Mar 3 17:42:04 2015 +0200
----------------------------------------------------------------------
.../rebind/persister/XmlMementoSerializer.java | 6 +-
...ompilerIndependentOuterClassFieldMapper.java | 150 ++++++++++++++++++
.../brooklyn/util/xstream/XmlSerializer.java | 2 +-
.../util/xstream/CompilerCompatibilityTest.java | 154 +++++++++++++++++++
.../rebind/compiler_compatibility_eclipse.xml | 41 +++++
.../rebind/compiler_compatibility_oracle.xml | 41 +++++
6 files changed, 391 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba0e6480/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java b/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
index 0d88bea..4bd1a20 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
@@ -135,8 +135,10 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T> implements Memento
// Warning: this is called in the super-class constuctor, so before this constructor!
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
- MapperWrapper result = new CustomMapper(next, Entity.class, "entityProxy");
- return new CustomMapper(result, Location.class, "locationProxy");
+ MapperWrapper mapper = super.wrapMapper(next);
+ mapper = new CustomMapper(mapper, Entity.class, "entityProxy");
+ mapper = new CustomMapper(mapper, Location.class, "locationProxy");
+ return mapper;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba0e6480/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java b/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java
new file mode 100644
index 0000000..7faeb02
--- /dev/null
+++ b/core/src/main/java/brooklyn/util/xstream/CompilerIndependentOuterClassFieldMapper.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.util.xstream;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.thoughtworks.xstream.mapper.Mapper;
+import com.thoughtworks.xstream.mapper.MapperWrapper;
+
+/**
+ * <p>Compiler independent outer class field mapper.</p>
+ * <p>Different compilers generate different indexes for the names of outer class reference
+ * field (this$N) leading to deserialization errors.</p>
+ * <ul>
+ * <li> eclipse-[groovy-]compiler counts all outer static classes
+ * <li> OpenJDK/Oracle/IBM compiler starts at 0, regardless of the nesting level
+ * </ul>
+ * <p>The mapper will be able to update field names for instances with a single this$N
+ * field only (including those from parent classes).</p>
+ * <p>For difference between generated field names compare
+ * {@code src/test/java/brooklyn/util/xstream/compiler_compatibility_eclipse.xml} and
+ * {@code src/test/java/brooklyn/util/xstream/compiler_compatibility_oracle.xml},
+ * generated from {@code brooklyn.util.xstream.CompilerCompatibilityTest}</p>
+ * <p>JLS 1.1 relevant section, copied verbatim for a lack of reliable URL:</p>
+ * <blockquote>
+ * <p>Java 1.1 compilers are strongly encouraged, though not required, to use the
+ * following naming conventions when implementing inner classes. Compilers may
+ * not use synthetic names of the forms defined here for any other purposes.</p>
+ * <p>A synthetic field pointing to the outermost enclosing instance is named this$0.
+ * The next-outermost enclosing instance is this$1, and so forth. (At most one such
+ * field is necessary in any given inner class.) A synthetic field containing a copy
+ * of a constant v is named val$v. These fields are final.</p>
+ * </blockquote>
+ * <p>Currently available at
+ * http://web.archive.org/web/20000830111107/http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html</p>
+ */
+public class CompilerIndependentOuterClassFieldMapper extends MapperWrapper {
+ public static final Logger LOG = LoggerFactory.getLogger(CompilerIndependentOuterClassFieldMapper.class);
+
+ private static final String OUTER_CLASS_FIELD_PREFIX = "this$";
+
+ public CompilerIndependentOuterClassFieldMapper(Mapper wrapped) {
+ super(wrapped);
+ }
+
+ @Override
+ public String realMember(@SuppressWarnings("rawtypes") Class type, String serialized) {
+ // Let com.thoughtworks.xstream.mapper.OuterClassMapper also run on the input.
+ String serializedFieldName = super.realMember(type, serialized);
+
+ if (serializedFieldName.startsWith(OUTER_CLASS_FIELD_PREFIX)) {
+ Collection<String> compiledFieldNames = findOuterClassFieldNames(type);
+ if (compiledFieldNames.size() == 0) {
+ throw new IllegalStateException("Unable to find any outer class fields in " + type + ", searching specifically for " + serializedFieldName);
+ }
+
+ Set<String> uniqueFieldNames = new HashSet<String>(compiledFieldNames);
+ String deserializeFieldName;
+ if (!compiledFieldNames.contains(serializedFieldName)) {
+ String msg =
+ "Unable to find outer class field " + serializedFieldName + " in class " + type + ". " +
+ "This could be caused by " +
+ "1) changing the class (or one of its parents) to a static or " +
+ "2) moving the class to a different lexical level (enclosing classes) or " +
+ "3) using a different compiler (i.e eclipse vs oracle) at the time the object was serialized. ";
+ if (uniqueFieldNames.size() == 1) {
+ // Try to fix the field naming only for the case with a single field or
+ // multiple fields with the same name, in which case XStream puts defined-in
+ // for the field declared in super.
+ //
+ // We don't have access to the XML elements from here to check for same name
+ // so we check the target class instead. This should work most of the time, but
+ // if code is recompiled in such a way that the new instance has fields with
+ // different names, where only the field of the extending class is renamed and
+ // the super field is not, then the instance will be deserialized incorrectly -
+ // the super field will be assigned both times. If the field type is incompatible
+ // then a casting exception will be thrown, if it's the same then only the warning
+ // below will indicate of a possible problem down the line - most probably NPE on
+ // the this$N field.
+ deserializeFieldName = compiledFieldNames.iterator().next();
+ LOG.warn(msg + "Will use the field " + deserializeFieldName + " instead.");
+ } else {
+ // Multiple fields with differing names case - don't try to fix it.
+ // Better fail with an explicit error, and have someone fix it manually,
+ // than try to fix it here non-reliably and have it fail down the line
+ // with some unrelated error.
+ // XStream will fail later with a field not found exception.
+ LOG.error(msg + "Will fail with a field not found exception. " +
+ "Edit the persistence state manually and update the field names. "+
+ "Existing field names are " + uniqueFieldNames);
+ deserializeFieldName = serializedFieldName;
+ }
+ } else {
+ if (uniqueFieldNames.size() > 1) {
+ // Log at debug level as the actual problem would occur in very specific cases. Only
+ // useful when the compiler is changed, otherwise leads to false positives.
+ LOG.debug("Deserializing the non-static class " + type + " with multiple outer class fields " + uniqueFieldNames + ". " +
+ "When changing compilers it's possible that the instance won't be able to be deserialized due to changed outer class field names. " +
+ "In those cases deserialization could fail with field not found exception or class cast exception following this log line.");
+ }
+ deserializeFieldName = serializedFieldName;
+ }
+
+ return deserializeFieldName;
+ } else {
+ return serializedFieldName;
+ }
+ }
+
+ private Collection<String> findOuterClassFieldNames(Class<?> type) {
+ Collection<String> fields = new ArrayList<String>();
+ addOuterClassFields(type, fields);
+ return fields;
+ }
+
+ private void addOuterClassFields(Class<?> type, Collection<String> fields) {
+ for (Field field : type.getDeclaredFields()) {
+ if (field.isSynthetic()) {
+ fields.add(field.getName());
+ }
+ }
+ if (type.getSuperclass() != null) {
+ addOuterClassFields(type.getSuperclass(), fields);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba0e6480/core/src/main/java/brooklyn/util/xstream/XmlSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/xstream/XmlSerializer.java b/core/src/main/java/brooklyn/util/xstream/XmlSerializer.java
index ed1dc79..7220254 100644
--- a/core/src/main/java/brooklyn/util/xstream/XmlSerializer.java
+++ b/core/src/main/java/brooklyn/util/xstream/XmlSerializer.java
@@ -72,7 +72,7 @@ public class XmlSerializer<T> {
}
protected MapperWrapper wrapMapper(MapperWrapper next) {
- return next;
+ return new CompilerIndependentOuterClassFieldMapper(next);
}
public void serialize(Object object, Writer writer) {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba0e6480/core/src/test/java/brooklyn/util/xstream/CompilerCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/xstream/CompilerCompatibilityTest.java b/core/src/test/java/brooklyn/util/xstream/CompilerCompatibilityTest.java
new file mode 100644
index 0000000..5a1f844
--- /dev/null
+++ b/core/src/test/java/brooklyn/util/xstream/CompilerCompatibilityTest.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.util.xstream;
+
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+
+import org.testng.annotations.Test;
+
+import brooklyn.util.xstream.CompilerCompatibilityTest.EnclosingClass.DynamicClass;
+import brooklyn.util.xstream.CompilerCompatibilityTest.EnclosingClass.DynamicExtendingClass;
+import brooklyn.util.xstream.CompilerCompatibilityTest.EnclosingClass.EnclosingDynamicClass;
+import brooklyn.util.xstream.CompilerCompatibilityTest.EnclosingClass.EnclosingDynamicClass.NestedDynamicClass;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.mapper.MapperWrapper;
+
+// To get the generated synthetic fields use the command:
+/*
+ find core/target/test-classes -name CompilerCompatibilityTest\$EnclosingClass\$* | \
+ sed s@core/target/test-classes/@@ | sed 's@.class$@@' | sed s@/@.@g | \
+ xargs javap -classpath core/target/test-classes/ | grep -B1 this
+*/
+@SuppressWarnings("unused")
+public class CompilerCompatibilityTest {
+ private EnclosingClass enclosingClass = new EnclosingClass();
+ private DynamicClass dynamicClass = enclosingClass.new DynamicClass();
+ private DynamicExtendingClass dynamicExtendingClass = enclosingClass.new DynamicExtendingClass();
+ private EnclosingDynamicClass enclosingDynamicClass = enclosingClass.new EnclosingDynamicClass();
+ private NestedDynamicClass nestedDynamicClass = enclosingDynamicClass.new NestedDynamicClass();
+// NOT SUPPORTED
+// private DynamicExtendingClassWithDifferentScope dynamicExtendingClassWithDifferentScope =
+// enclosingClass.new DynamicExtendingClassWithDifferentScope(enclosingDynamicClass);
+
+ public static class EnclosingClass {
+ public class DynamicClass {
+ //Oracle/OpenJDK/IBM generates
+ //final EnclosingClass this$0;
+
+ //eclipse-[groovy-]compiler generates
+ //final EnclosingClass this$1;
+ }
+
+ public class DynamicExtendingClass extends DynamicClass {
+ //The field here masks the parent field
+
+ //Oracle/OpenJDK/IBM generates
+ //final EnclosingClass this$0;
+
+ //eclipse-[groovy-]compiler generates
+ //final EnclosingClass this$1;
+ }
+
+ public class EnclosingDynamicClass {
+ //Oracle/OpenJDK/IBM generates
+ //final EnclosingClass this$0;
+
+ //eclipse-[groovy-]compiler generates
+ //final EnclosingClass this$1;
+
+ public class NestedDynamicClass {
+ //Oracle/OpenJDK/IBM generates
+ //final EnclosingClass this$1;
+
+ //eclipse-[groovy-]compiler generates
+ //final EnclosingClass this$2;
+ }
+ }
+
+// WARNING: Combination NOT SUPPORTED. Not enough information in XML to deserialize reliably,
+// having in mind that different compilers could be used for parent/child classes.
+// If we really need to, we can extend the heuristic to check for field types or assume that
+// only one compiler was used for the whole class hierarchy covering some more cases.
+//
+// The problem is that we have two fields with different names, without relation between the
+// indexes in each one. Changing compilers (or combination of compilers) could change the
+// indexes independently in each field. This makes it impossible to infer which field in the xml
+// maps to which field in the object.
+// When having identical field names with parent classes XStream will put a defined-in attribute
+// which makes it possible to deserialize, but it can't be forced to put it in each element.
+//
+ public class DynamicExtendingClassWithDifferentScope extends NestedDynamicClass {
+ //Oracle/OpenJDK/IBM generates
+ //final EnclosingClass this$0;
+
+ //eclipse-[groovy-]compiler generates
+ //final EnclosingClass this$1;
+
+ //constructor required to compile
+ public DynamicExtendingClassWithDifferentScope(EnclosingDynamicClass superEnclosingScope) {
+ superEnclosingScope.super();
+ }
+ }
+ }
+
+ @Test
+ public void testXStreamDeserialize() throws Exception {
+ deserialize("/brooklyn/entity/rebind/compiler_compatibility_eclipse.xml");
+ deserialize("/brooklyn/entity/rebind/compiler_compatibility_oracle.xml");
+ }
+
+ private void deserialize(String inputUrl) throws Exception {
+ XStream xstream = new XStream() {
+ @Override
+ protected MapperWrapper wrapMapper(MapperWrapper next) {
+ return new CompilerIndependentOuterClassFieldMapper(super.wrapMapper(next));
+ }
+ };
+
+ InputStream in = this.getClass().getResourceAsStream(inputUrl);
+ try {
+ Object obj = xstream.fromXML(in);
+ assertNonNullOuterFields(obj);
+ } finally {
+ in.close();
+ }
+ }
+
+ private void assertNonNullOuterFields(Object obj) throws Exception {
+ Field[] testInstances = obj.getClass().getDeclaredFields();
+ for (Field instanceField : testInstances) {
+ Object instance = instanceField.get(obj);
+ Class<?> type = instance.getClass();
+ do {
+ for (Field field : type.getDeclaredFields()) {
+ if (field.getName().startsWith("this$")) {
+ Object value = field.get(instance);
+ assertTrue(value != null, field + " should not be null");
+ }
+ }
+ type = type.getSuperclass();
+ } while (type != null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba0e6480/core/src/test/resources/brooklyn/entity/rebind/compiler_compatibility_eclipse.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/entity/rebind/compiler_compatibility_eclipse.xml b/core/src/test/resources/brooklyn/entity/rebind/compiler_compatibility_eclipse.xml
new file mode 100644
index 0000000..dc972ef
--- /dev/null
+++ b/core/src/test/resources/brooklyn/entity/rebind/compiler_compatibility_eclipse.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<brooklyn.util.xstream.CompilerCompatibilityTest>
+ <enclosingClass/>
+ <dynamicClass>
+ <this_-1 reference="../../enclosingClass"/>
+ </dynamicClass>
+ <dynamicExtendingClass>
+ <this_-1 defined-in="brooklyn.util.xstream.CompilerCompatibilityTest$EnclosingClass$DynamicClass" reference="../../enclosingClass"/>
+ <this_-1 reference="../../enclosingClass"/>
+ </dynamicExtendingClass>
+ <enclosingDynamicClass>
+ <this_-1 reference="../../enclosingClass"/>
+ </enclosingDynamicClass>
+ <nestedDynamicClass>
+ <this_-2 reference="../../enclosingDynamicClass"/>
+ </nestedDynamicClass>
+<!-- NOT SUPPORTED
+ <dynamicExtendingClassWithDifferentScope>
+ <this_-2 reference="../../enclosingDynamicClass"/>
+ <this_-1 reference="../../enclosingClass"/>
+ </dynamicExtendingClassWithDifferentScope>
+-->
+</brooklyn.util.xstream.CompilerCompatibilityTest>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba0e6480/core/src/test/resources/brooklyn/entity/rebind/compiler_compatibility_oracle.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/entity/rebind/compiler_compatibility_oracle.xml b/core/src/test/resources/brooklyn/entity/rebind/compiler_compatibility_oracle.xml
new file mode 100644
index 0000000..a01692e
--- /dev/null
+++ b/core/src/test/resources/brooklyn/entity/rebind/compiler_compatibility_oracle.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<brooklyn.util.xstream.CompilerCompatibilityTest>
+ <enclosingClass/>
+ <dynamicClass>
+ <outer-class reference="../../enclosingClass"/>
+ </dynamicClass>
+ <dynamicExtendingClass>
+ <outer-class defined-in="brooklyn.util.xstream.CompilerCompatibilityTest$EnclosingClass$DynamicClass" reference="../../enclosingClass"/>
+ <outer-class reference="../../enclosingClass"/>
+ </dynamicExtendingClass>
+ <enclosingDynamicClass>
+ <outer-class reference="../../enclosingClass"/>
+ </enclosingDynamicClass>
+ <nestedDynamicClass>
+ <this_-1 reference="../../enclosingDynamicClass"/>
+ </nestedDynamicClass>
+<!-- NOT SUPPORTED
+ <dynamicExtendingClassWithDifferentScope>
+ <this_-1 reference="../../enclosingDynamicClass"/>
+ <outer-class reference="../../enclosingClass"/>
+ </dynamicExtendingClassWithDifferentScope>
+-->
+</brooklyn.util.xstream.CompilerCompatibilityTest>
[4/4] incubator-brooklyn git commit: This closes #520
Posted by al...@apache.org.
This closes #520
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/1f3bff40
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/1f3bff40
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/1f3bff40
Branch: refs/heads/master
Commit: 1f3bff40150a265e7fc87ce4a040465e2c0ac7eb
Parents: 34ce96e 49c5be4
Author: Aled Sage <al...@gmail.com>
Authored: Tue Mar 3 16:19:37 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Mar 3 16:19:37 2015 +0000
----------------------------------------------------------------------
core/pom.xml | 17 +-
.../rebind/persister/XmlMementoSerializer.java | 6 +-
...ompilerIndependentOuterClassFieldMapper.java | 166 +++++++++++++++++++
.../brooklyn/util/xstream/XmlSerializer.java | 2 +-
.../util/xstream/CompilerCompatibilityTest.java | 154 +++++++++++++++++
.../rebind/compiler_compatibility_eclipse.xml | 41 +++++
.../rebind/compiler_compatibility_oracle.xml | 41 +++++
7 files changed, 423 insertions(+), 4 deletions(-)
----------------------------------------------------------------------