Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
The following unit test will fail to compile. If the return value is changed to simply "SelfRef.class" everything works fine.
public void testAccessingCompilingClass() throws Exception {
SimpleCompiler sc = new SimpleCompiler();
sc.cook("package test.simple;" +
"public class SelfRef {" +
" public Class getSelf() {" +
" return test.simple.SelfRef.class;" +
" }" +
"}"
);
Class self = sc.getClassLoader().loadClass("test.simple.SelfRef");
Method m = self.getDeclaredMethod("getSelf", null);
Object inst = self.newInstance();
Class res = (Class)m.invoke(inst, null);
assertEquals(self, res);
}
This patch fixes the issue and adds a test for it to EvaluatorTest.java
It also factors some of the duplicated code in UnitCompiler.java into helper methods, which I did while coming to understand the code and the problem better.