JakeWharton / timber

A logger with a small, extensible API which provides utility on top of Android's normal Log class.
https://jakewharton.github.io/timber/docs/5.x/
Apache License 2.0
10.41k stars 959 forks source link

Unable to build with latest JDK #416

Open neoneye opened 3 years ago

neoneye commented 3 years ago

Hi Timber,

I just checked out this Timber repo and ran gradle test. However I'm seeing some robolectric issues.

PROMPT> gradle test
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Task :timber:compileDebugKotlin
w: /Users/johndoe/timber-master/timber/src/main/java/timber/log/Timber.kt: (20, 18): There's a cycle in scopes for that type. Most probably, there's a companion object that inherits some nested class (see KT-21515).
Such code is currently unstable, and its behavior may change in future releases
w: /Users/johndoe/timber-master/timber/src/main/java/timber/log/Timber.kt: (144, 66): 'isLoggable(Int): Boolean' is deprecated. Use isLoggable(String, int)
w: /Users/johndoe/timber-master/timber/src/main/java/timber/log/Timber.kt: (153, 11): Name shadowed: message
w: /Users/johndoe/timber-master/timber/src/main/java/timber/log/Timber.kt: (274, 13): There's a cycle in scopes for that type. Most probably, there's a companion object that inherits some nested class (see KT-21515).
Such code is currently unstable, and its behavior may change in future releases

> Task :timber:compileDebugJavaWithJavac
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings

> Task :timber:compileDebugUnitTestJavaWithJavac
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings

> Task :timber:testDebugUnitTest
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.robolectric.util.ReflectionHelpers$7 (file:/Users/johndoe/.gradle/caches/modules-2/files-2.1/org.robolectric/shadowapi/3.8/d638f001e81ef737bb35db2964312360cc996a94/shadowapi-3.8.jar) to method java.lang.ClassLoader.getPackage(java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.robolectric.util.ReflectionHelpers$7
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

timber.log.TimberTest > nullMessageWithoutThrowable FAILED
    java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalAccessException: Can not set static final org.robolectric.internal.IShadow field org.robolectric.shadow.api.Shadow.SHADOW_IMPL to org.robolectric.internal.bytecode.ShadowImpl
        at org.robolectric.util.ReflectionHelpers.setStaticField(ReflectionHelpers.java:192)
        at org.robolectric.internal.bytecode.Sandbox.configure(Sandbox.java:63)
        at org.robolectric.internal.SandboxTestRunner.configureShadows(SandboxTestRunner.java:205)
        at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:223)
        at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
        at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
        at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
        at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:119)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:832)

        Caused by:
        java.lang.RuntimeException: java.lang.IllegalAccessException: Can not set static final org.robolectric.internal.IShadow field org.robolectric.shadow.api.Shadow.SHADOW_IMPL to org.robolectric.internal.bytecode.ShadowImpl
            at org.robolectric.util.ReflectionHelpers.setStaticField(ReflectionHelpers.java:177)
            at org.robolectric.util.ReflectionHelpers.setStaticField(ReflectionHelpers.java:190)
            ... 42 more

            Caused by:
            java.lang.IllegalAccessException: Can not set static final org.robolectric.internal.IShadow field org.robolectric.shadow.api.Shadow.SHADOW_IMPL to org.robolectric.internal.bytecode.ShadowImpl
                at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76)
                at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80)
                at java.base/jdk.internal.reflect.UnsafeQualifiedStaticObjectFieldAccessorImpl.set(UnsafeQualifiedStaticObjectFieldAccessorImpl.java:77)
                at java.base/java.lang.reflect.Field.set(Field.java:778)
                at org.robolectric.util.ReflectionHelpers.setStaticField(ReflectionHelpers.java:175)
                ... 43 more

Info

timber git hash: 4fd8e2a09c81931e9c9b004f45aea2937835278c.

Android Studio 4.2.1

macOS 11.4

JakeWharton commented 3 years ago

My guess is your JDK is too new and restricts whatever Robolectric is doing. For now, you can use an older JDK. Long term we'll upgrade or eliminate Robolectric.

JakeWharton commented 3 years ago

kapt is now broken on JDK 16 as well.