This code:
print(" - Start");
int[] num = new int[] {1,2,3,4,5,6,7,8,9,10};
for(int i : num)
{
print("--> "+ i);
try
{
print(" . try");
if(i == 2)
break;
}
catch (java.lang.Exception e)
{}
finally
{
print(" . finally");
}
}
print(" - End");
Does not work as expected. I.e. the break
seems not to work.
Can anyone explain why this is?
I'm gonna say it's a BeanShell bug. Not for the reasons outlined below (those apply only to Java on the Mac), but because if you put the same code in a main method in a "classic" Java application it does not behave in the same way. That is, the break condition works.
The following applies only to the latest version of Java on the Mac.
I think it's a BeanShell bug. When I try changing the if to the following BeanShell hangs up:
if(i == 2) {
print("trying to break");
break;
}
I forced-closed it and restarted it with the command line. I see the following errors:
$ java -jar bsh-2.0b4.jar
java[1119] <Error>: CGContextGetCTM: invalid context 0x0
java[1119] <Error>: CGContextSetBaseCTM: invalid context 0x0
java[1119] <Error>: CGContextGetCTM: invalid context 0x0
java[1119] <Error>: CGContextSetBaseCTM: invalid context 0x0