Forum: JRuby rspec problem with jruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lenny M. (Guest)
on 2008-10-29 03:07
(Received via mailing list)
I'm not sure if this falls to rspec or jruby, but if resolving it has
anything to do with not being able to run focused specs from
NetBeans, then I'd LOVE to resolve it.

http://rubyforge.org/pipermail/rspec-users/2008-Oc...

Thanks,
-lenny

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2008-10-29 05:41
(Received via mailing list)
Lenny M. wrote:
> I'm not sure if this falls to rspec or jruby, but if resolving it has
> anything to do with not being able to run focused specs from NetBeans,
> then I'd LOVE to resolve it.
>
> http://rubyforge.org/pipermail/rspec-users/2008-Oc...

It sounds like it must be a JRuby issue...can you file a bug for it with
a sample spec and command line to reproduce?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Lenny M. (Guest)
on 2008-10-29 06:02
(Received via mailing list)
On Oct 28, 2008, at 11:41 PM, Charles Oliver N. wrote:

> Lenny M. wrote:
>> I'm not sure if this falls to rspec or jruby, but if resolving it
>> has anything to do with not being able to run focused specs from
>> NetBeans, then I'd LOVE to resolve it.
>> http://rubyforge.org/pipermail/rspec-users/2008-Oc...
>
> It sounds like it must be a JRuby issue...can you file a bug for it
> with a sample spec and command line to reproduce?
>
>

  http://jira.codehaus.org/browse/JRUBY-3092

Thanks,
-lenny

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-10-29 06:09
(Received via mailing list)
Hi,

I'm doing some work with Java3D 1.5.3/JRuby 1.1.4, and I'm trying to
subclass from a class in Java3D:

class Smoo < javax.media.j3d.Behavior
   def initialize
     timcon = javax.media.j3d.WakeupOnElapsedTime.new(1000)
     self.wakeupOn(timcon)
   end

   def processCondition
     p "in process condition\n"
   end
end


when I instantiate Smoo, I get a missing_method failure on the call to
wakeupOn, which is a method of javax.media.j3d.Behavior

when I call Smoo.methods, wakeupOn and a whole bunch of other methods
are missing from the list, but one method, getNumSchedulingIntervals()
is listed. That public function returns a static int.

If I create a direct instantiation of Behavior, I can call wakeupOn()
and other methods, without a problem.

can someone shed some light on what I'm going wrong ??

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2008-10-29 22:05
(Received via mailing list)
john casu wrote:
>
>   def processCondition
>     p "in process condition\n"
>   end
> end
>
>
> when I instantiate Smoo, I get a missing_method failure on the call to
> wakeupOn, which is a method of javax.media.j3d.Behavior

Are the missing methods protected? There's a standing bug in 1.1.4 and
lower that protected methods are never invokable (and don't even get
listed), even for subclasses. That's fixed in trunk/1.1.5 by listing
them and forcing them to be accessible so long as security settings
allow it.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-10-29 22:58
(Received via mailing list)
Charles Oliver N. wrote:
>>   end
> Are the missing methods protected? There's a standing bug in 1.1.4 and
> lower that protected methods are never invokable (and don't even get
> listed), even for subclasses. That's fixed in trunk/1.1.5 by listing
> them and forcing them to be accessible so long as security settings
> allow it.
>

Charlie,

wakeupOn() *is* protected, but other missing methods, such as
getEnable() are not. initialize & processCondition are abstract classes,
and they are not listed when I do the direct instantiation of Behavior.
In fact, the only method that seem to get listed is the one that returns
a static int.

I guess my fix is to download the 1.1.5 branch.

thanks,

-john c


> - Charlie
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-10-30 02:29
(Received via mailing list)
I'm trying to download the latest snapshot of jruby from svn, and it's
failing for me. Since I am able to svn from other repos, I'm guessing
there's an issue with the codehaus svn server.

some help would be appreciated.

thanks,

-john c.


enterprise:jruby-1.1.5-svn casuj$ svn co
svn://svn.codehaus.org/jruby/trunk/jruby jruby
svn: Can't connect to host 'svn.codehaus.org': Operation timed out
enterprise:jruby-1.1.5-svn casuj$ ping svn.codehaus.org
PING svn.codehaus.org (63.246.2.115): 56 data bytes
64 bytes from 63.246.2.115: icmp_seq=0 ttl=48 time=72.033 ms
64 bytes from 63.246.2.115: icmp_seq=1 ttl=48 time=68.740 ms
64 bytes from 63.246.2.115: icmp_seq=2 ttl=48 time=79.669 ms


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-10-30 04:25
(Received via mailing list)
apologies, was being a retard.

