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

Refactor PredefinedMeshManager and 3D shapes


    • Type: Enhancement
    • Status: In Progress
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8, 9, 10, openjfx11
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Subcomponent:
    • Understanding:
      Cause Known


      PredefinedMeshManager uses class instances to store mesh caches. An enum based approach will eliminate code duplication and provide the bundled advantages of enums.

      enum TriangleMeshCache {
              Map cache = new HashMap(...);
              // methods

      This will allow an extremely easy and safe way to add more shape caches in the future if the need arises.

      A disadvantage is that once one of the cache instances is lazily initialized, the other caches will be initialized as well. This is only a minor disadvantage as each instance will only hold an empty map, and given that there is a very limited number of predefined shapes that can be added, the memory consumption overhead is very limited.

      This is also an opportunity to revisit the disputable caching mechanism of reference counts, as noted in a comment on JDK-8192056 [1].

      Also, the Map's constructor parameters should be relooked at - is there a performance reason to use something other than the default? There is a TODO there.

      Shape3D and its subclasses can also be refactored to remove repeating code along with the necessary changes for the above.

      [1] https://bugs.openjdk.java.net/browse/JDK-8192056?focusedCommentId=14148930&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14148930


          Issue Links



              • Assignee:
                nlisker Nir Lisker
                nlisker Nir Lisker
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: