Skip to content
15 changes: 7 additions & 8 deletions testng-core/src/main/java/org/testng/internal/ClassImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}

@Override
public long[] getInstanceHashCodes() {

Check warning on line 80 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / OpenRewrite

[deprecation] getInstanceHashCodes() in IClass has been deprecated

Check warning on line 80 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / 17, zulu, same hashcode, ubuntu, Pacific/Chatham, fr_FR

[deprecation] getInstanceHashCodes() in IClass has been deprecated

Check warning on line 80 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / 28, oracle, ubuntu, Pacific/Chatham, ru_RU, stress JIT

[deprecation] getInstanceHashCodes() in IClass has been deprecated
return m_instanceHashCodes;
}

Expand Down Expand Up @@ -114,12 +114,12 @@
}

@Override
public Object[] getInstances(boolean create) {

Check warning on line 117 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / OpenRewrite

[deprecation] getInstances(boolean) in IClass has been deprecated

Check warning on line 117 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / 17, zulu, same hashcode, ubuntu, Pacific/Chatham, fr_FR

[deprecation] getInstances(boolean) in IClass has been deprecated

Check warning on line 117 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / 28, oracle, ubuntu, Pacific/Chatham, ru_RU, stress JIT

[deprecation] getInstances(boolean) in IClass has been deprecated
return getInstances(create, "");
}

@Override
public Object[] getInstances(boolean create, String errorMsgPrefix) {

Check warning on line 122 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / OpenRewrite

[deprecation] getInstances(boolean,String) in IClass has been deprecated

Check warning on line 122 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / 17, zulu, same hashcode, ubuntu, Pacific/Chatham, fr_FR

[deprecation] getInstances(boolean,String) in IClass has been deprecated

Check warning on line 122 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / 28, oracle, ubuntu, Pacific/Chatham, ru_RU, stress JIT

[deprecation] getInstances(boolean,String) in IClass has been deprecated
return Arrays.stream(getObjects(create, errorMsgPrefix))
.map(IdentifiableObject::getInstance)
.toArray(Object[]::new);
Expand Down Expand Up @@ -157,7 +157,7 @@
}

@Override
public void addInstance(Object instance) {

Check warning on line 160 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / OpenRewrite

[deprecation] addInstance(Object) in IClass has been deprecated

Check warning on line 160 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / 17, zulu, same hashcode, ubuntu, Pacific/Chatham, fr_FR

[deprecation] addInstance(Object) in IClass has been deprecated

Check warning on line 160 in testng-core/src/main/java/org/testng/internal/ClassImpl.java

View workflow job for this annotation

GitHub Actions / 28, oracle, ubuntu, Pacific/Chatham, ru_RU, stress JIT

[deprecation] addInstance(Object) in IClass has been deprecated
addObject(new IdentifiableObject(instance));
}

Expand All @@ -173,13 +173,12 @@
}

