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

No virtual method intValueExact() in Android API 30 and below #392

Closed
deskangel opened this issue Sep 14, 2023 · 3 comments
Closed

No virtual method intValueExact() in Android API 30 and below #392

deskangel opened this issue Sep 14, 2023 · 3 comments
Milestone

Comments

@deskangel
Copy link

  static int parseASN1IntegerAsInt(byte[] content) {
    return new BigInteger(content).intValueExact();
  }

It looks like jsch may not be compatible with older Android versions (xxxExact was introduced in Android API 31) based on the code above. Are there any recommended workarounds for this?

@norrisjeremy
Copy link
Contributor

Hi @deskangel,

I don't have any recommended workarounds other than to use a Java implementation that fully implements the Java 8 specification, since this JSch fork requires Java 8+ to function.

You are also welcome to submit a PR that we can review to attempt to remedy this issue if you believe you can find a way to implement the above method in a different way that is compatible with the non fully compliant version of Java you are attempting to use.

Thanks,
Jeremy

@deskangel
Copy link
Author

Hi @norrisjeremy,

I don't have the development environment for jsch and Java, so it's not very convenient for me to submit a PR. The reason I raised this issue is that I don't think it's necessary to introduce this function; It simply throws an exception when the value exceeds the int range compared to intValue. Previous versions of jsch worked well on older versions of Android, so I feel a bit regretful that it is incompatible with older Android versions just because of this function.

That's all.

mwiede added a commit that referenced this issue Sep 26, 2023
@mwiede
Copy link
Owner

mwiede commented Sep 26, 2023

@deskangel I can recommend Github Codespaces, which gives fast access to any repository out there and you could start working directly in the browser...

I have looked at this, but even desugaring did not help.
After compiling jsch in Android studio, it seems that this line of code is the only incompatibility with the Android API, so I have will create a small PR.

mwiede added a commit that referenced this issue Oct 3, 2023
#392 replace call to BigInteger.intValueExact to remain comptaible wi…
@mwiede mwiede added this to the 0.2.12 milestone Oct 25, 2023
@mwiede mwiede closed this as completed Oct 25, 2023
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

No branches or pull requests

3 participants