Last active
August 29, 2015 14:19
-
-
Save roolo/9cf93b96669b94e8c83b to your computer and use it in GitHub Desktop.
JRuby tryout stuff
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
| public class Dog{ | |
| String breed; | |
| int age; | |
| String color; | |
| void barking(){ | |
| System.out.println("Bark"); | |
| } | |
| void hungry(){ | |
| } | |
| void sleeping(){ | |
| } | |
| } | |
| Dog shelter[] = [new Dog]; |
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
| class Dog | |
| breed = ''; | |
| age = nil; | |
| color = ''; | |
| def barking | |
| puts 'Bark' | |
| end | |
| def hungry | |
| end | |
| def sleeping | |
| end | |
| end | |
| shelter = [Dog.new] | |
| shelter[0].barking |
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
| NameError: cannot link Java class Inter, probable missing dependency: Inter (wrong name: cz/codeland/gunlicensetester/util/Inter) | |
| for_name at org/jruby/javasupport/JavaClass.java:1286 | |
| get_proxy_class at org/jruby/javasupport/JavaUtilities.java:34 | |
| java_import at file:/Users/mailo/.rvm/rubies/jruby-9.0.0.0.pre1/lib/jruby.jar!/jruby/java/core_ext/object.rb:47 | |
| map at org/jruby/RubyArray.java:2306 | |
| java_import at file:/Users/mailo/.rvm/rubies/jruby-9.0.0.0.pre1/lib/jruby.jar!/jruby/java/core_ext/object.rb:34 | |
| __script__ at inter.rb:10 |
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
| //package cz.codeland.gunlicensetester.util; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| public class Inter | |
| { | |
| private ArrayList<Integer> array; | |
| public Inter(Integer... integers) | |
| { | |
| array = new ArrayList<>(Arrays.asList(integers)); | |
| } | |
| @Override | |
| public String toString() | |
| { | |
| StringBuilder result = new StringBuilder(array.size()); | |
| for(Integer integer : array) { | |
| result.append(integer); | |
| } | |
| return result.toString(); | |
| } | |
| public Boolean add(Integer number) { | |
| return array.add(number); | |
| } | |
| } |
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
| # Ruby stuff | |
| require 'pp' | |
| require 'java' | |
| require 'inter.jar' | |
| #import 'cz.codeland.gunlicensetester.util.Inter' | |
| pp $CLASSPATH.inspect | |
| import 'Inter' | |
| #pp java.lang.cz.codeland.gunlicensetester.util.inter.new.inspect | |
| module Codeland | |
| java_import 'cz.codeland.gunlicensetester.util' | |
| end | |
| pp Codeland.methods.inspect | |
| pp Inter.new.inspect | |
| pp Codeland::Inter.new.inspect | |
| puts Cz::Codeland::Gunlicensetester::Util.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment