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: HotSwapMethodJoinPointImpl.java,v 1.1.2.1 2004/08/10 19:37:38 lgerald Exp $
018: //=====================================================================
019: //
020: //(history at end)
021: //
022:
023: package ch.ethz.inf.iks.jvmai.jvmdi;
024:
025: import java.lang.reflect.Method;
026:
027: /**
028: * Super class for method entry/exit join points (method execution join points).
029: *
030: * @author Angela Nicoara
031: * @author Gerald Linhofer
032: * @version $Revision$
033: */
034: public abstract class HotSwapMethodJoinPointImpl extends
035: HotSwapJoinPointImpl {
036:
037: /**
038: * Method identifier to which this join point belongs.
039: * (this has nothing to do with JNI jmethodIDs)
040: */
041: protected int methodId;
042:
043: /**
044: * Constructs an uninitialized instance.
045: * To use it {@link #init} must be called
046: * after construction.
047: */
048: HotSwapMethodJoinPointImpl() {
049: super ();
050: }
051:
052: /**
053: * Constructs an initialized instance.
054: * @param id method identifier to which this join point belongs
055: * @param tag AOP tag associated with this join point
056: */
057: HotSwapMethodJoinPointImpl(int id, Object tag) {
058: super (tag, 0);
059: methodId = id;
060: }
061:
062: /**
063: * (Re)Initialize this join point.
064: *
065: * @param id method identifier to which this join point belongs
066: * @param tag AOP tag associated with this join point
067: */
068: public void init(int id, Object tag) {
069: methodId = id;
070: super .init(tag);
071: }
072:
073: /**
074: * Returns the object the join point target belongs to.
075: * For method entry and exit join points this returns
076: * the same like {@link #getThis getThis()}.
077: *
078: * @return Object
079: * @throws IlligalIdException can not find the stack frame of the 'target'.
080: */
081: public Object getTarget() {
082: return getThis();
083: }
084:
085: /**
086: * Returns the method to that this join point belongs.
087: * <P>
088: * Overwrites the method of the super class with a
089: * faster implementation for method join points.
090: *
091: * @return Method reflected method or null if the
092: * method is a constructor.
093: */
094: public Method getMethod() {
095: if (null == method) {
096: method = (Method) HotSwapClassWeaver.idToMethod(methodId);
097: }
098: return method;
099: }
100:
101: }
102:
103: //======================================================================
104: //
105: //$Log$
106: //
|