Skip to content

const_defined? returns false for External Constants in JRuby 10.0.1.0 and 9.4.14.0 #8924

Description

@yamam

When a constant is defined outside of a class, calling const_defined? on that class returns false in JRuby 10.0.1.0. However, in JRuby 10.0.0.1 and CRuby 3.4.5, it returns true.

Environment Information

jruby 10.0.1.0 (3.4.2) 2025-07-17 0f10d1d OpenJDK 64-Bit Server VM 21.0.7+6-Ubuntu-0ubuntu124.04 on 21.0.7+6-Ubuntu-0ubuntu124.04 +indy +jit [x86_64-linux]

Expected Behavior

$ jruby -e 'A=0;p Class.new.const_defined?("A")'                                                                                                                                       
true

Actual Behavior

$ jruby -e 'A=0;p Class.new.const_defined?("A")'                                                                                                                                       
false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions