Skip to content

Issue with R8 and Reflection on InstantTimeProvider #11975

Closed
@hijamoya

Description

@hijamoya

What version of gRPC-Java are you using?

v1.71.0

What is your environment?

android

What did you expect to see?

The reflection on the getNano() method of java.time.Instant or j$.time.Instant should work correctly without throwing a NoSuchMethodException.

What did you see instead?

java.lang.NoSuchMethodException: j$.time.Instant.getNano []

Steps to reproduce the bug

I am currently working on an Android project using gRPC-Java v1.71.0, and I am facing an issue related to R8 and reflection, specifically with the j$.time.Instant and java.time.Instant classes. I am using coreLibraryDesugaring to handle time-related functionality, but when I try to use the latest v1.71.0 version (there is no issue in v1.68.1) , I encounter a NoSuchMethodException for the getNano() method.
However, If I don't use R8, it works correctly.

What I Have Tried:
• Added specific -keep rules for j$.time.Instant and java.time.Instant.
• Tried to use both public *; and more specific getNano() methods in the ProGuard rules.
• Verified the class names are correct in the reflection code.

Can anyone provide guidance on how to ensure these classes and methods are not removed or obfuscated by ProGuard when using reflection with coreLibraryDesugaring? Or is there another solution to prevent the NoSuchMethodException error in this case

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions