Skip to content

Instantly share code, notes, and snippets.

@sberan
Created November 6, 2010 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sberan/665726 to your computer and use it in GitHub Desktop.
Save sberan/665726 to your computer and use it in GitHub Desktop.
Top 20 interfaces with the most methods
require 'java'
import java.util.jar.JarFile;
sys_jar_loc = "/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar"
interfaces = JarFile.new(sys_jar_loc).entries.map do |entry|
if entry.name.match /java.*\.class$/ and not entry.name.match(/\$/)
begin
clas = java.lang.Class.forName(entry.name.gsub(/\.class$/,'').gsub(/\//,'.'))
clas.isInterface ? clas : nil
rescue
nil
end
end
end
interfaces.compact.sort_by{|c| -c.methods.size}.take(20).each_with_index do |c, i|
puts "#{i+1}. #{c.name} - #{c.methods.size} methods"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment