Java-Cocoa NSAppleScript and bus errors
Java-Cocoa NSAppleScript and bus errors
- Subject: Java-Cocoa NSAppleScript and bus errors
- From: Jamie Gunn <email@hidden>
- Date: Fri, 31 Oct 2003 17:32:20 +0100
Dear cocoa-dev list
I am writing a Java-Cocoa application which uses class NSAppleScript to
execute apple scripts to remotely drive an application. On many occasions I
get the error signal 10 (SIGBUS) or signal 11(SIGSEGV)
I then wrote this simple program (below) to execute a simple apple script
5000 times, but still get bus error.
If I increase the sleep to 500 then the loop eventually completed without
error.
Is here a bug in NSAppleScript? Has anyone insight into this problem?
With kind regards Jamie Gunn
import java.util.*;
import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;
public class SimpleJava {
public static void main (String args[]) {
NSApplication app = NSApplication.sharedApplication();
int x = 5000;
while (x-- > 0){
String script = "tell application \"Finder\"\n" +
"get the name of every item in the desktop\n" +
"end tell";
NSMutableDictionary errors = new NSMutableDictionary();
NSAppleScript myScript = new NSAppleScript(script);
NSAppleEventDescriptor results = myScript.execute(errors);
if (results == null) {
System.out.println("Error:\n");
}
else {
int numberOfDesktopItems = results.numberOfItems();
System.out.println(x + " NoOfFolders=" +
numberOfDesktopItems);
/*
for(int i = 1; i <= numberOfDesktopItems; i++) {
NSAppleEventDescriptor subDescriptor =
results.descriptorAtIndex(i);
System.out.println(" " +
subDescriptor.stringValue());
}
*/
}
try {
Thread.sleep(10);
} catch(Exception e){}
}
}
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.