Menu

#73 implied constant promotion aborts compilation

All_releases
closed-fixed
5
2004-12-29
2004-12-28
Anonymous
No

public class O
{
public void m() { long l = 5; }
}

Compiling this class with Janino 2.1.0 using Sun's
1.4.2_06-b03 JVM under Windows results in the
compilation being aborted with this error message:

java.lang.RuntimeException: O.m(): Operand stack
underrun at offset 1

Putting "5L" at the right-hand side of the equals sign
compiles. Looks like Janino doesn't promote the
constant "5" from its default type (int) to the needed
type (long), or something.

Discussion

  • Arno Unkrig

    Arno Unkrig - 2004-12-29
    • status: open --> closed-fixed
     
  • Arno Unkrig

    Arno Unkrig - 2004-12-29

    Logged In: YES
    user_id=865893

    The assignment conversion was missing for local variable
    initializers. No problem for byte/short/char/int, but if the
    variable or the initialzer have type long/float/double, then
    you get JVM errors.

    Not good programming style to write "double x = 0", eh? ;-)

    Added assignment conversion. Will be fixed in the next
    (post-2.1.0) release; not scheduled yet.

     
  • Nobody/Anonymous

    Logged In: NO

    Others have also seen this:
    http://jira.codehaus.org/browse/DROOLS-252
    (on double-typed variables)

     
  • Nobody/Anonymous

    Logged In: NO

    > Will be fixed in the next (post-2.1.0) release; not
    scheduled yet.

    Could you attach a patch here in the meantime? Thanks.

     
  • Nobody/Anonymous

    Logged In: NO

    > Will be fixed in the next (post-2.1.0) release; not
    scheduled yet.

    Could you attach a patch here in the meantime? Thanks.

     
  • Arno Unkrig

    Arno Unkrig - 2004-12-29
     
  • Arno Unkrig

    Arno Unkrig - 2004-12-29

    Logged In: YES
    user_id=865893

    No problem, here's your patch.

     

Log in to post a comment.

MongoDB Logo MongoDB