[jbosstools-commits] JBoss Tools SVN: r22342 - in trunk/cdi: plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl and 4 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed May 26 16:21:59 EDT 2010
Author: akazakov
Date: 2010-05-26 16:21:57 -0400 (Wed, 26 May 2010)
New Revision: 22342
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GenericInitializerMethodBroken.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2708 Added new CDI validation rule: 3.9.1. Declaring an initializer method - generic method of a bean is annotated @Inject (initializer method is a non-abstract, non-static, non-generic method of a bean class)
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -460,6 +460,51 @@
return params;
}
+ /**
+ * Returns true if the method is generic
+ *
+ * @param method
+ * @return
+ */
+ public static boolean isMethodGeneric(IBeanMethod method) {
+ try {
+ return method.getMethod().getTypeParameters().length>0;
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if the method is static
+ *
+ * @param method
+ * @return
+ */
+ public static boolean isMethodStatic(IBeanMethod method) {
+ try {
+ return Flags.isStatic(method.getMethod().getFlags());
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if the method is abstract
+ *
+ * @param method
+ * @return
+ */
+ public static boolean isMethodAbstract(IBeanMethod method) {
+ try {
+ return Flags.isAbstract(method.getMethod().getFlags());
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ return false;
+ }
+
private static IType getSuperClass(IType type) throws JavaModelException {
String superclassName = type.getSuperclassName();
if(superclassName!=null) {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -51,4 +51,11 @@
* parameter of injection point method. May be null.
*/
IAnnotationDeclaration getDelegateAnnotation();
+
+ /**
+ * Returns the @Inject annotation declaration
+ *
+ * @return the @Inject annotation declaration.
+ */
+ IAnnotationDeclaration getInjectAnnotation();
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanField.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanField.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanField.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl;
+import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IInjectionPointField;
@@ -22,12 +23,27 @@
public InjectionPointField() {}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IInjectionPoint#getDelegateAnnotation()
+ */
public IAnnotationDeclaration getDelegateAnnotation() {
return getDefinition().getDelegateAnnotation();
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IInjectionPoint#isDelegate()
+ */
public boolean isDelegate() {
return getDelegateAnnotation() != null;
}
-}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IInjectionPoint#getInjectAnnotation()
+ */
+ public IAnnotationDeclaration getInjectAnnotation() {
+ return definition.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
+ }
+}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointMethod.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -33,4 +33,12 @@
protected Parameter newParameter() {
return new InjectionPointParameter();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IInjectionPoint#getInjectAnnotation()
+ */
+ public IAnnotationDeclaration getInjectAnnotation() {
+ return inject;
+ }
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -51,4 +51,11 @@
return isAnnotationPresent(CDIConstants.DELEGATE_STEREOTYPE_TYPE_NAME);
}
-}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IInjectionPoint#getInjectAnnotation()
+ */
+ public IAnnotationDeclaration getInjectAnnotation() {
+ return beanMethod.inject;
+ }
+}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -48,7 +48,7 @@
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IDecorator;
import org.jboss.tools.cdi.core.IInjectionPoint;
-import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.IInjectionPointMethod;
import org.jboss.tools.cdi.core.IInjectionPointParameter;
import org.jboss.tools.cdi.core.IInterceptor;
import org.jboss.tools.cdi.core.IParametedType;
@@ -592,14 +592,14 @@
ITypeDeclaration typeDeclaration = null;
if (!typeDeclarations.isEmpty()) {
/*
- * 3.3. Producer methods - producer method return type contains
- * a wildcard type parameter
+ * 3.3. Producer methods
+ * - producer method return type contains a wildcard type parameter
*
- * 2.2.1 Legal bean types - a parameterized type that contains a
- * wildcard type parameter is not a legal bean type.
+ * 2.2.1 Legal bean types
+ * - a parameterized type that contains a wildcard type parameter is not a legal bean type.
*
- * 3.4. Producer fields - producer field type contains a
- * wildcard type parameter
+ * 3.4. Producer fields
+ * - producer field type contains a wildcard type parameter
*/
typeDeclaration = typeDeclarations.iterator().next();
String[] paramTypes = Signature.getTypeArguments(typeDeclaration.getSignature());
@@ -615,14 +615,13 @@
}
}
- /**
- * 3.3. Producer methods - producer method with a parameterized
- * return type with a type variable declares any scope other
- * than @Dependent
+ /*
+ * 3.3. Producer methods
+ * - producer method with a parameterized return type with a type variable declares any scope other than @Dependent
*
- * 3.4. Producer fields - producer field with a parameterized
- * type with a type variable declares any scope other than @Dependent
- */
+ * 3.4. Producer fields
+ * - producer field with a parameterized type with a type variable declares any scope other than @Dependent
+ */
if (paramTypes.length > 0) {
IAnnotationDeclaration scopeOrStereotypeDeclaration = CDIUtil.getDifferentScopeDeclarationThanDepentend(producer);
if (scopeOrStereotypeDeclaration != null) {
@@ -635,8 +634,8 @@
}
/*
- * 3.3.2. Declaring a producer method - producer method is annotated
- * @Inject
+ * 3.3.2. Declaring a producer method
+ * - producer method is annotated @Inject
*/
IAnnotationDeclaration inject = producer.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
if (inject != null) {
@@ -647,9 +646,8 @@
if (producer instanceof IProducerField) {
/*
- * 3.5.1. Declaring a resource - producer field declaration
- * specifies an EL name (together with one of @Resource,
- * @PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
+ * 3.5.1. Declaring a resource
+ * - producer field declaration specifies an EL name (together with one of @Resource, @PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
*/
IProducerField producerField = (IProducerField) producer;
if (producerField.getName() != null) {
@@ -666,7 +664,8 @@
}
}
/*
- * 3.4. Producer fields - producer field type is a type variable
+ * 3.4. Producer fields
+ * - producer field type is a type variable
*/
if (typeVariables.length > 0) {
String typeSign = producerField.getField().getTypeSignature();
@@ -694,22 +693,22 @@
disposalDeclarations.add(producerMethod.getAnnotation(CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME));
for (IParameter param : params) {
/*
- * 3.3.6. Declaring a disposer method - a disposer method is
- * annotated @Produces.
+ * 3.3.6. Declaring a disposer method
+ * - a disposer method is annotated @Produces.
*
- * 3.3.2. Declaring a producer method - a has a parameter
- * annotated @Disposes
+ * 3.3.2. Declaring a producer method
+ * - a has a parameter annotated @Disposes
*/
ITextSourceReference declaration = param.getAnnotationPosition(CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
if (declaration != null) {
disposalDeclarations.add(declaration);
}
/*
- * 3.3.2. Declaring a producer method - a has a parameter
- * annotated @Observers
+ * 3.3.2. Declaring a producer method
+ * - a has a parameter annotated @Observers
*
- * 10.4.2. Declaring an observer method - an observer method
- * is annotated @Produces
+ * 10.4.2. Declaring an observer method
+ * - an observer method is annotated @Produces
*/
declaration = param.getAnnotationPosition(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
if (declaration != null) {
@@ -730,11 +729,11 @@
}
/*
- * 3.3. Producer methods - producer method return type is a type
- * variable
+ * 3.3. Producer methods
+ * - producer method return type is a type variable
*
- * 2.2.1 - Legal bean types - a type variable is not a legal
- * bean type
+ * 2.2.1 - Legal bean types
+ * - a type variable is not a legal bean type
*/
String typeSign = producerMethod.getMethod().getReturnType();
String typeString = Signature.toString(typeSign);
@@ -847,7 +846,7 @@
}
}
- } else if (!(injection instanceof IInjectionPointField)) {
+ } else if (injection instanceof IInjectionPointMethod) {
IAnnotationDeclaration named = injection.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
if (named != null) {
try {
@@ -860,13 +859,24 @@
}
}
if (!valueExists) {
- addError(CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME, CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME, named,
- injection.getResource());
+ addError(CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME, CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME, named, injection.getResource());
}
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
}
}
+
+ /*
+ *
+ */
+ IInjectionPointMethod injectionMethod = (IInjectionPointMethod)injection;
+ IAnnotationDeclaration declaration = injection.getInjectAnnotation();
+ if(CDIUtil.isMethodGeneric(injectionMethod)) {
+ addError(CDIValidationMessages.GENERIC_METHOD_ANNOTATED_INJECT, CDIPreferences.GENERIC_METHOD_ANNOTATED_INJECT, declaration, injection.getResource());
+ }
+ if(CDIUtil.isMethodStatic(injectionMethod)) {
+ addError(CDIValidationMessages.STATIC_METHOD_ANNOTATED_INJECT, CDIPreferences.GENERIC_METHOD_ANNOTATED_INJECT, declaration, injection.getResource());
+ }
}
}
@@ -883,8 +893,8 @@
if (sessionDeclaration != null) {
/*
- * 3.2. Session beans - bean class of a session bean is annotated
- * @Decorator
+ * 3.2. Session beans
+ * - bean class of a session bean is annotated @Decorator
*/
if (decoratorDeclaration != null) {
addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_DECORATOR, CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR,
@@ -893,8 +903,8 @@
decoratorDeclaration, bean.getResource());
}
/*
- * 3.2. Session beans - bean class of a session bean is annotated
- * @Interceptor
+ * 3.2. Session beans
+ * - bean class of a session bean is annotated @Interceptor
*/
if (interceptorDeclaration != null) {
addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_INTERCEPTOR, CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR,
@@ -911,8 +921,8 @@
IType type = bean.getBeanClass();
try {
/*
- * 3.2. Session beans - session bean with a parameterized bean
- * class declares any scope other than @Dependent
+ * 3.2. Session beans
+ * - session bean with a parameterized bean class declares any scope other than @Dependent
*/
String[] typeVariables = type.getTypeParameterSignatures();
if (typeVariables.length > 0) {
@@ -921,9 +931,8 @@
} else {
if (bean.isStateless()) {
/*
- * 3.2. Session beans - session bean specifies an
- * illegal scope (a stateless session bean must belong
- * to the @Dependent pseudo-scope)
+ * 3.2. Session beans
+ * - session bean specifies an illegal scope (a stateless session bean must belong to the @Dependent pseudo-scope)
*/
if (declaration != null) {
addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_STATELESS_SESSION_BEAN, CDIPreferences.ILLEGAL_SCOPE_FOR_SESSION_BEAN,
@@ -931,10 +940,8 @@
}
} else if (bean.isSingleton()) {
/*
- * 3.2. Session beans - session bean specifies an
- * illegal scope (a singleton bean must belong to either
- * the @ApplicationScoped scope or to the @Dependent
- * pseudo-scope)
+ * 3.2. Session beans
+ * - session bean specifies an illegal scope (a singleton bean must belong to either the @ApplicationScoped scope or to the @Dependent pseudo-scope)
*/
if (declaration != null) {
declaration = CDIUtil.getDifferentScopeDeclarationThanApplicationScoped(bean);
@@ -950,9 +957,8 @@
}
}
/*
- * 3.2.4. Specializing a session bean - session bean class annotated
- * @Specializes does not directly extend the bean class of another
- * session bean
+ * 3.2.4. Specializing a session bean
+ * - session bean class annotated @Specializes does not directly extend the bean class of another session bean
*/
IAnnotationDeclaration specializesDeclaration = bean.getSpecializesAnnotationDeclaration();
if (specializesDeclaration != null) {
@@ -963,8 +969,7 @@
addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_SESSION_BEAN, CDIPreferences.ILLEGAL_SPECIALIZING_SESSION_BEAN, specializesDeclaration,
bean.getResource());
} else if (!CDIUtil.isSessionBean(sBean)) {
- // The specializing bean directly extends a non-session bean
- // class
+ // The specializing bean directly extends a non-session bean class
addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_SESSION_BEAN, CDIPreferences.ILLEGAL_SPECIALIZING_SESSION_BEAN, specializesDeclaration,
bean.getResource());
}
@@ -973,7 +978,8 @@
private void validateManagedBean(IClassBean bean) {
/*
- * 3.1. Managed beans - the bean class of a managed bean is annotated with both the @Interceptor and @Decorator stereotypes
+ * 3.1. Managed beans
+ * - the bean class of a managed bean is annotated with both the @Interceptor and @Decorator stereotypes
*/
IAnnotationDeclaration decorator = bean.getAnnotation(CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME);
IAnnotationDeclaration interceptor = bean.getAnnotation(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME);
@@ -987,7 +993,8 @@
IType type = bean.getBeanClass();
try {
/*
- * 3.1. Managed beans - managed bean with a public field declares any scope other than @Dependent
+ * 3.1. Managed beans
+ * - managed bean with a public field declares any scope other than @Dependent
*/
IField[] fields = type.getFields();
for (IField field : fields) {
@@ -998,7 +1005,8 @@
}
}
/*
- * 3.1. Managed beans - managed bean with a parameterized bean class declares any scope other than @Dependent
+ * 3.1. Managed beans
+ * - managed bean with a parameterized bean class declares any scope other than @Dependent
*/
String[] typeVariables = type.getTypeParameterSignatures();
if (typeVariables.length > 0) {
@@ -1010,7 +1018,8 @@
}
}
/*
- * 3.1.4. Specializing a managed bean - managed bean class annotated @Specializes does not directly extend the bean class of another managed bean
+ * 3.1.4. Specializing a managed bean
+ * - managed bean class annotated @Specializes does not directly extend the bean class of another managed bean
*/
IAnnotationDeclaration specializesDeclaration = bean.getSpecializesAnnotationDeclaration();
if (specializesDeclaration != null) {
@@ -1052,7 +1061,8 @@
private void validateInterceptor(IInterceptor interceptor) {
/*
- * 2.5.3. Beans with no EL name - interceptor has a name (Non-Portable behavior)
+ * 2.5.3. Beans with no EL name
+ * - interceptor has a name (Non-Portable behavior)
*/
if (interceptor.getName() != null) {
ITextSourceReference declaration = interceptor.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
@@ -1066,7 +1076,8 @@
}
/*
- * 2.6.1. Declaring an alternative - interceptor is an alternative (Non-Portable behavior)
+ * 2.6.1. Declaring an alternative
+ * - interceptor is an alternative (Non-Portable behavior)
*/
if (interceptor.isAlternative()) {
ITextSourceReference declaration = interceptor.getAlternativeDeclaration();
@@ -1091,7 +1102,8 @@
private void validateDecorator(IDecorator decorator) {
/*
- * 2.5.3. Beans with no EL name - decorator has a name (Non-Portable behavior)
+ * 2.5.3. Beans with no EL name
+ * - decorator has a name (Non-Portable behavior)
*/
if (decorator.getName() != null) {
ITextSourceReference declaration = decorator.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
@@ -1105,7 +1117,8 @@
}
/*
- * 2.6.1. Declaring an alternative - decorator is an alternative (Non-Portable behavior)
+ * 2.6.1. Declaring an alternative
+ * - decorator is an alternative (Non-Portable behavior)
*/
if (decorator.isAlternative()) {
ITextSourceReference declaration = decorator.getAlternativeDeclaration();
@@ -1129,8 +1142,8 @@
}
/*
- * 2.2.2. Restricting the bean types of a bean - bean class or producer method or field specifies a @Typed annotation,
- * and the value member specifies a class which does not correspond to a type in the unrestricted set of bean types of a bean
+ * 2.2.2. Restricting the bean types of a bean
+ * - bean class or producer method or field specifies a @Typed annotation, and the value member specifies a class which does not correspond to a type in the unrestricted set of bean types of a bean
*/
private void validateTyped(IBean bean) {
Set<ITypeDeclaration> typedDeclarations = bean.getRestrictedTypeDeclaratios();
@@ -1166,10 +1179,7 @@
}
// 2.4.4. Default scope
- // - bean does not explicitly declare a scope when there is no default
- // scope
- // (there are two different stereotypes declared by the bean that
- // declare different default scopes)
+ // - bean does not explicitly declare a scope when there is no default scope (there are two different stereotypes declared by the bean that declare different default scopes)
//
// Such bean definitions are invalid because they declares two
// stereotypes that have different default scopes and the bean does not
@@ -1192,8 +1202,8 @@
}
/*
- * 2.4.1. Built-in scope types - interceptor or decorator has any scope
- * other than @Dependent (Non-Portable behavior)
+ * 2.4.1. Built-in scope types
+ * - interceptor or decorator has any scope other than @Dependent (Non-Portable behavior)
*/
boolean interceptor = bean instanceof IInterceptor;
boolean decorator = bean instanceof IDecorator;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -68,6 +68,7 @@
public static String CONSTRUCTOR_PARAMETER_ANNOTATED_OBSERVES;
public static String CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES;
public static String GENERIC_METHOD_ANNOTATED_INJECT;
+ public static String STATIC_METHOD_ANNOTATED_INJECT;
public static String MULTIPLE_OBSERVING_PARAMETERS;
public static String ILLEGAL_OBSERVER_IN_SESSION_BEAN;
public static String ILLEGAL_CONDITIONAL_OBSERVER;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-05-26 20:21:57 UTC (rev 22342)
@@ -47,6 +47,7 @@
CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES=Bean constructor has a parameter annotated @Disposes
CONSTRUCTOR_PARAMETER_ANNOTATED_OBSERVES=Bean constructor has a parameter annotated @Observes
GENERIC_METHOD_ANNOTATED_INJECT=Generic method of a bean is annotated @Inject
+STATIC_METHOD_ANNOTATED_INJECT=Static method of a bean is annotated @Inject
MULTIPLE_OBSERVING_PARAMETERS=Method has more than one parameter annotated @Observes
ILLEGAL_OBSERVER_IN_SESSION_BEAN=Non-static method of a session bean class has a parameter annotated @Observes, and the method is not a business method of the EJB
ILLEGAL_CONDITIONAL_OBSERVER=Bean with scope @Dependent has an observer method declared receive=IF_EXISTS
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -89,7 +89,7 @@
{CDIPreferences.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalProducerFieldInSessionBean_label},
{CDIPreferences.MULTIPLE_INJECTION_CONSTRUCTORS, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleInjectionConstructors_label},
{CDIPreferences.CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_constructorParameterIllegallyAnnotated_label},
-// {CDIPreferences.GENERIC_METHOD_ANNOTATED_INJECT, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_genericMethodAnnotatedInject_label},
+ {CDIPreferences.GENERIC_METHOD_ANNOTATED_INJECT, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_genericMethodAnnotatedInject_label},
{CDIPreferences.MULTIPLE_OBSERVING_PARAMETERS, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleObservingParameters_label},
{CDIPreferences.ILLEGAL_OBSERVER_IN_SESSION_BEAN, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalObserverInSessionBean_label},
// {CDIPreferences.ILLEGAL_CONDITIONAL_OBSERVER, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalConditionalObserver_label},
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2010-05-26 20:21:57 UTC (rev 22342)
@@ -70,7 +70,7 @@
CDIValidatorConfigurationBlock_pb_illegalProducerFieldInSessionBean_label=Illegal producer field in Session Bean:
CDIValidatorConfigurationBlock_pb_multipleInjectionConstructors_label=Multiple injection constructors:
CDIValidatorConfigurationBlock_pb_constructorParameterIllegallyAnnotated_label=Constructor parameter illegally annotated:
-CDIValidatorConfigurationBlock_pb_genericMethodAnnotatedInject_label=Generic method is annotated @Inject:
+CDIValidatorConfigurationBlock_pb_genericMethodAnnotatedInject_label=Generic or static method is annotated @Inject:
CDIValidatorConfigurationBlock_pb_multipleObservingParameters_label=Multiple observing parameterts:
CDIValidatorConfigurationBlock_pb_illegalObserverInSessionBean_label=Illegal observer in Session Bean:
CDIValidatorConfigurationBlock_pb_illegalConditionalObserver_label=Illegal conditional observer:
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GenericInitializerMethodBroken.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GenericInitializerMethodBroken.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GenericInitializerMethodBroken.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.inject;
+
+import javax.inject.Inject;
+
+public class GenericInitializerMethodBroken {
+
+ @Inject
+ public <U> void genericFoo(U arg) {
+ }
+
+ @Inject
+ public static void staticFoo(String arg) {
+ }
+}
\ No newline at end of file
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/inject/GenericInitializerMethodBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-26 19:59:50 UTC (rev 22341)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-26 20:21:57 UTC (rev 22342)
@@ -805,6 +805,28 @@
}
/**
+ * 3.9. Initializer methods
+ * - initializer method may not be static
+ *
+ * @throws Exception
+ */
+ public void testStaticInitializerMethod() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/GenericInitializerMethodBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.STATIC_METHOD_ANNOTATED_INJECT, 11);
+ }
+
+ /**
+ * 3.9.1. Declaring an initializer method
+ * - generic method of a bean is annotated @Inject
+ *
+ * @throws Exception
+ */
+ public void testGenericInitializerMethod() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/GenericInitializerMethodBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.GENERIC_METHOD_ANNOTATED_INJECT, 7);
+ }
+
+ /**
* 3.11. The qualifier @Named at injection points
* - injection point other than injected field declares a @Named annotation that does not specify the value member
*
More information about the jbosstools-commits
mailing list