All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.qbicc.plugin.initializationcontrol.InitAtRuntimeRegistry Maven / Gradle / Ivy

There is a newer version: 0.77.0
Show newest version
package org.qbicc.plugin.initializationcontrol;

import org.qbicc.context.AttachmentKey;
import org.qbicc.context.CompilationContext;

import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class InitAtRuntimeRegistry {

    private static final AttachmentKey KEY = new AttachmentKey<>();

    private final CompilationContext ctxt;
    private final Set runtimeInitializedClasses = ConcurrentHashMap.newKeySet();

    private InitAtRuntimeRegistry(CompilationContext ctxt) {
        this.ctxt = ctxt;
    }

    public static InitAtRuntimeRegistry get(CompilationContext ctxt) {
        InitAtRuntimeRegistry patcher = ctxt.getAttachment(KEY);
        if (patcher == null) {
            patcher = new InitAtRuntimeRegistry(ctxt);
            InitAtRuntimeRegistry appearing = ctxt.putAttachmentIfAbsent(KEY, patcher);
            if (appearing != null) {
                patcher = appearing;
            }
        }
        return patcher;
    }

    public void addRuntimeInitializedClass(String internalName) {
        runtimeInitializedClasses.add(internalName);
    }

    public boolean isRuntimeInitializedClass(String internalName) {
        return runtimeInitializedClasses.contains(internalName);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy