-
-
Save jimtng/ae5a84b1ad8764481604c28bed60498e to your computer and use it in GitHub Desktop.
jruby overload
This file contains 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
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
import javax.script.ScriptException; | |
public class OverloadBug { | |
public static void overloaded(String a, String b, OverloadBug c) { | |
System.out.println("Correct"); | |
} | |
public static void overloaded(String a, String b, float c) { | |
System.out.println("Wrong"); | |
} | |
public OverloadBug() {} | |
public void run() throws ScriptException { | |
ScriptEngineManager manager = new ScriptEngineManager(); | |
ScriptEngine engine = manager.getEngineByName("jruby"); | |
engine.eval("Java::OverloadBug.overloaded(nil, 'one', Java::OverloadBug.new)"); // This will call the correct one | |
} | |
public static void main(String[] args) throws ScriptException { | |
OverloadBug bug = new OverloadBug(); | |
bug.run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment