Skip to content
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

Some Java modules do not respond_to name #2468

Closed
jeremyevans opened this issue Jan 16, 2015 · 0 comments
Closed

Some Java modules do not respond_to name #2468

jeremyevans opened this issue Jan 16, 2015 · 0 comments
Assignees
Milestone

Comments

@jeremyevans
Copy link
Contributor

In jruby, Module.method_defined?(:name) is true. However, not all modules respond to it:

ObjectSpace.each_object(Module).each do |mod| p mod unless mod.respond_to?(:name) end
Java::OrgJrubyRuntimeBuiltinName
Java::OrgJrubyRuntimeMarshalName
Java::JavaxName
Java::JavaxManagementName
Java::OrgJrubyUtilName
Java::OrgJrubyExtReadlineName
Java::JavaNioName
Java::JavaNioChannelsName
Java::JavaNetName
Java::OrgJrubyRuntimeName
Java::OrgJrubyJavaUtilName
Java::OrgJrubyExtName
Java::OrgJrubyRuntimeLoadName
Java::OrgJrubyName
Java::OrgName
Java::OrgJrubyLexerName
Java::OrgJrubyLexerYaccName
Java::OrgJrubyAstName
Java::JavaLangReflectName
Java::JavaUtilName
Java::JavaUtilRegexName
Java::JavaIoName
JavaPackageModuleTemplate
Java::Java
Java::Default
Java::JavaLang

Most of these modules, despite not claiming to respond to name, actually do respond to it, and once you call the name method on them, then they will claim to respond to it.

The one exception to that is JavaPackageModuleTemplate, which doesn't respond to it, and raises an ArgumentError when called:

irb(main):022:0> JavaPackageModuleTemplate.name
ArgumentError: invalid package module
        from org/jruby/javasupport/JavaUtilities.java:54:in `get_proxy_or_package_under_package'
        from file:/usr/local/jruby/lib/jruby.jar!/jruby/java/java_package_module_template.rb:14:in `method_missing'
        from (irb):22:in `evaluate'
        from org/jruby/RubyKernel.java:1107:in `eval'
        from org/jruby/RubyKernel.java:1507:in `loop'
        from org/jruby/RubyKernel.java:1270:in `catch'
        from org/jruby/RubyKernel.java:1270:in `catch'
        from /usr/local/jruby/bin/jirb:13:in `(root)'

I think JavaPackageModuleTemplate should be fixed to define name, and all of the modules that claim not to respond to it but actually do should be fixed to claim they respond to it.

This bug causes rack-unreloader to break: jeremyevans/rack-unreloader#4

@kares kares self-assigned this Aug 11, 2015
kares added a commit to kares/jruby that referenced this issue Aug 11, 2015
... since its counted among `ObjectSpace.each_object(Module)` (jruby#2468)
@kares kares closed this as completed in 0d452ee Aug 12, 2015
kares added a commit that referenced this issue Aug 13, 2015
@kares kares added this to the JRuby 1.7.22 milestone Aug 13, 2015
kares added a commit to kares/jruby that referenced this issue Aug 24, 2015
kares added a commit to kares/jruby that referenced this issue Aug 24, 2015
kares added a commit to kares/jruby that referenced this issue Dec 4, 2015
kares added a commit to kares/jruby that referenced this issue Jan 4, 2016
kares added a commit to kares/jruby that referenced this issue Feb 21, 2016
kares added a commit to kares/jruby that referenced this issue Mar 21, 2016
kares added a commit to kares/jruby that referenced this issue Mar 22, 2016
- `pkg.name` has been working since 1.7.22/9.0.1.0 (jruby#2468)
- handling :object_id as it is quite surprising to not have
- can handle :throw/:catch since they're not valid package names
- commented-out methods that would be good to have as well
kares added a commit to kares/jruby that referenced this issue Mar 22, 2016
- `pkg.name` has been working since 1.7.22/9.0.1.0 (jruby#2468)
- handling :object_id as it is quite surprising to not have
- can handle :throw/:catch since they're not valid package names
- commented-out methods that would be good to have as well
kares added a commit that referenced this issue Mar 22, 2016
- `pkg.name` has been working since 1.7.22/9.0.1.0 (#2468)
- handling :object_id as it is quite surprising to not have
- can handle :throw/:catch since they're not valid package names
- commented-out methods that would be good to have as well
ujifgc added a commit to padrino/padrino-framework that referenced this issue May 11, 2016
ujifgc added a commit to padrino/padrino-framework that referenced this issue Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants