openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1594859 - in /openwebbeans/branches/owb_1.2.x/webbeans-impl/src: main/java/org/apache/webbeans/proxy/ test/java/org/apache/webbeans/newtests/interceptors/factory/ test/java/org/apache/webbeans/newtests/interceptors/factory/beans/
Date Thu, 15 May 2014 10:47:07 GMT
Author: struberg
Date: Thu May 15 10:47:06 2014
New Revision: 1594859

URL: http://svn.apache.org/r1594859
Log:
OWB-957 use SIPUSH instead of BIPUSH on methods > 127

We originally alwayse used the byte version of index push (BIPISH)
This did lead to ArrayIndexOutOfBounds exceptions if interceptors got used
on 'fat' classes.


Added:
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/TonsOfMethodsInterceptedClass.java
Modified:
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java?rev=1594859&r1=1594858&r2=1594859&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
Thu May 15 10:47:06 2014
@@ -455,7 +455,16 @@ public class InterceptorDecoratorProxyFa
         mv.visitFieldInsn(Opcodes.GETSTATIC, proxyClassFileName, FIELD_INTERCEPTED_METHODS,
Type.getDescriptor(Method[].class));
 
         // push the methodIndex of the current method
-        mv.visitIntInsn(Opcodes.BIPUSH, methodIndex);
+        if (methodIndex <128)
+        {
+            mv.visitIntInsn(Opcodes.BIPUSH, methodIndex);
+        }
+        else
+        {
+            // for methods > 127 we need to push a short number as index
+            mv.visitIntInsn(Opcodes.SIPUSH, methodIndex);
+        }
+
 
         // and now load the Method from the array
         mv.visitInsn(Opcodes.AALOAD);

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java?rev=1594859&r1=1594858&r2=1594859&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
Thu May 15 10:47:06 2014
@@ -36,10 +36,12 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.newtests.interceptors.factory.beans.ClassInterceptedClass;
+import org.apache.webbeans.newtests.interceptors.factory.beans.TonsOfMethodsInterceptedClass;
 import org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory;
 
 import org.apache.webbeans.proxy.InterceptorHandler;
 import org.apache.webbeans.proxy.OwbInterceptorProxy;
+import org.apache.webbeans.test.component.intercept.webbeans.TransactionalInterceptor;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.CustomBaseType;
 import org.apache.webbeans.util.CustomType;
@@ -135,6 +137,26 @@ public class InterceptorDecoratorProxyFa
         Assert.assertNotNull(internalInstance.newInstance()); 
     }
 
