Created
April 19, 2013 00:27
-
-
Save pauladam/5417261 to your computer and use it in GitHub Desktop.
Re-opening Java classes from Jruby example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jr-test $: cat jr-test.rb | |
| require 'java' | |
| class java::lang::String | |
| # redefine length to give random values | |
| # instead of the correct one | |
| def length | |
| (rand() * 100).to_i | |
| end | |
| end | |
| j_string = java::lang::String.new(ARGV.first) | |
| puts j_string.length | |
| jr-test $: ruby jr-test.rb a-string | |
| 53 | |
| jr-test $: ruby jr-test.rb a-string | |
| 41 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment