Jruby call method from super java class

I am trying to create a subclass in jruby which overrides the keys
method from the super java class properties cause i want to sort the
entries in the properties class by the keys:

class SortedProperties < java.util.Properties
def keys
keysEnum = super().keys()
keyList = java.util.Vector.new
keysEnum.elements.each do |element|
puts element.to_s
keyList.add(element.to_java(:String))
end
java.util.Collections.sort(keyList)
puts keyList.elements().to_s
return keyList.elements()
end
end

I am doing definitly something wrong with the super statement but i
don’t know what. Searched a lot but can’t find anything that points me
to the correct call of the method keys() in the super class properties.

Why not just use Ruby to sort them?:

sorted_keys = my_properties_object.keys.sort

If you’re using Properties objects created by the JVM, you’ll call the
Properties class’ keys method and not your custom method.

If you’re creating your own Properties objects, then you might not want
to
use a Ruby subclass of Properties; Java code won’t see the subclass, and
if
you’re only using it in Ruby, then a hash would probably be a lot more
convenient than a Properties object.

  • Keith

On Wed, Dec 3, 2014 at 2:31 PM, Jochen S. [email protected]