From d143bdb57d7738ba9e9d998f94cc9f152a16e50a Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Sun, 29 Oct 2017 13:01:02 +0000
Subject: [PATCH 1/4] TestUtils: add getPrivateStaticField in the same vein as
 getPrivateField only accepting a Class object argument

---
 test/unit/org/openstreetmap/josm/TestUtils.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/test/unit/org/openstreetmap/josm/TestUtils.java b/test/unit/org/openstreetmap/josm/TestUtils.java
index 4717f3d48..a26038337 100644
--- a/test/unit/org/openstreetmap/josm/TestUtils.java
+++ b/test/unit/org/openstreetmap/josm/TestUtils.java
@@ -170,6 +170,22 @@ public final class TestUtils {
     }
 
     /**
+     * Returns a private static field value.
+     * @param obj object
+     * @param fieldName private field name
+     * @return private field value
+     * @throws ReflectiveOperationException if a reflection operation error occurs
+     */
+    public static Object getPrivateStaticField(Class<?> cls, String fieldName) throws ReflectiveOperationException {
+        Field f = cls.getDeclaredField(fieldName);
+        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+            f.setAccessible(true);
+            return null;
+        });
+        return f.get(null);
+    }
+
+    /**
      * Returns an instance of {@link AbstractProgressMonitor} which keeps track of the monitor state,
      * but does not show the progress.
      * @return a progress monitor
-- 
2.11.0

