Anil Rasouli created GROOVY-9719:
------------------------------------
Summary: Class loading issue when class has annotation referenced
to a nested class
Key: GROOVY-9719
URL: https://issues.apache.org/jira/browse/GROOVY-9719
Project: Groovy
Issue Type: Bug
Affects Versions: 2.4.3
Reporter: Anil Rasouli
A MultipleCompilationErrorsException is thrown when we try to load a class that
has a reference to a nested class via annotation.
Here a small example:
We have two classes class A and B. Class A has a reference to the nested class
of class B (NestedInB) in the annotation. Class A can not be loaded except the
annotation is removed.
{code:java}
package pkg2
import pkg1.B
class A {
@SuppressWarnings(value = [B.NestedInB.NestedProp])
A() {
String name = B.NestedInB.class.getName();
System.out.println(name);
System.out.println(B.NestedInB.NestedProp);
}
}
{code}
{code:java}
package pkg1
import pkg2.A
public class B {
public static final String Prop = "ABCD";
B() {
A a = new A()
}
public static class NestedInB {
public static final String NestedProp = "ABCD";
}
}
{code}
{code:java}
@Test
public void test2() throws Exception {
final File mainDirectory = new File("Path to the class A and B");
URL url = mainDirectory.getAbsoluteFile().toURI().toURL();
groovyClassLoader.addURL(url);
groovyClassLoader.addClasspath(mainDirectory.getPath());
final Class<?> a = groovyClassLoader.loadClass("pkg2.A");
a.newInstance();
assertNotNull(a);
}
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)