object Main {
def main(args: Array[String]): Unit = {
Thread.setDefaultUncaughtExceptionHandler(new AppUncaughtExceptionHandler)
throw new RuntimeException("bang!")
}
class AppUncaughtExceptionHandler extends Thread.UncaughtExceptionHandler {
def uncaughtException(thread: Thread, cause: Throwable): Unit =
{
println("uncaught")
}
}When compiling an executing on windows, the handler is triggered, however when I build this code on Linux the exception is thrownsetting handler java.lang.RuntimeException: bang! at stuff.Main$.main(Main.scala:36) at stuff.Main.main(Main.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at scala.reflect.internal.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:70) at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31) at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:101) at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:70) at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101) at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22) at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:39) at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:29) at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:39) at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:65) at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87) at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98) at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103) at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
The build processes are different (Windows I'm compiling using Intellij), Linux is build under Gradle. Still, i have looked at the byte code on each and see nothing untoward.
Any pointers as to what might be happening here please?
Thanks
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks for the response.
println(Option(Thread.getDefaultUncaughtExceptionHandler).getOrElse("None"))
println(Option(Thread.currentThread().getUncaughtExceptionHandler).getOrElse("None").toString)
Thread.setDefaultUncaughtExceptionHandler(new AppUncaughtExceptionHandler)
Thread.currentThread().setUncaughtExceptionHandler(new AppUncaughtExceptionHandler)
println(Option(Thread.getDefaultUncaughtExceptionHandler).getOrElse("None"))
println(Option(Thread.currentThread().getUncaughtExceptionHandler).getOrElse("None").toString)
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.