Cleaning up DPORStateReducer.java
[jpf-core.git] / src / main / gov / nasa / jpf / PropertyListenerAdapter.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18 package gov.nasa.jpf;
19
20 import gov.nasa.jpf.jvm.ClassFile;
21 import gov.nasa.jpf.report.Publisher;
22 import gov.nasa.jpf.report.PublisherExtension;
23 import gov.nasa.jpf.search.Search;
24 import gov.nasa.jpf.search.SearchListener;
25 import gov.nasa.jpf.vm.ChoiceGenerator;
26 import gov.nasa.jpf.vm.ClassInfo;
27 import gov.nasa.jpf.vm.ElementInfo;
28 import gov.nasa.jpf.vm.Instruction;
29 import gov.nasa.jpf.vm.MethodInfo;
30 import gov.nasa.jpf.vm.ThreadInfo;
31 import gov.nasa.jpf.vm.VM;
32 import gov.nasa.jpf.vm.VMListener;
33
34 /**
35  * abstract base class that dummy implements Property, Search- and VMListener methods
36  * convenient for creating listeners that act as properties, just having to override
37  * the methods they need
38  *
39  * the only local functionality is that instances register themselves automatically
40  * as property when the search is started
41  *
42  * <2do> rewrite once GenericProperty is an interface
43  */
44 public abstract class PropertyListenerAdapter extends GenericProperty implements
45     SearchListener, VMListener, PublisherExtension {
46
47   //--- Property interface
48   @Override
49   public boolean check(Search search, VM vm) {
50     // return false if property is violated
51     return true;
52   }
53
54   @Override
55   public void reset () {
56     // override if the property has any local state
57   }
58
59   @Override
60   public Property clone() throws CloneNotSupportedException {
61     return super.clone();
62   }
63   
64 //--- the VMListener interface
65   @Override
66   public void vmInitialized(VM vm) {}
67   @Override
68   public void instructionExecuted(VM vm, ThreadInfo currentThread, Instruction nextInstruction, Instruction executedInstruction) {}
69   @Override
70   public void executeInstruction(VM vm, ThreadInfo currentThread, Instruction instructionToExecute) {}
71   @Override
72   public void threadStarted(VM vm, ThreadInfo startedThread) {}
73   @Override
74   public void threadWaiting (VM vm, ThreadInfo waitingThread) {}
75   @Override
76   public void threadNotified (VM vm, ThreadInfo notifiedThread) {}
77   @Override
78   public void threadInterrupted (VM vm, ThreadInfo interruptedThread) {}
79   @Override
80   public void threadScheduled (VM vm, ThreadInfo scheduledThread) {}
81   @Override
82   public void threadBlocked (VM vm, ThreadInfo blockedThread, ElementInfo lock) {}
83   @Override
84   public void threadTerminated(VM vm, ThreadInfo terminatedThread) {}
85   @Override
86   public void loadClass (VM vm, ClassFile cf) {}
87   @Override
88   public void classLoaded(VM vm, ClassInfo loadedClass) {}
89   @Override
90   public void objectCreated(VM vm, ThreadInfo currentThread, ElementInfo newObject) {}
91   @Override
92   public void objectReleased(VM vm, ThreadInfo currentThread, ElementInfo releasedObject) {}
93   @Override
94   public void objectLocked (VM vm, ThreadInfo currentThread, ElementInfo lockedObject) {}
95   @Override
96   public void objectUnlocked (VM vm, ThreadInfo currentThread, ElementInfo unlockedObject) {}
97   @Override
98   public void objectWait (VM vm, ThreadInfo currentThread, ElementInfo waitingObject) {}
99   @Override
100   public void objectNotify (VM vm, ThreadInfo currentThread, ElementInfo notifyingObject) {}
101   @Override
102   public void objectNotifyAll (VM vm, ThreadInfo currentThread, ElementInfo notifyingObject) {}
103   @Override
104   public void objectExposed (VM vm, ThreadInfo currentThread, ElementInfo fieldOwnerObject, ElementInfo exposedObject) {}
105   @Override
106   public void objectShared (VM vm, ThreadInfo currentThread, ElementInfo sharedObject) {}
107   @Override
108   public void gcBegin(VM vm) {}
109   @Override
110   public void gcEnd(VM vm) {}
111   @Override
112   public void exceptionThrown(VM vm, ThreadInfo currentThread, ElementInfo thrownException) {}
113   @Override
114   public void exceptionBailout(VM vm, ThreadInfo currentThread) {}
115   @Override
116   public void exceptionHandled(VM vm, ThreadInfo currentThread) {}
117   @Override
118   public void choiceGeneratorRegistered (VM vm, ChoiceGenerator<?> nextCG, ThreadInfo currentThread, Instruction executedInstruction) {}
119   @Override
120   public void choiceGeneratorSet (VM vm, ChoiceGenerator<?> newCG) {}
121   @Override
122   public void choiceGeneratorAdvanced (VM vm, ChoiceGenerator<?> currentCG) {}
123   @Override
124   public void choiceGeneratorProcessed (VM vm, ChoiceGenerator<?> processedCG) {}
125   @Override
126   public void methodEntered (VM vm, ThreadInfo currentThread, MethodInfo enteredMethod) {}
127   @Override
128   public void methodExited (VM vm, ThreadInfo currentThread, MethodInfo exitedMethod) {}
129
130
131   //--- the SearchListener interface
132   @Override
133   public void stateAdvanced(Search search) {}
134   @Override
135   public void stateProcessed(Search search) {}
136   @Override
137   public void stateBacktracked(Search search) {}
138   @Override
139   public void statePurged(Search search) {}
140   @Override
141   public void stateStored(Search search) {}
142   @Override
143   public void stateRestored(Search search) {}
144   @Override
145   public void searchProbed (Search search){}
146   @Override
147   public void propertyViolated(Search search) {}
148   @Override
149   public void searchStarted(Search search) {
150     search.addProperty(this);
151   }
152   @Override
153   public void searchConstraintHit(Search search) {}
154   @Override
155   public void searchFinished(Search search) {}
156
157
158   //--- PublisherExtension interface
159   @Override
160   public void publishStart (Publisher publisher) {}
161   @Override
162   public void publishTransition (Publisher publisher) {}
163   @Override
164   public void publishPropertyViolation (Publisher publisher) {}
165   @Override
166   public void publishConstraintHit (Publisher publisher) {}
167   @Override
168   public void publishFinished (Publisher publisher) {}
169   @Override
170   public void publishProbe (Publisher publisher) {}
171 }