Scala reflection spamming to System.out at runtime (2.10.0 release)

80 views
Skip to first unread message

Aleksey Nikiforov

unread,
Jan 22, 2013, 11:40:07 AM1/22/13
to scala-l...@googlegroups.com
Getting spammed by these messages in System.out:

...
 [] ?_$3 setInst org.mypackage.MyClass
 [] ?_$3 setInst org.mypackage.MyClass
 [] ?_$3 setInst org.mypackage.MyClass
 [] ?_$3 setInst org.mypackage.MyClass
...


Stack trace from System.out reveals:

...
    at scala.Console$.println(Console.scala:240)
    at scala.Predef$.println(Predef.scala:287)
    at scala.reflect.runtime.JavaUniverse.log(JavaUniverse.scala:20)
    at scala.reflect.internal.Types$class.solveOne$1(Types.scala:6377)
    at scala.reflect.internal.Types$$anonfun$solve$1.apply(Types.scala:6384)
    at scala.reflect.internal.Types$$anonfun$solve$1.apply(Types.scala:6384)
    at scala.reflect.internal.util.Collections$class.foreach3(Collections.scala:160)
    at scala.reflect.internal.SymbolTable.foreach3(SymbolTable.scala:12)
    at scala.reflect.internal.Types$class.solve(Types.scala:6384)
    at scala.reflect.internal.SymbolTable.solve(SymbolTable.scala:12)
    at scala.reflect.internal.Types$ExistentialType.withTypeVars(Types.scala:2805)
    at scala.reflect.internal.Types$class.thirdTry$1(Types.scala:6030)
    at scala.reflect.internal.Types$class.secondTry$1(Types.scala:5989)
    at scala.reflect.internal.Types$class.firstTry$1(Types.scala:5965)
    at scala.reflect.internal.Types$class.isSubType2(Types.scala:6108)
    at scala.reflect.internal.Types$class.isSubType(Types.scala:5717)
    at scala.reflect.runtime.JavaUniverse.scala$reflect$runtime$SynchronizedTypes$$super$isSubType(JavaUniverse.scala:12)
    at scala.reflect.runtime.SynchronizedTypes$class.isSubType(SynchronizedTypes.scala:60)
    at scala.reflect.runtime.JavaUniverse.isSubType(JavaUniverse.scala:12)
    at scala.reflect.internal.Types$Type.$less$colon$less(Types.scala:837)
    at scala.reflect.internal.Types$Type.$less$colon$less(Types.scala:328)
...

Looks like the following line was left uncommented:

scala.reflect.internal.Types$class.solveOne$1(Types.scala:6377):
        log(s"$tvar setInst $newInst")


Should this be filed as a tickets? Was not sure, just leaving it here.

Eugene Burmako

unread,
Jan 22, 2013, 11:45:57 AM1/22/13
to scala-l...@googlegroups.com
Sorry I've overlooked this one. It's fixed in 2.10.1.

Alexandre Curreli

unread,
Mar 20, 2013, 9:47:27 AM3/20/13
to scala-l...@googlegroups.com
Hello,

So I just downloaded scala-library 2.10.1 and checked the source file.

The log(s"$tvar setInst $newInst") is still there so the library is still spamming in 2.10.1.

Eugene Burmako

unread,
Mar 20, 2013, 9:50:57 AM3/20/13
to scala-l...@googlegroups.com
Yeah unfortunately the PR that fixed this issue along with other didn't make it into 2.10.1 :(


--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alexandre Curreli

unread,
Mar 20, 2013, 9:53:46 AM3/20/13
to scala-l...@googlegroups.com
Is there a way we can easily disable those logs?

Eugene Burmako

unread,
Mar 20, 2013, 11:25:16 AM3/20/13
to scala-l...@googlegroups.com
I don't think you can do anything with the logic there short of silencing the entire stdout or attaching a filter to stdout and weeding out everything, which starts from " [] " (with an obvious risk to lose messages that don't come from reflection).

Another workaround which comes to my mind is that you could probably subclass scala.reflect.runtime.JavaUniverse, override log and then instantiate and use the subclass just as you used scala.reflect.runtime.universe. This would work in isolation, but will break when you'll try to integrate with other reflection-based code though.

Good news is that finally I've submitted a fix to this problem: https://github.com/scala/scala/pull/2283.

Reply all
Reply to author
Forward
0 new messages