From ac97131907336dc18470bcd57678880c1b6ba0af 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
|
b
|
public final class TestUtils {
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| | 173 | * Returns a private static field value. |
| | 174 | * @param obj object |
| | 175 | * @param fieldName private field name |
| | 176 | * @return private field value |
| | 177 | * @throws ReflectiveOperationException if a reflection operation error occurs |
| | 178 | */ |
| | 179 | public static Object getPrivateStaticField(Class<?> cls, String fieldName) throws ReflectiveOperationException { |
| | 180 | Field f = cls.getDeclaredField(fieldName); |
| | 181 | AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
| | 182 | f.setAccessible(true); |
| | 183 | return null; |
| | 184 | }); |
| | 185 | return f.get(null); |
| | 186 | } |
| | 187 | |
| | 188 | /** |
| 173 | 189 | * Returns an instance of {@link AbstractProgressMonitor} which keeps track of the monitor state, |
| 174 | 190 | * but does not show the progress. |
| 175 | 191 | * @return a progress monitor |