Skip to content

Fix visibility mismatch in Utils.getPath method signature #59

Description

@simbo1905

Issue Description

The getPath method in Utils.java has a visibility mismatch where it uses JsonValueImpl (package-private class) in its public method signature, making the method unusable outside its visibility scope.

Location

  • File: json-java21/src/main/java/jdk/sandbox/internal/util/json/Utils.java
  • Method: public static String getPath(JsonValueImpl jvi)

Problem

The method signature uses JsonValueImpl which is a package-private class:

public static String getPath(JsonValueImpl jvi) {
    return JsonPath.getPath(jvi);
}

This creates a visibility issue because:

  1. The method is public (accessible from anywhere)
  2. But the parameter type JsonValueImpl is package-private (only accessible within the same package)
  3. This makes the method effectively unusable from outside the package
  4. While legal Java, it's a design smell that indicates improper API design

Expected Fix

Either:

  1. Change the method visibility to package-private to match the parameter type
  2. Change the parameter type to a public interface/class if cross-package usage is intended
  3. Move the method to a more appropriate location if it should remain public

Impact

  • Severity: Low (code quality issue)
  • Type: API design / Visibility mismatch
  • Module: json-java21

Additional Context

This issue was identified by static analysis tools that detect visibility mismatches between method signatures and their referenced types. The fix should align with proper encapsulation principles and intended API design.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions