You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/04/30 00:57:02 UTC

svn commit: r1098017 - in /tapestry/tapestry5/trunk: plastic/src/main/java/org/apache/tapestry5/internal/plastic/ plastic/src/main/java/org/apache/tapestry5/plastic/ tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ tapestry-ioc/src/...

Author: hlship
Date: Fri Apr 29 22:57:02 2011
New Revision: 1098017

URL: http://svn.apache.org/viewvc?rev=1098017&view=rev
Log:
TAP5-853: Change MethodDescription to hold a genericSignature property that is used when creating new MethodNodes

Modified:
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticInternalUtils.java
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BridgeClassTransformation.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java?rev=1098017&r1=1098016&r2=1098017&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java (original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java Fri Apr 29 22:57:02 2011
@@ -1809,7 +1809,7 @@ public class PlasticClassImpl extends Lo
 
         String name = makeUnique(methodNames, suggestedName);
 
-        MethodDescription description = new MethodDescription(Modifier.PRIVATE, typeName, name, argumentTypes,
+        MethodDescription description = new MethodDescription(Modifier.PRIVATE, typeName, name, argumentTypes, null,
                 exceptionTypes);
 
         return introduceMethod(description);
@@ -1942,7 +1942,8 @@ public class PlasticClassImpl extends Lo
             exceptions[i] = PlasticInternalUtils.toInternalName(description.checkedExceptionTypes[i]);
         }
 
-        MethodNode methodNode = new MethodNode(description.modifiers, description.methodName, desc, null, exceptions);
+        MethodNode methodNode = new MethodNode(description.modifiers, description.methodName, desc,
+                description.genericSignature, exceptions);
         boolean isOverride = methodBundle.isImplemented(methodNode.name, desc);
 
         if (isOverride)

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticInternalUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticInternalUtils.java?rev=1098017&r1=1098016&r2=1098017&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticInternalUtils.java (original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticInternalUtils.java Fri Apr 29 22:57:02 2011
@@ -112,7 +112,7 @@ public class PlasticInternalUtils
             exceptionClassNames[i] = exceptions.get(i).replace('/', '.');
         }
 
-        return new MethodDescription(node.access, returnType, node.name, arguments, exceptionClassNames);
+        return new MethodDescription(node.access, returnType, node.name, arguments, node.signature, exceptionClassNames);
     }
 
     private static String[] toClassNames(Type[] types)
@@ -349,4 +349,12 @@ public class PlasticInternalUtils
             throw new RuntimeException(ex);
         }
     }