svn co svn://svn.codehaus.org/jruby/trunk/jruby/

seem to be the correct invocation

john casu wrote:
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-10-30 04:45
(Received via mailing list)
Charlie,

I downloaded /trunk/jruby from the svn (2008-10-29 version), built it
and ran my code.  Still busted, but given that I couldn't find a
specific 1.1.5 branch/tag/version of jruby, I'm guessing I'm still using
the wrong version.

thanks for your help,

-john c.




Charles Oliver N. wrote:
>>   end
> Are the missing methods protected? There's a standing bug in 1.1.4 and
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Luis L. (Guest)
on 2008-10-30 04:55
(Received via mailing list)
Attachment: array_max_bug.tbz (0 Bytes)
I've detected a weird behaviour on the max(&block) method from
enumerable  when invoked on a has_many relation of rails.

The attachment file contains a rails environment where the
issue can be tested.

The following code exposes the bug ,

ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
lribeiro@wheat:~/test$ /usr/bin/ruby script/console
Loading development environment (Rails 2.1.2)
>> u = User.first
>> u.accounts.max{|x,y| puts x.class; puts y.class; -1}
Account
Account
Account
Account
Account
Account
Account
Account


jruby 1.1.4 (ruby 1.8.6 patchlevel 114) (2008-10-29 rev 7939)
[i386-java]
lribeiro@wheat:~/test$ jruby script/console
>> User.first.accounts.class
=> >> User.first.accounts.max{|x,y| puts x.class; puts y.class; -1}
Array
NilClass
Array
NilClass
Array
NilClass
Array
NilClass

>> User.first.accounts.max{|x,y| puts x.inspect; puts y.class; -1}
[#<Account id: 2, title: nil, user_id: 1, created_at: "2008-10-29
13:54:29", updated_at: "2008-10-29 13:54:29">, #<Account id: 1, title:
nil, user_id: 1, created_at: "2008-10-29 13:54:20", updated_at:
"2008-10-29 13:54:20">]
NilClass
[#<Account id: 3, title: nil, user_id: 1, created_at: "2008-10-29
13:54:30", updated_at: "2008-10-29 13:54:30">, #<Account id: 1, title:
nil, user_id: 1, created_at: "2008-10-29 13:54:20", updated_at:
"2008-10-29 13:54:20">]
NilClass
[#<Account id: 4, title: nil, user_id: 1, created_at: "2008-10-29
13:54:30", updated_at: "2008-10-29 13:54:30">, #<Account id: 1, title:
nil, user_id: 1, created_at: "2008-10-29 13:54:20", updated_at:
"2008-10-29 13:54:20">]
NilClass
[#<Account id: 5, title: nil, user_id: 1, created_at: "2008-10-29
13:54:30", updated_at: "2008-10-29 13:54:30">, #<Account id: 1, title:
nil, user_id: 1, created_at: "2008-10-29 13:54:20", updated_at:
"2008-10-29 13:54:20">]
NilClass
=> #<Account id: 1, title: nil, user_id: 1, created_at: "2008-10-29
13:54:20", updated_at: "2008-10-29 13:54:20">


If we clone the array, them max behaves has MRI,
so User.first.account.clone.max{|x,y| puts x.inspect; puts y.class; -1},
yields the same results on both MRI and JRUBY.
I suspect some association proxy in rails may be the culprit.

I've tested the issue against trunk, but I remember a fellow developer
hitting the same bug a few months ago (at the time I lacked the time to
investigate the issue), so older versions should also be affected.

Cheers
Luis Landeiro
Charles Oliver N. (Guest)
on 2008-10-30 05:50
(Received via mailing list)
Looks like you're running off trunk, yes? There's some known issues with
revisions around where you're at, so you may want to try to pull down
current trunk and check it again. If there's still a problem, let us
know and file a bug too.

Luis Landeiro R. wrote:
> Loading development environment (Rails 2.1.2)
>
> NilClass
> 13:54:30", updated_at: "2008-10-29 13:54:30">, #<Account id: 1, title:
> nil, user_id: 1, created_at: "2008-10-29 13:54:20", updated_at:
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Roy P. (Guest)
on 2008-10-30 17:18
(Received via mailing list)
Hey All,

Is this a place I can get help w/installation?  I'm on windows xp & am
seeing this:

  C:\DeleteMe\jruby\jruby-1.1.4\bin>jruby -v
  The system cannot find the path specified.

