Hi,
While working on fixing a few things in the ByteBuddy enhancer for Hibernate ORM, we noticed an issue with classes in the default package: we know it's a corner case but we are supporting it.
The issue lies in the inconsistency between:
- The
InstrumentedType.Default getPackage() method:
@Override
public PackageDescription getPackage() {
int packageIndex = name.lastIndexOf('.');
return packageIndex == -1
? PackageDescription.UNDEFINED
: new PackageDescription.Simple(name.substring(0, packageIndex));
}
which returns PackageDescription.UNDEFINED thus null for an empty package name
- And the
TypeDescription.ForLoadedType getPackage() method:
@Override
public PackageDescription getPackage() {
Package aPackage = type.getPackage();
return (aPackage == null)
? PackageDescription.UNDEFINED
: new PackageDescription.ForLoadedPackage(aPackage);
}
which returns a package with an empty name in the case of the default package.
I don't know if you meant UNDEFINED as being the default package but in any case both methods should be consistent.
Our issue is that at some point TypeDescription.isSamePackage(TypeDescription) fails because one is of the former type and the other from the latter and comparing the packages returns false.
Hi,
While working on fixing a few things in the ByteBuddy enhancer for Hibernate ORM, we noticed an issue with classes in the default package: we know it's a corner case but we are supporting it.
The issue lies in the inconsistency between:
InstrumentedType.DefaultgetPackage()method:which returns
PackageDescription.UNDEFINEDthus null for an empty package nameTypeDescription.ForLoadedTypegetPackage()method:which returns a package with an empty name in the case of the default package.
I don't know if you meant
UNDEFINEDas being the default package but in any case both methods should be consistent.Our issue is that at some point
TypeDescription.isSamePackage(TypeDescription)fails because one is of the former type and the other from the latter and comparing the packages returns false.