aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Michajlo Matijkiw <michajlo@google.com>2016-08-01 15:43:25 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-08-02 07:32:46 +0000
commit32994caee8e2d06dad9006c8a6e0931e03818403 (patch)
tree5fd43f5f665afdd1fd28bc031073510c3e1d19dd /src/main
parent8b4df1b70eb040a6813579690ad8ce4dbe467e0a (diff)
Don't fill in stack trace for ReturnException
This is used to implement return, it's not really an exceptional condition requiring a full trace. -- MOS_MIGRATED_REVID=128988641
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/EvalException.java21
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java6
2 files changed, 22 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalException.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalException.java
index 2f7ca84564..97d695f91d 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/EvalException.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalException.java
@@ -19,9 +19,7 @@ import com.google.common.base.Throwables;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.util.LoggingUtil;
import com.google.devtools.build.lib.util.Preconditions;
-
import java.util.logging.Level;
-
import javax.annotation.Nullable;
/**
@@ -59,6 +57,25 @@ public class EvalException extends Exception {
* @param dueToIncompleteAST if the error is caused by a previous error, such as parsing.
*/
public EvalException(Location location, String message, boolean dueToIncompleteAST) {
+ this(location, message, dueToIncompleteAST, true);
+ }
+
+ /**
+ * Create an EvalException with the option to not fill in the java stack trace. An optimization
+ * for ReturnException, and potentially others, which aren't exceptional enough to include a
+ * stack trace.
+ *
+ * @param location the location where evaluation/execution failed.
+ * @param message the error message.
+ * @param dueToIncompleteAST if the error is caused by a previous error, such as parsing.
+ * @param fillInJavaStackTrace whether or not to fill in the java stack trace for this exception
+ */
+ EvalException(
+ Location location,
+ String message,
+ boolean dueToIncompleteAST,
+ boolean fillInJavaStackTrace) {
+ super(null, null, /*enableSuppression=*/ true, fillInJavaStackTrace);
this.location = location;
this.message = Preconditions.checkNotNull(message);
this.dueToIncompleteAST = dueToIncompleteAST;
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java b/src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java
index fa1aac406f..d3dac8198c 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java
@@ -18,7 +18,6 @@ import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.syntax.compiler.DebugInfo;
import com.google.devtools.build.lib.syntax.compiler.LoopLabels;
import com.google.devtools.build.lib.syntax.compiler.VariableScope;
-
import net.bytebuddy.implementation.bytecode.ByteCodeAppender;
import net.bytebuddy.implementation.bytecode.member.MethodReturn;
@@ -30,11 +29,12 @@ public class ReturnStatement extends Statement {
/**
* Exception sent by the return statement, to be caught by the function body.
*/
- public class ReturnException extends EvalException {
+ public static class ReturnException extends EvalException {
Object value;
public ReturnException(Location location, Object value) {
- super(location, "Return statements must be inside a function");
+ super(location, "Return statements must be inside a function",
+ /*dueToIncompleteAST=*/ false, /*fillInJavaStackTrace=*/ false);
this.value = value;
}