001: //
002: //This file is part of the prose package.
003: //
004: //The contents of this file are subject to the Mozilla Public License
005: //Version 1.1 (the "License"); you may not use this file except in
006: //compliance with the License. You may obtain a copy of the License at
007: //http://www.mozilla.org/MPL/
008: //
009: //Software distributed under the License is distributed on an "AS IS" basis,
010: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011: //for the specific language governing rights and limitations under the
012: //License.
013: //
014: //The Original Code is prose.
015: //
016: //Contributor(s):
017: //$Id$
018: //=====================================================================
019: //
020: //(history at end)
021: //
022:
023: package ch.ethz.inf.iks.jvmai.jvmdi;
024:
025: import ch.ethz.jvmai.FieldModificationJoinPoint;
026:
027: /**
028: * Concrete implementation of a FieldModificationJoinPoint for the hotswap advice weaving.
029: *
030: * @author Angela Nicoara
031: * @author Gerald Linhofer
032: * @version $Revision$
033: */
034: public class HotSwapFieldModificationJoinPointImpl extends
035: HotSwapFieldJoinPointImpl implements FieldModificationJoinPoint {
036:
037: int newValueSlot;
038:
039: /**
040: * Constructs an uninitialized instance.
041: * To use it {@link #init} must be called
042: * after construction.
043: */
044: HotSwapFieldModificationJoinPointImpl() {
045: super ();
046: newValueSlot = -1;
047: }
048:
049: /**
050: * Constructs an initialized instance.
051: * @param tag AOP tag associated with this join point.
052: * @param slot variable table index of target fields new value.
053: * @param fieldId unique numerical identifier for the target field.
054: * @param owner Object owning the field.
055: */
056: HotSwapFieldModificationJoinPointImpl(Object tag, int slot,
057: int fieldId, Object Owner) {
058: super (tag, fieldId, Owner);
059: newValueSlot = slot;
060: }
061:
062: /**
063: * Initializes this instance.
064: * @param tag AOP tag associated with this join point.
065: * @param slot variable table index of target fields new value.
066: * @param fieldId unique numerical identifier for the target field.
067: * @param owner Object owning the field.
068: */
069: public void init(Object tag, int slot, int fieldId, Object owner) {
070: newValueSlot = slot;
071: super .init(tag, fieldId, owner);
072: }
073:
074: public String getKind() {
075: return FieldModificationJoinPoint.KIND;
076: }
077:
078: public int getMask() {
079: return MASK_CODE_JP | MASK_FIELD_JP
080: | MASK_FIELD_MODIFICATION_JP;
081: }
082:
083: /**
084: * Returns the value that will be assigned to the target field. Primitive
085: * types will be wrapped in a java object.
086: *
087: * @return Object the new value for the field
088: * @throws ch.ethz.jvmai.IlligalIdException can not find methods stack frame
089: */
090: public Object getNewValue() {
091: return doGetLocalVar(newValueSlot, encodeArgType(getField()
092: .getType()), Thread.currentThread(), height);
093: }
094:
095: /**
096: * Changes the value that will be assigned to the target field.
097: *
098: * @param newValue the new value for the field.
099: * @throws ch.ethz.jvmai.IlligalIdException can not find methods stack frame
100: */
101: public void setNewValue(Object newValue) {
102: doSetLocalVar(newValueSlot,
103: encodeArgType(getField().getType()), newValue, Thread
104: .currentThread(), height);
105: }
106:
107: }
108:
109: //======================================================================
110: //
111: //$Log$
112: //
|