-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
become_java! not compatible with Java sub-class generated proxies #4274
Comments
If this is due to e2027ed what was happening in 9.1.5.0 and earlier? It just failed but applications worked anyhow? |
Here's a simpler example I ran into while trying to play with JRuby and JavaFX (don't need to mess with any dependencies to see the error): require "java"
class Foo < Java.javafx.application.Application
def start(primaryStage)
primaryStage.setTitle("Hello World!")
btn = Java::javafx::scene::control::Button.new
btn.setText("Say 'Hello World'")
btn.setOnAction do
p "btn pressed"
end
root = Java.javafx.scene.layout.StackPane.new
root.getChildren().add(btn)
primaryStage.setScene(Java::javafx::scene::Scene.new(root, 300, 250))
primaryStage.show()
end
end
Foo.become_java!
Java::javafx::application::Application.launch(Foo.java_class, ARGV.to_java(:string))
I was able to work around it by compiling a java class and setting a proc on it, but it would have been nice to avoid that: import javafx.application.Application;
import javafx.stage.Stage;
// JavaFX needs an Application to instantiate. So we define a Java class that will call Ruby
public class JavaFXBootstrap extends Application {
public interface MyLauncher {
public void launch(Stage primaryStage);
}
public static MyLauncher rubyLauncher;
public void start(Stage primaryStage) {
rubyLauncher.launch(primaryStage);
}
} Java::JavaFXBootstrap.rubyLauncher = proc {|primaryStage|
primaryStage.setTitle("Hello World!")
btn = Java::javafx::scene::control::Button.new
btn.setText("Say 'Hello World'")
btn.setOnAction do
p "btn pressed"
end
root = Java.javafx.scene.layout.StackPane.new
root.getChildren().add(btn)
primaryStage.setScene(Java::javafx::scene::Scene.new(root, 300, 250))
primaryStage.show()
}
Java::javafx::application::Application.launch(Java::JavaFXBootstrap.java_class, ARGV.to_java(:string)) Edit: If this helps:
I'm using JFX 8u60 |
@presidentbeef yy - might have worked but there probably might have been issues (due reify failure) later. |
OH, this one is likely the same as #4165 ... an important detail :
... have been looking into this before and I do not have a quick solution (requires considerable work on the internals of these features). so the work-around is probably the only way to get this working. |
For me it always worked in Jruby 9k until 9.1.6, which broke it.
I also did not see any bad effects other than the double buttons in jrubyfx#100
Am 28. Dezember 2016 03:22:26 schrieb Justin <notifications@github.com>:
… If this is due to e2027ed what was
happening in 9.1.5.0 and earlier? It just failed but applications worked
anyhow?
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#4274 (comment)
|
This is a problem when using JRubyFX since it overrides |
JRubyFX author here, and yes, that file was carefully crafted before to work well, and it was working correctly (at least in relation to JavaFX interop) from 1.7.3 - 9.1.5. This is a regression. |
Still broken in 9.1.8.0 :-((( |
Indeed...we had to cut off 9.1.8.0 before it got too fat. This tab is still on my list. |
Just a small poke on this - can't switch from 1.7 to 9.x until this is fixed 😭 |
I'll take a shot at this during my next flight. |
I think we try and understand what JRubyFX needed from become_java!. Worst case for 9.1.10.0 (out this week for sure) we just revert the raise. It would be nice if we can do something which does not reexpose the original NPE it is protecting. |
This is what I tracked down to the JavaFX code when I did my original digging before: https://github.com/teamfx/openjfx-8u-dev-rt/blob/8ae6126201acc37c26c2ab1b291f075c5f437168/modules/graphics/src/main/java/javafx/application/Application.java#L254-L255 (This is a linkable mirror) JavaFX actually checks that the application class is a subclass and raises an error otherwise. That's why I ended up with my compiled JavaFXBootstrap shim in the above example. |
@zmoazeni I believe your reduced example is different than what was originally reported and also what @presidentbeef & @pilhuhn are running into atm. Your example is showing perfectly the issue description but I think the roadblock for others is not this specifically. What we know is that like @zmoazeni example that we have never worked in reifying this case. This was why @headius put the raise in. The reified class internally fails and is null so it should not be doing anything (that we can figure out). So @presidentbeef and @pilhuhn are seeing issues with JRubyFX hitting this new raise in controller.rb:152 when it tries to become_java!. If I remove the raise it looks like things work in hawkfx (although there is some other error which I think may just be an FX issue involving LineChart) and JRubyFX demo works. HOWEVER, if I just delete the become_java! from controller.rb:152 then both examples also works? At this point I am still looking for why that line in controller.rb:152 is neccesary. I believe @byteit101 that he put it there for a reason but I need to see an example of it before we can fix it. For 9.1.10.0 (which I am putting out today) we are just going to revert this extra raise so everyone's stuff should continue to work as it did in 9.1.5.0. I still want to dig on this one as well though. |
@presidentbeef would it be possible for you to try commenting out that line (controller.rb:152) in installed jrubyfx gem and see if you run into issues with your app? As I said, we reverted the raise for now but I want another datapoint. |
Commenting out that line appears to make no difference - all tests pass. |
@presidentbeef ok thanks for checking on that. |
Apparently the change that makes this fail was reverted in 9.1.11 (or earlier?) so this very issue works with 9.1.11. |
@pilhuhn I got this crossed with another issue and it should have been marked against 9.1.10.0. Closing now. |
Environment
Provide at least:
jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.111-b14 on 1.8.0_111-b14 +jit [darwin-x86_64]
Darwin snert 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64
This used to work in 9.1.5 and fails in 9.1.6
The full code is at https://github.com/pilhuhn/hawkfx with the failing controller at https://github.com/pilhuhn/hawkfx/blob/master/lib/chart_view_controller.rb
The text was updated successfully, but these errors were encountered: