defn/defs need scope to get proper rubyClass for definition.

Fixes #1239
Use common logic for checking singleton class for def self.x
Merge branch 'jruby-1_7'