[JIRA] (HHH-17035) Bytecode enhancement leads to StackOverflowError with specific setup involving different generic parameter names
by Yoann Rodière (JIRA)
Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYmIzMGZhMzEw... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-17035?atlOrigin=eyJpIjoiYmIzMG... ) HHH-17035 ( https://hibernate.atlassian.net/browse/HHH-17035?atlOrigin=eyJpIjoiYmIzMG... ) Bytecode enhancement leads to StackOverflowError with specific setup involving different generic parameter names ( https://hibernate.atlassian.net/browse/HHH-17035?atlOrigin=eyJpIjoiYmIzMG... )
Issue Type: Bug Affects Versions: 6.3.0.CR1, 6.2.7 Assignee: Unassigned Components: hibernate-core Created: 04/Aug/2023 09:41 AM Fix Versions: 6.3.0, 6.2.8 Priority: Major Reporter: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
I noticed this by accident while working on https://hibernate.atlassian.net/browse/HHH-17034. I will send a PR with a reproducer.
May be related to https://hibernate.atlassian.net/browse/HHH-17034 , or may be a problem in how Hibernate ORM uses Bytebuddy, or may simply be a bug in bytebuddy.
The model below triggers a StackOverflowError upon bytecode enhancement:
java.lang.NoClassDefFoundError: org/hibernate/orm/test/bytecode/enhance/internal/bytebuddy/DirtyCheckingWithDifferentGenericParameterNameTest$MyEntity
at org.hibernate.orm.test.bytecode.enhance.internal.bytebuddy.DirtyCheckingWithDifferentGenericParameterNameTest.shouldDeclareMethodsInEntityClass(DirtyCheckingWithDifferentGenericParameterNameTest.java:47)
...
Caused by: java.lang.ClassNotFoundException: org.hibernate.orm.test.bytecode.enhance.internal.bytebuddy.DirtyCheckingWithDifferentGenericParameterNameTest$MyEntity not found
at org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner$EnhancingClassLoader.loadClass(BytecodeEnhancerRunner.java:235)
... 42 more
Caused by: java.lang.StackOverflowError
at java.base/java.util.AbstractList$Itr.next(AbstractList.java:371)
at net.bytebuddy.matcher.FilterableList$AbstractBase.filter(FilterableList.java:124)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findVariable(TypeVariableSource.java:157)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findVariable(TypeVariableSource.java:162)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:172)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
at net.bytebuddy.description.method.MethodDescription$Latent.getReturnType(MethodDescription.java:1478)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toSafeString(MethodDescription.java:1041)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2062)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable.accept(TypeDescription.java:5705)
at net.bytebuddy.description.type.TypeDescription$Generic$LazyProjection.accept(TypeDescription.java:6297)
...
The model:
@MappedSuperclass
public static abstract class MyAbstractEmbeddable {
}
@Embeddable
public static class MyEmbeddable extends MyAbstractEmbeddable {
@Column
private String text;
public MyEmbeddable() {
}
private MyEmbeddable(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
@MappedSuperclass
// The key to reproducing the problem is to use a different name for the generic parameter
// in this class than in the superclass.
// Note that, as in other similar tests, the field of the superclass needs
// to not be visible from the subclass in other to reproduce the problem.
public static abstract class MyLevel2GenericMappedSuperclass<T extends MyAbstractEmbeddable>
extends MyNonVisibleGenericMappedSuperclass<T> {
}
@Entity(name = "myentity")
public static class MyEntity extends MyLevel2GenericMappedSuperclass<MyEmbeddable> {
@Id
private Integer id;
public MyEntity() {
}
private MyEntity(Integer id, String text) {
this.id = id;
setEmbedded( new MyEmbeddable( text ) );
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
// This class must not be nested in the test class, otherwise its private fields will be visible
// from subclasses and we won't reproduce the bug.
@MappedSuperclass
public abstract class MyNonVisibleGenericMappedSuperclass<C> {
@Embedded
private C embedded;
public C getEmbedded() {
return embedded;
}
public void setEmbedded(C embedded) {
this.embedded = embedded;
}
}
( https://hibernate.atlassian.net/browse/HHH-17035#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-17035#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100233- sha1:06f5c37 )
11 months, 1 week