When a class has prepended a module, the superclass is reported as itself.
module M; end
class C
prepend M
end
C.superclass
# => C (in JRuby 9.0.0.0)
# => Object (in MRI 2.2.3)
I had a look here: https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyClass.java#L1119
It looks as though we are walking up the inheritance chain and returning the first non-module we find.