HHH-14768 Fix recursive type variable rendering
This commit is contained in:
parent
c1f28b4d09
commit
e528a1ab53
|
@ -6,7 +6,9 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpamodelgen.util;
|
package org.hibernate.jpamodelgen.util;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
import javax.lang.model.element.ElementKind;
|
import javax.lang.model.element.ElementKind;
|
||||||
import javax.lang.model.element.TypeParameterElement;
|
import javax.lang.model.element.TypeParameterElement;
|
||||||
|
@ -30,6 +32,7 @@ import javax.lang.model.util.SimpleTypeVisitor8;
|
||||||
public final class TypeRenderingVisitor extends SimpleTypeVisitor8<Object, Object> {
|
public final class TypeRenderingVisitor extends SimpleTypeVisitor8<Object, Object> {
|
||||||
|
|
||||||
private final StringBuilder sb = new StringBuilder();
|
private final StringBuilder sb = new StringBuilder();
|
||||||
|
private final Set<TypeVariable> visitedTypeVariables = new HashSet<>();
|
||||||
|
|
||||||
private TypeRenderingVisitor() {
|
private TypeRenderingVisitor() {
|
||||||
}
|
}
|
||||||
|
@ -129,9 +132,10 @@ public final class TypeRenderingVisitor extends SimpleTypeVisitor8<Object, Objec
|
||||||
if ( typeVariableElement instanceof TypeParameterElement ) {
|
if ( typeVariableElement instanceof TypeParameterElement ) {
|
||||||
final TypeParameterElement typeParameter = (TypeParameterElement) typeVariableElement;
|
final TypeParameterElement typeParameter = (TypeParameterElement) typeVariableElement;
|
||||||
sb.append( typeParameter );
|
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 " );
|
sb.append( " extends " );
|
||||||
t.getUpperBound().accept( this, null );
|
t.getUpperBound().accept( this, null );
|
||||||
|
visitedTypeVariables.remove( t );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -93,4 +93,11 @@ public class CollectionAsBasicTypeTest extends CompilationTest {
|
||||||
public void testIntersectionType() {
|
public void testIntersectionType() {
|
||||||
assertMetamodelClassGeneratedFor( ConcreteLike.class );
|
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