oblac / jodd-util

Essential Java utilities.
https://util.jodd.org
BSD 2-Clause "Simplified" License
40 stars 9 forks source link

java.lang.management not available on Android #16

Closed neroux closed 1 year ago

neroux commented 1 year ago

@igr, it would appear as if the newest Android Studio (or one of its libraries) was not too fond of the use of java.lang.management.ManagementFactory in jodd.util.SystemInfo

https://github.com/oblac/jodd-util/blob/8d7398b8f9b06163c05e54e4efd0719961300aa6/src/main/java/jodd/util/SystemInfo.java#L495

The error message is

Missing class java.lang.management.ManagementFactory (referenced from: long jodd.util.SystemInfo.getCurrentPID())
Missing class java.lang.management.RuntimeMXBean (referenced from: long jodd.util.SystemInfo.getCurrentPID())

That seems to be a general issue with that package on Android -> https://stackoverflow.com/a/19595885 and https://github.com/Kotlin/kotlinx.coroutines/issues/959

It's possible to "skip" that error, so it's not a complete show-stopper. Rather a heads-up :)

igr commented 1 year ago

Maybe I can just remove that method, as on Java9 there is a new way anyway: long pid = ProcessHandle.current().pid();

igr commented 1 year ago

6.2.1. released:)