Fix compatibility with JDK9

Cast runtime object retrieved reflectively to their public interface
counterpart.

See gh-7226
This commit is contained in:
Stephane Nicoll
2016-11-28 11:30:34 +01:00
parent a6f9e5b9fe
commit e15b3e463f
4 changed files with 8 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ class ExpressionTree extends ReflectionWrapper {
"getInitializers");
ExpressionTree(Object instance) {
super(instance);
super("com.sun.source.tree.ExpressionTree", instance);
}
public String getKind() throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,14 +31,9 @@ class ReflectionWrapper {
private final Object instance;
ReflectionWrapper(Object instance) {
this.type = instance.getClass();
this.instance = instance;
}
ReflectionWrapper(String type, Object instance) {
this.type = findClass(instance.getClass().getClassLoader(), type);
this.instance = instance;
this.instance = this.type.cast(instance);
}
protected final Object getInstance() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import javax.lang.model.element.Element;
final class Trees extends ReflectionWrapper {
private Trees(Object instance) {
super(instance);
super("com.sun.source.util.Trees", instance);
}
public Tree getTree(Element element) throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import javax.lang.model.element.Modifier;
class VariableTree extends ReflectionWrapper {
VariableTree(Object instance) {
super(instance);
super("com.sun.source.tree.VariableTree", instance);
}
public String getName() throws Exception {