From 8212aaf3bbc5b81daa06aea9627a6f0fa6ef7312 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 14 May 2020 00:22:58 +0200 Subject: [PATCH] ResolvableType ignores TypeNotPresentException from generic signature Closes gh-25064 --- .../springframework/core/ResolvableType.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index 162f152802..ae6fe4f084 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -464,15 +464,25 @@ public class ResolvableType implements Serializable { */ public ResolvableType getSuperType() { Class resolved = resolve(); - if (resolved == null || resolved.getGenericSuperclass() == null) { + if (resolved == null) { return NONE; } - ResolvableType superType = this.superType; - if (superType == null) { - superType = forType(resolved.getGenericSuperclass(), this); - this.superType = superType; + try { + Type superclass = resolved.getGenericSuperclass(); + if (superclass == null) { + return NONE; + } + ResolvableType superType = this.superType; + if (superType == null) { + superType = forType(superclass, this); + this.superType = superType; + } + return superType; + } + catch (TypeNotPresentException ex) { + // Ignore non-present types in generic signature + return NONE; } - return superType; } /** @@ -544,13 +554,18 @@ public class ResolvableType implements Serializable { } Class resolved = resolve(); if (resolved != null) { - for (Type genericInterface : resolved.getGenericInterfaces()) { - if (genericInterface instanceof Class) { - if (forClass((Class) genericInterface).hasGenerics()) { - return true; + try { + for (Type genericInterface : resolved.getGenericInterfaces()) { + if (genericInterface instanceof Class) { + if (forClass((Class) genericInterface).hasGenerics()) { + return true; + } } } } + catch (TypeNotPresentException ex) { + // Ignore non-present types in generic signature + } return getSuperType().hasUnresolvableGenerics(); } return false;