Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel 4.1 fails to desugar kotlinx-coroutines-core-jvm:1.5.0 #13553

Open
Bencodes opened this issue Jun 4, 2021 · 15 comments
Open

Bazel 4.1 fails to desugar kotlinx-coroutines-core-jvm:1.5.0 #13553

Bencodes opened this issue Jun 4, 2021 · 15 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug

Comments

@Bencodes
Copy link
Contributor

Bencodes commented Jun 4, 2021

Description of the problem / feature request:

Bazel 4.1 fails to desugar kotlinx-coroutines-core-jvm:1.5.0 producing the following exception:

ERROR: /private/var/tmp/_bazel_blee/f1f2afba98d721e05bb8ec203ca691d8/external/maven/BUILD:57:11: Desugaring v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.5.0/kotlinx-coroutines-core-jvm-1.5.0.jar for Android failed: (Exit 1): desugar_java8 failed: error executing command bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/bazel_tools/tools/android/desugar_java8 ... (remaining 1 argument(s) skipped)
java.lang.TypeNotPresentException: Type sun.misc.SignalHandler not present
        at java.base/sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:97)
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:69)
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:45)
        at java.base/java.lang.invoke.MethodType.fromDescriptor(MethodType.java:1134)
        at java.base/java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1113)
        at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:406)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)
        at com.google.devtools.build.android.desugar.strconcat.IndyStringConcatDesugaring$IndifiedStringConcatInvocationConverter.visitInvokeDynamicInsn(IndyStringConcatDesugaring.java:141)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)
        at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2444)
        at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1487)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:717)
        at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:544)
        at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:320)
        at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:240)
        at com.google.devtools.build.android.desugar.Desugar.processRequest(Desugar.java:1014)
        at com.google.devtools.build.android.desugar.Desugar.runPersistentWorker(Desugar.java:974)
        at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:952)
Caused by: java.lang.ClassNotFoundException: Class sun.misc.SignalHandler not found
        at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:53)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        at java.base/sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:95)
        ... 18 more

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Steps to reproduce can be found here https://github.com/Bencodes/bazel_issue_13553

Example failure: https://github.com/Bencodes/bazel_issue_13553/runs/2742154274?check_suite_focus=true#step:5:44

What operating system are you running Bazel on?

macOs 10.15.7

What's the output of bazel info release?

release 4.1.0

Any other information, logs, or outputs that you want to share?

java-runtime: OpenJDK Runtime Environment (build 11.0.6+10-LTS) by Azul Systems, Inc.
java-vm: OpenJDK 64-Bit Server VM (build 11.0.6+10-LTS, mixed mode) by Azul Systems, Inc.

@Bencodes
Copy link
Contributor Author

Bencodes commented Jun 7, 2021

Tested against HEAD and it also fails

@alexjlockwood
Copy link

This issue appears to be a blocker for adopting Jetpack Compose in Bazel projects. (The latest 1.0.0-beta08 release requires Kotlin 1.5.10 and Kotlin coroutines 1.5.0).

@arunkumar9t2
Copy link
Contributor

Could be caused by Kotlin/kotlinx.coroutines@b400b02

Since AgentPremain contains sun.misc.SignalHandler import.

Wonder how gradle handle sun.* packages during desugar.

@cgruber
Copy link
Contributor

cgruber commented Jun 8, 2021

A related issue occurred in Kotlin/kotlinx.coroutines#2046. The workaround there was to make proguard not spew typenotfound errors like so.

-dontwarn java.lang.instrument.ClassFileTransformer
-dontwarn sun.misc.SignalHandler
-dontwarn java.lang.instrument.Instrumentation
-dontwarn sun.misc.Signal

This case seems to be different - the desugarer blows up, not proguard, but it may be a clue on the hunt.

I know we ran into inconsistencies between the bazel desugarer and the desugaring in the android toolchain, and in some cases resolved things by calling out to d8 in a custom toolchain, but it's not clear whether the problems we had were connected to this one. I know gradle uses d8's desugaring, and may simply have special case logic around sun.misc stuff, which I think gets magically swapped by Android's jvm impl anyway (or things that rely on it are swizzled in)

@kevin1e100
Copy link
Contributor

The original report seems to indicate that desugaring is run on JDK11. Does this also happen when using a JDK8 as host JDK?

@Kernald
Copy link
Contributor

Kernald commented Jun 10, 2021

I just tried with a JDK8:

openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)

