Back port of Bugs #418486 and #440360.
Signed-off-by: Martin Vojtek <martin.vojtek@oracle.com>
diff --git a/moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/xmladapter/enum.json b/moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/xmladapter/enum.json
index 675fdb0..f535a96 100644
--- a/moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/xmladapter/enum.json
+++ b/moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/xmladapter/enum.json
@@ -1,2 +1,2 @@
-{"root":{"single":"2","multi":["1","3","1"]}}
+{"root":{"single":"2","multi":["1","3","1"],"cardSuit":"DIAMOND","cardSuits":["CLUB","HEART","SPADE"]}}
diff --git a/moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/xmladapter/enum.xml b/moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/xmladapter/enum.xml
index 1282962..d877ebd 100644
--- a/moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/xmladapter/enum.xml
+++ b/moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/jaxb/xmladapter/enum.xml
@@ -3,4 +3,8 @@
<multi>1</multi>
<multi>3</multi>
<multi>1</multi>
+ <cardSuit>DIAMOND</cardSuit>
+ <cardSuits>CLUB</cardSuits>
+ <cardSuits>HEART</cardSuits>
+ <cardSuits>SPADE</cardSuits>
</root>
\ No newline at end of file
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/XmlAdapterTestSuite.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/XmlAdapterTestSuite.java
index 980b7ad..6c97640 100644
--- a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/XmlAdapterTestSuite.java
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/XmlAdapterTestSuite.java
@@ -1,11 +1,11 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
@@ -29,18 +29,19 @@
import org.eclipse.persistence.testing.jaxb.xmladapter.direct.ListToStringAdapterTestCases;
import org.eclipse.persistence.testing.jaxb.xmladapter.direct.NormalizedStringTestCases;
import org.eclipse.persistence.testing.jaxb.xmladapter.direct.XmlAdapterDirectExceptionTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.direct.XmlAdapterDirectNullTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.direct.XmlAdapterDirectTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.direct.XmlAdapterSchemaTypeTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.direct.objectlist.ObjectListTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.elementref.XmlAdapterElementRefListTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.elementref.XmlAdapterElementRefTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.enumeration.AdapterEnumTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.generics.AdapterWithGenericsTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.hexbinary.XmlAdapterHexBinaryTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.inheritance.AdapterWithInheritanceTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.inheritance.generics.GenericAdapterTestCases;
-import org.eclipse.persistence.testing.jaxb.xmladapter.list.XmlAdapterListMultipleBarTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.direct.XmlAdapterDirectNullTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.direct.XmlAdapterDirectTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.direct.XmlAdapterSchemaTypeTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.direct.objectlist.ObjectListTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.elementref.XmlAdapterElementRefListTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.elementref.XmlAdapterElementRefTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.enumeration.AdapterEnumMoreGenericTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.enumeration.AdapterEnumTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.generics.AdapterWithGenericsTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.hexbinary.XmlAdapterHexBinaryTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.inheritance.AdapterWithInheritanceTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.inheritance.generics.GenericAdapterTestCases;
+import org.eclipse.persistence.testing.jaxb.xmladapter.list.XmlAdapterListMultipleBarTestCases;
import org.eclipse.persistence.testing.jaxb.xmladapter.list.XmlAdapterListSingleBarTestCases;
import org.eclipse.persistence.testing.jaxb.xmladapter.list.XmlAdapterNestedListSingleBarTestCases;
import org.eclipse.persistence.testing.jaxb.xmladapter.map.JAXBMapWithAdapterTestCases;
@@ -81,15 +82,17 @@
suite.addTestSuite(AdapterWithGenericsTestCases.class);
suite.addTestSuite(XmlAdapterDirectCollectionArrayTestCases.class);
suite.addTestSuite(ByteArrayTestCases.class);
- suite.addTestSuite(CollapsedStringListTestCases.class);
- suite.addTestSuite(CollapsedStringTestCases.class);
- suite.addTestSuite(NormalizedStringListTestCases.class);
- suite.addTestSuite(NormalizedStringTestCases.class);
- suite.addTestSuite(AdapterWithInheritanceTestCases.class);
- suite.addTestSuite(AdapterEnumTestCases.class);
- suite.addTestSuite(GenericAdapterTestCases.class);
- suite.addTestSuite(NoArgCtorAdapterTestCases.class);
- suite.addTestSuite(XmlAdapterSchemaTypeTestCases.class);
- return suite;
- }
-}
+ suite.addTestSuite(CollapsedStringListTestCases.class);
+ suite.addTestSuite(CollapsedStringTestCases.class);
+ suite.addTestSuite(NormalizedStringListTestCases.class);
+ suite.addTestSuite(NormalizedStringTestCases.class);
+ suite.addTestSuite(AdapterWithInheritanceTestCases.class);
+ suite.addTestSuite(AdapterEnumTestCases.class);
+ suite.addTestSuite(AdapterEnumMoreGenericTestCases.class);
+ suite.addTestSuite(GenericAdapterTestCases.class);
+ suite.addTestSuite(NoArgCtorAdapterTestCases.class);
+ suite.addTestSuite(XmlAdapterSchemaTypeTestCases.class);
+
+ return suite;
+ }
+}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/AdapterEnumMoreGenericTestCases.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/AdapterEnumMoreGenericTestCases.java
new file mode 100644
index 0000000..d2f61f2
--- /dev/null
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/AdapterEnumMoreGenericTestCases.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ ******************************************************************************/
+package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.persistence.testing.jaxb.JAXBWithJSONTestCases;
+
+/**
+ * This test represents scenario when more complicated generic XmlAdapter is used.
+ * <p>
+ * Example: GenericSuitsAdapterWithT<T extends Enum> extends XmlAdapter<String, T>
+ * </p>
+ */
+public class AdapterEnumMoreGenericTestCases extends JAXBWithJSONTestCases{
+ private final static String XML_RESOURCE = "org/eclipse/persistence/testing/jaxb/xmladapter/enum.xml";
+ private final static String JSON_RESOURCE = "org/eclipse/persistence/testing/jaxb/xmladapter/enum.json";
+
+ public AdapterEnumMoreGenericTestCases(String name) throws Exception {
+ super(name);
+ setControlDocument(XML_RESOURCE);
+ setControlJSON(JSON_RESOURCE);
+ Class[] classes = {MoreGenericEnumRoot.class};
+ setClasses(classes);
+ }
+
+ protected Object getControlObject() {
+ MoreGenericEnumRoot emp = new MoreGenericEnumRoot();
+ emp.multi = new ArrayList<Byte>();
+ emp.multi.add((byte)1);
+ emp.multi.add((byte)3);
+ emp.multi.add((byte)1);
+
+ emp.single = (byte)2;
+
+ emp.cardSuit = MoreGenericCardSuit.DIAMOND;
+ emp.cardSuits = Arrays.asList(MoreGenericCardSuit.CLUB, MoreGenericCardSuit.HEART, MoreGenericCardSuit.SPADE);
+ return emp;
+ }
+}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/AdapterEnumTestCases.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/AdapterEnumTestCases.java
index 4e6fc1a..accb073 100644
--- a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/AdapterEnumTestCases.java
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/AdapterEnumTestCases.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 - 2014 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -13,6 +13,7 @@
package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
import java.util.ArrayList;
+import java.util.Arrays;
import org.eclipse.persistence.testing.jaxb.JAXBWithJSONTestCases;
@@ -24,8 +25,7 @@
super(name);
setControlDocument(XML_RESOURCE);
setControlJSON(JSON_RESOURCE);
- Class[] classes = new Class[1];
- classes[0] = EnumRoot.class;
+ Class[] classes = {EnumRoot.class};
setClasses(classes);
}
@@ -37,6 +37,9 @@
emp.multi.add((byte)1);
emp.single = (byte)2;
+
+ emp.cardSuit = CardSuit.DIAMOND;
+ emp.cardSuits = Arrays.asList(CardSuit.CLUB, CardSuit.HEART, CardSuit.SPADE);
return emp;
}
}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/ByteToExampleEnumAdapter.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/ByteToExampleEnumAdapter.java
index ece5257..3bfb227 100644
--- a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/ByteToExampleEnumAdapter.java
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/ByteToExampleEnumAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/CardSuit.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/CardSuit.java
new file mode 100644
index 0000000..420d785
--- /dev/null
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/CardSuit.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ ******************************************************************************/
+package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+@XmlJavaTypeAdapter(value = SuitsAdapter.class)
+public enum CardSuit {
+ CLUB, DIAMOND, HEART, SPADE
+}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/EnumRoot.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/EnumRoot.java
index b857828..86858d1 100644
--- a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/EnumRoot.java
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/EnumRoot.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 - 2014 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -26,9 +26,41 @@
@XmlJavaTypeAdapter(ByteToExampleEnumAdapter.class)
public List<Byte> multi;
- public boolean equals(Object obj) {
- EnumRoot root = (EnumRoot)obj;
- return root.single.equals(single) && root.multi.equals(multi);
+ public CardSuit cardSuit;
+
+ public List<CardSuit> cardSuits;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ EnumRoot enumRoot = (EnumRoot) o;
+
+ if (cardSuit != enumRoot.cardSuit) return false;
+ if (cardSuits != null ? !cardSuits.equals(enumRoot.cardSuits) : enumRoot.cardSuits != null) return false;
+ if (multi != null ? !multi.equals(enumRoot.multi) : enumRoot.multi != null) return false;
+ if (single != null ? !single.equals(enumRoot.single) : enumRoot.single != null) return false;
+
+ return true;
}
+ @Override
+ public int hashCode() {
+ int result = single != null ? single.hashCode() : 0;
+ result = 31 * result + (multi != null ? multi.hashCode() : 0);
+ result = 31 * result + (cardSuit != null ? cardSuit.hashCode() : 0);
+ result = 31 * result + (cardSuits != null ? cardSuits.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "EnumRoot{" +
+ "single=" + single +
+ ", multi=" + multi +
+ ", cardSuit=" + cardSuit +
+ ", cardSuits=" + cardSuits +
+ '}';
+ }
}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/ExampleEnum.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/ExampleEnum.java
index 91cc1b7..5eea1e9 100644
--- a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/ExampleEnum.java
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/ExampleEnum.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/GenericSuitsAdapter.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/GenericSuitsAdapter.java
new file mode 100644
index 0000000..3dabba3
--- /dev/null
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/GenericSuitsAdapter.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ ******************************************************************************/
+package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+public abstract class GenericSuitsAdapter<T extends Enum> extends XmlAdapter<String, Enum> {
+ @Override
+ public Enum unmarshal(String v) throws Exception {
+ return convert(v);
+ }
+
+ public abstract T convert(String value);
+
+ @Override
+ public String marshal(Enum v) throws Exception {
+ return v.name();
+ }
+}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/GenericSuitsAdapterWithT.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/GenericSuitsAdapterWithT.java
new file mode 100644
index 0000000..ed06dbe
--- /dev/null
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/GenericSuitsAdapterWithT.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ ******************************************************************************/
+package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.eclipse.persistence.internal.jaxb.GenericsClassHelper;
+
+/**
+ * <p>
+ * The correct values of BoundType and ValueType of Generic XmlAdapter are resolved by GenericsClassHelper.
+ *
+ * <p>
+ * ReflectionHelper does not help when you define XmlAdapter as XmlAdapter<Object, Object> or XmlAdapter<Object, T>
+ *
+ * @see GenericsClassHelper
+ *
+ */
+public abstract class GenericSuitsAdapterWithT<T extends Enum> extends XmlAdapter<String, T> {
+ @Override
+ public T unmarshal(String v) throws Exception {
+ return convert(v);
+ }
+
+ public abstract T convert(String value);
+
+ @Override
+ public String marshal(T v) throws Exception {
+ return v.name();
+ }
+}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericCardSuit.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericCardSuit.java
new file mode 100644
index 0000000..ee6e9f7
--- /dev/null
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericCardSuit.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ ******************************************************************************/
+package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+@XmlJavaTypeAdapter(value = MoreGenericSuitsAdapter.class)
+public enum MoreGenericCardSuit {
+ CLUB, DIAMOND, HEART, SPADE
+}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericEnumRoot.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericEnumRoot.java
new file mode 100644
index 0000000..ed1e719
--- /dev/null
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericEnumRoot.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ ******************************************************************************/
+package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+@XmlRootElement(name="root")
+public class MoreGenericEnumRoot {
+
+ @XmlJavaTypeAdapter(ByteToExampleEnumAdapter.class)
+ public Byte single;
+
+ @XmlJavaTypeAdapter(ByteToExampleEnumAdapter.class)
+ public List<Byte> multi;
+
+ public MoreGenericCardSuit cardSuit;
+
+ public List<MoreGenericCardSuit> cardSuits;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ MoreGenericEnumRoot enumRoot = (MoreGenericEnumRoot) o;
+
+ if (cardSuit != enumRoot.cardSuit) return false;
+ if (cardSuits != null ? !cardSuits.equals(enumRoot.cardSuits) : enumRoot.cardSuits != null) return false;
+ if (multi != null ? !multi.equals(enumRoot.multi) : enumRoot.multi != null) return false;
+ if (single != null ? !single.equals(enumRoot.single) : enumRoot.single != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = single != null ? single.hashCode() : 0;
+ result = 31 * result + (multi != null ? multi.hashCode() : 0);
+ result = 31 * result + (cardSuit != null ? cardSuit.hashCode() : 0);
+ result = 31 * result + (cardSuits != null ? cardSuits.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "EnumRoot{" +
+ "single=" + single +
+ ", multi=" + multi +
+ ", cardSuit=" + cardSuit +
+ ", cardSuits=" + cardSuits +
+ '}';
+ }
+}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericSuitsAdapter.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericSuitsAdapter.java
new file mode 100644
index 0000000..f9ad67c
--- /dev/null
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/MoreGenericSuitsAdapter.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ ******************************************************************************/
+package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
+
+public class MoreGenericSuitsAdapter extends GenericSuitsAdapter<MoreGenericCardSuit> {
+ @Override
+ public MoreGenericCardSuit convert(String value) {
+ return MoreGenericCardSuit.valueOf(value);
+ }
+}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/SuitsAdapter.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/SuitsAdapter.java
new file mode 100644
index 0000000..47a4a23
--- /dev/null
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmladapter/enumeration/SuitsAdapter.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ ******************************************************************************/
+package org.eclipse.persistence.testing.jaxb.xmladapter.enumeration;
+
+public class SuitsAdapter extends GenericSuitsAdapter<CardSuit> {
+ @Override
+ public CardSuit convert(String value) {
+ return CardSuit.valueOf(value);
+ }
+}
diff --git a/moxy/org.eclipse.persistence.moxy.dynamicxjc/src/org/eclipse/persistence/jaxb/javamodel/xjc/XJCJavaClassImpl.java b/moxy/org.eclipse.persistence.moxy.dynamicxjc/src/org/eclipse/persistence/jaxb/javamodel/xjc/XJCJavaClassImpl.java
index 1e184a9..053216f 100644
--- a/moxy/org.eclipse.persistence.moxy.dynamicxjc/src/org/eclipse/persistence/jaxb/javamodel/xjc/XJCJavaClassImpl.java
+++ b/moxy/org.eclipse.persistence.moxy.dynamicxjc/src/org/eclipse/persistence/jaxb/javamodel/xjc/XJCJavaClassImpl.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011 - 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -23,19 +23,13 @@
import org.eclipse.persistence.dynamic.DynamicClassLoader;
import org.eclipse.persistence.exceptions.JAXBException;
-import org.eclipse.persistence.internal.helper.ClassConstants;
-import org.eclipse.persistence.internal.helper.ConversionManager;
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.jaxb.javamodel.JavaAnnotation;
-import org.eclipse.persistence.jaxb.javamodel.JavaClass;
-import org.eclipse.persistence.jaxb.javamodel.JavaConstructor;
-import org.eclipse.persistence.jaxb.javamodel.JavaField;
-import org.eclipse.persistence.jaxb.javamodel.JavaMethod;
-import org.eclipse.persistence.jaxb.javamodel.JavaModel;
-import org.eclipse.persistence.jaxb.javamodel.JavaPackage;
-
-import com.sun.codemodel.ClassType;
-import com.sun.codemodel.JAnnotationUse;
+import org.eclipse.persistence.internal.helper.ClassConstants;
+import org.eclipse.persistence.internal.helper.ConversionManager;
+import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
+import org.eclipse.persistence.jaxb.javamodel.*;
+
+import com.sun.codemodel.ClassType;
+import com.sun.codemodel.JAnnotationUse;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
@@ -52,16 +46,16 @@
* <b>Purpose:</b> <code>JavaClass</code> implementation wrapping XJC's <code>JDefinedClass</code>.
* Used when bootstrapping a <code>DynamicJAXBContext</code> from an XML Schema.
* </p>
- *
- * <p>
- * <b>Responsibilities:</b>
- * <ul>
- * <li>Provide Class information from the underlying <code>JDefinedClass</code>.</li>
- * </ul>
- * </p>
- *
- * @since EclipseLink 2.1
- *
+ *
+ * <p>
+ * <b>Responsibilities:</b>
+ * </p>
+ * <ul>
+ * <li>Provide Class information from the underlying <code>JDefinedClass</code>.</li>
+ * </ul>
+ *
+ * @since EclipseLink 2.1
+ *
* @see org.eclipse.persistence.jaxb.javamodel.JavaClass
*/
public class XJCJavaClassImpl implements JavaClass {
@@ -522,12 +516,15 @@
* @return <code>JavaClass</code> representing the super class of this <code>JavaClass</code>.
*/
public JavaClass getSuperclass() {
- try {
- JClass superClass = (JClass) PrivilegedAccessHelper.getValueFromField(JDEFINEDCLASS_SUPERCLASS, xjcClass);
-
- if (superClass instanceof JDefinedClass) {
- if (javaModel != null) {
- return this.javaModel.getClass(superClass.fullName());
+ try {
+ JClass superClass = (JClass) PrivilegedAccessHelper.getValueFromField(JDEFINEDCLASS_SUPERCLASS, xjcClass);
+
+ if (superClass == null) // if null -> no need to continue
+ return null;
+
+ if (superClass instanceof JDefinedClass) {
+ if (javaModel != null) {
+ return this.javaModel.getClass(superClass.fullName());
}
return new XJCJavaClassImpl((JDefinedClass) superClass, jCodeModel, dynamicClassLoader);
} else {
@@ -698,12 +695,17 @@
* Not supported.
*/
public boolean isSynthetic() {
- throw new UnsupportedOperationException("isSynthetic");
- }
-
- /**
- * If this <code>JavaClass</code> is annotated with an <code>Annotation</code> matching <code>aClass</code>,
- * return its <code>JavaAnnotation</code> representation.
+ throw new UnsupportedOperationException("isSynthetic");
+ }
+
+ @Override
+ public JavaClassInstanceOf instanceOf() {
+ return JavaClassInstanceOf.XJC_JAVA_CLASS_IMPL;
+ }
+
+ /**
+ * If this <code>JavaClass</code> is annotated with an <code>Annotation</code> matching <code>aClass</code>,
+ * return its <code>JavaAnnotation</code> representation.
*
* @param aClass a <code>JavaClass</code> representing the <code>Annotation</code> to look for.
*
@@ -794,7 +796,7 @@
* @param javaModel The <code>JavaModel</code> to set.
*/
public void setJavaModel(JavaModel javaModel) {
- this.javaModel = javaModel;
- }
-
-}
\ No newline at end of file
+ this.javaModel = javaModel;
+ }
+
+}
diff --git a/moxy/org.eclipse.persistence.moxy.dynamicxjc/src/org/eclipse/persistence/jaxb/javamodel/xjc/XJCJavaMethodImpl.java b/moxy/org.eclipse.persistence.moxy.dynamicxjc/src/org/eclipse/persistence/jaxb/javamodel/xjc/XJCJavaMethodImpl.java
index 6afcd63..e8487c1 100644
--- a/moxy/org.eclipse.persistence.moxy.dynamicxjc/src/org/eclipse/persistence/jaxb/javamodel/xjc/XJCJavaMethodImpl.java
+++ b/moxy/org.eclipse.persistence.moxy.dynamicxjc/src/org/eclipse/persistence/jaxb/javamodel/xjc/XJCJavaMethodImpl.java
@@ -1,7 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+/*******************************************************************************
+ * Copyright (c) 2011 - 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
@@ -354,7 +355,14 @@
* @param owningClass the <code>JavaClass</code> representing the owner of this <code>JavaMethod</code>.
*/
public void setOwningClass(JavaClass owningClass) {
- this.owningClass = owningClass;
- }
-
+ this.owningClass = owningClass;
+ }
+
+ /**
+ * Not supported.
+ */
+ @Override
+ public boolean isBridge() {
+ return false;
+ }
}
\ No newline at end of file
diff --git a/moxy/org.eclipse.persistence.moxy/.settings/org.eclipse.jdt.core.prefs b/moxy/org.eclipse.persistence.moxy/.settings/org.eclipse.jdt.core.prefs
index 90a25d9..a2b8934 100644
--- a/moxy/org.eclipse.persistence.moxy/.settings/org.eclipse.jdt.core.prefs
+++ b/moxy/org.eclipse.persistence.moxy/.settings/org.eclipse.jdt.core.prefs
@@ -1,15 +1,24 @@
-#Mon Oct 08 11:43:43 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.deprecation=ignore
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=ignore
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
@@ -47,6 +56,7 @@
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/internal/jaxb/GenericsClassHelper.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/internal/jaxb/GenericsClassHelper.java
new file mode 100644
index 0000000..e30cc15
--- /dev/null
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/internal/jaxb/GenericsClassHelper.java
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ ******************************************************************************/
+package org.eclipse.persistence.internal.jaxb;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Utility class for Generic class hierarchy.
+ *
+ */
+public class GenericsClassHelper {
+
+ /**
+ * A tuple consisting of a concrete class, declaring class that declares a
+ * generic interface type.
+ */
+ private static class DeclaringClassInterfacePair {
+ public final Class concreteClass;
+
+ public final Class declaringClass;
+
+ public final Type genericInterface;
+
+ private DeclaringClassInterfacePair(Class concreteClass, Class declaringClass, Type genericInteface) {
+ this.concreteClass = concreteClass;
+ this.declaringClass = declaringClass;
+ this.genericInterface = genericInteface;
+ }
+ }
+
+ /**
+ * Get the parameterized type arguments for a declaring class that
+ * declares a generic class or interface type.
+ *
+ * @param concrete the concrete class than directly or indirectly
+ * implements or extends an interface class.
+ * @param classOrIface the interface or class.
+ * @return the parameterized type arguments, or null if the generic
+ * interface type is not a parameterized type.
+ */
+ public static Type[] getParameterizedTypeArguments(Class concrete, Class classOrIface) {
+ DeclaringClassInterfacePair declaringClassInterfacePair = getClass(concrete, classOrIface);
+ if (null != declaringClassInterfacePair) {
+ return getParameterizedTypeArguments(declaringClassInterfacePair);
+ }
+ return null;
+ }
+
+ /**
+ * Get the parameterized type arguments for a declaring class that
+ * declares a generic interface type.
+ *
+ * @param p the declaring class
+ * @return the parameterized type arguments, or null if the generic
+ * interface type is not a parameterized type.
+ */
+ private static Type[] getParameterizedTypeArguments(DeclaringClassInterfacePair p) {
+ if (p.genericInterface instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) p.genericInterface;
+ Type[] as = pt.getActualTypeArguments();
+ Type[] ras = new Type[as.length];
+
+ for (int i = 0; i < as.length; i++) {
+ Type a = as[i];
+ if (a instanceof Class) {
+ ras[i] = a;
+ } else if (a instanceof ParameterizedType) {
+ pt = (ParameterizedType) a;
+ ras[i] = a;
+ } else if (a instanceof TypeVariable) {
+ ClassTypePair ctp = resolveTypeVariable(p.concreteClass, p.declaringClass, (TypeVariable) a);
+ if (null != ctp) {
+ ras[i] = ctp.t;
+ }
+ }
+ }
+ return ras;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Find the declaring class that implements or extends an interface or class.
+ *
+ * @param concrete the concrete class than directly or indirectly
+ * implements or extends an interface class.
+ * @param classOrIface the interface or class.
+ * @return the tuple of the declaring class and the generic interface or class
+ * type.
+ */
+ private static DeclaringClassInterfacePair getClass(Class concrete, Class classOrIface) {
+ return getClass(concrete, classOrIface, concrete);
+ }
+
+ private static DeclaringClassInterfacePair getClass(Class concrete, Class classOrIface, Class c) {
+ Type[] gis = null;
+
+ if (null != c.getGenericSuperclass()) {
+ gis = new Type[] {c.getGenericSuperclass()};
+ }
+
+ if (null == gis) {
+ gis = c.getGenericInterfaces();
+ }
+
+ DeclaringClassInterfacePair p = getType(concrete, classOrIface, c, gis);
+ if (p != null)
+ return p;
+
+ c = c.getSuperclass();
+ if (c == null || c == Object.class)
+ return null;
+
+ return getClass(concrete, classOrIface, c);
+ }
+
+ private static DeclaringClassInterfacePair getType(Class concrete, Class classOrIface, Class c, Type[] ts) {
+ for (Type t : ts) {
+ DeclaringClassInterfacePair p = getType(concrete, classOrIface, c, t);
+ if (p != null)
+ return p;
+ }
+ return null;
+ }
+
+ private static DeclaringClassInterfacePair getType(Class concrete, Class classOrIface, Class c, Type t) {
+ if (t instanceof Class) {
+ if (t == classOrIface) {
+ return new DeclaringClassInterfacePair(concrete, c, t);
+ } else {
+ return getClass(concrete, classOrIface, (Class) t);
+ }
+ } else if (t instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) t;
+ if (pt.getRawType() == classOrIface) {
+ return new DeclaringClassInterfacePair(concrete, c, t);
+ } else {
+ return getClass(concrete, classOrIface, (Class) pt.getRawType());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * A tuple consisting of a class and type of the class.
+ */
+ private static class ClassTypePair {
+
+ /**
+ * The type of the class.
+ */
+ public final Type t;
+
+ public ClassTypePair(Class c) {
+ this(c, c);
+ }
+
+ public ClassTypePair(Class c, Type t) {
+ this.t = t;
+ }
+ }
+
+ /**
+ * Given a type variable resolve the Java class of that variable.
+ *
+ * @param c the concrete class from which all type variables are resolved
+ * @param dc the declaring class where the type variable was defined
+ * @param tv the type variable
+ * @return the resolved Java class and type, otherwise null if the type variable
+ * could not be resolved
+ */
+ private static ClassTypePair resolveTypeVariable(Class c, Class dc, TypeVariable tv) {
+ return resolveTypeVariable(c, dc, tv, new HashMap<TypeVariable, Type>());
+ }
+
+ private static ClassTypePair resolveTypeVariable(Class c, Class dc, TypeVariable tv,
+ Map<TypeVariable, Type> map) {
+ Type[] gis = c.getGenericInterfaces();
+ for (Type gi : gis) {
+ if (gi instanceof ParameterizedType) {
+ // process pt of interface
+ ParameterizedType pt = (ParameterizedType) gi;
+ ClassTypePair ctp = resolveTypeVariable(pt, (Class) pt.getRawType(), dc, tv, map);
+ if (ctp != null)
+ return ctp;
+ }
+ }
+
+ Type gsc = c.getGenericSuperclass();
+ if (gsc instanceof ParameterizedType) {
+ // process pt of class
+ ParameterizedType pt = (ParameterizedType) gsc;
+ return resolveTypeVariable(pt, c.getSuperclass(), dc, tv, map);
+ } else if (gsc instanceof Class) {
+ return resolveTypeVariable(c.getSuperclass(), dc, tv, map);
+ }
+ return null;
+ }
+
+ private static ClassTypePair resolveTypeVariable(ParameterizedType pt, Class c, Class dc, TypeVariable tv,
+ Map<TypeVariable, Type> map) {
+ Type[] typeArguments = pt.getActualTypeArguments();
+
+ TypeVariable[] typeParameters = c.getTypeParameters();
+
+ Map<TypeVariable, Type> submap = new HashMap<TypeVariable, Type>();
+ for (int i = 0; i < typeArguments.length; i++) {
+ // Substitute a type variable with the Java class
+ if (typeArguments[i] instanceof TypeVariable) {
+ Type t = map.get(typeArguments[i]);
+ submap.put(typeParameters[i], t);
+ } else {
+ submap.put(typeParameters[i], typeArguments[i]);
+ }
+ }
+
+ if (c == dc) {
+ Type t = submap.get(tv);
+ if (t instanceof Class) {
+ return new ClassTypePair((Class) t);
+ } else if (t instanceof GenericArrayType) {
+ t = ((GenericArrayType) t).getGenericComponentType();
+ if (t instanceof Class) {
+ c = (Class) t;
+ try {
+ return new ClassTypePair(getArrayClass(c));
+ } catch (Exception e) {
+ }
+ return null;
+ } else if (t instanceof ParameterizedType) {
+ Type rt = ((ParameterizedType) t).getRawType();
+ if (rt instanceof Class) {
+ c = (Class) rt;
+ } else {
+ return null;
+ }
+ try {
+ return new ClassTypePair(getArrayClass(c), t);
+ } catch (Exception e) {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ } else if (t instanceof ParameterizedType) {
+ pt = (ParameterizedType) t;
+ if (pt.getRawType() instanceof Class) {
+ return new ClassTypePair((Class) pt.getRawType(), pt);
+ } else
+ return null;
+ } else {
+ return null;
+ }
+ } else {
+ return resolveTypeVariable(c, dc, tv, submap);
+ }
+ }
+
+ protected static Class getClassOfType(Type type) {
+ if (type instanceof Class) {
+ return (Class) type;
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType arrayType = (GenericArrayType) type;
+ Type t = arrayType.getGenericComponentType();
+ if (t instanceof Class) {
+ return getArrayClass((Class) t);
+ }
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType subType = (ParameterizedType) type;
+ Type t = subType.getRawType();
+ if (t instanceof Class) {
+ return (Class) t;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get Array class of component class.
+ *
+ * @param c the component class of the array
+ * @return the array class.
+ */
+ private static Class getArrayClass(Class c) {
+ try {
+ Object o = Array.newInstance(c, 0);
+ return o.getClass();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/internal/jaxb/XMLJavaTypeConverter.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/internal/jaxb/XMLJavaTypeConverter.java
index 2eaf965..289ad51 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/internal/jaxb/XMLJavaTypeConverter.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/internal/jaxb/XMLJavaTypeConverter.java
@@ -1,51 +1,49 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2015 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
- ******************************************************************************/
-package org.eclipse.persistence.internal.jaxb;
-
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.util.HashMap;
-
-import org.eclipse.persistence.core.mappings.converters.CoreConverter;
-import org.eclipse.persistence.exceptions.ConversionException;
-import org.eclipse.persistence.exceptions.JAXBException;
-import org.eclipse.persistence.internal.oxm.XMLConversionManager;
-import org.eclipse.persistence.internal.oxm.XMLBinaryDataHelper;
-import org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping;
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.internal.security.PrivilegedClassForName;
-import org.eclipse.persistence.internal.security.PrivilegedGetConstructorFor;
-import org.eclipse.persistence.internal.security.PrivilegedGetDeclaredMethods;
-import org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass;
-import org.eclipse.persistence.internal.sessions.AbstractSession;
-import org.eclipse.persistence.mappings.DatabaseMapping;
-import org.eclipse.persistence.mappings.converters.ObjectTypeConverter;
-import org.eclipse.persistence.oxm.XMLMarshaller;
-import org.eclipse.persistence.oxm.XMLUnmarshaller;
-import org.eclipse.persistence.jaxb.JAXBMarshaller;
-import org.eclipse.persistence.jaxb.JAXBUnmarshaller;
-import org.eclipse.persistence.sessions.Session;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import javax.xml.namespace.QName;
-
-/**
- * Converter that wraps an XmlAdapter.
- *
+ ******************************************************************************/
+package org.eclipse.persistence.internal.jaxb;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Type;
+import java.security.AccessController;
+import java.util.HashMap;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.namespace.QName;
+
+import org.eclipse.persistence.core.mappings.converters.CoreConverter;
+import org.eclipse.persistence.exceptions.ConversionException;
+import org.eclipse.persistence.exceptions.JAXBException;
+import org.eclipse.persistence.internal.oxm.XMLBinaryDataHelper;
+import org.eclipse.persistence.internal.oxm.XMLConversionManager;
+import org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping;
+import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
+import org.eclipse.persistence.internal.security.PrivilegedClassForName;
+import org.eclipse.persistence.internal.security.PrivilegedGetConstructorFor;
+import org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass;
+import org.eclipse.persistence.internal.sessions.AbstractSession;
+import org.eclipse.persistence.jaxb.JAXBMarshaller;
+import org.eclipse.persistence.jaxb.JAXBUnmarshaller;
+import org.eclipse.persistence.mappings.DatabaseMapping;
+import org.eclipse.persistence.mappings.converters.ObjectTypeConverter;
+import org.eclipse.persistence.oxm.XMLMarshaller;
+import org.eclipse.persistence.oxm.XMLUnmarshaller;
+import org.eclipse.persistence.sessions.Session;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * Converter that wraps an XmlAdapter.
+ *
* @see javax.xml.bind.annotation.adapters.XmlAdapter
*/
public class XMLJavaTypeConverter extends org.eclipse.persistence.oxm.mappings.converters.XMLConverterAdapter {
@@ -59,23 +57,21 @@
protected CoreConverter nestedConverter;
/**
- * The default constructor. This constructor should be used
- * in conjunction with the setXmlAdapterClass method or
- * setXmlAdapterClassName method.
- *
- * @see setXmlAdapterClass(Class)
- */
- public XMLJavaTypeConverter() {
- }
+ * The default constructor. This constructor should be used
+ * in conjunction with the setXmlAdapterClass method or
+ * setXmlAdapterClassName method.
+ */
+ public XMLJavaTypeConverter() {
+ }
/**
- * This constructor takes the XmlAdapter class to be used with this
- * converter.
- *
- * @param xmlAdapter
- */
- public XMLJavaTypeConverter(Class xmlAdapterClass) {
- setXmlAdapterClass(xmlAdapterClass);
+ * This constructor takes the XmlAdapter class to be used with this
+ * converter.
+ *
+ * @param xmlAdapterClass
+ */
+ public XMLJavaTypeConverter(Class xmlAdapterClass) {
+ setXmlAdapterClass(xmlAdapterClass);
}
/**
@@ -92,13 +88,13 @@
* This constructor takes the XmlAdapter class to be used with this
* converter, as well as a schema type to be used during the conversion
* operation. During unmarshal, the value type will be converted to
- * the schema type, then from that type to the bound type. The opposite
- * will occur during marshal.
- *
- * @param xmlAdapter
- * @param schemaType
- */
- public XMLJavaTypeConverter(Class xmlAdapterClass, QName schemaType) {
+ * the schema type, then from that type to the bound type. The opposite
+ * will occur during marshal.
+ *
+ * @param xmlAdapterClass
+ * @param schemaType
+ */
+ public XMLJavaTypeConverter(Class xmlAdapterClass, QName schemaType) {
setSchemaType(schemaType);
setXmlAdapterClass(xmlAdapterClass);
}
@@ -107,13 +103,13 @@
* This constructor takes the XmlAdapter class name to be used with this
* converter (loaded during initialization), as well as a schema type to
* be used during the conversion operation. During unmarshal, the value
- * type will be converted to the schema type, then from that type to the
- * bound type. The opposite will occur during marshal.
- *
- * @param xmlAdapter
- * @param schemaType
- */
- public XMLJavaTypeConverter(String xmlAdapterClassName, QName schemaType) {
+ * type will be converted to the schema type, then from that type to the
+ * bound type. The opposite will occur during marshal.
+ *
+ * @param xmlAdapterClassName
+ * @param schemaType
+ */
+ public XMLJavaTypeConverter(String xmlAdapterClassName, QName schemaType) {
setSchemaType(schemaType);
setXmlAdapterClassName(xmlAdapterClassName);
}
@@ -250,49 +246,26 @@
}
// validate adapter class extends javax.xml.bind.annotation.adapters.XmlAdapter
- if (!XmlAdapter.class.isAssignableFrom(xmlAdapterClass)) {
- throw JAXBException.invalidAdapterClass(getXmlAdapterClassName());
- }
-
- this.mapping = mapping;
- Method[] methods = null;
- if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
- try {
- methods = (Method[]) AccessController.doPrivileged(new PrivilegedGetDeclaredMethods(xmlAdapterClass));
- } catch (PrivilegedActionException ex) {
- throw JAXBException.adapterClassMethodsCouldNotBeAccessed(getXmlAdapterClassName(), ex);
- }
- } else {
- methods = PrivilegedAccessHelper.getDeclaredMethods(xmlAdapterClass);
- }
- Method method;
- // look for marshal method
- for (int i = 0; i < methods.length; i++) {
- method = methods[i];
-
- // for some reason, getDeclaredMethods is returning inherited
- // methods - need to filter
- if (method.getName().equals("marshal") && (PrivilegedAccessHelper.getMethodReturnType(method) != Object.class) && (method.getParameterTypes()[0] != Object.class)) {
- valueType = method.getReturnType();
- boundType = method.getParameterTypes()[0];
- break;
- }
- }
-
- try {
- try {
- if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
- xmlAdapter = (XmlAdapter) AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(getXmlAdapterClass()));
- } else {
+ if (!XmlAdapter.class.isAssignableFrom(xmlAdapterClass)) {
+ throw JAXBException.invalidAdapterClass(getXmlAdapterClassName());
+ }
+
+ setBoundTypeAndValueTypeInCaseOfGenericXmlAdapter();
+
+ try {
+ try {
+ if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
+ xmlAdapter = (XmlAdapter) AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(getXmlAdapterClass()));
+ } else {
xmlAdapter = (XmlAdapter) PrivilegedAccessHelper.newInstanceFromClass(getXmlAdapterClass());
}
- } catch (IllegalAccessException e) {
- Constructor ctor = null;
- if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
- ctor = AccessController.doPrivileged(new PrivilegedGetConstructorFor(xmlAdapterClass, new Class[0], true));
- } else {
- ctor = PrivilegedAccessHelper.getDeclaredConstructorFor(xmlAdapterClass, new Class[0], true);
- }
+ } catch (IllegalAccessException e) {
+ Constructor ctor = null;
+ if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
+ ctor = AccessController.doPrivileged(new PrivilegedGetConstructorFor(xmlAdapterClass, new Class[0], true));
+ } else {
+ ctor = PrivilegedAccessHelper.getDeclaredConstructorFor(xmlAdapterClass, new Class[0], true);
+ }
xmlAdapter = (XmlAdapter) PrivilegedAccessHelper.invokeConstructor(ctor, new Object[0]);
}
} catch (Exception ex) {
@@ -303,12 +276,31 @@
((ObjectTypeConverter)nestedConverter).convertClassNamesToClasses(loader);
}
nestedConverter.initialize(mapping, session);
- }
- }
-
- /**
- * Satisfy the interface.
- */
+ }
+ }
+
+ private void setBoundTypeAndValueTypeInCaseOfGenericXmlAdapter() {
+ Type[] parameterizedTypeArguments = GenericsClassHelper.getParameterizedTypeArguments(xmlAdapterClass, XmlAdapter.class);
+
+ if (null != parameterizedTypeArguments) {
+ Class valueTypeClass = GenericsClassHelper.getClassOfType(parameterizedTypeArguments[0]);
+ if (null != valueTypeClass) {
+ valueType = valueTypeClass;
+ }
+ if (valueType.isInterface()) {
+ valueType = Object.class; // during unmarshalling we'll need to instantiate this, so -> no interfaces
+ }
+
+ Class boundTypeClass = GenericsClassHelper.getClassOfType(parameterizedTypeArguments[1]);
+ if (null != boundTypeClass) {
+ boundType = boundTypeClass;
+ }
+ }
+ }
+
+ /**
+ * Satisfy the interface.
+ */
public boolean isMutable() {
return false;
}
@@ -330,13 +322,13 @@
this.xmlAdapterClass = xmlAdapterClass;
}
- /**
- * Set the XmlAdapter class to be used with this converter.
- *
- * @param xmlAdapterClass
- */
- public void setXmlAdapterClassName(String xmlAdapterClassName) {
- this.xmlAdapterClassName = xmlAdapterClassName;
+ /**
+ * Set the XmlAdapter class to be used with this converter.
+ *
+ * @param xmlAdapterClassName
+ */
+ public void setXmlAdapterClassName(String xmlAdapterClassName) {
+ this.xmlAdapterClassName = xmlAdapterClassName;
}
/**
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/Property.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/Property.java
index 46ae652..3b33bb9 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/Property.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/Property.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998 - 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -21,21 +21,20 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.eclipse.persistence.jaxb.javamodel.reflection.JavaClassImpl;
-import org.eclipse.persistence.internal.oxm.mappings.Field;
-import org.eclipse.persistence.internal.oxm.XPathFragment;
-import org.eclipse.persistence.jaxb.javamodel.Helper;
-import org.eclipse.persistence.jaxb.javamodel.JavaClass;
-import org.eclipse.persistence.jaxb.javamodel.JavaHasAnnotations;
-import org.eclipse.persistence.jaxb.javamodel.JavaMethod;
-import org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy;
-import org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef;
-import org.eclipse.persistence.jaxb.xmlmodel.XmlElementWrapper;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.namespace.QName;
+
+import org.eclipse.persistence.internal.jaxb.GenericsClassHelper;
+import org.eclipse.persistence.internal.oxm.XPathFragment;
+import org.eclipse.persistence.internal.oxm.mappings.Field;
+import org.eclipse.persistence.jaxb.javamodel.*;
+import org.eclipse.persistence.jaxb.javamodel.reflection.JavaClassImpl;
+import org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy;
+import org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef;
+import org.eclipse.persistence.jaxb.xmlmodel.XmlElementWrapper;
import org.eclipse.persistence.jaxb.xmlmodel.XmlElements;
import org.eclipse.persistence.jaxb.xmlmodel.XmlJavaTypeAdapter;
import org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes;
@@ -67,26 +66,25 @@
private QName schemaType;
private boolean isSwaAttachmentRef;
private boolean isMtomAttachment;
- private boolean isInlineBinaryData;
- private String mimeType;
- private JavaClass type;
- private JavaClass adapterClass;
- private JavaHasAnnotations element;
- private JavaClass genericType;
- private boolean isAttribute = false;
+ private boolean isInlineBinaryData;
+ private String mimeType;
+ private JavaClass type;
+ private JavaHasAnnotations element;
+ private JavaClass genericType;
+ private boolean isAttribute = false;
private boolean isAnyAttribute = false;
- private boolean isAnyElement = false;
- private Helper helper;
- private Map<Object, Object> userProperties;
-
- //Original get and set methods for this property
- //Used to keep track of overrides
- private String originalGetMethodName;
- private String originalSetMethodName;
-
- private String getMethodName;
- private String setMethodName;
- private boolean isRequired = false;
+ private boolean isAnyElement = false;
+ private Helper helper;
+ private Map<Object, Object> userProperties;
+
+ //Original get and set methods for this property
+ //Used to keep track of overrides
+ private String originalGetMethodName;
+ private String originalSetMethodName;
+
+ private String getMethodName;
+ private String setMethodName;
+ private boolean isRequired = false;
private boolean isNillable = false;
private boolean isXmlList = false;
private boolean isTransient;
@@ -119,18 +117,16 @@
// XmlAnyElement specific attributes
private boolean lax;
private String domHandlerClassName;
- private String variableAttributeName;
- private String variableClassName;
- private boolean variableNodeAttribute;
-
-
-
- // XmlMap specific attributes
- private JavaClass keyType;
- private JavaClass valueType;
- public static final String DEFAULT_KEY_NAME = "key";
- public static final String DEFAULT_VALUE_NAME = "value";
- private boolean isMap = false;
+ private String variableAttributeName;
+ private String variableClassName;
+ private boolean variableNodeAttribute;
+
+ // XmlMap specific attributes
+ private JavaClass keyType;
+ private JavaClass valueType;
+ public static final String DEFAULT_KEY_NAME = "key";
+ public static final String DEFAULT_VALUE_NAME = "value";
+ private boolean isMap = false;
private String xmlPath;
// XmlElements specific attributes
@@ -147,20 +143,29 @@
private XmlJoinNodes xmlJoinNodes;
private List<XmlJoinNodes> xmlJoinNodesList;
private boolean isSuperClassProperty;
-
- private boolean isTransientType;
- private static final String MARSHAL_METHOD_NAME = "marshal";
-
- private boolean isTyped;
-
-
- public Property() {}
-
- public Property(Helper helper) {
- this.helper = helper;
- }
-
- public void setHelper(Helper helper) {
+
+ private boolean isTransientType;
+ private static final String MARSHAL_METHOD_NAME = "marshal";
+
+ private static JavaClass XML_ADAPTER_CLASS;
+ private static JavaClass OBJECT_CLASS;
+
+ private boolean isTyped;
+
+
+ public Property() {}
+
+ public Property(Helper helper) {
+ this.helper = helper;
+
+ // let's init static fields
+ if (XML_ADAPTER_CLASS == null)
+ XML_ADAPTER_CLASS = helper.getJavaClass(XmlAdapter.class);
+ if (OBJECT_CLASS == null)
+ OBJECT_CLASS = helper.getJavaClass(Object.class);
+ }
+
+ public void setHelper(Helper helper) {
this.helper = helper;
}
@@ -169,71 +174,62 @@
* original type will be set as required based on the XmlAdapter's
* marshal method return type and input parameters.
*
- * @param adapterCls
- */
- public void setAdapterClass(JavaClass adapterCls) {
- adapterClass = adapterCls;
-
- // Walk up the inheritance hierarchy until we find a generic superclass specifying
- // the value and bound types
- Type genericSuperClass = adapterCls.getGenericSuperclass();
- while (genericSuperClass != null && genericSuperClass instanceof Class) {
- genericSuperClass = ((Class) genericSuperClass).getGenericSuperclass();
- }
-
- if (genericSuperClass != null) {
- ParameterizedType parameterizedSuperClass = (ParameterizedType) genericSuperClass;
- Type[] typeArguments = parameterizedSuperClass.getActualTypeArguments();
- Type valueType = typeArguments[0];
- Type boundType = typeArguments.length > 1 ? typeArguments[1] : typeArguments[0];
- setTypeFromAdapterClass(getJavaClassFromType(valueType), getJavaClassFromType(boundType));
- return;
- }
-
- // If no generic superclass was found, use the old method of looking at
- // marshal method return type. This mechanism is used for Dynamic JAXB.
- JavaClass newType = helper.getJavaClass(Object.class);
- ArrayList<JavaMethod> marshalMethods = new ArrayList<JavaMethod>();
-
- // Look for marshal method
- for (Iterator<JavaMethod> methodIt = adapterClass.getMethods().iterator(); methodIt.hasNext(); ) {
- JavaMethod method = methodIt.next();
- if (method.getName().equals(MARSHAL_METHOD_NAME)) {
- JavaClass returnType = method.getReturnType();
- // Try and find a marshal method where Object is not the return type,
- // to avoid processing an inherited default marshal method
- if (!returnType.getQualifiedName().equals(newType.getQualifiedName())) {
- if (!returnType.isInterface()) {
- newType = (JavaClass) method.getReturnType();
- setTypeFromAdapterClass(newType, method.getParameterTypes()[0]);
- return;
- }
- }
- // Found a marshal method with an Object return type; add
- // it to the list in case we need to process it later
- marshalMethods.add(method);
- }
- }
- // If there are no marshal methods to process just set type
- // and original type, then return
- if (marshalMethods.size() == 0) {
- setTypeFromAdapterClass(newType, null);
- return;
- }
- // At this point we didn't find a marshal method with a non-Object return type
- for (JavaMethod method : marshalMethods) {
- JavaClass paramType = method.getParameterTypes()[0];
- // look for non-Object parameter type
- if (!paramType.getQualifiedName().equals(newType.getQualifiedName())) {
- setTypeFromAdapterClass(newType, paramType);
- return;
- }
- }
- // At this point we will just grab the first marshal method
- setTypeFromAdapterClass(newType, marshalMethods.get(0).getParameterTypes()[0]);
- }
-
- private JavaClass getJavaClassFromType(Type t) {
+ * @param adapterCls
+ */
+ public void setAdapterClass(JavaClass adapterCls) {
+ if (adapterCls.instanceOf() == JavaClassInstanceOf.JAVA_CLASS_IMPL) {
+ Type[] parameterizedTypeArguments = GenericsClassHelper.getParameterizedTypeArguments(((JavaClassImpl)adapterCls).getJavaClass(), XmlAdapter.class);
+ if (null != parameterizedTypeArguments && null != parameterizedTypeArguments[0]) {
+ JavaClass valueTypeClass = getJavaClassFromType(parameterizedTypeArguments[0]);
+ JavaClass boundType = getJavaClassFromType(parameterizedTypeArguments[1]);
+
+ if (valueTypeClass.isInterface()) {
+ valueTypeClass = OBJECT_CLASS; // during unmarshalling we'll need to instantiate this, so -> no interfaces
+ }
+
+ setTypeFromAdapterClass(valueTypeClass, boundType);
+ return;
+ }
+ }
+
+ // If no generic superclass was found, use the old method of looking at
+ // marshal method return type. This mechanism is used for Dynamic JAXB.
+ ArrayList<JavaMethod> marshalMethods = new ArrayList<JavaMethod>();
+
+ // Look for marshal method
+ for (JavaMethod method : (Collection<JavaMethod>) adapterCls.getMethods()) {
+ if (!method.isBridge() && method.getName().equals(MARSHAL_METHOD_NAME)) {
+ final JavaClass[] parameterTypes = method.getParameterTypes();
+ if (parameterTypes.length != 1)
+ continue;
+ JavaClass returnType = method.getReturnType();
+
+ // Try and find a marshal method where Object is not the return type,
+ // to avoid processing an inherited default marshal method
+ if (!returnType.getQualifiedName().equals(OBJECT_CLASS.getQualifiedName()) && !returnType.isInterface()) { // if it's interface, we'll use OBJECT instead later
+ setTypeFromAdapterClass(returnType, parameterTypes[0]);
+ return;
+ }
+ }
+ // Found a marshal method with an Object return type; add
+ // it to the list in case we need to process it later
+ marshalMethods.add(method);
+ }
+ // At this point we didn't find a marshal method with a non-Object return type
+ for (JavaMethod method : marshalMethods) {
+ JavaClass paramType = method.getParameterTypes()[0];
+ // look for non-Object parameter type
+ if (!paramType.getQualifiedName().equals(OBJECT_CLASS.getQualifiedName())) {
+ setTypeFromAdapterClass(OBJECT_CLASS, paramType);
+ return;
+ }
+ }
+ if (!marshalMethods.isEmpty())
+ setTypeFromAdapterClass(OBJECT_CLASS, null);
+ // else impossible? - looks like provided adapted doesn't contain marshal(...) method
+ }
+
+ private JavaClass getJavaClassFromType(Type t) {
if (t instanceof Class) {
return helper.getJavaClass((Class) t);
} else if (t instanceof ParameterizedType) {
@@ -249,13 +245,13 @@
GenericArrayType genericArrayValueType = (GenericArrayType) t;
Type rawType = genericArrayValueType.getGenericComponentType();
if (rawType instanceof Class) {
- return helper.getJavaClass(Array.newInstance((Class) rawType, 1).getClass());
- }
- }
- return null;
- }
-
- /**
+ return helper.getJavaClass(Array.newInstance((Class) rawType, 1).getClass());
+ }
+ }
+ return OBJECT_CLASS;
+ }
+
+ /**
* This convenience method will set the generic type, type and original type
* for this Porperty as required based on a given 'new' type and parameter
* type. This method will typically be called when setting the type during
@@ -627,13 +623,12 @@
}
/**
- * Set indicator for XmlAnyElement.
- *
- * @param isAnyElement
- * @return
- */
- public void setIsAny(boolean isAnyElement) {
- this.isAnyElement = isAnyElement;
+ * Set indicator for XmlAnyElement.
+ *
+ * @param isAnyElement
+ */
+ public void setIsAny(boolean isAnyElement) {
+ this.isAnyElement = isAnyElement;
}
/**
@@ -726,21 +721,21 @@
* the type has been changed via @XmlElement annotation and the
* original type is desired.
*
- * @return
- */
- public JavaClass getOriginalType() {
- return originalType;
- }
-
+ * @return
+ */
+ public JavaClass getOriginalType() {
+ if (originalType == null) // in case of adapter which returns the same type - original type is the same as type
+ return type;
+ return originalType;
+ }
+
/**
- * Set the original type of the property. This is typically used when
- * the type will been changed via @XmlElement annotation and the
- * original type may be needed.
- *
- * @return
- */
- public void setOriginalType(JavaClass type) {
- originalType = type;
+ * Set the original type of the property. This is typically used when
+ * the type will been changed via @XmlElement annotation and the
+ * original type may be needed.
+ */
+ public void setOriginalType(JavaClass type) {
+ originalType = type;
}
/**
@@ -771,13 +766,12 @@
* @param xmlJavaTypeAdapter
* @see XmlJavaTypeAdapter
*/
- public void setXmlJavaTypeAdapter(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
- this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
- if (xmlJavaTypeAdapter == null) {
- adapterClass = null;
- setType(originalType);
- } else {
- // set the adapter class
+ public void setXmlJavaTypeAdapter(XmlJavaTypeAdapter xmlJavaTypeAdapter) {
+ this.xmlJavaTypeAdapter = xmlJavaTypeAdapter;
+ if (xmlJavaTypeAdapter == null) {
+ setType(originalType);
+ } else {
+ // set the adapter class
setAdapterClass(helper.getJavaClass(xmlJavaTypeAdapter.getValue()));
}
}
@@ -824,16 +818,16 @@
*
* @return
*/
- public boolean isXmlValue() {
- return this.isXmlValue;
- }
-
- /**
- * Set the isXmlList property.
- *
- * @param isXmlList
- */
- public void setIsXmlList(boolean isXmlList) {
+ public boolean isXmlValue() {
+ return this.isXmlValue;
+ }
+
+ /**
+ * Set the isXmlList property.
+ *
+ * @param isXmlList
+ */
+ public void setIsXmlList(boolean isXmlList) {
this.isXmlList = isXmlList;
if(isXmlList){
this.setNillable(false);
@@ -890,13 +884,13 @@
return isXmlId;
}
- /**
- * Sets the indicator that identifies this property as an ID field.
- *
- * @param isXmlIdRef
- */
- public void setIsXmlId(boolean isXmlId) {
- this.isXmlId = isXmlId;
+ /**
+ * Sets the indicator that identifies this property as an ID field.
+ *
+ * @param isXmlId
+ */
+ public void setIsXmlId(boolean isXmlId) {
+ this.isXmlId = isXmlId;
}
/**
@@ -1252,14 +1246,14 @@
/**
* Indicates if nillable='true' should be set on a given schema component.
* This will typically be called by SchemaGenerator.
- * The value returned will be true if one of the following is true:
- *
- * - isNillable
- * - isSetNullPolicy && xsi-nil-represents-null == 'true'
- * - isSetNullPolicy && null-representation-for-xml == 'XSI_NIL'
- *
- * @return
- */
+ * The value returned will be true if one of the following is true:
+ *
+ * - isNillable
+ * - isSetNullPolicy {@literal &&} xsi-nil-represents-null == 'true'
+ * - isSetNullPolicy {@literal &&} null-representation-for-xml == 'XSI_NIL'
+ *
+ * @return
+ */
public boolean shouldSetNillable() {
if (isNillable()) {
return true;
@@ -1484,7 +1478,7 @@
public void setTyped(boolean isTyped) {
this.isTyped = isTyped;
- }
-
-
-}
\ No newline at end of file
+ }
+
+
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaClass.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaClass.java
index 6233978..a9ff4aa 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaClass.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaClass.java
@@ -1,11 +1,11 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
@@ -22,13 +22,13 @@
* <ul>
* <li>Provide information about a given implementation's underlying class, such
* as name, package, method/field names and parameters, annotations, etc.</li>
- * </ul>
- *
- * @since Oracle TopLink 11.1.1.0.0
- * @see org.eclipse.persistence.jaxb20.javamodel.JavaHasAnnotations
- * @see java.lang.Class
- */
-public interface JavaClass extends JavaHasAnnotations {
+ * </ul>
+ *
+ * @since Oracle TopLink 11.1.1.0.0
+ * @see org.eclipse.persistence.jaxb.javamodel.JavaHasAnnotations
+ * @see java.lang.Class
+ */
+public interface JavaClass extends JavaHasAnnotations {
public Collection getActualTypeArguments();
public JavaClass getComponentType();
public String getQualifiedName();
@@ -63,7 +63,8 @@
public boolean isPrimitive();
public boolean isPrivate();
public boolean isProtected();
- public boolean isPublic();
- public boolean isStatic();
- public boolean isSynthetic();
-}
+ public boolean isPublic();
+ public boolean isStatic();
+ public boolean isSynthetic();
+ public JavaClassInstanceOf instanceOf();
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaClassInstanceOf.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaClassInstanceOf.java
new file mode 100644
index 0000000..87ffc15
--- /dev/null
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaClassInstanceOf.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ ******************************************************************************/
+package org.eclipse.persistence.jaxb.javamodel;
+
+/**
+ * INTERNAL:
+ * <p><b>Purpose:</b>To provide faster alternative to instanceof.
+ *
+ * @author Martin Vojtek (martin.vojtek@oracle.com)
+ */
+public enum JavaClassInstanceOf {
+ JAVA_CLASS_IMPL, OXM_JAVA_CLASS_IMPL, OXM_JAXB_ELEMENT_IMPL, OXM_OBJECT_FACTORY_IMPL, XJC_JAVA_CLASS_IMPL
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaMethod.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaMethod.java
index a0fff24..65be947 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaMethod.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/JavaMethod.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998 - 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -35,7 +35,8 @@
public boolean isFinal();
public boolean isPrivate();
public boolean isProtected();
- public boolean isPublic();
- public boolean isStatic();
- public boolean isSynthetic();
-}
+ public boolean isPublic();
+ public boolean isStatic();
+ public boolean isSynthetic();
+ boolean isBridge();
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJAXBElementImpl.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJAXBElementImpl.java
index b134ac8..a7830c2 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJAXBElementImpl.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJAXBElementImpl.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -13,34 +13,28 @@
package org.eclipse.persistence.jaxb.javamodel.oxm;
import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.persistence.jaxb.javamodel.JavaAnnotation;
-import org.eclipse.persistence.jaxb.javamodel.JavaClass;
-import org.eclipse.persistence.jaxb.javamodel.JavaConstructor;
-import org.eclipse.persistence.jaxb.javamodel.JavaField;
-import org.eclipse.persistence.jaxb.javamodel.JavaMethod;
-import org.eclipse.persistence.jaxb.javamodel.JavaModel;
-import org.eclipse.persistence.jaxb.javamodel.JavaPackage;
-
-/**
- * INTERNAL:
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.persistence.jaxb.javamodel.*;
+
+/**
+ * INTERNAL:
* <p>
* <b>Purpose:</b> Specialized <code>JavaClass</code> used to represent a
* <code>JAXBElement</code>. Used when bootstrapping a <code>DynamicJAXBContext</code>
* from XML Bindings.
* </p>
- *
- * <p>
- * <b>Responsibilities:</b>
- * <ul>
- * <li>Provide Class information to the <code>JavaModel</code>.</li>
- * </ul>
- * </p>
- *
- * @since EclipseLink 2.2
- *
+ *
+ * <p>
+ * <b>Responsibilities:</b>
+ * </p>
+ * <ul>
+ * <li>Provide Class information to the <code>JavaModel</code>.</li>
+ * </ul>
+ *
+ * @since EclipseLink 2.2
+ *
* @see org.eclipse.persistence.jaxb.javamodel.JavaClass
* @see org.eclipse.persistence.jaxb.javamodel.oxm.OXMJAXBElementImpl
*/
@@ -202,12 +196,17 @@
}
public boolean isSynthetic() {
- return false;
- }
-
- public JavaAnnotation getAnnotation(JavaClass arg0) {
- return null;
- }
+ return false;
+ }
+
+ @Override
+ public JavaClassInstanceOf instanceOf() {
+ return JavaClassInstanceOf.OXM_JAXB_ELEMENT_IMPL;
+ }
+
+ public JavaAnnotation getAnnotation(JavaClass arg0) {
+ return null;
+ }
public Collection<JavaAnnotation> getAnnotations() {
return null;
@@ -220,7 +219,7 @@
public Collection<JavaAnnotation> getDeclaredAnnotations() {
return null;
}
-
- private static final String JAVAX_XML_BIND_JAXBELEMENT = "javax.xml.bind.JAXBElement";
-
-}
\ No newline at end of file
+
+ private static final String JAVAX_XML_BIND_JAXBELEMENT = "javax.xml.bind.JAXBElement";
+
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJavaClassImpl.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJavaClassImpl.java
index 4ea3862..0326b76 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJavaClassImpl.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJavaClassImpl.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -22,19 +22,13 @@
import java.util.List;
import javax.xml.bind.JAXBElement;
-
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.jaxb.compiler.XMLProcessor;
-import org.eclipse.persistence.jaxb.javamodel.JavaAnnotation;
-import org.eclipse.persistence.jaxb.javamodel.JavaClass;
-import org.eclipse.persistence.jaxb.javamodel.JavaConstructor;
-import org.eclipse.persistence.jaxb.javamodel.JavaField;
-import org.eclipse.persistence.jaxb.javamodel.JavaMethod;
-import org.eclipse.persistence.jaxb.javamodel.JavaModel;
-import org.eclipse.persistence.jaxb.javamodel.JavaPackage;
-import org.eclipse.persistence.jaxb.xmlmodel.JavaAttribute;
-import org.eclipse.persistence.jaxb.xmlmodel.JavaType;
-import org.eclipse.persistence.jaxb.xmlmodel.JavaType.JavaAttributes;
+
+import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
+import org.eclipse.persistence.jaxb.compiler.XMLProcessor;
+import org.eclipse.persistence.jaxb.javamodel.*;
+import org.eclipse.persistence.jaxb.xmlmodel.JavaAttribute;
+import org.eclipse.persistence.jaxb.xmlmodel.JavaType;
+import org.eclipse.persistence.jaxb.xmlmodel.JavaType.JavaAttributes;
import org.eclipse.persistence.jaxb.xmlmodel.XmlAnyAttribute;
import org.eclipse.persistence.jaxb.xmlmodel.XmlAnyElement;
import org.eclipse.persistence.jaxb.xmlmodel.XmlAttribute;
@@ -51,16 +45,16 @@
* <b>Purpose:</b> <code>JavaClass</code> implementation wrapping MOXy's <code>xmlmodel.JavaType</code>.
* Used when bootstrapping a <code>DynamicJAXBContext</code> from XML Bindings.
* </p>
- *
- * <p>
- * <b>Responsibilities:</b>
- * <ul>
- * <li>Provide Class information from the underlying <code>JavaType</code>.</li>
- * </ul>
- * </p>
- *
- * @since EclipseLink 2.2
- *
+ *
+ * <p>
+ * <b>Responsibilities:</b>
+ * </p>
+ * <ul>
+ * <li>Provide Class information from the underlying <code>JavaType</code>.</li>
+ * </ul>
+ *
+ * @since EclipseLink 2.2
+ *
* @see org.eclipse.persistence.jaxb.javamodel.JavaClass
* @see org.eclipse.persistence.jaxb.xmlmodel.JavaType
*/
@@ -482,13 +476,13 @@
}
/**
- * Indicates if this <code>JavaClass</code> is either the same as, or is a superclass of,
- * the <code>javaClass</code> argument.
- *
- * @param javaClass the <code>Class</code> to test.
- *
- * @return <code>true</code> if this <code>JavaClass</code> is assignable from
- * <code>javaClass</code>, otherwise <code>false</code>.
+ * Indicates if this <code>JavaClass</code> is either the same as, or is a superclass of,
+ * the <code>javaClass</code> argument.
+ *
+ * @param arg0 the <code>Class</code> to test.
+ *
+ * @return <code>true</code> if this <code>JavaClass</code> is assignable from
+ * <code>javaClass</code>, otherwise <code>false</code>.
*
* @see java.lang.Class#isAssignableFrom(Class)
*/
@@ -545,13 +539,13 @@
return false;
}
- /**
- * Indicates if this <code>JavaClass</code> is an inner <code>Class</code>.
- *
- * @return <code>true</code> if this <code>JavaClass</code> is an inner </code>Class</code>, otherwise <code>false</code>.
- */
- public boolean isMemberClass() {
- return false;
+ /**
+ * Indicates if this <code>JavaClass</code> is an inner <code>Class</code>.
+ *
+ * @return <code>true</code> if this <code>JavaClass</code> is an inner <code>Class</code>, otherwise <code>false</code>.
+ */
+ public boolean isMemberClass() {
+ return false;
}
/**
@@ -603,12 +597,17 @@
* Not supported.
*/
public boolean isSynthetic() {
- throw new UnsupportedOperationException("isSynthetic");
- }
-
- /**
- * If this <code>JavaClass</code> is annotated with an <code>Annotation</code> matching <code>aClass</code>,
- * return its <code>JavaAnnotation</code> representation.
+ throw new UnsupportedOperationException("isSynthetic");
+ }
+
+ @Override
+ public JavaClassInstanceOf instanceOf() {
+ return JavaClassInstanceOf.OXM_JAVA_CLASS_IMPL;
+ }
+
+ /**
+ * If this <code>JavaClass</code> is annotated with an <code>Annotation</code> matching <code>aClass</code>,
+ * return its <code>JavaAnnotation</code> representation.
*
* @param aClass a <code>JavaClass</code> representing the <code>Annotation</code> to look for.
*
@@ -628,13 +627,13 @@
}
/**
- * If this <code>JavaClass</code> declares an <code>Annotation</code> matching <code>aClass</code>,
- * return its <code>JavaAnnotation</code> representation.
- *
- * @param aClass a <code>JavaClass</code> representing the <code>Annotation</code> to look for.
- *
- * @return always returns <code>null</code>, as <code>JavaTypes</code> do not have <code>Annotations</code>.
- */
+ * If this <code>JavaClass</code> declares an <code>Annotation</code> matching <code>aClass</code>,
+ * return its <code>JavaAnnotation</code> representation.
+ *
+ * @param arg0 a <code>JavaClass</code> representing the <code>Annotation</code> to look for.
+ *
+ * @return always returns <code>null</code>, as <code>JavaTypes</code> do not have <code>Annotations</code>.
+ */
public JavaAnnotation getDeclaredAnnotation(JavaClass arg0) {
return null;
}
@@ -646,24 +645,24 @@
*/
public Collection<JavaAnnotation> getDeclaredAnnotations() {
return new ArrayList<JavaAnnotation>();
- }
-
- /**
- * Get this <code>JavaClass'</code> <code>JavaModel</code>.
- *
- * @return The <code>JavaModel</code> associated with this <code>JavaClass<code>.
- */
- public void setJavaModel(JavaModel model) {
- this.javaModel = model;
- }
-
- /**
- * Set this <code>JavaClass'</code> <code>JavaModel</code>.
- *
- * @param javaModel The <code>JavaModel</code> to set.
- */
- public JavaModel getJavaModel() {
- return this.javaModel;
+ }
+
+ /**
+ * Set this <code>JavaClass'</code> <code>JavaModel</code>.
+ *
+ * @param model The <code>JavaModel</code> to set.
+ */
+ public void setJavaModel(JavaModel model) {
+ this.javaModel = model;
+ }
+
+ /**
+ * Get this <code>JavaClass'</code> <code>JavaModel</code>.
+ *
+ * @return The <code>JavaModel</code> associated with this <code>JavaClass</code>.
+ */
+ public JavaModel getJavaModel() {
+ return this.javaModel;
}
// ========================================================================
@@ -671,7 +670,7 @@
private static String EMPTY_STRING = "";
private static String JAVA = "java";
private static String DOT = ".";
- private static String JAVA_LANG_OBJECT = "java.lang.Object";
- private static String JAVA_UTIL_MAP = "java.util.Map";
-
-}
\ No newline at end of file
+ private static String JAVA_LANG_OBJECT = "java.lang.Object";
+ private static String JAVA_UTIL_MAP = "java.util.Map";
+
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJavaMethodImpl.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJavaMethodImpl.java
index d7d83de..4052f50 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJavaMethodImpl.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMJavaMethodImpl.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011 - 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -116,7 +116,11 @@
}
public Collection<JavaAnnotation> getDeclaredAnnotations() {
- return null;
- }
-
+ return null;
+ }
+
+ @Override
+ public boolean isBridge() {
+ return false;
+ }
}
\ No newline at end of file
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMObjectFactoryImpl.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMObjectFactoryImpl.java
index 765e56e..4bb6ff1 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMObjectFactoryImpl.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/oxm/OXMObjectFactoryImpl.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -18,20 +18,13 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.persistence.internal.oxm.XMLConversionManager;
-import org.eclipse.persistence.jaxb.javamodel.AnnotationProxy;
-import org.eclipse.persistence.jaxb.javamodel.JavaAnnotation;
-import org.eclipse.persistence.jaxb.javamodel.JavaClass;
-import org.eclipse.persistence.jaxb.javamodel.JavaConstructor;
-import org.eclipse.persistence.jaxb.javamodel.JavaField;
-import org.eclipse.persistence.jaxb.javamodel.JavaMethod;
-import org.eclipse.persistence.jaxb.javamodel.JavaModel;
-import org.eclipse.persistence.jaxb.javamodel.JavaPackage;
-import org.eclipse.persistence.jaxb.javamodel.reflection.JavaAnnotationImpl;
-import org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry;
-import org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl;
+import java.util.List;
+
+import org.eclipse.persistence.internal.oxm.XMLConversionManager;
+import org.eclipse.persistence.jaxb.javamodel.*;
+import org.eclipse.persistence.jaxb.javamodel.reflection.JavaAnnotationImpl;
+import org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry;
+import org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl;
/**
* INTERNAL:
@@ -41,16 +34,16 @@
* <code>ObjectFactory</code>. Used when bootstrapping a <code>DynamicJAXBContext</code>
* from XML Bindings.
* </p>
- *
- * <p>
- * <b>Responsibilities:</b>
- * <ul>
- * <li>Provide Class information to the <code>JavaModel</code>.</li>
- * </ul>
- * </p>
- *
- * @since EclipseLink 2.2
- *
+ *
+ * <p>
+ * <b>Responsibilities:</b>
+ * </p>
+ * <ul>
+ * <li>Provide Class information to the <code>JavaModel</code>.</li>
+ * </ul>
+ *
+ * @since EclipseLink 2.2
+ *
* @see org.eclipse.persistence.jaxb.javamodel.JavaClass
* @see org.eclipse.persistence.jaxb.javamodel.oxm.OXMJAXBElementImpl
*/
@@ -242,12 +235,17 @@
}
public boolean isSynthetic() {
- return false;
- }
-
- public JavaAnnotation getAnnotation(JavaClass arg0) {
- return null;
- }
+ return false;
+ }
+
+ @Override
+ public JavaClassInstanceOf instanceOf() {
+ return JavaClassInstanceOf.OXM_OBJECT_FACTORY_IMPL;
+ }
+
+ public JavaAnnotation getAnnotation(JavaClass arg0) {
+ return null;
+ }
public Collection<JavaAnnotation> getAnnotations() {
return null;
@@ -274,7 +272,7 @@
private static String JAVA_LANG_OBJECT = "java.lang.Object";
private static String NAME = "name";
private static String NAMESPACE = "namespace";
- private static String SUBSTITUTION_HEAD_NAME = "substitutionHeadName";
- private static String SUBSTITUTION_HEAD_NAMESPACE = "substitutionHeadNamespace";
-
-}
\ No newline at end of file
+ private static String SUBSTITUTION_HEAD_NAME = "substitutionHeadName";
+ private static String SUBSTITUTION_HEAD_NAMESPACE = "substitutionHeadNamespace";
+
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java
index c11b406..7a0b348 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaClassImpl.java
@@ -1,28 +1,23 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
******************************************************************************/
package org.eclipse.persistence.jaxb.javamodel.reflection;
-
-import org.eclipse.persistence.exceptions.JAXBException;
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.jaxb.javamodel.JavaAnnotation;
-import org.eclipse.persistence.jaxb.javamodel.JavaClass;
-import org.eclipse.persistence.jaxb.javamodel.JavaConstructor;
-import org.eclipse.persistence.jaxb.javamodel.JavaField;
-import org.eclipse.persistence.jaxb.javamodel.JavaMethod;
-import org.eclipse.persistence.jaxb.javamodel.JavaPackage;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
+
+import org.eclipse.persistence.exceptions.JAXBException;
+import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
+import org.eclipse.persistence.jaxb.javamodel.*;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
@@ -31,12 +26,13 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * INTERNAL:
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * INTERNAL:
* <p><b>Purpose:</b>A wrapper class for a JDK Class. This implementation
* of the EclipseLink JAXB 2.X Java model simply makes reflective calls on the
* underlying JDK object.
@@ -76,15 +72,14 @@
public void setJavaModelImpl(JavaModelImpl javaModel) {
this.javaModelImpl = javaModel;
- }
- public Collection getActualTypeArguments() {
- ArrayList<JavaClass> argCollection = new ArrayList<JavaClass>();
- if (jType instanceof ParameterizedType) {
- ParameterizedType pType = (ParameterizedType) jType;
- Type[] params = pType.getActualTypeArguments();
- for (Type type : params) {
- if (type instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) type;
+ }
+ public Collection getActualTypeArguments() {
+ ArrayList<JavaClass> argCollection = new ArrayList<JavaClass>();
+ if (jType != null) {
+ Type[] params = jType.getActualTypeArguments();
+ for (Type type : params) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
argCollection.add(new JavaClassImpl(pt, (Class) pt.getRawType(), javaModelImpl));
} else if(type instanceof WildcardType){
Type[] upperTypes = ((WildcardType)type).getUpperBounds();
@@ -160,14 +155,14 @@
}
}
- public Collection getDeclaredFields() {
- ArrayList<JavaField> fieldCollection = new ArrayList<JavaField>();
- Field[] fields = PrivilegedAccessHelper.getDeclaredFields(jClass);
-
- for (Field field : fields) {
- field.setAccessible(true);
- fieldCollection.add(getJavaField(field));
- }
+ public Collection getDeclaredFields() {
+ ArrayList<JavaField> fieldCollection = new ArrayList<JavaField>();
+ Field[] fields = PrivilegedAccessHelper.getDeclaredFields(jClass);
+
+ for (Field field : fields) {
+ field.setAccessible(true);
+ fieldCollection.add(getJavaField(field));
+ }
return fieldCollection;
}
@@ -512,12 +507,17 @@
}
public boolean isSynthetic() {
- return jClass.isSynthetic();
- }
-
- public JavaClass getComponentType() {
- if(!isArray()) {
- return null;
+ return jClass.isSynthetic();
+ }
+
+ @Override
+ public JavaClassInstanceOf instanceOf() {
+ return JavaClassInstanceOf.JAVA_CLASS_IMPL;
+ }
+
+ public JavaClass getComponentType() {
+ if(!isArray()) {
+ return null;
}
return javaModelImpl.getClass(this.jClass.getComponentType());
}
@@ -563,7 +563,7 @@
annotationCollection.add(new JavaAnnotationImpl(annotation));
}
}
- return annotationCollection;
- }
-
-}
\ No newline at end of file
+ return annotationCollection;
+ }
+
+}
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaMethodImpl.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaMethodImpl.java
index 4ed0b43..d113357 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaMethodImpl.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/javamodel/reflection/JavaMethodImpl.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998 - 2014 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -171,16 +171,20 @@
}
public boolean isSynthetic() {
- return jMethod.isSynthetic();
- }
-
-// ---------------- unimplemented methods ----------------//
- public JavaAnnotation getDeclaredAnnotation(JavaClass arg0) {
- return null;
+ return jMethod.isSynthetic();
+ }
+
+ @Override
+ public boolean isBridge() {
+ return jMethod.isBridge();
+ }
+// ---------------- unimplemented methods ----------------//
+ public JavaAnnotation getDeclaredAnnotation(JavaClass arg0) {
+ return null;
}
public Collection getDeclaredAnnotations() {
- return null;
- }
-
-}
\ No newline at end of file
+ return null;
+ }
+
+}