Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

WIP: JDK-8186429 FXMLLoader setStaticLoad should be public API #44

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

abhinayagarwal
Copy link
Contributor

This is useful for SceneBuilder to open FXML files with event handler attributes. Currently, SceneBuilder for JDK 9+ uses reflection as a workaround.

@abhinayagarwal
Copy link
Contributor Author

There is already a webrev in the issue with potential fix. Does it make this PR redundant?

@eugener eugener added the enhancement New feature or request label Mar 26, 2018
@@ -39,7 +38,7 @@
@SuppressWarnings("deprecation")
public void testStaticScriptLoad() throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("static_script_load.fxml"));
FXMLLoaderHelper.setStaticLoad(fxmlLoader, true);
fxmlLoader.setStaticLoad(true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is only called 2 times directly after the constructor it would make sense to add this directly as a param to the constructor. By doing so the field could be defined as final

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long gap :)

Are you trying to suggest to we can overload the constructor? Something similar to:

public FXMLLoader(boolean  staticLoad) {
    this.staticLoad = staticLoad;
}

Since FXMLoader already has a long list of constructors, do you think this would be a good idea?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not recommend adding any more constructor parameters.

If you want to take this new feature forward, it will take a fair bit of work to specify what the effect of staticLoad should be on loading fxml files. It seems like a somewhat of a SceneBuilder-specific mode, but if it has more general use then it could be something to consider. Also, there will need to be several new tests to validate the behavior of various loading scenarios when using static load, including checking what the effects are of switching between modes for successive loads. It might seem simple to "just make this method public", but there is more to it than that.

I would also want @johanvos to weigh in, since Gluon now maintains SceneBuilder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the pointers.

I will try to find if this feature has use-cases outside of Scene Builder.

@@ -39,7 +38,7 @@
@SuppressWarnings("deprecation")
public void testStaticScriptLoad() throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("static_script_load.fxml"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final FXMLLoader fxmlLoader

@kevinrushforth kevinrushforth added the WIP Work In Progress label Feb 16, 2019
@kevinrushforth kevinrushforth changed the title JDK-8186429 FXMLLoader setStaticLoad should be public API [WIP] JDK-8186429 FXMLLoader setStaticLoad should be public API Feb 16, 2019
@tobiasdiez
Copy link

The static load mode is also helpful if you want to use the FXMLLoader more as a parser. For example, we use it to verify that each fxml file in our project can be parsed successfully (as a unit test), and to extract all localized strings. In these cases, the static load mode is needed.

@kevinrushforth kevinrushforth changed the title [WIP] JDK-8186429 FXMLLoader setStaticLoad should be public API WIP: JDK-8186429 FXMLLoader setStaticLoad should be public API Oct 1, 2019
@kevinrushforth
Copy link
Collaborator

kevinrushforth commented Oct 1, 2019

As announced in this message, the official jfx repository is moving from hg.openjdk.java.net/openjfx/jfx-dev/rt to github.com/openjdk/jfx.

This sandbox repository is being retired on 1-Oct-2019. You will need to migrate your WIP pull request to the openjdk/jfx repo if you want to continue working on it. Here are instructions for migrating your pull request. The updated CONTRIBUTING.md doc has additional information on how to proceed.

Once you have done this, it would be helpful to add a comment with a pointer to the new PR.

NOTE: since this is a feature / enhancement request it needs to be discussed on the openjfx-dev mailing list if you want it to be considered.


The new openjdk/jfx repo will be open for pull requests on Wednesday, 2-Oct-2019. I will send email to the openjfx-dev mailing list announcing this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request WIP Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants