How to use _Assertions object in Kotlin?

404 Views Asked by At

I'm trying to recreate a file walker (like File('/path').walk()) for Android's Storage Access Framework. This is a snippet from the original FileTreeWalk:

private abstract class DirectoryState(rootDir: File) : WalkState(rootDir) {
    init {
        if (_Assertions.ENABLED)
            assert(rootDir.isDirectory) { "rootDir must be verified to be directory beforehand." }
    }
}

It seems that _Assertions is only visible inside its module (internal visibility), which seems to be the stdlib:

@PublishedApi
internal object _Assertions {
    @JvmField
    @PublishedApi
    internal val ENABLED: Boolean = javaClass.desiredAssertionStatus()
}

Is there a way that I can check _Assertions.ENABLED in my walker?

0

There are 0 best solutions below