28 import java.text.MessageFormat; |
28 import java.text.MessageFormat; |
29 import java.util.Locale; |
29 import java.util.Locale; |
30 import java.util.ResourceBundle; |
30 import java.util.ResourceBundle; |
31 import jdk.nashorn.api.scripting.NashornException; |
31 import jdk.nashorn.api.scripting.NashornException; |
32 import jdk.nashorn.internal.scripts.JS; |
32 import jdk.nashorn.internal.scripts.JS; |
|
33 import jdk.nashorn.internal.codegen.CompilerConstants; |
33 |
34 |
34 /** |
35 /** |
35 * Helper class to throw various standard "ECMA error" exceptions such as Error, ReferenceError, TypeError etc. |
36 * Helper class to throw various standard "ECMA error" exceptions such as Error, ReferenceError, TypeError etc. |
36 */ |
37 */ |
37 public final class ECMAErrors { |
38 public final class ECMAErrors { |
399 */ |
400 */ |
400 public static boolean isScriptFrame(final StackTraceElement frame) { |
401 public static boolean isScriptFrame(final StackTraceElement frame) { |
401 final String className = frame.getClassName(); |
402 final String className = frame.getClassName(); |
402 |
403 |
403 // Look for script package in class name (into which compiler puts generated code) |
404 // Look for script package in class name (into which compiler puts generated code) |
404 if (className.startsWith(scriptPackage)) { |
405 if (className.startsWith(scriptPackage) && !frame.getMethodName().startsWith(CompilerConstants.INTERNAL_METHOD_PREFIX)) { |
405 final String source = frame.getFileName(); |
406 final String source = frame.getFileName(); |
406 /* |
407 /* |
407 * Make sure that it is not some Java code that Nashorn has in that package! |
408 * Make sure that it is not some Java code that Nashorn has in that package! |
408 * also, we don't want to report JavaScript code that lives in script engine implementation |
409 * also, we don't want to report JavaScript code that lives in script engine implementation |
409 * We want to report only user's own scripts and not any of our own scripts like "engine.js" |
410 * We want to report only user's own scripts and not any of our own scripts like "engine.js" |