Skip to content

Commit 765c358

Browse files
author
TheSnoozer
authored
Merge pull request #308 from TheSnoozer/master
fixes for oraclejdk9
2 parents e4c7f11 + 51c9f48 commit 765c358

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
language: java
22
sudo: false
3+
dist: trusty
34
jdk:
5+
- oraclejdk9
46
- oraclejdk8
57
- openjdk7

pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
<jgit.version>4.5.2.201704071617-r</jgit.version>
6161
<junit.version>4.12</junit.version>
62-
<mockito.version>2.0.35-beta</mockito.version>
62+
<mockito.version>2.8.47</mockito.version>
6363

6464
<fest-assert.version>1.4</fest-assert.version>
6565
</properties>
@@ -234,7 +234,7 @@
234234
</plugin>
235235
<plugin>
236236
<artifactId>maven-jar-plugin</artifactId>
237-
<version>2.6</version>
237+
<version>3.0.2</version>
238238
</plugin>
239239
<plugin>
240240
<artifactId>maven-plugin-plugin</artifactId>
@@ -293,6 +293,11 @@
293293
-->
294294
</executions>
295295
</plugin>
296+
297+
<plugin>
298+
<groupId>org.apache.maven.plugins</groupId>
299+
<artifactId>maven-jar-plugin</artifactId>
300+
</plugin>
296301
</plugins>
297302
</build>
298303

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.mockito.internal.util.reflection;
2+
3+
import java.lang.reflect.Field;
4+
5+
@Deprecated
6+
public class Whitebox {
7+
public static void setInternalState(Object target, String field, Object value) {
8+
Class<?> c = target.getClass();
9+
try {
10+
Field f = getFieldFromHierarchy(c, field);
11+
f.setAccessible(true);
12+
f.set(target, value);
13+
} catch (Exception e) {
14+
throw new RuntimeException("Unable to set internal state on a private field. Please report to mockito mailing list.", e);
15+
}
16+
}
17+
18+
private static Field getFieldFromHierarchy(Class<?> clazz, String field) {
19+
Field f = getField(clazz, field);
20+
while (f == null && clazz != Object.class) {
21+
clazz = clazz.getSuperclass();
22+
f = getField(clazz, field);
23+
}
24+
if (f == null) {
25+
throw new RuntimeException(
26+
"You want me to get this field: '" + field +
27+
"' on this class: '" + clazz.getSimpleName() +
28+
"' but this field is not declared withing hierarchy of this class!");
29+
}
30+
return f;
31+
}
32+
33+
private static Field getField(Class<?> clazz, String field) {
34+
try {
35+
return clazz.getDeclaredField(field);
36+
} catch (NoSuchFieldException e) {
37+
return null;
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)