History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-679
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Blocker Blocker
Assignee: Charles Oliver Nutter
Reporter: R. Mark Volkmann
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JRuby

Constructor arities should be able to be different when extending a concrete Java class

Created: 09/Mar/07 06:08 AM   Updated: 06/May/07 09:49 PM
Component/s: Java Integration
Affects Version/s: JRuby 0.9.8
Fix Version/s: JRuby 1.0.0RC1

Time Tracking:
Not Specified

Environment: Mac OS X


 Description  « Hide
When the simple code below is run, the following error is reported.

/Users/enebo/jruby/releases/jruby-0_9_8/src/builtin/javasupport.rb:486:in `__jcreate!': wrong # of arguments for constructor (NameError)

require 'java'

Observable = java.util.Observable
Observer = java.util.Observer

class Weather < Observable
def initialize(temp)
@temp = temp
end

def temperature
@temp
end

def temperature=(temp)
@temp = temp
setChanged
notifyObservers
end
end

class Meteorologist < Observer
def initialize(weather)
weather.addObserver(self)
end

def update(observable, arg)
puts "The current temperature is #{observable.temperature}."
end
end

weather = Weather.new(70)
meteorologist = Meteorologist.new(weather)
weather.temperature = 100



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Charles Oliver Nutter - 27/Mar/07 03:41 PM
This could be the big __jcreate! bug that's been hitting a few people. Must be fixed asap.

Bill Dortch - 21/Apr/07 08:42 AM
There are actually three issues here:

1. The reported issue is a (lack of) documentation bug. The initialize method just needs to call super with an appropriate number of arguments (none, in this case):

class Weather < Observable
def initialize(temp)
super()
@temp = temp
end
.....
class Meteorologist < Observer
def initialize(weather)
super()
weather.addObserver(self)
end
.....

Doing that then brings us to:

2. self == nil when referenced from initialize in an interface proxy. I included the fix for this with the patch for JRUBY-664 (it was just a line or two of code).

Having that fixed brings us to:

3. Can't call a protected method (setChanged in this case) from a generated subclass. See related issues JRUBY-194 and JRUBY-705. I don't have a fix yet, but I'm thinking about it, may have something this weekend.

-Bill


Bill Dortch - 06/May/07 08:18 PM
As noted previously, the reported issue is a non-issue, and the secondary issue has been resolved. The remaining issue is the same as JRUBY-194.

Charles Oliver Nutter - 06/May/07 08:20 PM
Ok Bill, thanks for the clarification, I was confused.

Charles Oliver Nutter - 06/May/07 09:49 PM
Closing for 1.0RC1