Daestrum Expert Licensed User Longtime User Jan 31, 2016 #1 Should I be concerned at this warning, I am passing an Integer to a sub that expects a javaobject. I thought a javaobject could take any type of variable. B4X: Expand Collapse Copy ... Log(Integer_toHexString(1,99) << warning on this line "Types do not match. (warning #22)" ... '++++++++++++++++++++++++ '++ AutoGenerated Code ++ '++++++++++++++++++++++++ ' Argument is : int Sub Integer_toHexString(ob As JavaObject, arg As Int) As String Return ob.RunMethod("toHexString",Array(arg)) End Sub
Should I be concerned at this warning, I am passing an Integer to a sub that expects a javaobject. I thought a javaobject could take any type of variable. B4X: Expand Collapse Copy ... Log(Integer_toHexString(1,99) << warning on this line "Types do not match. (warning #22)" ... '++++++++++++++++++++++++ '++ AutoGenerated Code ++ '++++++++++++++++++++++++ ' Argument is : int Sub Integer_toHexString(ob As JavaObject, arg As Int) As String Return ob.RunMethod("toHexString",Array(arg)) End Sub
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2016 #2 Why not use Bit.ToHexString (based on this exact API)? Upvote 0
Daestrum Expert Licensed User Longtime User Jan 31, 2016 #3 I do normally, but I am testing some code that generates the entire sub to execute javaobject.runmethod for any class in the java libraries. (I picked the hextostring as I know what I should get back, all I had to do was type 'Integer', then selected java.lang.Integer, then selected toHexString(int) and the code was produced for me). So can I ignore the warning as the code seems to run ok, but wanted to check. Upvote 0
I do normally, but I am testing some code that generates the entire sub to execute javaobject.runmethod for any class in the java libraries. (I picked the hextostring as I know what I should get back, all I had to do was type 'Integer', then selected java.lang.Integer, then selected toHexString(int) and the code was produced for me). So can I ignore the warning as the code seems to run ok, but wanted to check.
LucaMs Expert Licensed User Longtime User Jan 31, 2016 #4 Daestrum said: Should I be concerned at this warning, I am passing an Integer to a sub that expects a javaobject. I thought a javaobject could take any type of variable. B4X: Expand Collapse Copy ... Log(Integer_toHexString(1,99) << warning on this line "Types do not match. (warning #22)" ... '++++++++++++++++++++++++ '++ AutoGenerated Code ++ '++++++++++++++++++++++++ ' Argument is : int Sub Integer_toHexString(ob As JavaObject, arg As Int) As String Return ob.RunMethod("toHexString",Array(arg)) End Sub Click to expand... You are passing 1 as java object (on which you run a method) Upvote 0
Daestrum said: Should I be concerned at this warning, I am passing an Integer to a sub that expects a javaobject. I thought a javaobject could take any type of variable. B4X: Expand Collapse Copy ... Log(Integer_toHexString(1,99) << warning on this line "Types do not match. (warning #22)" ... '++++++++++++++++++++++++ '++ AutoGenerated Code ++ '++++++++++++++++++++++++ ' Argument is : int Sub Integer_toHexString(ob As JavaObject, arg As Int) As String Return ob.RunMethod("toHexString",Array(arg)) End Sub Click to expand... You are passing 1 as java object (on which you run a method)
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2016 #5 You can ignore it. However it will be better to set the JavaObject internally and then ignore it inside the sub. Upvote 0
You can ignore it. However it will be better to set the JavaObject internally and then ignore it inside the sub.
LucaMs Expert Licensed User Longtime User Jan 31, 2016 #6 I understand that it is a "type mismatch" which should not be warned, but how can you have: 1.RunMethod("toHexString",Array(arg)) ? Java oddities? Upvote 0
I understand that it is a "type mismatch" which should not be warned, but how can you have: 1.RunMethod("toHexString",Array(arg)) ? Java oddities?
Daestrum Expert Licensed User Longtime User Jan 31, 2016 #7 Because Java is nice - in that case it just uses the class ie Integer for the call as that what it expects to be there In 'pure' Java you would write Integer.toHexString(99); I would guess the generated java for the Sub would be like B4X: Expand Collapse Copy public String name_of_the_sub(Object o, Integer arg){ Class<?> c = o.getClass(); ... return c.toHexString(arg); } Last edited: Jan 31, 2016 Upvote 0
Because Java is nice - in that case it just uses the class ie Integer for the call as that what it expects to be there In 'pure' Java you would write Integer.toHexString(99); I would guess the generated java for the Sub would be like B4X: Expand Collapse Copy public String name_of_the_sub(Object o, Integer arg){ Class<?> c = o.getClass(); ... return c.toHexString(arg); }
LucaMs Expert Licensed User Longtime User Jan 31, 2016 #8 Daestrum said: Because Java is nice - in that case it just uses the class ie Integer for the call as that what it expects to be there In 'pure' Java you would write Integer.toHexString(99); I would guess the generated java for the Sub would be like B4X: Expand Collapse Copy public String name_of_the_sub(Object o, Integer arg){ Class<?> c = o.getClass(); ... return c.toHexString(arg); } Click to expand... Now I remember that something like this exists in .Net too (after all, coincidentally, VB.Net, C#, etc. followed Java); but I don't entered into these "subtleties" Upvote 0
Daestrum said: Because Java is nice - in that case it just uses the class ie Integer for the call as that what it expects to be there In 'pure' Java you would write Integer.toHexString(99); I would guess the generated java for the Sub would be like B4X: Expand Collapse Copy public String name_of_the_sub(Object o, Integer arg){ Class<?> c = o.getClass(); ... return c.toHexString(arg); } Click to expand... Now I remember that something like this exists in .Net too (after all, coincidentally, VB.Net, C#, etc. followed Java); but I don't entered into these "subtleties"