Hi all
I’m encountering this rather strange issue.
I have this setup going.
JavaClass.java
public class JavaClass
{
public void pushString() { … }
}
RubyClass.rb
class RubyClass < JavaClass
def pushString
super.pushString # error! (NoMethodError) undefined method
`pushString’
end
end
=====
However, if I have this
JavaClass.java
public class JavaClass implements Serializable
{
public void pushString() {…}
public void writeReplace() {… } // method from Serializable
}
RubyClass.rb
class RubyClass < JavaClass
java_implements ‘Serializable’
java_signature ‘public Object writeReplace()’
def writeReplace
super.pushString #works…
return…
end
end
=====
BUT this doesn’t:
Interface.java
public interface Interface
{
public void test();
public Object test2();
}
JavaClass.java
public class JavaClass implements Serializable, Interface
{
public void pushString() {…}
public void writeReplace() {… } // method from Serializable
public void test() { … }
public Object test2() { return “S”; }
}
RubyClass.rb
class RubyClass < JavaClass
java_implements ‘Serializable, Interface’
java_signature ‘public Object writeReplace()’
def writeReplace
super.pushString #works…
return…
end
java_signature ‘public void test()’
def test
super.pushString # no method error again from nil class
end
java_signature ‘public void test2()’
def test2
super.pushString # no method error , but this time it says
(NoMethodError) undefined method `pushString’ for “S”:String
end
end
=====
Why is this so…?
I’m curious as to why I can call super methods from Serializable’s
interface methods, but doing the same for my own interface doesn’t work.
Also, the last error is even stranger, why would it say “S”:String,
which is the return for my super class’s method?
What’s the best practice for calling super methods? java_send or super?
Thanks!
Regards
Angel