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: // The Initial Developer of the Original Code is Andrei Popovici. Portions
017: // created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018: // All Rights Reserved.
019: //
020: // Contributor(s):
021: // $Id: FieldAccessJoinPointImpl.java,v 1.1.1.1 2003/07/02 15:30:50 apopovic Exp $
022: // =====================================================================
023: //
024: // (history at end)
025: //
026:
027: package ch.ethz.inf.iks.jvmai.jvmdi;
028:
029: // used packages/classes
030: import ch.ethz.jvmai.FieldAccessJoinPoint;
031:
032: /**
033: * Class FieldAccessJoinPoint represents a joinpoint where
034: * a field is accessed. This class does not provide any new
035: * fields or methods.
036: *
037: * @version $Revision: 1.1.1.1 $
038: * @author Stephan Markwalder
039: * @author Andrei Popovici
040: */
041: public class FieldAccessJoinPointImpl extends FieldJoinPointImpl
042: implements FieldAccessJoinPoint {
043:
044: public FieldAccessJoinPointImpl(ControlFlow cf, JoinPointContext ctx) {
045: super (cf, ctx);
046: }
047:
048: public String getKind() {
049: return FieldAccessJoinPoint.KIND;
050: }
051:
052: public int getMask() {
053: return MASK_CODE_JP | MASK_FIELD_JP | MASK_FIELD_ACCESS_JP;
054: }
055:
056: /**
057: * Changes the value of the field.
058: *
059: * @param value new value of the field. If the field
060: * holds a primitive type value, the new value must
061: * be wrapped in instance of the java class for this type.
062: * @throws SecurityException SecurityManager denies access to this field.
063: * @throws IllegalArgumentException unwrapping conversion to primitive type failed.
064: * @throws NullPointerException can not find owner object (only non static fields).
065: * @throws ExceptionInInitializerError the initialization provoked by this method fails.
066: */
067: public void setValue(Object value) {
068: if (!field.isAccessible())
069: field.setAccessible(true);
070: try {
071: field.set(getTarget(), value);
072: }
073: // The exception should never be thrown, instead the setAccessible
074: // call above throws a SecurityException, if the field is not accessible.
075: catch (IllegalAccessException e) {
076: throw new RuntimeException(e);
077: }
078: }
079:
080: }
081:
082: //======================================================================
083: //
084: // $Log: FieldAccessJoinPointImpl.java,v $
085: // Revision 1.1.1.1 2003/07/02 15:30:50 apopovic
086: // Imported from ETH Zurich
087: //
088: // Revision 1.4 2003/05/05 17:46:24 popovici
089: // Refactorization step (runes->prose) cleanup
090: //
091: // Revision 1.3 2003/04/17 08:47:03 popovici
092: // Important functionality additions
093: // - Cflow specializers
094: // - Restructuring of the MethodCut, SetCut, ExceptionCut, and GetCut (they are much smaller)
095: // - Transactional capabilities
096: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
097: // between static and dynamic specializers.
098: // - Functionality pulled up in abstract classes
099: // - Uniformization of advice methods patterns and names
100: //
101: // Revision 1.2 2003/03/04 16:09:33 popovici
102: // Documentation improvements
103: //
104: // Revision 1.1 2003/03/04 11:26:33 popovici
105: // Important refactorization step (march):
106: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
107: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
108: // structures
109: //
110: // Revision 1.4 2002/03/28 13:48:25 popovici
111: // Mozilla-ified
112: //
113: // Revision 1.3 2002/02/13 12:24:25 smarkwal
114: // spaces/tabs alignment corrected
115: //
116: // Revision 1.2 2002/01/24 12:46:22 smarkwal
117: // comments added
118: //
119: // Revision 1.1 2001/12/14 15:01:14 smarkwal
120: // Initial Revision
121: //
|