[webbeans-commits] Webbeans SVN: r3493 - ri/trunk/impl/src/main/java/org/jboss/webbeans/util and 2 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Fri Aug 14 12:25:19 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-08-14 12:25:19 -0400 (Fri, 14 Aug 2009)
New Revision: 3493
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObjectList.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObserverMethodWithParametertizedTypeTest.java
Log:
WBRI-302
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-14 15:12:29 UTC (rev 3492)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-14 16:25:19 UTC (rev 3493)
@@ -572,27 +572,28 @@
private void checkEventType(Type eventType)
{
Type[] types;
- if (eventType instanceof Class)
+ Type resolvedType = new Reflections.HierarchyDiscovery(eventType).getResolvedType();
+ if (resolvedType instanceof Class)
{
- types = Reflections.getActualTypeArguments((Class<?>) eventType);
+ types = new Type[0];
}
- else if (eventType instanceof ParameterizedType)
+ else if (resolvedType instanceof ParameterizedType)
{
- types = ((ParameterizedType) eventType).getActualTypeArguments();
+ types = ((ParameterizedType) resolvedType).getActualTypeArguments();
}
else
{
- throw new IllegalArgumentException("Event type " + eventType + " isn't a concrete type");
+ throw new IllegalArgumentException("Event type " + resolvedType + " is not allowed");
}
for (Type type : types)
{
if (type instanceof WildcardType)
{
- throw new IllegalArgumentException("Cannot provide an event type parameterized with a wildcard " + eventType);
+ throw new IllegalArgumentException("Cannot provide an event type parameterized with a wildcard " + resolvedType);
}
if (type instanceof TypeVariable)
{
- throw new IllegalArgumentException("Cannot provide an event type parameterized with a type parameter " + eventType);
+ throw new IllegalArgumentException("Cannot provide an event type parameterized with a type parameter " + resolvedType);
}
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-08-14 15:12:29 UTC (rev 3492)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-08-14 16:25:19 UTC (rev 3493)
@@ -79,7 +79,12 @@
public Type getResolvedType()
{
- return resolveType(type, type);
+ if (type instanceof Class)
+ {
+ Class<?> clazz = (Class<?>) type;
+ return resolveType(clazz);
+ }
+ return type;
}
private void discoverTypes(Type type)
@@ -89,16 +94,7 @@
if (type instanceof Class)
{
Class<?> clazz = (Class<?>) type;
- if (clazz.getTypeParameters().length > 0)
- {
- TypeVariable[] actualTypeParameters = clazz.getTypeParameters();
- ParameterizedType parameterizedType = new ParameterizedTypeImpl(clazz, actualTypeParameters, clazz.getDeclaringClass());
- add(parameterizedType);
- }
- else
- {
- add(clazz);
- }
+ add(resolveType(clazz));
discoverFromClass(clazz);
}
else
@@ -116,6 +112,20 @@
}
}
+ private Type resolveType(Class<?> clazz)
+ {
+ if (clazz.getTypeParameters().length > 0)
+ {
+ TypeVariable<?>[] actualTypeParameters = clazz.getTypeParameters();
+ ParameterizedType parameterizedType = new ParameterizedTypeImpl(clazz, actualTypeParameters, clazz.getDeclaringClass());
+ return parameterizedType;
+ }
+ else
+ {
+ return clazz;
+ }
+ }
+
@SuppressWarnings("unchecked")
private void discoverFromClass(Class<?> clazz)
{
@@ -376,13 +386,14 @@
*/
public static Type[] getActualTypeArguments(Class<?> clazz)
{
- if (clazz.getGenericSuperclass() instanceof ParameterizedType)
+ Type type = new HierarchyDiscovery(clazz).getResolvedType();
+ if (type instanceof ParameterizedType)
{
- return ((ParameterizedType) clazz.getGenericSuperclass()).getActualTypeArguments();
+ return ((ParameterizedType) type).getActualTypeArguments();
}
else
{
- return new Type[0];
+ return EMPTY_TYPES;
}
}
@@ -670,7 +681,7 @@
if (type1 instanceof Class)
{
Class<?> clazz = (Class<?>) type1;
- if (isAssignableFrom(clazz, new Type[0], type2))
+ if (isAssignableFrom(clazz, EMPTY_TYPES, type2))
{
return true;
}
@@ -756,7 +767,7 @@
else if (type2 instanceof Class)
{
Class<?> clazz = (Class<?>) type2;
- if (isAssignableFrom(rawType1, actualTypeArguments1, clazz, new Type[0]))
+ if (isAssignableFrom(rawType1, actualTypeArguments1, clazz, EMPTY_TYPES))
{
return true;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-08-14 15:12:29 UTC (rev 3492)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-08-14 16:25:19 UTC (rev 3493)
@@ -97,26 +97,11 @@
//TODO How can we assert that the exception was logged?
}
-
- @Test(groups = { "events", "underInvestigation" })
- @SpecAssertion(section = "11.2.7", id = "review") // removed from spec?
- public void testObserverMethodCallsManagerAddObserverWithObserverObject()
- {
- assert false;
- }
-
- @Test(groups = { "events", "underInvestigation" })
- @SpecAssertion(section = "10.4.1", id = "review") // removed from spec?
- public void testObserverMethodCallsManagerAddObserverWithAllBindingAnnotationsExceptFires()
- {
- assert false;
- }
-
@Test(groups = { "events" }, expectedExceptions = IllegalArgumentException.class)
@SpecAssertion(section = "11.3.11", id = "c")
- public void testEventObjectContainsTypeVariablesWhenResolvingFails()
+ public <T> void testEventObjectContainsTypeVariablesWhenResolvingFails()
{
- eventObjectContainsTypeVariables(new ArrayList<String>());
+ eventObjectContainsTypeVariables(new ArrayList<T>());
}
private <E> void eventObjectContainsTypeVariables(ArrayList<E> eventToFire)
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObjectList.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObjectList.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObjectList.java 2009-08-14 16:25:19 UTC (rev 3493)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.event.observer.wildcardAndTypeVariable;
+
+import java.util.ArrayList;
+
+/**
+ * @author pmuir
+ *
+ */
+public class ObjectList extends ArrayList<Object>
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObjectList.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObserverMethodWithParametertizedTypeTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObserverMethodWithParametertizedTypeTest.java 2009-08-14 15:12:29 UTC (rev 3492)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/wildcardAndTypeVariable/ObserverMethodWithParametertizedTypeTest.java 2009-08-14 16:25:19 UTC (rev 3493)
@@ -19,12 +19,11 @@
-import java.util.ArrayList;
import java.util.List;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -39,9 +38,8 @@
@SpecVersion("20090625")
public class ObserverMethodWithParametertizedTypeTest extends AbstractJSR299Test
{
- @Test(groups = { "events", "ri-broken"})
+ @Test(groups = { "events"})
@SpecAssertion(section = "10.4.1", id = "cb")
- // WBRI-302
public void testObserverMethodCanObserveTypeVariable()
{
BostonTerrier.observed = false;
@@ -50,14 +48,13 @@
assert BostonTerrier.observed;
}
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "10.4.1", id = "ca")
- // WBRI-302
public void testObserverMethodCanObserveWildcardType()
{
WildBostonTerrier.observed = false;
// TODO Not sure if this should match a wildcard event, I think it should as ? is an upper bound of all types PLM
- List<?> event = new ArrayList<Object>();
+ List<Object> event = new ObjectList();
getCurrentManager().fireEvent(event);
assert WildBostonTerrier.observed;
}
More information about the weld-commits
mailing list