You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org> on 2010/01/16 21:40:55 UTC

[jira] Closed: (MNG-4529) maven fails on IBM JDK 1.5.0 with exception IllegalAccessException: Field is final

     [ http://jira.codehaus.org/browse/MNG-4529?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann closed MNG-4529.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 3.0-alpha-7
         Assignee: Benjamin Bentmann

Fixed in [r900021|http://svn.apache.org/viewvc?view=revision&revision=900021].

And now for the fun part: This is the code at StringSearchModelInterpolator.java:189:
{code:java}
if ( !interpolated.equals( value ) )
{
    fields[i].set( target, interpolated );
}
{code}
i.e. a field is only set if its value actually changed. The original value for the field {{Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE}} is "combine.children", and this is also the interpolated value... In plain English, this issue shows up on the IBM JDK only because it manages to reach a state where it considers two strings with the contents "combine.children" not equal, making it execute an otherwise unreachable code path.

> maven fails on IBM JDK 1.5.0 with exception IllegalAccessException: Field is final
> ----------------------------------------------------------------------------------
>
>                 Key: MNG-4529
>                 URL: http://jira.codehaus.org/browse/MNG-4529
>             Project: Maven 2 & 3
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>         Environment: Windows XP, IBM JDK 1.5.0
>            Reporter: Thai Ha
>            Assignee: Benjamin Bentmann
>             Fix For: 3.0-alpha-7
>
>         Attachments: ibm.output.txt, myapp.zip, sun.output.txt
>
>
> On Windows XP, and IBM JDK 1.5.0, maven 2.2.1 fails with the exception IllegalAccessException: Field is final. (See the complete stacktrace is at the end)
> How to duplicate:
> 1. (IMPORTANT) Delete maven local repository at <user home>\.m2\repository directory completely!
> 2. Unzip myapp.zip
> 3. Run command "mvn package -e"
> More info:
> The exception will happen when maven trying to set value to some static final fields. Re-run the command will see another new exception (old exception will not happend again). If you try maven in debug mode (to debug it with Eclipse), the exception will NOT appear. The complete information about maven, JDK, etc. are in the attached file: ibm.output.txt. The other output file (sun.output.txt) is the successful result when running using Sun JDK 1.5.0
> Root cause:
> In StringSearchModelInterpolator.java of maven 2.2.1, there is a code snippet that tries to using Reflection to change values of fields (even if the fields are final)
> Line 175: 
>   fields[i].setAccessible( true );
> Line 189:
>   fields[i].set( target, interpolated );
> If fields[i] is a final field, on Sun JDK 1.5.0, the operation is successful but on IBM JDK 1.5.0, an exception will be thrown. 
> ================ Complete stacktrace ==========================
> org.apache.maven.lifecycle.LifecycleExecutionException: Unable to build project for plugin 'org.apache.maven.plugins:maven-compiler-plugin': Failed to interpolate field: public static final java.lang.String org.codehaus.plexus.util.xml.Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE on class: org.codehaus.plexus.util.xml.Xpp3Dom for project unknown:maven-compiler-plugin at Artifact [org.apache.maven.plugins:maven-compiler-plugin:pom:2.0.2]
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1557)
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindLifecycleForPackaging(DefaultLifecycleExecutor.java:1311)
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappings(DefaultLifecycleExecutor.java:1275)
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:534)
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
> 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
> 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
> 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
> 	at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:615)
> 	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.InvalidPluginException: Unable to build project for plugin 'org.apache.maven.plugins:maven-compiler-plugin': Failed to interpolate field: public static final java.lang.String org.codehaus.plexus.util.xml.Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE on class: org.codehaus.plexus.util.xml.Xpp3Dom for project unknown:maven-compiler-plugin at Artifact [org.apache.maven.plugins:maven-compiler-plugin:pom:2.0.2]
> 	at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:293)
> 	at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:205)
> 	at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:184)
> 	at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
> 	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
> 	... 19 more
> Caused by: org.apache.maven.project.InvalidProjectModelException: Failed to interpolate field: public static final java.lang.String org.codehaus.plexus.util.xml.Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE on class: org.codehaus.plexus.util.xml.Xpp3Dom for project unknown:maven-compiler-plugin at Artifact [org.apache.maven.plugins:maven-compiler-plugin:pom:2.0.2]
> 	at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:884)
> 	at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:255)
> 	at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:277)
> 	... 23 more
> Caused by: org.apache.maven.project.interpolation.ModelInterpolationException: Failed to interpolate field: public static final java.lang.String org.codehaus.plexus.util.xml.Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE on class: org.codehaus.plexus.util.xml.Xpp3Dom
> 	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.traverseObjectWithParents(StringSearchModelInterpolator.java:318)
> 	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.run(StringSearchModelInterpolator.java:135)
> 	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.run(StringSearchModelInterpolator.java:102)
> 	at java.security.AccessController.doPrivileged(AccessController.java:192)
> 	at org.apache.maven.project.interpolation.StringSearchModelInterpolator.interpolateObject(StringSearchModelInterpolator.java:80)
> 	at org.apache.maven.project.interpolation.StringSearchModelInterpolator.interpolate(StringSearchModelInterpolator.java:62)
> 	at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:990)
> 	at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880)
> 	... 25 more
> Caused by: java.lang.IllegalAccessException: Field is final
> 	at sun.reflect.UnsafeQualifiedStaticObjectFieldAccessorImpl.set(UnsafeQualifiedStaticObjectFieldAccessorImpl.java:77)
> 	at java.lang.reflect.Field.set(Field.java:684)
> 	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.traverseObjectWithParents(StringSearchModelInterpolator.java:189)
> 	... 32 more

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