If this is not a good place for this question, apologies & do please
direct me...

Thanks!

-Roy

Roy P.
Research Analyst/Programmer
Group Health Center For Health Studies (Cancer Research Network)
(206) 287-2078
Google Talk: rpardee

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Vladimir S. (Guest)
on 2008-10-30 17:47
(Received via mailing list)
Hi Roy,

It is highly recommended to add JRuby's bin directory to environment
variable %PATH%, so that you will be able to simply invoke jruby
without full path.

Thanks,
  --Vladimir

On Thu, Oct 30, 2008 at 4:17 PM, Pardee, Roy 
<removed_email_address@domain.invalid> wrote:
>
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Roy P. (Guest)
on 2008-10-30 17:57
(Received via mailing list)
Ach--sorry--forgot to mention that I did that.  I cd'd into the bin
directory after getting that error just out of superstition.  But I
believe the system is finding jruby.exe, b/c I get a different error if
I try to call something I know doesn't exist:

  C:\>jruby
  The system cannot find the path specified.

  C:\>fargle
  'fargle' is not recognized as an internal or external command,
  operable program or batch file.

I'm guessing there's something wrong w/the JRE maybe?  Not a java guy,
so don't know how to dx... :(

Thanks!

-Roy
Mike McKinney (Guest)
on 2008-10-30 18:03
(Received via mailing list)
tidy steps for install:

1. download / unzip the jruby dist
    i.e. http://dist.codehaus.org/jruby/jruby-bin-1.1.4.zip >
