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

ClassCastException with desugaring #360

Closed
ber4444 opened this issue Sep 22, 2022 · 10 comments · Fixed by #371
Closed

ClassCastException with desugaring #360

ber4444 opened this issue Sep 22, 2022 · 10 comments · Fixed by #371

Comments

@ber4444
Copy link

ber4444 commented Sep 22, 2022

java.lang.ClassCastException: j$.util.stream.ReferencePipeline$Head cannot be cast to java.util.stream.Stream
                                                                                                    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5364)
                                                                                                    	at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                    	at android.os.Looper.loop(Looper.java:154)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
                                                                                                    Caused by: java.lang.ClassCastException: j$.util.stream.ReferencePipeline$Head cannot be cast to java.util.stream.Stream
                                                                                                    	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:268)
                                                                                                    	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:194)
                                                                                                    	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
                                                                                                    	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1361)
                                                                                                    	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
                                                                                                    	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
                                                                                                    	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
                                                                                                    	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:235)
                                                                                                    	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:500)
                                                                                                    	at j$.util.stream.Stream$VivifiedWrapper.collect(D8$$SyntheticClass)
                                                                                                    	at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.getSpanKeysFromAttributesExtractors(InstrumenterBuilder.java:378)
                                                                                                    	at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildSpanSuppressor(InstrumenterBuilder.java:366)
                                                                                                    	at io.opentelemetry.instrumentation.api.instrumenter.Instrumenter.<init>(Instrumenter.java:93)
                                                                                                    	at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder$InstrumenterConstructor$$ExternalSyntheticLambda1.create(D8$$SyntheticClass)
                                                                                                    	at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildInstrumenter(InstrumenterBuilder.java:325)
                                                                                                    	at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildInstrumenter(InstrumenterBuilder.java:317)
                                                                                                    	at io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpTelemetryBuilder.build(OkHttpTelemetryBuilder.java:87)
                                                                                                    	at com.splunk.rum.SplunkRum.createOkHttpTracing(SplunkRum.java:191)
                                                                                                    	at com.splunk.rum.SplunkRum.createRumOkHttpCallFactory(SplunkRum.java:184)

I'm using Splunk OTEL 0.17.0, and version 1.2.2 of https://github.com/google/desugar_jdk_libs/
This is happening on OS 7

@ber4444
Copy link
Author

ber4444 commented Sep 22, 2022

Actually it's happening on any OS versions

@ber4444
Copy link
Author

ber4444 commented Sep 22, 2022

A fix is downgrading the desugaring library to '1.1.5'

@ber4444
Copy link
Author

ber4444 commented Sep 22, 2022

okay, so this was reported here: https://issuetracker.google.com/issues/243636261

@mateuszrzeszutek
Copy link
Contributor

Hey @ber4444 ,
We're actually using desugar_jdk_libs version 1.1.6 in this project:

coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.6")

Can you try using that version? (I suppose 1.1.5 would probably be fine as well)
We cannot do anything about bugs in the desugaring lib itself in this project, we can only recommend the version that's working for us.

@mateuszrzeszutek
Copy link
Contributor

Hey @ber4444 ,
You can now use desugar_jdk_libs 1.2.2 with AGP 7.3 -- we've switched to that version in #371

@mateuszrzeszutek mateuszrzeszutek linked a pull request Oct 4, 2022 that will close this issue
@ber4444
Copy link
Author

ber4444 commented Oct 28, 2022

This should not have been closed.

I tried with 1.2.2 but still crashing with a very similar stack trace:

  E  java.lang.RuntimeException: Unable to create application com.xxx.XXXApplication: java.lang.ClassCastException: j$.util.stream.v2 cannot be cast to java.util.stream.Stream
                         E      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7703)
                         E      at android.app.ActivityThread.access$1800(ActivityThread.java:324)
                         E      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2336)
                         E      at android.os.Handler.dispatchMessage(Handler.java:106)
                         E      at android.os.Looper.loopOnce(Looper.java:226)
                         E      at android.os.Looper.loop(Looper.java:313)
                         E      at android.app.ActivityThread.main(ActivityThread.java:8855)
                         E      at java.lang.reflect.Method.invoke(Native Method)
                         E      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                         E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
                         E  Caused by: java.lang.ClassCastException: j$.util.stream.v2 cannot be cast to java.util.stream.Stream
                         E      at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:280)
                         E      at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:203)
                         E      at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:185)
                         E      at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1390)
                         E      at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
                         E      at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:475)
                         E      at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
                         E      at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:236)
                         E      at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:517)
                         E      at j$.util.stream.Stream$VivifiedWrapper.collect(Unknown Source:6)
                         E      at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.getSpanKeysFromAttributesExtractors(SourceFile:42)
                         E      at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildSpanSuppressor(Unknown Source:2)
                         E      at io.opentelemetry.instrumentation.api.instrumenter.Instrumenter.<init>(SourceFile:67)
                         E      at io.opentelemetry.instrumentation.api.instrumenter.c.create(Unknown Source:2)
                         E      at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildInstrumenter(SourceFile:6)
                         E      at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildInstrumenter(SourceFile:4)
                         E      at io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpTelemetryBuilder.build(SourceFile:64)

@ber4444
Copy link
Author

ber4444 commented Oct 28, 2022

The Google issue I linked to says

This is fixed in 2.0+ which is to be released,
I don't see any way to implement a good fix in 1.2.

@mateuszrzeszutek
Copy link
Contributor

Hey @ber4444 ,
We actually went back to version 1.1.8 in #373
(1.2 for some reason worked, but only on my machine 😅 )
Can you try using 1.1.8 and check if this issue still persists?

@breedx-splk
Copy link
Contributor

Hi @ber4444 . This issue looks to be stale (almost a year old now with no reply). Can you reply with the latest results or otherwise let us know if this is still an issue?

@breedx-splk
Copy link
Contributor

Please reopen if still relevant. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants