QDox
  1. QDox
  2. QDOX-231

clazz.getAnnotations() for interface returns empty list of elements.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 1.12
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Used indirectly by gwt-maven-plugin to create Async interfaces for GWT
    • Number of attachments :
      1

      Description

      clazz.getAnnotations() returns an not-null but empty table (0 elements) in following code (taken from gwt-maven-plugin)

      GenerateAsyncMojo.java
              String uri = MessageFormat.format( rpcPattern, className );
              if ( clazz.getAnnotations() != null )
              {
                  for ( Annotation annotation : clazz.getAnnotations() )
                  {
                      getLog().debug( "annotation found on service interface " + annotation );
                      if ( annotation.getType().getValue().equals( "com.google.gwt.user.client.rpc.RemoteServiceRelativePath" ) )
                      {
                          uri = annotation.getNamedParameter( "value" ).toString();
                          // remove quotes
                          uri = uri.substring( 1, uri.length() - 1 );
                          getLog().debug( "@RemoteServiceRelativePath annotation found on service interface " + uri );
                      }
                  }
              }
      

        Issue Links

          Activity

          Hide
          Michał Bartczak added a comment -

          This issue should be linked to http://jira.codehaus.org/browse/MGWT-300

          Show
          Michał Bartczak added a comment - This issue should be linked to http://jira.codehaus.org/browse/MGWT-300
          Robert Scholte made changes -
          Field Original Value New Value
          Assignee Robert Scholte [ rfscholte ]
          Robert Scholte made changes -
          Link This issue is depended upon by MGWT-300 [ MGWT-300 ]
          Hide
          Robert Scholte added a comment -

          Michał,
          could you be more specific? We're working on QDox-2.0 where every List is never null, but at least an empty list. There's no null-check required anymore, use it immediately in a for-loop.

          Show
          Robert Scholte added a comment - Michał, could you be more specific? We're working on QDox-2.0 where every List is never null , but at least an empty list. There's no null-check required anymore, use it immediately in a for -loop.
          Hide
          Michał Bartczak added a comment - - edited

          The list is not null, as you wrote, but the list is also empty in a case where we expect some annotations to be found.

          When used in maven-gwt-plugin it is unable to find annotations from class:

          GreetingService.java
          @RemoteServiceRelativePath("greetings")
          public interface GreetingService extends RemoteService {
          	String greetServer(String name) throws IllegalArgumentException;
          }
          

          The code in example receives an empty list and the for loop is never executed - and that causes an improper behavior of plugin.

          Show
          Michał Bartczak added a comment - - edited The list is not null, as you wrote, but the list is also empty in a case where we expect some annotations to be found. When used in maven-gwt-plugin it is unable to find annotations from class: GreetingService.java @RemoteServiceRelativePath( "greetings" ) public interface GreetingService extends RemoteService { String greetServer( String name) throws IllegalArgumentException; } The code in example receives an empty list and the for loop is never executed - and that causes an improper behavior of plugin.
          Hide
          Robert Scholte added a comment -

          It's clear and very unexpected. This is really basic stuff. The good part is: I can't reproduce the issue with QDox-2.0.
          I've tried it on the qdox-1.12 tag and I can't reproduce it there either. Are you sure the gwt-m-p is using qdox-1.12? Otherwise add this as dependency to the plugin as a valid workaround.

          Show
          Robert Scholte added a comment - It's clear and very unexpected. This is really basic stuff. The good part is: I can't reproduce the issue with QDox-2.0. I've tried it on the qdox-1.12 tag and I can't reproduce it there either. Are you sure the gwt-m-p is using qdox-1.12? Otherwise add this as dependency to the plugin as a valid workaround.
          Hide
          Michał Bartczak added a comment -

          Taken from the current gwt-maven-plugin:

              <dependency>
                <groupId>com.thoughtworks.qdox</groupId>
                <artifactId>qdox</artifactId>
                <version>1.12</version>
              </dependency>
          

          I made an example and now I am not 100% sure where the error comes from.

          You may try the example that I've attached. Here is what the results would be:

          • First run mvn:compile. On target You will see generated-sources/gwt/com/demo/gaemaven/client/GreetingServiceAsync.java which is fine, the annotation is processed and there is line of code having target.setServiceEntryPoint( GWT.getModuleBaseURL() + "blah" );
          • Delete that source file
          • Rerun mvn:compile, and voila - you get the same class back but this time with target.setServiceEntryPoint( GWT.getModuleBaseURL() + "GreetingService" );, which is wrong.
          • As long as compiled version of interface is in target/classes, all source generation will fail
          Show
          Micha&#322; Bartczak added a comment - Taken from the current gwt-maven-plugin: <dependency> <groupId>com.thoughtworks.qdox</groupId> <artifactId>qdox</artifactId> <version>1.12</version> </dependency> I made an example and now I am not 100% sure where the error comes from. You may try the example that I've attached. Here is what the results would be: First run mvn:compile. On target You will see generated-sources/gwt/com/demo/gaemaven/client/GreetingServiceAsync.java which is fine, the annotation is processed and there is line of code having target.setServiceEntryPoint( GWT.getModuleBaseURL() + "blah" ); Delete that source file Rerun mvn:compile, and voila - you get the same class back but this time with target.setServiceEntryPoint( GWT.getModuleBaseURL() + "GreetingService" );, which is wrong. As long as compiled version of interface is in target/classes, all source generation will fail
          Micha&#322; Bartczak made changes -
          Attachment gaemaven.zip [ 55565 ]
          Hide
          Robert Scholte added a comment -

          That would mean that the problem has to do with the classlibrary order specified by the gwt-m-p (you can compare this with classloaders). So it's not a QDox-bug, so I'll close it here.

          Show
          Robert Scholte added a comment - That would mean that the problem has to do with the classlibrary order specified by the gwt-m-p (you can compare this with classloaders). So it's not a QDox-bug, so I'll close it here.
          Robert Scholte made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Not A Bug [ 6 ]
          Robert Scholte made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Robert Scholte
              Reporter:
              Micha&#322; Bartczak
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: