Flex remoteobject calls java overload Functions
Version:
Flex sdk: 3.2, jdk: 1.7; intellij idea14; flex builder3;
Problem description:
Can I call java's heavy-load method by using the remoteObject of actionscript? Is the overloaded method called?
Lab:
1. java background code:
public String test1(int info){ System.out.println("int:"+info); return "int:"+info; } public String test1(float info){ System.out.println("float:"+info); return "float:"+info; } public String test1(double info){ System.out.println("double:"+info); return "double:"+info; } public String test1(long info){ System.out.println("long:"+info); return "long:"+info; } public String test1(String info){ System.out.println("String:"+info); return "String:"+info; }2. flex front-end code:
function testForOverload(type:String):void{if("1"==type){var info :int = 3;hDFSFileUtil.test1(info);}if("2"==type){var info2 :String = "str3";hDFSFileUtil.test1(info2);}if("3"==type){var info3:Number =new Number(33);hDFSFileUtil.test1(info3);}}
<Mx: button label = "Test 1" click = "testForOverload ('1')" visible = "true"> <mx: button label = "Test 2" click = "testForOverload ('2')" visible = "true"> <mx: button label = "Test 3" click = "testForOverload ('3')" visible = "true"> </mx: button> </mx: button>Directly click "Test 1", "Test 2", and "Test 3" buttons and find that the called buttons are long, string, long, this indicates that the string and int/Number types in flex can be distinguished. But what type is int/Number transferred to java? Is it long?
Lab:
Adjust the positions of the first four functions in the java background and find that no matter which function, if it is in the final (normal sorting), it is called; for example, if you move the double function to the front of the string function, java calls the double function;
Summary:
This figure is from the flex4 document. We can see that when the basic type is transferred from flex to java, the int type is serialized to Integer and Number is serialized to Double, and then received on the java side. However, there are multiple types of java-side receivers;
Therefore, the conclusion is that flex can call the java-side overload function to a certain extent. (Note that flex itself does not support overloading.) However, some problems may occur; therefore, it is best to define different function names;