You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2014/09/09 20:40:50 UTC
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
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)
{