Skip to content

Commit e15b3e4

Browse files
committed
Fix compatibility with JDK9
Cast runtime object retrieved reflectively to their public interface counterpart. See gh-7226
1 parent a6f9e5b commit e15b3e4

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/ExpressionTree.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ class ExpressionTree extends ReflectionWrapper {
4747
"getInitializers");
4848

4949
ExpressionTree(Object instance) {
50-
super(instance);
50+
super("com.sun.source.tree.ExpressionTree", instance);
5151
}
5252

5353
public String getKind() throws Exception {

spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/ReflectionWrapper.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,14 +31,9 @@ class ReflectionWrapper {
3131

3232
private final Object instance;
3333

34-
ReflectionWrapper(Object instance) {
35-
this.type = instance.getClass();
36-
this.instance = instance;
37-
}
38-
3934
ReflectionWrapper(String type, Object instance) {
4035
this.type = findClass(instance.getClass().getClassLoader(), type);
41-
this.instance = instance;
36+
this.instance = this.type.cast(instance);
4237
}
4338

4439
protected final Object getInstance() {

spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
3030
final class Trees extends ReflectionWrapper {
3131

3232
private Trees(Object instance) {
33-
super(instance);
33+
super("com.sun.source.util.Trees", instance);
3434
}
3535

3636
public Tree getTree(Element element) throws Exception {

spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
3030
class VariableTree extends ReflectionWrapper {
3131

3232
VariableTree(Object instance) {
33-
super(instance);
33+
super("com.sun.source.tree.VariableTree", instance);
3434
}
3535

3636
public String getName() throws Exception {

0 commit comments

Comments
 (0)