We can work around this issue by not using auto-boxing, but I wanted to make
sure you knew about this change in behavior between 1.5.1 and 1.5.2. In
addition, I tested it under a 1.6 snapshot from late last week and it fails
on that build as well.
Thanks,
Chuck
public class Autobox {
public static void main(String[] args) {
new GroovyShell().evaluate("Autobox.Util.printByte(\"1\",
Byte.valueOf((byte)1));");
new GroovyShell().evaluate("Autobox.Util.printByte(\"1\",
(byte)1);");
}
public static class Util {
public static void printByte(String str, Byte defaultValue) {
System.out.println(str + ", " + defaultValue);
}
}
}
[jboss@snook] ~/prj/groovy $ java -cp .:./groovy-all-1.5.1.jar Autobox
1, 1
1, 1
[jboss@snook] ~/prj/groovy $ java -cp .:./groovy-all-1.5.2.jar Autobox
1, 1
Exception in thread "main" groovy.lang.MissingMethodException: No signature
of method: static Autobox$Util.printByte() is applicable for argument types:
(java.lang.String, java.lang.Byte) values: {"1", 1}
at
groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1144)
at
groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1130)
at
org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:748)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
at Script1.run(Script1.groovy:1)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:543)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:518)
at Autobox.main(Autobox.java:7)
--
View this message in context: http://www.nabble.com/Autobox-issue-with-1.5.2-tp15168956p15168956.html
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com
I guess you have good reasons for that, but you are making your life
here a bit more difficult than needed.
Autobox.Util.printByte("1",1)
that would do it already. Groovy is able to call a method taking a byte
by using a normal int. well... If the above does not work, then it is
another bug.
bye blackdrag
--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/
glaforge wrote:
>
> Looks like a bug worth a JIRA issue!
>
--
View this message in context: http://www.nabble.com/Autobox-issue-with-1.5.2-tp15168956p15169385.html
import groovy.lang.GroovyShell;
public class Autobox {
public static void main(String[] args) {
new GroovyShell().evaluate("Autobox.Util.printByte(\"1\",
Byte.valueOf((byte)1));");
new GroovyShell().evaluate("Autobox.Util.printByte(\"1\", 1);");
new GroovyShell().evaluate("Autobox.Util.printByte(\"1\",
(byte)1);");
}
public static class Util {
public static void printByte(String str, Byte defaultValue) {
System.out.println(str + ", " + defaultValue);
}
}
}
[jboss@snook] ~/prj/groovy $ java -cp .:./groovy-all-1.5.1.jar Autobox
1, 1
Exception in thread "main" groovy.lang.MissingMethodException: No signature
of method: static Autobox$Util.printByte() is applicable for argument types:
(java.lang.String, java.lang.Integer) values: {"1", 1}
at
groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1127)
at
groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1113)
at
org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:744)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
at Script1.run(Script1.groovy:1)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:459)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:434)
at Autobox.main(Autobox.java:7)
Jochen Theodorou wrote:
>
> I guess you have good reasons for that, but you are making your life
> here a bit more difficult than needed.
>
> Autobox.Util.printByte("1",1)
>
> that would do it already. Groovy is able to call a method taking a byte
> by using a normal int. well... If the above does not work, then it is
> another bug.
>
> bye blackdrag
>
> --
> Jochen "blackdrag" Theodorou
> The Groovy Project Tech Lead (http://groovy.codehaus.org)
> http://blackdragsview.blogspot.com/
> http://www.g2one.com/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--
View this message in context: http://www.nabble.com/Autobox-issue-with-1.5.2-tp15168956p15169762.html
Sent from the groovy - user mailing list archive at Nabble.com.
I didn't mean it will work that way, I wanted to tell you that it should
have worked that way. That it did not proves that there is a major error