-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix
getAllInvolvedRawTypes()
recursing infinitely
For recursive type parameter definitions like `class Example<T extends Comparable<T>>` the method `JavaClass.getAllInvolvedRawTypes()` causes a `StackOverflowError` at the moment. This is because we have a simple recursion without any short circuit condition if we encounter a type we've already seen before. We can utilize `JavaType.traverseSignature(..)` to solve this, because there the problem is already solved in the visitor pattern implementation. Signed-off-by: Peter Gafert <peter.gafert@archunit.org>
- Loading branch information
1 parent
088d00c
commit f002cbb
Showing
9 changed files
with
55 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
archunit/src/test/java/com/tngtech/archunit/core/domain/JavaGenericArrayTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.tngtech.archunit.core.domain; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
import com.tngtech.archunit.core.importer.ClassFileImporter; | ||
import org.junit.Test; | ||
|
||
import static com.tngtech.archunit.testutil.Assertions.assertThatTypes; | ||
|
||
public class JavaGenericArrayTypeTest { | ||
|
||
@Test | ||
public void all_involved_raw_types_of_generic_array() { | ||
class SampleClass<T extends String & List<Serializable>> { | ||
@SuppressWarnings("unused") | ||
private T[][] field; | ||
} | ||
|
||
JavaGenericArrayType typeVariable = (JavaGenericArrayType) new ClassFileImporter().importClass(SampleClass.class).getField("field").getType(); | ||
|
||
assertThatTypes(typeVariable.getAllInvolvedRawTypes()).matchInAnyOrder(String.class, List.class, Serializable.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters