Bloop: AssertionError: expected protocol to be 'file' or empty in URI

Created on 28 May 2020  路  5Comments  路  Source: scalacenter/bloop

While running bloop compile with v1.4.1 I got the following error that I have never seen before 馃

java.lang.RuntimeException: java.lang.AssertionError: assertion failed: Expected protocol to be 'file' or empty in URI jar:file:/Users/lgeirsson/workspace/bsp-projects/foobar/.bloop/bloop-jars/finatra.http.src.main.scala.com.twitter.finatra.http.response.response.jar
!/com/twitter/finatra/http/response/ResponseBuilder.class
    at com.sun.tools.javac.main.Main.compile(Main.java:559)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at bloop.CompilerCache$BloopJavaCompiler.run(CompilerCache.scala:271)
    at sbt.internal.inc.javac.AnalyzingJavaCompiler.$anonfun$compile$11(AnalyzingJavaCompiler.scala:156)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at sbt.internal.inc.javac.AnalyzingJavaCompiler.timed(AnalyzingJavaCompiler.scala:234)
    at sbt.internal.inc.javac.AnalyzingJavaCompiler.compile(AnalyzingJavaCompiler.scala:146)
    at sbt.internal.inc.javac.AnalyzingJavaCompiler.compile(AnalyzingJavaCompiler.scala:73)
    at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$9(BloopHighLevelCompiler.scala:179)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:72)
    at bloop.tracing.BraveTracer.traceInternal(BraveTracer.scala:64)
    at bloop.tracing.BraveTracer.trace(BraveTracer.scala:38)
    at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:71)
    at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$8(BloopHighLevelCompiler.scala:172)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at monix.eval.internal.TaskRunLoop$.monix$eval$internal$TaskRunLoop$$loop$1(TaskRunLoop.scala:187)
    at monix.eval.internal.TaskRunLoop$RestartCallback$1.onSuccess(TaskRunLoop.scala:119)
    at monix.eval.Task$.$anonfun$forkedUnit$2(Task.scala:1463)
    at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.AssertionError: assertion failed: Expected protocol to be 'file' or empty in URI jar:file:/Users/lgeirsson/workspace/bsp-projects/foobar/.bloop/bloop-jars/finatra.http.src.main.scala.com.twitter.finatra.http.response.response.jar!/com/twitter/finatra/http/response/ResponseBuilder.class
    at scala.Predef$.assert(Predef.scala:223)
    at sbt.io.IO$.uriToFile(IO.scala:150)
    at sbt.io.IO$.toFile(IO.scala:123)
    at sbt.internal.inc.javac.DiagnosticsReporter$PositionImpl$.$anonfun$apply$1(DiagnosticsReporter.scala:107)
    at scala.Option.map(Option.scala:230)
    at sbt.internal.inc.javac.DiagnosticsReporter$PositionImpl$.apply(DiagnosticsReporter.scala:107)
    at sbt.internal.inc.javac.DiagnosticsReporter.report(DiagnosticsReporter.scala:50)
    at com.sun.tools.javac.api.ClientCodeWrapper$WrappedDiagnosticListener.report(ClientCodeWrapper.java:593)
    at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:616)
    at com.sun.tools.javac.util.Log$DefaultDiagnosticHandler.report(Log.java:591)
    at com.sun.tools.javac.util.Log$DeferredDiagnosticHandler.reportDeferredDiagnostics(Log.java:161)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.showDiagnostics(JavacProcessingEnvironment.java:1064)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1191)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    ... 24 more

I'm still working on minimizing a reproduction but wanted to start by opening a ticket with the stack trace. Any idea what might be causing this issue?

The jar from the exception is here response.jar (rename to response.jar to make it work). It's a java codebase where the error happens.

bug task / compile

All 5 comments

Thanks for reporting! I have never seen this issue, looks like it's being thrown in the sbt-zinc universe. I'm wondering if sbt needs to be changed to process the jar:file URI protocol correctly. Is this jar specified only in the classpath of a project?

This is caused by javac reporting the following warning:

Cannot find annotation method 'value()' in type 'com.company.MyAnnotation': class file for com.company.MyAnnotation not found

The error is indeed attached to a classfile inside a JAR on my classpath. This is fixed in upstream Zinc in https://github.com/sbt/zinc/commit/db028c338af528876e24fc8d6214e24f7d19d707#diff-8c308205e560ef07b6e6b8e73e438e5dR109-R123

Nice job tracking that down! Do I understand correctly this would be fixed by rebasing on top of the latest changes in zinc 1.4.0-M1?

Yes, I believe so.

I cherry-picked the relevant parts of the commit I linked above to scalacenter/zinc#13.

I built it manually, and can confirm that this fixes our issue 馃帀

Was this page helpful?
0 / 5 - 0 ratings