Hello.
Java 9 introduced the VarHandle infrastructure that allows atomic and plain
access to fields and array elements. To initialize a VarHandle, one must
perform the following "dance" every time:
*class* A {
*int* field;
*static final* VarHandle FIELD;
*static* {
*try* {
FIELD = MethodHandles.lookup().findVarHandle(A.*class*, "field",
Integer.TYPE);
} *catch* (Throwable ex) {
*throw new* InternalError(ex);
}
}
}
When covering such classes, the problem is that the catch will never get
executed because findVarHandle can't fail (if coded properly). Factoring
out MethodHandles.lookup().findVarHandle into some common method doesn't
work most of the time because of runtime access checks regarding the target
class and field (usually would require to make everything public).
Is there a way to exclude such impossible paths from the coverage
statistics or do I have to live with such uncoverable code paths (i.e.,
similar to some synchronized and finally blocks that can never fail)?
--
You received this message because you are subscribed to the Google Groups
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/a3f07905-a4ec-4614-a771-26078c3ef0be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.