diff --git a/common/src/main/java/io/netty/util/internal/TypeParameterMatcher.java b/common/src/main/java/io/netty/util/internal/TypeParameterMatcher.java index bf7868a164..e3c11dfb14 100644 --- a/common/src/main/java/io/netty/util/internal/TypeParameterMatcher.java +++ b/common/src/main/java/io/netty/util/internal/TypeParameterMatcher.java @@ -100,8 +100,12 @@ public abstract class TypeParameterMatcher { "unknown type parameter '" + typeParamName + "': " + parameterizedSuperclass); } - Type[] actualTypeParams = - ((ParameterizedType) currentClass.getGenericSuperclass()).getActualTypeArguments(); + Type genericSuperType = currentClass.getGenericSuperclass(); + if (!(genericSuperType instanceof ParameterizedType)) { + return Object.class; + } + + Type[] actualTypeParams = ((ParameterizedType) genericSuperType).getActualTypeArguments(); Type actualTypeParam = actualTypeParams[typeParamIndex]; if (actualTypeParam instanceof ParameterizedType) { diff --git a/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java b/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java index f65a761069..abd324c417 100644 --- a/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java +++ b/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java @@ -112,4 +112,10 @@ public class TypeParameterMatcherTest { assertFalse(m.match(new Object())); assertTrue(m.match(new byte[1])); } + + @Test + public void testRawType() throws Exception { + TypeParameterMatcher m = TypeParameterMatcher.find(new U() { }, U.class, "E"); + assertTrue(m.match(new Object())); + } }