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

The FXMLLoader should detect fx:include cycle and throw an exception when cycles are detected.

    XMLWordPrintable

Details

    Description

      When loading an FXML that includes itself, or loading an FXML A that includes B that includes C that includes A, the FXMLLoader goes in an active loop that eventually stops with an OutOfMemoryError (I've seen a StackOverflowError in SceneBuilder).

      The FXMLLoader should detect the cycle and throws an exception instead. A dedicated exception giving information about the cycle would be preferable.

      The attached zip contains several files that have cycles - dummy-cycle.fxml includes itself.
      master.fxml includes cycler.fxml includes vector.fxml includes cycler.fxml.

      Loading any of those triggers the issue.

      Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
      at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
      at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
      at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
      at java.lang.Class.privateGetPublicMethods(Class.java:2562)
      at java.lang.Class.privateGetPublicMethods(Class.java:2578)
      at java.lang.Class.privateGetPublicMethods(Class.java:2578)
      at java.lang.Class.privateGetPublicMethods(Class.java:2578)
      at java.lang.Class.privateGetPublicMethods(Class.java:2578)
      at java.lang.Class.privateGetPublicMethods(Class.java:2578)
      at java.lang.Class.getMethods(Class.java:1427)
      at com.sun.javafx.fxml.BeanAdapter.updateMethodCache(BeanAdapter.java:273)
      at com.sun.javafx.fxml.BeanAdapter.setBean(BeanAdapter.java:258)
      at com.sun.javafx.fxml.BeanAdapter.<init>(BeanAdapter.java:221)
      at javafx.fxml.FXMLLoader$Element.getValueAdapter(FXMLLoader.java:159)
      at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:406)
      at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:197)
      at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:588)
      at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2430)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2136)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
      at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:937)
      at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:567)
      at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2314)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2131)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
      at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:937)
      at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:567)
      at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2314)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2131)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
      at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:937)
      at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:567)
      at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2314)

      Attachments

        Issue Links

          Activity

            People

              tbrandal Tomáš Brandalík (Inactive)
              dfuchs Daniel Fuchs
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: