private int writeStackTrace(final DataOutput output, final StackTraceElement[] stackTrace, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { // don't bother recording in seen because stack traces are always copied final int length = stackTrace.length; writePackedInt(output, length); for (StackTraceElement element : stackTrace) { cnt = writeStackElement(output, element, seen, stringCache, cnt); } return cnt; }
private int writeFields(final DataOutput output, final Map<String, String> fields, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { writePackedInt(output, fields.size()); for (Map.Entry<String, String> entry : fields.entrySet()) { cnt = writeString(output, entry.getKey(), seen, stringCache, cnt); cnt = writeString(output, entry.getValue(), seen, stringCache, cnt); } return cnt; }
private int writeStackElement(final DataOutput output, final StackTraceElement element, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { final int idx = seen.get(element, - 1); final int distance = cnt - idx; if (idx == -1 || distance > (1 << 14) - 1) { output.write(ST_NEW_STACK_ELEMENT_V8); cnt = writeString(output, element.getClassName(), seen, stringCache, cnt); cnt = writeString(output, element.getMethodName(), seen, stringCache, cnt); cnt = writeString(output, element.getFileName(), seen, stringCache, cnt); writePackedInt(output, element.getLineNumber()); seen.put(element, cnt++); return cnt; } else { if (distance < 127) { output.writeByte(ST_BACKREF_NEAR | distance); } else { assert distance <= 0x3fff; output.writeByte(ST_BACKREF_FAR | distance >> 8); output.writeByte(distance); } return cnt; } }
private int writeToStream(DataOutput output, IdentityIntMap<Object> seen, HashMap<String, String> stringCache, int cnt) throws IOException { // register in cycle map seen.put(this, cnt++); // write the header byte output.writeByte(ST_NEW_EXCEPTION_CAUSE); // first write class name cnt = writeString(output, exceptionClassName, seen, stringCache, cnt); // null or message cnt = writeString(output, getMessage(), seen, stringCache, cnt); // stack trace cnt = writeStackTrace(output, getStackTrace(), seen, stringCache, cnt); // fields cnt = writeFields(output, fields, seen, stringCache, cnt); // caused-by cnt = writeThrowable(output, getCause(), seen, stringCache, cnt); // suppressed final Throwable[] suppressed = getSuppressed(); writePackedInt(output, suppressed.length); for (final Throwable t : suppressed) { cnt = writeThrowable(output, t, seen, stringCache, cnt); } return cnt; }
private int writeStackTrace(final DataOutput output, final StackTraceElement[] stackTrace, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { // don't bother recording in seen because stack traces are always copied final int length = stackTrace.length; writePackedInt(output, length); for (StackTraceElement element : stackTrace) { cnt = writeStackElement(output, element, seen, stringCache, cnt); } return cnt; }
private int writeStackTrace(final DataOutput output, final StackTraceElement[] stackTrace, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { // don't bother recording in seen because stack traces are always copied final int length = stackTrace.length; writePackedInt(output, length); for (StackTraceElement element : stackTrace) { cnt = writeStackElement(output, element, seen, stringCache, cnt); } return cnt; }
private int writeFields(final DataOutput output, final Map<String, String> fields, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { writePackedInt(output, fields.size()); for (Map.Entry<String, String> entry : fields.entrySet()) { cnt = writeString(output, entry.getKey(), seen, stringCache, cnt); cnt = writeString(output, entry.getValue(), seen, stringCache, cnt); } return cnt; }
private int writeFields(final DataOutput output, final Map<String, String> fields, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { writePackedInt(output, fields.size()); for (Map.Entry<String, String> entry : fields.entrySet()) { cnt = writeString(output, entry.getKey(), seen, stringCache, cnt); cnt = writeString(output, entry.getValue(), seen, stringCache, cnt); } return cnt; }
private int writeStackElement(final DataOutput output, final StackTraceElement element, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { final int idx = seen.get(element, - 1); final int distance = cnt - idx; if (idx == -1 || distance > (1 << 14) - 1) { output.write(ST_NEW_STACK_ELEMENT_V8); cnt = writeString(output, element.getClassName(), seen, stringCache, cnt); cnt = writeString(output, element.getMethodName(), seen, stringCache, cnt); cnt = writeString(output, element.getFileName(), seen, stringCache, cnt); writePackedInt(output, element.getLineNumber()); seen.put(element, cnt++); return cnt; } else { if (distance < 127) { output.writeByte(ST_BACKREF_NEAR | distance); } else { assert distance <= 0x3fff; output.writeByte(ST_BACKREF_FAR | distance >> 8); output.writeByte(distance); } return cnt; } }
private int writeStackElement(final DataOutput output, final StackTraceElement element, final IdentityIntMap<Object> seen, final HashMap<String, String> stringCache, int cnt) throws IOException { final int idx = seen.get(element, - 1); final int distance = cnt - idx; if (idx == -1 || distance > (1 << 14) - 1) { output.write(ST_NEW_STACK_ELEMENT_V8); cnt = writeString(output, element.getClassName(), seen, stringCache, cnt); cnt = writeString(output, element.getMethodName(), seen, stringCache, cnt); cnt = writeString(output, element.getFileName(), seen, stringCache, cnt); writePackedInt(output, element.getLineNumber()); seen.put(element, cnt++); return cnt; } else { if (distance < 127) { output.writeByte(ST_BACKREF_NEAR | distance); } else { assert distance <= 0x3fff; output.writeByte(ST_BACKREF_FAR | distance >> 8); output.writeByte(distance); } return cnt; } }
private int writeToStream(DataOutput output, IdentityIntMap<Object> seen, HashMap<String, String> stringCache, int cnt) throws IOException { // register in cycle map seen.put(this, cnt++); // write the header byte output.writeByte(ST_NEW_EXCEPTION_CAUSE); // first write class name cnt = writeString(output, exceptionClassName, seen, stringCache, cnt); // null or message cnt = writeString(output, getMessage(), seen, stringCache, cnt); // stack trace cnt = writeStackTrace(output, getStackTrace(), seen, stringCache, cnt); // fields cnt = writeFields(output, fields, seen, stringCache, cnt); // caused-by cnt = writeThrowable(output, getCause(), seen, stringCache, cnt); // suppressed final Throwable[] suppressed = getSuppressed(); writePackedInt(output, suppressed.length); for (final Throwable t : suppressed) { cnt = writeThrowable(output, t, seen, stringCache, cnt); } return cnt; }
private int writeToStream(DataOutput output, IdentityIntMap<Object> seen, HashMap<String, String> stringCache, int cnt) throws IOException { // register in cycle map seen.put(this, cnt++); // write the header byte output.writeByte(ST_NEW_EXCEPTION_CAUSE); // first write class name cnt = writeString(output, exceptionClassName, seen, stringCache, cnt); // null or message cnt = writeString(output, getMessage(), seen, stringCache, cnt); // stack trace cnt = writeStackTrace(output, getStackTrace(), seen, stringCache, cnt); // fields cnt = writeFields(output, fields, seen, stringCache, cnt); // caused-by cnt = writeThrowable(output, getCause(), seen, stringCache, cnt); // suppressed final Throwable[] suppressed = getSuppressed(); writePackedInt(output, suppressed.length); for (final Throwable t : suppressed) { cnt = writeThrowable(output, t, seen, stringCache, cnt); } return cnt; }