File tree 1 file changed +21
-0
lines changed
ssvm-core/src/main/java/dev/xdark/ssvm
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 60
60
import java .util .Map ;
61
61
import java .util .TreeMap ;
62
62
import java .util .concurrent .atomic .AtomicReference ;
63
+ import java .util .function .Consumer ;
63
64
64
65
public class VirtualMachine implements VMEventCollection {
65
66
@@ -94,6 +95,26 @@ public class VirtualMachine implements VMEventCollection {
94
95
private volatile InstanceValue mainThreadGroup ;
95
96
96
97
public VirtualMachine () {
98
+ this (null );
99
+ }
100
+
101
+ /**
102
+ * Constructor for running some logic operating on {@code this}
103
+ * before the VM internals are initialized.
104
+ * <p/>
105
+ * This allows sub-classes to set field values <i>(though non-final)</i>
106
+ * which can then be used in the {@code createX} method implementations.
107
+ * The consumer allows us to act on {@code this} <i>"before the super
108
+ * constructor call".</i>
109
+ *
110
+ * @param consumer
111
+ * Consumer to run before the VM internals are initialized.
112
+ * @param <V>
113
+ * Self type.
114
+ */
115
+ @ SuppressWarnings ("unchecked" )
116
+ public <V extends VirtualMachine > VirtualMachine (Consumer <V > consumer ) {
117
+ if (consumer != null ) consumer .accept ((V ) this );
97
118
properties = createSystemProperties ();
98
119
env = createEnvironmentVariables ();
99
120
vmInterface = createVMInterface ();
You can’t perform that action at this time.
0 commit comments