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

ProxyBuilder cannot handle Read-Only List Properties properly

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b01
    • Introduced In Version:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Linux yushijinhun-laptop 4.15.0-21-generic #22-Ubuntu SMP Tue May 1 13:26:51 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

      openjdk version "1.8.0_171"
      OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
      OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      ProxyBuilder doesn't take Read-Only List Properties into consideration, which causes only the first element is added to the list while others are stripped.

      I wrote a more detailed description here: https://gist.github.com/yushijinhun/87abb48d605b1a519f714349da043837

      The bug appears in 8u152 but does not appear in 8u151.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a java bean.
      2. Add a parameterized constructor to the bean, the parameter is annotated by @NamedArg.
      3. Add a read-only list property to the bean.
      4. Load an FXML which declares the bean and adds more than one elements to its list property.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The list property contains more then one element.
      ACTUAL -
      The list property contains only one element.

      ---------- BEGIN SOURCE ----------
      test/Test.java:
      package test;

      import java.io.IOException;
      import javafx.beans.NamedArg;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.fxml.FXMLLoader;

      public class Test {

      private ObservableList<String> listProp = FXCollections.observableArrayList();

      public Test() {}

      // The problem is solved after the constructor is commented
      public Test(@NamedArg("stringProp") String stringProp) {}
      //

      public ObservableList<String> getListProp() {
      return listProp;
      }

      public static void main(String[] args) throws IOException {
      Test region = new FXMLLoader(Test.class.getResource("/test.fxml")).load();

      System.out.println("listProp: " + region.listProp);

      if (region.listProp.size() == 2) {
      System.out.println("Problem did not appear");
      } else {
      System.out.println("Problem appeared");
      }
      }
      }

      test.fxml:
      <?xml version="1.0" encoding="UTF-8"?>
      <?import test.Test?>
      <?import java.lang.String?>

      <Test xmlns:fx="http://javafx.com/fxml">
      <listProp>
      <String fx:value="elementA"/>
      <String fx:value="elementB"/>
      </listProp>
      </Test>

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Do not use @NamedArg in the constructor. (do not do step 2)

      FREQUENCY : always


        Attachments

        1. test.fxml
          0.2 kB
        2. Test.java
          0.9 kB

          Activity

            People

            Assignee:
            kcr Kevin Rushforth
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: