aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1171540 - in /aries/trunk/proxy/proxy-impl/src: main/java/org/apache/aries/proxy/impl/interfaces/ test/java/org/apache/aries/blueprint/proxy/
Date Fri, 16 Sep 2011 13:19:25 GMT
Author: timothyjward
Date: Fri Sep 16 13:19:24 2011
New Revision: 1171540

URL: http://svn.apache.org/viewvc?rev=1171540&view=rev
Log:
ARIES-746: Fix Object methods on pure interface proxies

Modified:
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceUsingWovenProxyMethodAdapter.java
    aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/InterfaceProxyingTest.java

Modified: aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java?rev=1171540&r1=1171539&r2=1171540&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
Fri Sep 16 13:19:24 2011
@@ -101,6 +101,7 @@ final class InterfaceCombiningClassAdapt
         }
       }
       
+      adapter.setCurrentInterface(Type.getType(Object.class));
       visitObjectMethods();
       
       adapter.visitEnd();

Modified: aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceUsingWovenProxyMethodAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceUsingWovenProxyMethodAdapter.java?rev=1171540&r1=1171539&r2=1171540&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceUsingWovenProxyMethodAdapter.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceUsingWovenProxyMethodAdapter.java
Fri Sep 16 13:19:24 2011
@@ -31,12 +31,16 @@ import org.objectweb.asm.commons.Method;
 final class InterfaceUsingWovenProxyMethodAdapter extends AbstractWovenProxyMethodAdapter
{
 
   private final Type interfaceType;
+  
+  private final boolean isInterfaceType;
+  
   public InterfaceUsingWovenProxyMethodAdapter(MethodVisitor mv, int access, String name,
       String desc, String methodStaticFieldName, Method currentTransformMethod,
       Type typeBeingWoven, Type interfaceType) {
     super(mv, access, name, desc, methodStaticFieldName, currentTransformMethod,
         typeBeingWoven);
     this.interfaceType = interfaceType;
+    this.isInterfaceType = !!!interfaceType.equals(OBJECT_TYPE);
   }
 
   /**
@@ -81,6 +85,6 @@ final class InterfaceUsingWovenProxyMeth
   
   @Override
   protected final boolean isTypeToCastToInterface() {
-    return true;
+    return isInterfaceType;
   }
 }

Modified: aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/InterfaceProxyingTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/InterfaceProxyingTest.java?rev=1171540&r1=1171539&r2=1171540&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/InterfaceProxyingTest.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/InterfaceProxyingTest.java
Fri Sep 16 13:19:24 2011
@@ -191,24 +191,34 @@ public class InterfaceProxyingTest {
   
   @Test
   public void testHandlesObjectMethods() throws Exception {
+      TestListener listener = new TestListener();
       List<String> list = Arrays.asList("one", "two", "three");
-      Object proxied = InterfaceProxyGenerator.getProxyInstance(testBundle, Arrays.<Class<?>>asList(List.class),
constantly(list), null);
+      Object proxied = InterfaceProxyGenerator.getProxyInstance(testBundle, Arrays.<Class<?>>asList(List.class),
constantly(list), listener);
       
       // obeys hashCode and equals, they *are* on the interface
       assertTrue(proxied.equals(Arrays.asList("one", "two", "three")));
+      assertEquals(Collection.class.getMethod("equals", Object.class), listener.getLastMethod());
+      listener.clear();
       assertEquals(Arrays.asList("one", "two", "three").hashCode(), proxied.hashCode());
-      
+      assertEquals(Collection.class.getMethod("hashCode"), listener.getLastMethod());
+      listener.clear();
       // and toString
       assertEquals(list.toString(), proxied.toString());
+      assertEquals(Object.class.getMethod("toString"), listener.getLastMethod());
+      listener.clear();
       
       Runnable runnable = new Runnable() {
         public void run() {}
       };
-      proxied = InterfaceProxyGenerator.getProxyInstance(testBundle, Arrays.<Class<?>>asList(Runnable.class),
constantly(runnable), null);
+      proxied = InterfaceProxyGenerator.getProxyInstance(testBundle, Arrays.<Class<?>>asList(Runnable.class),
constantly(runnable), listener);
       
       // obeys hashCode and equals, they *are not* on the interface
       assertTrue(proxied.equals(runnable));
+      assertEquals(Object.class.getMethod("equals", Object.class), listener.getLastMethod());
+      listener.clear();
       assertEquals(runnable.hashCode(), proxied.hashCode());
+      assertEquals(Object.class.getMethod("hashCode"), listener.getLastMethod());
+      listener.clear();
   }
   
   private static class TestClassLoader extends ClassLoader {



Mime
View raw message