Author: swd847
Date: 2010-04-12 06:24:02 -0400 (Mon, 12 Apr 2010)
New Revision: 6092
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java
Log:
fix for constructor of inner classes
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java 2010-04-12
07:05:46 UTC (rev 6091)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java 2010-04-12
10:24:02 UTC (rev 6092)
@@ -3,6 +3,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
import javax.enterprise.inject.spi.Annotated;
@@ -70,7 +71,7 @@
public Set<Type> getTypeClosure()
{
- return Collections.unmodifiableSet(typeClosure);
+ return new HashSet<Type>(typeClosure);
}
public Type getBaseType()
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java 2010-04-12
07:05:46 UTC (rev 6091)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java 2010-04-12
10:24:02 UTC (rev 6092)
@@ -16,7 +16,27 @@
NewAnnotatedConstructor(NewAnnotatedType<X> type, Constructor<?>
constructor, AnnotationStore annotations, Map<Integer, AnnotationStore>
parameterAnnotations, Map<Integer, Type> typeOverrides)
{
- super(type, (Constructor<X>) constructor, constructor.getDeclaringClass(),
constructor.getParameterTypes(), constructor.getGenericParameterTypes(), annotations,
parameterAnnotations, null, typeOverrides);
+
+ super(type, (Constructor<X>) constructor, constructor.getDeclaringClass(),
constructor.getParameterTypes(), getGenericArray(constructor), annotations,
parameterAnnotations, null, typeOverrides);
}
+ private static Type[] getGenericArray(Constructor<?> constructor)
+ {
+ Type[] genericTypes = constructor.getGenericParameterTypes();
+ // for inner classes genericTypes and parameterTypes can be different
+ // length, this is a hack to fix this.
+ // TODO: investigate this behaviour further, on different JVM's and
+ // compilers
+ if (genericTypes.length + 1 == constructor.getParameterTypes().length)
+ {
+ genericTypes = new Type[constructor.getGenericParameterTypes().length + 1];
+ genericTypes[0] = constructor.getParameterTypes()[0];
+ for (int i = 0; i < constructor.getGenericParameterTypes().length; ++i)
+ {
+ genericTypes[i + 1] = constructor.getGenericParameterTypes()[i];
+ }
+ }
+ return genericTypes;
+ }
+
}