//
// This file is part of the prose package.
//
// The contents of this file are subject to the Mozilla Public License
// Version 1.1 (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.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is prose.
//
// The Initial Developer of the Original Code is Angela Nicoara. Portions
// created by Angela Nicoara are Copyright (C) 2004 Angela Nicoara.
// All Rights Reserved.
//
// Contributor(s):
// $Id: HotSwapFieldAccessJoinPointImpl.java,v 1.2 2008/11/18 11:09:31 anicoara Exp $
// =====================================================================
//
package ch.ethz.inf.iks.jvmai.jvmdi;
import java.lang.reflect.Field;
import ch.ethz.jvmai.FieldAccessJoinPoint;
import ch.ethz.jvmai.JVMAIRuntimeException;
/**
* Concrete implementation of a FieldAccessJoinPoint for the hotswap advice weaving.
*
* @author Angela Nicoara
* @author Gerald Linhofer
* @version $Revision: 1.2 $
*/
public class HotSwapFieldAccessJoinPointImpl extends HotSwapFieldJoinPointImpl implements FieldAccessJoinPoint {
HotSwapFieldAccessJoinPointImpl() {
super();
}
HotSwapFieldAccessJoinPointImpl( Object aopTag, int fieldId, Object owner ) {
super( aopTag, fieldId, owner );
}
public String getKind() {
return FieldAccessJoinPoint.KIND;
}
public int getMask() {
return MASK_CODE_JP | MASK_FIELD_JP | MASK_FIELD_ACCESS_JP;
}
public void setValue(Object newValue) {
value = newValue;
Field f = getField();
// Make the field accessible if it's private or protected.
// There's no reset after access, because repeated
// accesses to this field are very likely.
if( ! f.isAccessible() );
f.setAccessible( true );
try { f.set( owner, value ); }
// If this handler is reached, something went wrong at
// the f.isAccessible() or f.setAccessible() call above.
catch( IllegalAccessException e ) { throw new JVMAIRuntimeException("Illigal field access: this should never happen"); }
}
}