aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbrat...@apache.org
Subject svn commit: r1727484 - in /aries/trunk/proxy: proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java proxy-itests/src/test/java/org/apache/aries/proxy/itests/AbstractBasicProxyTest.java
Date Fri, 29 Jan 2016 06:23:46 GMT
Author: sbratton
Date: Fri Jan 29 06:23:46 2016
New Revision: 1727484

URL: http://svn.apache.org/viewvc?rev=1727484&view=rev
Log:
[ARIES-1486] can't create proxy on java 8 vm  for interfaces containing lambda

Modified:
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceCombiningClassAdapter.java
    aries/trunk/proxy/proxy-itests/src/test/java/org/apache/aries/proxy/itests/AbstractBasicProxyTest.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=1727484&r1=1727483&r2=1727484&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 Jan 29 06:23:46 2016
@@ -84,16 +84,21 @@ final class InterfaceCombiningClassAdapt
 
   @Override
   public final MethodVisitor visitMethod(int access, String name, String desc,
-      String sig, String[] arg4) {
-    //If we already implement this method (from another interface) then we don't
-    //want a duplicate. We also don't want to copy any static init blocks (these
-    //initialize static fields on the interface that we don't copy
-    if(adapter.getKnownMethods().contains(new Method(name, desc)) || 
-        "<clinit>".equals(name))
-      return null;
-    else {//We're going to implement this method, so make it non abstract!
-      return adapter.visitMethod(access, name, desc, null, arg4);
-    }
+          String sig, String[] arg4) {
+      //If we already implement this method (from another interface) then we don't
+      //want a duplicate. We also don't want to copy any static init blocks (these
+      //initialize static fields on the interface that we don't copy
+      if(adapter.getKnownMethods().contains(new Method(name, desc)) || 
+              "<clinit>".equals(name)) {
+          return null;
+      }
+      else if(((access & (ACC_PRIVATE|ACC_SYNTHETIC)) == (ACC_PRIVATE|ACC_SYNTHETIC)))
{
+          // private, synthetic methods on interfaces don't need to be proxied.       
+          return null;
+      }
+      else {//We're going to implement this method, so make it non abstract!
+          return adapter.visitMethod(access, name, desc, null, arg4);
+      }
   }
 
   /**

Modified: aries/trunk/proxy/proxy-itests/src/test/java/org/apache/aries/proxy/itests/AbstractBasicProxyTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-itests/src/test/java/org/apache/aries/proxy/itests/AbstractBasicProxyTest.java?rev=1727484&r1=1727483&r2=1727484&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-itests/src/test/java/org/apache/aries/proxy/itests/AbstractBasicProxyTest.java
(original)
+++ aries/trunk/proxy/proxy-itests/src/test/java/org/apache/aries/proxy/itests/AbstractBasicProxyTest.java
Fri Jan 29 06:23:46 2016
@@ -54,6 +54,26 @@ public abstract class AbstractBasicProxy
   }
 
   /**
+   * This method checks that we correctly proxy an interface with default methods on java
8
+   */
+  @Test
+  public void checkProxydefaultMethodInterface() throws UnableToProxyException
+  {
+      Bundle b = bundleContext.getBundle();
+      Callable<Object> c = new TestCallable();
+      Collection<Class<?>> classes = new ArrayList<Class<?>>();
+      // proxy an interface with a default methods (on Java 8).
+      classes.add(java.lang.CharSequence.class);
+      try {
+          mgr.createDelegatingProxy(b, classes, c, null);
+      } catch (FinalModifierException e) {
+          String msg = e.getMessage();
+          assertEquals("The message didn't look right", "The class " + TestCallable.class.getName()
+ " is final.", msg);
+          assertTrue("The message didn't appear in the toString", e.toString().endsWith(msg));
+      }
+  }
+  
+  /**
    * This method checks that we correctly fail to proxy a class with final methods.
    * It also does a quick validation on the exception message.
    */



Mime
View raw message