Skip to content

[Possible bug] Can not start jruby-swing applications since 9.4.9.0 - or rather, the window auto-closes almost instantly #8416

@rubyFeedback

Description

@rubyFeedback

So, the following is a standalone hello-world example in jruby-swing:

#!/usr/bin/ruby -w
# Encoding: UTF-8
# frozen_string_literal: true
# ============================================================================ #
# === HelloWorldExample  
# ============================================================================ #
java_import javax.swing.JFrame
java_import javax.swing.JLabel
java_import javax.swing.JPanel
java_import java.awt.Font

class HelloWorldExample < JFrame # === HelloWorldExample

  alias e puts

  # ========================================================================== #
  # === initialize
  # ========================================================================== #
  def initialize
    run
  end

  # ========================================================================== #
  # === run
  # ========================================================================== #
  def run

    frame = JFrame.new("HelloWorldExample")
    frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)

    panel = JPanel.new
    label = JLabel.new("Hello World")

    panel.add(label)
    frame.add(panel)

    frame.pack
    frame.setSize(1400, 1000)
    frame.setVisible(true) 
  end

end

HelloWorldExample.new

I am using:

jruby 9.4.8.0 (3.1.4) 2024-07-02 4d41e55a67 OpenJDK 64-Bit Server VM 17.0.7+7-jvmci-22.3-b18 on 17.0.7+7-jvmci-22.3-b18 +jit [x86_64-linux]

It works fine.

When I switch to

jruby 9.4.9.0 (3.1.4) 2024-11-04 547c6b150e OpenJDK 64-Bit Server VM 17.0.7+7-jvmci-22.3-b18 on 17.0.7+7-jvmci-22.3-b18 [x86_64-linux]

though, a window shows up, but then immediately closes, without any
further notification as to why it closed. Nothing is printed on the
terminal after that window closes.

I have not investigated this further (for now I'll revert to 9.4.8.0,
which is mostly the same anyway) but I believe that no matter the
underlying reason, it should not instantly auto-close without any notice.
After all jruby 9.4.8.0 shows a different behaviour, and I can interact with
the window that is displayed, whereas on jruby 9.4.9.0 I can not do
anything since it auto-closes at once - all with the same code shown above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions