diff --git a/pkl-core/pkl-core.gradle.kts b/pkl-core/pkl-core.gradle.kts index 9ffbe0d2..698444be 100644 --- a/pkl-core/pkl-core.gradle.kts +++ b/pkl-core/pkl-core.gradle.kts @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import net.ltgt.gradle.errorprone.errorprone +import net.ltgt.gradle.nullaway.nullaway import org.apache.tools.ant.filters.ReplaceTokens plugins { @@ -21,6 +23,7 @@ plugins { id("pklJavaLibrary") id("pklPublishLibrary") id("pklNativeLifecycle") + id("pklJSpecify") idea } @@ -57,6 +60,7 @@ dependencies { add("generatorImplementation", libs.javaPoet) add("generatorImplementation", libs.truffleApi) + add("generatorImplementation", libs.jspecify) javaExecutableConfiguration(project(":pkl-cli", "javaExecutable")) } @@ -107,6 +111,18 @@ tasks.processResources { tasks.compileJava { options.generatedSourceOutputDirectory.set(file("generated/truffle")) } +tasks.withType().configureEach { + options.errorprone.nullaway { + // Do not require LateInit fields to be initialized at construction time. + // Unfortunately, IntelliJ doesn't currently understand this, + // and therefore emits many warnings related to LateInit. + excludedFieldAnnotations.add("org.pkl.core.util.LateInit") + + // For now, don't analyze code that deals with Truffle ASTs. + unannotatedSubPackages.addAll("org.pkl.core.ast", "org.pkl.core.stdlib") + } +} + tasks.compileKotlin { enabled = false } tasks.test { diff --git a/pkl-core/src/generator/java/org/pkl/core/generator/MemberRegistryGenerator.java b/pkl-core/src/generator/java/org/pkl/core/generator/MemberRegistryGenerator.java index bb7e5a66..b48db12a 100644 --- a/pkl-core/src/generator/java/org/pkl/core/generator/MemberRegistryGenerator.java +++ b/pkl-core/src/generator/java/org/pkl/core/generator/MemberRegistryGenerator.java @@ -39,6 +39,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; +import org.jspecify.annotations.Nullable; /** * Generates a subclass of {@code org.pkl.core.stdlib.registry.ExternalMemberRegistry} for each @@ -114,6 +115,7 @@ public final class MemberRegistryGenerator extends AbstractProcessor { Comparator.comparing( (TypeElement element) -> { var enclosingElement = element.getEnclosingElement(); + assert enclosingElement != null; return enclosingElement.getKind() == ElementKind.PACKAGE ? "" : enclosingElement.getSimpleName().toString(); @@ -155,6 +157,7 @@ public final class MemberRegistryGenerator extends AbstractProcessor { for (var nodeClass : nodeClasses) { var enclosingClass = nodeClass.getEnclosingElement(); + assert enclosingClass != null; var pklClassName = getAnnotatedPklName(enclosingClass); if (pklClassName == null) { @@ -226,7 +229,7 @@ public final class MemberRegistryGenerator extends AbstractProcessor { writeJavaFile(REGISTRY_PACKAGE_NAME, registryFactoryClass.build()); } - private String getAnnotatedPklName(Element element) { + private @Nullable String getAnnotatedPklName(Element element) { for (var annotation : element.getAnnotationMirrors()) { var annotationName = annotation.getAnnotationType().asElement().getSimpleName().toString(); diff --git a/pkl-core/src/generator/java/org/pkl/core/generator/package-info.java b/pkl-core/src/generator/java/org/pkl/core/generator/package-info.java new file mode 100644 index 00000000..5e551a7c --- /dev/null +++ b/pkl-core/src/generator/java/org/pkl/core/generator/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package org.pkl.core.generator; + +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/Analyzer.java b/pkl-core/src/main/java/org/pkl/core/Analyzer.java index 74518098..dc66ed5c 100644 --- a/pkl-core/src/main/java/org/pkl/core/Analyzer.java +++ b/pkl-core/src/main/java/org/pkl/core/Analyzer.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; import org.graalvm.polyglot.Context; +import org.jspecify.annotations.Nullable; import org.pkl.core.evaluatorSettings.TraceMode; import org.pkl.core.http.HttpClient; import org.pkl.core.http.HttpClientInitException; @@ -36,7 +37,6 @@ import org.pkl.core.runtime.VmContext; import org.pkl.core.runtime.VmException; import org.pkl.core.runtime.VmImportAnalyzer; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; /** Utility library for static analysis of Pkl programs. */ public class Analyzer { diff --git a/pkl-core/src/main/java/org/pkl/core/CommandSpec.java b/pkl-core/src/main/java/org/pkl/core/CommandSpec.java index b66bdc06..8b2b59f4 100644 --- a/pkl-core/src/main/java/org/pkl/core/CommandSpec.java +++ b/pkl-core/src/main/java/org/pkl/core/CommandSpec.java @@ -21,7 +21,7 @@ import java.util.Map; import java.util.Set; import java.util.function.BiFunction; import java.util.function.Function; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** * A specification parsed from a valid {@code pkl:Command} submodule. @@ -144,7 +144,7 @@ public record CommandSpec( @Nullable String helpText, boolean showAsRequired, BiFunction transformEach, - BiFunction, URI, Object> transformAll, + BiFunction, URI, @Nullable Object> transformAll, @Nullable CompletionCandidates completionCandidates, @Nullable String shortName, String metavar, @@ -227,7 +227,7 @@ public record CommandSpec( String name, @Nullable String helpText, BiFunction transformEach, - BiFunction, URI, Object> transformAll, + BiFunction, URI, @Nullable Object> transformAll, @Nullable CompletionCandidates completionCandidates, boolean repeated) implements Option { @@ -239,7 +239,7 @@ public record CommandSpec( /** A function used to transform command {@link State} as arguments are parsed. */ public interface ApplyFunction { - State apply(Map options, @Nullable State parent); + State apply(Map options, @Nullable State parent); } /** diff --git a/pkl-core/src/main/java/org/pkl/core/Composite.java b/pkl-core/src/main/java/org/pkl/core/Composite.java index 3bd63dbd..e7477ff5 100644 --- a/pkl-core/src/main/java/org/pkl/core/Composite.java +++ b/pkl-core/src/main/java/org/pkl/core/Composite.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package org.pkl.core; import java.util.Map; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** A container of properties. */ public interface Composite extends Value { diff --git a/pkl-core/src/main/java/org/pkl/core/DataSize.java b/pkl-core/src/main/java/org/pkl/core/DataSize.java index 2ef2e426..5fcb44db 100644 --- a/pkl-core/src/main/java/org/pkl/core/DataSize.java +++ b/pkl-core/src/main/java/org/pkl/core/DataSize.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ import static org.pkl.core.DataSizeUnit.*; import java.io.Serial; import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.MathUtils; -import org.pkl.core.util.Nullable; /** Java representation of a {@code pkl.base#DataSize} value. */ public final class DataSize implements Value { diff --git a/pkl-core/src/main/java/org/pkl/core/DataSizeUnit.java b/pkl-core/src/main/java/org/pkl/core/DataSizeUnit.java index 877f485a..7b98d8a4 100644 --- a/pkl-core/src/main/java/org/pkl/core/DataSizeUnit.java +++ b/pkl-core/src/main/java/org/pkl/core/DataSizeUnit.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.pkl.core; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** * The unit of a {@link DataSize}. In Pkl, data size units are represented as String {@link diff --git a/pkl-core/src/main/java/org/pkl/core/Duration.java b/pkl-core/src/main/java/org/pkl/core/Duration.java index e16f880a..df38d7ea 100644 --- a/pkl-core/src/main/java/org/pkl/core/Duration.java +++ b/pkl-core/src/main/java/org/pkl/core/Duration.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ import static org.pkl.core.DurationUnit.*; import java.io.Serial; import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.DurationUtils; -import org.pkl.core.util.Nullable; /** Java representation of a {@code pkl.base#Duration} value. */ public final class Duration implements Value { diff --git a/pkl-core/src/main/java/org/pkl/core/DurationUnit.java b/pkl-core/src/main/java/org/pkl/core/DurationUnit.java index f94f8f06..0d13fcfd 100644 --- a/pkl-core/src/main/java/org/pkl/core/DurationUnit.java +++ b/pkl-core/src/main/java/org/pkl/core/DurationUnit.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.pkl.core; import java.time.temporal.ChronoUnit; import java.util.concurrent.TimeUnit; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** * The unit of a {@link Duration}. In Pkl, duration units are represented as String {@link diff --git a/pkl-core/src/main/java/org/pkl/core/EvaluatorBuilder.java b/pkl-core/src/main/java/org/pkl/core/EvaluatorBuilder.java index ed1acb65..b46c444f 100644 --- a/pkl-core/src/main/java/org/pkl/core/EvaluatorBuilder.java +++ b/pkl-core/src/main/java/org/pkl/core/EvaluatorBuilder.java @@ -19,6 +19,7 @@ import com.oracle.truffle.api.TruffleOptions; import java.nio.file.Path; import java.util.*; import java.util.regex.Pattern; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManagers.StandardBuilder; import org.pkl.core.evaluatorSettings.PklEvaluatorSettings.ExternalReader; import org.pkl.core.evaluatorSettings.TraceMode; @@ -33,7 +34,6 @@ import org.pkl.core.resource.ResourceReader; import org.pkl.core.resource.ResourceReaders; import org.pkl.core.runtime.LoggerImpl; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; /** A builder for an {@link Evaluator}. Can be reused to build multiple evaluators. */ @SuppressWarnings({"UnusedReturnValue", "unused"}) @@ -56,7 +56,7 @@ public final class EvaluatorBuilder { private final Map externalProperties = new HashMap<>(); - private @Nullable java.time.Duration timeout; + private java.time.@Nullable Duration timeout; private @Nullable Path moduleCacheDir = IoUtils.getDefaultModuleCacheDir(); @@ -386,7 +386,7 @@ public final class EvaluatorBuilder { /** * Sets an evaluation timeout to be enforced by the {@link Evaluator}'s {@code evaluate} methods. */ - public EvaluatorBuilder setTimeout(@Nullable java.time.Duration timeout) { + public EvaluatorBuilder setTimeout(java.time.@Nullable Duration timeout) { this.timeout = timeout; return this; } diff --git a/pkl-core/src/main/java/org/pkl/core/EvaluatorImpl.java b/pkl-core/src/main/java/org/pkl/core/EvaluatorImpl.java index 70e12b64..7113d4c6 100644 --- a/pkl-core/src/main/java/org/pkl/core/EvaluatorImpl.java +++ b/pkl-core/src/main/java/org/pkl/core/EvaluatorImpl.java @@ -30,6 +30,7 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.graalvm.polyglot.Context; +import org.jspecify.annotations.Nullable; import org.msgpack.core.MessageBufferPacker; import org.msgpack.core.MessagePack; import org.pkl.core.ast.ConstantValueNode; @@ -61,7 +62,6 @@ import org.pkl.core.runtime.VmValue; import org.pkl.core.runtime.VmValueRenderer; import org.pkl.core.util.ErrorMessages; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; public final class EvaluatorImpl implements Evaluator { private final StackFrameTransformer frameTransformer; @@ -307,7 +307,7 @@ public final class EvaluatorImpl implements Evaluator { reservedFlagShortNames, (fileOutput) -> new FileOutputImpl(this, fileOutput)); run.accept(commandRunner.parse(module)); - return null; + return true; // return value is not used; returning null would violate nullness }); } diff --git a/pkl-core/src/main/java/org/pkl/core/Member.java b/pkl-core/src/main/java/org/pkl/core/Member.java index 3e33a799..7452c423 100644 --- a/pkl-core/src/main/java/org/pkl/core/Member.java +++ b/pkl-core/src/main/java/org/pkl/core/Member.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import java.io.Serializable; import java.util.List; import java.util.Objects; import java.util.Set; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** Common base class for TypeAlias, PClass, PClass.Property, and PClass.Method. */ public abstract class Member implements Serializable { diff --git a/pkl-core/src/main/java/org/pkl/core/ModuleSchema.java b/pkl-core/src/main/java/org/pkl/core/ModuleSchema.java index 9072e3e0..7c921524 100644 --- a/pkl-core/src/main/java/org/pkl/core/ModuleSchema.java +++ b/pkl-core/src/main/java/org/pkl/core/ModuleSchema.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ package org.pkl.core; import java.net.URI; import java.util.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; /** Describes the property, method and class members of a module. */ public final class ModuleSchema { diff --git a/pkl-core/src/main/java/org/pkl/core/ModuleSource.java b/pkl-core/src/main/java/org/pkl/core/ModuleSource.java index 4024f8c6..1b4047fb 100644 --- a/pkl-core/src/main/java/org/pkl/core/ModuleSource.java +++ b/pkl-core/src/main/java/org/pkl/core/ModuleSource.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ package org.pkl.core; import java.io.File; import java.net.URI; import java.nio.file.Path; +import org.jspecify.annotations.Nullable; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; /** * A representation for a Pkl module's source URI, and optionally its source text. diff --git a/pkl-core/src/main/java/org/pkl/core/PClass.java b/pkl-core/src/main/java/org/pkl/core/PClass.java index 02a6beac..309f2a58 100644 --- a/pkl-core/src/main/java/org/pkl/core/PClass.java +++ b/pkl-core/src/main/java/org/pkl/core/PClass.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.pkl.core; import java.io.Serial; import java.util.*; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** Java representation of a {@code pkl.base#Class} value. */ public final class PClass extends Member implements Value { diff --git a/pkl-core/src/main/java/org/pkl/core/PClassInfo.java b/pkl-core/src/main/java/org/pkl/core/PClassInfo.java index 562863cd..4ef1420b 100644 --- a/pkl-core/src/main/java/org/pkl/core/PClassInfo.java +++ b/pkl-core/src/main/java/org/pkl/core/PClassInfo.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.io.Serializable; import java.net.URI; import java.util.*; import java.util.regex.Pattern; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** Information about a Pkl class and its Java representation. */ @SuppressWarnings("rawtypes") diff --git a/pkl-core/src/main/java/org/pkl/core/PModule.java b/pkl-core/src/main/java/org/pkl/core/PModule.java index 529a9e90..5836f00a 100644 --- a/pkl-core/src/main/java/org/pkl/core/PModule.java +++ b/pkl-core/src/main/java/org/pkl/core/PModule.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import java.io.Serial; import java.net.URI; import java.util.Map; import java.util.Objects; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** Java representation of a Pkl module. */ public final class PModule extends PObject { diff --git a/pkl-core/src/main/java/org/pkl/core/PObject.java b/pkl-core/src/main/java/org/pkl/core/PObject.java index cceb2f6c..ae0f2fa0 100644 --- a/pkl-core/src/main/java/org/pkl/core/PObject.java +++ b/pkl-core/src/main/java/org/pkl/core/PObject.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.pkl.core; import java.io.Serial; import java.util.Map; import java.util.Objects; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** Java representation of a Pkl object. */ public class PObject implements Composite { diff --git a/pkl-core/src/main/java/org/pkl/core/Pair.java b/pkl-core/src/main/java/org/pkl/core/Pair.java index ef2c9394..d79970d5 100644 --- a/pkl-core/src/main/java/org/pkl/core/Pair.java +++ b/pkl-core/src/main/java/org/pkl/core/Pair.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +18,12 @@ package org.pkl.core; import java.io.Serial; import java.util.Iterator; import java.util.NoSuchElementException; -import org.pkl.core.util.Nullable; +import java.util.Objects; +import org.jspecify.annotations.Nullable; /** Java representation of a {@code pkl.base#Pair} value. */ -public final class Pair implements Value, Iterable { +public final class Pair + implements Value, Iterable<@Nullable Object> { @Serial private static final long serialVersionUID = 0L; private final F first; @@ -44,7 +46,7 @@ public final class Pair implements Value, Iterable { } @Override - public Iterator iterator() { + public Iterator<@Nullable Object> iterator() { return new Iterator<>() { int pos = 0; @@ -54,7 +56,7 @@ public final class Pair implements Value, Iterable { } @Override - public Object next() { + public @Nullable Object next() { return switch (pos++) { case 0 -> first; case 1 -> second; @@ -83,12 +85,12 @@ public final class Pair implements Value, Iterable { public boolean equals(@Nullable Object obj) { if (this == obj) return true; if (!(obj instanceof Pair other)) return false; - return first.equals(other.first) && second.equals(other.second); + return Objects.equals(first, other.first) && Objects.equals(second, other.second); } @Override public int hashCode() { - return first.hashCode() * 31 + second.hashCode(); + return Objects.hashCode(first) * 31 + Objects.hashCode(second); } @Override diff --git a/pkl-core/src/main/java/org/pkl/core/PklException.java b/pkl-core/src/main/java/org/pkl/core/PklException.java index c3918c19..278c1a65 100644 --- a/pkl-core/src/main/java/org/pkl/core/PklException.java +++ b/pkl-core/src/main/java/org/pkl/core/PklException.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,16 +15,18 @@ */ package org.pkl.core; +import org.jspecify.annotations.Nullable; + public class PklException extends RuntimeException { - public PklException(String message, Throwable cause) { + public PklException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } - public PklException(String message) { + public PklException(@Nullable String message) { super(message); } - public PklException(Throwable cause) { + public PklException(@Nullable Throwable cause) { super(cause); } } diff --git a/pkl-core/src/main/java/org/pkl/core/PropertiesRenderer.java b/pkl-core/src/main/java/org/pkl/core/PropertiesRenderer.java index 0227b95d..23fa1fe8 100644 --- a/pkl-core/src/main/java/org/pkl/core/PropertiesRenderer.java +++ b/pkl-core/src/main/java/org/pkl/core/PropertiesRenderer.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.properties.PropertiesUtils; // To instantiate this class, use ValueRenderers.properties(). diff --git a/pkl-core/src/main/java/org/pkl/core/SecurityManager.java b/pkl-core/src/main/java/org/pkl/core/SecurityManager.java index 24b9d077..2f505141 100644 --- a/pkl-core/src/main/java/org/pkl/core/SecurityManager.java +++ b/pkl-core/src/main/java/org/pkl/core/SecurityManager.java @@ -18,7 +18,7 @@ package org.pkl.core; import java.io.IOException; import java.net.URI; import java.nio.file.Path; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** * Enforces a security model during {@link Evaluator evaluation}. diff --git a/pkl-core/src/main/java/org/pkl/core/SecurityManagerBuilder.java b/pkl-core/src/main/java/org/pkl/core/SecurityManagerBuilder.java index 9eb81f52..ee63389d 100644 --- a/pkl-core/src/main/java/org/pkl/core/SecurityManagerBuilder.java +++ b/pkl-core/src/main/java/org/pkl/core/SecurityManagerBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import java.nio.file.Path; import java.util.Collection; import java.util.List; import java.util.regex.Pattern; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** * Parent interface to builder classes for configuring a {@link SecurityManager}. @@ -45,8 +45,7 @@ public interface SecurityManagerBuilder> { B setRootDir(@Nullable Path rootDir); - @Nullable - Path getRootDir(); + @Nullable Path getRootDir(); SecurityManager build(); } diff --git a/pkl-core/src/main/java/org/pkl/core/SecurityManagers.java b/pkl-core/src/main/java/org/pkl/core/SecurityManagers.java index 9ba16614..3f1fbe95 100644 --- a/pkl-core/src/main/java/org/pkl/core/SecurityManagers.java +++ b/pkl-core/src/main/java/org/pkl/core/SecurityManagers.java @@ -23,9 +23,9 @@ import java.nio.file.Path; import java.util.*; import java.util.function.Function; import java.util.regex.Pattern; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.ErrorMessages; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; /** A provider for {@link SecurityManager}s. */ public final class SecurityManagers { @@ -273,7 +273,7 @@ public final class SecurityManagers { private final List allowedResources = new ArrayList<>(); - private Path rootDir; + private @Nullable Path rootDir; private StandardBuilder() {} diff --git a/pkl-core/src/main/java/org/pkl/core/StackFrame.java b/pkl-core/src/main/java/org/pkl/core/StackFrame.java index ac36b7b8..500bd3ad 100644 --- a/pkl-core/src/main/java/org/pkl/core/StackFrame.java +++ b/pkl-core/src/main/java/org/pkl/core/StackFrame.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.pkl.core; import java.util.List; import java.util.Objects; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** An element of a Pkl stack trace. */ // better name would be `StackTraceElement` diff --git a/pkl-core/src/main/java/org/pkl/core/TestResults.java b/pkl-core/src/main/java/org/pkl/core/TestResults.java index 9827fdd8..bafce1ff 100644 --- a/pkl-core/src/main/java/org/pkl/core/TestResults.java +++ b/pkl-core/src/main/java/org/pkl/core/TestResults.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.pkl.core; import java.util.ArrayList; import java.util.List; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** * The results of testing a Pkl test module. @@ -301,7 +301,7 @@ public record TestResults( * @param message The message of the underlying exception. * @param exception The exception thrown by Pkl */ - public record Error(String message, PklException exception) {} + public record Error(@Nullable String message, PklException exception) {} /** * Indicates that an assertion failed. diff --git a/pkl-core/src/main/java/org/pkl/core/TypeAlias.java b/pkl-core/src/main/java/org/pkl/core/TypeAlias.java index 70d25398..07653cc7 100644 --- a/pkl-core/src/main/java/org/pkl/core/TypeAlias.java +++ b/pkl-core/src/main/java/org/pkl/core/TypeAlias.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ package org.pkl.core; import java.io.Serial; import java.util.List; import java.util.Set; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; /** Java representation of a {@code pkl.base#TypeAlias} value. */ public final class TypeAlias extends Member implements Value { diff --git a/pkl-core/src/main/java/org/pkl/core/ValueVisitor.java b/pkl-core/src/main/java/org/pkl/core/ValueVisitor.java index 9402bdf9..90d98af7 100644 --- a/pkl-core/src/main/java/org/pkl/core/ValueVisitor.java +++ b/pkl-core/src/main/java/org/pkl/core/ValueVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** Visitor for data models generated by [Evaluator]. */ public interface ValueVisitor { diff --git a/pkl-core/src/main/java/org/pkl/core/Version.java b/pkl-core/src/main/java/org/pkl/core/Version.java index 39c4d7d4..d5b06770 100644 --- a/pkl-core/src/main/java/org/pkl/core/Version.java +++ b/pkl-core/src/main/java/org/pkl/core/Version.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ package org.pkl.core; import java.util.*; import java.util.regex.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; /** * A semantic version. diff --git a/pkl-core/src/main/java/org/pkl/core/YamlRenderer.java b/pkl-core/src/main/java/org/pkl/core/YamlRenderer.java index 5081c3f3..fb1ba725 100644 --- a/pkl-core/src/main/java/org/pkl/core/YamlRenderer.java +++ b/pkl-core/src/main/java/org/pkl/core/YamlRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import java.io.UncheckedIOException; import java.io.Writer; import java.util.*; import java.util.regex.Pattern; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.yaml.snake.YamlUtils; import org.snakeyaml.engine.v2.api.ConstructNode; import org.snakeyaml.engine.v2.api.DumpSettings; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/MemberNode.java b/pkl-core/src/main/java/org/pkl/core/ast/MemberNode.java index d3c0c97a..cfba3a17 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/MemberNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/MemberNode.java @@ -18,10 +18,10 @@ package org.pkl.core.ast; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.member.DefaultPropertyBodyNode; import org.pkl.core.runtime.VmExceptionBuilder; import org.pkl.core.runtime.VmLanguage; -import org.pkl.core.util.Nullable; public abstract class MemberNode extends PklRootNode { @Child protected ExpressionNode bodyNode; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/PklRootNode.java b/pkl-core/src/main/java/org/pkl/core/ast/PklRootNode.java index ef8c85e5..9e4b57d4 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/PklRootNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/PklRootNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.type.VmTypeMismatchException; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; @NodeInfo(language = "Pkl") @TypeSystemReference(VmTypes.class) diff --git a/pkl-core/src/main/java/org/pkl/core/ast/builder/AbstractAstBuilder.java b/pkl-core/src/main/java/org/pkl/core/ast/builder/AbstractAstBuilder.java index b53a4d89..faee0ce5 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/builder/AbstractAstBuilder.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/builder/AbstractAstBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ package org.pkl.core.ast.builder; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.runtime.VmExceptionBuilder; -import org.pkl.core.util.Nullable; import org.pkl.parser.BaseParserVisitor; import org.pkl.parser.Span; import org.pkl.parser.syntax.DocComment; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java b/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java index 244f2870..96affffa 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java @@ -33,6 +33,7 @@ import java.util.function.BiFunction; import java.util.function.Supplier; import java.util.stream.Collectors; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.PClassInfo; import org.pkl.core.PklBugException; import org.pkl.core.SecurityManagerException; @@ -183,7 +184,6 @@ import org.pkl.core.stdlib.registry.MemberRegistryFactory; import org.pkl.core.util.CollectionUtils; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; import org.pkl.core.util.Pair; import org.pkl.parser.Span; import org.pkl.parser.syntax.Annotation; @@ -2694,7 +2694,7 @@ public class AstBuilder extends AbstractAstBuilder { return builder; } - private @Nullable FrameDescriptor.Builder createFrameDescriptorBuilder(ObjectBody body) { + private FrameDescriptor.@Nullable Builder createFrameDescriptorBuilder(ObjectBody body) { if (body.getParameters().isEmpty()) return null; var builder = FrameDescriptor.newBuilder(body.getParameters().size()); @@ -2746,7 +2746,7 @@ public class AstBuilder extends AbstractAstBuilder { .withMemberName(symbolTable.getCurrentScope().getQualifiedName()); } - private @Nullable SymbolTable.Scope getParentLexicalScope() { + private SymbolTable.@Nullable Scope getParentLexicalScope() { var parent = symbolTable.getCurrentScope().getLexicalScope().getParent(); if (parent != null) return parent.getLexicalScope(); return null; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/builder/ImportsAndReadsParser.java b/pkl-core/src/main/java/org/pkl/core/ast/builder/ImportsAndReadsParser.java index c098897e..4d4d4dbb 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/builder/ImportsAndReadsParser.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/builder/ImportsAndReadsParser.java @@ -21,13 +21,13 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.builder.ImportsAndReadsParser.Entry; import org.pkl.core.module.ModuleKey; import org.pkl.core.module.ResolvedModuleKey; import org.pkl.core.runtime.VmExceptionBuilder; import org.pkl.core.runtime.VmUtils; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; import org.pkl.parser.Parser; import org.pkl.parser.ParserError; import org.pkl.parser.syntax.Expr; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/builder/SymbolTable.java b/pkl-core/src/main/java/org/pkl/core/ast/builder/SymbolTable.java index 4f2eb64f..ed3221e6 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/builder/SymbolTable.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/builder/SymbolTable.java @@ -19,6 +19,7 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameDescriptor.Builder; import java.util.*; import java.util.function.Function; +import org.jspecify.annotations.Nullable; import org.pkl.core.TypeParameter; import org.pkl.core.ast.ConstantNode; import org.pkl.core.ast.ExpressionNode; @@ -28,7 +29,6 @@ import org.pkl.core.runtime.Identifier; import org.pkl.core.runtime.ModuleInfo; import org.pkl.core.runtime.VmDataSize; import org.pkl.core.runtime.VmDuration; -import org.pkl.core.util.Nullable; import org.pkl.parser.Lexer; public final class SymbolTable { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/builder/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/builder/package-info.java index 04308f62..685b70c2 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/builder/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/builder/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.builder; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/EqualNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/EqualNode.java index 0de0b12f..c2c7987d 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/EqualNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/EqualNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,9 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; @NodeInfo(shortName = "==") @NodeChild(value = "leftNode", type = ExpressionNode.class) diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/NotEqualNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/NotEqualNode.java index 5eb0e837..1d5a8816 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/NotEqualNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/NotEqualNode.java @@ -21,9 +21,9 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.runtime.VmValue; -import org.pkl.core.util.Nullable; @NodeInfo(shortName = "!=") @NodeChild(value = "leftNode", type = ExpressionNode.class) diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/package-info.java index 0b1079d8..5ba063e8 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.expression.binary; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorForNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorForNode.java index b83b1b20..71adba86 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorForNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorForNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,11 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public abstract class GeneratorForNode extends GeneratorMemberNode { private final FrameDescriptor generatorDescriptor; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorObjectLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorObjectLiteralNode.java index 1b9d237d..03a9b1a5 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorObjectLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorObjectLiteralNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,12 +26,12 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.expression.literal.AmendFunctionNode; import org.pkl.core.ast.expression.literal.ObjectLiteralNode; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; /** An object literal node that contains at least one for- or when-expression. */ @ImportStatic(BaseModule.class) diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/package-info.java index 2e07dcad..bd32b64d 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.expression.generator; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/AmendFunctionNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/AmendFunctionNode.java index fc8b8fcf..64cca238 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/AmendFunctionNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/AmendFunctionNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.PklNode; import org.pkl.core.ast.PklRootNode; @@ -31,7 +32,6 @@ import org.pkl.core.ast.member.FunctionNode; import org.pkl.core.ast.member.Lambda; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public final class AmendFunctionNode extends PklNode { private final boolean isCustomThisScope; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/CheckIsAnnotationClassNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/CheckIsAnnotationClassNode.java index 227089a7..dc84d2af 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/CheckIsAnnotationClassNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/CheckIsAnnotationClassNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,11 @@ package org.pkl.core.ast.expression.literal; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public final class CheckIsAnnotationClassNode extends ExpressionNode { @Child private UnresolvedTypeNode unresolvedTypeNode; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ConstantEntriesLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ConstantEntriesLiteralNode.java index af481fba..ec8c1b15 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ConstantEntriesLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ConstantEntriesLiteralNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,11 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; /** * Object literal that contains entries (and possibly properties) but not elements. Additionally, diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ElementsEntriesLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ElementsEntriesLiteralNode.java index 2209b153..56886a59 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ElementsEntriesLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ElementsEntriesLiteralNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,12 +25,12 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.source.SourceSection; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; /** * Object literal that contains both elements and entries (and possibly properties). Example: `new diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ElementsLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ElementsLiteralNode.java index ffaaa080..b68f1ade 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ElementsLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ElementsLiteralNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,12 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; /** * Object literal that contains elements (and possibly properties) but not entries. Example: `new diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/EntriesLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/EntriesLiteralNode.java index f7a05ec8..fd8a111a 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/EntriesLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/EntriesLiteralNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,13 +24,13 @@ import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.source.SourceSection; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; import org.pkl.core.runtime.VmException.ProgramValue; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; /** * Object literal that contains entries (and possibly properties) but not elements. Additionally, at diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/FunctionLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/FunctionLiteralNode.java index 45543552..e062a56a 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/FunctionLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/FunctionLiteralNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,12 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.member.FunctionNode; import org.pkl.core.ast.member.UnresolvedFunctionNode; import org.pkl.core.runtime.VmFunction; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; public final class FunctionLiteralNode extends ExpressionNode { private @Child UnresolvedFunctionNode unresolvedFunctionNode; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ObjectLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ObjectLiteralNode.java index 0f9e74cd..c8a8d8ea 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ObjectLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/ObjectLiteralNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.ast.type.UnresolvedTypeNode; @@ -28,7 +29,6 @@ import org.pkl.core.runtime.VmClass; import org.pkl.core.runtime.VmFunction; import org.pkl.core.runtime.VmLanguage; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; // IDEA: don't materialize frames when all members are constants @NodeChild(value = "parentNode", type = ExpressionNode.class) diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/PropertiesLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/PropertiesLiteralNode.java index 8a51b46a..b35db943 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/PropertiesLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/PropertiesLiteralNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,11 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.source.SourceSection; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; /** Object literal that contains properties but not elements or entries. */ // IDEA: don't materialize frame when all members are constants diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/SpecializedObjectLiteralNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/SpecializedObjectLiteralNode.java index 0bf0fee1..6d2c0afb 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/SpecializedObjectLiteralNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/SpecializedObjectLiteralNode.java @@ -26,13 +26,13 @@ import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.source.SourceSection; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; import org.pkl.core.runtime.VmException.ProgramValue; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; /** * Base class for object literal nodes specialized for a certain mix of property/entry/element diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/package-info.java index e41d1c19..cbe289a0 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.expression.literal; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/member/ReadPropertyNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/member/ReadPropertyNode.java index e9cda6af..b4e04ed6 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/member/ReadPropertyNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/member/ReadPropertyNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,11 @@ import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.MemberLookupMode; import org.pkl.core.ast.member.ClassProperty; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; @NodeInfo(shortName = ".") @ImportStatic(BaseModule.class) diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/member/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/member/package-info.java index caae5599..d19a7f97 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/member/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/member/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.expression.member; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/package-info.java index 7a057cef..dc0219d0 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.expression; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/primary/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/primary/package-info.java index 36c30fd4..7571b9e6 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/primary/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/primary/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.expression.primary; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/ternary/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/ternary/package-info.java index c1aabf33..59864ef5 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/ternary/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/ternary/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.expression.ternary; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/AbstractReadNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/AbstractReadNode.java index 607e0418..9aa2f9e7 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/AbstractReadNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/AbstractReadNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,13 +22,13 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManagerException; import org.pkl.core.externalreader.ExternalReaderProcessException; import org.pkl.core.module.ModuleKey; import org.pkl.core.packages.PackageLoadError; import org.pkl.core.runtime.VmContext; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; public abstract class AbstractReadNode extends UnaryExpressionNode { protected final ModuleKey currentModule; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ReadGlobMemberBodyNode.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ReadGlobMemberBodyNode.java index 6130641d..478bb23b 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ReadGlobMemberBodyNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ReadGlobMemberBodyNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,9 @@ public class ReadGlobMemberBodyNode extends ExpressionNode { private Object readResource(VmObjectLike mapping, String path) { @SuppressWarnings("unchecked") var globElements = (Map) mapping.getExtraStorage(); - var resourceUri = VmUtils.getMapValue(globElements, path).uri(); + var globElement = VmUtils.getMapValue(globElements, path); + assert globElement != null; + var resourceUri = globElement.uri(); var resource = VmContext.get(this).getResourceManager().read(resourceUri, this).orElse(null); if (resource == null) { CompilerDirectives.transferToInterpreter(); diff --git a/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/package-info.java index f5e817ad..2f102fc4 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.expression.unary; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/frame/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/frame/package-info.java index 65fdd20c..41cbdd04 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/frame/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/frame/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.frame; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/internal/BlackholeNode.java b/pkl-core/src/main/java/org/pkl/core/ast/internal/BlackholeNode.java index f4d17edc..30c784aa 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/internal/BlackholeNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/internal/BlackholeNode.java @@ -18,8 +18,8 @@ package org.pkl.core.ast.internal; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; -import org.pkl.core.util.Nullable; /** Ensures that `childNode` isn't optimized away. */ @NodeChild(value = "childNode", type = ExpressionNode.class) diff --git a/pkl-core/src/main/java/org/pkl/core/ast/internal/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/internal/package-info.java index dd580308..f4c08b67 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/internal/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/internal/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.internal; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/lambda/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/lambda/package-info.java index f8b5d6c5..bbf54d5c 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/lambda/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/lambda/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.lambda; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassMember.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassMember.java index 29aa1a18..045fda62 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassMember.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassMember.java @@ -18,10 +18,10 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.source.SourceSection; import java.util.ArrayList; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.runtime.Identifier; import org.pkl.core.runtime.VmClass; import org.pkl.core.runtime.VmTyped; -import org.pkl.core.util.Nullable; public abstract class ClassMember extends Member { protected final SourceSection @Nullable [] docComment; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassMethod.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassMethod.java index e0862c7c..9cfa622d 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassMethod.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassMethod.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,12 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.source.SourceSection; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.PClass; import org.pkl.core.TypeParameter; import org.pkl.core.ast.VmModifier; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public final class ClassMethod extends ClassMember { private final List typeParameters; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassNode.java index 96956765..9302105f 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.oracle.truffle.api.source.SourceSection; import java.util.ArrayList; import java.util.List; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.PClassInfo; import org.pkl.core.TypeParameter; import org.pkl.core.ast.ExpressionNode; @@ -30,7 +31,6 @@ import org.pkl.core.ast.type.TypeNode; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; @NodeInfo(shortName = "class") public final class ClassNode extends ExpressionNode { @@ -102,12 +102,8 @@ public final class ClassNode extends ExpressionNode { prototype.setExtraStorage(moduleInfo); prototype.addProperties(prototypeMembers); } else { - prototype = - new VmTyped( - frame.materialize(), - null, // initialized later by VmClass - null, // initialized later by VmClass - prototypeMembers); + // parent and clazz will be initialized later by VmClass + prototype = new VmTyped(frame.materialize(), null, prototypeMembers); } var annotations = new ArrayList(annotationNodes.length); diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java index c2f6f212..3aeb29c7 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ClassProperty.java @@ -17,11 +17,11 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.source.SourceSection; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.Member.SourceLocation; import org.pkl.core.PClass; import org.pkl.core.ast.VmModifier; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public final class ClassProperty extends ClassMember { private final @Nullable PropertyTypeNode typeNode; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/DefaultPropertyBodyNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/DefaultPropertyBodyNode.java index d840851d..b4b7bdc4 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/DefaultPropertyBodyNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/DefaultPropertyBodyNode.java @@ -18,10 +18,10 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.runtime.Identifier; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; /** * Property body for properties that don't have an explicit body. Returns the default value for the diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ElementOrEntryNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ElementOrEntryNode.java index f99a0f12..8af0eacb 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ElementOrEntryNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ElementOrEntryNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.IndirectCallNode; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.expression.primary.GetReceiverNode; import org.pkl.core.runtime.VmDynamic; @@ -29,7 +30,6 @@ import org.pkl.core.runtime.VmLanguage; import org.pkl.core.runtime.VmListing; import org.pkl.core.runtime.VmMapping; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; /** Equivalent of {@link TypedPropertyNode} for elements/entries. */ public abstract class ElementOrEntryNode extends RegularMemberNode { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java index e1227e0b..3af39269 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.source.SourceSection; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.Member.SourceLocation; import org.pkl.core.PClass; import org.pkl.core.PType; @@ -31,7 +32,6 @@ import org.pkl.core.ast.VmModifier; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.runtime.*; import org.pkl.core.util.CollectionUtils; -import org.pkl.core.util.Nullable; import org.pkl.core.util.Pair; public final class FunctionNode extends RegularMemberNode { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/Lambda.java b/pkl-core/src/main/java/org/pkl/core/ast/member/Lambda.java index c72dceed..7fe0b41a 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/Lambda.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/Lambda.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.VmModifier; -import org.pkl.core.util.Nullable; public class Lambda extends Member { public Lambda(SourceSection sourceSection, String qualifiedName) { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ListingOrMappingTypeCastNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ListingOrMappingTypeCastNode.java index 6ac3e304..61df46b3 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ListingOrMappingTypeCastNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ListingOrMappingTypeCastNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +18,10 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.PklRootNode; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.runtime.VmLanguage; -import org.pkl.core.util.Nullable; /** Performs a typecast on a Mapping entry value, or a Listing element. */ public final class ListingOrMappingTypeCastNode extends PklRootNode { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/LocalTypedPropertyNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/LocalTypedPropertyNode.java index b3c55f40..f6bde413 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/LocalTypedPropertyNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/LocalTypedPropertyNode.java @@ -18,12 +18,12 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.VmLanguage; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; public final class LocalTypedPropertyNode extends RegularMemberNode { private final VmLanguage language; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/Member.java b/pkl-core/src/main/java/org/pkl/core/ast/member/Member.java index 6f0a2792..7b7e3c8f 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/Member.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/Member.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,9 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.VmModifier; import org.pkl.core.runtime.Identifier; -import org.pkl.core.util.Nullable; public abstract class Member { protected final SourceSection sourceSection; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMember.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMember.java index 83723b59..c645bef4 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMember.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMember.java @@ -19,13 +19,13 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ConstantNode; import org.pkl.core.ast.MemberNode; import org.pkl.core.ast.VmModifier; import org.pkl.core.runtime.Identifier; import org.pkl.core.runtime.VmDynamic; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; public final class ObjectMember extends Member { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMethodNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMethodNode.java index aa62321c..a2b9808a 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMethodNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMethodNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,12 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; public final class ObjectMethodNode extends RegularMemberNode { private final VmLanguage language; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java index 486e5b82..229df4f7 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java @@ -19,12 +19,12 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.PType; import org.pkl.core.ast.PklRootNode; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.ast.type.TypeNode.UnknownTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public final class PropertyTypeNode extends PklRootNode { private final String qualifiedPropertyName; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/RegularMemberNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/RegularMemberNode.java index 4af4f348..0677e187 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/RegularMemberNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/RegularMemberNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,10 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.MemberNode; import org.pkl.core.runtime.VmLanguage; -import org.pkl.core.util.Nullable; /** A {@code MemberNode} that belongs to a single {@link Member}. */ public abstract class RegularMemberNode extends MemberNode { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/SharedMemberNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/SharedMemberNode.java index cddb3208..22efae86 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/SharedMemberNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/SharedMemberNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +18,10 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.MemberNode; import org.pkl.core.runtime.VmLanguage; -import org.pkl.core.util.Nullable; /** A {@code MemberNode} that is shared between multiple {@linkplain Member members}. */ public class SharedMemberNode extends MemberNode { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/TypeAliasNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/TypeAliasNode.java index 5724cb33..22be156e 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/TypeAliasNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/TypeAliasNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,13 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; import java.util.ArrayList; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.TypeParameter; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.VmTypeAlias; import org.pkl.core.runtime.VmTyped; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; public final class TypeAliasNode extends ExpressionNode { private final SourceSection headerSection; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/TypeCheckedPropertyNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/TypeCheckedPropertyNode.java index eaff4a3c..b906b0b8 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/TypeCheckedPropertyNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/TypeCheckedPropertyNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.IndirectCallNode; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.expression.primary.GetOwnerNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; /** A property definition that does not have a type annotation but should be type-checked. */ public abstract class TypeCheckedPropertyNode extends RegularMemberNode { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedClassMemberNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedClassMemberNode.java index 109b1899..0249216f 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedClassMemberNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedClassMemberNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,12 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.PklNode; import org.pkl.core.runtime.Identifier; import org.pkl.core.runtime.VmClass; import org.pkl.core.runtime.VmLanguage; -import org.pkl.core.util.Nullable; public abstract class UnresolvedClassMemberNode extends PklNode { protected final SourceSection headerSection; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedFunctionNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedFunctionNode.java index 14c362b4..f96930c6 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedFunctionNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedFunctionNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,11 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.PklNode; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public final class UnresolvedFunctionNode extends PklNode { private final VmLanguage language; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedMethodNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedMethodNode.java index 769ccd7a..9ee989a7 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedMethodNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedMethodNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,12 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.TypeParameter; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.VmModifier; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public final class UnresolvedMethodNode extends UnresolvedClassMemberNode { private final int parameterCount; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedPropertyNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedPropertyNode.java index 746f4c8f..368edf71 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedPropertyNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/UnresolvedPropertyNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,11 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.VmModifier; import org.pkl.core.ast.type.UnresolvedTypeNode; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; public final class UnresolvedPropertyNode extends UnresolvedClassMemberNode { private final SourceSection propertyNameSection; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/UntypedObjectMemberNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/UntypedObjectMemberNode.java index bd1f11b2..90ccca87 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/UntypedObjectMemberNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/UntypedObjectMemberNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ package org.pkl.core.ast.member; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.runtime.VmLanguage; -import org.pkl.core.util.Nullable; public final class UntypedObjectMemberNode extends RegularMemberNode { public UntypedObjectMemberNode( diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/member/package-info.java index 9639c970..a151af40 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.member; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/package-info.java index f846f332..8daec843 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/repl/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/repl/package-info.java index 8632be47..54557209 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/repl/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/repl/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.repl; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java b/pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java index 7c62f04c..fc91c26e 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.PklRootNode; import org.pkl.core.runtime.VmLanguage; -import org.pkl.core.util.Nullable; /** Root node for a mixin used as default value for type `Mixin`. */ public final class IdentityMixinNode extends PklRootNode { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java b/pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java index cdf281b7..14f7a309 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,11 @@ package org.pkl.core.ast.type; import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.runtime.Identifier; import org.pkl.core.runtime.VmObjectLike; import org.pkl.core.runtime.VmTyped; -import org.pkl.core.util.Nullable; public abstract class ResolveDeclaredTypeNode extends ExpressionNode { @Child private IndirectCallNode callNode = IndirectCallNode.create(); diff --git a/pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java b/pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java index 78c8240b..6c90ce81 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java @@ -33,6 +33,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.pkl.core.PType; import org.pkl.core.PType.StringLiteral; import org.pkl.core.PklBugException; @@ -52,8 +54,6 @@ import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.EconomicSets; import org.pkl.core.util.LateInit; import org.pkl.core.util.MutableBoolean; -import org.pkl.core.util.Nonnull; -import org.pkl.core.util.Nullable; public abstract class TypeNode extends PklNode { @@ -2689,7 +2689,7 @@ public abstract class TypeNode extends PklNode { } @Override - public @Nonnull VmTypeAlias getVmTypeAlias() { + public @NonNull VmTypeAlias getVmTypeAlias() { return typeAlias; } diff --git a/pkl-core/src/main/java/org/pkl/core/ast/type/TypeTestNode.java b/pkl-core/src/main/java/org/pkl/core/ast/type/TypeTestNode.java index 816f95ad..a7c95836 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/type/TypeTestNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/type/TypeTestNode.java @@ -19,9 +19,9 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.runtime.VmLanguage; -import org.pkl.core.util.Nullable; @NodeInfo(shortName = "is") public final class TypeTestNode extends ExpressionNode { diff --git a/pkl-core/src/main/java/org/pkl/core/ast/type/VmTypeMismatchException.java b/pkl-core/src/main/java/org/pkl/core/ast/type/VmTypeMismatchException.java index 8b6e2459..59ff4964 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/type/VmTypeMismatchException.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/type/VmTypeMismatchException.java @@ -22,6 +22,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.SourceSection; import java.util.*; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; import org.pkl.core.StackFrame; import org.pkl.core.ValueFormatter; import org.pkl.core.ast.type.TypeNode.UnionTypeNode; @@ -29,7 +30,6 @@ import org.pkl.core.runtime.*; import org.pkl.core.runtime.VmException.ProgramValue; import org.pkl.core.util.AnsiStringBuilder; import org.pkl.core.util.ErrorMessages; -import org.pkl.core.util.Nullable; /** * Indicates that a type check failed. [TypeNode]s use this exception instead of [VmException] to diff --git a/pkl-core/src/main/java/org/pkl/core/ast/type/package-info.java b/pkl-core/src/main/java/org/pkl/core/ast/type/package-info.java index 0b9e262c..885d5cf4 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/type/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/type/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.ast.type; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/PklEvaluatorSettings.java b/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/PklEvaluatorSettings.java index 13f3fe31..f24a9224 100644 --- a/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/PklEvaluatorSettings.java +++ b/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/PklEvaluatorSettings.java @@ -29,6 +29,7 @@ import java.util.function.BiFunction; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.jspecify.annotations.Nullable; import org.pkl.core.Duration; import org.pkl.core.PNull; import org.pkl.core.PObject; @@ -39,7 +40,6 @@ import org.pkl.core.Value; import org.pkl.core.util.ErrorMessages; import org.pkl.core.util.GlobResolver; import org.pkl.core.util.GlobResolver.InvalidGlobPatternException; -import org.pkl.core.util.Nullable; /** Java version of {@code pkl.EvaluatorSettings}. */ public record PklEvaluatorSettings( diff --git a/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/package-info.java b/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/package-info.java index 26c9b633..29aa26b9 100644 --- a/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.evaluatorSettings; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessagePackDecoder.java b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessagePackDecoder.java index 9578b6a3..9b6edef4 100644 --- a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessagePackDecoder.java +++ b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessagePackDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.pkl.core.externalreader; import java.io.InputStream; import java.net.URISyntaxException; import java.util.Map; +import org.jspecify.annotations.Nullable; import org.msgpack.core.MessagePack; import org.msgpack.core.MessageUnpacker; import org.msgpack.value.Value; @@ -26,7 +27,6 @@ import org.pkl.core.messaging.BaseMessagePackDecoder; import org.pkl.core.messaging.DecodeException; import org.pkl.core.messaging.Message; import org.pkl.core.messaging.Message.Type; -import org.pkl.core.util.Nullable; final class ExternalReaderMessagePackDecoder extends BaseMessagePackDecoder { diff --git a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessagePackEncoder.java b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessagePackEncoder.java index b383b4ac..bb314832 100644 --- a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessagePackEncoder.java +++ b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessagePackEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import org.pkl.core.externalreader.ExternalReaderMessages.*; import org.pkl.core.messaging.BaseMessagePackEncoder; import org.pkl.core.messaging.Message; import org.pkl.core.messaging.ProtocolException; -import org.pkl.core.util.Nullable; final class ExternalReaderMessagePackEncoder extends BaseMessagePackEncoder { @@ -36,7 +35,7 @@ final class ExternalReaderMessagePackEncoder extends BaseMessagePackEncoder { } @Override - protected @Nullable void encodeMessage(Message msg) throws ProtocolException, IOException { + protected void encodeMessage(Message msg) throws ProtocolException, IOException { switch (msg.type()) { case INITIALIZE_MODULE_READER_REQUEST -> { var m = (InitializeModuleReaderRequest) msg; diff --git a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessages.java b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessages.java index 6714ec79..ffec64db 100644 --- a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessages.java +++ b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderMessages.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ */ package org.pkl.core.externalreader; +import org.jspecify.annotations.Nullable; import org.pkl.core.messaging.Message.*; import org.pkl.core.messaging.Messages.ModuleReaderSpec; import org.pkl.core.messaging.Messages.ResourceReaderSpec; -import org.pkl.core.util.Nullable; final class ExternalReaderMessages { private ExternalReaderMessages() {} diff --git a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderProcess.java b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderProcess.java index edce5725..a1c83aa1 100644 --- a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderProcess.java +++ b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderProcess.java @@ -16,8 +16,8 @@ package org.pkl.core.externalreader; import java.io.IOException; +import org.jspecify.annotations.Nullable; import org.pkl.core.evaluatorSettings.PklEvaluatorSettings.ExternalReader; -import org.pkl.core.util.Nullable; /** An external process that reads Pkl modules and resources. */ public interface ExternalReaderProcess extends AutoCloseable { @@ -54,8 +54,7 @@ public interface ExternalReaderProcess extends AutoCloseable { * @throws IllegalStateException if this process has already been {@linkplain #close closed} * @throws IOException if an I/O error occurs */ - @Nullable - ModuleReaderSpec getModuleReaderSpec(String scheme) throws IOException; + @Nullable ModuleReaderSpec getModuleReaderSpec(String scheme) throws IOException; /** * Returns the spec, if available, of this process's resource reader with the given scheme. @@ -63,8 +62,7 @@ public interface ExternalReaderProcess extends AutoCloseable { * @throws IllegalStateException if this process has already been {@linkplain #close closed} * @throws IOException if an I/O error occurs */ - @Nullable - ResourceReaderSpec getResourceReaderSpec(String scheme) throws IOException; + @Nullable ResourceReaderSpec getResourceReaderSpec(String scheme) throws IOException; /** * Closes this process, releasing any associated resources. diff --git a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderProcessImpl.java b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderProcessImpl.java index 05a74527..583f8f5b 100644 --- a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderProcessImpl.java +++ b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalReaderProcessImpl.java @@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import javax.annotation.concurrent.GuardedBy; +import org.jspecify.annotations.Nullable; import org.pkl.core.evaluatorSettings.PklEvaluatorSettings.ExternalReader; import org.pkl.core.externalreader.ExternalReaderMessages.*; import org.pkl.core.messaging.MessageTransport; @@ -34,7 +35,6 @@ import org.pkl.core.messaging.MessageTransports; import org.pkl.core.messaging.ProtocolException; import org.pkl.core.util.ErrorMessages; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; final class ExternalReaderProcessImpl implements ExternalReaderProcess { @@ -171,7 +171,7 @@ final class ExternalReaderProcessImpl implements ExternalReaderProcess { } @Override - public ModuleReaderSpec getModuleReaderSpec(String uriScheme) throws IOException { + public @Nullable ModuleReaderSpec getModuleReaderSpec(String uriScheme) throws IOException { return MessageTransports.resolveFuture( initializeModuleReaderResponses.computeIfAbsent( uriScheme, @@ -207,7 +207,7 @@ final class ExternalReaderProcessImpl implements ExternalReaderProcess { } @Override - public ResourceReaderSpec getResourceReaderSpec(String uriScheme) throws IOException { + public @Nullable ResourceReaderSpec getResourceReaderSpec(String uriScheme) throws IOException { return MessageTransports.resolveFuture( initializeResourceReaderResponses.computeIfAbsent( uriScheme, diff --git a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalResourceResolverImpl.java b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalResourceResolverImpl.java index e749de56..96fd27d2 100644 --- a/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalResourceResolverImpl.java +++ b/pkl-core/src/main/java/org/pkl/core/externalreader/ExternalResourceResolverImpl.java @@ -25,6 +25,7 @@ import java.util.Random; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; import org.pkl.core.messaging.MessageTransport; @@ -33,7 +34,6 @@ import org.pkl.core.messaging.Messages.*; import org.pkl.core.messaging.ProtocolException; import org.pkl.core.module.PathElement; import org.pkl.core.resource.Resource; -import org.pkl.core.util.Nullable; final class ExternalResourceResolverImpl implements ExternalResourceResolver { private final MessageTransport transport; diff --git a/pkl-core/src/main/java/org/pkl/core/externalreader/package-info.java b/pkl-core/src/main/java/org/pkl/core/externalreader/package-info.java index 735a048d..351043f7 100644 --- a/pkl-core/src/main/java/org/pkl/core/externalreader/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/externalreader/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.externalreader; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/http/HttpClient.java b/pkl-core/src/main/java/org/pkl/core/http/HttpClient.java index 352a3789..ca564f84 100644 --- a/pkl-core/src/main/java/org/pkl/core/http/HttpClient.java +++ b/pkl-core/src/main/java/org/pkl/core/http/HttpClient.java @@ -25,8 +25,8 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; import javax.net.ssl.SSLContext; +import org.jspecify.annotations.Nullable; import org.pkl.core.Pair; -import org.pkl.core.util.Nullable; /** * An HTTP client. diff --git a/pkl-core/src/main/java/org/pkl/core/http/HttpClientBuilder.java b/pkl-core/src/main/java/org/pkl/core/http/HttpClientBuilder.java index 99e2f8da..5b3fc30f 100644 --- a/pkl-core/src/main/java/org/pkl/core/http/HttpClientBuilder.java +++ b/pkl-core/src/main/java/org/pkl/core/http/HttpClientBuilder.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.function.Supplier; import java.util.regex.Pattern; +import org.jspecify.annotations.Nullable; import org.pkl.core.Pair; import org.pkl.core.Release; import org.pkl.core.http.HttpClient.Builder; @@ -39,7 +40,7 @@ final class HttpClientBuilder implements HttpClient.Builder { private final List certificateFiles = new ArrayList<>(); private final List certificateBytes = new ArrayList<>(); private int testPort = -1; - private ProxySelector proxySelector; + private @Nullable ProxySelector proxySelector; private Map rewrites = new HashMap<>(); private List>>> headers = new ArrayList<>(); @@ -90,7 +91,7 @@ final class HttpClientBuilder implements HttpClient.Builder { } @Override - public Builder setProxy(URI proxyAddress, List noProxy) { + public Builder setProxy(@Nullable URI proxyAddress, List noProxy) { this.proxySelector = new org.pkl.core.http.ProxySelector(proxyAddress, noProxy); return this; } diff --git a/pkl-core/src/main/java/org/pkl/core/http/LazyHttpClient.java b/pkl-core/src/main/java/org/pkl/core/http/LazyHttpClient.java index 32dd52fa..00387034 100644 --- a/pkl-core/src/main/java/org/pkl/core/http/LazyHttpClient.java +++ b/pkl-core/src/main/java/org/pkl/core/http/LazyHttpClient.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.util.Optional; import java.util.function.Supplier; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; +import org.jspecify.annotations.Nullable; /** * An {@code HttpClient} decorator that defers creating the underlying HTTP client until the first @@ -34,10 +35,10 @@ final class LazyHttpClient implements HttpClient { private final Object lock = new Object(); @GuardedBy("lock") - private HttpClient client; + private @Nullable HttpClient client; @GuardedBy("lock") - private RuntimeException exception; + private @Nullable RuntimeException exception; LazyHttpClient(Supplier supplier) { this.supplier = supplier; diff --git a/pkl-core/src/main/java/org/pkl/core/http/NoProxyRule.java b/pkl-core/src/main/java/org/pkl/core/http/NoProxyRule.java index 53986793..b8e5cefc 100644 --- a/pkl-core/src/main/java/org/pkl/core/http/NoProxyRule.java +++ b/pkl-core/src/main/java/org/pkl/core/http/NoProxyRule.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.net.URI; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.util.regex.Pattern; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** * Represents a noproxy entry. diff --git a/pkl-core/src/main/java/org/pkl/core/http/ProxySelector.java b/pkl-core/src/main/java/org/pkl/core/http/ProxySelector.java index e1682707..b4758e83 100644 --- a/pkl-core/src/main/java/org/pkl/core/http/ProxySelector.java +++ b/pkl-core/src/main/java/org/pkl/core/http/ProxySelector.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import java.net.Proxy; import java.net.SocketAddress; import java.net.URI; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.ErrorMessages; -import org.pkl.core.util.Nullable; final class ProxySelector extends java.net.ProxySelector { @@ -31,7 +31,7 @@ final class ProxySelector extends java.net.ProxySelector { private final @Nullable List myProxy; private final List noProxyRules; - private final @Nullable java.net.ProxySelector delegate; + private final java.net.@Nullable ProxySelector delegate; ProxySelector(@Nullable URI proxyAddress, List noProxyRules) { this.noProxyRules = noProxyRules.stream().map(NoProxyRule::new).toList(); diff --git a/pkl-core/src/main/java/org/pkl/core/http/RequestRewritingClient.java b/pkl-core/src/main/java/org/pkl/core/http/RequestRewritingClient.java index 8cf0e6bb..2af696a3 100644 --- a/pkl-core/src/main/java/org/pkl/core/http/RequestRewritingClient.java +++ b/pkl-core/src/main/java/org/pkl/core/http/RequestRewritingClient.java @@ -31,10 +31,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; import java.util.stream.Stream; import javax.annotation.concurrent.ThreadSafe; +import org.jspecify.annotations.Nullable; import org.pkl.core.Pair; import org.pkl.core.PklBugException; import org.pkl.core.util.HttpUtils; -import org.pkl.core.util.Nullable; /** * An {@code HttpClient} decorator that diff --git a/pkl-core/src/main/java/org/pkl/core/http/package-info.java b/pkl-core/src/main/java/org/pkl/core/http/package-info.java index fb60dfb1..7cb4a4d0 100644 --- a/pkl-core/src/main/java/org/pkl/core/http/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/http/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.http; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackDecoder.java b/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackDecoder.java index 5a3c3fe9..a6780ba7 100644 --- a/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackDecoder.java +++ b/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; import org.msgpack.core.MessagePack; import org.msgpack.core.MessageTypeException; import org.msgpack.core.MessageUnpacker; @@ -30,7 +31,6 @@ import org.msgpack.value.Value; import org.msgpack.value.impl.ImmutableStringValueImpl; import org.pkl.core.messaging.Message.Type; import org.pkl.core.util.ErrorMessages; -import org.pkl.core.util.Nullable; public abstract class AbstractMessagePackDecoder implements MessageDecoder { diff --git a/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackEncoder.java b/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackEncoder.java index 8c618334..66a55fca 100644 --- a/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackEncoder.java +++ b/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackEncoder.java @@ -20,9 +20,9 @@ import java.io.OutputStream; import java.util.Collection; import java.util.Map; import java.util.function.Function; +import org.jspecify.annotations.Nullable; import org.msgpack.core.MessagePack; import org.msgpack.core.MessagePacker; -import org.pkl.core.util.Nullable; public abstract class AbstractMessagePackEncoder implements MessageEncoder { @@ -36,8 +36,7 @@ public abstract class AbstractMessagePackEncoder implements MessageEncoder { this(MessagePack.newDefaultPacker(stream)); } - protected abstract @Nullable void encodeMessage(Message msg) - throws ProtocolException, IOException; + protected abstract void encodeMessage(Message msg) throws ProtocolException, IOException; @Override public final void encode(Message msg) throws IOException, ProtocolException { diff --git a/pkl-core/src/main/java/org/pkl/core/messaging/BaseMessagePackDecoder.java b/pkl-core/src/main/java/org/pkl/core/messaging/BaseMessagePackDecoder.java index c4fa6dde..ff2fe6fe 100644 --- a/pkl-core/src/main/java/org/pkl/core/messaging/BaseMessagePackDecoder.java +++ b/pkl-core/src/main/java/org/pkl/core/messaging/BaseMessagePackDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,12 @@ import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; import java.util.*; +import org.jspecify.annotations.Nullable; import org.msgpack.core.MessageUnpacker; import org.msgpack.value.Value; import org.pkl.core.messaging.Message.Type; import org.pkl.core.messaging.Messages.*; import org.pkl.core.module.PathElement; -import org.pkl.core.util.Nullable; public class BaseMessagePackDecoder extends AbstractMessagePackDecoder { diff --git a/pkl-core/src/main/java/org/pkl/core/messaging/BaseMessagePackEncoder.java b/pkl-core/src/main/java/org/pkl/core/messaging/BaseMessagePackEncoder.java index 0b7aacca..47e8c243 100644 --- a/pkl-core/src/main/java/org/pkl/core/messaging/BaseMessagePackEncoder.java +++ b/pkl-core/src/main/java/org/pkl/core/messaging/BaseMessagePackEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import org.msgpack.core.MessagePacker; import org.pkl.core.messaging.Messages.*; import org.pkl.core.module.PathElement; import org.pkl.core.util.ErrorMessages; -import org.pkl.core.util.Nullable; public class BaseMessagePackEncoder extends AbstractMessagePackEncoder { @@ -54,7 +53,7 @@ public class BaseMessagePackEncoder extends AbstractMessagePackEncoder { packKeyValue("isDirectory", pathElement.isDirectory()); } - protected @Nullable void encodeMessage(Message msg) throws ProtocolException, IOException { + protected void encodeMessage(Message msg) throws ProtocolException, IOException { switch (msg.type()) { case READ_RESOURCE_REQUEST -> { var m = (ReadResourceRequest) msg; diff --git a/pkl-core/src/main/java/org/pkl/core/messaging/MessageDecoder.java b/pkl-core/src/main/java/org/pkl/core/messaging/MessageDecoder.java index f604fb9b..debb5cf3 100644 --- a/pkl-core/src/main/java/org/pkl/core/messaging/MessageDecoder.java +++ b/pkl-core/src/main/java/org/pkl/core/messaging/MessageDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,9 @@ package org.pkl.core.messaging; import java.io.IOException; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** Decodes a stream of messages. */ public interface MessageDecoder { - @Nullable - Message decode() throws IOException, DecodeException; + @Nullable Message decode() throws IOException, DecodeException; } diff --git a/pkl-core/src/main/java/org/pkl/core/messaging/MessageTransports.java b/pkl-core/src/main/java/org/pkl/core/messaging/MessageTransports.java index 7062638a..d49baa16 100644 --- a/pkl-core/src/main/java/org/pkl/core/messaging/MessageTransports.java +++ b/pkl-core/src/main/java/org/pkl/core/messaging/MessageTransports.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import org.jspecify.annotations.Nullable; import org.pkl.core.messaging.Message.OneWay; import org.pkl.core.messaging.Message.Response; import org.pkl.core.util.ErrorMessages; @@ -49,7 +50,7 @@ public final class MessageTransports { return Pair.of(transport1, transport2); } - public static T resolveFuture(Future future) throws IOException { + public static T resolveFuture(Future future) throws IOException { try { return future.get(); } catch (ExecutionException | InterruptedException e) { @@ -98,7 +99,7 @@ public final class MessageTransports { protected static class DirectMessageTransport extends AbstractMessageTransport { - private DirectMessageTransport other; + private @Nullable DirectMessageTransport other; protected DirectMessageTransport(Logger logger) { super(logger); @@ -112,6 +113,8 @@ public final class MessageTransports { @Override protected void doSend(Message message) throws ProtocolException, IOException { + var other = this.other; + assert other != null; other.accept(message); } @@ -123,8 +126,14 @@ public final class MessageTransports { protected abstract static class AbstractMessageTransport implements MessageTransport { private final Logger logger; - private MessageTransport.OneWayHandler oneWayHandler; - private MessageTransport.RequestHandler requestHandler; + private MessageTransport.OneWayHandler oneWayHandler = + (msg) -> { + throw new ProtocolException("Cannot receive one-way messages before transport start."); + }; + private MessageTransport.RequestHandler requestHandler = + (msg) -> { + throw new ProtocolException("Cannot receive request messages before transport start."); + }; private final Map responseHandlers = new ConcurrentHashMap<>(); protected AbstractMessageTransport(Logger logger) { diff --git a/pkl-core/src/main/java/org/pkl/core/messaging/Messages.java b/pkl-core/src/main/java/org/pkl/core/messaging/Messages.java index 74197085..dc78a05d 100644 --- a/pkl-core/src/main/java/org/pkl/core/messaging/Messages.java +++ b/pkl-core/src/main/java/org/pkl/core/messaging/Messages.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ import java.net.URI; import java.util.Arrays; import java.util.List; import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.pkl.core.messaging.Message.*; import org.pkl.core.module.PathElement; -import org.pkl.core.util.Nullable; public final class Messages { private Messages() {} diff --git a/pkl-core/src/main/java/org/pkl/core/messaging/package-info.java b/pkl-core/src/main/java/org/pkl/core/messaging/package-info.java index 4253de96..c9454d02 100644 --- a/pkl-core/src/main/java/org/pkl/core/messaging/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/messaging/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.messaging; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/module/ModuleKey.java b/pkl-core/src/main/java/org/pkl/core/module/ModuleKey.java index 29bd48b6..f74169d5 100644 --- a/pkl-core/src/main/java/org/pkl/core/module/ModuleKey.java +++ b/pkl-core/src/main/java/org/pkl/core/module/ModuleKey.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,10 +19,10 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; import java.nio.file.Path; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; import org.pkl.core.runtime.ReaderBase; -import org.pkl.core.util.Nullable; /** * SPI for identifying, resolving, caching, and resolving a Pkl module. Standard implementations can diff --git a/pkl-core/src/main/java/org/pkl/core/module/ModuleKeyFactories.java b/pkl-core/src/main/java/org/pkl/core/module/ModuleKeyFactories.java index 85b61f90..d920815b 100644 --- a/pkl-core/src/main/java/org/pkl/core/module/ModuleKeyFactories.java +++ b/pkl-core/src/main/java/org/pkl/core/module/ModuleKeyFactories.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import java.util.List; import java.util.Optional; import java.util.ServiceLoader; import javax.annotation.concurrent.GuardedBy; +import org.jspecify.annotations.Nullable; import org.pkl.core.Closeables; import org.pkl.core.externalreader.ExternalModuleResolver; import org.pkl.core.externalreader.ExternalReaderProcess; @@ -266,7 +267,7 @@ public final class ModuleKeyFactories { private final long evaluatorId; @GuardedBy("this") - private ExternalModuleResolver resolver; + private @Nullable ExternalModuleResolver resolver; ExternalProcess(String scheme, ExternalReaderProcess process, long evaluatorId) { this.scheme = scheme; diff --git a/pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java b/pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java index 8d455037..94910f89 100644 --- a/pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java +++ b/pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java @@ -28,6 +28,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.List; import java.util.Map; +import org.jspecify.annotations.Nullable; import org.pkl.core.PklBugException; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; @@ -43,7 +44,6 @@ import org.pkl.core.runtime.VmContext; import org.pkl.core.util.ErrorMessages; import org.pkl.core.util.HttpUtils; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; /** Utilities for creating and using {@link ModuleKey}s. */ public final class ModuleKeys { diff --git a/pkl-core/src/main/java/org/pkl/core/module/ModulePathResolver.java b/pkl-core/src/main/java/org/pkl/core/module/ModulePathResolver.java index c45eeaf1..7174b462 100644 --- a/pkl-core/src/main/java/org/pkl/core/module/ModulePathResolver.java +++ b/pkl-core/src/main/java/org/pkl/core/module/ModulePathResolver.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,10 +28,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.concurrent.GuardedBy; +import org.jspecify.annotations.Nullable; import org.pkl.core.module.PathElement.TreePathElement; import org.pkl.core.runtime.FileSystemManager; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.LateInit; /** * Resolves {@code modulepath} URIs from ZIP or JAR files, or from directory paths. @@ -44,17 +44,14 @@ public final class ModulePathResolver implements AutoCloseable { private final Object lock = new Object(); - @LateInit @GuardedBy("lock") - private Map fileCache; + private @Nullable Map fileCache; - @LateInit @GuardedBy("lock") - private List zipFileSystems; + private @Nullable List zipFileSystems; - @LateInit @GuardedBy("lock") - private TreePathElement cachedPathElementRoot; + private @Nullable TreePathElement cachedPathElementRoot; private @GuardedBy("lock") boolean isClosed = false; @@ -100,6 +97,7 @@ public final class ModulePathResolver implements AutoCloseable { populateCaches(); } + assert fileCache != null; return fileCache; } } @@ -127,6 +125,7 @@ public final class ModulePathResolver implements AutoCloseable { synchronized (lock) { if (isClosed || fileCache == null) return; + assert zipFileSystems != null; for (var fileSystem : zipFileSystems) { try { fileSystem.close(); @@ -154,7 +153,9 @@ public final class ModulePathResolver implements AutoCloseable { stream.forEach( (path) -> { var relativized = IoUtils.relativize(path, basePath); + assert fileCache != null; fileCache.putIfAbsent(IoUtils.toNormalizedPathString(relativized), path); + assert cachedPathElementRoot != null; var element = cachedPathElementRoot; for (var i = 0; i < relativized.getNameCount(); i++) { var name = relativized.getName(i).toString(); diff --git a/pkl-core/src/main/java/org/pkl/core/module/PathElement.java b/pkl-core/src/main/java/org/pkl/core/module/PathElement.java index bd8421ab..41b181ef 100644 --- a/pkl-core/src/main/java/org/pkl/core/module/PathElement.java +++ b/pkl-core/src/main/java/org/pkl/core/module/PathElement.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ import java.util.Comparator; import java.util.List; import java.util.Objects; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; public class PathElement { public static final Comparator comparator = diff --git a/pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java b/pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java index bf582738..1b8c09cc 100644 --- a/pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java +++ b/pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java @@ -22,6 +22,7 @@ import java.util.Map; import java.util.Objects; import javax.annotation.concurrent.GuardedBy; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.PklBugException; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; @@ -50,10 +51,10 @@ public final class ProjectDependenciesManager { private final SecurityManager securityManager; @GuardedBy("lock") - private ProjectDeps projectDeps; + private @Nullable ProjectDeps projectDeps; @GuardedBy("lock") - private Map myDependencies = null; + private @Nullable Map myDependencies; @GuardedBy("lock") private final EconomicMap> localPackageDependencies = @@ -139,8 +140,7 @@ public final class ProjectDependenciesManager { var localDeclaredDependencies = entry.getValue(); var packageUri = localDeclaredDependencies.myPackageUri(); assert packageUri != null; - var canonicalPackageUri = - CanonicalPackageUri.fromPackageUri(localDeclaredDependencies.myPackageUri()); + var canonicalPackageUri = CanonicalPackageUri.fromPackageUri(packageUri); var resolvedDep = resolvedProjectDeps.get(canonicalPackageUri); if (resolvedDep == null) { throw new PackageLoadError("unresolvedProjectDependency", packageUri); @@ -164,6 +164,7 @@ public final class ProjectDependenciesManager { public Map getDependencies() { ensureDependenciesInitialized(); + assert myDependencies != null; return myDependencies; } @@ -189,7 +190,7 @@ public final class ProjectDependenciesManager { var packageDependency = entry.getValue(); var canonicalPackage = CanonicalPackageUri.fromPackageUri(packageDependency.getPackageUri()); - var resolvedDep = projectDeps.get(canonicalPackage); + var resolvedDep = getProjectDeps().get(canonicalPackage); if (resolvedDep == null) { throw new PackageLoadError("unresolvedProjectDependency", packageDependency); } diff --git a/pkl-core/src/main/java/org/pkl/core/module/package-info.java b/pkl-core/src/main/java/org/pkl/core/module/package-info.java index 65da9906..42eeedb0 100644 --- a/pkl-core/src/main/java/org/pkl/core/module/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/module/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.module; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/package-info.java b/pkl-core/src/main/java/org/pkl/core/package-info.java index d78232b6..ccd2b16f 100644 --- a/pkl-core/src/main/java/org/pkl/core/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/packages/Checksums.java b/pkl-core/src/main/java/org/pkl/core/packages/Checksums.java index 9b173f0e..276cb5db 100644 --- a/pkl-core/src/main/java/org/pkl/core/packages/Checksums.java +++ b/pkl-core/src/main/java/org/pkl/core/packages/Checksums.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package org.pkl.core.packages; import java.util.Objects; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; public final class Checksums { private final String sha256; diff --git a/pkl-core/src/main/java/org/pkl/core/packages/Dependency.java b/pkl-core/src/main/java/org/pkl/core/packages/Dependency.java index 8cbe7e9f..e55a57b9 100644 --- a/pkl-core/src/main/java/org/pkl/core/packages/Dependency.java +++ b/pkl-core/src/main/java/org/pkl/core/packages/Dependency.java @@ -19,10 +19,10 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.file.Path; import java.util.Objects; +import org.jspecify.annotations.Nullable; import org.pkl.core.PklBugException; import org.pkl.core.Version; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; public abstract class Dependency { diff --git a/pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java b/pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java index 0f76a53c..2847d8e1 100644 --- a/pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java +++ b/pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.regex.Pattern; +import org.jspecify.annotations.Nullable; import org.pkl.core.DataSize; import org.pkl.core.DataSizeUnit; import org.pkl.core.Duration; @@ -40,7 +41,6 @@ import org.pkl.core.Pair; import org.pkl.core.PklException; import org.pkl.core.Version; import org.pkl.core.packages.Dependency.RemoteDependency; -import org.pkl.core.util.Nullable; import org.pkl.core.util.json.Json; import org.pkl.core.util.json.Json.FormatException; import org.pkl.core.util.json.Json.JsArray; @@ -532,7 +532,7 @@ public final class DependencyMetadata { if (checksums != null) { jsonWriter.name("checksums"); jsonWriter.beginObject(); - jsonWriter.name("sha256").value(entry.getValue().getChecksums().getSha256()); + jsonWriter.name("sha256").value(checksums.getSha256()); jsonWriter.endObject(); } jsonWriter.endObject(); diff --git a/pkl-core/src/main/java/org/pkl/core/packages/PackageLoadError.java b/pkl-core/src/main/java/org/pkl/core/packages/PackageLoadError.java index aa29aab8..d2bfa06f 100644 --- a/pkl-core/src/main/java/org/pkl/core/packages/PackageLoadError.java +++ b/pkl-core/src/main/java/org/pkl/core/packages/PackageLoadError.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,20 +15,21 @@ */ package org.pkl.core.packages; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.ErrorMessages; public final class PackageLoadError extends RuntimeException { private final String messageName; - private final Object[] arguments; + private final @Nullable Object[] arguments; - public PackageLoadError(Throwable cause, String messageName, Object... arguments) { + public PackageLoadError(Throwable cause, String messageName, @Nullable Object... arguments) { super(ErrorMessages.create(messageName, arguments), cause); this.messageName = messageName; this.arguments = arguments; } - public PackageLoadError(String messageName, Object... arguments) { + public PackageLoadError(String messageName, @Nullable Object... arguments) { super(ErrorMessages.create(messageName, arguments)); this.messageName = messageName; this.arguments = arguments; @@ -38,7 +39,7 @@ public final class PackageLoadError extends RuntimeException { return messageName; } - public Object[] getArguments() { + public @Nullable Object[] getArguments() { return arguments; } } diff --git a/pkl-core/src/main/java/org/pkl/core/packages/PackageResolver.java b/pkl-core/src/main/java/org/pkl/core/packages/PackageResolver.java index 7c0f9521..ed34d5b0 100644 --- a/pkl-core/src/main/java/org/pkl/core/packages/PackageResolver.java +++ b/pkl-core/src/main/java/org/pkl/core/packages/PackageResolver.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,13 @@ import java.io.IOException; import java.nio.file.Path; import java.util.List; import javax.naming.OperationNotSupportedException; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; import org.pkl.core.http.HttpClient; import org.pkl.core.module.PathElement; import org.pkl.core.packages.PackageResolvers.DiskCachedPackageResolver; import org.pkl.core.packages.PackageResolvers.InMemoryPackageResolver; -import org.pkl.core.util.Nullable; import org.pkl.core.util.Pair; public interface PackageResolver extends Closeable { diff --git a/pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java b/pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java index 1b71f836..6519bae4 100644 --- a/pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java +++ b/pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ import java.util.stream.StreamSupport; import java.util.zip.ZipInputStream; import javax.annotation.concurrent.GuardedBy; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; import org.pkl.core.http.HttpClient; @@ -56,7 +57,6 @@ import org.pkl.core.util.ByteArrayUtils; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.HttpUtils; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; import org.pkl.core.util.Pair; import org.pkl.core.util.json.Json.JsonParseException; diff --git a/pkl-core/src/main/java/org/pkl/core/packages/PackageUri.java b/pkl-core/src/main/java/org/pkl/core/packages/PackageUri.java index 7f3bf849..2e409a5c 100644 --- a/pkl-core/src/main/java/org/pkl/core/packages/PackageUri.java +++ b/pkl-core/src/main/java/org/pkl/core/packages/PackageUri.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,11 @@ package org.pkl.core.packages; import java.net.URI; import java.net.URISyntaxException; +import org.jspecify.annotations.Nullable; import org.pkl.core.PklBugException; import org.pkl.core.Version; import org.pkl.core.util.ErrorMessages; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; public final class PackageUri { private final URI uri; diff --git a/pkl-core/src/main/java/org/pkl/core/packages/package-info.java b/pkl-core/src/main/java/org/pkl/core/packages/package-info.java index 69482949..0d6de57d 100644 --- a/pkl-core/src/main/java/org/pkl/core/packages/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/packages/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.packages; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/project/DeclaredDependencies.java b/pkl-core/src/main/java/org/pkl/core/project/DeclaredDependencies.java index 188baa1e..50b440de 100644 --- a/pkl-core/src/main/java/org/pkl/core/project/DeclaredDependencies.java +++ b/pkl-core/src/main/java/org/pkl/core/project/DeclaredDependencies.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ package org.pkl.core.project; import java.net.URI; import java.util.Map; +import org.jspecify.annotations.Nullable; import org.pkl.core.packages.Dependency.RemoteDependency; import org.pkl.core.packages.PackageUri; -import org.pkl.core.util.Nullable; public record DeclaredDependencies( Map remoteDependencies, diff --git a/pkl-core/src/main/java/org/pkl/core/project/Package.java b/pkl-core/src/main/java/org/pkl/core/project/Package.java index e2a71549..9ca6738a 100644 --- a/pkl-core/src/main/java/org/pkl/core/project/Package.java +++ b/pkl-core/src/main/java/org/pkl/core/project/Package.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ package org.pkl.core.project; import java.net.URI; import java.nio.file.Path; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.Version; import org.pkl.core.packages.PackageUri; -import org.pkl.core.util.Nullable; /** Java representation of class {@code pkl.Project#Package} */ @SuppressWarnings("unused") diff --git a/pkl-core/src/main/java/org/pkl/core/project/Project.java b/pkl-core/src/main/java/org/pkl/core/project/Project.java index 4c7d652f..a004d0b8 100644 --- a/pkl-core/src/main/java/org/pkl/core/project/Project.java +++ b/pkl-core/src/main/java/org/pkl/core/project/Project.java @@ -26,6 +26,7 @@ import java.util.Objects; import java.util.function.Function; import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; import org.pkl.core.Analyzer; import org.pkl.core.Composite; import org.pkl.core.Duration; @@ -55,7 +56,6 @@ import org.pkl.core.runtime.VmException; import org.pkl.core.runtime.VmExceptionBuilder; import org.pkl.core.util.ImportGraphUtils; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; /** Java representation of module {@code pkl.Project}. */ public final class Project { @@ -79,7 +79,7 @@ public final class Project { public static Project loadFromPath( Path path, SecurityManager securityManager, - @Nullable java.time.Duration timeout, + java.time.@Nullable Duration timeout, StackFrameTransformer stackFrameTransformer, Map envVars, boolean powerAssertionsEnabled) { @@ -112,7 +112,7 @@ public final class Project { public static Project loadFromPath( Path path, SecurityManager securityManager, - @Nullable java.time.Duration timeout, + java.time.@Nullable Duration timeout, StackFrameTransformer stackFrameTransformer, Map envVars) { return loadFromPath(path, securityManager, timeout, stackFrameTransformer, envVars, false); @@ -120,7 +120,7 @@ public final class Project { /** Convenience method to load a project with the default stack frame transformer. */ public static Project loadFromPath( - Path path, SecurityManager securityManager, @Nullable java.time.Duration timeout) { + Path path, SecurityManager securityManager, java.time.@Nullable Duration timeout) { return loadFromPath( path, securityManager, timeout, StackFrameTransformers.defaultTransformer, System.getenv()); } diff --git a/pkl-core/src/main/java/org/pkl/core/project/ProjectDependenciesResolver.java b/pkl-core/src/main/java/org/pkl/core/project/ProjectDependenciesResolver.java index ba6b7b11..a2c9922c 100644 --- a/pkl-core/src/main/java/org/pkl/core/project/ProjectDependenciesResolver.java +++ b/pkl-core/src/main/java/org/pkl/core/project/ProjectDependenciesResolver.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.io.Writer; import java.nio.file.Path; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.EconomicSet; +import org.jspecify.annotations.Nullable; import org.pkl.core.PklException; import org.pkl.core.SecurityManagerException; import org.pkl.core.packages.Checksums; @@ -34,7 +35,6 @@ import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.EconomicSets; import org.pkl.core.util.ErrorMessages; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; /** * Given a project's dependencies, build the dependency list. @@ -131,6 +131,7 @@ public final class ProjectDependenciesResolver { var packageUri = declaredDependencies.myPackageUri(); assert packageUri != null; var projectDir = Path.of(declaredDependencies.projectFileUri()).getParent(); + assert projectDir != null; var relativePath = IoUtils.relativize(projectDir, this.project.getProjectDir()); var localDependency = new LocalDependency(packageUri.toProjectPackageUri(), relativePath); updateDependency(localDependency); diff --git a/pkl-core/src/main/java/org/pkl/core/project/ProjectDeps.java b/pkl-core/src/main/java/org/pkl/core/project/ProjectDeps.java index bf893efd..1db8b760 100644 --- a/pkl-core/src/main/java/org/pkl/core/project/ProjectDeps.java +++ b/pkl-core/src/main/java/org/pkl/core/project/ProjectDeps.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.packages.Checksums; import org.pkl.core.packages.Dependency; import org.pkl.core.packages.Dependency.LocalDependency; @@ -36,7 +37,6 @@ import org.pkl.core.packages.PackageUtils; import org.pkl.core.runtime.VmExceptionBuilder; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; import org.pkl.core.util.json.Json; import org.pkl.core.util.json.Json.FormatException; import org.pkl.core.util.json.Json.JsObject; diff --git a/pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java b/pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java index 95c2a343..6d7c0cab 100644 --- a/pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java +++ b/pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java @@ -196,15 +196,15 @@ public final class ProjectPackager { } } catch (PackageLoadError e) { if (e.getMessageName().equals("badHttpStatusCode")) { - if ((int) e.getArguments()[0] == 404) { + var firstArg = e.getArguments()[0]; + assert firstArg != null; + var statusCode = (int) firstArg; + if (statusCode == 404) { return; } else { throw new PklException( ErrorMessages.create( - "unableToAccessPublishedPackage", - pkg.name(), - pkg.packageZipUrl(), - e.getArguments()[0])); + "unableToAccessPublishedPackage", pkg.name(), pkg.packageZipUrl(), statusCode)); } } throw e; @@ -417,6 +417,7 @@ public final class ProjectPackager { .toPklException(stackFrameTransformer, color); } var currentPath = pklModulePath.getParent(); + assert currentPath != null; var importPath = importUri.getPath().split("/"); // It's not good enough to just check the normalized path to see whether it exists within the // root dir. diff --git a/pkl-core/src/main/java/org/pkl/core/project/package-info.java b/pkl-core/src/main/java/org/pkl/core/project/package-info.java index d5f3ee0b..e1138148 100644 --- a/pkl-core/src/main/java/org/pkl/core/project/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/project/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.project; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/repl/ReplServer.java b/pkl-core/src/main/java/org/pkl/core/repl/ReplServer.java index 4cbe5608..e04ccfbc 100644 --- a/pkl-core/src/main/java/org/pkl/core/repl/ReplServer.java +++ b/pkl-core/src/main/java/org/pkl/core/repl/ReplServer.java @@ -25,6 +25,7 @@ import java.util.*; import java.util.stream.Collectors; import org.graalvm.collections.UnmodifiableEconomicMap; import org.graalvm.polyglot.Context; +import org.jspecify.annotations.Nullable; import org.pkl.core.*; import org.pkl.core.SecurityManager; import org.pkl.core.ast.*; @@ -49,7 +50,6 @@ import org.pkl.core.util.AnsiStringBuilder; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.IoUtils; import org.pkl.core.util.MutableReference; -import org.pkl.core.util.Nullable; import org.pkl.core.util.SyntaxHighlighter; import org.pkl.parser.Parser; import org.pkl.parser.ParserError; @@ -426,12 +426,8 @@ public class ReplServer implements AutoCloseable { moduleKey, resolvedModuleKey, false); - var module = - new VmTyped( - VmUtils.createEmptyMaterializedFrame(), - null, // set by initSuperclass() - null, - moduleMembers); + // clazz will be initialized by initSuperclass() later + var module = new VmTyped(VmUtils.createEmptyMaterializedFrame(), null, moduleMembers); module.setExtraStorage(moduleInfo); var clazz = new VmClass( diff --git a/pkl-core/src/main/java/org/pkl/core/repl/package-info.java b/pkl-core/src/main/java/org/pkl/core/repl/package-info.java index 6cb3081e..50e1cd5b 100644 --- a/pkl-core/src/main/java/org/pkl/core/repl/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/repl/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.repl; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/resource/ResourceReaders.java b/pkl-core/src/main/java/org/pkl/core/resource/ResourceReaders.java index 42897540..8affd26b 100644 --- a/pkl-core/src/main/java/org/pkl/core/resource/ResourceReaders.java +++ b/pkl-core/src/main/java/org/pkl/core/resource/ResourceReaders.java @@ -29,6 +29,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.ServiceLoader; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; import org.pkl.core.externalreader.ExternalReaderProcess; @@ -48,7 +49,6 @@ import org.pkl.core.runtime.VmExceptionBuilder; import org.pkl.core.util.ErrorMessages; import org.pkl.core.util.HttpUtils; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; /** Predefined resource readers for OS environment variables and external properties. */ public final class ResourceReaders { @@ -654,7 +654,7 @@ public final class ResourceReaders { private final String scheme; private final ExternalReaderProcess process; private final long evaluatorId; - private ExternalResolver underlying; + private @Nullable ExternalResolver underlying; public ExternalProcess(String scheme, ExternalReaderProcess process, long evaluatorId) { this.scheme = scheme; diff --git a/pkl-core/src/main/java/org/pkl/core/resource/package-info.java b/pkl-core/src/main/java/org/pkl/core/resource/package-info.java index 6c1c4baf..acec81c0 100644 --- a/pkl-core/src/main/java/org/pkl/core/resource/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/resource/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.resource; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java b/pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java index 12399fc2..a1ae4ea9 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java @@ -33,6 +33,7 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.CommandSpec; import org.pkl.core.CommandSpec.Argument; import org.pkl.core.CommandSpec.BooleanFlag; @@ -64,7 +65,6 @@ import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.GlobResolver; import org.pkl.core.util.GlobResolver.InvalidGlobPatternException; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; import org.pkl.core.util.Pair; /** Runs commands. */ @@ -460,19 +460,19 @@ public final class CommandSpecParser { private class OptionBehavior { private @Nullable BiFunction each; - private @Nullable BiFunction, URI, Object> all; + private @Nullable BiFunction, URI, @Nullable Object> all; private @Nullable Boolean multiple; private @Nullable String metavar; - private @Nullable CommandSpec.CompletionCandidates completionCandidates; + private CommandSpec.@Nullable CompletionCandidates completionCandidates; private @Nullable Object defaultValue = null; private boolean isNullable = false; private OptionBehavior( @Nullable BiFunction each, - @Nullable BiFunction, URI, Object> all, + @Nullable BiFunction, URI, @Nullable Object> all, @Nullable Boolean multiple, @Nullable String metavar, - @Nullable CommandSpec.CompletionCandidates completionCandidates) { + CommandSpec.@Nullable CompletionCandidates completionCandidates) { this.each = each; this.all = all; this.multiple = multiple; @@ -874,7 +874,7 @@ public final class CommandSpecParser { }; } - private static @Nullable CommandSpec.CompletionCandidates exportCompletionCandidates( + private static CommandSpec.@Nullable CompletionCandidates exportCompletionCandidates( VmTyped annotation) { var value = VmUtils.readMember(annotation, Identifier.COMPLETION_CANDIDATES); if (value instanceof VmNull) return null; @@ -892,7 +892,7 @@ public final class CommandSpecParser { return each; } - public BiFunction, URI, Object> getAll() { + public BiFunction, URI, @Nullable Object> getAll() { assert all != null; return all; } @@ -907,7 +907,7 @@ public final class CommandSpecParser { return metavar; } - public @Nullable CommandSpec.CompletionCandidates getCompletionCandidates() { + public CommandSpec.@Nullable CompletionCandidates getCompletionCandidates() { return completionCandidates; } @@ -928,7 +928,7 @@ public final class CommandSpecParser { * *

Transforms List into VmList, Set into VmSet, and Map into VmMap. */ - private VmTyped buildObject(VmClass clazz, Map properties) { + private VmTyped buildObject(VmClass clazz, Map properties) { EconomicMap members = EconomicMaps.create(properties.size()); for (var prop : properties.entrySet()) { var key = prop.getKey(); diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/FileSystemManager.java b/pkl-core/src/main/java/org/pkl/core/runtime/FileSystemManager.java index a824b5ac..d272fdf8 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/FileSystemManager.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/FileSystemManager.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,9 @@ public final class FileSystemManager { public static synchronized FileSystem getFileSystem(URI uri) throws IOException { var fs = fileSystems.get(uri); if (fs != null) { - counts.put(fs, counts.get(fs) + 1); + var count = counts.get(fs); + assert count != null; + counts.put(fs, count + 1); return fs; } try { @@ -76,9 +78,11 @@ public final class FileSystemManager { * to Pkl. */ private static synchronized void close(Handle fs) throws IOException { - var count = counts.get(fs) - 1; - if (count > 0) { - counts.put(fs, count); + var count = counts.get(fs); + assert count != null; + var newCount = count - 1; + if (newCount > 0) { + counts.put(fs, newCount); return; } counts.remove(fs); diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/KeyLookupSuggestions.java b/pkl-core/src/main/java/org/pkl/core/runtime/KeyLookupSuggestions.java index 9d860185..a0615ab2 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/KeyLookupSuggestions.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/KeyLookupSuggestions.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ package org.pkl.core.runtime; import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.ValueFormatter; -import org.pkl.core.util.Nullable; import org.pkl.core.util.StringSimilarity; public final class KeyLookupSuggestions { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/MemberLookupSuggestions.java b/pkl-core/src/main/java/org/pkl/core/runtime/MemberLookupSuggestions.java index 4a18200d..db67f5d7 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/MemberLookupSuggestions.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/MemberLookupSuggestions.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,11 @@ package org.pkl.core.runtime; import java.util.*; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.member.ClassMethod; import org.pkl.core.ast.member.Member; import org.pkl.core.runtime.MemberLookupSuggestions.Candidate.Kind; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; import org.pkl.core.util.StringSimilarity; public final class MemberLookupSuggestions { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/MinPklVersionChecker.java b/pkl-core/src/main/java/org/pkl/core/runtime/MinPklVersionChecker.java index 04978b5a..d63c338c 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/MinPklVersionChecker.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/MinPklVersionChecker.java @@ -16,9 +16,9 @@ package org.pkl.core.runtime; import com.oracle.truffle.api.nodes.Node; +import org.jspecify.annotations.Nullable; import org.pkl.core.Release; import org.pkl.core.Version; -import org.pkl.core.util.Nullable; import org.pkl.parser.syntax.Module; import org.pkl.parser.syntax.ObjectMember.ObjectProperty; import org.pkl.parser.syntax.Type; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/ModuleCache.java b/pkl-core/src/main/java/org/pkl/core/runtime/ModuleCache.java index f58e488a..45b83037 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/ModuleCache.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/ModuleCache.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Supplier; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; import org.pkl.core.Release; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; @@ -35,7 +36,6 @@ import org.pkl.core.module.ModuleKey; import org.pkl.core.module.ModuleKeys; import org.pkl.core.module.ResolvedModuleKey; import org.pkl.core.packages.PackageLoadError; -import org.pkl.core.util.Nullable; /** * Caches modules by the URI originally specified in the importing module, and also by the resolved diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/ModuleInfo.java b/pkl-core/src/main/java/org/pkl/core/runtime/ModuleInfo.java index 8d15fc1d..988fb528 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/ModuleInfo.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/ModuleInfo.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.pkl.core.runtime; import com.oracle.truffle.api.source.SourceSection; import java.net.URI; import java.util.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.ModuleSchema; import org.pkl.core.PClass; import org.pkl.core.TypeAlias; @@ -27,7 +28,6 @@ import org.pkl.core.module.ModuleKey; import org.pkl.core.module.ResolvedModuleKey; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; public final class ModuleInfo { private final SourceSection headerSection; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/ModuleResolver.java b/pkl-core/src/main/java/org/pkl/core/runtime/ModuleResolver.java index e90719f1..fa925081 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/ModuleResolver.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/ModuleResolver.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,12 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Collection; import java.util.Optional; +import org.jspecify.annotations.Nullable; import org.pkl.core.ModuleSource; import org.pkl.core.externalreader.ExternalReaderProcessException; import org.pkl.core.module.ModuleKey; import org.pkl.core.module.ModuleKeyFactory; import org.pkl.core.module.ModuleKeys; -import org.pkl.core.util.Nullable; public final class ModuleResolver { private final Collection factories; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/PowerAssertions.java b/pkl-core/src/main/java/org/pkl/core/runtime/PowerAssertions.java index bd054639..8d5a8966 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/PowerAssertions.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/PowerAssertions.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ConstantValueNode; import org.pkl.core.ast.expression.member.InferParentWithinMethodNode; import org.pkl.core.ast.expression.member.InferParentWithinObjectMethodNode; @@ -38,7 +39,6 @@ import org.pkl.core.ast.expression.member.InvokeMethodDirectNode; import org.pkl.core.ast.type.GetParentForTypeNode; import org.pkl.core.util.AnsiStringBuilder; import org.pkl.core.util.AnsiStringBuilder.AnsiCode; -import org.pkl.core.util.Nullable; import org.pkl.core.util.SyntaxHighlighter; import org.pkl.parser.Lexer; import org.pkl.parser.Parser; @@ -205,8 +205,8 @@ public class PowerAssertions { } // tries to find the parser node for this node - private static @Nullable org.pkl.parser.syntax.Node findParserNode( - Node node, @Nullable org.pkl.parser.syntax.Node parserNode, int offset) { + private static org.pkl.parser.syntax.@Nullable Node findParserNode( + Node node, org.pkl.parser.syntax.@Nullable Node parserNode, int offset) { if (!node.getSourceSection().isAvailable()) { return null; } diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java b/pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java index bd70212f..3c400355 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; import org.pkl.core.externalreader.ExternalReaderProcessException; @@ -32,7 +33,6 @@ import org.pkl.core.packages.PackageLoadError; import org.pkl.core.resource.Resource; import org.pkl.core.resource.ResourceReader; import org.pkl.core.stdlib.VmObjectFactory; -import org.pkl.core.util.Nullable; public final class ResourceManager { private final Map resourceReaders = new HashMap<>(); diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/StackTraceGenerator.java b/pkl-core/src/main/java/org/pkl/core/runtime/StackTraceGenerator.java index 9e6776c2..ee9fab8d 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/StackTraceGenerator.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/StackTraceGenerator.java @@ -20,9 +20,9 @@ import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.SourceSection; import java.util.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.StackFrame; import org.pkl.core.ast.MemberNode; -import org.pkl.core.util.Nullable; final class StackTraceGenerator { private final VmException exception; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/StackTraceRenderer.java b/pkl-core/src/main/java/org/pkl/core/runtime/StackTraceRenderer.java index d88a1ad6..18957505 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/StackTraceRenderer.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/StackTraceRenderer.java @@ -19,10 +19,10 @@ import java.util.ArrayList; import java.util.List; import java.util.function.BiConsumer; import java.util.function.Function; +import org.jspecify.annotations.Nullable; import org.pkl.core.StackFrame; import org.pkl.core.util.AnsiStringBuilder; import org.pkl.core.util.AnsiTheme; -import org.pkl.core.util.Nullable; import org.pkl.core.util.SyntaxHighlighter; public final class StackTraceRenderer { @@ -101,6 +101,7 @@ public final class StackTraceRenderer { if (hint != null) { out.append(AnsiTheme.ERROR_MESSAGE_HINT, hint); } else { + assert hintBuilder != null; out.append(AnsiTheme.ERROR_MESSAGE_HINT, () -> hintBuilder.accept(out, true)); } out.append('\n'); diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/TestRunner.java b/pkl-core/src/main/java/org/pkl/core/runtime/TestRunner.java index d9309e24..e874d804 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/TestRunner.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/TestRunner.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import org.jspecify.annotations.Nullable; import org.pkl.core.BufferedLogger; import org.pkl.core.StackFrameTransformer; import org.pkl.core.TestResults; @@ -41,7 +42,6 @@ import org.pkl.core.util.AnsiTheme; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.MutableBoolean; import org.pkl.core.util.MutableReference; -import org.pkl.core.util.Nullable; /** Runs test results examples and facts. */ public final class TestRunner { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmBugException.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmBugException.java index 6e7d8a5f..4c839477 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmBugException.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmBugException.java @@ -22,16 +22,16 @@ import com.oracle.truffle.api.source.SourceSection; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; +import org.jspecify.annotations.Nullable; import org.pkl.core.*; import org.pkl.core.util.AnsiStringBuilder; -import org.pkl.core.util.Nullable; public final class VmBugException extends VmException { public VmBugException( @Nullable String message, @Nullable Throwable cause, boolean isExternalMessage, - Object[] messageArguments, + @Nullable Object[] messageArguments, @Nullable BiConsumer messageBuilder, List programValues, @Nullable Node location, diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmBytes.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmBytes.java index 3fb908c6..c8c2520b 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmBytes.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmBytes.java @@ -22,11 +22,11 @@ import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.PrimitiveIterator; +import org.jspecify.annotations.Nullable; import org.pkl.core.DataSizeUnit; import org.pkl.core.ast.ByteConstantValueNode; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.util.ByteArrayUtils; -import org.pkl.core.util.Nullable; @ValueType public final class VmBytes extends VmValue implements Iterable { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java index 7d1e3880..59d8d20e 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java @@ -24,6 +24,7 @@ import java.util.*; import java.util.function.*; import javax.annotation.concurrent.GuardedBy; import org.graalvm.collections.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.Member.SourceLocation; import org.pkl.core.PClass; import org.pkl.core.PClassInfo; @@ -35,7 +36,6 @@ import org.pkl.core.ast.type.TypeNode; import org.pkl.core.util.CollectionUtils; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; // Most stdlib modules and their members are initialized in static initializers // and reused across Truffle contexts. @@ -60,31 +60,27 @@ public final class VmClass extends VmValue { @CompilationFinal private @Nullable TypeNode supertypeNode; @CompilationFinal private @Nullable VmClass superclass; - @LateInit @GuardedBy("allPropertiesLock") - private UnmodifiableEconomicMap __allProperties; + private @Nullable UnmodifiableEconomicMap __allProperties; private final Object allPropertiesLock = new Object(); - @LateInit @GuardedBy("allMethodsLock") - private UnmodifiableEconomicMap __allMethods; + private @Nullable UnmodifiableEconomicMap __allMethods; private final Object allMethodsLock = new Object(); // Element type is `Object` rather than `Identifier` to enable `contains(Object)` tests // (see signature of `UnmodifiableEconomicSet.contains()`). - @LateInit @GuardedBy("allRegularPropertyNamesLock") - private UnmodifiableEconomicSet __allRegularPropertyNames; + private @Nullable UnmodifiableEconomicSet __allRegularPropertyNames; private final Object allRegularPropertyNamesLock = new Object(); // Element type is `Object` rather than `Identifier` to enable `contains(Object)` tests // (see signature of `UnmodifiableEconomicSet.contains()`). - @LateInit @GuardedBy("allHiddenPropertyNamesLock") - private UnmodifiableEconomicSet __allHiddenPropertyNames; + private @Nullable UnmodifiableEconomicSet __allHiddenPropertyNames; private final Object allHiddenPropertyNamesLock = new Object(); @@ -240,8 +236,11 @@ public final class VmClass extends VmValue { * corresponding module. */ public VmTyped getModule() { - //noinspection ConstantConditions - return classInfo.isModuleClass() ? prototype : (VmTyped) prototype.getEnclosingOwner(); + if (classInfo.isModuleClass()) return prototype; + + var module = prototype.getEnclosingOwner(); + assert module != null; + return (VmTyped) module; } public VmTyped getModuleMirror() { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmContext.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmContext.java index 155de1e1..0a90d026 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmContext.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmContext.java @@ -22,6 +22,7 @@ import com.oracle.truffle.api.nodes.Node; import java.nio.file.Path; import java.util.HashMap; import java.util.Map; +import org.jspecify.annotations.Nullable; import org.pkl.core.Logger; import org.pkl.core.SecurityManager; import org.pkl.core.StackFrameTransformer; @@ -30,7 +31,6 @@ import org.pkl.core.http.HttpClient; import org.pkl.core.module.ProjectDependenciesManager; import org.pkl.core.packages.PackageResolver; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; public final class VmContext { private static final ContextReference REFERENCE = @@ -54,7 +54,7 @@ public final class VmContext { private final ResourceManager resourceManager; private final Logger logger; private final Map environmentVariables; - private final Path moduleCacheDir; + private final @Nullable Path moduleCacheDir; private final Map externalProperties; private final ModuleCache moduleCache; private final @Nullable PackageResolver packageResolver; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmDataSize.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmDataSize.java index a23ae322..698924ed 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmDataSize.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmDataSize.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,11 @@ import static java.util.Map.*; import com.oracle.truffle.api.CompilerDirectives.ValueType; import java.util.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.DataSize; import org.pkl.core.DataSizeUnit; import org.pkl.core.Value; import org.pkl.core.util.MathUtils; -import org.pkl.core.util.Nullable; @ValueType public final class VmDataSize extends VmValue implements Comparable { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmDuration.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmDuration.java index 655910fa..010486ef 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmDuration.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmDuration.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ package org.pkl.core.runtime; import com.oracle.truffle.api.CompilerDirectives.ValueType; import java.util.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.*; import org.pkl.core.util.DurationUtils; -import org.pkl.core.util.Nullable; @ValueType public final class VmDuration extends VmValue implements Comparable { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmEvalException.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmEvalException.java index 17bc1951..24a20d01 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmEvalException.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmEvalException.java @@ -21,16 +21,16 @@ import com.oracle.truffle.api.source.SourceSection; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; +import org.jspecify.annotations.Nullable; import org.pkl.core.StackFrame; import org.pkl.core.util.AnsiStringBuilder; -import org.pkl.core.util.Nullable; public class VmEvalException extends VmException { public VmEvalException( @Nullable String message, @Nullable Throwable cause, boolean isExternalMessage, - Object[] messageArguments, + @Nullable Object[] messageArguments, @Nullable BiConsumer messageBuilder, List programValues, @Nullable Node location, diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmException.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmException.java index f107273a..ade09e98 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmException.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmException.java @@ -23,13 +23,13 @@ import com.oracle.truffle.api.source.SourceSection; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; +import org.jspecify.annotations.Nullable; import org.pkl.core.*; import org.pkl.core.util.AnsiStringBuilder; -import org.pkl.core.util.Nullable; public abstract class VmException extends AbstractTruffleException { private final boolean isExternalMessage; - private final Object[] messageArguments; + private final @Nullable Object[] messageArguments; private final List programValues; private final @Nullable SourceSection sourceSection; private final @Nullable String memberName; @@ -41,7 +41,7 @@ public abstract class VmException extends AbstractTruffleException { @Nullable String message, @Nullable Throwable cause, boolean isExternalMessage, - Object[] messageArguments, + @Nullable Object[] messageArguments, @Nullable BiConsumer messageBuilder, List programValues, @Nullable Node location, @@ -50,6 +50,7 @@ public abstract class VmException extends AbstractTruffleException { @Nullable BiConsumer hintBuilder, Map insertedStackFrames) { super(message, cause, UNLIMITED_STACK_TRACE, location); + assert message != null || messageBuilder != null; this.messageBuilder = messageBuilder; this.isExternalMessage = isExternalMessage; this.messageArguments = messageArguments; @@ -64,7 +65,7 @@ public abstract class VmException extends AbstractTruffleException { return isExternalMessage; } - public final Object[] getMessageArguments() { + public final @Nullable Object[] getMessageArguments() { return messageArguments; } diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionBuilder.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionBuilder.java index 46321dde..267db257 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionBuilder.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionBuilder.java @@ -22,11 +22,11 @@ import java.util.*; import java.util.function.BiConsumer; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.jspecify.annotations.Nullable; import org.pkl.core.StackFrame; import org.pkl.core.runtime.MemberLookupSuggestions.Candidate.Kind; import org.pkl.core.runtime.VmException.ProgramValue; import org.pkl.core.util.AnsiStringBuilder; -import org.pkl.core.util.Nullable; /** * Error message guidelines: @@ -56,7 +56,7 @@ public final class VmExceptionBuilder { private @Nullable Object receiver; private @Nullable Map insertedStackFrames; - private VmException wrappedException; + private @Nullable VmException wrappedException; private @Nullable BiConsumer hintBuilder; public static class MultilineValue { @@ -94,7 +94,7 @@ public final class VmExceptionBuilder { private @Nullable Throwable cause; private VmException.Kind kind = VmException.Kind.EVAL_ERROR; private boolean isExternalMessage; - private Object[] messageArguments = new Object[0]; + private @Nullable Object[] messageArguments = new Object[0]; private final List programValues = new ArrayList<>(); private @Nullable Node location; private @Nullable SourceSection sourceSection; @@ -267,12 +267,12 @@ public final class VmExceptionBuilder { } // not internationalized - public VmExceptionBuilder bug(String message, Object... args) { + public VmExceptionBuilder bug(@Nullable String message, @Nullable Object... args) { kind = VmException.Kind.BUG; return withMessage(message, args); } - private VmExceptionBuilder withMessage(String message, Object... args) { + private VmExceptionBuilder withMessage(@Nullable String message, @Nullable Object... args) { this.message = message; messageArguments = args; isExternalMessage = false; @@ -280,7 +280,7 @@ public final class VmExceptionBuilder { return this; } - private VmExceptionBuilder withExternalMessage(String message, Object... args) { + private VmExceptionBuilder withExternalMessage(String message, @Nullable Object... args) { this.message = message; messageArguments = args; isExternalMessage = true; @@ -289,11 +289,11 @@ public final class VmExceptionBuilder { } // slow path, hence no need to cache anything (also resource bundles are cached by default) - public VmExceptionBuilder evalError(String messageKey, Object... args) { + public VmExceptionBuilder evalError(String messageKey, @Nullable Object... args) { return withExternalMessage(messageKey, args); } - public VmExceptionBuilder adhocEvalError(String message, Object... args) { + public VmExceptionBuilder adhocEvalError(@Nullable String message, @Nullable Object... args) { return withMessage(message, args); } @@ -329,12 +329,8 @@ public final class VmExceptionBuilder { return this; } - public VmExceptionBuilder withCause(Throwable cause) { + public VmExceptionBuilder withCause(@Nullable Throwable cause) { this.cause = cause; - if (this.message == null) { - var causeMessage = cause.getMessage(); - this.message = causeMessage == null ? "None (cause has no message)" : causeMessage; - } return this; } @@ -364,13 +360,18 @@ public final class VmExceptionBuilder { } public VmException build() { - if (message == null && messageBuilder == null) { - throw new IllegalStateException("No message set."); - } if (message != null && messageBuilder != null) { throw new IllegalStateException("Both message and messageBuilder are set"); } + if (message == null && messageBuilder == null) { + if (cause == null) { + throw new IllegalStateException("No message set."); + } + var causeMessage = cause.getMessage(); + message = causeMessage == null ? "None (cause has no message)" : causeMessage; + } + var effectiveInsertedStackFrames = insertedStackFrames == null ? new HashMap() : insertedStackFrames; return switch (kind) { @@ -414,20 +415,22 @@ public final class VmExceptionBuilder { memberName, hintBuilder, effectiveInsertedStackFrames); - case WRAPPED -> - new VmWrappedEvalException( - message, - cause, - isExternalMessage, - messageArguments, - messageBuilder, - programValues, - location, - sourceSection, - memberName, - hintBuilder, - effectiveInsertedStackFrames, - wrappedException); + case WRAPPED -> { + assert wrappedException != null; + yield new VmWrappedEvalException( + message, + cause, + isExternalMessage, + messageArguments, + messageBuilder, + programValues, + location, + sourceSection, + memberName, + hintBuilder, + effectiveInsertedStackFrames, + wrappedException); + } }; } diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionRenderer.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionRenderer.java index 6358f783..37e5f3c7 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionRenderer.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmExceptionRenderer.java @@ -19,11 +19,11 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; import org.pkl.core.Release; import org.pkl.core.util.AnsiStringBuilder; import org.pkl.core.util.AnsiTheme; import org.pkl.core.util.ErrorMessages; -import org.pkl.core.util.Nullable; public final class VmExceptionRenderer { private final @Nullable StackTraceRenderer stackTraceRenderer; @@ -80,35 +80,35 @@ public final class VmExceptionRenderer { } private void renderException(VmException exception, AnsiStringBuilder out, boolean withHeader) { - String message; - var hintBuilder = exception.getHintBuilder(); + @Nullable String message = null; @Nullable String hint = null; - if (exception.isExternalMessage()) { - var totalMessage = - ErrorMessages.create(exception.getMessage(), exception.getMessageArguments()); - // first paragraph is message, remainder is hint - var index = totalMessage.indexOf("\n\n"); - if (index != -1) { - message = totalMessage.substring(0, index); - hint = totalMessage.substring(index + 2); - } else { - message = totalMessage; - } - } else if (exception.getMessage() != null && exception.getMessageArguments().length != 0) { - message = String.format(exception.getMessage(), exception.getMessageArguments()); - } else { - message = exception.getMessage(); - } if (withHeader) { out.append(AnsiTheme.ERROR_HEADER, "–– Pkl Error ––").append('\n'); } if (exception.getMessageBuilder() != null) { - out.append( - AnsiTheme.ERROR_MESSAGE, - () -> exception.getMessageBuilder().accept(out, powerAssertions)); + var messageBuilder = exception.getMessageBuilder(); + out.append(AnsiTheme.ERROR_MESSAGE, () -> messageBuilder.accept(out, powerAssertions)); out.append('\n'); } else { + var exceptionMessage = exception.getMessage(); + assert exceptionMessage != null; // VmException has either message builder or message + var messageArguments = exception.getMessageArguments(); + if (exception.isExternalMessage()) { + var totalMessage = ErrorMessages.create(exceptionMessage, messageArguments); + // first paragraph is message, remainder is hint + var index = totalMessage.indexOf("\n\n"); + if (index != -1) { + message = totalMessage.substring(0, index); + hint = totalMessage.substring(index + 2); + } else { + message = totalMessage; + } + } else if (messageArguments.length != 0) { + message = String.format(exceptionMessage, messageArguments); + } else { + message = exceptionMessage; + } out.append(AnsiTheme.ERROR_MESSAGE, message).append('\n'); } @@ -142,6 +142,7 @@ public final class VmExceptionRenderer { hint = sb.toString().lines().map((it) -> ">\t" + it).collect(Collectors.joining("\n")); } + var hintBuilder = exception.getHintBuilder(); if (!frames.isEmpty()) { stackTraceRenderer.render(frames, hint, hintBuilder, out.append('\n')); } else if (hint != null) { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmFileDetector.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmFileDetector.java index 598b1e41..c9f66d5c 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmFileDetector.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmFileDetector.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.pkl.core.runtime; import java.nio.file.Path; import java.nio.file.spi.FileTypeDetector; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; public final class VmFileDetector extends FileTypeDetector { @Override diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmFunction.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmFunction.java index c3b13c0b..d0f6847a 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmFunction.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmFunction.java @@ -20,10 +20,10 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.frame.MaterializedFrame; import java.util.function.BiFunction; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.PklRootNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; public final class VmFunction extends VmObjectLike { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmIntSeq.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmIntSeq.java index 96ed547a..170ee391 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmIntSeq.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmIntSeq.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.ValueType; import java.util.NoSuchElementException; import java.util.PrimitiveIterator; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; // Some code copied from kotlin.ranges.Progressions, kotlin.ranges.ProgressionIterators, // kotlin.internal.ProgressionUtil (Apache 2). diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmLanguage.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmLanguage.java index a2ebbb77..4259505e 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmLanguage.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmLanguage.java @@ -22,11 +22,11 @@ import com.oracle.truffle.api.TruffleLanguage.ContextPolicy; import com.oracle.truffle.api.instrumentation.ProvidedTags; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.Source; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.builder.AstBuilder; import org.pkl.core.module.ModuleKey; import org.pkl.core.module.ResolvedModuleKey; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; import org.pkl.parser.Parser; import org.pkl.parser.ParserError; import org.pkl.parser.syntax.Module; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmList.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmList.java index 36b57c8a..5634c357 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmList.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmList.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.jspecify.annotations.Nullable; import org.organicdesign.fp.collections.UnmodCollection; import org.organicdesign.fp.collections.UnmodIterable; import org.pkl.core.ast.ConstantNode; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.runtime.Iterators.ReverseTruffleIterator; import org.pkl.core.runtime.Iterators.TruffleIterator; -import org.pkl.core.util.Nullable; import org.pkl.core.util.paguro.RrbTree; import org.pkl.core.util.paguro.RrbTree.ImRrbt; import org.pkl.core.util.paguro.RrbTree.MutRrbt; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmListing.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmListing.java index 7eed3b66..c0af13c0 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmListing.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmListing.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +20,10 @@ import com.oracle.truffle.api.frame.MaterializedFrame; import java.util.ArrayList; import java.util.List; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.member.ListingOrMappingTypeCastNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; public final class VmListing extends VmListingOrMapping { private static final class EmptyHolder { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmListingOrMapping.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmListingOrMapping.java index bb3b48c4..8898a930 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmListingOrMapping.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmListingOrMapping.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.nodes.IndirectCallNode; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.member.ListingOrMappingTypeCastNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.ast.type.TypeNode; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; public abstract class VmListingOrMapping extends VmObject { // reified type of listing elements and mapping values @@ -66,12 +66,15 @@ public abstract class VmListingOrMapping extends VmObject { // Avoids repeating the same type cast in some cases. @Nullable ListingOrMappingTypeCastNode nextTypeCastNode) { var newNextTypeCastNode = typeCastNode != null ? typeCastNode : nextTypeCastNode; - @SuppressWarnings("DataFlowIssue") - var result = - this == owner - ? value - : ((VmListingOrMapping) parent) - .executeTypeCasts(value, owner, callNode, member, newNextTypeCastNode); + Object result; + if (this == owner) { + result = value; + } else { + assert parent != null; + result = + ((VmListingOrMapping) parent) + .executeTypeCasts(value, owner, callNode, member, newNextTypeCastNode); + } if (typeCastNode == null || typeCastNode == nextTypeCastNode) return result; var callTarget = typeCastNode.getCallTarget(); try { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmMap.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmMap.java index 8a6b7ff2..7ad2de57 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmMap.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmMap.java @@ -19,13 +19,13 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import java.util.Iterator; import java.util.Map; import java.util.function.Consumer; +import org.jspecify.annotations.Nullable; import org.organicdesign.fp.collections.ImMap; import org.organicdesign.fp.collections.MutMap; import org.organicdesign.fp.collections.PersistentHashMap; import org.pkl.core.ast.ConstantNode; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.util.CollectionUtils; -import org.pkl.core.util.Nullable; import org.pkl.core.util.paguro.RrbTree; import org.pkl.core.util.paguro.RrbTree.ImRrbt; import org.pkl.core.util.paguro.RrbTree.MutRrbt; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmMapping.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmMapping.java index fe160ddb..eb80f303 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmMapping.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmMapping.java @@ -32,7 +32,8 @@ public final class VmMapping extends VmListingOrMapping { private long cachedLength = -1; @GuardedBy("this") - private @LateInit VmSet __allKeys; + @LateInit + private VmSet __allKeys; private static final class EmptyHolder { private static final VmMapping EMPTY = diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmNull.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmNull.java index 15704705..5eb0641b 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmNull.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmNull.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.pkl.core.runtime; import com.oracle.truffle.api.CompilerDirectives.ValueType; +import org.jspecify.annotations.Nullable; import org.pkl.core.PNull; -import org.pkl.core.util.Nullable; @ValueType public final class VmNull extends VmValue { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmObject.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmObject.java index 3987d9ac..73633bef 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmObject.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmObject.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ import java.util.*; import java.util.function.BiFunction; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.util.CollectionUtils; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; /** Corresponds to `pkl.base#Object`. */ public abstract class VmObject extends VmObjectLike { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmObjectLike.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmObjectLike.java index b6f087aa..67717eab 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmObjectLike.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmObjectLike.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.frame.MaterializedFrame; import java.util.function.BiFunction; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.member.ObjectMember; -import org.pkl.core.util.Nullable; /** * Corresponds to `pkl.base#Object|pkl.base#Function`. The lexical scope is a chain of diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmPair.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmPair.java index 480300e6..b9f1ceaa 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmPair.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmPair.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.ValueType; import java.util.Iterator; import java.util.NoSuchElementException; +import org.jspecify.annotations.Nullable; import org.pkl.core.Pair; -import org.pkl.core.util.Nullable; @ValueType public final class VmPair extends VmValue implements Iterable { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmRegex.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmRegex.java index d00ad238..0a17b03f 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmRegex.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmRegex.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.ValueType; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jspecify.annotations.Nullable; import org.pkl.core.ValueFormatter; -import org.pkl.core.util.Nullable; @ValueType public final class VmRegex extends VmValue { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmSet.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmSet.java index 31bbd249..4bbe1255 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmSet.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmSet.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.pkl.core.runtime; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import java.util.Iterator; import java.util.Set; +import org.jspecify.annotations.Nullable; import org.organicdesign.fp.collections.ImSet; import org.organicdesign.fp.collections.MutSet; import org.organicdesign.fp.collections.PersistentHashSet; @@ -26,7 +27,6 @@ import org.pkl.core.ast.ExpressionNode; import org.pkl.core.runtime.Iterators.ReverseTruffleIterator; import org.pkl.core.runtime.Iterators.TruffleIterator; import org.pkl.core.util.CollectionUtils; -import org.pkl.core.util.Nullable; import org.pkl.core.util.paguro.RrbTree; import org.pkl.core.util.paguro.RrbTree.ImRrbt; import org.pkl.core.util.paguro.RrbTree.MutRrbt; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmTypeAlias.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmTypeAlias.java index 8ed4889c..4a97079f 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmTypeAlias.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmTypeAlias.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; import javax.annotation.concurrent.GuardedBy; +import org.jspecify.annotations.Nullable; import org.pkl.core.Member.SourceLocation; import org.pkl.core.PClassInfo; import org.pkl.core.PObject; @@ -34,7 +35,6 @@ import org.pkl.core.ast.type.TypeNode.ConstrainedTypeNode; import org.pkl.core.ast.type.TypeNode.TypeVariableNode; import org.pkl.core.ast.type.TypeNode.UnknownTypeNode; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; public final class VmTypeAlias extends VmValue { private final SourceSection sourceSection; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java index a9e70938..e01741c3 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java @@ -21,6 +21,7 @@ import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.UnmodifiableEconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.Composite; import org.pkl.core.PModule; import org.pkl.core.PObject; @@ -29,7 +30,6 @@ import org.pkl.core.ast.expression.unary.ImportNode; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; public final class VmTyped extends VmObject { @CompilationFinal @LateInit private VmClass clazz; @@ -37,13 +37,20 @@ public final class VmTyped extends VmObject { public VmTyped( MaterializedFrame enclosingFrame, @Nullable VmTyped parent, - // null -> will be initialized using lateInitVmClass() later - @Nullable VmClass clazz, + VmClass clazz, UnmodifiableEconomicMap members) { super(enclosingFrame, parent, members); this.clazz = clazz; } + /** Constructs a VmTyped whose clazz will be initialized using lateInitVmClass() later. */ + public VmTyped( + MaterializedFrame enclosingFrame, + @Nullable VmTyped parent, + UnmodifiableEconomicMap members) { + super(enclosingFrame, parent, members); + } + public void lateInitVmClass(VmClass clazz) { assert this.clazz == null : "VmTyped.clazz has already been initialized."; this.clazz = clazz; diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmUndefinedValueException.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmUndefinedValueException.java index 0df25e43..f3584455 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmUndefinedValueException.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmUndefinedValueException.java @@ -23,9 +23,9 @@ import java.util.Deque; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; +import org.jspecify.annotations.Nullable; import org.pkl.core.StackFrame; import org.pkl.core.util.AnsiStringBuilder; -import org.pkl.core.util.Nullable; import org.pkl.parser.Lexer; public final class VmUndefinedValueException extends VmEvalException { @@ -35,7 +35,7 @@ public final class VmUndefinedValueException extends VmEvalException { @Nullable String message, @Nullable Throwable cause, boolean isExternalMessage, - Object[] messageArguments, + @Nullable Object[] messageArguments, @Nullable BiConsumer messageBuilder, List programValues, @Nullable Node location, @@ -65,6 +65,7 @@ public final class VmUndefinedValueException extends VmEvalException { if (hintBuilder != null) return this; var builder = new StringBuilder(); var memberKey = getMessageArguments()[0]; + assert memberKey != null; path.push(memberKey); builder.append("The above error occurred when rendering path `"); renderPath(builder, path); diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java index 880be9d9..bd696493 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java @@ -37,6 +37,7 @@ import java.util.regex.PatternSyntaxException; import java.util.stream.Collectors; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Engine; +import org.jspecify.annotations.Nullable; import org.organicdesign.fp.collections.ImMap; import org.pkl.core.FileOutput; import org.pkl.core.PClassInfo; @@ -60,7 +61,6 @@ import org.pkl.core.module.ModuleKey; import org.pkl.core.module.ModuleKeys; import org.pkl.core.module.ResolvedModuleKey; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; import org.pkl.parser.Parser; import org.pkl.parser.ParserError; import org.pkl.parser.syntax.Expr; @@ -95,12 +95,12 @@ public final class VmUtils { private VmUtils() {} static VmTyped createEmptyModule() { - return new VmTyped(createEmptyMaterializedFrame(), null, null, EconomicMaps.create()); + return new VmTyped(createEmptyMaterializedFrame(), null, EconomicMaps.create()); } @TruffleBoundary public static MaterializedFrame createEmptyMaterializedFrame() { - return Truffle.getRuntime().createMaterializedFrame(new Object[] {null, null}); + return Truffle.getRuntime().createMaterializedFrame(new @Nullable Object[] {null, null}); } public static Context createContext(Runnable initializer) { @@ -784,7 +784,9 @@ public final class VmUtils { } public static TypeNode[] resolveParameterTypes( - VirtualFrame frame, FrameDescriptor descriptor, UnresolvedTypeNode[] parameterTypeNodes) { + VirtualFrame frame, + FrameDescriptor descriptor, + @Nullable UnresolvedTypeNode[] parameterTypeNodes) { var resolvedNodes = new TypeNode[parameterTypeNodes.length]; @@ -939,7 +941,7 @@ public final class VmUtils { } @TruffleBoundary - public static V getMapValue(Map map, K key) { + public static @Nullable V getMapValue(Map map, K key) { return map.get(key); } diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmValue.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmValue.java index 2b0dee4d..2d1b9d17 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmValue.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmValue.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.pkl.core.runtime; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; public abstract class VmValue { public abstract VmClass getVmClass(); diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmValueTracker.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmValueTracker.java index a6944fcc..8e656845 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmValueTracker.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmValueTracker.java @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; public final class VmValueTracker implements AutoCloseable { diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/VmWrappedEvalException.java b/pkl-core/src/main/java/org/pkl/core/runtime/VmWrappedEvalException.java index 014dd21b..88ada6fa 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/VmWrappedEvalException.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/VmWrappedEvalException.java @@ -21,9 +21,9 @@ import com.oracle.truffle.api.source.SourceSection; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; +import org.jspecify.annotations.Nullable; import org.pkl.core.StackFrame; import org.pkl.core.util.AnsiStringBuilder; -import org.pkl.core.util.Nullable; public class VmWrappedEvalException extends VmEvalException { @@ -33,7 +33,7 @@ public class VmWrappedEvalException extends VmEvalException { @Nullable String message, @Nullable Throwable cause, boolean isExternalMessage, - Object[] messageArguments, + @Nullable Object[] messageArguments, @Nullable BiConsumer messageBuilder, List programValues, @Nullable Node location, diff --git a/pkl-core/src/main/java/org/pkl/core/runtime/package-info.java b/pkl-core/src/main/java/org/pkl/core/runtime/package-info.java index 91b25413..b6b25258 100644 --- a/pkl-core/src/main/java/org/pkl/core/runtime/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/runtime/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.runtime; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/service/package-info.java b/pkl-core/src/main/java/org/pkl/core/service/package-info.java new file mode 100644 index 00000000..9d06085d --- /dev/null +++ b/pkl-core/src/main/java/org/pkl/core/service/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package org.pkl.core.service; + +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/settings/PklSettings.java b/pkl-core/src/main/java/org/pkl/core/settings/PklSettings.java index 14226d82..8b54a1a5 100644 --- a/pkl-core/src/main/java/org/pkl/core/settings/PklSettings.java +++ b/pkl-core/src/main/java/org/pkl/core/settings/PklSettings.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.regex.Pattern; +import org.jspecify.annotations.Nullable; import org.pkl.core.*; import org.pkl.core.evaluatorSettings.PklEvaluatorSettings; import org.pkl.core.module.ModuleKeyFactories; @@ -26,7 +27,6 @@ import org.pkl.core.resource.ResourceReaders; import org.pkl.core.runtime.VmEvalException; import org.pkl.core.runtime.VmExceptionBuilder; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; /** * Java representation of a Pkl settings file. A Pkl settings file is a Pkl module amending the @@ -34,7 +34,7 @@ import org.pkl.core.util.Nullable; * {@code load} methods. */ // keep in sync with stdlib/settings.pkl -public record PklSettings(Editor editor, @Nullable PklEvaluatorSettings.Http http) { +public record PklSettings(Editor editor, PklEvaluatorSettings.@Nullable Http http) { private static final List ALLOWED_MODULES = List.of(Pattern.compile("pkl:"), Pattern.compile("file:")); diff --git a/pkl-core/src/main/java/org/pkl/core/settings/package-info.java b/pkl-core/src/main/java/org/pkl/core/settings/package-info.java index 80a1defe..a934ae5c 100644 --- a/pkl-core/src/main/java/org/pkl/core/settings/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/settings/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.settings; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/AbstractRenderer.java b/pkl-core/src/main/java/org/pkl/core/stdlib/AbstractRenderer.java index 4fedf8ff..2cfd6951 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/AbstractRenderer.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/AbstractRenderer.java @@ -19,6 +19,7 @@ import com.oracle.truffle.api.source.SourceSection; import java.util.ArrayDeque; import java.util.Deque; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.member.ClassProperty; import org.pkl.core.runtime.BaseModule; import org.pkl.core.runtime.Identifier; @@ -42,7 +43,6 @@ import org.pkl.core.runtime.VmValueConverter; import org.pkl.core.runtime.VmValueVisitor; import org.pkl.core.util.LateInit; import org.pkl.core.util.MutableBoolean; -import org.pkl.core.util.Nullable; public abstract class AbstractRenderer implements VmValueVisitor { diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/PklConverter.java b/pkl-core/src/main/java/org/pkl/core/stdlib/PklConverter.java index 53a225a9..036d23b0 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/PklConverter.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/PklConverter.java @@ -16,9 +16,9 @@ package org.pkl.core.stdlib; import java.util.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.member.ClassProperty; import org.pkl.core.runtime.*; -import org.pkl.core.util.Nullable; import org.pkl.core.util.Pair; public final class PklConverter implements VmValueConverter { diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/VmObjectFactory.java b/pkl-core/src/main/java/org/pkl/core/stdlib/VmObjectFactory.java index 0d89e5c5..e5d4c1d6 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/VmObjectFactory.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/VmObjectFactory.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import java.util.function.Supplier; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.VmModifier; import org.pkl.core.ast.member.ObjectMember; @@ -28,7 +29,6 @@ import org.pkl.core.ast.member.UntypedObjectMemberNode; import org.pkl.core.runtime.*; import org.pkl.core.util.EconomicMaps; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; public final class VmObjectFactory { private final Supplier classSupplier; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/analyze/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/analyze/package-info.java index b27066f8..1f9ec37f 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/analyze/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/analyze/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.analyze; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/base/CollectionNodes.java b/pkl-core/src/main/java/org/pkl/core/stdlib/base/CollectionNodes.java index 96a0e7ae..ba9f69d4 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/base/CollectionNodes.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/base/CollectionNodes.java @@ -17,6 +17,7 @@ package org.pkl.core.stdlib.base; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.PklNode; import org.pkl.core.ast.expression.binary.LessThanNode; import org.pkl.core.ast.expression.binary.LessThanNodeGen; @@ -27,7 +28,6 @@ import org.pkl.core.ast.lambda.ApplyVmFunction2NodeGen; import org.pkl.core.runtime.BaseModule; import org.pkl.core.runtime.VmFunction; import org.pkl.core.runtime.VmUtils; -import org.pkl.core.util.Nullable; public final class CollectionNodes { private CollectionNodes() {} diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/base/MergeSort.java b/pkl-core/src/main/java/org/pkl/core/stdlib/base/MergeSort.java index d7ad0e8e..4f8709d7 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/base/MergeSort.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/base/MergeSort.java @@ -16,9 +16,9 @@ package org.pkl.core.stdlib.base; import com.oracle.truffle.api.frame.VirtualFrame; +import org.jspecify.annotations.Nullable; import org.pkl.core.runtime.VmFunction; import org.pkl.core.stdlib.base.CollectionNodes.SortComparatorNode; -import org.pkl.core.util.Nullable; final class MergeSort { // must be a power of two diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/base/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/base/package-info.java index 423bc092..28fbce76 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/base/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/base/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.base; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/BenchmarkUtils.java b/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/BenchmarkUtils.java index 9b89449f..8e66c5a5 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/BenchmarkUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/BenchmarkUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ package org.pkl.core.stdlib.benchmark; import java.util.function.*; +import org.jspecify.annotations.Nullable; import org.pkl.core.DurationUnit; import org.pkl.core.runtime.*; import org.pkl.core.stdlib.VmObjectFactory; -import org.pkl.core.util.Nullable; final class BenchmarkUtils { private static final VmObjectFactory benchmarkResultFactory = diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/MicrobenchmarkNodes.java b/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/MicrobenchmarkNodes.java index 757e4144..5bb96c4e 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/MicrobenchmarkNodes.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/MicrobenchmarkNodes.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.source.SourceSection; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.PklRootNode; import org.pkl.core.ast.internal.BlackholeNode; @@ -32,7 +33,6 @@ import org.pkl.core.runtime.VmLanguage; import org.pkl.core.runtime.VmTyped; import org.pkl.core.runtime.VmUtils; import org.pkl.core.stdlib.ExternalMethod0Node; -import org.pkl.core.util.Nullable; public final class MicrobenchmarkNodes { public abstract static class run extends ExternalMethod0Node { diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/OutputBenchmarkNodes.java b/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/OutputBenchmarkNodes.java index 1bce83c1..d57b7ff8 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/OutputBenchmarkNodes.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/OutputBenchmarkNodes.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.io.IOException; import java.net.URI; import java.nio.file.Path; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; import org.pkl.core.externalreader.ExternalReaderProcessException; @@ -35,7 +36,6 @@ import org.pkl.core.runtime.VmTyped; import org.pkl.core.runtime.VmUtils; import org.pkl.core.stdlib.ExternalMethod0Node; import org.pkl.core.util.MutableReference; -import org.pkl.core.util.Nullable; public final class OutputBenchmarkNodes { public abstract static class run extends ExternalMethod0Node { diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/package-info.java index c25acb1a..75cbcec5 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/benchmark/package-info.java @@ -1,6 +1,6 @@ -@NonnullByDefault +@NullMarked @PklName("Benchmark") package org.pkl.core.stdlib.benchmark; +import org.jspecify.annotations.NullMarked; import org.pkl.core.stdlib.PklName; -import org.pkl.core.util.NonnullByDefault; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/json/ParserNodes.java b/pkl-core/src/main/java/org/pkl/core/stdlib/json/ParserNodes.java index c0fd2ae3..2ef74b24 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/json/ParserNodes.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/json/ParserNodes.java @@ -21,13 +21,13 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.IndirectCallNode; import java.util.*; import org.graalvm.collections.EconomicMap; +import org.jspecify.annotations.Nullable; import org.pkl.core.ast.VmModifier; import org.pkl.core.ast.member.ObjectMember; import org.pkl.core.runtime.*; import org.pkl.core.stdlib.ExternalMethod1Node; import org.pkl.core.stdlib.PklConverter; import org.pkl.core.util.EconomicMaps; -import org.pkl.core.util.Nullable; import org.pkl.core.util.json.JsonHandler; import org.pkl.core.util.json.JsonParser; import org.pkl.core.util.json.ParseException; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/json/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/json/package-info.java index dac2310a..01ebd5fc 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/json/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/json/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.json; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/jsonnet/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/jsonnet/package-info.java index b54a2ad7..53b331db 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/jsonnet/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/jsonnet/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.jsonnet; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/math/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/math/package-info.java index 1cbb47ef..546e7c67 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/math/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/math/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.math; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/package-info.java index a7704b4a..c1e97ab0 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/pklbinary/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/pklbinary/package-info.java index 0cb9238d..db6a8265 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/pklbinary/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/pklbinary/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.pklbinary; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/platform/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/platform/package-info.java index 19c705d5..92435835 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/platform/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/platform/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.platform; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/RendererNodes.java b/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/RendererNodes.java index 06b7b76e..6906324a 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/RendererNodes.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/RendererNodes.java @@ -21,6 +21,7 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.Optional; +import org.jspecify.annotations.Nullable; import org.pkl.core.DurationUnit; import org.pkl.core.ast.member.ClassProperty; import org.pkl.core.ast.member.PropertyTypeNode; @@ -67,7 +68,6 @@ import org.pkl.core.stdlib.AbstractStringRenderer; import org.pkl.core.stdlib.ExternalMethod1Node; import org.pkl.core.stdlib.PklConverter; import org.pkl.core.util.ArrayCharEscaper; -import org.pkl.core.util.Nullable; import org.pkl.core.util.json.JsonEscaper; public final class RendererNodes { diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/package-info.java index 4a829d41..e89583ef 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.protobuf; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/reflect/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/reflect/package-info.java index 4045ecca..04f59087 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/reflect/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/reflect/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.reflect; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/registry/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/registry/package-info.java index 860f7eb1..022698d4 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/registry/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/registry/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.registry; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/release/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/release/package-info.java index f1fd654b..f9a6e896 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/release/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/release/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.release; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/test/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/test/package-info.java index 88595890..a5ec70f1 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/test/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/test/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.test; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/test/report/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/test/report/package-info.java new file mode 100644 index 00000000..3727ce6b --- /dev/null +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/test/report/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package org.pkl.core.stdlib.test.report; + +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/xml/RendererNodes.java b/pkl-core/src/main/java/org/pkl/core/stdlib/xml/RendererNodes.java index a82e2e42..ae1f9b4c 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/xml/RendererNodes.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/xml/RendererNodes.java @@ -17,12 +17,12 @@ package org.pkl.core.stdlib.xml; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Specialization; +import org.jspecify.annotations.Nullable; import org.pkl.core.runtime.*; import org.pkl.core.stdlib.AbstractStringRenderer; import org.pkl.core.stdlib.ExternalMethod1Node; import org.pkl.core.stdlib.PklConverter; import org.pkl.core.util.ArrayCharEscaper; -import org.pkl.core.util.Nullable; import org.pkl.core.util.xml.XmlValidator; public final class RendererNodes { diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/xml/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/xml/package-info.java index 54c82a08..fc0a1a74 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/xml/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/xml/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.xml; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/stdlib/yaml/package-info.java b/pkl-core/src/main/java/org/pkl/core/stdlib/yaml/package-info.java index f10690f4..10acfed3 100644 --- a/pkl-core/src/main/java/org/pkl/core/stdlib/yaml/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/stdlib/yaml/package-info.java @@ -143,7 +143,7 @@ * *

END OF TERMS AND CONDITIONS */ -@NonnullByDefault +@NullMarked package org.pkl.core.stdlib.yaml; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/util/AbstractCharEscaper.java b/pkl-core/src/main/java/org/pkl/core/util/AbstractCharEscaper.java index e5d55e35..46af6a70 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/AbstractCharEscaper.java +++ b/pkl-core/src/main/java/org/pkl/core/util/AbstractCharEscaper.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package org.pkl.core.util; +import org.jspecify.annotations.Nullable; + public abstract class AbstractCharEscaper { protected abstract @Nullable String findReplacement(char ch); diff --git a/pkl-core/src/main/java/org/pkl/core/util/ArrayCharEscaper.java b/pkl-core/src/main/java/org/pkl/core/util/ArrayCharEscaper.java index 960d6174..d85f52cc 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/ArrayCharEscaper.java +++ b/pkl-core/src/main/java/org/pkl/core/util/ArrayCharEscaper.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.pkl.core.util; import java.util.*; +import org.jspecify.annotations.Nullable; public final class ArrayCharEscaper extends AbstractCharEscaper { private final char minEscape; diff --git a/pkl-core/src/main/java/org/pkl/core/util/CodeGeneratorUtils.java b/pkl-core/src/main/java/org/pkl/core/util/CodeGeneratorUtils.java index 05761ac2..56930f6c 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/CodeGeneratorUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/util/CodeGeneratorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.pkl.core.util; import java.util.Set; +import org.jspecify.annotations.Nullable; import org.pkl.core.PClassInfo; import org.pkl.core.PType; diff --git a/pkl-core/src/main/java/org/pkl/core/util/EconomicMaps.java b/pkl-core/src/main/java/org/pkl/core/util/EconomicMaps.java index 2bfe2e72..6e191d13 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/EconomicMaps.java +++ b/pkl-core/src/main/java/org/pkl/core/util/EconomicMaps.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.graalvm.collections.EconomicMap; import org.graalvm.collections.MapCursor; import org.graalvm.collections.UnmodifiableEconomicMap; import org.graalvm.collections.UnmodifiableMapCursor; +import org.jspecify.annotations.Nullable; /** * Puts {@link TruffleBoundary}s on {@link EconomicMap} methods and provides some added diff --git a/pkl-core/src/main/java/org/pkl/core/util/ErrorMessages.java b/pkl-core/src/main/java/org/pkl/core/util/ErrorMessages.java index 7ce934bc..a17ff3dd 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/ErrorMessages.java +++ b/pkl-core/src/main/java/org/pkl/core/util/ErrorMessages.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,12 @@ import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; import java.util.stream.*; +import org.jspecify.annotations.Nullable; public final class ErrorMessages { private ErrorMessages() {} - public static String create(String messageName, Object... args) { + public static String create(String messageName, @Nullable Object... args) { var locale = Locale.getDefault(); String errorMessage = ResourceBundle.getBundle("org.pkl.core.errorMessages", locale).getString(messageName); @@ -35,7 +36,7 @@ public final class ErrorMessages { return formatter.format(args); } - public static String createIndented(String messageName, String indent, Object... args) { + public static String createIndented(String messageName, String indent, @Nullable Object... args) { return create(messageName, args) .lines() .map((msg) -> indent + msg) diff --git a/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java b/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java index e5f4449a..121d9d07 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java +++ b/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.jspecify.annotations.Nullable; import org.pkl.core.PklBugException; import org.pkl.core.SecurityManager; import org.pkl.core.SecurityManagerException; @@ -534,10 +535,14 @@ public final class GlobResolver { var regexPattern = toRegexPattern(globPattern); // using "dummy" to make this a legitimate URI. The scheme specific part of the URI should be // ignored by the reader. - var globUri = - hasAbsoluteGlob - ? URI.create(globPattern) - : URI.create(enclosingUri.getScheme() + ":dummy"); + URI globUri; + if (hasAbsoluteGlob) { + globUri = URI.create(globPattern); + } else { + //noinspection ConstantValue (assertion required by NullAway) + assert enclosingUri != null; + globUri = URI.create(enclosingUri.getScheme() + ":dummy"); + } resolveOpaqueGlob(securityManager, reader, globUri, regexPattern, result); } return result; diff --git a/pkl-core/src/main/java/org/pkl/core/util/ImportGraphUtils.java b/pkl-core/src/main/java/org/pkl/core/util/ImportGraphUtils.java index 1010513e..345e429b 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/ImportGraphUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/util/ImportGraphUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.pkl.core.util; import java.net.URI; import java.util.ArrayList; import java.util.List; +import org.jspecify.annotations.Nullable; import org.pkl.core.ImportGraph; public class ImportGraphUtils { @@ -42,6 +43,7 @@ public class ImportGraphUtils { private static @Nullable List doFindCycle( URI currentUri, ImportGraph importGraph, List path) { var imports = importGraph.imports().get(currentUri); + assert imports != null; var startingUri = path.get(0); for (var imprt : imports) { var uri = imprt.uri(); diff --git a/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java b/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java index 61bcc5f6..952abf5b 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/util/IoUtils.java @@ -34,6 +34,7 @@ import java.util.*; import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import org.jspecify.annotations.Nullable; import org.pkl.core.PklBugException; import org.pkl.core.Platform; import org.pkl.core.SecurityManager; diff --git a/pkl-core/src/main/java/org/pkl/core/util/LateInit.java b/pkl-core/src/main/java/org/pkl/core/util/LateInit.java index 704e51cd..08fe5957 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/LateInit.java +++ b/pkl-core/src/main/java/org/pkl/core/util/LateInit.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,20 +19,17 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.annotation.Nonnull; -import javax.annotation.meta.TypeQualifierNickname; -import javax.annotation.meta.When; +import org.jspecify.annotations.Nullable; /** * Indicates that the annotated field is initially {@code null} and initialized to a non-null value * before or upon first use. Corresponds to {@code lateinit} in Kotlin (but does not result in - * automatic runtime non-null checks). + * automatic runtime non-null checks). This is not a nullness annotation; NullAway is configured to + * exempt fields annotated with {@code LateInit} from constructor initialization checks. * *

Note: Fields that are initialized late to a nullable value should only be annotated with * {@link Nullable} (same as in Kotlin). */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) -@Nonnull(when = When.UNKNOWN) -@TypeQualifierNickname public @interface LateInit {} diff --git a/pkl-core/src/main/java/org/pkl/core/util/MathUtils.java b/pkl-core/src/main/java/org/pkl/core/util/MathUtils.java index 3cf65fb4..c060f020 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/MathUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/util/MathUtils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.pkl.core.util; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import java.math.RoundingMode; +import org.jspecify.annotations.Nullable; public final class MathUtils { private static final long FLOOR_SQRT_MAX_LONG = 3037000499L; diff --git a/pkl-core/src/main/java/org/pkl/core/util/MutableReference.java b/pkl-core/src/main/java/org/pkl/core/util/MutableReference.java index 42f6bdd3..4e59216a 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/MutableReference.java +++ b/pkl-core/src/main/java/org/pkl/core/util/MutableReference.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.pkl.core.util; import java.util.concurrent.atomic.AtomicReference; +import org.jspecify.annotations.Nullable; /** * A mutable reference in a box. If you need a thread-safe box, use {@link AtomicReference} instead. diff --git a/pkl-core/src/main/java/org/pkl/core/util/Nonnull.java b/pkl-core/src/main/java/org/pkl/core/util/Nonnull.java deleted file mode 100644 index 31ffc5e0..00000000 --- a/pkl-core/src/main/java/org/pkl/core/util/Nonnull.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pkl.core.util; - -import java.lang.annotation.*; -import javax.annotation.meta.TypeQualifierNickname; -import javax.annotation.meta.When; - -@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@javax.annotation.Nonnull(when = When.ALWAYS) -@TypeQualifierNickname -public @interface Nonnull {} diff --git a/pkl-core/src/main/java/org/pkl/core/util/NonnullByDefault.java b/pkl-core/src/main/java/org/pkl/core/util/NonnullByDefault.java deleted file mode 100644 index bdb83de4..00000000 --- a/pkl-core/src/main/java/org/pkl/core/util/NonnullByDefault.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pkl.core.util; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import javax.annotation.meta.TypeQualifierDefault; - -/** - * Indicates that method return types and method parameters in the annotated package are {@link - * Nonnull} unless explicitly annotated with {@link Nullable}. - * - *

This annotation is a generalization of {@link javax.annotation.ParametersAreNonnullByDefault}. - * All Pkl packages containing Java code should carry this annotation. - * - *

Ideally, this default would apply to every {@link ElementType#TYPE_USE}, but I haven't been - * able to make this work reasonably in IntelliJ. - */ -@Documented -@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE_PARAMETER}) -@javax.annotation.Nonnull -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PACKAGE) -public @interface NonnullByDefault {} diff --git a/pkl-core/src/main/java/org/pkl/core/util/Nullable.java b/pkl-core/src/main/java/org/pkl/core/util/Nullable.java deleted file mode 100644 index 2d35d31f..00000000 --- a/pkl-core/src/main/java/org/pkl/core/util/Nullable.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pkl.core.util; - -import static javax.annotation.meta.When.MAYBE; - -import java.lang.annotation.*; -import javax.annotation.meta.TypeQualifierNickname; - -@Target({ - ElementType.TYPE_PARAMETER, - ElementType.TYPE_USE, - ElementType.PARAMETER, - ElementType.FIELD, - ElementType.METHOD -}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@javax.annotation.Nonnull(when = MAYBE) -@TypeQualifierNickname -public @interface Nullable {} diff --git a/pkl-core/src/main/java/org/pkl/core/util/Pair.java b/pkl-core/src/main/java/org/pkl/core/util/Pair.java index 9bc94600..8fddfdee 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/Pair.java +++ b/pkl-core/src/main/java/org/pkl/core/util/Pair.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.pkl.core.util; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.ValueType; +import org.jspecify.annotations.Nullable; @ValueType public final class Pair { diff --git a/pkl-core/src/main/java/org/pkl/core/util/json/Json.java b/pkl-core/src/main/java/org/pkl/core/util/json/Json.java index e64cf34f..b20c50c7 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/json/Json.java +++ b/pkl-core/src/main/java/org/pkl/core/util/json/Json.java @@ -25,9 +25,9 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Set; +import org.jspecify.annotations.Nullable; import org.pkl.core.Version; import org.pkl.core.util.ErrorMessages; -import org.pkl.core.util.Nullable; /** * Parser for JSON. @@ -85,7 +85,7 @@ public final class Json { } var ret = handler.value; if (!(ret instanceof JsObject jsObject)) { - throw new FormatException("object", ret.getClass()); + throw new FormatException("object", ret == null ? Void.class : ret.getClass()); } return jsObject; } @@ -156,7 +156,7 @@ public final class Json { } private static class Handler extends JsonHandler { - Object value; + @Nullable Object value; @Override public void endString(String string) { @@ -188,12 +188,14 @@ public final class Json { } @Override - public void endArrayValue(JsArray array) { + public void endArrayValue(@Nullable JsArray array) { + assert array != null; array.add(value); } @Override - public void endArray(JsArray array) { + public void endArray(@Nullable JsArray array) { + assert array != null; value = array; } @@ -203,18 +205,20 @@ public final class Json { } @Override - public void endObjectValue(JsObject object, String name) { + public void endObjectValue(@Nullable JsObject object, String name) { + assert object != null; object.put(name, value); } @Override - public void endObject(JsObject object) { + public void endObject(@Nullable JsObject object) { + assert object != null; value = object; } } - public static class JsObject implements Map { - private final Map delegate; + public static class JsObject implements Map { + private final Map delegate; public JsObject() { this.delegate = new HashMap<>(); @@ -362,17 +366,17 @@ public final class Json { } @Override - public @Nullable Object put(String key, Object value) { + public @Nullable Object put(String key, @Nullable Object value) { return delegate.put(key, value); } @Override - public Object remove(Object key) { + public @Nullable Object remove(Object key) { return delegate.remove(key); } @Override - public void putAll(Map m) { + public void putAll(Map m) { delegate.putAll(m); } @@ -387,12 +391,12 @@ public final class Json { } @Override - public Collection values() { + public Collection<@Nullable Object> values() { return delegate.values(); } @Override - public Set> entrySet() { + public Set> entrySet() { return delegate.entrySet(); } @@ -402,8 +406,8 @@ public final class Json { } } - public static class JsArray implements List { - private final List delegate; + public static class JsArray implements List<@Nullable Object> { + private final List<@Nullable Object> delegate; public JsArray() { this.delegate = new ArrayList<>(); @@ -429,7 +433,7 @@ public final class Json { } @Override - public Iterator iterator() { + public Iterator<@Nullable Object> iterator() { return delegate.iterator(); } @@ -444,7 +448,7 @@ public final class Json { } @Override - public boolean add(Object o) { + public boolean add(@Nullable Object o) { return delegate.add(o); } @@ -490,17 +494,17 @@ public final class Json { } @Override - public Object set(int index, Object element) { + public @Nullable Object set(int index, @Nullable Object element) { return delegate.set(index, element); } @Override - public void add(int index, Object element) { + public void add(int index, @Nullable Object element) { delegate.add(index, element); } @Override - public Object remove(int index) { + public @Nullable Object remove(int index) { return delegate.remove(index); } @@ -515,17 +519,17 @@ public final class Json { } @Override - public ListIterator listIterator() { + public ListIterator<@Nullable Object> listIterator() { return delegate.listIterator(); } @Override - public ListIterator listIterator(int index) { + public ListIterator<@Nullable Object> listIterator(int index) { return delegate.listIterator(index); } @Override - public List subList(int fromIndex, int toIndex) { + public List<@Nullable Object> subList(int fromIndex, int toIndex) { return delegate.subList(fromIndex, toIndex); } diff --git a/pkl-core/src/main/java/org/pkl/core/util/json/JsonEscaper.java b/pkl-core/src/main/java/org/pkl/core/util/json/JsonEscaper.java index 00606cc1..a2451e80 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/json/JsonEscaper.java +++ b/pkl-core/src/main/java/org/pkl/core/util/json/JsonEscaper.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ */ package org.pkl.core.util.json; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.AbstractCharEscaper; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; public final class JsonEscaper extends AbstractCharEscaper { /* diff --git a/pkl-core/src/main/java/org/pkl/core/util/json/JsonHandler.java b/pkl-core/src/main/java/org/pkl/core/util/json/JsonHandler.java index 8f6918bd..8584875e 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/json/JsonHandler.java +++ b/pkl-core/src/main/java/org/pkl/core/util/json/JsonHandler.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ */ package org.pkl.core.util.json; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.LateInit; -import org.pkl.core.util.Nullable; /** * A handler for parser events. Instances of this class can be given to a {@link JsonParser}. The diff --git a/pkl-core/src/main/java/org/pkl/core/util/json/JsonWriter.java b/pkl-core/src/main/java/org/pkl/core/util/json/JsonWriter.java index 70b69e17..d523be44 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/json/JsonWriter.java +++ b/pkl-core/src/main/java/org/pkl/core/util/json/JsonWriter.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import java.io.Flushable; import java.io.IOException; import java.io.Writer; import java.util.*; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** * Writes a JSON (RFC 7159) encoded value to a diff --git a/pkl-core/src/main/java/org/pkl/core/util/json/Location.java b/pkl-core/src/main/java/org/pkl/core/util/json/Location.java index cf9e9c39..9db877e3 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/json/Location.java +++ b/pkl-core/src/main/java/org/pkl/core/util/json/Location.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.pkl.core.util.json; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; /** An immutable object that represents a location in the parsed text. */ public final class Location { diff --git a/pkl-core/src/main/java/org/pkl/core/util/json/package-info.java b/pkl-core/src/main/java/org/pkl/core/util/json/package-info.java index 95e21fea..c0fe61b2 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/json/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/util/json/package-info.java @@ -40,7 +40,7 @@ * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ -@NonnullByDefault +@NullMarked package org.pkl.core.util.json; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/util/package-info.java b/pkl-core/src/main/java/org/pkl/core/util/package-info.java index 15571ee9..d3afd41d 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/util/package-info.java @@ -190,5 +190,7 @@ * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ -@NonnullByDefault +@NullMarked package org.pkl.core.util; + +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/util/paguro/RrbTree.java b/pkl-core/src/main/java/org/pkl/core/util/paguro/RrbTree.java index 660c38a4..ca81478c 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/paguro/RrbTree.java +++ b/pkl-core/src/main/java/org/pkl/core/util/paguro/RrbTree.java @@ -22,6 +22,7 @@ import static org.organicdesign.fp.indent.IndentUtils.indentSpace; import java.io.*; import java.util.Arrays; import java.util.List; +import org.jspecify.annotations.Nullable; import org.organicdesign.fp.collections.BaseList; import org.organicdesign.fp.collections.ImList; import org.organicdesign.fp.collections.MutList; @@ -34,7 +35,6 @@ import org.organicdesign.fp.indent.Indented; import org.organicdesign.fp.oneOf.Option; import org.organicdesign.fp.tuple.Tuple2; import org.organicdesign.fp.tuple.Tuple4; -import org.pkl.core.util.Nullable; /** * An RRB Tree is an immutable List (like Clojure's PersistentVector) that also supports random diff --git a/pkl-core/src/main/java/org/pkl/core/util/paguro/package-info.java b/pkl-core/src/main/java/org/pkl/core/util/paguro/package-info.java index 772c5240..2486eff2 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/paguro/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/util/paguro/package-info.java @@ -24,7 +24,7 @@ *

See the License for the specific language governing permissions and limitations under the * License. */ -@NonnullByDefault +@NullMarked package org.pkl.core.util.paguro; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/util/pklbinary/PklBinaryCode.java b/pkl-core/src/main/java/org/pkl/core/util/pklbinary/PklBinaryCode.java index a4004085..6a969d1e 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/pklbinary/PklBinaryCode.java +++ b/pkl-core/src/main/java/org/pkl/core/util/pklbinary/PklBinaryCode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.pkl.core.util.pklbinary; -import org.pkl.core.util.Nullable; +import org.jspecify.annotations.Nullable; public enum PklBinaryCode { OBJECT((byte) 0x01), diff --git a/pkl-core/src/main/java/org/pkl/core/util/pklbinary/package-info.java b/pkl-core/src/main/java/org/pkl/core/util/pklbinary/package-info.java index 4d4dc22a..a40bb336 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/pklbinary/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/util/pklbinary/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.util.pklbinary; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/util/properties/package-info.java b/pkl-core/src/main/java/org/pkl/core/util/properties/package-info.java new file mode 100644 index 00000000..ff37a861 --- /dev/null +++ b/pkl-core/src/main/java/org/pkl/core/util/properties/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package org.pkl.core.util.properties; + +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/util/xml/package-info.java b/pkl-core/src/main/java/org/pkl/core/util/xml/package-info.java index 44541779..d2108d44 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/xml/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/util/xml/package-info.java @@ -163,7 +163,7 @@ * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ -@NonnullByDefault +@NullMarked package org.pkl.core.util.xml; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/util/yaml/YamlEscaper.java b/pkl-core/src/main/java/org/pkl/core/util/yaml/YamlEscaper.java index afd32482..d2aaace6 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/yaml/YamlEscaper.java +++ b/pkl-core/src/main/java/org/pkl/core/util/yaml/YamlEscaper.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ */ package org.pkl.core.util.yaml; +import org.jspecify.annotations.Nullable; import org.pkl.core.util.AbstractCharEscaper; import org.pkl.core.util.IoUtils; -import org.pkl.core.util.Nullable; /** * Emits escape sequences for YAML. This is only used when emitting double-quoted strings. diff --git a/pkl-core/src/main/java/org/pkl/core/util/yaml/package-info.java b/pkl-core/src/main/java/org/pkl/core/util/yaml/package-info.java index 7e4895ee..2045e69d 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/yaml/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/util/yaml/package-info.java @@ -1,4 +1,4 @@ -@NonnullByDefault +@NullMarked package org.pkl.core.util.yaml; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/main/java/org/pkl/core/util/yaml/snake/package-info.java b/pkl-core/src/main/java/org/pkl/core/util/yaml/snake/package-info.java index a48678f2..172abc3b 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/yaml/snake/package-info.java +++ b/pkl-core/src/main/java/org/pkl/core/util/yaml/snake/package-info.java @@ -143,7 +143,7 @@ * *

END OF TERMS AND CONDITIONS */ -@NonnullByDefault +@NullMarked package org.pkl.core.util.yaml.snake; -import org.pkl.core.util.NonnullByDefault; +import org.jspecify.annotations.NullMarked; diff --git a/pkl-core/src/test/kotlin/org/pkl/core/externalreader/ExternalReaderClient.kt b/pkl-core/src/test/kotlin/org/pkl/core/externalreader/ExternalReaderClient.kt index da61420f..054edcc7 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/externalreader/ExternalReaderClient.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/externalreader/ExternalReaderClient.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,13 @@ package org.pkl.core.externalreader import java.io.IOException +import org.jspecify.annotations.Nullable import org.pkl.core.externalreader.ExternalReaderMessages.* import org.pkl.core.messaging.Message import org.pkl.core.messaging.MessageTransport import org.pkl.core.messaging.Messages import org.pkl.core.messaging.Messages.* import org.pkl.core.messaging.ProtocolException -import org.pkl.core.util.Nullable /** An implementation of the client side of the external reader flow */ class ExternalReaderClient( diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/Util.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/Util.kt index 48b02625..7f4fd8b4 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/Util.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/Util.kt @@ -136,6 +136,6 @@ fun OutputStream.write(str: String) = write(str.toByteArray(Charsets.UTF_8)) fun OutputStream.writeLine(str: String) = write((str + "\n").toByteArray(Charsets.UTF_8)) -operator fun org.pkl.core.util.Pair.component1(): A = first +operator fun org.pkl.core.util.Pair.component1(): A = first -operator fun org.pkl.core.util.Pair.component2(): B = second +operator fun org.pkl.core.util.Pair.component2(): B = second diff --git a/pkl-executor/src/main/java/org/pkl/executor/spi/v1/ExecutorSpiException.java b/pkl-executor/src/main/java/org/pkl/executor/spi/v1/ExecutorSpiException.java index 2f3c3a2e..c631149b 100644 --- a/pkl-executor/src/main/java/org/pkl/executor/spi/v1/ExecutorSpiException.java +++ b/pkl-executor/src/main/java/org/pkl/executor/spi/v1/ExecutorSpiException.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,10 @@ */ package org.pkl.executor.spi.v1; +import org.jspecify.annotations.Nullable; + public final class ExecutorSpiException extends RuntimeException { - public ExecutorSpiException(String message, Throwable cause) { + public ExecutorSpiException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } }