EvoSuite / evosuite

EvoSuite - automated generation of JUnit test suites for Java classes
http://www.evosuite.org
GNU Lesser General Public License v3.0
829 stars 340 forks source link

No converter available #403

Open bchenghi opened 2 years ago

bchenghi commented 2 years ago

Context

Tried to generate tests as per usual via the CLI. I have java version 17.0.2, maven 3.8.5 and evosuite 1.2.0. It throws JDKClassResetter error, followed by No Converter Available as shown below.

Steps to Reproduce

  1. Install the above versions of java and maven.
  2. Modify pom.xml maven compiler source and target to 17
  3. Follow steps in evosuite's tutorial (i.e. Tutorial_Stack) except install 1.2.0 for evosuite.

EvoSuite Arguments

java -jar evosuite/evosuite-1.2.0.jar -class tutorial.Stack -projectCP target/classes

Current Result

* Going to generate test cases for class: tutorial.Stack
* Starting Client-0
[MASTER] 10:49:48.712 [logback-2] ERROR JDKClassResetter - Failed to handle 'identitymap': java.lang.reflect.InaccessibleObjectException: Unable to make field private static java.util.HashMap java.awt.RenderingHints$Key.identitymap accessible: module java.desktop does not "opens java.awt" to unnamed module @401e7803
* Connecting to master process on port 7758
* Analyzing classpath:
* Error while initializing target class: No converter available
---- Debugging information ----
message             : No converter available
type                : org.jgrapht.util.ArrayUnenforcedSet
converter           : com.thoughtworks.xstream.converters.reflection.SerializableConverter
message[1]          : Unable to make private void java.util.ArrayList.readObject(java.io.ObjectInputStream) throws java.io.IOException,java.lang.ClassNotFoundException accessible: module java.base does not "opens java.util" to unnamed module @401e7803
converter[1]        : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
message[2]          : Unable to make field protected transient int java.util.AbstractList.modCount accessible: module java.base does not "opens java.util" to unnamed module @401e7803
class               : org.jgrapht.graph.AbstractBaseGraph$DirectedEdgeContainer
required-type       : org.jgrapht.graph.AbstractBaseGraph$DirectedEdgeContainer
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /org.evosuite.setup.InheritanceTree/inheritanceGraph/specifics/vertexMapDirected/entry/org.jgrapht.graph.AbstractBaseGraph$DirectedEdgeContainer/incoming
line number         : 145887
class[1]            : java.util.LinkedHashMap
required-type[1]    : java.util.LinkedHashMap
converter-type[1]   : com.thoughtworks.xstream.converters.collections.MapConverter
class[2]            : org.jgrapht.graph.AbstractBaseGraph$DirectedSpecifics
required-type[2]    : org.jgrapht.graph.AbstractBaseGraph$DirectedSpecifics
class[3]            : org.jgrapht.graph.DirectedMultigraph
required-type[3]    : org.jgrapht.graph.DirectedMultigraph
class[4]            : org.evosuite.setup.InheritanceTree
required-type[4]    : org.evosuite.setup.InheritanceTree
version             : 1.2.0
-------------------------------
[MASTER] 10:49:49.725 [logback-2] ERROR TestSuiteGenerator - Problem for tutorial.Stack. Full stack:
com.thoughtworks.xstream.converters.ConversionException: No converter available
---- Debugging information ----
message             : No converter available
type                : org.jgrapht.util.ArrayUnenforcedSet
converter           : com.thoughtworks.xstream.converters.reflection.SerializableConverter
message[1]          : Unable to make private void java.util.ArrayList.readObject(java.io.ObjectInputStream) throws java.io.IOException,java.lang.ClassNotFoundException accessible: module java.base does not "opens java.util" to unnamed module @401e7803
converter[1]        : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
message[2]          : Unable to make field protected transient int java.util.AbstractList.modCount accessible: module java.base does not "opens java.util" to unnamed module @401e7803
class               : org.jgrapht.graph.AbstractBaseGraph$DirectedEdgeContainer
required-type       : org.jgrapht.graph.AbstractBaseGraph$DirectedEdgeContainer
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /org.evosuite.setup.InheritanceTree/inheritanceGraph/specifics/vertexMapDirected/entry/org.jgrapht.graph.AbstractBaseGraph$DirectedEdgeContainer/incoming
line number         : 145887
class[1]            : java.util.LinkedHashMap
required-type[1]    : java.util.LinkedHashMap
converter-type[1]   : com.thoughtworks.xstream.converters.collections.MapConverter
class[2]            : org.jgrapht.graph.AbstractBaseGraph$DirectedSpecifics
required-type[2]    : org.jgrapht.graph.AbstractBaseGraph$DirectedSpecifics
class[3]            : org.jgrapht.graph.DirectedMultigraph
required-type[3]    : org.jgrapht.graph.DirectedMultigraph
class[4]            : org.evosuite.setup.InheritanceTree
required-type[4]    : org.evosuite.setup.InheritanceTree
version             : 1.2.0
-------------------------------
        at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:88)
        at com.thoughtworks.xstream.XStream$1.lookupConverterForType(XStream.java:472)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:56)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:132)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:117)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readCompleteItem(AbstractCollectionConverter.java:147)
        at com.thoughtworks.xstream.converters.collections.MapConverter.putCurrentEntryIntoMap(MapConverter.java:106)
        at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:98)
        at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:92)
        at com.thoughtworks.xstream.converters.collections.MapConverter.unmarshal(MapConverter.java:87)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1391)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1376)
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1270)
        at org.evosuite.setup.InheritanceTreeGenerator.readJDKData(InheritanceTreeGenerator.java:452)
        at org.evosuite.setup.InheritanceTreeGenerator.createFromClassPath(InheritanceTreeGenerator.java:79)
        at org.evosuite.setup.DependencyAnalysis.initInheritanceTree(DependencyAnalysis.java:75)
        at org.evosuite.TestSuiteGenerator.initializeTargetClass(TestSuiteGenerator.java:93)
        at org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:135)
        at org.evosuite.rmi.service.ClientNodeImpl.lambda$startNewSearch$0(ClientNodeImpl.java:140)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
* Computation finished
[MASTER] 10:49:52.221 [main] ERROR SearchStatistics - No statistics has been saved because EvoSuite failed to generate any test case
[MASTER] 10:49:52.322 [main] ERROR TestGeneration - failed to write statistics data

Expected result

Expected test cases to be generated.

abhishekahuja35 commented 1 year ago

I am also facing the same issue. Were you able to solve the issue? If yes, how? The information might be helpful for me; thank you.

lacinoire commented 1 year ago

Hey 🙂

I got around this issue by adding --add-opens to my java options. Found this here: https://github.com/x-stream/xstream/issues/262#issuecomment-1247342505 and here: https://issues.sonatype.org/browse/NEXUS-27902

What needs to be added can be read from the line containing the ERROR JDKClassResetter in the output of EvoSuite.

v1d3rm3 commented 1 year ago

Hey 🙂

I got around this issue by adding --add-opens to my java options. Found this here: x-stream/xstream#262 (comment) and here: https://issues.sonatype.org/browse/NEXUS-27902

What needs to be added can be read from the line containing the ERROR JDKClassResetter in the output of EvoSuite.

What exactly command did you use? I'm getting same error, i tried to use add-opens, but no success.