Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 28, 2025

The ./gradlew compileJava task was failing due to ErrorProne's EffectivelyPrivate warnings being treated as compilation errors with the -Werror flag.

Problem

ErrorProne was flagging several declarations as having public or protected modifiers when they are effectively private (only used within their declaring class or within private nested classes). This caused compilation to fail with messages like:

warning: [EffectivelyPrivate] This declaration has public or protected modifiers, but is effectively private.
    public BaseDataContractDeserializer() {
           ^
    (see https://errorprone.info/bugpattern/EffectivelyPrivate)
  Did you mean 'BaseDataContractDeserializer() {'?
error: warnings found and -Werror specified

Solution

Fixed the visibility modifiers for the following declarations to make them package-private:

  1. JsonHelper.java: BaseDataContractDeserializer() constructor in private static class
  2. BatchItemProcessor.java: internalRun() method called only within the same class
  3. ConfigurationLogger.java: log() abstract method in private enum
  4. AttributeProcessor.java: HttpUrlKeyValuePair fields and constructor in private static class

These changes align with ErrorProne's suggestions and maintain the same functionality while reducing unnecessary visibility.

Testing

  • ./gradlew compileJava now succeeds without warnings
  • ✅ All modified methods/constructors maintain their existing usage patterns
  • ✅ No functional changes to the codebase

The fix ensures the build passes while following Java visibility best practices.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copilot AI changed the title [WIP] fix ./gradlew compileJava Fix EffectivelyPrivate warnings causing ./gradlew compileJava to fail Jul 28, 2025
Copilot AI requested a review from trask July 28, 2025 16:56
Copilot finished work on behalf of trask July 28, 2025 16:56
@trask trask marked this pull request as ready for review July 28, 2025 17:18
@trask
Copy link
Member

trask commented Jul 28, 2025

there are still more errors

  • What went wrong:
    Execution failed for task ':agent:agent-tooling:compileTestJava'.

Compilation failed; see the compiler output below.
/home/runner/work/ApplicationInsights-Java/ApplicationInsights-Java/agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/profiler/ProfilingInitializerTest.java:32: warning: [EffectivelyPrivate] This declaration has public or protected modifiers, but is effectively private.
public final String name;
^
(see https://errorprone.info/bugpattern/EffectivelyPrivate)
Did you mean 'final String name;'?
1 error
7 warnings

Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 28, 2025

there are still more errors

  • What went wrong:
    ...

Fixed the additional EffectivelyPrivate warnings in ProfilingInitializerTest.java. Removed public modifiers from fields and methods in private static classes as suggested by ErrorProne. Both ./gradlew compileJava and ./gradlew compileTestJava now succeed without warnings. Changes made in commit f8f1475.

Copilot finished work on behalf of trask July 28, 2025 17:41
@trask trask merged commit b0918f1 into dependabot/gradle/errorProneVersion-2.41.0 Jul 28, 2025
138 of 140 checks passed
@trask trask deleted the copilot/fix-20a955a1-6f52-419a-b0df-10b3d43afa58 branch July 28, 2025 18:47
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.

2 participants