NullPointerExceptions (GenICodeCodePhase$Context)

73 views
Skip to first unread message

jayunit1...@gmail.com

unread,
Aug 29, 2014, 12:51:15 PM8/29/14
to scala-code-c...@googlegroups.com
I've managed to get byte code instrumentation working, however, I notice two peculiarities.

1) Several warnings of the form

[WARNING] [warn] [scoverage] Could not instrument [EmptyTree$/null]. No position.

2) A null pointer exception, which breaks the build:

[INFO]   last tree to typer: Literal(Constant(String))
[INFO]               symbol: null
[INFO]    symbol definition: null
[INFO]                  tpe: Class(classOf[java.lang.String])
[INFO]        symbol owners:
[INFO]       context owners: package package -> package random
[INFO]
[INFO] == Enclosing template or block ==
[INFO]
[INFO] Template( // val <local package>: <notype> in package random, tree.tpe=org.apache.spark.util.random.package.type
[INFO]   "java.lang.Object" // parents
[INFO]   ValDef(
[INFO]     private
[INFO]     "_"
[INFO]     <tpt>
[INFO]     <empty>
[INFO]   )
[INFO]   DefDef( // def <init>(): org.apache.spark.util.random.package.type in package random
[INFO]     <method>
[INFO]     "<init>"
[INFO]     []
[INFO]     List(Nil)
[INFO]     <tpt> // tree.tpe=org.apache.spark.util.random.package.type
[INFO]     Block( // tree.tpe=Unit
[INFO]       Apply( // def <init>(): Object in class Object, tree.tpe=Object
[INFO]         `package`.super."<init>" // def <init>(): Object in class Object, tree.tpe=()Object
[INFO]         Nil
[INFO]       )
[INFO]       ()
[INFO]     )
[INFO]   )
[INFO] )
[INFO]
[INFO] == Expanded type of tree ==
[INFO]
[INFO] ConstantType(value = Constant(String))
[INFO]
[INFO] uncaught exception during compilation: java.lang.NullPointerException
[ERROR] error: java.lang.NullPointerException
[INFO]  at scala.tools.nsc.backend.icode.GenICode$ICodePhase$Context.exitScope(GenICode.scala:2001)
[INFO]  at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1067)
[INFO]  at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$6$$anonfun$apply$2.apply(GenICode.scala:418)
[INFO]  at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$6$$anonfun$apply$2.apply(GenICode.scala:416)
[INFO]  at scala.tools.nsc.backend.icode.GenICode$ICodePhase$Context$$anonfun$21.apply(GenICode.scala:2136)
[INFO]  at scala.tools.nsc.backend.icode.GenICode$ICodePhase$Context$$anonfun$21.apply(GenICode.scala:2131)
[INFO]  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
[INFO]  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
[INFO]  at scala.collection.immutable.List.foreach(List.scala:318)
[INFO]  at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)

I've pasted a full trace of a segment of the output here :

https://gist.github.com/jayunit100/9531dce4d95b94286597

Any thoguhts would be appreciated. 

SCoverage looks very cool ! Cant wait to get it working.

jayunit1...@gmail.com

unread,
Aug 29, 2014, 9:48:12 PM8/29/14
to scala-code-c...@googlegroups.com, jayunit1...@gmail.com
update:  The failures seem to be happening in a package of meta data files

"package.scala"
"package-info.java"
...

And in particular, the error message above seems to indicate that placeholder / metadata files are tripping up the modified scoverage compiler engine somehow.

Is that possible ?

Any hints would be great ! I think however I am getting a little closer



jay vyas

unread,
Aug 29, 2014, 10:00:12 PM8/29/14
to scala-code-c...@googlegroups.com
PROGRESS !

Ive foud that some classes, like the metatdata ones, and some methods, like certain types of provate generic methods, can trip up scoverage.  So, you will want to EXCLUDE them when running SCoverage.
--
jay vyas

jayunit1...@gmail.com

unread,
Aug 30, 2014, 2:43:23 PM8/30/14
to scala-code-c...@googlegroups.com, jayunit1...@gmail.com
More color on this:  The logs above actually show alot of detail about classes which arent actually causing the problem, i think.
Instead, if you look up in the logs, you can see the exact class causing the NPE, and then you can use the excludePackages directive
or the // $COVERAGE-OFF$ directive in your code to exclude the occasional class which trips scoverage up.

Stephen Samuel

unread,
Sep 4, 2014, 3:41:16 PM9/4/14
to scala-code-c...@googlegroups.com, jayunit1...@gmail.com
Can you give me an example of such a method.
Reply all
Reply to author
Forward
0 new messages