Closed Bug 114918 Opened 24 years ago Closed 24 years ago

The method overloading of liveconnect can not differentiate between different types of numbers

Categories

(Core Graveyard :: Java: Live Connect, defect)

x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED WORKSFORME

People

(Reporter: xiaobin.lu, Assigned: beard)

References

()

Details

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1 BuildID: 20011212 This is my applet code. I would call these applet method from JS. However, whenever I call setValue("test1", 1), it always calls setValue("test1", 1.0) method. public class JApplet_TEST extends JApplet { public void setValue (String par, int val) { System.out.println("par="+par+ " int val="+val); } public void setValue (String par, boolean val) { System.out.println("par="+par+ " boolean val="+val); } public void setValue (String par, double val) { System.out.println("par="+par+ " double val="+val); } public void setValue (String par, String val) { System.out.println("par="+par+ " String val="+val); } } I digged into the code and found that when the liveconnect engine tries to reflect these java methods, it can not differentiate between data types because Javascript defines data types as below. typedef enum JSJType { JSJTYPE_VOID, /* undefined */ JSJTYPE_BOOLEAN, /* boolean */ JSJTYPE_NUMBER, /* number */ JSJTYPE_STRING, /* string */ JSJTYPE_NULL, /* null */ JSJTYPE_JAVACLASS, /* JavaClass */ JSJTYPE_JAVAOBJECT, /* JavaObject */ JSJTYPE_JAVAARRAY, /* JavaArray */ JSJTYPE_JSARRAY, /* JS Array */ JSJTYPE_OBJECT, /* Any other JS Object, including functions */ JSJTYPE_LIMIT } JSJType; Those types do not differentiate number types in more details. This may cause problem sometimes. Reproducible: Always Steps to Reproduce: 1. Open the URL specified. 2. Click the Liveconnect Test 1 and liveconnect Test 3. 3. Open Java console, you should be able to see some messages printed out. Notice that liveconnect Test3 uses the method setValue(String, double) to print. Actual Results: It calls setValue(String, double) Expected Results: It calls setValue(String, int)
confirming, but the problem is that ECMAScript has no concept of Integer vs Float numbers, if I understand correctly....
Reassigning to Patrick; cc'ing Brendan, Roger -
Assignee: rogerl → beard
Status: UNCONFIRMED → NEW
Ever confirmed: true
Yes, the current JavaScript engine is based on the ECMAScript 3 standard, and there is no other kind of number other than double- precision floating point. However, there is a mechanism called "explicit resolution" that can be used to select a specific method.
Patrick: Can you tell me how to use explict resolution method? Thanks!
If you change your test3 function to, you can select the method with the int parameter: function test3() { document.test["setValue(java.lang.String,int)"]("test 3", 3); } In general, you look up the method you want with a fully qualified set of method signatures. All of the primitive type names are as they are defined in Java, byte, short, int, long, float, double, and boolean. For object parameters, use the fully qualified class name. No spaces between signatures, just comma delimited.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → WORKSFORME
Marking Verified - Xiaobin, if this is still a problem, please reopen this bug; thanks -
Status: RESOLVED → VERIFIED
Ok for me!
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.