-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom components disappear from Custom list after importing a new jar #70
Comments
Original comment by Adam Paul (Bitbucket: adampaul112591, GitHub: adampaul112591): Jose I've discovered a work around for this using Scene Builder 8.1.1 on Windows. To replicate...
|
Original comment by Adam Paul (Bitbucket: adampaul112591, GitHub: adampaul112591): Well if you consider it a full solution, then this can be closed. If you struggle to replicate it I can upload my install with the config to bitbucket. |
Original comment by Jose Pereda (Bitbucket: JPereda, GitHub: JPereda): I haven't tested your workaround but, as I said, if it implies closing the application, I don't think it is a solution, unless we consider the need to restart SceneBuilder every time we add a jar, like when installing a plugin on the IDE... |
I run into a related issue when trying to add the jar file of our yFiles for JavaFX product (https://www.yworks.com/products/yfiles-for-javafx). The jar contains several custom controls that reference a custom fx event but the static initializer of this event is called multiple times when the jar is parsed leading to an IllegalArgumentException as described above. I attached a minimal example of this setup that breaks in the same way as our library jar: The workaround with adding the jar to Scene Builders classpath does work but isn't intuitive for our customers which may want to use SceneBuilder to create their yFiles-based application. |
Originally reported by: Jose Pereda (Bitbucket: JPereda, GitHub: JPereda)
When Scene Builder starts, a task is launched to load all the custom components from the user library folder. For this, a classloader is created based on the jars found in that folder. The jars are scanned and their clases are instantiated once to find out about valid components.
In case the user imports a new jar, the task is stopped, the jar is added to the folder, and the task is started again.
While the classloader is created again, there are some cases where some classes may have not been garbage collected, and the second time they are instantiated, the instance fails with and exception, and those components, that were before on the Custom list, now won't be included.
It can be reproduced for instance with
NotificationPane
from ControlsFX.How to reproduce:
Import ControlsFX 8.40.10 or 8.40.11-SNAPSHOT in case it is not imported yet.
Accept all the components, or at least
NotificationPane
.Close Scene Builder, and open it again. Notice that
NotificationPane
is available under the Custom tab.Now import any other jar. After selecting its valid components, the Custom list is refreshed. Notice that
NotificationPane
won't be at the list. (Closing and opening SB will reveal it again)The reason for this issue can be found in the exception thrown by the attempt of creating the new instance in `JarExplorer.instantiateWithFXMLLoader():
A short test can be made to try to create the instance of
NotificationPane
in the same way.Running it twice will throw the same exception as above, including also this:
Having a look at the
NotificationPane
source code, an staticEventType
object is created when the class is instantiated. This is registered in aWeakHashMap
(seeEventType.register()
), and when callingUserLibrary.stopWatching()
and setting the url class loader to null it doesn't get garbage collected.That's why the next time the component is instantiated (by running
UserLibrary.startWatching()
a second time), this exception will be thrown because the event type is already registered:While setting the classloader to null and adding a call to
System.gc()
works in the test, it is not the case in Scene Builder.The text was updated successfully, but these errors were encountered: