Closed
Bug 227615
Opened 21 years ago
Closed 20 years ago
String.replace fails when used inside a function that is called by an applet using Live connect
Categories
(Core Graveyard :: Java: OJI, defect)
Tracking
(Not tracked)
RESOLVED
WORKSFORME
People
(Reporter: sanket, Assigned: yuanyi21)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6a) Gecko/20031030 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6a) Gecko/20031030 Hi i was developing an applet which was calling a javascript function.this is being established using live connect.The function call goes correctly and the function seems to be working fine except in one case. If i make a call to a String.replace function the code does not seem to execute. I tried Mozilla 1.5, 1.6a , netscape 7 ,firebird on windows. then i rebooted and tried on linux Mozilla on linux also gave the same error. But the same code works in IE on windows and Konqueror in Linux So this seems like a bug in mozilla. In essence the function execution is terminated. I checked the javascript and java consoles!No errors were reported. Reproducible: Always Steps to Reproduce: if i use the simple code <script> var Message="hello"; if(Message.replace) { alert("Trying to replace"); Message=Message.replace('ello','handsome'); alert("replace complete"); }else { alert("Replace not supported"); } </script> on a webpage it works. But if i put the same code inside a function and when my applet calls it with the string as an argument the code does not execute. Also no subsequent code that comes after the call to string.replace is executed. Actual Results: The function string replace should replace the regex with the new string! Nothing of that sort happens. Statements after this call are also not executed. In essence the function execution is terminated. I checked the javascript and java consoles!No errors were reported.
Comment 1•21 years ago
|
||
This sounds similar to a number of other issues that OJI is considering. Reassigning to Java:OJI component for further triage -
Assignee: live-connect → kyle.yuan
Status: UNCONFIRMED → NEW
Component: Java: Live Connect → Java: OJI
Ever confirmed: true
Comment 3•21 years ago
|
||
Nothing to do with Java.
Reporter | ||
Comment 4•21 years ago
|
||
Hi The fact is the function fails only when a call to the function is made from a java applet.All the rest of the calls seem to be working. so it must be a bug in java live connect or something. I am not a mozilla developer so i dont know the exact words. My code works in IE and konqueror so it must also work in Mozilla. But it fails to work and that problem must be solved. Thanks/Regards Sanket Gupta
it works for me on both Windows 2000 & Linux. Here is my test case. You can see what the difference is. <html> <body> <applet id="testApplet" code="TestLC.class" MAYSCRIPT="true"> </applet> <script> function stringreplace(oldstr, newstr) { var Message = "hello"; Message = Message.replace(oldstr, newstr); alert(Message); } </script> </body> </html> ===================================================== import java.awt.*; import java.awt.event.*; import java.applet.Applet; import netscape.javascript.JSObject; import netscape.javascript.JSException; public class TestLC extends Applet implements ActionListener { JSObject win = null; public void init() { Button b1 = new Button("call"); b1.addActionListener(this); add(b1); } public void actionPerformed(ActionEvent e) { String arg = e.getActionCommand(); try { win = (JSObject)JSObject.getWindow(this); if (win == null) { System.out.println("JSObject win = null"); return; } if (arg.equals("call")) { test_call(); } } catch (JSException ex) { System.out.println(ex.toString()); } } private void test_call() throws JSException { String args[] = new String[2]; args[0] = "ello"; args[1] = "handsome"; win.call("stringreplace", args); } }
Reporter | ||
Comment 6•21 years ago
|
||
Hi I tried your code and i agree that it works. But the fact is that it fails to work in my code.The function call goes in smoothly and any statements that come before the replace function are executed correctly. So it definately isa mozilla bug One thing is that my applet is a mustithreaded socket based applet which recieves incoming data and displays tha data using javascript. Before it displays the data some strings have to be replaced and thats where the problem occurs. Can it be an error in the way mozilla handles multithreaded applets? I am not sure what else to say.
My test case proves that java->javascript call works. For your case , it's either the problem in your code or like you said, some problem with the multithread applets. But without test case, I'm afraid we can do nothing for this.
WFM. Feel free to reopen it if you are still seeing this bug.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → WORKSFORME
Reporter | ||
Comment 9•20 years ago
|
||
(In reply to comment #8) > WFM. Feel free to reopen it if you are still seeing this bug. Well i stopped using that function for now.Basically i rewrote the function call myself in javascript.Thats the best solution i had.
You need to log in
before you can comment on or make changes to this bug.
Description
•