Longi94 / JavaSteam

Java library that provides an interface to directly interact with Valve's Steam servers.
MIT License
96 stars 20 forks source link

[Bug]: AuthSession.pollingWaitForResultCompat can't be used in pure-Java projects due to Kotlin exception dependency #257

Closed Eiim closed 6 months ago

Eiim commented 6 months ago

Describe the bug

I'm trying to implement logon following the template at SampleLogonAuthentication.java, which has this line:

https://github.com/Longi94/JavaSteam/blob/c388103874dd22bec2ea0933d0b41f435b7e3d29/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_1logon/SampleLogonAuthentication.java#L115

Unfortunately, this doesn't work, because of the exceptions thrown by the method pollingWaitForResultCompat():

https://github.com/Longi94/JavaSteam/blob/c388103874dd22bec2ea0933d0b41f435b7e3d29/src/main/java/in/dragonbra/javasteam/steam/authentication/AuthSession.kt#L84-L94

In particular, NotImplementedError is from Kotlin, so Java builds can't access it. Since it can be thrown here, a Java class could need to handle it. See this Gradle build result:

> Task :compileJava FAILED
C:\Users\ethan\Documents\GitHub\Game2Git\src\main\java\io\github\eiim\game2git\App.java:68: error: cannot access NotImplementedError
            AuthPollResult pollResponse = authSession.pollingWaitForResultCompat();
                                                                                ^
  class file for kotlin.NotImplementedError not found
1 error

FAILURE: Build failed with an exception.

To Reproduce

  1. Create a Java project
  2. Add Javastream and bcprov-jdk18on dependencies
  3. Copy SampleLogonAuthentication.java
  4. Attempt to build

Expected behavior

It should be able to compile.

JavaSteam Version

1.3.0

Platform Version

Windows

JVM Version

Adoptium 21.0.2

Additional Information

No response

LossyDragon commented 6 months ago

I had a similar report for that catch. Try using 1.4.0-SNAPSHOT

LossyDragon commented 6 months ago

Read through some DM's about this same issue. Try adding kotlin.stdlib 1.9.23. https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib/1.9.23

If you use java modules, add requires kotlin.stdlib;

Eiim commented 6 months ago

That works, thanks!

LossyDragon commented 6 months ago

I did find the issue now, I'll try and remove the requirements for stdlib for 1.4.0