ruby-core

Mailing list archive

[#46930] [ruby-trunk - Bug #6825][Open] forking and pthread_cond_timedwait: Invalid argument (EINVAL) on OS X / 1.9.3-p194 — "xentronium (Mark A)" <markizko@...>

29 messages 2012/08/02

[#46974] [ruby-trunk - Bug #6830][Assigned] test failure test_constants(OpenSSL::TestConfig) [/ruby/test/openssl/test_config.rb:27] on Mac + homebrew — "kosaki (Motohiro KOSAKI)" <kosaki.motohiro@...>

17 messages 2012/08/04

[#46975] [ruby-trunk - Bug #6831][Assigned] test_getpwuid() on Mountain Lion — "kosaki (Motohiro KOSAKI)" <kosaki.motohiro@...>

12 messages 2012/08/04

[#46996] [ruby-trunk - Bug #6836][Assigned] Improve File.expand_path performance in Windows — "luislavena (Luis Lavena)" <luislavena@...>

15 messages 2012/08/04

[#47036] [ruby-trunk - Feature #6841][Open] Shorthand for Assigning Return Value of Method to Self — "wardrop (Tom Wardrop)" <tom@...>

18 messages 2012/08/07

[#47108] [ruby-trunk - Feature #6852][Open] [].transpose should behave specially — "boris_stitnicky (Boris Stitnicky)" <boris@...>

13 messages 2012/08/10

[#47138] [ruby-trunk - Bug #6861][Open] ERB::Util.escape_html is not escaping single quotes — "spastorino (Santiago Pastorino)" <santiago@...>

14 messages 2012/08/12

[#47163] [ruby-trunk - Bug #6865][Open] GC::Profiler.report might create a huge String and invoke a few GC cycles — "Eregon (Benoit Daloze)" <redmine@...>

9 messages 2012/08/13

[#47189] [ruby-trunk - Feature #6868][Open] Make `do` in block syntax optional when the block is the last argument of a method and is not an optional argument — "alexeymuranov (Alexey Muranov)" <redmine@...>

8 messages 2012/08/14

[#47243] [ruby-trunk - Feature #6895][Open] TracePoint API — "ko1 (Koichi Sasada)" <redmine@...>

27 messages 2012/08/20

[#47267] [ruby-trunk - Bug #6903][Open] [[Ruby 1.9:]] --enable-load-relative broken on systems with /lib64 — "mpapis (Michal Papis)" <mpapis@...>

11 messages 2012/08/22

[#47309] [ruby-trunk - Bug #6929][Open] Documentation for Ripper — "zzak (Zachary Scott)" <zachary@...>

16 messages 2012/08/25

[#47345] [ruby-trunk - Feature #6946][Open] FIPS support? — "vo.x (Vit Ondruch)" <v.ondruch@...>

35 messages 2012/08/28

[ruby-core:46909] Re: (Half-baked DRAFT) new `require' framework

From: Charles Oliver Nutter <headius@...>
Date: 2012-08-01 07:29:12 UTC
List: ruby-core #46909
On Tue, Jul 31, 2012 at 7:29 AM, SASADA Koichi <ko1@atdot.net> wrote:
> (Proposal-2)
> However, Proposal-1 is too big and we have not-enough time to discuss
> about it.  I propose alternative feature: `require' contractible
> primitives.  Break down `require' process and add primitives which can
> implement `customized require' in Ruby (or C level).
> Using (Proposal-2), we can make gem which provides (Proposal-1).  We can
> try and discuss about good design of (Proposal-1).

Yes! The lookup logic should be the first thing exposed to Ruby, and
then options to "properly" load code is a secondary feature.

> JRuby can require file from `.jar' (and .war file? sorry i'm not sure).

JRuby can load from anything on Java's "classpath", which can include
jar files, paths on the filesystem, or anything added to the JVM's
classpath. We do very little to make classpath/classloader resources
available; we just look there as a last resort.

FWIW, this also includes network resources...

system ~/projects/jruby $ ssh 192.168.0.200 "cat public_html/some_library.rb"
headius@192.168.0.200's password:
puts 'this is on the server!'

system ~/projects/jruby $ jruby -rjava -e '$CLASSPATH <<
"http://192.168.0.200/~headius/"; load "some_library.rb"'
this is on the server!

We inherit this behavior from the JVM.

>  JRuby also extends file path like VFS (virtual file system).  JRuby can
> open a file in a .jar file like file system.
> (JRuby GURU: Please complement this section!)

We do have some support for URLs that include a .jar file as part of
their structure, but it's still mostly a JVM thing. We add the ability
to have jar files within jar files and still search them, but it's a
minor classloader trick.

Torquebox does (or did) use JBoss VFS to provide more extensive
filesystem simulation within jars and classloader archives.

FYI, jar files are just zip files. There's no reason MRI could not do
the same thing. I have been trying to encourage this for years :(

> === Rubinius
>
> Rubinius supports AOT compile (a ruby script to a compiled file).
> (Rubinius GURU: Please complement it!)

I should mention that JRuby supports precompiled Ruby code; we search
for .class when .rb are searched and not found. .rb can be compiled to
.class, and there's no significant functional difference other than
being precompiled (and being nearly impossible to reverse-engineer
unless you know JVM bytecode, JRuby internals, and Ruby logic).

system ~/projects/jruby $ cat blah.rb
puts 'hello from compiled code!'

system ~/projects/jruby $ jrubyc blah.rb

system ~/projects/jruby $ rm blah.rb

system ~/projects/jruby $ jruby -e "load 'blah.rb'"
hello from compiled code!

system ~/projects/jruby $ file blah.class
blah.class: compiled Java class data, version 51.0

system ~/projects/jruby $ javap blah
Compiled from "blah.rb"
public class blah extends org.jruby.ast.executable.AbstractScript {
  public blah();
  public static org.jruby.runtime.builtin.IRubyObject __file__(blah,
org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject[], org.jruby.runtime.Block);
  public org.jruby.runtime.builtin.IRubyObject
__file__(org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject[], org.jruby.runtime.Block);
  public org.jruby.runtime.builtin.IRubyObject
load(org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject, boolean);
  public static void main(java.lang.String[]);
}

> === Java Jigsaw project <http://openjdk.java.net/projects/jigsaw/>
>
> (Java GURU: Help me to complement it!)

Jigsaw is intended as a new module and namespace system for Java
applications. I'm not sure the authors know exactly how it works, but
you could get a general idea by studying the classloader system...and
OSGi, a current, working implementation of namespaced modules for the
JVM.

JRuby users have used both Maven and OSGi for years to include JRuby
in modularized systems and to control modularized systems from JRuby.

> Make an `extensible require' framework for require().
> It's my draft (not implemented yet):
>   <http://www.atdot.net/sp/view/tcy08m/readonly>

I will try to read this in depth soon!

> == Usecase
>
> (snip... not described yet)

RubyGems without RubyGems hacks? :)

Arbitrary sourcing of code from archives, network, and more?

All the cool stuff JRuby can do? :)

- Charlie

In This Thread