{"record":{"id":"c7e203db3011be52","repo":"alibaba/arthas","slug":"by-default-strict-mode-is-true-not-allowed-to-se","errorCode":null,"errorMessage":"By default, strict mode is true, not allowed to set object properties. Want to set object properties, execute `options strict false`","messagePattern":"By default, strict mode is true, not allowed to set object properties\\. Want to set object properties, execute `options strict false`","errorType":"exception","errorClass":"IllegalAccessError","httpStatus":null,"severity":"warning","filePath":"core/src/main/java/com/taobao/arthas/core/command/express/ArthasObjectPropertyAccessor.java","lineNumber":18,"sourceCode":"package com.taobao.arthas.core.command.express;\n\nimport java.util.Map;\n\nimport com.taobao.arthas.core.GlobalOptions;\n\nimport ognl.ObjectPropertyAccessor;\nimport ognl.OgnlException;\n\n/**\n * @author hengyunabc 2022-03-24\n */\npublic class ArthasObjectPropertyAccessor extends ObjectPropertyAccessor {\n\n    @Override\n    public Object setPossibleProperty(Map context, Object target, String name, Object value) throws OgnlException {\n        if (GlobalOptions.strict) {\n            throw new IllegalAccessError(GlobalOptions.STRICT_MESSAGE);\n        }\n        return super.setPossibleProperty(context, target, name, value);\n    }\n\n}\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/command/express/ArthasObjectPropertyAccessor.java#L1-L24","documentation":"Thrown as IllegalAccessError by ArthasObjectPropertyAccessor.setPossibleProperty when GlobalOptions.strict is true (the default) and an OGNL expression tries to SET an object property (write). This is a deliberate safety guard: out-of-the-box Arthas forbids OGNL writes to objects to prevent accidental mutation of the live target application. The message itself (GlobalOptions.STRICT_MESSAGE) instructs the user how to opt out.","triggerScenarios":"Evaluate an OGNL expression that assigns to a property — e.g. '#this.field = x', 'target.foo = bar', or any lvalue assignment in watch/trace/ognl — while GlobalOptions.strict is at its default true.","commonSituations":"User attempts to mutate target state via ognl/watch without knowing strict mode is on; scripted diagnostics that try to flip a flag on the target; migrating from an older Arthas where strict was not enforced.","solutions":["Explicitly disable strict mode: run `options strict false` before the mutating expression.","Re-evaluate whether you really need to write — prefer read-only diagnostics; if you must mutate, accept the risk consciously.","Re-enable strict after: `options strict true`."],"exampleFix":"// before\nognl '#this.enabled = true'   // throws under strict mode\n\n// after\noptions strict false\nognl '#this.enabled = true'\noptions strict true","handlingStrategy":"validation","validationCode":"if (GlobalOptions.strict && expressionIsWrite(ognlExpr)) {\n    // either run `options strict false` or refrain from writing\n}","typeGuard":"static boolean isStrictWriteBlocked() { return GlobalOptions.strict; }","tryCatchPattern":"try {\n    Object r = ognlEngine.get/setValue(...);\n} catch (IllegalAccessError e) {\n    if (e.getMessage().equals(GlobalOptions.STRICT_MESSAGE)) {\n        // instruct user to `options strict false` if write is intentional\n    }\n}","preventionTips":["Prefer read-only OGNL expressions for diagnostics.","Consciously toggle `options strict false` only when mutation is intended, then re-enable.","Document which expressions write so reviewers can catch accidental mutations."],"tags":["ognl","strict-mode","safety","configuration"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}