It looks like VirtualFlow is completely locked dow...
# tornadofx
e
It looks like VirtualFlow is completely locked down in Java 9. It's public and not final, but everything interesting is private. That sucks big time. I might need to implement a similar solution from scratch to get DataGrid up and running. Should also investigate how this is done in similar Java 9 compatible components, I suspect there are some in ControlsFX.
😱 3
n
Mhm that sounds not to good sorry that I can't help much right now, I need to get an tfx app ready for release on Monday so I will have to work all weekend πŸ˜‰ But I hope at the end of next week I am back again.
e
@nimakro Don't worry, I will try to implement this in a naive way first, to get a POC up and running. I will ignore speed/optimizations just to see if I can get it to work. If that approach works for relatively large datasets, we can keep that approach until there is time to make a custom VirtualFlow we can use in other components.
a
@edvin ControlsFX uses reflection to access most of the private fields/methods. You may want to look at GridViewSkin. It's a shame that they made
VirtualFlow
inside the
VirtualContainerBase
private as well. Although reflection works for now, it cannot be considered as a long time solution.
Moreover, I think that package-private VirtualFlow in VirtualContainerBase is a regression in 9. More information - https://bugs.openjdk.java.net/browse/JDK-8187379
e
@abhinay Thanks for the info. They effectively made sure that
VirtualFlow
and
VirtualContainerBase
are completely unusable, they might has well chucked it back in
com.sun
package space 😞
Seems like
cells
in
VirtualFlow
is closed down as well. Disappointing and unnecessary 😞
@abhinay Doesn't this mean that even ControlsFX needs some command line parameter to be able to reflect on the JDK classes?
In a normal Java application, you could have accessed the class without adding the jvm flag but since they have changed the package for this particular class, we need to explicitly open it up.
e
@abhinay Thank you for this. If at all possible I want TornadoFX to be usable without "dirty" settings like this, but we might need to opt for an intermediary step where we allow for such tricks πŸ™‚
Once the Jet Lag ℒ️ wears off I will try to create a simplified VirtualFlow inside GridPane to see if performance is acceptable. If not, I'll revert to hackery πŸ™‚
a
I was talking about the above issue with Jonathan and he said that it might not be fixed for 18.3. So, as of now ControlsFX is vulnerable and so is any other control using Virtual Flow. Rewriting them might be the best option as of now.
e
@abhinay That's really surprising to me. It looks like an oversight that could be fixed with very little work. I'm also surprised Jonathan didn't catch this before the release of Java 9. There is probably some things I don't know here, but it seems odd.
The thing is, my current idea for a rewrite will not be performant for large datasets. I'm not sure what large means yet though. It could be several houndred thousand records or it could be 1k 😁
a
I am on the same boat as you are. Moreover, OpenJDK doesn't make it easy to vote / comment on issues.
It would have been just easy for the OpenJFX team to fix these issues.
e
Yes. Well, if my idea is viable we're safe for now. I think there is at least one other part of TornadoFX that uses internal classes through reflection, but that was already "tainted" in JavaFX 8, so a rewrite is long overdue anyways.
a
I peaked into the code you pushed in the jdk9 branch. I would be really excited to see how you around the code which uses Toolkit πŸ˜„
e
I haven't committed my latest batch of trickery.. hehe.. What part which uses Toolkit would you be interested in?
e
How to deal with
canStartNestedEventLoop()
etc?
a
Yup
Not sure if there is an alternative to them
e
I did find a "solution" to this, after beeing awake for 26 hours, on the way back. Let me check πŸ™‚
There are several ways to "trick" JavaFX into calling that method, actually.
You could create a Dialog or Stage and call ShowAndWait, then kill it. That would throw
IllegalStateException
if
!canStartNestedEventLoop
. Sad if we have to resort to this kind of thing though.
a
"dirty" hack 😞
e
Yes. I wonder what the rationale is for removing these functions from the public API.
I really thought the migration to Java 9 would be about the module system. That was five minutes work 😞
a
Neither do I...
They have introduced a lot of regression in JFX9 which makes life difficult for framework and custom control developers.
e
Yes indeed. After getting TornadoFX up and running I'll make a list of senseless regression examples and submit issues.
πŸ‘ 1
For now I think using dirty hacks that only access public api's are our best shots, unless performance penalties kick in.
a
If you have access to the JBS, please vote on related issues as well πŸ™
e
I will wait a little with passing judgement though. My head is still not on right after the flight back. I look at walls and they don't look straight anymore etc. Hehe.. Will pick this up again tomorrow, need to get my head on straight first.
I don't, but I'll for sure start lobbying once I get the big picture here.
a
Take rest πŸ™‚
And stop replying to my messages πŸ˜›
e
Probably best. Thanks for your help so far πŸ™‚ Talk to you later!
a
Later!
e
For
awaitUntil
, we can actually just remove the nestedEventLoop check and use the new functions in Platform directly:
fun <T> ObservableValue<T>.awaitUntil(condition: (T) -> Boolean) { val changeListener = object : ChangeListener<T> { override fun changed(observable: ObservableValue<out T>?, oldValue: T, newValue: T) { if (condition(value)) { runLater { Platform.exitNestedEventLoop(this@awaitUntil, null) removeListener(this) } } } } changeListener.changed(this, value, value) addListener(changeListener) Platform.enterNestedEventLoop(this) }
The reason is that
enterNestedEventLoop
will throw IllegalStateException for us with almost the same error message we used:
IllegalStateException("Cannot enter nested loop during animation or layout processing");
a
Ahha nice!