2010-06-01 5 views

답변

6

Looksee가 인터프리터를 패치하므로 JRuby, XRuby, IronRuby, Ruby.NET, Rubinius, tinyrb, RubyGoLightly, MacRuby, HotRuby, BlueRuby, Cardinal, MagLev가 아닌 MRI 및 YARV에서만 작동합니다. SmallRuby, Red Sun 및 기타 모든 구현. 당신이 핫스팟을 패치하고자하는 경우

그래서, 난 당신이 기본적인 성찰에 관해서는 자바 해당 :-)

을 채찍질 할 수 있는지 해요, 그냥 ™ 작동 :

require 'java' 
java.lang.String.public_instance_methods.sort.reject {|m| m =~ /[_?!=~<>]/ } 
# => [:bytes, :charAt, :class, :clone, :codePointAt, :codePointBefore, 
# => :codePointCount, :com, :compareTo, :compareToIgnoreCase, :concat, 
# => :contains, :contentEquals, :display, :dup, :empty, :endsWith, :equals, 
# => :equalsIgnoreCase, :extend, :finalize, :freeze, :getBytes, :getChars, 
# => :getClass, :hash, :hashCode, :id, :indexOf, :initialize, :inspect, :intern, 
# => :isEmpty, :java, :javax, :lastIndexOf, :length, :matches, :method, 
# => :methods, :notify, :notifyAll, :offsetByCodePoints, :org, :regionMatches, 
# => :replace, :replaceAll, :replaceFirst, :send, :split, :startsWith, 
# => :subSequence, :substring, :synchronized, :taint, :tap, :toCharArray, 
# => :toLowerCase, :toString, :toUpperCase, :trim, :trust, :type, :untaint, 
# => :untrust, :wait] 

물론 JRuby의 주요 요점 중 하나는 Java와 Ruby 객체 모델을 가능한 한 가깝게 통합하는 것이므로 Java와 Ruby의 두 가지 방법을 모두 여기에서 얻지 만 특이한 문자를 가진 모든 메소드를 거부하거나 자바에서 불법적 인 일반, 우리는 합리적으로 깨끗한 목록과 나머지 Ru 얻을 방법에 따라 이 표시되지 않으므로에 위치 할 수 없습니다.

6

에만 Java 메소드 얻을 수있는 기본 자바 클래스와 일반 반사를 사용

java.lang.String.java_class.declared_instance_methods 

이는 Class.getDeclaredMethods() 자바 메소드 호출에 직접 매핑하고, 각 자바 인스턴스 방법 Java::JavaMethod 객체의 배열을 얻을 수를 목표 클래스.

관련 문제