Buggy code:
class LayersFactory { static InstalledIdentity load ( final InstalledImage image , final ProductConfig productConfig , final List < File > moduleRoots , final List < File > bundleRoots ) throws IOException { final String productVersion = productConfig . resolveVersion ( ) ; final String productName = productConfig . getProductName ( ) ; final Identity identity = new LayersFactory . AbstractLazyIdentity ( ) { @ Override public String getName ( ) { return productName ; } @ Override public String getVersion ( ) { return productVersion ; } @ Override public InstalledImage getInstalledImage ( ) { return image ; } } ; final LayersFactory . InstalledConfiguration conf = LayersFactory . createInstalledConfig ( image ) ; final LayersFactory . ProcessedLayers processedLayers = LayersFactory . process ( conf , moduleRoots , bundleRoots ) ; final LayersFactory . InstalledConfiguration config = processedLayers . getConf ( ) ; <START_BUG> final InstalledIdentityImpl installedIdentity = new InstalledIdentityImpl ( identity ) ; <END_BUG> for ( final LayersFactory . LayerPathConfig layer : processedLayers . getLayers ( ) . values ( ) ) { final String name = layer . name ; installedIdentity . putLayer ( name , LayersFactory . createPatchableTarget ( name , layer , config . getLayerMetadataDir ( name ) , image ) ) ; } for ( final LayersFactory . LayerPathConfig addOn : processedLayers . getAddOns ( ) . values ( ) ) { final String name = addOn . name ; installedIdentity . putAddOn ( name , LayersFactory . createPatchableTarget ( name , addOn , config . getAddOnMetadataDir ( name ) , image ) ) ; } return installedIdentity ; } static LayersFactory . ProcessedLayers process ( final LayersFactory . InstalledConfiguration conf , final List < File > moduleRoots , final List < File > bundleRoots ) throws IOException { } static void processRoot ( final File root , final LayersFactory . ProcessedLayers layers , final LayersFactory . LayerPathSetter setter ) throws IOException { } static LayersFactory . AbstractLazyPatchableTarget createPatchableTarget ( final String name , final LayersFactory . LayerPathConfig layer , final File metadata , final InstalledImage image ) throws IOException { } static class LayerPathConfig { File modulePath ; File bundlePath ; final String name ; LayerPathConfig ( String name ) { } } interface LayerPathSetter { boolean setPath ( LayersFactory . LayerPathConfig pending , File root ) { } } static LayersFactory . InstalledConfiguration createInstalledConfig ( final InstalledImage image ) { } static class ProcessedLayers { private final LayersFactory . InstalledConfiguration conf ; private final Map < String , LayersFactory . LayerPathConfig > layers = new LinkedHashMap < String , LayersFactory . LayerPathConfig > ( ) ; private final Map < String , LayersFactory . LayerPathConfig > addOns = new LinkedHashMap < String , LayersFactory . LayerPathConfig > ( ) ; ProcessedLayers ( LayersFactory . InstalledConfiguration conf ) { } LayersFactory . InstalledConfiguration getConf ( ) { } Map < String , LayersFactory . LayerPathConfig > getLayers ( ) { } Map < String , LayersFactory . LayerPathConfig > getAddOns ( ) { } void addLayer ( final String name , final File root , final LayersFactory . LayerPathSetter setter ) { } void addAddOn ( final String name , final File root , LayersFactory . LayerPathSetter setter ) { } } static class InstalledConfiguration { final File metadata ; final InstalledImage installedImage ; final Set < String > installedLayers = new HashSet < String > ( ) ; final Set < String > installedAddOns = new HashSet < String > ( ) ; InstalledConfiguration ( final InstalledImage installedImage ) { } File getLayersMetadataDir ( ) { } File getLayerMetadataDir ( final String name ) { } File getAddOnsMetadataDir ( ) { } File getAddOnMetadataDir ( final String name ) { } Set < String > getInstalledLayers ( ) { } Set < String > getInstalledAddOns ( ) { } } static IllegalStateException processingError ( final String message , final Object ... params ) { } abstract static class AbstractLazyPatchableTarget extends LayerDirectoryStructure implements AddOn , Layer { @ Override public DirectoryStructure getDirectoryStructure ( ) { } @ Override public TargetInfo loadTargetInfo ( ) throws IOException { } } abstract static class AbstractLazyIdentity extends LayerDirectoryStructure . IdentityDirectoryStructure implements Identity { @ Override public DirectoryStructure getDirectoryStructure ( ) { } @ Override public TargetInfo loadTargetInfo ( ) throws IOException { } } }

Fix:
final InstalledIdentityImpl installedIdentity = new InstalledIdentityImpl ( identity , image ) ;