Skip to content

Remove InvalidSchemaError and the antlr4-runtime dependency - #927

Merged
oryan-block merged 1 commit into
masterfrom
feature/remove-antlr-runtime
Oct 24, 2026
Merged

oryan-block merged 1 commit into
masterfrom
feature/remove-antlr-runtime

Conversation

@oryan-block

Copy link
Copy Markdown
Collaborator

Checklist

  • Pull requests follows the contribution guide
  • New or modified functionality is covered by tests

Description

SchemaParserBuilder#parseDocuments caught antlr's ParseCancellationException and rethrew it as InvalidSchemaError. That catch hasn't been able to fire since graphql-java 19, which shades antlr into graphql.org.antlr.v4.runtime. The parser only throws the relocated classes, so a catch on org.antlr.v4.runtime never matches. The catch was also the only reason we depended on antlr4-runtime, so this removes the catch, InvalidSchemaError, the dependency and the requires in module-info.java.

The antlr rule in renovate.json is dropped separately in #924.

Verified:

  • none of the 26.1 jar's classes reference unshaded org/antlr/v4/runtime. 281 reference the shaded package
  • a scratch test on master fed 16 broken schemas (syntax errors, unterminated strings, illegal chars, 5000-deep nesting, 2 MB of comments or whitespace) through schemaString(...).build(), alone and with a second source. Everything came out as InvalidSyntaxException, SchemaSyntaxException or graphql-java's own ParseCancelled*Exception. Never InvalidSchemaError or an unshaded antlr class
  • mvn clean verify: 421 tests, 0 failures. dependency:tree has no org.antlr
  • probe with a broken .graphqls loaded through .file(...) still fails with SchemaSyntaxException: Invalid syntax with offending token '!' at line 3 column 11 in scenarios/syntax-error/schema.graphqls. The bookstore scenario builds and runs with no errors. The installed pom has no antlr

Release note: InvalidSchemaError is removed in 15.0.0. Nothing has thrown it since graphql-java 19, so a catch for it can just be deleted. graphql-java-tools no longer brings in org.antlr:antlr4-runtime, so an app that uses antlr directly needs to declare it.

graphql-java shades antlr, so its parser never throws the unshaded
ParseCancellationException that parseDocuments caught. The catch, and the
InvalidSchemaError it would have thrown, were dead code, and they were the
only reason tools depended on antlr4-runtime.
@sonarqubecloud

Copy link
Copy Markdown

@oryan-block
oryan-block merged commit 87c725f into master Oct 24, 2026
6 checks passed
@oryan-block
oryan-block deleted the feature/remove-antlr-runtime branch October 24, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant