[ 
http://jira.codehaus.org/browse/MPMD-58?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_117941
 ] 

Xavier Le Vourch commented on MPMD-58:
--------------------------------------

Dennis,

The byte order mark in your example is a problem on Linux. In fact, the code 
doesn't compile as is even when the encoding for javac is set to UTF-8 is 
specified in pom.xml.

When I remove the marker, everything is fine. According to wikipedia 
(http://en.wikipedia.org/wiki/Byte-order_mark), the use is not encouraged for 
UTF-8 files on Linux.

BTW, I didn't really reproduce the original problem when testing my patch but 
the encoding is picked up and an error is displayed if the encoding is invalid. 
Also the original problem is not related to the byte order marker but appears 
later on during the parsing.
 

> sourceEncoding honoured with pmd but not cpd
> --------------------------------------------
>
>                 Key: MPMD-58
>                 URL: http://jira.codehaus.org/browse/MPMD-58
>             Project: Maven 2.x PMD Plugin
>          Issue Type: Bug
>          Components: CPD
>    Affects Versions: 2.2
>         Environment: Linux,
> LC_LANG=en
> LC_ALL=POSIX
>            Reporter: M. Rohrmoser
>         Attachments: MPMD-58.zip, MPMD-58_sourceEncoding.txt
>
>
> If the source (*.java) contains non-Ascii Characters, e.g. in field names, 
> pmd:check works fine but pmd:cpd-check fails with the stacktrace
> [INFO] Trace
> org.apache.maven.lifecycle.LifecycleExecutionException: An error has occurred 
> in CPD Report report generation.
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:898)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:734)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:505)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:488)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:458)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at 
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> Caused by: org.apache.maven.plugin.MojoExecutionException: An error has 
> occurred in CPD Report report generation.
>         at 
> org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:79)
>         at 
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
>         ... 19 more
> Caused by: net.sourceforge.pmd.ast.TokenMgrError: Lexical error at line 32, 
> column 33.  Encountered: "\ufffd" (65533), after : ""
>         at 
> net.sourceforge.pmd.ast.JavaParserTokenManager.getNextToken(JavaParserTokenManager.java:2037)
>         at 
> net.sourceforge.pmd.cpd.JavaTokenizer.tokenize(JavaTokenizer.java:69)
>         at net.sourceforge.pmd.cpd.CPD.add(CPD.java:97)
>         at net.sourceforge.pmd.cpd.CPD.add(CPD.java:50)
>         at 
> org.apache.maven.plugin.pmd.CpdReport.executeReport(CpdReport.java:102)
>         at 
> org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:98)
>         at 
> org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:73)
>         ... 21 more
> The pom is:
> <project>
> ...
>       <reporting>
>               <plugins>
>                       <plugin>
>                               <groupId>org.apache.maven.plugins</groupId>
>                               <artifactId>maven-pmd-plugin</artifactId>
>                               <configuration>
>                                       <verbose>true</verbose>
>                                       <linkXref>true</linkXref>
>                                       <sourceEncoding>utf-8</sourceEncoding>
>                                       <minimumTokens>100</minimumTokens>
>                                       <targetJdk>1.5</targetJdk>
>                                       <excludes>
>                                       </excludes>
>                               </configuration>
>                       </plugin>
>               </plugins>
>       </reporting>
> ...
> </project>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to