+
+    /**
+     * Returns true if both objects are the same instance, or both null, or left equals right.
+     */
+    public static boolean isEqual(Object left, Object right)
+    {
+        return left == right || (left != null && left.equals(right));
+    }
 }

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java?rev=1098017&r1=1098016&r2=1098017&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java (original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/MethodDescription.java Fri Apr 29 22:57:02 2011
@@ -49,6 +49,8 @@ public class MethodDescription implement
     /** The name of the method. */
     public final String methodName;
 
+    public final String genericSignature;
+
     /**
      * A non-null array of Java source names for arguments. Do not modify
      * the contents of this array.
@@ -70,7 +72,7 @@ public class MethodDescription implement
      */
     public MethodDescription(String returnType, String methodName, String... argumentTypes)
     {
-        this(Modifier.PUBLIC, returnType, methodName, argumentTypes, null);
+        this(Modifier.PUBLIC, returnType, methodName, argumentTypes, null, null);
     }
 
     /**
@@ -80,11 +82,13 @@ public class MethodDescription implement
      * @param methodName
      * @param argumentTypes
      *            may be null
+     * @param genericSignature
+     *            TODO
      * @param checkedExceptionTypes
      *            may be null
      */
     public MethodDescription(int modifiers, String returnType, String methodName, String[] argumentTypes,
-            String[] checkedExceptionTypes)
+            String genericSignature, String[] checkedExceptionTypes)
     {
         assert PlasticInternalUtils.isNonBlank(returnType);
         assert PlasticInternalUtils.isNonBlank(methodName);
@@ -92,6 +96,7 @@ public class MethodDescription implement
         this.modifiers = modifiers;
         this.returnType = returnType;
         this.methodName = methodName;
+        this.genericSignature = genericSignature;
 
         this.argumentTypes = PlasticInternalUtils.orEmpty(argumentTypes);
         this.checkedExceptionTypes = PlasticInternalUtils.orEmpty(checkedExceptionTypes);
@@ -99,15 +104,15 @@ public class MethodDescription implement
 
     public MethodDescription withModifiers(int newModifiers)
     {
-        return new MethodDescription(newModifiers, returnType, methodName, argumentTypes, checkedExceptionTypes);
+        return new MethodDescription(newModifiers, returnType, methodName, argumentTypes, genericSignature,
+                checkedExceptionTypes);
     }
 
-    /** Creates a MethodDescription from a Java Method. */
+    /** Creates a MethodDescription from a Java Method. The generic signature will be null. */
     public MethodDescription(Method method)
     {
-        this(method.getModifiers(), PlasticUtils.toTypeName(method.getReturnType()), method.getName(),
-                PlasticUtils.toTypeNames(method.getParameterTypes()), PlasticUtils.toTypeNames(method
-                        .getExceptionTypes()));
+        this(method.getModifiers(), PlasticUtils.toTypeName(method.getReturnType()), method.getName(), PlasticUtils
+                .toTypeNames(method.getParameterTypes()), null, PlasticUtils.toTypeNames(method.getExceptionTypes()));
     }
 
     public int compareTo(MethodDescription o)
@@ -130,6 +135,8 @@ public class MethodDescription implement
         result = prime * result + Arrays.hashCode(checkedExceptionTypes);
         result = prime * result + methodName.hashCode();
         result = prime * result + modifiers;
+        result = prime * result + (genericSignature == null ? 0 : genericSignature.hashCode());
+
         result = prime * result + returnType.hashCode();
 
         return result;
@@ -164,6 +171,9 @@ public class MethodDescription implement
         if (!Arrays.equals(argumentTypes, other.argumentTypes))
             return false;
 
+        if (!PlasticInternalUtils.isEqual(genericSignature, other.genericSignature))
+            return false;
+
         if (!Arrays.equals(checkedExceptionTypes, other.checkedExceptionTypes))
             return false;
 
@@ -195,6 +205,9 @@ public class MethodDescription implement
 
         builder.append(")");
 
+        if (genericSignature != null)
+            builder.append(" <").append(genericSignature).append(">");
+
         sep = " throws ";
 
         for (String name : checkedExceptionTypes)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BridgeClassTransformation.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BridgeClassTransformation.java?rev=1098017&r1=1098016&r2=1098017&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BridgeClassTransformation.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BridgeClassTransformation.java Fri Apr 29 22:57:02 2011
@@ -108,7 +108,7 @@ public class BridgeClassTransformation i
     private static MethodDescription toMethodDescription(TransformMethodSignature signature)
     {
         return new MethodDescription(signature.getModifiers(), signature.getReturnType(), signature.getMethodName(),
-                signature.getParameterTypes(), signature.getExceptionTypes());
+                signature.getParameterTypes(), signature.getSignature(), signature.getExceptionTypes());
     }
 
     private static class BridgeTransformField implements TransformField

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java?rev=1098017&r1=1098016&r2=1098017&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java Fri Apr 29 22:57:02 2011
@@ -103,7 +103,7 @@ public class ModuleImpl implements Modul
 
     /** "Magic" method related to Externalizable that allows the Proxy object to replace itself with the token. */
     private static final MethodDescription WRITE_REPLACE = new MethodDescription(Modifier.PRIVATE, "java.lang.Object",
-            "writeReplace", null, new String[]
+            "writeReplace", null, null, new String[]
             { ObjectStreamException.class.getName() });
 
     public ModuleImpl(InternalRegistry registry, ServiceActivityTracker tracker, ModuleDef moduleDef,