Skip to content
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

Library accesses GSON internal API, breaks with gson on the module path #1494

Closed
mikehearn opened this issue Dec 19, 2022 · 3 comments · Fixed by #1496
Closed

Library accesses GSON internal API, breaks with gson on the module path #1494

mikehearn opened this issue Dec 19, 2022 · 3 comments · Fixed by #1496
Labels

Comments

@mikehearn
Copy link

Describe the bug

The ReflectionCheckingTypeAdapterFactory class accesses a GSON internal class directly. This breaks when GSON is placed on the module path due to encapsulation.

java.lang.IllegalAccessError: class com.stripe.net.ReflectionCheckingTypeAdapterFactory (in unnamed module @0x69a3d1d) cannot access class com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter (in module com.google.gson) because module com.google.gson does not export com.google.gson.internal.bind to unnamed module @0x69a3d1d @ com.stripe.net.ReflectionCheckingTypeAdapterFactory.create(Unknown Source)

To Reproduce

Place gson on the module path and then try to use the Stripe API.

Expected behavior

There are a few possible fixes that spring to mind:

  1. This class looks like a utility / assertion checking class, so it could be disabled in production code paths.
  2. Instead of using instanceof, the class name could maybe be checked using reflection?
  3. The IllegalAccessError could be caught, and that used to disable the check at runtime.

Code snippets

No response

OS

macOS

Java version

Java 17

stripe-java version

22.1.0

API version

2022-11-15

Additional context

A workaround is to place gson on the classpath instead of the module path. One could probably also use --add-opens.

@mikehearn mikehearn added the bug label Dec 19, 2022
@richardm-stripe
Copy link
Contributor

Relates to #1197.

@mikehearn
Copy link
Author

Thanks!

@richardm-stripe
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants