Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8094816

[Bindings] wrong calculation of operator priority in com.sun.javafx.fxml.expression.Expression.getPriority

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:
      None
    • Environment:
    • Subcomponent:

      Description

      For correct calculation of operator priority in expressions, there must be a differentiation between NEGATE and SUBTRACT (both use "-" as value), which isn't possible based on the supplied argument to the method getPriority(String operator) in class com.sun.javafx.fxml.expression.Expression. Therefore the priority for an BINARY_OPERATOR -> SUBTRACT will be calculated to the same priority like UNARY_OPERATOR -> NEGATE and UNARY_OPERATOR -> NOT (highest priority), which is wrong. Example:
      ${7.0 * 0.4 - 2 * 3.5} should evaluate to -4.2 with following tokens (inside method parse after tokenize)
      7.0, 0.4, 2, 3.5, *, *, -
      but is
      7.0, 0.4, 2, 3.5, *, -, * because of wrong priority
      and calculates to 46.199999, which is the wrong result.

      Instead of using String constants for operators it would be better to use an enum, which encapsulates the tokens and use the enum for priority calculation.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              msladecek Martin Sládeček
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: