HHH-14768 Fix recursive type variable rendering
This commit is contained in:
parent
96c96c67ea
commit
d87e8a387f
|
@ -6,7 +6,9 @@
|
|||
*/
|
||||
package org.hibernate.jpamodelgen.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.element.TypeParameterElement;
|
||||
|
@ -30,6 +32,7 @@ import javax.lang.model.util.SimpleTypeVisitor8;
|
|||
public final class TypeRenderingVisitor extends SimpleTypeVisitor8<Object, Object> {
|
||||
|
||||
private final StringBuilder sb = new StringBuilder();
|
||||
private final Set<TypeVariable> visitedTypeVariables = new HashSet<>();
|
||||
|
||||
private TypeRenderingVisitor() {
|
||||
}
|
||||
|
@ -129,9 +132,10 @@ public final class TypeRenderingVisitor extends SimpleTypeVisitor8<Object, Objec
|
|||
if ( typeVariableElement instanceof TypeParameterElement ) {
|
||||
final TypeParameterElement typeParameter = (TypeParameterElement) typeVariableElement;
|
||||
sb.append( typeParameter );
|
||||
if ( !"java.lang.Object".equals( t.getUpperBound().toString() ) ) {
|
||||
if ( !"java.lang.Object".equals( t.getUpperBound().toString() ) && visitedTypeVariables.add( t ) ) {
|
||||
sb.append( " extends " );
|
||||
t.getUpperBound().accept( this, null );
|
||||
visitedTypeVariables.remove( t );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -93,4 +93,11 @@ public class CollectionAsBasicTypeTest extends CompilationTest {
|
|||
public void testIntersectionType() {
|
||||
assertMetamodelClassGeneratedFor( ConcreteLike.class );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-14724")
|
||||
@WithClasses({ EnumHolder.class })
|
||||
public void testRecursiveTypeVariable() {
|
||||
assertMetamodelClassGeneratedFor( EnumHolder.class );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.hibernate.jpamodelgen.test.collectionbasictype;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class EnumHolder {
|
||||
|
||||
public <E extends Enum<E>> E getMyEnum() {
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue