Code review comment: @franz1981 could pls update the comment as well? `private final Lock 1l = new ReentrantLock();` => `private volatile Lock 1l`. I know it's nitpicking but... ;-)

Code under review:
Collection<Resource> generate(DotName scope) {
        List<BeanInfo> beans = new BeanStream(beanDeployment.getBeans()).withScope(scope).collect();
        ResourceClassOutput classOutput = new ResourceClassOutput(true, generateSources);
        String generatedName = scopeToGeneratedName.get(scope);
        reflectionRegistration.registerMethod(generatedName, MethodDescriptor.INIT);

        ClassCreator contextInstances = ClassCreator.builder().classOutput(classOutput).className(generatedName)
                .interfaces(ContextInstances.class).build();

        
        
        
        
        
        
        Map<String, InstanceAndLock> idToFields = new HashMap<>();
        int fieldIndex = 0;
        for (BeanInfo bean : beans) {
            String beanIdx = "" + fieldIndex++;
            FieldCreator handleField = contextInstances.getFieldCreator(beanIdx, ContextInstanceHandle.class)
                    .setModifiers(ACC_PRIVATE | ACC_VOLATILE);
            FieldCreator lockField = contextInstances.getFieldCreator(beanIdx + "l", Lock.class)
                    .setModifiers(ACC_PRIVATE | ACC_VOLATILE);
            FieldCreator atomicLockField = contextInstances.getFieldCreator("LAZY_" + beanIdx + "L_UPDATER",
                    AtomicReferenceFieldUpdater.class)
                    .setModifiers(ACC_PRIVATE | ACC_FINAL | ACC_STATIC);
            idToFields.put(bean.getIdentifier(),
                    new InstanceAndLock(handleField.getFieldDescriptor(), lockField.getFieldDescriptor(),
                            atomicLockField.getFieldDescriptor()));
        }

        implementStaticConstructor(contextInstances, idToFields);
        Map<String, MethodDescriptor> lazyLocks = implementLazyLocks(contextInstances, idToFields);

        MethodCreator constructor = contextInstances.getMethodCreator(MethodDescriptor.INIT, "V");
        constructor.invokeSpecialMethod(MethodDescriptors.OBJECT_CONSTRUCTOR, constructor.getThis());
        constructor.returnVoid();

        implementComputeIfAbsent(contextInstances, beans, idToFields, lazyLocks);
        implementGetIfPresent(contextInstances, beans, idToFields);
        List<MethodDescriptor> remove = implementRemove(contextInstances, beans, idToFields, lazyLocks);
        implementGetAllPresent(contextInstances, idToFields);
        implementRemoveEach(contextInstances, remove);

        contextInstances.close();

        return classOutput.getResources();
    }


Revised code:
Collection<Resource> generate(DotName scope) {
        List<BeanInfo> beans = new BeanStream(beanDeployment.getBeans()).withScope(scope).collect();
        ResourceClassOutput classOutput = new ResourceClassOutput(true, generateSources);
        String generatedName = scopeToGeneratedName.get(scope);
        reflectionRegistration.registerMethod(generatedName, MethodDescriptor.INIT);

        ClassCreator contextInstances = ClassCreator.builder().classOutput(classOutput).className(generatedName)
                .interfaces(ContextInstances.class).build();

        
        
        
        
        
        
        Map<String, InstanceAndLock> idToFields = new HashMap<>();
        int fieldIndex = 0;
        for (BeanInfo bean : beans) {
            String beanIdx = "" + fieldIndex++;
            FieldCreator handleField = contextInstances.getFieldCreator(beanIdx, ContextInstanceHandle.class)
                    .setModifiers(ACC_PRIVATE | ACC_VOLATILE);
            FieldCreator lockField = contextInstances.getFieldCreator(beanIdx + "l", Lock.class)
                    .setModifiers(ACC_PRIVATE | ACC_VOLATILE);
            FieldCreator atomicLockField = contextInstances.getFieldCreator("LAZY_" + beanIdx + "L_UPDATER",
                    AtomicReferenceFieldUpdater.class)
                    .setModifiers(ACC_PRIVATE | ACC_FINAL | ACC_STATIC);
            idToFields.put(bean.getIdentifier(),
                    new InstanceAndLock(handleField.getFieldDescriptor(), lockField.getFieldDescriptor(),
                            atomicLockField.getFieldDescriptor()));
        }

        implementStaticConstructor(contextInstances, idToFields);
        Map<String, MethodDescriptor> lazyLocks = implementLazyLocks(contextInstances, idToFields);

        MethodCreator constructor = contextInstances.getMethodCreator(MethodDescriptor.INIT, "V");
        constructor.invokeSpecialMethod(MethodDescriptors.OBJECT_CONSTRUCTOR, constructor.getThis());
        constructor.returnVoid();

        implementComputeIfAbsent(contextInstances, beans, idToFields, lazyLocks);
        implementGetIfPresent(contextInstances, beans, idToFields);
        List<MethodDescriptor> remove = implementRemove(contextInstances, beans, idToFields, lazyLocks);
        implementGetAllPresent(contextInstances, idToFields);
        implementRemoveEach(contextInstances, remove);

        contextInstances.close();

        return classOutput.getResources();
    }