Bug Description
The SDK currently relies on a hardcoded package name (com.razorpay.) inside ApiClient.java while resolving entity classes through reflection.
When the SDK is repackaged using shading or relocation (for example, with the Maven Shade Plugin), the package name changes, causing reflection to fail. This results in response parsing failures and ClassCastException/Unable to parse response errors, as reported in Issue #41 and Issue #333.
Additionally, the current test infrastructure depends on legacy Mockito APIs and older build tooling, which causes compatibility issues on modern Java versions (JDK 17+).
Proposed Solution
- Replace hardcoded package references with dynamic package resolution using
getClass().getPackage().getName().
- Modernize the test environment by upgrading Mockito and JaCoCo.
- Configure Maven Surefire for newer JVMs.
- Replace deprecated Mockito APIs (
anyObject() → any(), initMocks() → openMocks()).
- Remove the duplicate
org.json dependency from pom.xml.
Expected Outcome
- Response parsing works correctly even when the SDK is shaded or relocated.
- Developers can run the full test suite successfully on JDK 8–21.
- Removes deprecated APIs and improves long-term maintainability.
Verification
- ✅
mvn clean compile
- ✅
mvn test
- ✅ All 170 unit tests passed on Java 21.
Bug Description
The SDK currently relies on a hardcoded package name (
com.razorpay.) insideApiClient.javawhile resolving entity classes through reflection.When the SDK is repackaged using shading or relocation (for example, with the Maven Shade Plugin), the package name changes, causing reflection to fail. This results in response parsing failures and
ClassCastException/Unable to parse responseerrors, as reported in Issue #41 and Issue #333.Additionally, the current test infrastructure depends on legacy Mockito APIs and older build tooling, which causes compatibility issues on modern Java versions (JDK 17+).
Proposed Solution
getClass().getPackage().getName().anyObject()→any(),initMocks()→openMocks()).org.jsondependency frompom.xml.Expected Outcome
Verification
mvn clean compilemvn test