Skip to content

Can't Compile Duck Punched String #1810

Open
jstemen opened this Issue Jul 13, 2014 · 0 comments

1 participant

@jstemen
jstemen commented Jul 13, 2014

While I can run the scripts below. I'm unable to compile them into .java files using jrubyc.

##string.rb###
class String
def jared
"jared can change things"
end
end

##broken_runner.rb###
require 'java'
require_relative './string'
class BrokenRunner
java_signature 'void main(String[])'
def self.main(args)
BrokenRunner.new().magic
end
def magic
puts "test".jared
puts "123".jared
end
end

jared@jaredSatelliteL650:~/JaredsDocuments/workspace/exampleRuby$ jrubyc --javac broken_runner.rb string.rb
/home/jared/JaredsDocuments/workspace/exampleRuby/BrokenRunner.java:34: error: incompatible types
"").toString();
^
required: String
found: java.lang.String
/home/jared/JaredsDocuments/workspace/exampleRuby/BrokenRunner.java:35: error: method executeScript in class Ruby cannot be applied to given types;
ruby.executeScript(source, "broken_runner.rb");
^
required: java.lang.String,java.lang.String
found: String,java.lang.String
reason: actual argument String cannot be converted to java.lang.String by method invocation conversion
/home/jared/JaredsDocuments/workspace/exampleRuby/String.java:21: error: incompatible types
"end").toString();
^
required: String
found: java.lang.String
/home/jared/JaredsDocuments/workspace/exampleRuby/String.java:22: error: method executeScript in class Ruby cannot be applied to given types;
ruby.executeScript(source, "string.rb");
^
required: java.lang.String,java.lang.String
found: String,java.lang.String
reason: actual argument String cannot be converted to java.lang.String by method invocation conversion
4 errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.