Skip to content

Commit f2ea691

Browse files
committed
Minor cleanup
1 parent b2eb816 commit f2ea691

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

key.core/src/main/java/de/uka/ilkd/key/util/HelperClassForTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: GPL-2.0-only */
44
package de.uka.ilkd.key.util;
55

6+
import java.lang.reflect.Field;
67
import java.nio.file.Path;
78
import java.util.HashMap;
89
import java.util.Map;
@@ -290,4 +291,10 @@ public static KeYEnvironment<DefaultUserInterfaceControl> createKeYEnvironment()
290291
return KeYEnvironment.load(DUMMY_KEY_FILE);
291292
}
292293

294+
public static Field getPrivateField(Object o, String fieldName) throws NoSuchFieldException {
295+
final Field field = o.getClass().getDeclaredField(fieldName);
296+
field.setAccessible(true);
297+
return field;
298+
}
299+
293300
}

key.core/src/test/java/de/uka/ilkd/key/proof/replay/TestCopyingReplayer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import de.uka.ilkd.key.proof.Counter;
1414
import de.uka.ilkd.key.proof.Proof;
1515
import de.uka.ilkd.key.settings.GeneralSettings;
16+
import de.uka.ilkd.key.util.HelperClassForTests;
1617

1718
import org.key_project.util.helper.FindResources;
1819

@@ -40,8 +41,8 @@ public void resetCounters(Proof proof) {
4041
}
4142

4243
try {
43-
final Field countersField = proof.getServices().getClass().getDeclaredField("counters");
44-
countersField.setAccessible(true);
44+
final Field countersField =
45+
HelperClassForTests.getPrivateField(proof.getServices(), "counters");
4546
// noinspection unchecked
4647
((HashMap<String, Counter>) countersField.get(proof.getServices())).clear();
4748
} catch (NoSuchFieldException | IllegalAccessException e) {

0 commit comments

Comments
 (0)