8055906: Avoid throwing an exception with filled in stack trace as part of the normal control flow
Reviewed-by: attila, hannesw
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ApplySpecialization.java Tue Aug 26 11:32:12 2014 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ApplySpecialization.java Tue Aug 26 11:42:07 2014 +0200
@@ -35,6 +35,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import jdk.nashorn.internal.ir.AccessNode;
import jdk.nashorn.internal.ir.CallNode;
import jdk.nashorn.internal.ir.Expression;
@@ -127,6 +128,14 @@
*/
private boolean argumentsEscape(final FunctionNode functionNode) {
+ @SuppressWarnings("serial")
+ final UnsupportedOperationException uoe = new UnsupportedOperationException() {
+ @Override
+ public Throwable fillInStackTrace() {
+ return null;
+ }
+ };
+
final Deque<Set<Expression>> stack = new ArrayDeque<>();
//ensure that arguments is only passed as arg to apply
try {
@@ -151,7 +160,7 @@
@Override
public Node leaveIdentNode(final IdentNode identNode) {
if (isParam(identNode.getName()) || ARGUMENTS.equals(identNode.getName()) && !isCurrentArg(identNode)) {
- throw new UnsupportedOperationException();
+ throw uoe; //avoid filling in stack trace
}
return identNode;
}