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

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u20
    • 8
    • javafx
    • None

      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.

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

              Created:
              Updated:
              Resolved:
              Imported: