Skip to content

Commit

Permalink
Merge pull request #465 from atambo/const_get
Browse files Browse the repository at this point in the history
Add const_get to java package Fixes #435
  • Loading branch information
BanzaiMan committed Jan 5, 2013
2 parents 3eb26c2 + d3157b7 commit 3289fed
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 3289fed

Please sign in to comment.