[janino-dev] [jira] Created: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

View: New views
8 Messages — Rating Filter:   Alert me  

[janino-dev] [jira] Created: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
         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



[janino-dev] [jira] Resolved: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ http://jira.codehaus.org/browse/JANINO-117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Arno Unkrig resolved JANINO-117.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.5.15

Applied the patch.

Please test.

> 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



[janino-dev] [jira] Commented: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=138756#action_138756 ]

Matt Fowles commented on JANINO-117:
------------------------------------

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.

> 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



[janino-dev] [jira] Commented: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=138959#action_138959 ]

Arno Unkrig commented on JANINO-117:
------------------------------------

I see. This is not compatible with my understanding of the JIRA standard workflow.

> 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



[janino-dev] [jira] Reopened: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ http://jira.codehaus.org/browse/JANINO-117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Arno Unkrig reopened JANINO-117:
--------------------------------


> 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



[janino-dev] [jira] Resolved: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ 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



[janino-dev] [jira] Reopened: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ http://jira.codehaus.org/browse/JANINO-117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Fowles reopened JANINO-117:
--------------------------------


I would strongly urge you to reconsider this choice.  While Java does not allow byte literals directly, making your AST support them increases the expressive power of your library, without exposing any bugs.

In fact, this ability greatly simplifies targeting Janino's AST from a different compiler, which is exactly what we are doing.

> 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



[jira] Commented: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/JANINO-117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=179471#action_179471 ]

Matt Fowles commented on JANINO-117:
------------------------------------

You can find a fixed version of this at http://code.google.com/p/janino-streambase/

> 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