Blazebit / blaze-expression

Apache License 2.0
5 stars 6 forks source link

Could not deserialize ATN with version 3 (expected 4) #78

Closed michelkaeser closed 7 months ago

michelkaeser commented 10 months ago

Given the code from the quick-start snippets:

DomainBuilder domainBuilder = Domain.getDefaultProvider().createDefaultBuilder();
domainBuilder.createBasicType("String", String.class).build();
//domainBuilder.withOperator("String", new DomainOperator[]{ DomainOperator.PLUS });
//domainBuilder.withPredicate("String", DomainPredicate.distinguishable());
domainBuilder.createEntityType("Cat")
    .addAttribute("name", "String")
    .build();
DomainModel domain = domainBuilder.build();

ExpressionService expressionService = Expressions.forModel(domain);
ExpressionCompiler compiler = expressionService.createCompiler();
ExpressionCompiler.Context context = compiler.createContext(
    Map.of("c", domain.getType("Cat"))
);
Expression predicate = compiler.createExpression("c.name = 'Hans'", context);

this throws:

Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4).
        at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:56)
        at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:48)
        at com.blazebit.expression.impl.PredicateLexer.<clinit>(PredicateLexer.java:334)
        ... 22 more
Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 3 (expected 4).
        ... 25 more
beikov commented 10 months ago

Hey there, it looks like you are using an ANTLR version that is not compatible with the version required by blaze-expression. Could you please share the version that you are using? I guess it would be best to shade ANTLR to avoid such issues.

michelkaeser commented 10 months ago

Looks like it: https://github.com/antlr/antlr4/releases/tag/4.10 (actually using 4.10.1)

WARNING: Generated 4.10 lexers and parsers are incompatible with code generated by previous versions of ANTLR. You must regenerate all of your code from grammars to use the new runtime. This is true of all targets (except probably javascript).

beikov commented 7 months ago

I think this was fixed via https://github.com/Blazebit/blaze-expression/commit/28d54f7dc695c848b239c9ad366fd697baf07122