|
@@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.internal.RuntimeVirtualFieldSupplier
|
|
import io.opentelemetry.instrumentation.api.util.VirtualField;
|
|
import io.opentelemetry.instrumentation.api.util.VirtualField;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
|
|
+import java.security.PrivilegedAction;
|
|
|
|
|
|
final class RuntimeFieldBasedImplementationSupplier
|
|
final class RuntimeFieldBasedImplementationSupplier
|
|
implements RuntimeVirtualFieldSupplier.VirtualFieldSupplier {
|
|
implements RuntimeVirtualFieldSupplier.VirtualFieldSupplier {
|
|
@@ -18,6 +19,15 @@ final class RuntimeFieldBasedImplementationSupplier
|
|
@Override
|
|
@Override
|
|
public <U extends T, V extends F, T, F> VirtualField<U, V> find(
|
|
public <U extends T, V extends F, T, F> VirtualField<U, V> find(
|
|
Class<T> type, Class<F> fieldType) {
|
|
Class<T> type, Class<F> fieldType) {
|
|
|
|
+ if (System.getSecurityManager() == null) {
|
|
|
|
+ return findInternal(type, fieldType);
|
|
|
|
+ }
|
|
|
|
+ return java.security.AccessController.doPrivileged(
|
|
|
|
+ (PrivilegedAction<VirtualField<U, V>>) () -> findInternal(type, fieldType));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static <U extends T, V extends F, T, F> VirtualField<U, V> findInternal(
|
|
|
|
+ Class<T> type, Class<F> fieldType) {
|
|
try {
|
|
try {
|
|
String virtualFieldImplClassName =
|
|
String virtualFieldImplClassName =
|
|
getVirtualFieldImplementationClassName(type.getTypeName(), fieldType.getTypeName());
|
|
getVirtualFieldImplementationClassName(type.getTypeName(), fieldType.getTypeName());
|