And got what looks like the exact same stacktrace:

ERROR: /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/external/maven/BUILD:8498:11: Desugaring external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotli
nx/kotlinx-coroutines-core-jvm/1.5.0/kotlinx-coroutines-core-jvm-1.5.0.jar for Android failed: (Exit 1): desugar_java8 failed: error executing command bazel-out/k8-py2-opt-exec-2B5CBBC6/bin
/external/bazel_tools/tools/android/desugar_java8 ... (remaining 1 argument(s) skipped)                                                                                                      
java.lang.TypeNotPresentException: Type sun.misc.SignalHandler not present                                                                                                                   
        at java.base/sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:97)                                                                                                 
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:69)                                                                                              
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:45)                                                                                              
        at java.base/java.lang.invoke.MethodType.fromDescriptor(MethodType.java:1134)                                                                                                        
        at java.base/java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1113)                                                                                            
        at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:406)                                                
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at com.google.devtools.build.android.desugar.strconcat.IndyStringConcatDesugaring$IndifiedStringConcatInvocationConverter.visitInvokeDynamicInsn(IndyStringConcatDesugaring.java:141)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2444)                                                                                                                     
        at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1487)                                                                                                                   
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:717)                                                                                                                        
        at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:544)                                                                                         
        at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:320)                                                                                               
        at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:240)                                                                                                       
        at com.google.devtools.build.android.desugar.Desugar.processRequest(Desugar.java:1014)                                                                                               
        at com.google.devtools.build.android.desugar.Desugar.runPersistentWorker(Desugar.java:974)                                                                                           
        at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:952)                                                                                                          
Caused by: java.lang.ClassNotFoundException: Class sun.misc.SignalHandler not found                                                                                                          
        at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:53)                                                                               
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)                                                                                                                   
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)                                                                                                                   
        at java.base/sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:95)                                                                                                 
        ... 18 more                                                                                     

Interestingly enough, I had to use --keep_going as I was otherwise hitting a different desugar-related exception (which I also get with a JDK11):

ERROR: /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/external/maven/BUILD:8447:11: Desugaring external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotli
nx/kotlinx-coroutines-android/1.5.0/kotlinx-coroutines-android-1.5.0.jar for Android failed: Worker process did not return a WorkResponse:                                                   
                                                                                                                                                                                             
---8<---8<--- Start of log, file at /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/bazel-workers/worker-24-Desugar.log ---8<---8<---                             
Jun 10, 2021 4:36:03 PM com.google.devtools.build.android.desugar.Desugar runPersistentWorker                                                                                                
INFO: Processing Request success:                                                                                                                                                            
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation                                                                                                    
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)                                                                                                                       
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)                                                                                                                
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:877)                                                                                                                 
        at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:67)                                                                               
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)                                                                                                                   
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)                                                                                                                   
        at java.base/sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:95)                                                                                                 
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:60)                                                                                              
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:45)                                                                                              
        at java.base/java.lang.invoke.MethodType.fromDescriptor(MethodType.java:1134)                                                                                                        
        at java.base/java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1113)                                                                                            
        at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:406)                                                
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at com.google.devtools.build.android.desugar.strconcat.IndyStringConcatDesugaring$IndifiedStringConcatInvocationConverter.visitInvokeDynamicInsn(IndyStringConcatDesugaring.java:141)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2444)                                                                                                                     
        at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1487)                                                                                                                   
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:717)                                                                                                                        
        at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:544)                                                                                         
        at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:320)                                                                                               
        at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:240)                                                                                                       
        at com.google.devtools.build.android.desugar.Desugar.processRequest(Desugar.java:1014)                                                                                               
        at com.google.devtools.build.android.desugar.Desugar.runPersistentWorker(Desugar.java:974)                                                                                           
        at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:952)                                                                                                          
Caused by: java.lang.ClassNotFoundException: Class kotlin.coroutines.Continuation not found                                                                                                  
        at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:53)                                                                               
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)                                                                                                                   
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)                                                                                                                   
        ... 25 more                                                                                                                                                                          
---8<---8<--- End of log ---8<---8<---                                                                           

@philwo philwo added team-Android Issues for Android team type: bug labels Jun 10, 2021
@kevin1e100
Copy link
Contributor

The second error suggests that kotlin-stdlib.jar isn't on the classpath of kotlinx-coroutines-core-jvm-1.5.0.jar. You may need to add the former as a dep to the import of the latter. Could you also possibly share the output you get from including --verbose_failures in your Bazel command?

