[jdk8u-dev] RFR: 8327440: "bad source file" error during beaninfo generation

Andrew John Hughes andrew at openjdk.org
Tue Mar 12 20:07:43 UTC 2024


On Mon, 4 Mar 2024 16:36:22 GMT, fitzsim <duke at openjdk.org> wrote:

> The `gensrc_no_srczip/_the.generated_beaninfo` build rule does not use any sources in `gensrc`.  Remove `$(JDK_OUTPUTDIR)/gensrc` from the `javadoc` `-sourcepath` argument, because its presence can cause build failures.
> 
> Other build targets (for example,
> `gensrc/java/nio/_the.exceptions.dir`), generate source code under that path.  When make is invoked with more than one job, sometimes one of those other targets will be in the process of writing a source file when the `_the.generated_beaninfo` build rule invokes `javadoc`.  The result is build failures of the form:
> 
> 
> Generating beaninfo
> [...]\jdk8u-dev\jdk\src\share\classes\java\io\PrintStream.java:32: error: cannot access UnsupportedCharsetException
> import java.nio.charset.UnsupportedCharsetException;
>                        ^
>   bad source file: [...]\jdk8u-dev\build\windows-x64\jdk\gensrc\java\nio\charset\UnsupportedCharsetException.java
> 
> 
> Background
> ==========
> 
> This patch fixes a parallel make race condition during beaninfo generation.  I investigated this issue because I was seeing GitHub Actions failures on https://github.com/openjdk/jdk8u-dev/pull/452 and wanted to make sure they were not caused by the ZipFile backport.
> 
> This type of failure happens when generated source files are partially written to `$(JDK_OUTPUTDIR)/gensrc`.  The failing invocation is `javadoc` (i.e., `com.sun.tools.javadoc.Main`, i.e., the expansion of `$(NEW_JAVADOC)`).  `$(JDK_OUTPUTDIR)/gensrc` is listed in the `-sourcepath` javadoc argument.  Therefore javadoc tries to parse source files it finds while traversing `gensrc` and its subdirectories.
> 
> Other build rules write source files to `$(JDK_OUTPUTDIR)/gensrc`, and if any such source file is partially written, the `javadoc` sourcepath parsing fails with messages like:
> 
> 
> d:\a\jdk8u-dev\jdk8u-dev\jdk\jdk\src\share\classes\java\nio\channels\spi\AbstractSelectableChannel.java:33: error: cannot access IllegalSelectorException
> import java.nio.channels.IllegalSelectorException;
>                         ^
>   bad source file: d:\a\jdk8u-dev\jdk8u-dev\jdk\build\windows-x64\jdk\gensrc\java\nio\channels\IllegalSelectorException.java
>     file does not contain class java.nio.channels.IllegalSelectorException
>     Please remove or make sure it appears in the correct subdirectory of the sourcepath.
> 
> 
> which occurred in
> https://github.com/gnu-andrew/jdk8u-dev/actions/runs/7979614913/job/21787468883.
> 
> So far I have seen this type of error happen twice on Windows GitHub Actions runs, with the same ...

The `sourcepath` was added by JDK-8011346: "build-infra: While Constructing Javadoc information, JSpinner.java error: package sun.util.locale.provider does not exist" (private bug) and then the whole beaninfo generation was later removed in 9 by [JDK-4763438](https://bugs.openjdk.org/browse/JDK-4763438): "Replace uses of @beaninfo with meta facility in core j2se" removed this beaninfo generation so this is applicable to 8u only.

Unless more information comes to light as to why the generated source files were needed on the source path, I think it would be simpler to remove it and deal with any consequences of that change, rather than retaining something with a clear race issue.

-------------

Marked as reviewed by andrew (Reviewer).

PR Review: https://git.openjdk.org/jdk8u-dev/pull/465#pullrequestreview-1926206325


More information about the jdk8u-dev mailing list