Author: cziegeler
Date: Wed Nov 28 15:46:45 2012
New Revision: 1414766

URL: http://svn.apache.org/viewvc?rev=1414766&view=rev
Log:
FELIX-3739 :  scr-plugin: "Annotated method {0} not found" .

Modified:
    
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java

Modified: 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java?rev=1414766&r1=1414765&r2=1414766&view=diff
==============================================================================
--- 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java
 (original)
+++ 
felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/ClassScanner.java
 Wed Nov 28 15:46:45 2012
@@ -211,47 +211,49 @@ public class ClassScanner {
             final List<MethodNode> methods = classNode.methods;
             if (methods != null) {
                 for (final MethodNode method : methods) {
-
-                    @SuppressWarnings("unchecked")
-                    final List<AnnotationNode> annos = 
getAllAnnotations(method.invisibleAnnotations, method.visibleAnnotations);
-                    if (annos != null) {
-                        final String name = method.name;
-                        final Type[] signature = 
Type.getArgumentTypes(method.desc);
-
-                        final Method[] allMethods = 
annotatedClass.getDeclaredMethods();
-                        Method found = null;
-                        for (final Method m : allMethods) {
-                            if (m.getName().equals(name)) {
-                                if (m.getParameterTypes().length == 0 && 
(signature == null || signature.length == 0) ) {
-                                    found = m;
-                                }
-                                if (m.getParameterTypes().length > 0 && 
signature != null && m.getParameterTypes().length == signature.length) {
-                                    found = m;
-                                    for(int index = 0; index < 
m.getParameterTypes().length; index++ ) {
-                                        String parameterTypeName = 
m.getParameterTypes()[index].getName();
-                                        // Name of array parameters is 
returned with syntax [L<name>;, convert to <name>[]
-                                        Matcher matcher = 
ARRAY_PARAM_TYPE_NAME.matcher(parameterTypeName);
-                                        if (matcher.matches()) {
-                                            parameterTypeName = 
matcher.group(1) + "[]";
-                                        }
-                                        if 
(!parameterTypeName.equals(signature[index].getClassName()) &&
-                                                
!m.getParameterTypes()[index].getSimpleName().equals(signature[index].getClassName()))
 {
-                                            found = null;
+                    final String name = method.name;
+                    // check for constructor
+                    if ( !"<init>".equals(name) ) {
+                        @SuppressWarnings("unchecked")
+                        final List<AnnotationNode> annos = 
getAllAnnotations(method.invisibleAnnotations, method.visibleAnnotations);
+                        if (annos != null) {
+                            final Type[] signature = 
Type.getArgumentTypes(method.desc);
+
+                            final Method[] allMethods = 
annotatedClass.getDeclaredMethods();
+                            Method found = null;
+                            for (final Method m : allMethods) {
+                                if (m.getName().equals(name)) {
+                                    if (m.getParameterTypes().length == 0 && 
(signature == null || signature.length == 0) ) {
+                                        found = m;
+                                    }
+                                    if (m.getParameterTypes().length > 0 && 
signature != null && m.getParameterTypes().length == signature.length) {
+                                        found = m;
+                                        for(int index = 0; index < 
m.getParameterTypes().length; index++ ) {
+                                            String parameterTypeName = 
m.getParameterTypes()[index].getName();
+                                            // Name of array parameters is 
returned with syntax [L<name>;, convert to <name>[]
+                                            Matcher matcher = 
ARRAY_PARAM_TYPE_NAME.matcher(parameterTypeName);
+                                            if (matcher.matches()) {
+                                                parameterTypeName = 
matcher.group(1) + "[]";
+                                            }
+                                            if 
(!parameterTypeName.equals(signature[index].getClassName()) &&
+                                                    
!m.getParameterTypes()[index].getSimpleName().equals(signature[index].getClassName()))
 {
+                                                found = null;
+                                            }
                                         }
                                     }
-                                }
-                                // if method is found return it now, to avoid 
resetting 'found' to null if next method has same name but different parameters
-                                if (found != null) {
-                                    break;
+                                    // if method is found return it now, to 
avoid resetting 'found' to null if next method has same name but different 
parameters
+                                    if (found != null) {
+                                        break;
+                                    }
                                 }
                             }
-                        }
-                        if (found == null) {
-                            throw new SCRDescriptorException("Annotated method 
" + name + " not found.",
-                                    annotatedClass.getName());
-                        }
-                        for (final AnnotationNode annotation : annos) {
-                            parseAnnotation(descriptions, annotation, found);
+                            if (found == null) {
+                                throw new SCRDescriptorException("Annotated 
method " + name + " not found.",
+                                        annotatedClass.getName());
+                            }
+                            for (final AnnotationNode annotation : annos) {
+                                parseAnnotation(descriptions, annotation, 
found);
+                            }
                         }
                     }
                 }


Reply via email to