Author: jason.greene(a)jboss.com
Date: 2007-01-22 23:37:44 -0500 (Mon, 22 Jan 2007)
New Revision: 2029
Modified:
trunk/build/version.properties
trunk/jbossws-core/src/main/java/org/jboss/ws/core/utils/HolderUtils.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/utils/JavaUtils.java
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
trunk/jbossws-core/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java
Log:
Fix JBWS-1458
Modified: trunk/build/version.properties
===================================================================
--- trunk/build/version.properties 2007-01-22 21:11:38 UTC (rev 2028)
+++ trunk/build/version.properties 2007-01-23 04:37:44 UTC (rev 2029)
@@ -34,7 +34,7 @@
jboss-common-logging-log4j=2.0.2.GA
jboss-common-logging-spi=2.0.2.GA
jboss-ejb3=1.0.0.CR9-jboss4.0.5
-jboss-jbossretro=1.0.4.GA
+jboss-jbossretro=snapshot
jboss-security=4.0.5.GA
jboss-vfs=2.0.0.snapshot
jbossas-core-libs=4.0.5.GA
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/utils/HolderUtils.java
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/utils/HolderUtils.java 2007-01-22
21:11:38 UTC (rev 2028)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/utils/HolderUtils.java 2007-01-23
04:37:44 UTC (rev 2029)
@@ -206,6 +206,39 @@
}
/**
+ * Gets the value type of a JAX-RPC holder. Note this method should not be used
+ * for JAX-WS, as a JAX-WS holder requires generic info. Instead, use the Type
+ * version.
+ *
+ * @param holderType the generic type for JAX-WS, a standard class for JAX-RPC
+ * @return the value type
+ */
+ public static Class getValueType(Class holderClass)
+ {
+ boolean jaxrpcHolder =
javax.xml.rpc.holders.Holder.class.isAssignableFrom(holderClass);
+ boolean jaxwsHolder = javax.xml.ws.Holder.class.isAssignableFrom(holderClass);
+ if (!jaxrpcHolder && !jaxwsHolder)
+ throw new IllegalArgumentException("Is not a holder: " +
holderClass.getName());
+
+ // No generic info
+ if (jaxwsHolder)
+ return Object.class;
+
+ // Holder is supposed to have a public value field.
+ Field field;
+ try
+ {
+ field = holderClass.getField("value");
+ }
+ catch (NoSuchFieldException e)
+ {
+ throw new IllegalArgumentException("Cannot find public value field: "
+ holderClass);
+ }
+
+ return field.getType();
+ }
+
+ /**
* Gets the value object of a JAX-WS or JAX-RPC holder instance.
*
* @param holder the holder object instance
@@ -282,10 +315,14 @@
* @param holder JAX-WS holder type
* @return generic value type
*/
- // [JBBUILD-331] Add support for java.lang.reflect.Type
public static Type getGenericValueType(Type holder)
{
- return (holder instanceof ParameterizedType) ?
((ParameterizedType)holder).getActualTypeArguments()[0] : Object.class;
+ // For some reason the JDK 4 bytecode verifier trips up on this function if you use
the ternary operator
+ // The only difference between it and the working form here is the use of a goto
instruction. JDK bug perhaps?
+ if (holder instanceof ParameterizedType)
+ return ((ParameterizedType)holder).getActualTypeArguments()[0];
+
+ return Object.class;
}
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/utils/JavaUtils.java
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/utils/JavaUtils.java 2007-01-22
21:11:38 UTC (rev 2028)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/utils/JavaUtils.java 2007-01-23
04:37:44 UTC (rev 2029)
@@ -586,6 +586,17 @@
return ret;
}
+
+ /**
+ * This method tests for retro translation by searching for a known problem where
Class
+ * does not implement Type. If this is true, then code must never cast a Class to a
Type.
+ *
+ * @return true if we are in retro
+ */
+ public static boolean isRetro14()
+ {
+ return !(String.class instanceof java.lang.reflect.Type);
+ }
/**
* Tests if this class loader is a JBoss RepositoryClassLoader
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-01-22
21:11:38 UTC (rev 2028)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2007-01-23
04:37:44 UTC (rev 2029)
@@ -109,13 +109,21 @@
private static boolean matchParameter(Method method, int index, Class expectedType,
Set<Integer> matches, boolean exact, boolean holder)
{
Class returnType = method.getReturnType();
- Type[] parameters = method.getGenericParameterTypes();
+ Type[] genericParameters = method.getGenericParameterTypes();
+ Class[] classParameters = method.getParameterTypes();
if (index == -1 && matchTypes(returnType, expectedType, exact, false))
return true;
- boolean indexInBounds = -1 < index && index < parameters.length;
- if (indexInBounds && matchTypes(parameters[index], expectedType, exact,
holder))
+ boolean indexInBounds = -1 < index && index <
classParameters.length;
+ boolean matchTypes;
+
+ if (JavaUtils.isRetro14())
+ matchTypes = matchTypes(classParameters[index], expectedType, exact, holder);
+ else
+ matchTypes = matchTypes(genericParameters[index], expectedType, exact, holder);
+
+ if (indexInBounds && matchTypes)
{
matches.add(index);
return true;
@@ -123,7 +131,7 @@
return false;
}
-
+
private static boolean matchTypes(Type actualType, Class expectedType, boolean exact,
boolean holder)
{
if (holder && HolderUtils.isHolderType(actualType) == false)
@@ -132,6 +140,24 @@
Type valueType = (holder ? HolderUtils.getValueType(actualType) : actualType);
Class valueClass = JavaUtils.erasure(valueType);
+ return matchTypesInternal(valueClass, expectedType, exact);
+ }
+
+ // This duplication is needed because Class does not implement Type in 1.4,
+ // which makes retrotranslation not possible. This takes advantage of overloading to
+ // prevent the problem.
+ private static boolean matchTypes(Class actualType, Class expectedType, boolean exact,
boolean holder)
+ {
+ if (holder && HolderUtils.isHolderType(actualType) == false)
+ return false;
+
+ Class valueClass = (holder ? HolderUtils.getValueType(actualType) : actualType);
+
+ return matchTypesInternal(valueClass, expectedType, exact);
+ }
+
+ private static boolean matchTypesInternal(Class valueClass, Class expectedType,
boolean exact)
+ {
// FIXME - Why do we need this hack? It shouldn't be needed. The method
// signature should _ALWAYS_ match, else we will get ambiguous or
// incorrect results
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java 2007-01-22
21:11:38 UTC (rev 2028)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/tools/jaxws/JAXBWSDLGenerator.java 2007-01-23
04:37:44 UTC (rev 2029)
@@ -42,7 +42,7 @@
/**
* JAXBWSDLGenerator provides a JAXB based WSDLGenerator.
*
- * @author <a href="jason.greene(a)jboss.com">Jason T. Greene</a>
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T.
Greene</a>
*/
public class JAXBWSDLGenerator extends WSDLGenerator
{