[info] - cope with context bounds *** FAILED ***[info] Unexpected call: contextBound(foo, TypeTag[java.lang.String])[info][info] Expected:[info] inAnyOrder {[info] contextBound(foo, TypeTag[java.lang.String]) once (never called - UNSATISFIED)[info] }[info][info] Actual:[info] contextBound(foo, TypeTag[java.lang.String]) (Option.scala:120)
[info] - cope with context bounds *** FAILED ***[info] java.lang.NullPointerException:[info] at scala.reflect.internal.Types$TypeRef.computeHashCode(Types.scala:2332)[info] at scala.reflect.internal.Types$UniqueType.<init>(Types.scala:1274)[info] at scala.reflect.internal.Types$TypeRef.<init>(Types.scala:2315)[info] at scala.reflect.internal.Types$NoArgsTypeRef.<init>(Types.scala:2107)[info] at scala.reflect.internal.Types$ModuleTypeRef.<init>(Types.scala:2078)[info] at scala.reflect.internal.Types$PackageTypeRef.<init>(Types.scala:2095)[info] at scala.reflect.internal.Types$TypeRef$.apply(Types.scala:2516)[info] at scala.reflect.internal.Types$class.typeRef(Types.scala:3577)[info] at scala.reflect.internal.SymbolTable.typeRef(SymbolTable.scala:13)[info] at scala.reflect.internal.Symbols$TypeSymbol.newTypeRef(Symbols.scala:2754)
>> contextBound(foo, TypeTag[java.lang.String]) once (never called - UNSATISFIED)
What does this imply? Incorrectly generated or absent mock method? Someone forgetting to call the test method?
Also how many times does your type macro run per clean-compile-testall cycle? Maybe you generate multiple mocks, which somehow conflict with each other? Also, since c.freshName is currently broken as described in a nearby thread, maybe you reuse old mocks because of name clashes?
... this is the only test that makes use of TypeTags so it's hard to see how parallelism could be causing the problem.
You raise a very important problem. Indeed, we don't provide any guarantees that calling typetag-enabled methods from different threads is going to end well.
Could you please somehow ask ScalaTest to display more lines in stack traces? Maybe it's possible to log failures? A precise stack trace would be very helpful in determining the whereabouts of the problem.
Where do you think flaming letters would be appropriate? It would be an overkill to put them on every doc page. Maybe just the overview page of the upcoming reflection guide at docs.scala-lang.org would be enough?
my personal experience would lead to me to believe there's a runtime bug that leads to non-deterministic behavior with basic reflection
On 25 Dec 2012, at 22:21, Eugene Burmako <eugene....@epfl.ch> wrote:Where do you think flaming letters would be appropriate? It would be an overkill to put them on every doc page. Maybe just the overview page of the upcoming reflection guide at docs.scala-lang.org would be enough?
That would certainly be a start. But TBH I suspect that this is a banana skin that's bound to catch people out no matter how prominently the message is displayed. It simply never occurred to me that reflection wouldn't be threadsafe, and I doubt that I'll be the only one to make this assumption.
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher
The purpose of SynchronizedXXX is to prevent races, but because of SI-6240 it's not working for symbols. When we fix that bug, the situation will improve.
Worst possible idea to introduce a single global lock for the reflection. Just sayin'
def myMethod[T: ClassManifest] = ???
def myMethod[T: ClassTag] = ???
Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_09).Type in expressions to have them evaluated.Type :help for more information.scala> def myMethod[T: ClassManifest] = ???<console>:7: warning: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag insteaddef myMethod[T: ClassManifest] = ???^myMethod: [T](implicit evidence$1: ClassManifest[T])Nothing
// TODO undeprecated until Scala reflection becomes non-experimental
I assume that this thread safety issue does not exist with manifests? In which case, I think that I'm right in saying that this is thread safe:def myMethod[T: ClassManifest] = ???whereas this is not:
def myMethod[T: ClassTag] = ???
Have I got that right? (Eugene - please correct me if I'm wrong).Unfortunately, the former results in a deprecation warning suggesting that it should be rewritten as the latter:Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_09).Type in expressions to have them evaluated.Type :help for more information.scala> def myMethod[T: ClassManifest] = ???<console>:7: warning: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag insteaddef myMethod[T: ClassManifest] = ???^myMethod: [T](implicit evidence$1: ClassManifest[T])NothingSo we're suggesting that people should rewrite their thread safe code to become unsafe.Oddly, ClassManifest is the only manifest that has this deprecation warning. The other types of manifest have their deprecation warnings commented out with:// TODO undeprecated until Scala reflection becomes non-experimentalIs it just an oversight that ClassManifest is still deprecated? Or is ClassTag not subject to thread safety issues?
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher
On 26 Dec 2012, at 14:39, Eugene Burmako <eugene....@epfl.ch> wrote:
I assume that this thread safety issue does not exist with manifests? In which case, I think that I'm right in saying that this is thread safe:def myMethod[T: ClassManifest] = ???whereas this is not:
def myMethod[T: ClassTag] = ???
Have I got that right? (Eugene - please correct me if I'm wrong).Unfortunately, the former results in a deprecation warning suggesting that it should be rewritten as the latter:Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_09).Type in expressions to have them evaluated.Type :help for more information.scala> def myMethod[T: ClassManifest] = ???<console>:7: warning: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag insteaddef myMethod[T: ClassManifest] = ???^myMethod: [T](implicit evidence$1: ClassManifest[T])NothingSo we're suggesting that people should rewrite their thread safe code to become unsafe.Oddly, ClassManifest is the only manifest that has this deprecation warning. The other types of manifest have their deprecation warnings commented out with:// TODO undeprecated until Scala reflection becomes non-experimentalIs it just an oversight that ClassManifest is still deprecated? Or is ClassTag not subject to thread safety issues?
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher
On 26 Dec 2012, at 14:39, Eugene Burmako <eugene....@epfl.ch> wrote:
ClassTag doesn't have problems with multi-threading, only TypeTags do