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

Reimplement reporting error and warning count when a compilation error happens #29183

Merged
merged 16 commits into from
Jun 5, 2024

Conversation

hegyibalint
Copy link
Member

@hegyibalint hegyibalint commented May 16, 2024

When the new problem reporting framework was introduced, we didn't yet implement the error counters.

E.g., the following output from javac has a count at the end (note on the bottom the counters)

Test.java:4: warning: [cast] redundant cast to int
        int value = (int)1;
                    ^
Test.java:5: error: int cannot be dereferenced
        return value.toString();
                    ^
1 error
1 warning

This PR adds these counters back.

@hegyibalint hegyibalint requested a review from a team as a code owner May 16, 2024 13:03
@hegyibalint hegyibalint requested a review from big-guy May 16, 2024 13:03
@hegyibalint hegyibalint changed the title bhegyi/problems/java-compile/emit-error-count Reimplement reporting error and warning count when a compilation error happens May 16, 2024
@hegyibalint hegyibalint requested a review from a team May 16, 2024 13:11
@hegyibalint hegyibalint added a:regression This used to work in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures labels May 16, 2024
@hegyibalint hegyibalint added this to the 8.9 RC1 milestone May 16, 2024
@hegyibalint hegyibalint linked an issue May 16, 2024 that may be closed by this pull request
@hegyibalint hegyibalint linked an issue May 17, 2024 that may be closed by this pull request
@hegyibalint hegyibalint linked an issue May 17, 2024 that may be closed by this pull request
@hegyibalint hegyibalint linked an issue May 17, 2024 that may be closed by this pull request
Copy link
Member

@donat donat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I have only a few questions for my own education and some naming/documentation-related requests.

Comment on lines 86 to 110
/**
* This method is based on {JavaCompiler#printCount()}
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ The javadoc should state the following:

  • functionality: this method prints the number of warnings / errors to the standard output
  • intent: when there's no diagnostic listener attached to the compiler object, the number of warnings/errors are part of the putput. Since we have a listener attached, the output changed. Calling this method makes restores compatiblity with the original output
  • source: the method implementation is based on {JavaCompiler#printCount()}.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added further documentation

@@ -63,6 +63,7 @@ public WorkResult execute(JavaCompileSpec spec) {
ApiCompilerResult result = new ApiCompilerResult();
JavaCompiler.CompilationTask task = createCompileTask(spec, result);
boolean success = task.call();
diagnosticToProblemListener.reportDiagnosticCounts();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Will we hit this code path when we do joint Java-Groovy compilation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new integration test verifying this

@hegyibalint hegyibalint requested a review from donat May 28, 2024 07:01
@donat donat force-pushed the bhegyi/problems/java-compile/emit-error-count branch from 387f400 to 193c3f7 Compare May 30, 2024 12:15
@hegyibalint hegyibalint requested a review from donat June 3, 2024 14:18
…t-error-count' into bhegyi/problems/java-compile/emit-error-count

# Conflicts:
#	platforms/jvm/language-groovy/src/integTest/groovy/org/gradle/groovy/compile/GroovyCompileProblemsIntegrationTest.groovy
#	platforms/jvm/language-java/src/integTest/groovy/org/gradle/api/tasks/compile/JavaCompileProblemsIntegrationTest.groovy
#	platforms/jvm/language-java/src/main/java/org/gradle/api/internal/tasks/compile/DiagnosticToProblemListener.java
We don't need the compiler context here, so we can freely make a new object.
@hegyibalint hegyibalint added this pull request to the merge queue Jun 4, 2024
@bot-gradle
Copy link
Collaborator

WARN: Based on labels, this pull request addresses notable issue but no changes to release note found.

@bot-gradle
Copy link
Collaborator

The merge queue build has failed. Click here to see all failures.

@donat
Copy link
Member

donat commented Jun 4, 2024

@bot-gradle merge

@gradle gradle deleted a comment from donat Jun 4, 2024
@bot-gradle
Copy link
Collaborator

Sorry, we can't process your request because of the following error:

Pull request is already in the queue

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 4, 2024
@hegyibalint hegyibalint added this pull request to the merge queue Jun 5, 2024
@bot-gradle
Copy link
Collaborator

WARN: Based on labels, this pull request addresses notable issue but no changes to release note found.

@hegyibalint
Copy link
Member Author

Failed due to flaky tests

@bot-gradle
Copy link
Collaborator

The merge queue build has failed. Click here to see all failures.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 5, 2024
@hegyibalint hegyibalint requested a review from a team as a code owner June 5, 2024 09:29
@hegyibalint
Copy link
Member Author

Fixed the snippet, where I've reintroduced the error count.

@hegyibalint
Copy link
Member Author

Currently I'm running a snippet test to pre-test the merge.

@hegyibalint hegyibalint added this pull request to the merge queue Jun 5, 2024
@bot-gradle
Copy link
Collaborator

WARN: Based on labels, this pull request addresses notable issue but no changes to release note found.

Merged via the queue into master with commit dae448e Jun 5, 2024
30 checks passed
@hegyibalint hegyibalint deleted the bhegyi/problems/java-compile/emit-error-count branch June 5, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:regression This used to work in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem-reporting capable compilation doesn't emit error count
4 participants