C:\DeleteMe\jruby\jruby-1.1.4\bin
     (by the way, jruby doesn't belong in a dir called "DeleteMe"!!! :)
2. set path variables:
    JAVA_HOME : make sure this is set to your java dir... i.e.
C:\Program
Files\Java\jdk1.5.blah-blah
    JRUBY_HOME : C:\DeleteMe\jruby\jruby-1.1.4 in your case
    PATH : add this to the end of your PATH variable : %JRUBY_HOME%\bin

For help "setting windows environment variables" :
http://www.google.com/search?hl=en&q=setting%20win...
Jruby wiki for install:
http://wiki.jruby.org/wiki/Getting_Started#Installing_JRuby

This should do the trick for you, remember to change your env variables
when
you decide to move JRuby out of the "DeleteMe" directory!

M
On Thu, Oct 30, 2008 at 11:46 AM, Vladimir S.
<removed_email_address@domain.invalid>wrote:

> > Hey All,
> > Thanks!
> > To unsubscribe from this list, please visit:
>
>
>


--
Aloha!

Mike McKinney
(http://blog.huikau.com)
Mike McKinney (Guest)
on 2008-10-30 18:09
(Received via mailing list)
P.S.
make sure you open a new console window, then type in the jruby -v...
(console windows that are open while you set environment variables will
not
have the new settings...)

On Thu, Oct 30, 2008 at 12:02 PM, Mike McKinney 
<removed_email_address@domain.invalid> wrote:

>     PATH : add this to the end of your PATH variable : %JRUBY_HOME%\bin
>
>>
>> direct me...
>> >
>>
> (http://blog.huikau.com)
>



--
Aloha!

Mike McKinney
(http://blog.huikau.com)
Vladimir S. (Guest)
on 2008-10-30 18:49
(Received via mailing list)
On Thu, Oct 30, 2008 at 4:55 PM, Pardee, Roy 
<removed_email_address@domain.invalid> wrote:
> Ach--sorry--forgot to mention that I did that.  I cd'd into the bin directory after 
getting that error just out of superstition.  But I believe the system is finding 
jruby.exe, b/c I get a different error if I try to call something I know doesn't exist:
>
>  C:\>jruby
>  The system cannot find the path specified.
>
>  C:\>fargle
>  'fargle' is not recognized as an internal or external command,
>  operable program or batch file.

Indeed! Then then the most typical case for this is wrong %JAVA_HOME%
variable, it should point to the appropriate JDK/JRE installed.

Also, try to invoke jruby when you're are *not* inside *bin*
directory. There were some problems with this in the past.

Thanks,
  --Vladimir

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Matt B. (Guest)
on 2008-10-30 18:50
(Received via mailing list)
Pardee, Roy wrote:
> Hey All,
>
> Is this a place I can get help w/installation?  I'm on windows xp & am seeing this:
>
>   C:\DeleteMe\jruby\jruby-1.1.4\bin>jruby -v
>   The system cannot find the path specified.

This sounds like it could be a problem in the batch files that start
jruby. You might be able to figure out where it's failing by removing
"@echo off" from the beginning of *.bat in the jruby bin directory.

--
Matt

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Roy P. (Guest)
on 2008-10-30 19:39
(Received via mailing list)
Ah--thanks!  It was the JAVA_HOME var--had been pointing to a
nonexistant dir.

Heh--yeah, I need to rename that DeleteMe dir--it's a misnomer.

Thanks!

-Roy

________________________________
From: Mike McKinney [mailto:removed_email_address@domain.invalid]
Sent: Thursday, October 30, 2008 9:02 AM
To: removed_email_address@domain.invalid
Subject: Re: [jruby-user] installation help?

tidy steps for install:

1. download / unzip the jruby dist
    i.e. http://dist.codehaus.org/jruby/jruby-bin-1.1.4.zip >
C:\DeleteMe\jruby\jruby-1.1.4\bin
     (by the way, jruby doesn't belong in a dir called "DeleteMe"!!! :)
2. set path variables:
    JAVA_HOME : make sure this is set to your java dir... i.e.
C:\Program Files\Java\jdk1.5.blah-blah
    JRUBY_HOME : C:\DeleteMe\jruby\jruby-1.1.4 in your case
    PATH : add this to the end of your PATH variable : %JRUBY_HOME%\bin

For help "setting windows environment variables" :
http://www.google.com/search?hl=en&q=setting%20win...
Jruby wiki for install:
http://wiki.jruby.org/wiki/Getting_Started#Installing_JRuby

This should do the trick for you, remember to change your env variables
when you decide to move JRuby out of the "DeleteMe" directory!

M
On Thu, Oct 30, 2008 at 11:46 AM, Vladimir S.
<removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>> 
wrote:
Hi Roy,

It is highly recommended to add JRuby's bin directory to environment
variable %PATH%, so that you will be able to simply invoke jruby
without full path.

Thanks,
 --Vladimir

On Thu, Oct 30, 2008 at 4:17 PM, Pardee, Roy
<removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>> 
wrote:
>
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
Aloha!

Mike McKinney
(http://blog.huikau.com)
Luis L. (Guest)
on 2008-10-31 00:04
(Received via mailing list)
I've tested it against trunk r7971, the problem still persists.
Filled a bug report for it,
http://jira.codehaus.org/browse/JRUBY-3099

Luis Landeiro

Charles Oliver N. wrote:
>> issue can be tested.
>> Account
>> => >> User.first.accounts.max{|x,y| puts x.class; puts y.class; -1}
>> [#<Account id: 2, title: nil, user_id: 1, created_at: "2008-10-29
>> 13:54:30", updated_at: "2008-10-29 13:54:30">, #<Account id: 1, title:
>>
>> Cheers
>>     http://xircles.codehaus.org/manage_email
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-11-04 01:24
(Received via mailing list)
This is still broken in today's 1.1.5 release, but I'm getting a
different error message:

gui/gui_display.rb:40:in `initialize': invokee not a java object
(TypeError)
         from gui/gui_display.rb:130:in `initialize'
         from /Users/casuj/NetBeansProjects/rumcad/lib/main.rb:14

the line that fails is the "self.wakeupOn(timcon)" line as below.


thanks,
-john c.

john casu wrote:
>
>>> class Smoo < javax.media.j3d.Behavior
>>>
>>
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2008-11-04 04:56
(Received via mailing list)
I suspect this is a still-open issue where calling abstract methods (or
calling methods that call abstract methods) from within the constructor
or initialize does not work. The sequence of events that sets up the
Ruby and Java sides of the object is such that there's no way for both
to be initialized by the time an abstract method is called during
construction. If the Ruby side is initialized first, it then initializes
the Java side, but that would mean you could not call any Java methods
from within initializers. If the Java side is initialized first, it will
be available for calling against in the Ruby initializer; but abstract
methods it implements will not be callable yet.

Is wakeupOn or any methods it would call lead into an abstract method
implemented in Ruby code, like processCondition?

- Charlie

john casu wrote:
>
>>
>>>>
>>>>     p "in process condition\n"
>>> listing them and forcing them to be accessible so long as security
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-11-04 05:54
(Received via mailing list)
I think I know what the problem in this case might be..

In the java class Behavior, initialize is an abstract function, which
the user has to implement (there's another bug in my code, but that's
irrelevant to this discussion), whereas in jruby it's the class
constructor.

I'm wondering what would happen in this case.



Charles Oliver N. wrote:
>
> Is wakeupOn or any methods it would call lead into an abstract method
> implemented in Ruby code, like processCondition?
>

bug on my part here.  processCondition should be called processStimulus.
  Fixing this didn't change the bug.

processStimulus is an abstract function inherited from the Java class,
which in this case (and this is the entire point of this exercise) is
implemented in Jruby.

but wakeupOn doesn't appear to directly call processStimulus, but sets
things up for it to be called when the wakeup condition matures.



>>
>>> and ran my code.  Still busted, but given that I couldn't find a
>>> Charles Oliver N. wrote:
>>>>>   end
>>>> Are the missing methods protected? There's a standing bug in 1.1.4
>>>>    http://xircles.codehaus.org/manage_email
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2008-11-04 06:09
(Received via mailing list)
Ahh, yes, that's another long-standing issue. I'm not sure we've even
come up with a good workaround for it, since there's no good way to work
around Ruby's need to invoke "initialize" on construction. Hmmm.

So we're probably into new territory here. One idea I'd had for fixing
the "initialize" conflict would be to allow using a different name for
the initialization method on a Ruby subclass of a Java type. A couple
ideas:

__initialize__ (in line with __id__ and __send__ for example):

class MyClass < SomeJavaClass
   def __initialize__
     # called for construction instead of initialize
   end

   def initialize
     # works as method impl for initialize from superclass
   end
end

ClassName (like a Java constructor):

class MyClass < SomeJavaClass
   def MyClass
     # called for construction instead of initialize...
   end
...

I'm looking for input on this. If we come up with something reasonable,
we can look to push it in 1.1.6, which we want to flip pretty soon.

- Charlie

john casu wrote:
>
>> Ruby initializer; but abstract methods it implements will not be
> which in this case (and this is the entire point of this exercise) is
>>> This is still broken in today's 1.1.5 release, but I'm getting a
>>> thanks,
>>>> thanks for your help,
>>>>>> I'm doing some work with Java3D 1.5.3/JRuby 1.1.4, and I'm trying
>>>>>>   end
>>>>> security settings allow it.
>>>>
>>> ---------------------------------------------------------------------
>>    http://xircles.codehaus.org/manage_email
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-11-04 06:28
(Received via mailing list)
Charles Oliver N. wrote:
> Ahh, yes, that's another long-standing issue. I'm not sure we've even
> come up with a good workaround for it, since there's no good way to work
> around Ruby's need to invoke "initialize" on construction. Hmmm.
>

I'd be inclined to use a keyword like attr_constructor to tell jruby (or
any other ruby) to explicitly override the default naming:

def MyClass < SomeJavaClass
   attr_constructor :the_actual_ruby_constructor

   def the_actual_ruby_constructor
   #
   end

   def initialize
     # now an overridden java method
   end
end

>   end
>     # called for construction instead of initialize...
>>
>>> I suspect this is a still-open issue where calling abstract methods
>>>
>>
>>>>
>>>>
>>>>> -john c.
>>>>>>>
>>>>>>>
>>>>>> - Charlie
>>>>> ---------------------------------------------------------------------
>>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Chiaming H. (Guest)
on 2008-11-04 15:09
(Received via mailing list)
I would vote for the first suggestion by Charlie:
__initialize__ (in line with __id__ and __send__ for example)

because this is more a more Ruby-like syntax (since this is on the Ruby
side).

Cheers,
Chiaming H.



----- Original Message ----
From: john casu <removed_email_address@domain.invalid>
To: removed_email_address@domain.invalid
Sent: Monday, November 3, 2008 8:26:15 PM
Subject: Re: [jruby-user] Java inheritance question..

Charles Oliver N. wrote:
> Ahh, yes, that's another long-standing issue. I'm not sure we've even come up with a 
good workaround for it, since there's no good way to work around Ruby's need to invoke 
"initialize" on construction. Hmmm.
>

I'd be inclined to use a keyword like attr_constructor to tell jruby (or
any other ruby) to explicitly override the default naming:

def MyClass < SomeJavaClass
  attr_constructor :the_actual_ruby_constructor

  def the_actual_ruby_constructor
  #
  end

  def initialize
    # now an overridden java method
  end
end

>     # works as method impl for initialize from superclass
>
>>
>> processStimulus is an abstract function inherited from the Java class, which in this 
case (and this is the entire point of this exercise) is implemented in Jruby.
>>>> gui/gui_display.rb:40:in `initialize': invokee not a java object (TypeError)
>>>>> Charlie,
>>>>> Charles Oliver N. wrote:
>>>>>>>
>>>>>> - Charlie
>>>>> ---------------------------------------------------------------------
>>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Matt B. (Guest)
on 2008-11-04 18:10
(Received via mailing list)
john casu wrote:
> Charles Oliver N. wrote:
>> Ahh, yes, that's another long-standing issue. I'm not sure we've even
>> come up with a good workaround for it, since there's no good way to
>> work around Ruby's need to invoke "initialize" on construction. Hmmm.
>>
>
> I'd be inclined to use a keyword like attr_constructor to tell jruby (or
> any other ruby) to explicitly override the default naming:

Or, how about a keyword, like alias, that maps the Java (abstract or
not) method name to a ruby method impl?

def MyClass < SomeJavaClass
   java_method_override initialize java_initialize
   java_method_override baseClassMethodName ruby_method_name

   def java_initialize
     puts "implemented the 'interface' method."
   end

   def ruby_method_name
     base_res = super
     puts "added some stuff to #{base_res}"
     base_res
   end
end


--
Matt

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2008-11-04 20:19
(Received via mailing list)
Matt B. wrote:
> Or, how about a keyword, like alias, that maps the Java (abstract or
> not) method name to a ruby method impl?
>
> def MyClass < SomeJavaClass
>   java_method_override initialize java_initialize
>   java_method_override baseClassMethodName ruby_method_name

This is probably worth adding as well as __initialize__ which still
seems the most Ruby-like solution to the more common problem of mapping
constructors. It's a little wordy though.

First, it would have to be symbols; "alias" is a keyword and as such can
take non-symbols, but this would not be a keyword.

Second...maybe just java_override? java_alias? java_alias might raise
the expectation that it's going to *create* a method rather than just
tag one as being associate with a particular Java name.

So maybe..

def MyClass < SomeJavaClass
   java_override :initialize => :java_initialize
or
   java_method :initialize => :java_initialize
or
   bind_java :java_initialize => :initialize

Hmm.

FWIW, this is a valid discussion even with __initialize__ present, since
there's a few other methods we don't allow you to implement (__id__,
__send__, and others).

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-11-04 20:44
(Received via mailing list)
Charles Oliver N. wrote:
>>> (or any other ruby) to explicitly override the default naming:
> constructors. It's a little wordy though.
> def MyClass < SomeJavaClass
> __send__, and others).
>


I wasn't sure if initialize was the only method one has to watch out
for.   I'd also point out that jruby isn't the only ruby built on the
back of another languages' runtime.  macruby comes to mind.

I'd be in favor of a solution that was explicit, wrt overriding
initialize, etc.. and one that could be used as the basis for a generic
mechanism for solving the problem.

Are there other cross-language constructs, such as interrupts, for
example, that behave differently or don't quite map exactly, in Java and
Jruby ??  How would one handle those ?

> - Charlie
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2008-11-04 23:19
(Received via mailing list)
john casu wrote:
> I wasn't sure if initialize was the only method one has to watch out
> for.   I'd also point out that jruby isn't the only ruby built on the
> back of another languages' runtime.  macruby comes to mind.

Actually that's a good idea, Laurent might have similar issues to deal
with integrating into ObjC type hierarchies. We should talk to him.

> I'd be in favor of a solution that was explicit, wrt overriding
> initialize, etc.. and one that could be used as the basis for a generic
> mechanism for solving the problem.

I agree. In general it seems like putting control in the hands of the
user is better than trying to get at the "best" magic.

> Are there other cross-language constructs, such as interrupts, for
> example, that behave differently or don't quite map exactly, in Java and
> Jruby ??  How would one handle those ?

As in a thread interrupt? For the most part we just try to implement
blocking operations to be interruptible in JRuby. In general, Ruby has a
lot more ways to interrupt things than Java does, so most of those cases
come along for the ride.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
john casu (Guest)
on 2008-11-04 23:33
(Received via mailing list)
Charles Oliver N. wrote:
>> generic mechanism for solving the problem.
> lot more ways to interrupt things than Java does, so most of those cases
> come along for the ride.
>

ooops.. brain freeze..   I meant exceptions..

What I'm thinking of are cases, as in the constructor, where the mapping
  between jruby & java isn't exact.  In this case, an exception raised
in a Java routine might not be caught by the right rescue clause in a
jruby  exception block, and vice versa.




> - Charlie
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.