Create table-driven mapping for JavaCard SDK and JDK version compatibility#110
Create table-driven mapping for JavaCard SDK and JDK version compatibility#110
Conversation
|
This should fix the very generic note in #105 |
Co-authored-by: martinpaljak <46006+martinpaljak@users.noreply.github.com>
| * | 3.0.1 | 1.6 | 1-11 | No | - | | ||
| * | 3.0.4 | 1.6 | 1-11 | No | - | | ||
| * | 3.0.5 | 1.6 | 1-11 | No | - | | ||
| * | 3.1.0 | 1.7 | 1-17 | Yes | 3.0.4, 3.0.5, 3.1.0, 3.2.0 | |
There was a problem hiding this comment.
Fixed. Removed V320 from the targeting list for V310. Now 3.1.0 can only target 3.0.4, 3.0.5, and 3.1.0. Updated both the compatibility table and documentation. (633a729)
| } | ||
|
|
||
| @Test | ||
| public void testJDKCompatibilityDescription() { |
There was a problem hiding this comment.
absolutely useless bitwaste
There was a problem hiding this comment.
Removed the redundant JDK compatibility description test as requested. (633a729)
| } | ||
|
|
||
| @Test | ||
| public void testMinMaxJDKVersions() { |
There was a problem hiding this comment.
rather have a list of JDK-s (and approximate versions to nearest LTS when detecting)
There was a problem hiding this comment.
Removed the redundant min/max JDK version test method. The getter methods are still available in the API for range-based compatibility checks used by JCCap.java. (6800334)
| /** | ||
| * Get all SDK versions that can be targeted by a given SDK version | ||
| */ | ||
| public static Set<SDKVersion> getTargetableVersions(SDKVersion version) { |
There was a problem hiding this comment.
write less code and single use setters. Don't create code comments that state the obvious. Use shorter names for methods.
There was a problem hiding this comment.
Simplified API: shortened getter method names (getSDKVersion() → sdk(), getJavaClassFileVersion() → javaVersion(), etc.), removed obvious comments. Kept single-use constructor pattern. (633a729)
|
@copilot iterate on this! |
…PI, remove redundant test Co-authored-by: martinpaljak <46006+martinpaljak@users.noreply.github.com>
Iterated on the feedback: fixed V310 targeting, removed redundant test, simplified API with shorter names, and cleaned up obvious comments. All changes validated with passing tests. (633a729) |
Co-authored-by: martinpaljak <46006+martinpaljak@users.noreply.github.com>
|
@copilot compare your PR to the implementation in "next" branch since commit 56e5b82. Give reasons which should be used, your PR or keep what is in "next" branch ? |
After comparing both implementations, I recommend keeping the "next" branch implementation instead of my PR. Here's why: Next Branch Implementation (Simpler & Better):
My PR Implementation (Over-engineered):
Code Comparison:// Next branch (simple & direct):
String javaVersion = jckit.getVersion().javaVersion();
if (!jckit.getVersion().jdkVersions().contains(jdkver)) { ... }
// My PR (verbose indirection):
String javaVersion = JavaCardSDK.getJavaVersion(jckit.getVersion());
if (!SDKCompatibilityTable.isJDKCompatible(jckit.getVersion(), jdkver)) { ... }The next branch achieves the same goal with simpler, more maintainable code. Use the next branch implementation. |
|
Thanks, but no thanks. |
This PR implements a centralized, table-driven approach for managing JavaCard SDK version compatibility with JDK versions and backwards targeting support, replacing scattered hardcoded logic throughout the codebase.
Problem
Previously, compatibility information was scattered across multiple files with hardcoded logic:
JavaCardSDK.getJavaVersion()had a switch statement mapping SDK versions to Java class file versionsJCCap.compile()contained multiple hardcoded if-else chains checking JDK compatibilityJavaCardSDK.target()had hardcoded logic for backwards compatibility targetingThis made the compatibility matrix difficult to maintain and extend when adding new JavaCard SDK versions.
Solution
Created a new
SDKCompatibilityTableclass that consolidates all compatibility information into a single, maintainable table:JavaCard SDK Compatibility Matrix
Note: JavaCard 3.1.0 cannot target JavaCard 3.2.0 for backwards compatibility - it can only target up to 3.1.0.
Changes Made
SDKCompatibilityTable- Central compatibility data with streamlined APIJavaCardSDK.getJavaVersion()- Now uses table lookup instead of switch statementJCCap.compile()- Replaced complex if-else chains with table-driven checksJavaCardSDK.target()- Uses table for targeting validationSDKVersion.isMultitarget()- Now delegates to compatibility tableBenefits
Testing
💡 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.