openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1623866 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java test/java/org/apache/webbeans/test/interceptors/constructor/InterceptionOfBeanWithConstructorInjectionTest.java
Date Tue, 09 Sep 2014 18:40:50 GMT
Author: struberg
Date: Tue Sep  9 18:40:49 2014
New Revision: 1623866

URL: http://svn.apache.org/r1623866
Log:
OWB-1003 move back to invoking default ct for decorators and interceptors

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/InterceptionOfBeanWithConstructorInjectionTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java?rev=1623866&r1=1623865&r2=1623866&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
Tue Sep  9 18:40:49 2014
@@ -262,45 +262,42 @@ public class InterceptorDecoratorProxyFa
     protected void createConstructor(ClassWriter cw, String proxyClassFileName, Class<?>
classToProxy, String classFileName)
             throws ProxyGenerationException
     {
+        Constructor superDefaultCt;
+        String parentClassFileName = classFileName;
+        String descriptor = "()V";
+
         try
         {
-            Constructor superDefaultCt;
-            String parentClassFileName;
             if (classToProxy.isInterface())
             {
                 parentClassFileName = Type.getInternalName(Object.class);
                 superDefaultCt = Object.class.getConstructor(null);
+                descriptor = Type.getConstructorDescriptor(superDefaultCt);
             }
-            else
-            {
-                parentClassFileName = classFileName;
-                superDefaultCt = classToProxy.getDeclaredConstructor(null);
-            }
-            final String descriptor = Type.getConstructorDescriptor(superDefaultCt);
-
-            // was: final String descriptor = Type.getConstructorDescriptor(classToProxy.getDeclaredConstructor());
-            // but we need to get a default constructor even if the bean uses constructor
injection
-            final MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", descriptor,
null, null);
-            mv.visitCode();
-            mv.visitVarInsn(Opcodes.ALOAD, 0);
-            mv.visitMethodInsn(Opcodes.INVOKESPECIAL, parentClassFileName, "<init>",
descriptor, false);
-
-            mv.visitVarInsn(Opcodes.ALOAD, 0);
-            mv.visitInsn(Opcodes.ACONST_NULL);
-            mv.visitFieldInsn(Opcodes.PUTFIELD, proxyClassFileName, FIELD_PROXIED_INSTANCE,
Type.getDescriptor(classToProxy));
-
-            mv.visitVarInsn(Opcodes.ALOAD, 0);
-            mv.visitInsn(Opcodes.ACONST_NULL);
-            mv.visitFieldInsn(Opcodes.PUTFIELD, proxyClassFileName, FIELD_INTERCEPTOR_HANDLER,
Type.getDescriptor(InterceptorHandler.class));
-
-            mv.visitInsn(Opcodes.RETURN);
-            mv.visitMaxs(-1, -1);
-            mv.visitEnd();
         }
         catch (NoSuchMethodException nsme)
         {
-            throw new ProxyGenerationException(nsme);
+            // no worries
         }
+
+        // was: final String descriptor = Type.getConstructorDescriptor(classToProxy.getDeclaredConstructor());
+        // but we need to get a default constructor even if the bean uses constructor injection
+        final MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", descriptor,
null, null);
+        mv.visitCode();
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        mv.visitMethodInsn(Opcodes.INVOKESPECIAL, parentClassFileName, "<init>", descriptor,
false);
+
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        mv.visitInsn(Opcodes.ACONST_NULL);
+        mv.visitFieldInsn(Opcodes.PUTFIELD, proxyClassFileName, FIELD_PROXIED_INSTANCE, Type.getDescriptor(classToProxy));
+
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        mv.visitInsn(Opcodes.ACONST_NULL);
+        mv.visitFieldInsn(Opcodes.PUTFIELD, proxyClassFileName, FIELD_INTERCEPTOR_HANDLER,
Type.getDescriptor(InterceptorHandler.class));
+
+        mv.visitInsn(Opcodes.RETURN);
+        mv.visitMaxs(-1, -1);
+        mv.visitEnd();
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/InterceptionOfBeanWithConstructorInjectionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/InterceptionOfBeanWithConstructorInjectionTest.java?rev=1623866&r1=1623865&r2=1623866&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/InterceptionOfBeanWithConstructorInjectionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/InterceptionOfBeanWithConstructorInjectionTest.java
Tue Sep  9 18:40:49 2014
@@ -64,12 +64,6 @@ public class InterceptionOfBeanWithConst
     {
         private final Injected injected;
 
-        BuildMeWithMyConstructor()
-        {
-            // default ct is needed for the proxy
-            injected = null;
-        }
-
         @Inject
         public BuildMeWithMyConstructor(final Injected injected)
         {



Mime
View raw message