001 package edu.rice.cs.cunit.record.syncPoints.object;
002
003 import edu.rice.cs.cunit.record.graph.LockInfo;
004 import edu.rice.cs.cunit.record.graph.ThreadInfo;
005 import edu.rice.cs.cunit.record.syncPoints.ISyncPoint;
006 import edu.rice.cs.cunit.instrumentors.DoNotInstrument;
007
008 /**
009 * General class for object-related synchronization points.
010 * @author Mathias Ricken
011 */
012 @DoNotInstrument
013 public abstract class AObjectSyncPoint implements ISyncPoint {
014 /**
015 * Object that whose method was called.
016 */
017 protected final Object _object;
018
019 /**
020 * Current thread.
021 */
022 protected final Thread _thread;
023
024 /**
025 * Constructor for this synchronization point.
026 * @param object object whose method was called.
027 * @param thread current thread
028 */
029 public AObjectSyncPoint(Object object, Thread thread) {
030 _object = object;
031 _thread = thread;
032 }
033
034 /**
035 * Class for translated versions on the monitor side.
036 */
037 public static abstract class Translated implements ISyncPoint.Translated {
038 /**
039 * Info about the object.
040 */
041 LockInfo _lockInfo;
042
043 /**
044 * Info about the current thread.
045 */
046 ThreadInfo _threadInfo;
047
048 /**
049 * Constructor for translated version on the monitor side.
050 * @param lockInfo info about the object
051 */
052 public Translated(LockInfo lockInfo, ThreadInfo threadInfo) {
053 _lockInfo = lockInfo;
054 _threadInfo = threadInfo;
055 }
056
057 /**
058 * Returns the info about the object.
059 * @return lock info
060 */
061 public LockInfo getLockInfo() {
062 return _lockInfo;
063 }
064
065 /**
066 * Returns the info about the current thread.
067 * @return current thread info
068 */
069 public ThreadInfo getThreadInfo() {
070 return _threadInfo;
071 }
072
073 /**
074 * Returns a string representation of the object.
075 * @return a string representation of the object.
076 */
077 public String toString() {
078 return this.getClass().getEnclosingClass().getSimpleName()+": LockInfo={"+_lockInfo+"} ThreadInfo={"+_threadInfo+"}";
079 }
080 }
081 }