Skip to content

Commit

Permalink
Add const_get to java package Fixes #435
Browse files Browse the repository at this point in the history
  • Loading branch information
atambo committed Dec 29, 2012
1 parent 2846144 commit d3157b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/java_integration/packages/access_spec.rb
Expand Up @@ -40,6 +40,10 @@
m = Module.new { import 'java.lang' }
m::System.should respond_to 'getProperty'
end

it "supports const_get" do
java.util.const_get("Arrays").should respond_to "asList"
end
end

describe "A class in the default package" do
Expand Down
4 changes: 4 additions & 0 deletions src/jruby/java/java_package_module_template.rb
Expand Up @@ -5,6 +5,10 @@ def const_missing(const)
end
private :const_missing

def const_get(const)
JavaUtilities.get_proxy_class(@package_name + const.to_s)
end

def method_missing(sym, *args)
Kernel.raise ArgumentError, "Java package `#{package_name}' does not have a method `#{sym}'" unless args.empty?
JavaUtilities.get_proxy_or_package_under_package self, sym
Expand Down

0 comments on commit d3157b7

Please sign in to comment.