fix compilation

This commit is contained in:
peter
2018-05-19 13:58:37 +02:00
parent ed426d0c37
commit 5970801d3e
3 changed files with 32 additions and 4 deletions
@@ -4,4 +4,10 @@ package org.jetbrains.jetCheck;
* @author peter
*/
class CannotRestoreValue extends RuntimeException {
CannotRestoreValue() {
}
CannotRestoreValue(String message) {
super(message);
}
}
@@ -10,14 +10,14 @@ import java.util.Base64;
class DataSerializer {
private static int readINT(ByteArrayInputStream record) {
final int val = record.read();
int val = readWithEof(record);
if (val < 192) {
return val;
}
int res = val - 192;
for (int sh = 6; ; sh += 7) {
int next = record.read();
int next = readWithEof(record);
res |= (next & 0x7F) << sh;
if ((next & 0x80) == 0) {
return res;
@@ -25,6 +25,13 @@ class DataSerializer {
}
}
private static int readWithEof(ByteArrayInputStream record) {
if (record.available() <= 0) {
throw new EOFException();
}
return record.read();
}
static void writeINT(DataOutput record, int val) throws IOException {
if (0 > val || val >= 192) {
record.writeByte(192 + (val & 0x3F));
@@ -61,7 +68,14 @@ class DataSerializer {
int hint = readINT(stream);
parameters.sizeHintFun = __ -> hint;
parameters.serializedData = __ -> readINT(stream);
parameters.serializedData = (IntDistribution dist) -> {
int i = readINT(stream);
if (!dist.isValidValue(i)) {
throw new CannotRestoreValue("Error restoring from serialized \"rechecking\" data. Possible cause: either the test or the environment it depends on has changed.");
}
return i;
};
}
static class EOFException extends RuntimeException {}
}
@@ -57,7 +57,15 @@ class Iteration<T> {
catch (CannotSatisfyCondition e) {
continue;
}
catch (DataSerializer.EOFException e) {
session.notifier.eofException();
return null;
}
catch (Throwable e) {
//noinspection InstanceofCatchParameter
if (e instanceof CannotRestoreValue && session.parameters.serializedData != null) {
throw e;
}
throw new GeneratorException(this, e);
}
if (!session.generatedNodes.add(node)) continue;