Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add const_get to java package Fixes #435 #465

Merged
merged 1 commit into from

3 participants

@atambo
Collaborator

No description provided.

@qmx

looks good to me

@BanzaiMan BanzaiMan merged commit 3289fed into from
@BanzaiMan
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 29, 2012
  1. @atambo
This page is out of date. Refresh to see the latest.
View
4 spec/java_integration/packages/access_spec.rb
@@ -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
View
4 src/jruby/java/java_package_module_template.rb
@@ -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
Something went wrong with that request. Please try again.