openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1434645 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/proxy/ test/java/org/apache/webbeans/test/unittests/inject/
Date Thu, 17 Jan 2013 12:38:40 GMT
Author: struberg
Date: Thu Jan 17 12:38:40 2013
New Revision: 1434645

URL: http://svn.apache.org/viewvc?rev=1434645&view=rev
Log:
OWB-344 proxying interfaces requires INVOKEINTERFACE and different ct handling

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/DisposalInjectedComponentTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java?rev=1434645&r1=1434644&r2=1434645&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
Thu Jan 17 12:38:40 2013
@@ -239,7 +239,7 @@ public abstract class AbstractProxyFacto
         int modifiers = delegatedMethod.getModifiers();
 
         //X TODO how to deal with native functions?
-        return (modifiers & (Modifier.PRIVATE | Modifier.ABSTRACT | Modifier.STATIC |
Modifier.FINAL | Modifier.NATIVE)) > 0 ||
+        return (modifiers & (Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL | Modifier.NATIVE))
> 0 ||
                "finalize".equals(delegatedMethod.getName());
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java?rev=1434645&r1=1434644&r2=1434645&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
Thu Jan 17 12:38:40 2013
@@ -125,8 +125,17 @@ public class NormalScopeProxyFactory ext
     {
         String proxyClassName = getUnusedProxyClassName(classLoader, classToProxy.getName()
+ "$OwbNormalScopeProxy");
 
-        List<Method> methods = ClassUtil.getNonPrivateMethods(classToProxy);
-        Method[] nonInterceptedMethods = methods.toArray(new Method[methods.size()]);
+        Method[] nonInterceptedMethods;
+        if (classToProxy.isInterface())
+        {
+            nonInterceptedMethods = classToProxy.getMethods();
+        }
+        else
+        {
+            List<Method> methods = ClassUtil.getNonPrivateMethods(classToProxy);
+            nonInterceptedMethods = methods.toArray(new Method[methods.size()]);
+        }
+
         Class<T> clazz = createProxyClass(classLoader, proxyClassName, classToProxy,
null, nonInterceptedMethods);
 
         return clazz;
@@ -261,7 +270,9 @@ public class NormalScopeProxyFactory ext
 
             // and finally invoke the target method on the provided Contextual Instance
             final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
-            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, declaringClass.getInternalName(), delegatedMethod.getName(),
methodDescriptor);
+            boolean interfaceMethod = Modifier.isAbstract(delegatedMethod.getModifiers());
+            mv.visitMethodInsn(interfaceMethod ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL,
+                               declaringClass.getInternalName(), delegatedMethod.getName(),
methodDescriptor);
 
             generateReturn(mv, delegatedMethod);
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/DisposalInjectedComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/DisposalInjectedComponentTest.java?rev=1434645&r1=1434644&r2=1434645&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/DisposalInjectedComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/DisposalInjectedComponentTest.java
Thu Jan 17 12:38:40 2013
@@ -46,9 +46,9 @@ public class DisposalInjectedComponentTe
         
         Assert.assertNotNull(producedService);
         
-        Object object = getInstance(ServiceImpl1.class);
+        IService service = getInstance(IService.class);
 
-        Assert.assertTrue(object instanceof ServiceImpl1);
+        Assert.assertEquals("ServiceImpl1", service.service());
 
         DisposalMethodComponent mc = getInstance(DisposalMethodComponent.class);
 



Mime
View raw message