Since a while I got the following Exception, when running my tests in Debugging Mode.
java.lang.NoSuchFieldException: serialPersistentFields
at java.base/java.lang.Class.getDeclaredField(Class.java:2642)
at java.base/java.io.ObjectStreamClass.getDeclaredSerialFields(ObjectStreamClass.java:1634)
at java.base/java.io.ObjectStreamClass.getSerialFields(ObjectStreamClass.java:1608)
at java.base/java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:398)
at java.base/java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:384)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.base/java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:384)
at java.base/java.io.ObjectStreamClass$Caches$1.computeValue(ObjectStreamClass.java:110)
at java.base/java.io.ObjectStreamClass$Caches$1.computeValue(ObjectStreamClass.java:107)
at java.base/java.io.ClassCache$1.computeValue(ClassCache.java:73)
at java.base/java.io.ClassCache$1.computeValue(ClassCache.java:70)
at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
at java.base/java.lang.ClassValue.get(ClassValue.java:116)
at java.base/java.io.ClassCache.get(ClassCache.java:84)
at java.base/java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:363)
at java.base/java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:246)
at org.junit.platform.launcher.TestIdentifier.<clinit>(TestIdentifier.java:51)
at com.intellij.junit5.JUnit5IdeaTestRunner.<clinit>(JUnit5IdeaTestRunner.java:72)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:383)
at java.base/java.lang.Class.forName(Class.java:376)
at com.intellij.rt.junit.JUnitStarter.getAgentClass(JUnitStarter.java:244)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:225)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
I am already, found the following links:
NoSuchFieldException when field exists
I also created a Bug Report at:
https://youtrack.jetbrains.com/issue/IDEA-300566
Even running a simpleTest like:
package com.example.package
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
class SampleTest {
@Test
fun someTest(){
//Arrange
val a = 5
val b = 10
//Act
val res = a b
//Assert
res.shouldBe(15)
}
}
causes the Exception shown above.
Does anyone got this problem alread and found a solution for it. I am not serializing anything. I can't even debug the most simple Test, printing Hello World. I a other project it's still possible. After this exception there are coming a lot more and if I disable the Breakpoints the test is excecuted without problems.
CodePudding user response:
Found out that disabling exception breakpoints fix the problem for the moment. Hope that there will be a better solution than this in the future.
The exceptions seem not to disturb the functionality of the Unit Test, so after all exceptions thrown the Breakpoints inside the code are visited again.