Author: struberg
Date: Sun Jun 1 11:05:42 2014
New Revision: 1598967
URL: http://svn.apache.org/r1598967
Log:
OWB-960 also 'proxy' the VARARGS modifier
This is sometimes needed e.g. for EL coercing of vararg methods.
txs to Vojtech Zavrel for the report and the fix hint!
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/InterceptorDecoratorProxyFactory.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/common/TransactionalChildBean.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InheritedBeanInterceptorTest.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=1598967&r1=1598966&r2=1598967&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
Sun Jun 1 11:05:42 2014
@@ -39,6 +39,14 @@ public abstract class AbstractProxyFacto
{
public final static int MAX_CLASSLOAD_TRIES = 10000;
+ /**
+ * This is needed as the Modifier#VARARGS is not (yet) public.
+ * Note that the bitcode is the same as Modifier#TRANSIENT.
+ * But 'varargs' is only for methods, whereas 'transient' is only for
fields.
+ */
+ public static final int MODIFIER_VARARGS = 0x00000080;;
+
+
protected WebBeansContext webBeansContext;
/**
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=1598967&r1=1598966&r2=1598967&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
Sun Jun 1 11:05:42 2014
@@ -315,7 +315,7 @@ public class InterceptorDecoratorProxyFa
exceptionTypeNames[i] =
Type.getType(exceptionTypes[i]).getInternalName();
}
- int targetModifiers = modifiers & (Modifier.PROTECTED |
Modifier.PUBLIC);
+ int targetModifiers = modifiers & (Modifier.PROTECTED |
Modifier.PUBLIC | MODIFIER_VARARGS);
MethodVisitor mv = cw.visitMethod(targetModifiers,
delegatedMethod.getName(), methodDescriptor, null, exceptionTypeNames);
@@ -376,7 +376,7 @@ public class InterceptorDecoratorProxyFa
}
// push the method definition
- int modifier = modifiers & (Opcodes.ACC_PUBLIC |
Opcodes.ACC_PROTECTED);
+ int modifier = modifiers & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED
| Opcodes.ACC_VARARGS);
MethodVisitor mv = cw.visitMethod(modifier, method.getName(),
Type.getMethodDescriptor(method), null, null);
mv.visitCode();
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=1598967&r1=1598966&r2=1598967&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
Sun Jun 1 11:05:42 2014
@@ -393,7 +393,7 @@ public class NormalScopeProxyFactory ext
exceptionTypeNames[i] =
Type.getType(exceptionTypes[i]).getInternalName();
}
- int targetModifiers = delegatedMethod.getModifiers() &
(Modifier.PROTECTED | Modifier.PUBLIC);
+ int targetModifiers = delegatedMethod.getModifiers() &
(Modifier.PROTECTED | Modifier.PUBLIC | MODIFIER_VARARGS);
MethodVisitor mv = cw.visitMethod(targetModifiers,
delegatedMethod.getName(), methodDescriptor, null, exceptionTypeNames);
@@ -442,7 +442,7 @@ public class NormalScopeProxyFactory ext
final int modifiers = method.getModifiers();
// push the method definition
- int modifier = modifiers & (Opcodes.ACC_PUBLIC |
Opcodes.ACC_PROTECTED);
+ int modifier = modifiers & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED
| Opcodes.ACC_VARARGS);
MethodVisitor mv = cw.visitMethod(modifier, method.getName(),
Type.getMethodDescriptor(method), null, null);
mv.visitCode();
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java?rev=1598967&r1=1598966&r2=1598967&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/SubclassProxyFactory.java
Sun Jun 1 11:05:42 2014
@@ -187,7 +187,7 @@ public class SubclassProxyFactory extend
exceptionTypeNames[i] =
Type.getType(exceptionTypes[i]).getInternalName();
}
- int targetModifiers = delegatedMethod.getModifiers() &
(Modifier.PROTECTED | Modifier.PUBLIC);
+ int targetModifiers = delegatedMethod.getModifiers() &
(Modifier.PROTECTED | Modifier.PUBLIC | MODIFIER_VARARGS);
MethodVisitor mv = cw.visitMethod(targetModifiers,
delegatedMethod.getName(), methodDescriptor, null, exceptionTypeNames);
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/common/TransactionalChildBean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/common/TransactionalChildBean.java?rev=1598967&r1=1598966&r2=1598967&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/common/TransactionalChildBean.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/common/TransactionalChildBean.java
Sun Jun 1 11:05:42 2014
@@ -37,4 +37,10 @@ public class TransactionalChildBean exte
{
return "21";
}
+
+ public int methodWithVarAargs(String... strings)
+ {
+ return strings.length;
+ }
+
}
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InheritedBeanInterceptorTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InheritedBeanInterceptorTest.java?rev=1598967&r1=1598966&r2=1598967&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InheritedBeanInterceptorTest.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InheritedBeanInterceptorTest.java
Sun Jun 1 11:05:42 2014
@@ -25,6 +25,7 @@ import org.apache.webbeans.test.intercep
import org.apache.webbeans.test.interceptors.common.TransactionInterceptor;
import org.junit.Test;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
@@ -64,6 +65,18 @@ public class InheritedBeanInterceptorTes
Assert.assertTrue(TransactionInterceptor.ECHO);
Assert.assertEquals(1, TransactionInterceptor.count);
+ Assert.assertEquals(3, child.methodWithVarAargs("A", "B", "C"));
+ Assert.assertEquals(1, child.methodWithVarAargs("A"));
+
+ Method[] methods = child.getClass().getDeclaredMethods();
+ for (Method method : methods)
+ {
+ if (method.getName().equals("methodWithVarAargs"))
+ {
+ Assert.assertTrue(method.isVarArgs());
+ }
+ }
+
shutDownContainer();
}