|
8 | 8 | import java.lang.reflect.Modifier;
|
9 | 9 | import java.util.ArrayList;
|
10 | 10 | import java.util.Collection;
|
| 11 | +import java.util.Comparator; |
11 | 12 | import java.util.HashMap;
|
12 | 13 | import java.util.List;
|
13 | 14 | import java.util.Map;
|
@@ -167,8 +168,10 @@ void build(List<StaticBytecodeRecorderBuildItem> staticInitTasks,
|
167 | 168 | mv.invokeStaticMethod(ofMethod(DisabledInitialContextManager.class, "register", void.class));
|
168 | 169 | }
|
169 | 170 |
|
170 |
| - //very first thing is to set system props (for build time) |
171 |
| - for (SystemPropertyBuildItem i : properties) { |
| 171 | + // very first thing is to set system props (for build time) |
| 172 | + // make sure we record the system properties in order for build reproducibility |
| 173 | + for (SystemPropertyBuildItem i : properties.stream().sorted(Comparator.comparing(SystemPropertyBuildItem::getKey)) |
| 174 | + .toList()) { |
172 | 175 | mv.invokeStaticMethod(ofMethod(System.class, "setProperty", String.class, String.class, String.class),
|
173 | 176 | mv.load(i.getKey()), mv.load(i.getValue()));
|
174 | 177 | }
|
@@ -219,9 +222,11 @@ void build(List<StaticBytecodeRecorderBuildItem> staticInitTasks,
|
219 | 222 | mv.setModifiers(Modifier.PROTECTED | Modifier.FINAL);
|
220 | 223 |
|
221 | 224 | // Make sure we set properties in doStartup as well. This is necessary because setting them in the static-init
|
222 |
| - // sets them at build-time, on the host JVM, while SVM has substitutions for System. get/ setProperty at |
| 225 | + // sets them at build-time, on the host JVM, while SVM has substitutions for System. get/setProperty at |
223 | 226 | // run-time which will never see those properties unless we also set them at run-time.
|
224 |
| - for (SystemPropertyBuildItem i : properties) { |
| 227 | + // make sure we record the system properties in order for build reproducibility |
| 228 | + for (SystemPropertyBuildItem i : properties.stream().sorted(Comparator.comparing(SystemPropertyBuildItem::getKey)) |
| 229 | + .toList()) { |
225 | 230 | mv.invokeStaticMethod(ofMethod(System.class, "setProperty", String.class, String.class, String.class),
|
226 | 231 | mv.load(i.getKey()), mv.load(i.getValue()));
|
227 | 232 | }
|
|
0 commit comments