@@ -17,18 +17,32 @@ public class Context { //FIXME clinit classes
1717 public Provider provider ;
1818 public Map <String , ClassNode > dictionary ;
1919 public Map <ClassNode , ConstantPool > constantPools ;
20- public final Map <AbstractInsnNode , BiFunction <List <JavaValue >, Context , JavaValue >> customMethodFunc = new HashMap <>();
21- public final ThreadStore threadStore = new ThreadStore ();
22- public final Monitor monitor = new Monitor ();
20+ public Map <AbstractInsnNode , BiFunction <List <JavaValue >, Context , JavaValue >> customMethodFunc = new HashMap <>();
21+ public ThreadStore threadStore = new ThreadStore ();
22+ public Monitor monitor = new Monitor ();
2323
24- public Set <String > clinit = new HashSet <>();
24+ public Set <String > clinit = Collections . synchronizedSet ( new HashSet <>() );
2525
2626 public File file ;
2727
2828 public Context (Provider provider ) {
2929 this .provider = provider ;
3030 }
3131
32+ public Context copyForNewThread () {
33+ Context threadContext = new Context (provider );
34+ threadContext .dictionary = dictionary ;
35+ threadContext .constantPools = constantPools ;
36+ threadContext .customMethodFunc = customMethodFunc ;
37+ threadContext .threadStore = threadStore ;
38+ threadContext .monitor = monitor ;
39+ threadContext .clinit = clinit ;
40+ threadContext .file = file ;
41+ threadContext .breakpointsBefore = breakpointsBefore ;
42+ threadContext .breakpointsAfter = breakpointsAfter ;
43+ return threadContext ;
44+ }
45+
3246 public StackTraceElement at (int index ) {
3347 return stackTrace .get (index );
3448 }
@@ -64,8 +78,8 @@ public void clearStackTrace() {
6478 stackTrace .clear ();
6579 }
6680
67- private final Map <AbstractInsnNode , Consumer <BreakpointInfo >> breakpointsBefore = new HashMap <>();
68- private final Map <AbstractInsnNode , Consumer <BreakpointInfo >> breakpointsAfter = new HashMap <>();
81+ private Map <AbstractInsnNode , Consumer <BreakpointInfo >> breakpointsBefore = new HashMap <>();
82+ private Map <AbstractInsnNode , Consumer <BreakpointInfo >> breakpointsAfter = new HashMap <>();
6983
7084 public void doBreakpoint (AbstractInsnNode now , boolean before , List <JavaValue > stack , List <JavaValue > locals , Object tothrow ) {
7185 if (before && breakpointsBefore .containsKey (now )) {
0 commit comments