@Kernald
Copy link
Contributor

Kernald commented Jun 14, 2021

The second error suggests that kotlin-stdlib.jar isn't on the classpath of kotlinx-coroutines-core-jvm-1.5.0.jar. You may need to add the former as a dep to the import of the latter.

Wouldn't kotlin.coroutines.Continuation be in kotlinx-coroutines-core-jvm rather than kotlin-stdlib? Either way, I don't have an easy way to add a dependency to the classpath by using rules_jvm_external as far as I'm aware - I tried wrapping every use of kotlinx-coroutines-core-jvm that I have in a java_library target depending on kotlin-stdlib, but it doesn't help.

Could you also possibly share the output you get from including --verbose_failures in your Bazel command?

This is what I get for the sun.misc.SignalHandler not found exception:

ERROR: /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/external/maven/BUILD:8498:11: Desugaring external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.5.0/kotlinx-coroutines-core-jvm-1.5.0.jar for Android failed: (Exit 1): desugar_java8 failed: error executing command 
  (cd /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/execroot/fr_enoent && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
  bazel-out/k8-py2-opt-exec-2B5CBBC6/bin/external/bazel_tools/tools/android/desugar_java8 @bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/_dx/org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm/kotlinx-coroutines-core-jvm-1.5.0.jar_desugared.jar-0.params)
Execution platform: @local_config_platform//:host
java.lang.TypeNotPresentException: Type sun.misc.SignalHandler not present
        at java.base/sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:97)
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:69)
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:45)
        at java.base/java.lang.invoke.MethodType.fromDescriptor(MethodType.java:1134)
        at java.base/java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1113)
        at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:406)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)
        at com.google.devtools.build.android.desugar.strconcat.IndyStringConcatDesugaring$IndifiedStringConcatInvocationConverter.visitInvokeDynamicInsn(IndyStringConcatDesugaring.java:141)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)
        at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2444)
        at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1487)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:717)
        at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:544)
        at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:320)
        at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:240)
        at com.google.devtools.build.android.desugar.Desugar.processRequest(Desugar.java:1014)
        at com.google.devtools.build.android.desugar.Desugar.runPersistentWorker(Desugar.java:974)
        at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:952)
Caused by: java.lang.ClassNotFoundException: Class sun.misc.SignalHandler not found
        at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:53)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        at java.base/sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:95)
        ... 18 more

And not much more for the continuation related one:

ERROR: /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/external/maven/BUILD:8447:11: Desugaring external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotli
nx/kotlinx-coroutines-android/1.5.0/kotlinx-coroutines-android-1.5.0.jar for Android failed: Worker process did not return a WorkResponse:                                                   
                                                                                                                                                                                             
---8<---8<--- Start of log, file at /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/bazel-workers/worker-41-Desugar.log ---8<---8<---                             
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/coroutines/Continuation                                                                                                    
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)                                                                                                                       
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)                                                                                                                
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:877)                                                                                                                 
        at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:67)                                                                               
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)                                                                                                                   
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)                                                                                                                   
        at java.base/sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:95)                                                                                                 
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:60)                                                                                              
        at java.base/sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:45)                                                                                              
        at java.base/java.lang.invoke.MethodType.fromDescriptor(MethodType.java:1134)                                                                                                        
        at java.base/java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1113)                                                                                            
        at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:406)                                                
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at com.google.devtools.build.android.desugar.strconcat.IndyStringConcatDesugaring$IndifiedStringConcatInvocationConverter.visitInvokeDynamicInsn(IndyStringConcatDesugaring.java:141)
        at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(MethodVisitor.java:461)                                                                                                    
        at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2444)                                                                                                                     
        at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1487)                                                                                                                   
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:717)                                                                                                                        
        at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:544)                                                                                         
        at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:320)                                                                                               
        at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:240)                                                                                                       
        at com.google.devtools.build.android.desugar.Desugar.processRequest(Desugar.java:1014)                                                                                               
        at com.google.devtools.build.android.desugar.Desugar.runPersistentWorker(Desugar.java:974)                                                                                           
        at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:952)                                                                                                          
Caused by: java.lang.ClassNotFoundException: Class kotlin.coroutines.Continuation not found                                                                                                  
        at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:53)                                                                               
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)                                                                                                                   
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)                                                                                                                   
        ... 25 more                                                                                                                                                                          
---8<---8<--- End of log ---8<---8<---                                                                   

