{"record":{"id":"f56f3da9165caeeb","repo":"Konloch/bytecode-viewer","slug":"string-is-too-long","errorCode":null,"errorMessage":"String is too long","messagePattern":"String is too long","errorType":"validation","errorClass":"InputMismatchException","httpStatus":null,"severity":"info","filePath":"src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java","lineNumber":635,"sourceCode":"            }\n        }\n    }//GEN-LAST:event_characterTextFieldKeyReleased\n\n    private void stringTextFieldKeyReleased(java.awt.event.KeyEvent evt)\n    {//GEN-FIRST:event_stringTextFieldKeyReleased\n        if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable())\n        {\n            try\n            {\n                String characterText = stringTextField.getText();\n\n                if (characterText.length() == 0)\n                    throw new InputMismatchException(\"Empty value not valid\");\n\n                byte[] bytes = characterText.getBytes(codeArea.getCharset());\n\n                if (bytes.length > CACHE_SIZE)\n                    throw new InputMismatchException(\"String is too long\");\n\n                System.arraycopy(bytes, 0, valuesCache, 0, bytes.length);\n\n                modifyValues(bytes.length);\n                updateValues();\n            }\n            catch (InputMismatchException ex)\n            {\n                showException(ex);\n            }\n        }\n    }//GEN-LAST:event_stringTextFieldKeyReleased\n\n    public void setCodeArea(CodeArea codeArea)\n    {\n        this.codeArea = codeArea;\n    }\n","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/Konloch/bytecode-viewer/blob/31430e0033fa220db566b5ef461256727ff6793b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java#L617-L653","documentation":"The string field handler throws InputMismatchException(\"String is too long\") when the UTF-encoded bytes of the entered string exceed CACHE_SIZE — the values cache can only hold a fixed number of bytes (single code-area row worth), so oversized strings are rejected before arraycopy.","triggerScenarios":"stringTextFieldKeyReleased where characterText.getBytes(codeArea.getCharset()).length > CACHE_SIZE; note byte length (not char length) counts, so multi-byte characters hit the limit sooner.","commonSituations":"Pasting long strings into the string field; strings with many non-ASCII characters inflating byte length; editing a small file/row where the cache is small.","solutions":["Shorten the string so its encoded byte length fits the cache.","Edit the string in several smaller chunks across rows.","Edit the underlying file directly (e.g. in a text editor or via the hex viewer) for long content.","Prefer ASCII text to avoid multi-byte expansion hitting the limit earlier."],"exampleFix":"// before\nstringTextField.setText(\"a very long string exceeding the cache limit...\"); // throws\n// after\nstringTextField.setText(\"short\"); // fits within CACHE_SIZE bytes","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    applyStringValue(stringTextField.getText());\n} catch (InputMismatchException e) {\n    setStatus(\"String exceeds \" + CACHE_SIZE + \" bytes; shorten it\");\n}","preventionTips":["Measure encoded byte length (not char count) before applying.","Split long edits into multiple row-sized chunks.","Prefer ASCII to avoid multi-byte expansion.","For long content, edit the file directly rather than via the string field."],"tags":["hexviewer","input-length","buffer-overflow-guard","validation"],"backgroundTag":"input-length-exceeded","analyzedSha":"31430e0033fa220db566b5ef461256727ff6793b","analyzedAt":"2026-09-05T18:22:22.725Z","contentChangedAt":"2026-09-05T18:22:22.725Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}