Skip to content

Conversation

@simbo1905
Copy link
Owner

Summary

Implementation Details

API Tracker Module

  • Class Discovery: Uses reflection to find all classes in and internal packages
  • Upstream Fetching: Downloads source files from OpenJDK GitHub repository
  • API Extraction:
    • Local: Uses reflection to extract public API details
    • Upstream: Uses compiler parsing (JavacTask) to analyze source code
  • Comparison: Detailed comparison of methods, fields, constructors, modifiers, and inheritance

GitHub Action

  • Runs daily at 2 AM UTC via cron schedule
  • Can be manually triggered for testing
  • Creates GitHub issue if API differences are detected

Testing

  • Comprehensive unit tests for all components
  • Integration test verifying full comparison workflow
  • Learning test demonstrating compiler API usage

Test Results

All tests passing (12 tests total):

  • Class discovery
  • API extraction (local and upstream)
  • Comparison logic
  • Full integration test

Usage

Manual testing:

mvn exec:java -pl json-java21-api-tracker -Dexec.mainClass="io.github.simbo1905.tracker.ApiTrackerRunner"

The tracker produces a JSON report showing:

  • Total classes analyzed
  • Matching vs different APIs
  • Detailed differences for each class
  • Execution time

This will help us stay synchronized with upstream API changes and identify when our backport needs updates.

- Implement API tracker module with reflection for local classes
- Add compiler parsing for upstream source analysis
- Create comparison logic to identify API differences
- Add GitHub Action for daily API tracking (cron: 2 AM UTC)
- Include command-line runner for manual testing

The tracker discovers local classes, fetches upstream sources from GitHub,
extracts public APIs using both reflection and compiler parsing, then
generates a detailed comparison report showing any differences.

Closes #7
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
Copy link
Owner Author

Choose a reason for hiding this comment

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

we must be using latest JDK to run tooling this should be Java 24

-pl json-java21-api-tracker \
-Dexec.mainClass="io.github.simbo1905.tracker.ApiTrackerRunner" \
-Dexec.args="INFO" \
-Djava.util.logging.ConsoleHandler.level=INFO
Copy link
Owner Author

Choose a reason for hiding this comment

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

please ensure that there is good INFO logging in the current code. especially to see timeouts and retries and 404 we expect the initial fetching to be the most runreliable part

final var classes = new TreeSet<Class<?>>((a, b) -> a.getName().compareTo(b.getName()));

// Known public API classes
final var publicApiClasses = List.of(
Copy link
Owner Author

Choose a reason for hiding this comment

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

this is a really bad idea as fragile. if more is added to the public API at a later date we need to remember to add to this list. so this is a dumb idea. these classes will be on the class path and reflection on the packages should find them all. so we only need to know the two package names that are likely to be stable and not get additions.


// Known internal implementation classes
final var internalClasses = List.of(
"jdk.sandbox.internal.util.json.JsonParser",
Copy link
Owner Author

Choose a reason for hiding this comment

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

ditto

}
});

LOGGER.fine(() -> "Discovered " + classes.size() + " classes");
Copy link
Owner Author

Choose a reason for hiding this comment

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

we need to know what the tool is doing this should be iNFO level logging.

}

public static void main(String[] args) {
LOGGER.info("Starting API Tracker v0.1-SNAPSHOT");
Copy link
Owner Author

Choose a reason for hiding this comment

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

there should be no hardcoding of a version that will change.

* Validates that the JSON backport is working correctly.
* Tests various JSON structures to ensure compatibility.
*/
private static boolean validateJsonBackport() {
Copy link
Owner Author

Choose a reason for hiding this comment

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

this should not be here as we have unit tests.

/**
* Tests edge cases for JSON parsing.
*/
private static void testEdgeCases() throws JsonParseException {
Copy link
Owner Author

Choose a reason for hiding this comment

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

this should not be here as we have unit tests.

import java.util.logging.Logger;
import java.util.logging.Level;

public class CompilerApiLearningTest {
Copy link
Owner Author

Choose a reason for hiding this comment

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

delete this scaffolding test.

simbo1905 and others added 3 commits July 26, 2025 08:24
- Remove duplicate ApiTrackerMain class (keep only ApiTrackerRunner)
- Replace hardcoded class list with dynamic classpath scanning
- Change logging from FINE to INFO for key operations
- Remove hardcoded version references

The API tracker now dynamically discovers classes in the JSON API packages
by scanning both directories and JAR files on the classpath. This makes it
more robust and eliminates the need to manually update class lists.
- Update both GitHub workflows to use Java 24 instead of matrix build
- Add comprehensive INFO logging for HTTP operations and class discovery
- Remove scaffolding test and fix compilation warnings
- Maintain Java 21 compatibility for main library while using Java 24 for tooling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove internal package scanning (jdk.sandbox.internal.util.json)
- Track only public API classes (jdk.sandbox.java.util.json)
- Eliminate false positive 404 errors for removed internal classes like StableValue
- Reduce tracked classes from 19 to 10 (public API only)
- Improve performance and focus on meaningful API drift detection
- Update tests to verify no internal classes are tracked

Results: 0 missing upstream, 10 public API classes, faster execution

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@simbo1905 simbo1905 merged commit 0cb586c into main Jul 27, 2025
1 check passed
@simbo1905 simbo1905 deleted the jdk-sandbox-api-tracker branch July 27, 2025 16:32
simbo1905 pushed a commit that referenced this pull request Aug 22, 2025
* refactor: Convert to multi-module Maven project

* build: Enforce stricter compiler settings and fix warnings

* feat: Add API tracker to compare local and upstream JSON APIs

- Implement API tracker module with reflection for local classes
- Add compiler parsing for upstream source analysis
- Create comparison logic to identify API differences
- Add GitHub Action for daily API tracking (cron: 2 AM UTC)
- Include command-line runner for manual testing

The tracker discovers local classes, fetches upstream sources from GitHub,
extracts public APIs using both reflection and compiler parsing, then
generates a detailed comparison report showing any differences.

Closes #7

* fix: Address PR review comments

- Remove duplicate ApiTrackerMain class (keep only ApiTrackerRunner)
- Replace hardcoded class list with dynamic classpath scanning
- Change logging from FINE to INFO for key operations
- Remove hardcoded version references

The API tracker now dynamically discovers classes in the JSON API packages
by scanning both directories and JAR files on the classpath. This makes it
more robust and eliminates the need to manually update class lists.

* fix: Address PR review comments

- Update both GitHub workflows to use Java 24 instead of matrix build
- Add comprehensive INFO logging for HTTP operations and class discovery
- Remove scaffolding test and fix compilation warnings
- Maintain Java 21 compatibility for main library while using Java 24 for tooling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

* fix: Focus API tracker on public API only, eliminate false positives

- Remove internal package scanning (jdk.sandbox.internal.util.json)
- Track only public API classes (jdk.sandbox.java.util.json)
- Eliminate false positive 404 errors for removed internal classes like StableValue
- Reduce tracked classes from 19 to 10 (public API only)
- Improve performance and focus on meaningful API drift detection
- Update tests to verify no internal classes are tracked

Results: 0 missing upstream, 10 public API classes, faster execution

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
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.

Add daily API tracking between local and upstream JSON APIs

2 participants