Description
Overview
TestClassPredicatesTests.StandaloneTestClasses.recursiveHierarchies()
currently passes when run with the Gradle build or in IntelliJ IDEA; however, it fails in Eclipse IDE.
Specifically, the assertion on the first line of that test method does not throw an exception in Eclipse.
The reason is twofold:
ReflectionUtils.visitNestedClasses(...)
short-circuits the search algorithm once a@Nested
test class has been detected.- The order in which nested classes are returned from
java.lang.Class.getDeclaredClasses()
apparently differs between the OpenJDK/IntelliJ compilers and the Eclipse compiler.
The result is that ReflectionUtils.detectInnerClassCycle()
only gets invoked on nested classes until the first @Nested
class is encountered (or until there are no more nested classes to inspect).
Thus, if a @Nested
class is detected before a nested class with a class hierarchy cycle, the cycle is not detected/reported.
In Eclipse, if you rename TestClassPredicatesTests.TestCases.OuterClass.InnerClass
to TestClassPredicatesTests.TestCases.OuterClass.XXXInnerClass
, the test then passes because TestClassPredicatesTests.TestCases.OuterClass.RecursiveInnerClass
is encountered first, resulting in the expected JUnitException
stating that it "detected [a] cycle in [the] inner class hierarchy".