Konloch/bytecode-viewer · info · InputMismatchException
String is too long
Error message
String is too long
What it means
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.
Source
Thrown at src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/ValuesPanel.java:635
}
}
}//GEN-LAST:event_characterTextFieldKeyReleased
private void stringTextFieldKeyReleased(java.awt.event.KeyEvent evt)
{//GEN-FIRST:event_stringTextFieldKeyReleased
if (evt.getKeyCode() == KeyEvent.VK_ENTER && isEditable())
{
try
{
String characterText = stringTextField.getText();
if (characterText.length() == 0)
throw new InputMismatchException("Empty value not valid");
byte[] bytes = characterText.getBytes(codeArea.getCharset());
if (bytes.length > CACHE_SIZE)
throw new InputMismatchException("String is too long");
System.arraycopy(bytes, 0, valuesCache, 0, bytes.length);
modifyValues(bytes.length);
updateValues();
}
catch (InputMismatchException ex)
{
showException(ex);
}
}
}//GEN-LAST:event_stringTextFieldKeyReleased
public void setCodeArea(CodeArea codeArea)
{
this.codeArea = codeArea;
}
View on GitHub (pinned to 31430e0033)
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.
Example fix
// before
stringTextField.setText("a very long string exceeding the cache limit..."); // throws
// after
stringTextField.setText("short"); // fits within CACHE_SIZE bytes Defensive patterns
Strategy: validation
Try / catch
try {
applyStringValue(stringTextField.getText());
} catch (InputMismatchException e) {
setStatus("String exceeds " + CACHE_SIZE + " bytes; shorten it");
} Prevention
- 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.
When it happens
Trigger: stringTextFieldKeyReleased where characterText.getBytes(codeArea.getCharset()).length > CACHE_SIZE; note byte length (not char length) counts, so multi-byte characters hit the limit sooner.
Common situations: 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.
Related errors
AI-assisted analysis of Konloch/bytecode-viewer@31430e0033 (2026-09-05).
Data as JSON: /api/errors/f56f3da9165caeeb.
Report an issue: GitHub.