Improve the utility and reliability of include_package
------------------------------------------------------
Key: JRUBY-5558
URL: http://jira.codehaus.org/browse/JRUBY-5558
Project: JRuby
Issue Type: Improvement
Components: Java Integration
Affects Versions: JRuby 1.6RC2
Reporter: Charles Oliver Nutter
The reason we have the const_missing behavior for include_package is because
the JVM provides no facilities for looking up all classes in a given package.
Most likely, this is because new classes can be loaded at any time, making the
list only accurate for the current moment. If we relied solely on such a
hypothetical list, we might miss later loads.
We have considered various options for getting include_package to be smarter:
* Scan classloader resources looking for all .class files under that package.
This works, and it's what Jython does. But we'd need to also maintain on-disk
caches mapping jar files to lists of contained packages and classes, to avoid
re-scanning. The Jython guys started to pull this out as a separate library,
but never completed that work:
http://code.google.com/p/jvm-language-runtime/source/browse/#svn%2Ftrunk%2Fpackagecache
* Ship with lists of core Java packages and the classes they contain. This too
is cumbersome; the lists would be large, and we'd need to include lists for
Java 5, 6, and 7 or differential files for 6 and 7.
* Build a smarter custom Module subclass that knows how to lookup Java classes
and propagate constants as normal. This would mean that for purposes of
constant lookup it always tries Java classes, failing over to normal constant
lookup behavior.
The third option here may be the easiest, since it doesn't require us to scan
classes or include predetermined lists of classes.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email