Models initialization of system thread group, main thread group, main thread, and some Thread APIs.
| 51 | * main thread, and some Thread APIs. |
| 52 | */ |
| 53 | public class ThreadHandler implements Plugin { |
| 54 | |
| 55 | private Solver solver; |
| 56 | |
| 57 | private ClassHierarchy hierarchy; |
| 58 | |
| 59 | /** |
| 60 | * This variable of Thread.start(). |
| 61 | */ |
| 62 | private Var threadStartThis; |
| 63 | |
| 64 | /** |
| 65 | * Set of running threads. |
| 66 | */ |
| 67 | private PointsToSet runningThreads; |
| 68 | |
| 69 | /** |
| 70 | * Represent Thread.currentThread. |
| 71 | */ |
| 72 | private JMethod currentThread; |
| 73 | |
| 74 | /** |
| 75 | * Return variable of Thread.currentThread(). |
| 76 | */ |
| 77 | private Var currentThreadReturn; |
| 78 | |
| 79 | /** |
| 80 | * Contexts of Thread.currentThread(). |
| 81 | */ |
| 82 | private final Set<Context> currentThreadContexts = Sets.newHybridSet(); |
| 83 | |
| 84 | @Override |
| 85 | public void setSolver(Solver solver) { |
| 86 | this.solver = solver; |
| 87 | runningThreads = solver.makePointsToSet(); |
| 88 | hierarchy = solver.getHierarchy(); |
| 89 | threadStartThis = requireNonNull( |
| 90 | hierarchy.getJREMethod("<java.lang.Thread: void start()>")) |
| 91 | .getIR() |
| 92 | .getThis(); |
| 93 | currentThread = hierarchy.getJREMethod( |
| 94 | "<java.lang.Thread: java.lang.Thread currentThread()>"); |
| 95 | currentThreadReturn = getOne(requireNonNull(currentThread) |
| 96 | .getIR() |
| 97 | .getReturnVars()); |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public void onStart() { |
| 102 | if (!solver.getOptions().getBoolean("implicit-entries")) { |
| 103 | return; |
| 104 | } |
| 105 | TypeSystem typeSystem = solver.getTypeSystem(); |
| 106 | HeapModel heapModel = solver.getHeapModel(); |
| 107 | |
| 108 | // setup system thread group |
| 109 | JMethod threadGroupInit = requireNonNull( |
| 110 | hierarchy.getJREMethod("<java.lang.ThreadGroup: void <init>()>")); |
nothing calls this directly
no test coverage detected