-
Bug
-
Resolution: Duplicate
-
P3
-
8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS Sierra 10.12.6
A DESCRIPTION OF THE PROBLEM :
Sample script:
var return5 = (function(x) {
mark0: {
var y;
if (x !== null) {
y = 5;
break mark0
};
throw 'Bang!'
}
return y
})
print(return5(10))
This prints 'undefined' in Nashorn instead of '5' as expected. If you comment out the throw 'Bang!' and run it prints '5', even though the throw is not hit. If you call the unedited function in Firefox or Chrome, you get '5' as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Put a labelled break in a function that returns a value. Add a throw statement somewhere.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
We get the proper returned value, not 'undefined'.
ACTUAL -
We get 'undefined' as the returned value.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
var return5 = (function(x) {
mark0: {
var y;
if (x !== null) {
y = 5;
break mark0
};
throw 'Bang!' // commenting out this line causes the result to be correct, even though it is not executed.
}
return y
})
print(return5(10)) // prints 'undefined' in Nashorn, not '5'.
---------- END SOURCE ----------
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS Sierra 10.12.6
A DESCRIPTION OF THE PROBLEM :
Sample script:
var return5 = (function(x) {
mark0: {
var y;
if (x !== null) {
y = 5;
break mark0
};
throw 'Bang!'
}
return y
})
print(return5(10))
This prints 'undefined' in Nashorn instead of '5' as expected. If you comment out the throw 'Bang!' and run it prints '5', even though the throw is not hit. If you call the unedited function in Firefox or Chrome, you get '5' as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Put a labelled break in a function that returns a value. Add a throw statement somewhere.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
We get the proper returned value, not 'undefined'.
ACTUAL -
We get 'undefined' as the returned value.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
var return5 = (function(x) {
mark0: {
var y;
if (x !== null) {
y = 5;
break mark0
};
throw 'Bang!' // commenting out this line causes the result to be correct, even though it is not executed.
}
return y
})
print(return5(10)) // prints 'undefined' in Nashorn, not '5'.
---------- END SOURCE ----------
- duplicates
-
JDK-8177691 Labeled break in catch and finally works wrongly, when invoked through nashorn
- Resolved