Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LANG-1702] Add test in TypeUtilsTest #1151

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,26 @@ public void test_LANG_820() {
assertArrayEquals(expectedArray, TypeUtils.normalizeUpperBounds(typeArray));
}

/** This non-static inner class is parameterized. */
private class MyInnerClass<T> {
}

/** The inner class is used as a return type from a method. */
private <U> MyInnerClass<U> aMethod() {
return null;
}

@Test
public void test_LANG_1702() throws NoSuchMethodException, SecurityException {
final Type type = TypeUtilsTest.class.getDeclaredMethod("aMethod").getGenericReturnType();

// any map will do
final Map<TypeVariable<?>, Type> typeArguments = Collections.emptyMap();

// this fails with a stack overflow
final Type unrolledType = TypeUtils.unrollVariables(typeArguments, type);
}

@Test
public void testContainsTypeVariables() throws Exception {
assertFalse(TypeUtils.containsTypeVariables(Test1.class.getMethod("m0").getGenericReturnType()));
Expand Down