albertogoffi / toradocu

Toradocu - automated generation of test oracles from Javadoc documentation
Other
42 stars 21 forks source link

NullPointerException for enum (?) #60

Closed bjkeller closed 7 years ago

bjkeller commented 7 years ago

On randoop branch, when run with the enum org.apache.commons.math3.exception.util.LocalizedFormats as the target class, get the following

Exception in thread "main" java.lang.NullPointerException
        at org.toradocu.translator.JavaElementsCollector.collect(JavaElementsCollector.java:48)
        at org.toradocu.translator.Matcher.subjectMatch(Matcher.java:36)
        at org.toradocu.translator.ConditionTranslator.translatePropositions(ConditionTranslator.java:201)
        at org.toradocu.translator.ConditionTranslator.processTag(ConditionTranslator.java:408)
        at org.toradocu.translator.ConditionTranslator.translate(ConditionTranslator.java:37)
        at org.toradocu.Toradocu.main(Toradocu.java:145)

Happens also for: org.apache.commons.math3.ode.sampling.StepNormalizerBounds (also an enum)

albertogoffi commented 7 years ago

The issue was caused by the fact that the first two parameters of an enum constructor are synthetic: they are generated by the compiler to be able to invoke the constructor of the superclass java.lang.Enum. So when the parameters are loaded through reflection, the number of parameters is different from the expected (the number of parameters in the source code).

The commit https://github.com/albertogoffi/toradocu/commit/d7688cf98da88c9229a56a126364f01424799b0b solves the problem, ignoring the first two parameters of an enum constructor loaded with reflection.