Package org.mozilla.javascript
Class StrictModeHelper
java.lang.Object
org.mozilla.javascript.StrictModeHelper
Helper class for handling strict mode compliance warnings.
This class provides utilities to log warnings for strict mode violations
that would have been errors in newer versions of Rhino (post 1.7.7.1).
To maintain backward compatibility with Rhino 1.7.7.1, strict mode checks
added after that version now log warnings instead of throwing errors.
The warnings include the full error message that would have been thrown,
providing complete information about the violation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCheck if we should throw an error for strict mode violations.static voidwarnStrictMode(Context cx, String messageId, Object... args) Log a strict mode warning instead of throwing an error.static voidwarnStrictModeReferenceError(Context cx, String errorMessage) Log a strict mode warning for ReferenceError violations.
-
Constructor Details
-
StrictModeHelper
public StrictModeHelper()
-
-
Method Details
-
warnStrictMode
Log a strict mode warning instead of throwing an error. This is used for strict mode compliance checks added after Rhino 1.7.7.1.- Parameters:
cx- the current contextmessageId- the message ID from Messages.propertiesargs- optional arguments for the message
-
warnStrictModeReferenceError
Log a strict mode warning for ReferenceError violations. Similar to warnStrictMode but specifically for reference errors.- Parameters:
cx- the current contexterrorMessage- the complete error message
-
shouldThrowStrictError
Check if we should throw an error for strict mode violations. Returns true if FEATURE_STRICT_MODE is enabled AND we're in strict mode. This preserves the old 1.7.7.1 behavior where FEATURE_STRICT_MODE would cause errors to be thrown.- Parameters:
cx- the current context- Returns:
- true if errors should be thrown for strict mode violations
-