[
http://jira.codehaus.org/browse/JANINO-117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Arno Unkrig resolved JANINO-117.
--------------------------------
Resolution: Won't Fix
However, I have bad news for you: I removed your fix. The reason being is that in Java there is no such thing as a "byte literal" or "short literal". "new Literal(new Byte(8))" worked only accidentially!
But Java's conversion rules (JLS2 5.2) imply that you can legally assign an integer literal to, say, a byte variable, if the constant value of the integer literal is in range:
byte a = 3;
byte b = -128;
I added an argument type check to "Literal(Object)" which throws IllegalArgumentExceptions.
> UnparseVisitor does not handle Byte or Short Literals
> -----------------------------------------------------
>
> Key: JANINO-117
> URL:
http://jira.codehaus.org/browse/JANINO-117> Project: Janino
> Issue Type: Bug
> Reporter: Matt Fowles
> Assignee: Arno Unkrig
> Fix For: 2.5.15
>
> Attachments: literals.diff
>
>
> The following test will fail with a RuntimeException. While parsed java cannot create a literal Byte or Short value, it is fairly easy to create them directly from the AST, and handling them is quite simple.
> {code}
> public void testLiterals() throws Exception {
> Object[][] tests = new Object[][] {
> { new Java.Literal(null, new Short((short)1)), "((short)1)" },
> { new Java.Literal(null, new Byte((byte)1)), "((byte)1)" },
> };
> for(int i = 0; i < tests.length; ++i) {
> Atom expr = (Atom) tests[i][0];
> String expected = (String) tests[i][1];
>
> StringWriter sw = new StringWriter();
> UnparseVisitor uv = new UnparseVisitor(sw);
> expr.accept(uv);
> Assert.assertEquals(expected, sw.toString());
> }
> }
> {code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email