openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1524678 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/util/GenericsUtil.java test/java/org/apache/webbeans/newtests/injection/generics/ArrayOuttOfBouncExceptionFromMLTest.java
Date Thu, 19 Sep 2013 10:24:37 GMT
Author: rmannibucau
Date: Thu Sep 19 10:24:37 2013
New Revision: 1524678

URL: http://svn.apache.org/r1524678
Log:
OWB-901 type erasure handling for parameterizedtype

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/ArrayOuttOfBouncExceptionFromMLTest.java
      - copied, changed from r1524640, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/GenericBeanTest.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java?rev=1524678&r1=1524677&r2=1524678&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
Thu Sep 19 10:24:37 2013
@@ -564,7 +564,15 @@ public final class GenericsUtil
             if (genericClass instanceof ParameterizedType)
             {
                 ParameterizedType classType = (ParameterizedType)genericClass;
-                return resolveType(classType.getActualTypeArguments()[typeIndex], remove());
+                final Type[] actualTypeArguments = classType.getActualTypeArguments();
+                if (actualTypeArguments.length > typeIndex)
+                {
+                    return resolveType(actualTypeArguments[typeIndex], remove());
+                }
+                else
+                {
+                    return Object.class;
+                }
             }
             else
             {

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/ArrayOuttOfBouncExceptionFromMLTest.java
(from r1524640, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/GenericBeanTest.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/ArrayOuttOfBouncExceptionFromMLTest.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/ArrayOuttOfBouncExceptionFromMLTest.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/GenericBeanTest.java&r1=1524640&r2=1524678&rev=1524678&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/GenericBeanTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/ArrayOuttOfBouncExceptionFromMLTest.java
Thu Sep 19 10:24:37 2013
@@ -19,23 +19,52 @@
 package org.apache.webbeans.newtests.injection.generics;
 
 import org.apache.webbeans.newtests.AbstractUnitTest;
-import org.apache.webbeans.test.component.inject.generic.GenericComponent;
-import org.apache.webbeans.test.component.inject.generic.GenericComponentInjector;
-import org.junit.Assert;
 import org.junit.Test;
 
-public class GenericBeanTest extends AbstractUnitTest
+import javax.inject.Inject;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+
+import static org.junit.Assert.assertNotNull;
+
+// http://openejb.979440.n4.nabble.com/ArrayIndexOutOfBoundsException-on-TomEE-1-6-0-td4665080.html
+public class ArrayOuttOfBouncExceptionFromMLTest extends AbstractUnitTest
 {
-    
+    @Inject
+    private TwoKeyHashMap<String, Integer, Value> injected;
+
     @Test
     public void testGenericBeanInjection()
     {
-        startContainer(GenericComponent.class, GenericComponentInjector.class);
+        startContainer(Arrays.<Class<?>>asList(TwoKeyHashMap.class), Collections.<String>emptyList(),
true);
         
-        GenericComponentInjector<?> instance = getInstance(GenericComponentInjector.class);
-        Assert.assertNotNull(instance.getInjection1());
-        Assert.assertNotNull(instance.getInjection2());
-        Assert.assertNotNull(instance.getInjection3());
-        Assert.assertNotNull(instance.getInjection4());
+        assertNotNull(injected);
+
+        shutDownContainer();
+    }
+
+    public static class TwoKeyHashMap<K1, K2, V extends TwoKeyHashMap.TwoKeyValue<K1,
K2>> extends HashMap<K1, V>
+    {
+        public static interface TwoKeyValue<K1, K2>
+        {
+            K1 getKey1();
+            K2 getKey2();
+        }
+    }
+
+    public static class Value implements TwoKeyHashMap.TwoKeyValue<String, Integer>
+    {
+        @Override
+        public String getKey1()
+        {
+            return "1";
+        }
+
+        @Override
+        public Integer getKey2()
+        {
+            return 2;
+        }
     }
 }



Mime
View raw message