private DetailedAttributes newDetailedAttributes(boolean create, String errMsgPrefix) {
DetailedAttributes ea = new DetailedAttributes();
ea.setXmlTest(m_testContext.getCurrentXmlTest());
ea.setClasses(m_classes);
ea.setFinder(m_annotationFinder);
ea.setDeclaringClass(m_class);
ea.setErrorMsgPrefix(errMsgPrefix);
ea.setCreate(create);
return ea;
return new DetailedAttributes(
m_class,
m_classes,
m_testContext.getCurrentXmlTest(),
m_annotationFinder,
create,
errMsgPrefix);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.testng.internal.collections;

import org.jspecify.annotations.Nullable;
import org.testng.collections.Objects;

public class Pair<A, B> {
Expand Down Expand Up @@ -28,7 +29,7 @@ public int hashCode() {
}

@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Iterator;
import org.jspecify.annotations.Nullable;
import org.testng.internal.Utils;

/**
Expand All @@ -18,15 +19,15 @@
public class ResourceAwareIterator<T> implements CloseableIterator<T> {

private final Iterator<T> delegate;
private final AutoCloseable resource;
private final @Nullable AutoCloseable resource;
private boolean closed;

/**
* @param delegate the iterator that actually produces the elements.
* @param resource the resource to release on {@link #close()}, or {@code null} if there is
* nothing to release.
*/
public ResourceAwareIterator(Iterator<T> delegate, AutoCloseable resource) {
public ResourceAwareIterator(Iterator<T> delegate, @Nullable AutoCloseable resource) {
this.delegate = delegate;
this.resource = resource;
}
Expand All @@ -43,7 +44,7 @@ public ResourceAwareIterator(Iterator<T> delegate, AutoCloseable resource) {
* iterator was derived from), or {@code null} if there is nothing to release.
*/
public static CloseableIterator<Object[]> forDataProvider(
Iterator<Object> iterator, Type returnType, AutoCloseable resource) {
Iterator<Object> iterator, Type returnType, @Nullable AutoCloseable resource) {
return new ResourceAwareIterator<>(toObjectArrayIterator(iterator, returnType), resource);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** Iterators and small containers used to shape data provider rows and internal state. */
@NullMarked
package org.testng.internal.collections;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** Suite-level state the invokers carry forward, detached from the XML model it came from. */
@NullMarked
package org.testng.internal.invokers.objects;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package org.testng.internal.objects.pojo;

import org.jspecify.annotations.Nullable;
import org.testng.IClass;

/** Represents the basic attributes associated with object creation. */
public class BasicAttributes {

private final IClass iClass;
private final Class<?> clazz;
private final @Nullable IClass iClass;
private final @Nullable Class<?> clazz;

public BasicAttributes(IClass iClass, Class<?> clazz) {
public BasicAttributes(@Nullable IClass iClass, @Nullable Class<?> clazz) {
this.iClass = iClass;
this.clazz = clazz;
}

/** @return - The actual {@link Class} */
public Class<?> getRawClass() {
public @Nullable Class<?> getRawClass() {
return clazz;
}

/** @return - The wrapped {@link IClass} that represents a TestNG test class. */
public IClass getTestClass() {
public @Nullable IClass getTestClass() {
return iClass;
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package org.testng.internal.objects.pojo;

import org.jspecify.annotations.Nullable;
import org.testng.ITestContext;
import org.testng.internal.invokers.objects.GuiceContext;

/** Represents the parameters that are associated with object creation. */
public class CreationAttributes {

private final BasicAttributes basic;
private final DetailedAttributes detailed;
private final ITestContext context;
private final GuiceContext suiteContext;
private final @Nullable DetailedAttributes detailed;
private final @Nullable ITestContext context;
private final @Nullable GuiceContext suiteContext;

public CreationAttributes(ITestContext ctx, BasicAttributes basic, DetailedAttributes detailed) {
public CreationAttributes(
ITestContext ctx, BasicAttributes basic, @Nullable DetailedAttributes detailed) {
this.basic = basic;
this.detailed = detailed;
this.context = ctx;
Expand All @@ -25,19 +27,19 @@ public CreationAttributes(BasicAttributes basic, GuiceContext suiteContext) {
this.suiteContext = suiteContext;
}

public DetailedAttributes getDetailedAttributes() {
public @Nullable DetailedAttributes getDetailedAttributes() {
return detailed;
}

public BasicAttributes getBasicAttributes() {
return basic;
}

public ITestContext getContext() {
public @Nullable ITestContext getContext() {
return context;
}

public GuiceContext getSuiteContext() {
public @Nullable GuiceContext getSuiteContext() {
return suiteContext;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,49 @@
/** Represents the elaborate set of attributes required for object creation. */
public class DetailedAttributes {

private Class<?> declaringClass;
private Map<Class<?>, IClass> classes;
private XmlTest xmlTest;
private IAnnotationFinder finder;
private boolean create;
private String errorMsgPrefix;
private final Class<?> declaringClass;
private final Map<Class<?>, IClass> classes;
private final XmlTest xmlTest;
private final IAnnotationFinder finder;
private final boolean create;
private final String errorMsgPrefix;

public DetailedAttributes(
Class<?> declaringClass,
Map<Class<?>, IClass> classes,
XmlTest xmlTest,
IAnnotationFinder finder,
boolean create,
String errorMsgPrefix) {
this.declaringClass = declaringClass;
this.classes = classes;
this.xmlTest = xmlTest;
this.finder = finder;
this.create = create;
this.errorMsgPrefix = errorMsgPrefix;
}

public Class<?> getDeclaringClass() {
return declaringClass;
}

public void setDeclaringClass(Class<?> declaringClass) {
this.declaringClass = declaringClass;
}

public Map<Class<?>, IClass> getClasses() {
return classes;
}

public void setClasses(Map<Class<?>, IClass> classes) {
this.classes = classes;
}

public XmlTest getXmlTest() {
return xmlTest;
}

public void setXmlTest(XmlTest xmlTest) {
this.xmlTest = xmlTest;
}

public IAnnotationFinder getFinder() {
return finder;
}

public void setFinder(IAnnotationFinder finder) {
this.finder = finder;
}

public boolean isCreate() {
return create;
}

public void setCreate(boolean create) {
this.create = create;
}

public String getErrorMsgPrefix() {
return errorMsgPrefix;
}

public void setErrorMsgPrefix(String errorMsgPrefix) {
this.errorMsgPrefix = errorMsgPrefix;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** The attribute bundles the object dispensers are handed to create a test instance. */
@NullMarked
package org.testng.internal.objects.pojo;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.jspecify.annotations.Nullable;
import org.testng.IDynamicGraph;
import org.testng.internal.AutoCloseableLock;
import org.testng.internal.RuntimeBehavior;
Expand All @@ -24,7 +25,7 @@ public class GraphOrchestrator<T> {
private final IDynamicGraph<T> graph;
private final Map<T, IWorker<T>> mapping = new ConcurrentHashMap<>();
private final Map<T, T> upstream = new ConcurrentHashMap<>();
private final Comparator<T> comparator;
private final @Nullable Comparator<T> comparator;
private final IThreadWorkerFactory<T> factory;
private final boolean shutdownExecutorOnFinish;
private final CountDownLatch completed = new CountDownLatch(1);
Expand All @@ -35,7 +36,7 @@ public GraphOrchestrator(
ExecutorService service,
IThreadWorkerFactory<T> factory,
IDynamicGraph<T> graph,
Comparator<T> comparator) {
@Nullable Comparator<T> comparator) {
this(service, factory, graph, comparator, true);
}

Expand All @@ -49,7 +50,7 @@ public GraphOrchestrator(
ExecutorService service,
IThreadWorkerFactory<T> factory,
IDynamicGraph<T> graph,
Comparator<T> comparator,
@Nullable Comparator<T> comparator,
boolean shutdownExecutorOnFinish) {
this.service = service;
this.graph = graph;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.testng.internal.thread.graph;

import java.util.List;
import javax.annotation.Nonnull;
import org.testng.thread.IWorker;

class PhoneyWorker<T> implements IWorker<T> {
Expand All @@ -13,7 +12,8 @@ public PhoneyWorker(long threadId) {

@Override
public List<T> getTasks() {
return null;
// A PhoneyWorker stands in for a thread id, never for work: it has no tasks to report.
return List.of();
}

@Override
Expand All @@ -27,7 +27,7 @@ public int getPriority() {
}

@Override
public int compareTo(@Nonnull IWorker<T> o) {
public int compareTo(IWorker<T> o) {
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** Drives a dynamic graph's ready nodes through an executor, worker by worker. */
@NullMarked
package org.testng.internal.thread.graph;

import org.jspecify.annotations.NullMarked;
5 changes: 5 additions & 0 deletions testng-core/src/main/java/org/testng/log/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** The java.util.logging formatter TestNG installs on its own handlers. */
@NullMarked
package org.testng.log;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.testng.reporters.util;

import org.jspecify.annotations.Nullable;
import org.testng.ITestNGMethod;

/**
Expand All @@ -20,7 +21,8 @@ private StackTraceTools() {
* @return topmost position of the test method in the stack, or top of stack if <code>method
* </code> is not in it.
*/
public static int getTestRoot(StackTraceElement[] stack, ITestNGMethod method) {
public static int getTestRoot(
StackTraceElement @Nullable [] stack, @Nullable ITestNGMethod method) {
if (stack == null || method == null) {
return -1;
}
Expand All @@ -41,7 +43,7 @@ public static int getTestRoot(StackTraceElement[] stack, ITestNGMethod method) {
* </code> is not in it.
*/
public static StackTraceElement[] getTestNGInfrastructure(
StackTraceElement[] stack, ITestNGMethod method) {
StackTraceElement @Nullable [] stack, @Nullable ITestNGMethod method) {
if (method == null || stack == null) {
return new StackTraceElement[] {};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** Stack trace slicing for reporters. */
@NullMarked
package org.testng.reporters.util;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** The worker and thread-pool contracts the graph executors are written against. */
@NullMarked
package org.testng.thread;

import org.jspecify.annotations.NullMarked;
Loading
Loading