-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add API tracker to compare local and upstream JSON APIs #8
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
Conversation
- 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' |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
json-java21-api-tracker/src/main/java/io/github/simbo1905/tracker/ApiTrackerRunner.java
Show resolved
Hide resolved
| import java.util.logging.Logger; | ||
| import java.util.logging.Level; | ||
|
|
||
| public class CompilerApiLearningTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this scaffolding test.
- 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]>
* 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]>
Summary
Implementation Details
API Tracker Module
GitHub Action
Testing
Test Results
All tests passing (12 tests total):
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:
This will help us stay synchronized with upstream API changes and identify when our backport needs updates.