01: //
02: // This file is part of the prose package.
03: //
04: // The contents of this file are subject to the Mozilla Public License
05: // Version 1.1 (the "License"); you may not use this file except in
06: // compliance with the License. You may obtain a copy of the License at
07: // http://www.mozilla.org/MPL/
08: //
09: // Software distributed under the License is distributed on an "AS IS" basis,
10: // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11: // for the specific language governing rights and limitations under the
12: // License.
13: //
14: // The Original Code is prose.
15: //
16: // Contributor(s):
17: // $Id$
18: // =====================================================================
19: //
20: // (history at end)
21: //
22:
23: package ch.ethz.inf.iks.jvmai.jvmdi;
24:
25: import java.lang.reflect.Field;
26: import ch.ethz.jvmai.FieldAccessJoinPoint;
27: import ch.ethz.jvmai.JVMAIRuntimeException;
28:
29: /**
30: * Concrete implementation of a FieldAccessJoinPoint for the hotswap advice weaving.
31: *
32: * @author Angela Nicoara
33: * @author Gerald Linhofer
34: * @version $Revision: 1.1.2.2 $
35: */
36: public class HotSwapFieldAccessJoinPointImpl extends
37: HotSwapFieldJoinPointImpl implements FieldAccessJoinPoint {
38:
39: HotSwapFieldAccessJoinPointImpl() {
40: super ();
41: }
42:
43: HotSwapFieldAccessJoinPointImpl(Object aopTag, int fieldId,
44: Object owner) {
45: super (aopTag, fieldId, owner);
46: }
47:
48: public String getKind() {
49: return FieldAccessJoinPoint.KIND;
50: }
51:
52: public int getMask() {
53: return MASK_CODE_JP | MASK_FIELD_JP | MASK_FIELD_ACCESS_JP;
54: }
55:
56: public void setValue(Object newValue) {
57: value = newValue;
58: Field f = getField();
59: // Make the field accessible if it's private or protected.
60: // There's no reset after access, because repeated
61: // accessses to this field are very likely.
62: if (!f.isAccessible())
63: ;
64: f.setAccessible(true);
65: try {
66: f.set(owner, value);
67: }
68: // If this handler is reached, something went wrong at
69: // the f.isAccessible() or f.setAccessible() call above.
70: catch (IllegalAccessException e) {
71: throw new JVMAIRuntimeException(
72: "Illigal field access: this should never happen");
73: }
74: }
75:
76: }
77:
78: //======================================================================
79: //
80: //$Log$
81: //
|