+    /**
+     * We originally did have a bug in our proxy code which
+     * blew up if we did have > 127 methods in an intercepted class.
+     */
+    @Test
+    public void testManyMethodsInterceptor() throws Exception
+    {
+        addInterceptor(TransactionalInterceptor.class);
+        startContainer(TonsOfMethodsInterceptedClass.class);
+
+        TonsOfMethodsInterceptedClass instance = getInstance(TonsOfMethodsInterceptedClass.class);
+
+        for (int i = 0; i < 130; i++)
+        {
+            String methodName = "method" + i;
+            Method m = instance.getClass().getDeclaredMethod(methodName);
+            m.invoke(instance);
+        }
+    }
+
     public static class DummyBean implements Bean {
         @Override
         public Object create(CreationalContext context)

Added: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/TonsOfMethodsInterceptedClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/TonsOfMethodsInterceptedClass.java?rev=1594859&view=auto
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/TonsOfMethodsInterceptedClass.java
(added)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/TonsOfMethodsInterceptedClass.java
Thu May 15 10:47:06 2014
@@ -0,0 +1,559 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.interceptors.factory.beans;
+
+import javax.enterprise.context.Dependent;
+
+import org.apache.webbeans.test.component.intercept.webbeans.bindings.Transactional;
+
+/**
+ * A test bean which has > 128 methods.
+ * This did originally cause a bug in our generated interceptor bytecode
+ * as we used BIPUSH which is only 8bit signed as index.
+ */
+@Transactional
+@Dependent
+public class TonsOfMethodsInterceptedClass
+{
+    public void method0()
+    {
+    }
+
+    public void method1()
+    {
+    }
+
+    public void method2()
+    {
+    }
+
+    public void method3()
+    {
+    }
+
+    public void method4()
+    {
+    }
+
+    public void method5()
+    {
+    }
+
+    public void method6()
+    {
+    }
+
+    public void method7()
+    {
+    }
+
+    public void method8()
+    {
+    }
+
+    public void method9()
+    {
+    }
+
+    public void method10()
+    {
+    }
+
+    public void method11()
+    {
+    }
+
+    public void method12()
+    {
+    }
+
+    public void method13()
+    {
+    }
+
+    public void method14()
+    {
+    }
+
+    public void method15()
+    {
+    }
+
+    public void method16()
+    {
+    }
+
+    public void method17()
+    {
+    }
+
+    public void method18()
+    {
+    }
+
+    public void method19()
+    {
+    }
+
+    public void method20()
+    {
+    }
+
+    public void method21()
+    {
+    }
+
+    public void method22()
+    {
+    }
+
+    public void method23()
+    {
+    }
+
+    public void method24()
+    {
+    }
+
+    public void method25()
+    {
+    }
+
+    public void method26()
+    {
+    }
+
+    public void method27()
+    {
+    }
+
+    public void method28()
+    {
+    }
+
+    public void method29()
+    {
+    }
+
+    public void method30()
+    {
+    }
+
+    public void method31()
+    {
+    }
+
+    public void method32()
+    {
+    }
+
+    public void method33()
+    {
+    }
+
+    public void method34()
+    {
+    }
+
+    public void method35()
+    {
+    }
+
+    public void method36()
+    {
+    }
+
+    public void method37()
+    {
+    }
+
+    public void method38()
+    {
+    }
+
+    public void method39()
+    {
+    }
+
+
+    public void method40()
+    {
+    }
+
+    public void method41()
+    {
+    }
+
+    public void method42()
+    {
+    }
+
+    public void method43()
+    {
+    }
+
+    public void method44()
+    {
+    }
+
+    public void method45()
+    {
+    }
+
+    public void method46()
+    {
+    }
+
+    public void method47()
+    {
+    }
+
+    public void method48()
+    {
+    }
+
+    public void method49()
+    {
+    }
+
+
+    public void method50()
+    {
+    }
+
+    public void method51()
+    {
+    }
+
+    public void method52()
+    {
+    }
+
+    public void method53()
+    {
+    }
+
+    public void method54()
+    {
+    }
+
+    public void method55()
+    {
+    }
+
+    public void method56()
+    {
+    }
+
+    public void method57()
+    {
+    }
+
+    public void method58()
+    {
+    }
+
+    public void method59()
+    {
+    }
+
+
+    public void method60()
+    {
+    }
+
+    public void method61()
+    {
+    }
+
+    public void method62()
+    {
+    }
+
+    public void method63()
+    {
+    }
+
+    public void method64()
+    {
+    }
+
+    public void method65()
+    {
+    }
+
+    public void method66()
+    {
+    }
+
+    public void method67()
+    {
+    }
+
+    public void method68()
+    {
+    }
+
+    public void method69()
+    {
+    }
+
+
+    public void method70()
+    {
+    }
+
+    public void method71()
+    {
+    }
+
+    public void method72()
+    {
+    }
+
+    public void method73()
+    {
+    }
+
+    public void method74()
+    {
+    }
+
+    public void method75()
+    {
+    }
+
+    public void method76()
+    {
+    }
+
+    public void method77()
+    {
+    }
+
+    public void method78()
+    {
+    }
+
+    public void method79()
+    {
+    }
+
+    public void method80()
+    {
+    }
+
+    public void method81()
+    {
+    }
+
+    public void method82()
+    {
+    }
+
+    public void method83()
+    {
+    }
+
+    public void method84()
+    {
+    }
+
+    public void method85()
+    {
+    }
+
+    public void method86()
+    {
+    }
+
+    public void method87()
+    {
+    }
+
+    public void method88()
+    {
+    }
+
+    public void method89()
+    {
+    }
+
+    public void method90()
+    {
+    }
+
+    public void method91()
+    {
+    }
+
+    public void method92()
+    {
+    }
+
+    public void method93()
+    {
+    }
+
+    public void method94()
+    {
+    }
+
+    public void method95()
+    {
+    }
+
+    public void method96()
+    {
+    }
+
+    public void method97()
+    {
+    }
+
+    public void method98()
+    {
+    }
+
+    public void method99()
+    {
+    }
+
+    public void method100()
+    {
+    }
+
+    public void method101()
+    {
+    }
+
+    public void method102()
+    {
+    }
+
+    public void method103()
+    {
+    }
+
+    public void method104()
+    {
+    }
+
+    public void method105()
+    {
+    }
+
+    public void method106()
+    {
+    }
+
+    public void method107()
+    {
+    }
+
+    public void method108()
+    {
+    }
+
+    public void method109()
+    {
+    }
+
+    public void method110()
+    {
+    }
+
+    public void method111()
+    {
+    }
+
+    public void method112()
+    {
+    }
+
+    public void method113()
+    {
+    }
+
+    public void method114()
+    {
+    }
+
+    public void method115()
+    {
+    }
+
+    public void method116()
+    {
+    }
+
+    public void method117()
+    {
+    }
+
+    public void method118()
+    {
+    }
+
+    public void method119()
+    {
+    }
+
+    public void method120()
+    {
+    }
+
+    public void method121()
+    {
+    }
+
+    public void method122()
+    {
+    }
+
+    public void method123()
+    {
+    }
+
+    public void method124()
+    {
+    }
+
+    public void method125()
+    {
+    }
+
+    public void method126()
+    {
+    }
+
+    public void method127()
+    {
+    }
+
+    public void method128()
+    {
+    }
+
+    public void method129()
+    {
+    }
+
+
+}



Mime
View raw message