Skip to content

Commit e4e1815

Browse files
build: fork javac with -Xss16m to survive deeply nested generated sources
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent eb3e035 commit e4e1815

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,21 @@ mavenPublishing {
644644

645645
tasks.withType(JavaCompile).configureEach {
646646
options.encoding = 'UTF-8'
647+
648+
// javac's parser is recursive descent: one stack frame per level of nesting. The generated
649+
// CCJSqlParser is nested deeply enough to exhaust the default thread stack, which surfaces as
650+
// "An exception has occurred in the compiler ... java.lang.StackOverflowError" - a compiler
651+
// crash, not a compile error, and not a bug worth reporting to Oracle.
652+
//
653+
// -Xss only takes effect at JVM launch, so the compiler has to run in its own process:
654+
// setting forkOptions without options.fork = true silently does nothing.
655+
options.fork = true
656+
options.forkOptions.jvmArgs = (options.forkOptions.jvmArgs ?: []) + ['-Xss16m']
657+
}
658+
659+
// javadoc parses the same sources in a forked process and hits the same wall
660+
tasks.withType(Javadoc).configureEach {
661+
options.setJFlags((options.getJFlags() ?: []) + ['-Xss16m'])
647662
}
648663

649664
remotes {

0 commit comments

Comments
 (0)