@SuppressWarning("unused") causes compilation error.
----------------------------------------------------

                 Key: MNG-5089
                 URL: http://jira.codehaus.org/browse/MNG-5089
             Project: Maven 2 & 3
          Issue Type: Bug
          Components: General
    Affects Versions: 3.0, 2.0.11
         Environment: windows xp sp3, Linux 2.6.9
maven 3.0 and 2.0.11
IBM(R) 32-bit SDK for Windows(R), Java(TM) 2  Technology Edition, Version 5.0
surefire plugin + junit
            Reporter: Jerzy Zagórski


@SuppressWarning("unused") causes compilation error. TestCase compiles just 
fine when running it from Eclipse project. When trying to run it from maven it 
causes following error:

trace:
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] An exception has occurred in the compiler (1.5.0). Please file a bug at
the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after che
cking the Bug Parade for duplicates. Include your program and the following diag
nostic in your report.  Thank you.
[ERROR] java.lang.AssertionError: {unused}
[ERROR] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.visitArray(TreeM
aker.java:655)
[ERROR] at com.sun.tools.javac.code.Attribute$Array.accept(Attribute.java:151)
[ERROR] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.translate(TreeMa
ker.java:658)
[ERROR] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.visitCompoundInt
ernal(TreeMaker.java:649)
[ERROR] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.translate(TreeMa
ker.java:662)
[ERROR] at com.sun.tools.javac.tree.TreeMaker.Annotation(TreeMaker.java:670)
[ERROR] at com.sun.tools.javac.tree.TreeMaker.Annotations(TreeMaker.java:591)
[ERROR] at com.sun.tools.javac.tree.TreeMaker.VarDef(TreeMaker.java:575)
[ERROR] at com.sun.tools.javac.comp.Lower.visitIterableForeachLoop(Lower.java:29
19)
[ERROR] at com.sun.tools.javac.comp.Lower.visitForeachLoop(Lower.java:2782)
[ERROR] at com.sun.tools.javac.tree.Tree$ForeachLoop.accept(Tree.java:618)
[ERROR] at com.sun.tools.javac.comp.Lower.translate(Lower.java:1909)
[ERROR] at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java
:66)
[ERROR] at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.jav
a:157)
[ERROR] at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:2954)
[ERROR] at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:556)
[ERROR] at com.sun.tools.javac.comp.Lower.translate(Lower.java:1909)
[ERROR] at com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator
.java:141)
[ERROR] at com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2294
)
[ERROR] at com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2213)
[ERROR] at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:499)
[ERROR] at com.sun.tools.javac.comp.Lower.translate(Lower.java:1909)
[ERROR] at com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:2017)
[ERROR] at com.sun.tools.javac.tree.Tree$ClassDef.accept(Tree.java:455)
[ERROR] at com.sun.tools.javac.comp.Lower.translate(Lower.java:1909)
[ERROR] at com.sun.tools.javac.comp.Lower.translate(Lower.java:1929)
[ERROR] at com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:3091
)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:523)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:605)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:557)
[ERROR] at com.sun.tools.javac.Main.compile(Main.java:122)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:79)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:618)
[ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(Jav
acCompiler.java:554)
[ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompile
r.java:161)
[ERROR] at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompiler
Mojo.java:605)
[ERROR] at org.apache.maven.plugin.TestCompilerMojo.execute(TestCompilerMojo.jav
a:161)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:107)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:195)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:148)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:140)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:79)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:618)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption

code causing error:
{code:title=SampleTest .java|borderStyle=solid}
import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

public class SampleTest extends TestCase{

        public void testSuppressWarnings() {
                List<Integer> objects = new ArrayList<Integer>();
                
                for (@SuppressWarnings("unused") Object object: objects) {
                        fail();
                }
        }
}
{code} 

-- 
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