2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
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
10 * http://www.apache.org/licenses/LICENSE-2.0.
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.
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;
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
39 * the only local functionality is that instances register themselves automatically
40 * as property when the search is started
42 * <2do> rewrite once GenericProperty is an interface
44 public abstract class PropertyListenerAdapter extends GenericProperty implements
45 SearchListener, VMListener, PublisherExtension {
47 //--- Property interface
49 public boolean check(Search search, VM vm) {
50 // return false if property is violated
55 public void reset () {
56 // override if the property has any local state
60 public Property clone() throws CloneNotSupportedException {
64 //--- the VMListener interface
66 public void vmInitialized(VM vm) {}
68 public void instructionExecuted(VM vm, ThreadInfo currentThread, Instruction nextInstruction, Instruction executedInstruction) {}
70 public void executeInstruction(VM vm, ThreadInfo currentThread, Instruction instructionToExecute) {}
72 public void threadStarted(VM vm, ThreadInfo startedThread) {}
74 public void threadWaiting (VM vm, ThreadInfo waitingThread) {}
76 public void threadNotified (VM vm, ThreadInfo notifiedThread) {}
78 public void threadInterrupted (VM vm, ThreadInfo interruptedThread) {}
80 public void threadScheduled (VM vm, ThreadInfo scheduledThread) {}
82 public void threadBlocked (VM vm, ThreadInfo blockedThread, ElementInfo lock) {}
84 public void threadTerminated(VM vm, ThreadInfo terminatedThread) {}
86 public void loadClass (VM vm, ClassFile cf) {}
88 public void classLoaded(VM vm, ClassInfo loadedClass) {}
90 public void objectCreated(VM vm, ThreadInfo currentThread, ElementInfo newObject) {}
92 public void objectReleased(VM vm, ThreadInfo currentThread, ElementInfo releasedObject) {}
94 public void objectLocked (VM vm, ThreadInfo currentThread, ElementInfo lockedObject) {}
96 public void objectUnlocked (VM vm, ThreadInfo currentThread, ElementInfo unlockedObject) {}
98 public void objectWait (VM vm, ThreadInfo currentThread, ElementInfo waitingObject) {}
100 public void objectNotify (VM vm, ThreadInfo currentThread, ElementInfo notifyingObject) {}
102 public void objectNotifyAll (VM vm, ThreadInfo currentThread, ElementInfo notifyingObject) {}
104 public void objectExposed (VM vm, ThreadInfo currentThread, ElementInfo fieldOwnerObject, ElementInfo exposedObject) {}
106 public void objectShared (VM vm, ThreadInfo currentThread, ElementInfo sharedObject) {}
108 public void gcBegin(VM vm) {}
110 public void gcEnd(VM vm) {}
112 public void exceptionThrown(VM vm, ThreadInfo currentThread, ElementInfo thrownException) {}
114 public void exceptionBailout(VM vm, ThreadInfo currentThread) {}
116 public void exceptionHandled(VM vm, ThreadInfo currentThread) {}
118 public void choiceGeneratorRegistered (VM vm, ChoiceGenerator<?> nextCG, ThreadInfo currentThread, Instruction executedInstruction) {}
120 public void choiceGeneratorSet (VM vm, ChoiceGenerator<?> newCG) {}
122 public void choiceGeneratorAdvanced (VM vm, ChoiceGenerator<?> currentCG) {}
124 public void choiceGeneratorProcessed (VM vm, ChoiceGenerator<?> processedCG) {}
126 public void methodEntered (VM vm, ThreadInfo currentThread, MethodInfo enteredMethod) {}
128 public void methodExited (VM vm, ThreadInfo currentThread, MethodInfo exitedMethod) {}
131 //--- the SearchListener interface
133 public void stateAdvanced(Search search) {}
135 public void stateProcessed(Search search) {}
137 public void stateBacktracked(Search search) {}
139 public void statePurged(Search search) {}
141 public void stateStored(Search search) {}
143 public void stateRestored(Search search) {}
145 public void searchProbed (Search search){}
147 public void propertyViolated(Search search) {}
149 public void searchStarted(Search search) {
150 search.addProperty(this);
153 public void searchConstraintHit(Search search) {}
155 public void searchFinished(Search search) {}
158 //--- PublisherExtension interface
160 public void publishStart (Publisher publisher) {}
162 public void publishTransition (Publisher publisher) {}
164 public void publishPropertyViolation (Publisher publisher) {}
166 public void publishConstraintHit (Publisher publisher) {}
168 public void publishFinished (Publisher publisher) {}
170 public void publishProbe (Publisher publisher) {}