Janino

Fully Qualified .class access fails to compile

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    1

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);
}

Activity

Hide
Matt Fowles added a comment -

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.

Show
Matt Fowles added a comment - 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.
Hide
Arno Unkrig added a comment -

That patch will go into the next release of JANINO.

Show
Arno Unkrig added a comment - That patch will go into the next release of JANINO.
Hide
Matt Fowles added a comment -

Arno, I do not have the ability to close this issue. I think my login to Jira does not have the power. You can consider this closed.

Show
Matt Fowles added a comment - Arno, I do not have the ability to close this issue. I think my login to Jira does not have the power. You can consider this closed.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: