
io.opentelemetry.javaagent.tooling.util.ClassLoaderValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-javaagent-tooling Show documentation
Show all versions of opentelemetry-javaagent-tooling Show documentation
Instrumentation of Java libraries using OpenTelemetry.
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.tooling.util;
import java.util.function.Supplier;
/**
* Associate value with a class loader. Added value will behave as if it was stored in a field in
* the class loader object, meaning that the value can be garbage collected once the class loader is
* garbage collected and referencing the class loader from the value will not prevent garbage
* collector from collecting the class loader.
*/
public final class ClassLoaderValue {
@SuppressWarnings("unchecked")
public T get(ClassLoader classLoader) {
return (T) ClassLoaderMap.get(classLoader, this);
}
public void put(ClassLoader classLoader, T value) {
ClassLoaderMap.put(classLoader, this, value);
}
@SuppressWarnings("unchecked")
public T computeIfAbsent(ClassLoader classLoader, Supplier extends T> value) {
return (T) ClassLoaderMap.computeIfAbsent(classLoader, this, value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy