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

io.github.jdcmp.codegen.bridge.GeneratedClassHolder Maven / Gradle / Ivy

There is a newer version: 0.3
Show newest version
package io.github.jdcmp.codegen.bridge;

import io.github.jdcmp.api.documentation.ThreadSafe;
import io.github.jdcmp.codegen.CodegenProvider;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;

/**
 * "Holds" generated classes.
 *
 */
@ThreadSafe
public final class GeneratedClassHolder {

	/**
	 * Returns a privileged Lookup for {@link GeneratedClassHolder}.
	 *
	 * @param caller The caller's Lookup
	 * @return A privileged lookup for {@link GeneratedClassHolder}
	 */
	public static Lookup lookup(Lookup caller) {
		if (CodegenProvider.class != caller.lookupClass()) {
			throw new IllegalArgumentException("Caller is not permitted to retrieve Lookup.");
		}

		return MethodHandles.lookup();
	}

	private GeneratedClassHolder() {
		throw new AssertionError("No instances");
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy