Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ParametersAreNonnullByDefault
package datadog.instrument.classinject;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package datadog.instrument.classmatch;

import javax.annotation.Nullable;

/** Minimal class header that describes its access modifiers and immediate class hierarchy. */
public class ClassHeader {

Expand All @@ -20,13 +22,13 @@ public class ClassHeader {
/** Internal name of this class. */
public final String className;

/** Internal name of the super-class declared by this class. */
public final String superName;
/** Internal name of the super-class declared by this class; {@code null} for modules. */
@Nullable public final String superName;

/** Internal names of the interfaces declared by this class. */
public final String[] interfaces;

ClassHeader(int access, String className, String superName, String[] interfaces) {
ClassHeader(int access, String className, @Nullable String superName, String[] interfaces) {
this.access = access;
this.className = className;
this.superName = superName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package datadog.instrument.classmatch;

import javax.annotation.Nullable;

/** Outlines a class; access modifiers, immediate class hierarchy, field, methods, annotations. */
public final class ClassOutline extends ClassHeader {

Expand All @@ -21,7 +23,7 @@ public final class ClassOutline extends ClassHeader {
ClassOutline(
int access,
String className,
String superName,
@Nullable String superName,
String[] interfaces,
FieldOutline[] fields,
MethodOutline[] methods,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ParametersAreNonnullByDefault
package datadog.instrument.classmatch;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2025-Present Datadog, Inc.
*/

package datadog.instrument.fieldinject;

import static datadog.instrument.fieldinject.ObjectStoreIds.objectStoreId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2025-Present Datadog, Inc.
*/

package datadog.instrument.fieldinject;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import static datadog.instrument.utils.ClassLoaderKey.SYSTEM_CLASS_LOADER;
import static datadog.instrument.utils.ClassLoaderKey.SYSTEM_CLASS_LOADER_KEY_ID;

import javax.annotation.Nullable;

/**
* Semi-stable index of known {@link ClassLoader}s that guarantees a unique key-id for different
* class-loaders. A class-loader may have more than one key-id over its life if it is temporarily
Expand All @@ -36,7 +38,7 @@ private ClassLoaderIndex() {}
* @param cl the class-loader to index
* @return key-id for the class-loader
*/
public static int getClassLoaderKeyId(ClassLoader cl) {
public static int getClassLoaderKeyId(@Nullable ClassLoader cl) {
if (cl == BOOT_CLASS_LOADER) {
return BOOT_CLASS_LOADER_KEY_ID;
} else if (cl == SYSTEM_CLASS_LOADER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.function.BiConsumer;
import javax.annotation.Nullable;

/**
* Lazily associate a computed value with (potentially) every {@link ClassLoader}. The computed
Expand Down Expand Up @@ -67,7 +68,7 @@ protected ClassLoaderValue() {
* @see #get
* @see #remove
*/
protected abstract V computeValue(ClassLoader cl);
protected abstract V computeValue(@Nullable ClassLoader cl);

/**
* Returns the value for the given class-loader. If no value has yet been computed, it is obtained
Expand All @@ -82,7 +83,7 @@ protected ClassLoaderValue() {
* @see #remove
* @see #computeValue
*/
public final V get(ClassLoader cl) {
public final V get(@Nullable ClassLoader cl) {
if (cl == BOOT_CLASS_LOADER) {
return getBootValue();
} else if (cl == SYSTEM_CLASS_LOADER) {
Expand All @@ -101,7 +102,7 @@ public final V get(ClassLoader cl) {
*
* @param cl the class-loader whose value must be removed
*/
public final void remove(ClassLoader cl) {
public final void remove(@Nullable ClassLoader cl) {
if (cl == BOOT_CLASS_LOADER) {
bootValue = null;
} else if (cl == SYSTEM_CLASS_LOADER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;

/**
* Immutable space-efficient trie that captures a mapping of package/class names to numbers.
Expand Down Expand Up @@ -120,8 +121,8 @@ public final class ClassNameTrie {
/** The compressed trie. */
private final char[] trieData;

/** Long jump offsets. */
private final int[] longJumps;
/** Long jump offsets; {@code null} if there are none. */
@Nullable private final int[] longJumps;

/**
* Returns the number in the trie the given class-name maps to.
Expand Down Expand Up @@ -153,7 +154,7 @@ public int apply(String key, int fromIndex) {
* @param fromIndex the index in the class-name to start matching from
* @return the number the class-name maps to; {@code -1} if not mapped
*/
public static int apply(char[] data, int[] longJumps, String key, int fromIndex) {
public static int apply(char[] data, @Nullable int[] longJumps, String key, int fromIndex) {
int keyLength = key.length();
int keyIndex = fromIndex;
int dataIndex = 0;
Expand Down Expand Up @@ -272,7 +273,7 @@ public static ClassNameTrie readFrom(DataInput in) throws IOException {
return new ClassNameTrie(trieData, longJumps);
}

ClassNameTrie(char[] trieData, int[] longJumps) {
ClassNameTrie(char[] trieData, @Nullable int[] longJumps) {
this.trieData = trieData;
this.longJumps = longJumps;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ParametersAreNonnullByDefault
package datadog.instrument.utils;

import javax.annotation.ParametersAreNonnullByDefault;
Loading