@kevin1e100
Copy link
Contributor

Wouldn't kotlin.coroutines.Continuation be in kotlinx-coroutines-core-jvm rather than kotlin-stdlib?

Note the missing x in kotlin.coroutines.Continuation: to my knowledge this class is in the stdlib.

Thanks for the --verbose_failures output, which I had unfortunately failed to anticipate wouldn't be enough: I'm interested in the contents of the @... params file included in the printed command line, i.e., bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/_dx/org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm/kotlinx-coroutines-core-jvm-1.5.0.jar_desugared.jar-0.params in the shared output. Could you share the contents of that file, possibly?

@Bencodes
Copy link
Contributor Author

Could you share the contents of that file, possibly?

This is what i'm seeing in the param file for kotlinx-coroutines-core-jvm

cat bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/_dx/org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm/kotlinx-coroutines-core-jvm-1.5.0.jar_desugared.jar-0.params
--input
external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.5.0/kotlinx-coroutines-core-jvm-1.5.0.jar
--output
bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/_dx/org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm/kotlinx-coroutines-core-jvm-1.5.0.jar_desugared.jar
--classpath_entry
bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.5.0/header_kotlinx-coroutines-core-jvm-1.5.0.jar
--classpath_entry
bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.0/header_kotlin-stdlib-common-1.5.0.jar
--classpath_entry
bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.5.0/header_kotlin-stdlib-jdk8-1.5.0.jar
--classpath_entry
bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.5.0/header_kotlin-stdlib-1.5.0.jar
--classpath_entry
bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/header_annotations-13.0.jar
--classpath_entry
bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.5.0/header_kotlin-stdlib-jdk7-1.5.0.jar
--bootclasspath_entry
external/androidsdk/platforms/android-29/android.jar
--emit_dependency_metadata_as_needed

@kevin1e100
Copy link
Contributor

Aha thanks. It's possible that --bootclasspath_entry external/androidsdk/platforms/android-29/android.jar is causing confusion here. All else equal it may be better to supply a JDK 8 bootclasspath, because that is what the input Jar was presumably compiled against. I'm not sure how/why it's using an android.jar in the first place, and this may well not be the issue, so I'm not sure if I'm helping or hurting here, but if someone has a way to try using a different bootclasspath I'd hope that that would allow making progress in diagnosing the issue.

@geaden
Copy link

geaden commented Nov 4, 2021

Is there way to workaround the issue? Can we add sun.misc.SignalHandler into https://github.com/google/desugar_jdk_libs/tree/master/jdk11/src/java.base/share/classes/sun/misc and use updated version of the libs?

@Kernald
Copy link
Contributor

Kernald commented Nov 4, 2021

Bencodes/bazel_issue_13553#1 is a working workaround.

@geaden
Copy link

geaden commented Nov 4, 2021

Bencodes/bazel_issue_13553#1 is a working workaround.

Thanks a lot!

@nohe427
Copy link

nohe427 commented Jul 28, 2022

Reproduced on release 5.2.0

adhiamboperes added a commit to oppia/oppia-android that referenced this issue Jun 12, 2024
## Explanation
Fixes #4119
Fixes #4120
Fixes part of #59

