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

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@900021 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-01-16 20:31:38 +00:00
parent 5a51823501
commit 03a383e30e
2 changed files with 66 additions and 0 deletions

View File

@ -32,6 +32,7 @@ import org.codehaus.plexus.interpolation.ValueSource;
import java.io.File;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@ -329,6 +330,11 @@ public class StringSearchModelInterpolator
return false;
}
if ( Modifier.isFinal( field.getModifiers() ) )
{
return false;
}
return true;
}

View File

@ -0,0 +1,60 @@
package org.apache.maven.model.interpolation;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.util.Properties;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.DefaultModelBuildingRequest;
import org.apache.maven.model.building.SimpleProblemCollector;
import junit.framework.TestCase;
/**
* @author Benjamin Bentmann
*/
public class StringSearchModelInterpolatorTest
extends TestCase
{
public void testFinalFieldsExcludedFromInterpolation()
{
Properties props = new Properties();
props.setProperty( "expression", "value" );
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setUserProperties( props );
SimpleProblemCollector problems = new SimpleProblemCollector();
StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator();
interpolator.interpolateObject( new ClassWithFinalField(), new Model(), null, request, problems );
assertTrue( problems.getFatals().toString(), problems.getFatals().isEmpty() );
assertTrue( problems.getErrors().toString(), problems.getErrors().isEmpty() );
assertTrue( problems.getWarnings().toString(), problems.getWarnings().isEmpty() );
}
static class ClassWithFinalField
{
public static final String CONSTANT = "${expression}";
}
}