Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Handle parsing of non-problems in JavaErrorParser #1455

Merged
merged 3 commits into from
Oct 12, 2024

Conversation

Friendseeker
Copy link
Member

@Friendseeker Friendseeker commented Oct 12, 2024

Issue

JavaErrorParser assumes javac outputs start with a list of problems or notes. However in certain situations javac emits the following lines first

Loading source file D:\Repos\zinc\internal\zinc-compile-core\target\jvm-2.13\test-classes\sbt\internal\inc\javac\test1.java...
Constructing Javadoc information...

which is neither problems nor notes. The parser then gives up and parse nothing. Hence JavaCompilerSpec fails.

Fix

We explicitly match for lines that start with "Loading source file" or "Constructing Javadoc information" and skip these lines before parsing problems / notes.

Validating the fix

I tested on a Java 17 windows machine that emits the below during JavaCompilerSpec

Loading source file D:\Repos\zinc\internal\zinc-compile-core\target\jvm-2.13\test-classes\sbt\internal\inc\javac\test1.java...
Constructing Javadoc information...
D:\Repos\zinc\internal\zinc-compile-core\target\jvm-2.13\test-classes\sbt\internal\inc\javac\test1.java:14: error: class Test is public, should be declared in a file named Test.java
public class Test {
       ^
D:\Repos\zinc\internal\zinc-compile-core\target\jvm-2.13\test-classes\sbt\internal\inc\javac\test1.java:15: error: cannot find symbol
    public NotFound foo() { return 5; }
           ^
  symbol:   class NotFound
  location: class Test
2 errors

The test passed locally.

Closes #1451

@Friendseeker Friendseeker marked this pull request as ready for review October 12, 2024 00:39
@Friendseeker Friendseeker requested a review from eed3si9n October 12, 2024 00:39
@eed3si9n
Copy link
Member

@Friendseeker Friendseeker force-pushed the fix-forked-java-parsing branch from 6fcb318 to 980b91d Compare October 12, 2024 07:22
@Friendseeker
Copy link
Member Author

@eed3si9n Addressed PR feedback & added test!

@eed3si9n eed3si9n merged commit 27216b5 into sbt:1.10.x Oct 12, 2024
9 checks passed
@Friendseeker Friendseeker deleted the fix-forked-java-parsing branch October 12, 2024 17:22
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.

JavaCompilerSpec.findsDocErrors failing for Windows Java 17/21
2 participants