This PR finishes the migration of the codebase to Kotlin 1.6 (addressing
both #4119 and #4120).

Kotlin 1.6 is needed as part of moving rules_kotlin to 1.7.x (which is,
in turn, needed in conjunction with Bazel 6.x to enable strict
dependency checking which significantly simplifies modularization which
is planned for downstream PRs). This PR doesn't actually finish the
movement to that version of rules_kotlin, but it does finish moving the
codebase to a new enough (and no longer pre-release) version of
rules_kotlin to allow using Kotlin 1.6 (over Kotlin 1.4 that the
codebase currently uses): version 1.5.0.

Previous PRs (#5400 and #5402) prepared for the changes here by
addressing large categories of build warnings that have either arisen
from this migration, or from past work. Note that another large category
of warnings have also been addressed in this PR: by moving to Kotlin
1.6, there's no longer a runtime incompatibility between the Kotlin SDK
and the reflection APIs (which was causing a _lot_ of warning output
previously). Between all three PRs, the output is now very clean and
free of nearly all build warnings.

To try and keep the warnings clean long-term, this PR introduces
warnings-as-errors for both Java and Kotlin code. However, please note
some caveats:
- Dagger generated code doesn't follow the Java warnings-as-error flag,
so those warnings were cleaned up manually (and will need to be
generally watched for, unfortunately).
- The version of rules_kotlin used in this PR doesn't directly support
turning on the functionality, but does internally (so a small patch file
has been added to augment rules_kotlin). When the codebase is updated to
rules_kotlin 1.7.x this patch will no longer be needed.
- To ease development, a build configuration flag was added to disable
failure upon encountering build warnings (per
https://bazel.build/run/bazelrc and
https://bazel.build/docs/configurable-attributes#query-and-cquery as an
example), though this needs to be opted into:
  ```sh
  bazel build --config=ignore_build_warnings <target>
  ```

Some other details to note:
- Version 1.6.10 is specifically picked in order to ensure Jetpack
Compose compatibility (for preparation of the work being prototyped in
#5401 to be compatible with the Oppia Android build environment).
- The vast majority of code in this PR is updating parameterized tests
to use a cleaner repeatable annotation pattern that wasn't available in
Kotlin 1.4.
- This upgrade absolutely does have runtime implications, but we're
relying very heavily on existing automated tests to ensure correctness
and no regressions.
- This PR doesn't make an effort to move toward newer Kotlin language
features except where forced (API deprecations) or largely wanted (the
repeatable annotation change).
- android-spotlight and kotlitex have been updated to support newer
versions of Kotlin (as both are custom forks managed in the broader
Oppia GitHub organization).
- Gradle files have been updated to match the same dependency versions
as Bazel (where it was obvious to make changes; some might still be a
bit off).
- The Gradle build configuration was also updated to use Kotlin 1.6.x
(otherwise there would be build incompatibilities with Bazel). I think
this is the last upgrade we can do for Gradle without upgrading AGP
(which will cause us significant issues with the model module, so we're
planning on instead dropping Gradle support).
- API changes that needed to be addressed in this PR due to deprecations
include: ``String.captialize``, ``String.toLowerCase``,
``String.toUpperCase``, ``SendChannel.offer``, and ``Char.toInt``.
- New API changes that have been leveraged in this PR:
``Flow.lastOrNull`` and ``Deferred.asListenableFuture`` (to replace
``SettableFuture`` for safety; this also resulted in nice
simplifications in ``CoroutineExecutorService``).
- The JVM coroutines dependency needed to be split out from Maven and
manually imported with some empty internal Java class files since it
otherwise has some issues being desugared:
bazelbuild/bazel#13553. This is a problem with
the Desugarer used in Bazel 4.x (and maybe later versions, so this
solution will probably need to kept for a while).
- Some Proguard rule updates were needed due to Kotlin SDK changes--see
the Proguard file & comments for specifics.
- Due to dependency changes, the KitKat main dex file was also trimmed
down. I'm fairly certain that it's already crashing on startup, so I
don't care much about this change--it just needs to build. We plan to
remove KitKat entirely eventually, anyway: #5012.
- Jetifier (that is, automatic conversion from support libraries to
Jetpack/AndroidX) support was disabled in Gradle. We don't have it
enabled in Bazel, and it could potentially encourage strange one-version
violations if it was ever actually needed. This is a safer (and likely
more performant) change to make.
- Moshi was updated to 1.13 to support the upgrade in Kotlin. This did
result in a small configuration change due to its annotation processor
being moved. Note that Moshi 1.14 couldn't be supported since it
requires Kotlin 1.7+ which requires rules_kotlin 1.7+. This will be an
option to upgrade in the future.
- Some improvements and fixes were made in
``FilterPerLanguageResources`` (I think it was outputting something
incorrectly before and that's now been fixed as part of a broader
logical reworking of the filtering logic).
- ``com.android.support:support-annotation`` was removed as a dependency
since it was never used in Bazel, and shouldn't be used (since it's
support library and not AndroidX).
- The updates to Moshi and Kotlin dependencies resulted in a bunch of
other transitive dependency updates.
- Note that Gradle doesn't have ``allWarningsAsErrors`` enabled since it
would require fixing more warnings than is exposed in Bazel, and we're
using Bazel builds as the general source of truth for code quality.

## Essential Checklist
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

## For UI-specific PRs only
N/A -- This is an infrastructural change. While it could inadvertently
affect user-facing code, it shouldn't based on the current passing state
of automated tests.

---------

Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com>
Co-authored-by: Sean Lip <sean@seanlip.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug
Projects
None yet
Development

No branches or pull requests

10 participants