kotlinx-lincheck
kotlinx-lincheck copied to clipboard
Can not use java.util.logging in my data class?
I want to use java.util.logging to print debugging information. But the Lincheck test would fail if I add java logging in my data class.
> linCheck FAILED
java.lang.InternalError: CallerSensitive annotation expected at frame 1
at java.base/jdk.internal.reflect.Reflection.getCallerClass(Native Method)
at org.jetbrains.kotlinx.lincheck.tran$f*rmed.java.util.logging.Logger.getLogger(Logger.java:701)
Unfortunately, I need to see the failing code to help you. I am also not sure that you really want to print debugging information this way, as Lincheck executes your methods hundreds of thousands of times.
M code is here
https://github.com/grpc/grpc-java/blob/0e64316f1d010ff9e547d3fbab4d4788a58bbe8a/servlet/src/main/java/io/grpc/servlet/AsyncServletOutputStreamWriter.java
I've already worked around this issue by abstracting java.util.logging.Logger class into my Log
interface, and test with a noop Log
instance.
https://github.com/grpc/grpc-java/blob/0e64316f1d010ff9e547d3fbab4d4788a58bbe8a/servlet/src/test/java/io/grpc/servlet/AsyncServletOutputStreamWriterConcurrencyTest.java
Then the lincheck worked. However, abstracting Log interface just for lincheck made the data class kind of hacky. I hope lincheck could just load the class successfully and ignore all interleaving with java.util.logging.Logger when addGuarantee()
.
I am also not sure that you really want to print debugging information this way, as Lincheck executes your methods hundreds of thousands of times.
These are FINE or FINEST level logs, so it won't really print anything in the test because the logging level is not at FINE in the test.
@dapengzhang0 you are right, it seems like an option not to transform a class may be useful, especially for such loggers, which don't affect correctness.
Yet, this issue arises only for java.util
classes, so maybe we'll just add a corner case for java.util.logging
in the next release
@alefedor I would suggest adding an option to load the specified classes (specified via regex or so) via the system class loader. We already have an issue with Kover caused by its classes transformation.
@alefedor could you please provide a fix when you have time?
This issue will likely be fixed automatically under #136
Hi, @dapengzhang0! It has taken a while to address the issue, but the recent 2.30 release should've fixed it. Could you please check?
@dapengzhang0, I'm closing this issue, as it should be fixed now. Please reopen it if you are still facing the bug.