Commit e15b3e46 authored by Stephane Nicoll's avatar Stephane Nicoll

Fix compatibility with JDK9

Cast runtime object retrieved reflectively to their public interface
counterpart.

See gh-7226
parent a6f9e5b9
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -47,7 +47,7 @@ class ExpressionTree extends ReflectionWrapper { ...@@ -47,7 +47,7 @@ class ExpressionTree extends ReflectionWrapper {
"getInitializers"); "getInitializers");
ExpressionTree(Object instance) { ExpressionTree(Object instance) {
super(instance); super("com.sun.source.tree.ExpressionTree", instance);
} }
public String getKind() throws Exception { public String getKind() throws Exception {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,14 +31,9 @@ class ReflectionWrapper { ...@@ -31,14 +31,9 @@ class ReflectionWrapper {
private final Object instance; private final Object instance;
ReflectionWrapper(Object instance) {
this.type = instance.getClass();
this.instance = instance;
}
ReflectionWrapper(String type, Object instance) { ReflectionWrapper(String type, Object instance) {
this.type = findClass(instance.getClass().getClassLoader(), type); this.type = findClass(instance.getClass().getClassLoader(), type);
this.instance = instance; this.instance = this.type.cast(instance);
} }
protected final Object getInstance() { protected final Object getInstance() {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -30,7 +30,7 @@ import javax.lang.model.element.Element; ...@@ -30,7 +30,7 @@ import javax.lang.model.element.Element;
final class Trees extends ReflectionWrapper { final class Trees extends ReflectionWrapper {
private Trees(Object instance) { private Trees(Object instance) {
super(instance); super("com.sun.source.util.Trees", instance);
} }
public Tree getTree(Element element) throws Exception { public Tree getTree(Element element) throws Exception {
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -30,7 +30,7 @@ import javax.lang.model.element.Modifier; ...@@ -30,7 +30,7 @@ import javax.lang.model.element.Modifier;
class VariableTree extends ReflectionWrapper { class VariableTree extends ReflectionWrapper {
VariableTree(Object instance) { VariableTree(Object instance) {
super(instance); super("com.sun.source.tree.VariableTree", instance);
} }
public String getName() throws Exception { public String getName() throws Exception {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment