Module: Rubeus::Reflection::JavaMethods

Defined in:
lib/rubeus/reflection/java_methods.rb

Defined Under Namespace

Modules: JavaClass, Object

Constant Summary collapse

MODIFIERS =
%w[public protected package_scope private final strict synchronized].freeze
METATYPES =
%w[instance class singleton].freeze
JAVA_METHODS_PATTERN =
/^java_(.+)_methods$/.freeze

Class Method Summary collapse

Class Method Details

.activateObject



3
4
5
6
# File 'lib/rubeus/reflection/java_methods.rb', line 3

def self.activate
  ::Java::JavaClass.send(:include, ::Rubeus::Reflection::JavaMethods::JavaClass)
  ::Object.send(:include, ::Rubeus::Reflection::JavaMethods::Object)
end

.parse(method_name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubeus/reflection/java_methods.rb', line 13

def self.parse(method_name)
  if method_name.to_s == 'java_methods'
    return [], nil
  elsif method_name.to_s =~ JAVA_METHODS_PATTERN
    modifiers = $1.gsub(/_/, "-").gsub(/package-scope/, 'package_scope').split(/-/)
    metatype = METATYPES.include?(modifiers.last) ? modifiers.pop : nil
    if metatype == 'singleton'
      metatype = 'class'
    end
    if (modifiers - MODIFIERS).empty?
      return modifiers, metatype
    else
      return nil, nil
    end
  else
    return nil, nil
  end
end