/** * {@inheritDoc} */ public PackageDescription getPackage() { if (type.isArray() || type.isPrimitive()) { return PackageDescription.UNDEFINED; } else { Package aPackage = type.getPackage(); if (aPackage == null) { String name = type.getName(); int index = name.lastIndexOf('.'); return index == -1 ? new PackageDescription.Simple(EMPTY_NAME) : new PackageDescription.Simple(name.substring(0, index)); } else { return new PackageDescription.ForLoadedPackage(aPackage); } } }
/** * Rebases a package. This offers an opportunity to add annotations to the package definition. Packages are defined * by classes named {@code package-info} without any methods or fields but permit annotations. Any field or method * definition will cause an {@link IllegalStateException} to be thrown when the type is created. * * @param aPackage The package that is being rebased. * @param classFileLocator The class file locator to use for locating the package's class file. * @return A type builder for rebasing the given package. */ public DynamicType.Builder<?> rebase(Package aPackage, ClassFileLocator classFileLocator) { return rebase(new PackageDescription.ForLoadedPackage(aPackage), classFileLocator); }