jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Sonar
  • SONAR-33

JavaNCSS can not parse annotations from method body

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.4
  • Component/s: None
  • Labels:
    None

Description

The annotation @SupressWarning is often used directly inside a method. It induces problems on the JavaNCSS plugin, which is very critical.
The problem is from the JavaNCSS library, but not from the maven plugin (see http://jira.codehaus.org/browse/MJNCSS-16). The core library is not a lot supported, so can we use an equivalent plugin ?

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Freddy Mallet added a comment - 21/Dec/07 7:07 AM

I think, we just need to update the java 5 grammar used by JavaNCSS (that is to say by Javacc) to correct this issue. The lastest java grammar is available on javacc web site.

Show
Freddy Mallet added a comment - 21/Dec/07 7:07 AM I think, we just need to update the java 5 grammar used by JavaNCSS (that is to say by Javacc) to correct this issue. The lastest java grammar is available on javacc web site.
Hide
Permalink
Seb V added a comment - 30/Jun/08 6:58 AM

According to http://jira.codehaus.org/browse/MJNCSS-16?focusedCommentId=137473#action_137473, the issue was fixed in JavaNCSS Version 29.50.

Show
Seb V added a comment - 30/Jun/08 6:58 AM According to http://jira.codehaus.org/browse/MJNCSS-16?focusedCommentId=137473#action_137473, the issue was fixed in JavaNCSS Version 29.50.
Hide
Permalink
Simon Brandhof added a comment - 30/Jun/08 7:30 AM

You're right. We were waiting for JavaNcss maven plugin 2.0-beta-3 that upgrades to 29.50, but it is still not released : http://jira.codehaus.org/browse/MJNCSS/fixforversion/13131.
Fortunately a workaround is possible :

<plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>javancss-maven-plugin</artifactId>
                <version>2.0-beta-2</version>
                <dependencies>
                    <dependency>
                        <groupId>javancss</groupId>
                        <artifactId>javancss</artifactId>
                        <version>29.50</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>

So we fix this issue on the next 1.4RC1. Thank you Seb for the reminder.

Show
Simon Brandhof added a comment - 30/Jun/08 7:30 AM You're right. We were waiting for JavaNcss maven plugin 2.0-beta-3 that upgrades to 29.50, but it is still not released : http://jira.codehaus.org/browse/MJNCSS/fixforversion/13131. Fortunately a workaround is possible :
<plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>javancss-maven-plugin</artifactId>
                <version>2.0-beta-2</version>
                <dependencies>
                    <dependency>
                        <groupId>javancss</groupId>
                        <artifactId>javancss</artifactId>
                        <version>29.50</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
So we fix this issue on the next 1.4RC1. Thank you Seb for the reminder.
Hide
Permalink
Wojciech Durczynski added a comment - 07/Jul/08 4:54 AM

After changing version of sonar to 1.4RC1 I got the following error:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute the command org.codehaus.mojo:javancss-maven-plugin:2.0-beta-2:report

Embedded error: An error has occurred in JavaNCSS Report report generation.
Encountered "public static final String ACTION_PARAM =" at line 9, column 3.
Was expecting one of:
"boolean" ...
"byte" ...
"char" ...
"double" ...
"float" ...
"int" ...
"long" ...
"short" ...
"@" ...
"." ...
"(" ...
"public" "public" ...
"public" "static" "public" ...
"public" "static" "static" ...
"public" "static" "protected" ...
"public" "static" "private" ...
"public" "static" "final" "public" ...
"public" "static" "final" "static" ...
"public" "static" "final" "protected" ...
"public" "static" "final" "private" ...
"public" "static" "final" "final" ...
"public" "static" "final" "abstract" ...
"public" "static" "final" "synchronized" ...
"public" "static" "final" "native" ...
"public" "static" "final" "transient" ...
"public" "static" "final" "volatile" ...
"public" "static" "final" "strictfp" ...
"public" "static" "final" "@" ...
"public" "static" "final" "enum" ...
"public" "protected" ...
"public" "private" ...
"public" "static" "abstract" ...
"public" "static" "final" "<" ...
"public" "static" "final" "void" ...
"public" "static" "final" "boolean" ...
"public" "static" "final" "char" ...
"public" "static" "final" "byte" ...
"public" "static" "final" "short" ...
"public" "static" "final" "int" ...
"public" "static" "final" "long" ...
"public" "static" "final" "float" ...
"public" "static" "final" "double" ...
"public" "static" "final" <IDENTIFIER> "<" ...
"public" "static" "final" <IDENTIFIER> "." ...
"public" "static" "final" <IDENTIFIER> "[" ...
"public" "static" "final" <IDENTIFIER> <IDENTIFIER> "(" ...
<IDENTIFIER> ...

It's caused probably by my interface:
public interface RequestParamMarkers { public static final String PLUGIN_PARAM = "__plugin_name_param"; //public static final String LOCATION_URL_PARAM = "__location_url_param"; public static final String LOCATION_PARAM = "__location_id_param"; @Deprecated public static final String ACTION_PARAM = "__action_id_param"; }

Sadly Sonar is still useless.

Show
Wojciech Durczynski added a comment - 07/Jul/08 4:54 AM After changing version of sonar to 1.4RC1 I got the following error: [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Cannot execute the command org.codehaus.mojo:javancss-maven-plugin:2.0-beta-2:report Embedded error: An error has occurred in JavaNCSS Report report generation. Encountered "public static final String ACTION_PARAM =" at line 9, column 3. Was expecting one of: "boolean" ... "byte" ... "char" ... "double" ... "float" ... "int" ... "long" ... "short" ... "@" ... "." ... "(" ... "public" "public" ... "public" "static" "public" ... "public" "static" "static" ... "public" "static" "protected" ... "public" "static" "private" ... "public" "static" "final" "public" ... "public" "static" "final" "static" ... "public" "static" "final" "protected" ... "public" "static" "final" "private" ... "public" "static" "final" "final" ... "public" "static" "final" "abstract" ... "public" "static" "final" "synchronized" ... "public" "static" "final" "native" ... "public" "static" "final" "transient" ... "public" "static" "final" "volatile" ... "public" "static" "final" "strictfp" ... "public" "static" "final" "@" ... "public" "static" "final" "enum" ... "public" "protected" ... "public" "private" ... "public" "static" "abstract" ... "public" "static" "final" "<" ... "public" "static" "final" "void" ... "public" "static" "final" "boolean" ... "public" "static" "final" "char" ... "public" "static" "final" "byte" ... "public" "static" "final" "short" ... "public" "static" "final" "int" ... "public" "static" "final" "long" ... "public" "static" "final" "float" ... "public" "static" "final" "double" ... "public" "static" "final" <IDENTIFIER> "<" ... "public" "static" "final" <IDENTIFIER> "." ... "public" "static" "final" <IDENTIFIER> "[" ... "public" "static" "final" <IDENTIFIER> <IDENTIFIER> "(" ... <IDENTIFIER> ... It's caused probably by my interface: public interface RequestParamMarkers { public static final String PLUGIN_PARAM = "__plugin_name_param"; //public static final String LOCATION_URL_PARAM = "__location_url_param"; public static final String LOCATION_PARAM = "__location_id_param"; @Deprecated public static final String ACTION_PARAM = "__action_id_param"; } Sadly Sonar is still useless.
Hide
Permalink
Simon Brandhof added a comment - 07/Jul/08 5:03 AM

Hi,
I can't reproduce your issue. Could you check that target/sonar/sonar-pom.xml contains the following :

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>javancss-maven-plugin</artifactId>
        <version>2.0-beta-2</version>
        <dependencies>
          <dependency>
            <groupId>javancss</groupId>
            <artifactId>javancss</artifactId>
            <version>29.50</version>
            <scope>compile</scope>
          </dependency>
        </dependencies>
        <configuration>
          <linkXRef>false</linkXRef>
        </configuration>
      </plugin>

It seems that the maven plugin still uses the old javancss version. Could you attach your pom.xml please ?

Show
Simon Brandhof added a comment - 07/Jul/08 5:03 AM Hi, I can't reproduce your issue. Could you check that target/sonar/sonar-pom.xml contains the following :
<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>javancss-maven-plugin</artifactId>
        <version>2.0-beta-2</version>
        <dependencies>
          <dependency>
            <groupId>javancss</groupId>
            <artifactId>javancss</artifactId>
            <version>29.50</version>
            <scope>compile</scope>
          </dependency>
        </dependencies>
        <configuration>
          <linkXRef>false</linkXRef>
        </configuration>
      </plugin>
It seems that the maven plugin still uses the old javancss version. Could you attach your pom.xml please ?
Hide
Permalink
Wojciech Durczynski added a comment - 07/Jul/08 5:48 AM

sonar-pom.xml contains exactly what you've pasted. I'll attach it to the issue.

Show
Wojciech Durczynski added a comment - 07/Jul/08 5:48 AM sonar-pom.xml contains exactly what you've pasted. I'll attach it to the issue.
Hide
Permalink
Wojciech Durczynski added a comment - 07/Jul/08 5:51 AM

I cannot add an attachment. But you can see sonar-pom.xml here:
http://ds5.agh.edu.pl/~avatar/sonar/sonar-pom.xml

Show
Wojciech Durczynski added a comment - 07/Jul/08 5:51 AM I cannot add an attachment. But you can see sonar-pom.xml here: http://ds5.agh.edu.pl/~avatar/sonar/sonar-pom.xml
Hide
Permalink
Simon Brandhof added a comment - 07/Jul/08 7:04 AM

Wojciech, which version of maven do you use ? Do you execute mvn from a command line or from a continuous integration tool ?

Show
Simon Brandhof added a comment - 07/Jul/08 7:04 AM Wojciech, which version of maven do you use ? Do you execute mvn from a command line or from a continuous integration tool ?
Hide
Permalink
Wojciech Durczynski added a comment - 07/Jul/08 7:07 AM

mvn -v
Maven version: 2.0.9
Java version: 1.6.0_02
OS name: "linux" version: "2.6.18-8.1.8.el5xen" arch: "amd64" Family: "unix"

I execute builds in continuous integration tool - Atlassian Bamboo 2.0.3

Show
Wojciech Durczynski added a comment - 07/Jul/08 7:07 AM mvn -v Maven version: 2.0.9 Java version: 1.6.0_02 OS name: "linux" version: "2.6.18-8.1.8.el5xen" arch: "amd64" Family: "unix" I execute builds in continuous integration tool - Atlassian Bamboo 2.0.3
Hide
Permalink
Wojciech Durczynski added a comment - 07/Jul/08 7:11 AM

But Bamboo probably uses maven-2.0.7, java version the same.

Show
Wojciech Durczynski added a comment - 07/Jul/08 7:11 AM But Bamboo probably uses maven-2.0.7, java version the same.
Hide
Permalink
Simon Brandhof added a comment - 07/Jul/08 7:11 AM

OK tkanks. And can you retry from command line ?

Show
Simon Brandhof added a comment - 07/Jul/08 7:11 AM OK tkanks. And can you retry from command line ?
Hide
Permalink
Wojciech Durczynski added a comment - 07/Jul/08 7:27 AM

When running from command line (with maven-2.0.9) result is exactly the same - exception from ncss plugin.

Show
Wojciech Durczynski added a comment - 07/Jul/08 7:27 AM When running from command line (with maven-2.0.9) result is exactly the same - exception from ncss plugin.
Hide
Permalink
Simon Brandhof added a comment - 07/Jul/08 8:36 AM

Can you send the sonar-pom.xml of the module that fails please ? And can you also send the result of mvn dependency:list executed from that module ?

Show
Simon Brandhof added a comment - 07/Jul/08 8:36 AM Can you send the sonar-pom.xml of the module that fails please ? And can you also send the result of mvn dependency:list executed from that module ?
Hide
Permalink
Wojciech Durczynski added a comment - 07/Jul/08 8:57 AM

sonar-pom.xml of the module that fails can be found here:
http://ds5.agh.edu.pl/~avatar/sonar/ui-core/sonar-pom.xml

dependency:list executed there prints:
[INFO] [dependency:list]
[INFO]
[INFO] The following files have been resolved:
[INFO] cglib:cglib-nodep:jar:2.1_3:test
[INFO] com.comarch.p7:spec:jar:0.4-SNAPSHOT:compile
[INFO] com.comarch.p7:wicket-core:jar:0.4-SNAPSHOT:compile
[INFO] com.comarch.p7bundles:cglib-nodep:jar:2.1.3.014:compile
[INFO] com.comarch.p7bundles:commons-beanutils:jar:1.7.0.014:compile
[INFO] com.comarch.p7bundles:commons-collections:jar:3.2.0.014:compile
[INFO] com.comarch.p7bundles:commons-lang:jar:2.2.0.014:compile
[INFO] com.comarch.p7bundles:findbugs-annotations:jar:1.3.3.014:compile
[INFO] com.comarch.p7bundles:jsr305:jar:1.3.3.014:compile
[INFO] com.comarch.p7bundles:pax-logging-api:jar:1.1.1:compile
[INFO] com.comarch.p7bundles:pax-web-service:jar:0.5.0.014:compile
[INFO] com.comarch.p7bundles:spring-beans:jar:2.5.5:compile
[INFO] com.comarch.p7bundles:spring-context:jar:2.5.5:compile
[INFO] com.comarch.p7bundles:spring-core:jar:2.5.5:compile
[INFO] com.comarch.p7bundles:spring-osgi-core:jar:1.1.0:compile
[INFO] com.comarch.p7bundles:spring-web:jar:2.5.5:compile
[INFO] com.comarch.p7bundles:wicket-all:jar:1.3.4.014:compile
[INFO] com.comarch.p7tools:unit-test-support:jar:0.14:test
[INFO] jdepend:jdepend:jar:2.9.1:test
[INFO] junit:junit:jar:4.4:test
[INFO] org.aspectj:org.aspectj.osgi:jar:1.1.0.200803102211:compile
[INFO] org.easymock:easymock:jar:2.3:test
[INFO] org.easymock:easymockclassextension:jar:2.3:test
[INFO] org.eclipse:osgi:jar:3.3.2.R33x_v20080105:compile

I cleaned my local maven2 repository, and after executing sonar:
javancss:javancss is downloaded in version 29.50 only
org.codehaus.mojo:javancss-maven-plugin is downloaded in version 2.0-beta-2 only

hope this helps

Show
Wojciech Durczynski added a comment - 07/Jul/08 8:57 AM sonar-pom.xml of the module that fails can be found here: http://ds5.agh.edu.pl/~avatar/sonar/ui-core/sonar-pom.xml dependency:list executed there prints: [INFO] [dependency:list] [INFO] [INFO] The following files have been resolved: [INFO] cglib:cglib-nodep:jar:2.1_3:test [INFO] com.comarch.p7:spec:jar:0.4-SNAPSHOT:compile [INFO] com.comarch.p7:wicket-core:jar:0.4-SNAPSHOT:compile [INFO] com.comarch.p7bundles:cglib-nodep:jar:2.1.3.014:compile [INFO] com.comarch.p7bundles:commons-beanutils:jar:1.7.0.014:compile [INFO] com.comarch.p7bundles:commons-collections:jar:3.2.0.014:compile [INFO] com.comarch.p7bundles:commons-lang:jar:2.2.0.014:compile [INFO] com.comarch.p7bundles:findbugs-annotations:jar:1.3.3.014:compile [INFO] com.comarch.p7bundles:jsr305:jar:1.3.3.014:compile [INFO] com.comarch.p7bundles:pax-logging-api:jar:1.1.1:compile [INFO] com.comarch.p7bundles:pax-web-service:jar:0.5.0.014:compile [INFO] com.comarch.p7bundles:spring-beans:jar:2.5.5:compile [INFO] com.comarch.p7bundles:spring-context:jar:2.5.5:compile [INFO] com.comarch.p7bundles:spring-core:jar:2.5.5:compile [INFO] com.comarch.p7bundles:spring-osgi-core:jar:1.1.0:compile [INFO] com.comarch.p7bundles:spring-web:jar:2.5.5:compile [INFO] com.comarch.p7bundles:wicket-all:jar:1.3.4.014:compile [INFO] com.comarch.p7tools:unit-test-support:jar:0.14:test [INFO] jdepend:jdepend:jar:2.9.1:test [INFO] junit:junit:jar:4.4:test [INFO] org.aspectj:org.aspectj.osgi:jar:1.1.0.200803102211:compile [INFO] org.easymock:easymock:jar:2.3:test [INFO] org.easymock:easymockclassextension:jar:2.3:test [INFO] org.eclipse:osgi:jar:3.3.2.R33x_v20080105:compile I cleaned my local maven2 repository, and after executing sonar: javancss:javancss is downloaded in version 29.50 only org.codehaus.mojo:javancss-maven-plugin is downloaded in version 2.0-beta-2 only hope this helps
Hide
Permalink
Simon Brandhof added a comment - 07/Jul/08 9:34 AM

That sounds incredible. I'm sure that JavaNcss 29.50 resolves this bug. It works for us when parsing the class http://svn.codehaus.org/sonar/trunk/samples/utf8-sample/src/main/java/org/sonar/samples/utf8/HelloSwiss.java. It 's exactly the same use of @Deprecated tag.
Can you also check versions of javancss/jhbasic and javancss/ccl from your local repository ?

Show
Simon Brandhof added a comment - 07/Jul/08 9:34 AM That sounds incredible. I'm sure that JavaNcss 29.50 resolves this bug. It works for us when parsing the class http://svn.codehaus.org/sonar/trunk/samples/utf8-sample/src/main/java/org/sonar/samples/utf8/HelloSwiss.java. It 's exactly the same use of @Deprecated tag. Can you also check versions of javancss/jhbasic and javancss/ccl from your local repository ?
Hide
Permalink
Wojciech Durczynski added a comment - 07/Jul/08 10:08 AM

javancss:jhbasic and javancss:ccl were downloaded in version 29.50 only.

Notice one difference: HelloSwiss is a class and RequestParamMarkers is an interface. Maybe this matters?

Show
Wojciech Durczynski added a comment - 07/Jul/08 10:08 AM javancss:jhbasic and javancss:ccl were downloaded in version 29.50 only. Notice one difference: HelloSwiss is a class and RequestParamMarkers is an interface. Maybe this matters?
Hide
Permalink
Simon Brandhof added a comment - 07/Jul/08 10:31 AM

You're right. The problem is only on interfaces. This is unfortunatly a JavaNCSS bug. So it will be long before getting a fix... I contact the javancss team.
Another issue is created for this problem : SONAR-312.

Show
Simon Brandhof added a comment - 07/Jul/08 10:31 AM You're right. The problem is only on interfaces. This is unfortunatly a JavaNCSS bug. So it will be long before getting a fix... I contact the javancss team. Another issue is created for this problem : SONAR-312.
Hide
Permalink
Simon Brandhof added a comment - 07/Jul/08 10:32 AM

Thank you Wojciech for all your help.

Show
Simon Brandhof added a comment - 07/Jul/08 10:32 AM Thank you Wojciech for all your help.

People

  • Assignee:
    Simon Brandhof
    Reporter:
    Simon Brandhof
Vote (3)
Watch (1)

Dates

  • Created:
    18/Dec/07 3:17 AM
    Updated:
    07/Jul/08 10:32 AM
    Resolved:
    30/Jun/08 7:30 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.